X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;ds=sidebyside;f=include%2Fmodules%2Fdns.h;h=1ba54cc616375fcfed8d4d26b75b25607b617d77;hb=932748db6dd2a7225c9f12bc34339fcb2f37c319;hp=7f863fcca3cdaf1a3bdda06b932926d800dd1379;hpb=5ac1ffce1168c4e3409e6667ff30285bfbc82bde;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/include/modules/dns.h b/include/modules/dns.h index 7f863fcca..1ba54cc61 100644 --- a/include/modules/dns.h +++ b/include/modules/dns.h @@ -57,6 +57,7 @@ namespace DNS ERROR_UNKNOWN, ERROR_UNLOADED, ERROR_TIMEDOUT, + ERROR_MALFORMED, ERROR_NOT_AN_ANSWER, ERROR_NONSTANDARD_QUERY, ERROR_FORMAT_ERROR, @@ -68,13 +69,9 @@ namespace DNS ERROR_INVALIDTYPE }; - const int PORT = 53; + typedef uint16_t RequestId; - /** - * The maximum value of a dns request id, - * 16 bits wide, 0xFFFF. - */ - const int MAX_REQUEST_ID = 0xFFFF; + const int PORT = 53; class Exception : public ModuleException { @@ -86,11 +83,11 @@ namespace DNS { std::string name; QueryType type; - unsigned short qclass; - Question() : type(QUERY_NONE), qclass(0) { } - Question(const std::string& n, QueryType t, unsigned short c = 1) : name(n), type(t), qclass(c) { } - inline bool operator==(const Question& other) const { return name == other.name && type == other.type && qclass == other.qclass; } + Question() : type(QUERY_NONE) { } + Question(const std::string& n, QueryType t) : name(n), type(t) { } + bool operator==(const Question& other) const { return ((name == other.name) && (type == other.type)); } + bool operator!=(const Question& other) const { return (!(*this == other)); } struct hash { @@ -107,19 +104,19 @@ namespace DNS std::string rdata; time_t created; - ResourceRecord(const std::string& n, QueryType t, unsigned short c = 1) : Question(n, t, c), ttl(0), created(ServerInstance->Time()) { } + ResourceRecord(const std::string& n, QueryType t) : Question(n, t), ttl(0), created(ServerInstance->Time()) { } ResourceRecord(const Question& question) : Question(question), ttl(0), created(ServerInstance->Time()) { } }; struct Query { - std::vector questions; + Question question; std::vector answers; Error error; bool cached; Query() : error(ERROR_NONE), cached(false) { } - Query(const Question& question) : error(ERROR_NONE), cached(false) { questions.push_back(question); } + Query(const Question& q) : question(q), error(ERROR_NONE), cached(false) { } }; class ReplySocket; @@ -147,19 +144,18 @@ namespace DNS /* Use result cache if available */ bool use_cache; /* Request id */ - unsigned short id; + RequestId id; /* Creator of this request */ Module* const creator; Request(Manager* mgr, Module* mod, const std::string& addr, QueryType qt, bool usecache = true) - : Timer((ServerInstance->Config->dns_timeout ? ServerInstance->Config->dns_timeout : 5), ServerInstance->Time()) + : Timer((ServerInstance->Config->dns_timeout ? ServerInstance->Config->dns_timeout : 5)) , Question(addr, qt) , manager(mgr) , use_cache(usecache) , id(0) , creator(mod) { - ServerInstance->Timers->AddTimer(this); } virtual ~Request()