From: Bert Hubert Date: Thu, 16 Jan 2003 17:24:36 +0000 (+0000) Subject: recursor work, alignment issues X-Git-Tag: pdns-2.9.5~8 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7b35aa49a8d56d4cb5c57a904ea8a15f44ca637b;p=pdns recursor work, alignment issues git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@137 d19b8d6e-7fed-0310-83ef-9ca221ded41b --- diff --git a/pdns/Makefile.am b/pdns/Makefile.am index 45edf65a0..8aa16833e 100644 --- a/pdns/Makefile.am +++ b/pdns/Makefile.am @@ -35,7 +35,7 @@ backends/bind/bindbackend.cc backends/bind/zoneparser2.cc \ backends/bind/bindparser.cc backends/bind/bindlexer.c \ backends/bind/huffman.cc backends/gsql/gsqlbackend.cc \ backends/gsql/gsqlbackend.hh backends/gsql/ssql.hh \ -sillyrecords.cc recbcomm.hh recbcomm.cc +sillyrecords.cc # pdns_server_LDFLAGS= @moduleobjects@ @modulelibs@ @DYNLINKFLAGS@ @LIBDL@ @THREADFLAGS@ diff --git a/pdns/misc.cc b/pdns/misc.cc index de5ded5b2..70e671fe4 100644 --- a/pdns/misc.cc +++ b/pdns/misc.cc @@ -313,10 +313,14 @@ void cleanSlashes(string &str) str=out; } + const string sockAddrToString(struct sockaddr_in *remote, Utility::socklen_t socklen) { - if(socklen==sizeof(struct sockaddr_in)) - return inet_ntoa(((struct sockaddr_in *)remote)->sin_addr); + if(socklen==sizeof(struct sockaddr_in)) { + struct sockaddr_in sip; + memcpy(&sip,(struct sockaddr_in*)remote,sizeof(sip)); + return inet_ntoa(sip.sin_addr); + } #ifdef HAVE_IPV6 else { char tmp[128]; diff --git a/pdns/misc.hh b/pdns/misc.hh index 8651631a3..d950d319d 100644 --- a/pdns/misc.hh +++ b/pdns/misc.hh @@ -69,6 +69,12 @@ inline void putLong(char* p, u_int32_t val) putLong((unsigned char *)p,val); } + +inline u_int32_t getLong(unsigned char *p) +{ + return (p[0]<<24)+(p[1]<<16)+(p[2]<<8)+p[3]; +} + void upperCase(string& s); struct ServiceTuple diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index b8801aed7..886681f84 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -156,8 +156,8 @@ void startDoResolve(void *p) R->setA(false); R->setRA(true); - SyncRes sr; - L<getData(); sendto(d_serversock,buffer,R->len,0,(struct sockaddr *)(R->remote),R->d_socklen); - L<d.ancount)<<" answers, "<d.arcount)<<" additional, took "<d.ancount)<<" answers, "<d.arcount)<<" additional, took "<::s_outqueries*100.0/SyncRes::s_queries)<<"%"<7200) { - SyncRes sr; + SyncRes sr; vectorret; sr.setNoCache(); @@ -290,7 +290,7 @@ int main(int argc, char **argv) arg().set("soa-serial-offset","0")="0"; arg().set("local-port","port to listen on")="5300"; arg().set("local-address","port to listen on")="0.0.0.0"; - arg().set("trace","if we should output heaps of logging")="true"; + arg().set("trace","if we should output heaps of logging")="off"; arg().set("daemon","Operate as a daemon")="no"; arg().parse(argc, argv); @@ -299,7 +299,7 @@ int main(int argc, char **argv) L.toConsole(Logger::Warning); if(arg().mustDo("trace")) - SyncRes::setLog(true); + SyncRes::setLog(true); makeClientSocket(); makeServerSocket(); diff --git a/pdns/syncres.cc b/pdns/syncres.cc index 99733fe19..6072a044b 100644 --- a/pdns/syncres.cc +++ b/pdns/syncres.cc @@ -30,15 +30,15 @@ #include "arguments.hh" #include "lwres.hh" -templatemap SyncRes::s_negcache; -templateunsigned int SyncRes::s_queries; -templateunsigned int SyncRes::s_outqueries; -templatebool SyncRes::s_log; +map SyncRes::s_negcache; +unsigned int SyncRes::s_queries; +unsigned int SyncRes::s_outqueries; +bool SyncRes::s_log; #define LOG if(s_log)L<int SyncRes<>::beginResolve(const string &qname, const QType &qtype, vector&ret) +int SyncRes::beginResolve(const string &qname, const QType &qtype, vector&ret) { set beenthere; s_queries++; @@ -48,7 +48,7 @@ template<>int SyncRes<>::beginResolve(const string &qname, const QType &qtype, v return res; } -templateint SyncRes::doResolve(const string &qname, const QType &qtype, vector&ret, int depth, set& beenthere) +int SyncRes::doResolve(const string &qname, const QType &qtype, vector&ret, int depth, set& beenthere) { string prefix(d_prefix); prefix.append(depth, ' '); @@ -78,7 +78,7 @@ templateint SyncRes::doResolve(const string &qna return res<0 ? RCode::ServFail : res; } -templatestring SyncRes::getA(const string &qname, int depth, set& beenthere) +string SyncRes::getA(const string &qname, int depth, set& beenthere) { vector res; string ret; @@ -89,7 +89,7 @@ templatestring SyncRes::getA(const string &qname return ret; } -templatevoid SyncRes::getBestNSFromCache(const string &qname, set&bestns, int depth, set& beenthere) +void SyncRes::getBestNSFromCache(const string &qname, set&bestns, int depth, set& beenthere) { string prefix(d_prefix), subdomain(qname); prefix.append(depth, ' '); @@ -120,7 +120,7 @@ templatevoid SyncRes::getBestNSFromCache(const s answer.qname=toLower(qname); answer.bestns=bestns; if(beenthere.count(answer)) { LOG<::const_iterator j=beenthere.begin();j!=beenthere.end();++j) + for( set::const_iterator j=beenthere.begin();j!=beenthere.end();++j) LOG<qname<<" ("<bestns.size()<<")"<void SyncRes::getBestNSFromCache(const s /** doesn't actually do the work, leaves that to getBestNSFromCache */ -templatestring SyncRes::getBestNSNamesFromCache(const string &qname,set& nsset, int depth, set&beenthere) +string SyncRes::getBestNSNamesFromCache(const string &qname,set& nsset, int depth, set&beenthere) { string subdomain(qname); @@ -150,7 +150,7 @@ templatestring SyncRes::getBestNSNamesFromCache( return subdomain; } -templatebool SyncRes::doCNAMECacheCheck(const string &qname, const QType &qtype, vector&ret, int depth, int &res) +bool SyncRes::doCNAMECacheCheck(const string &qname, const QType &qtype, vector&ret, int depth, int &res) { string prefix(d_prefix), tuple=toLower(qname)+"|CNAME"; prefix.append(depth, ' '); @@ -182,7 +182,7 @@ templatebool SyncRes::doCNAMECacheCheck(const st return false; } -templatebool SyncRes::doCacheCheck(const string &qname, const QType &qtype, vector&ret, int depth, int &res) +bool SyncRes::doCacheCheck(const string &qname, const QType &qtype, vector&ret, int depth, int &res) { string prefix(d_prefix), tuple; prefix.append(depth, ' '); @@ -232,7 +232,7 @@ templatebool SyncRes::doCacheCheck(const string return false; } -templatebool SyncRes::moreSpecificThan(const string& a, const string &b) +bool SyncRes::moreSpecificThan(const string& a, const string &b) { int counta=!a.empty(), countb=!b.empty(); @@ -245,7 +245,7 @@ templatebool SyncRes::moreSpecificThan(const str return counta>countb; } -templatevector SyncRes::shuffle(set &nameservers) +vector SyncRes::shuffle(set &nameservers) { vector rnameservers; for(set::const_iterator i=nameservers.begin();i!=nameservers.end();++i) @@ -256,7 +256,7 @@ templatevector SyncRes::shuffle(setint SyncRes::doResolveAt(set nameservers, string auth, const string &qname, const QType &qtype, vector&ret, +int SyncRes::doResolveAt(set nameservers, string auth, const string &qname, const QType &qtype, vector&ret, int depth, set&beenthere) { string prefix(d_prefix); @@ -355,7 +355,7 @@ templateint SyncRes::doResolveAt(set nam newtarget=i->content; } // for ANY answers we *must* have an authoritive answer - else if(i->d_place==DNSResourceRecord::ANSWER && i->qname==qname && (i->qtype==qtype || ( qtype==QType(QType::ANY) && aabit))) { + else if(i->d_place==DNSResourceRecord::ANSWER && toLower(i->qname)==toLower(qname) && (i->qtype==qtype || ( qtype==QType(QType::ANY) && aabit))) { LOG<content<<"|"<qtype.getName()<<"'"<int SyncRes::doResolveAt(set nam return -1; } -templatevoid SyncRes::addCruft(const string &qname, vector& ret) +void SyncRes::addCruft(const string &qname, vector& ret) { for(vector::const_iterator k=ret.begin();k!=ret.end();++k) // don't add stuff to an NXDOMAIN! if(k->d_place==DNSResourceRecord::AUTHORITY && k->qtype==QType(QType::SOA)) @@ -433,7 +433,7 @@ templatevoid SyncRes::addCruft(const string &qna LOG<void SyncRes::addAuthorityRecords(const string& qname, vector& ret, int depth) +void SyncRes::addAuthorityRecords(const string& qname, vector& ret, int depth) { set bestns; setbeenthere; diff --git a/pdns/syncres.hh b/pdns/syncres.hh index 7b31525a5..401d24f72 100644 --- a/pdns/syncres.hh +++ b/pdns/syncres.hh @@ -14,7 +14,7 @@ void replaceCache(const string &qname, const QType &qt, const set* res=0); -template class SyncRes +class SyncRes { public: SyncRes() : d_outqueries(0), d_cacheonly(false), d_nocache(false){} @@ -60,7 +60,7 @@ private: static bool s_log; bool d_cacheonly; bool d_nocache; - MultiPlexor d_lwr; + LWRes d_lwr; static map s_negcache; struct GetBestNSAnswer {