00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00041 #ifndef OW32_AsyncResolverOptions_h
00042 #define OW32_AsyncResolverOptions_h
00043
00044 #include <OW32/AsyncResolverError.h>
00045 #include <OW32/tstl.h>
00046 #include <vector>
00047 #include <string>
00048
00049 namespace OW32
00050 {
00051
00055 struct apattern
00056 {
00057 struct in_addr addr;
00058 struct in_addr mask;
00059 };
00060
00061 #ifdef _MSC_VER
00062 #pragma warning(disable: 4251)
00063 #endif
00064
00068 class OW32_LIB_EXPORT CAsyncResolverOptions
00069 {
00070 public:
00076 CAsyncResolverOptions();
00077
00087 AsyncResolverError init(const TCHAR *confPath = NULL);
00088
00090 AsyncResolverError setSearch(const char *domain_list);
00091
00093 AsyncResolverError setDomain(const char *domain);
00094
00096 const std::vector<std::string> &getSearch() const { return m_domains; }
00097
00103 AsyncResolverError setLookup(const char *lookups);
00104
00106 const std::string &getLookup() const { return m_lookups; }
00107
00109 AsyncResolverError setNameServer(const char *ns);
00110
00112 void clearNameServers() { m_servers.clear(); }
00113
00115 const std::vector<in_addr> &getServers() const { return m_servers; }
00116
00123 AsyncResolverError setSortList(const char *sl);
00124
00126 const std::vector<apattern> getSortList() const { return m_sortlist; }
00127
00131 void setHostsPath(const TCHAR *path);
00132
00134 const std::_tstring &getHostsPath() const { return m_hosts_path; }
00135
00140 void setDots(int ndots) { m_ndots = ndots; }
00141
00145 int getDots() const { return m_ndots; }
00146
00150 void setTries(int tries) { m_tries = tries; }
00151
00155 const int getTries() const { return m_tries; }
00156
00160 void setTimeout(int timeout) { m_timeout = timeout; }
00161
00165 const int getTimeout() const { return m_timeout; }
00166
00170 void setUDPPort(unsigned short udp_port) { m_udp_port = udp_port; }
00171
00173 const unsigned short getUDPPort() const { return m_udp_port; }
00174
00175
00176
00177
00178 void setTCPPort(unsigned short tcp_port) { m_tcp_port = tcp_port; }
00179
00181 const unsigned short getTCPPort() const { return m_tcp_port; }
00182
00184 enum OptionFlagValues
00185 {
00187 ARES_FLAG_USEVC = (1 << 0),
00189 ARES_FLAG_PRIMARY = (1 << 1),
00191 ARES_FLAG_IGNTC = (1 << 2),
00193 ARES_FLAG_NORECURSE = (1 << 3),
00195 ARES_FLAG_STAYOPEN = (1 << 4),
00197 ARES_FLAG_NOSEARCH = (1 << 5),
00199 ARES_FLAG_NOALIASES = (1 << 6),
00201 ARES_FLAG_NOCHECKRESP = (1 << 7)
00202 };
00203
00209 void setFlags(int flags) { m_flags = flags; }
00210
00214 const int getFlags() const { return m_flags; }
00215
00216 private:
00220 AsyncResolverError initByEnvironment();
00221
00226 AsyncResolverError initByConf(const TCHAR *confPath = NULL);
00227
00231 AsyncResolverError initByIPHelper();
00232
00236 AsyncResolverError initByRegistry();
00237
00241 AsyncResolverError initByDefaults();
00242
00246 AsyncResolverError setOptions(const char *opt);
00247
00249 int m_flags;
00251 int m_timeout;
00253 int m_tries;
00255 int m_ndots;
00257 unsigned short m_udp_port;
00259 unsigned short m_tcp_port;
00261 std::vector<in_addr> m_servers;
00263 std::vector<std::string> m_domains;
00265 std::vector<apattern> m_sortlist;
00267 std::string m_lookups;
00269 std::_tstring m_hosts_path;
00271 bool m_fSetServers;
00273 bool m_fSetSearch;
00275 bool m_fSetSort;
00276 };
00277
00278 #ifdef _MSC_VER
00279 #pragma warning(default: 4251)
00280 #endif
00281
00282 }
00283
00284 #endif // OW32_AsyncResolverOptions_h