diff options
author | w00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-05-19 15:56:42 +0000 |
---|---|---|
committer | w00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-05-19 15:56:42 +0000 |
commit | 9cf56d917d92959701694477f7944d45ad2c38ed (patch) | |
tree | a379ee905e7485c2ee825790720ed2b69ba127d1 /src/dns.cpp | |
parent | 3bbb36695383badf5b3ba0ecba070f16094ae51d (diff) |
Windows support. Tested and working to compile on freebsd and linux. Next step is to make sure it actually works in windows too. ;p. Add Burlex to contributors.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7043 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/dns.cpp')
-rw-r--r-- | src/dns.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/dns.cpp b/src/dns.cpp index c04ab4cc1..df79eba24 100644 --- a/src/dns.cpp +++ b/src/dns.cpp @@ -21,11 +21,16 @@ Please do not assume that firedns works like this, looks like this, walks like this or tastes like this. */ +#ifndef WIN32 #include <sys/types.h> #include <sys/socket.h> #include <errno.h> #include <netinet/in.h> #include <arpa/inet.h> +#else +#include "inspircd_win32wrapper.h" +#endif + #include "dns.h" #include "inspircd.h" #include "socketengine.h" @@ -238,7 +243,7 @@ int DNSRequest::SendRequests(const DNSHeader *header, const int length, QueryTyp memcpy(&addr.sin_addr.s_addr, &dnsobj->myserver4, sizeof(addr.sin_addr)); addr.sin_family = AF_INET; addr.sin_port = htons(DNS::QUERY_PORT); - if (sendto(dnsobj->GetFd(), payload, length + 12, 0, (sockaddr *) &addr, sizeof(addr)) != length+12) + if (sendto(dnsobj->GetFd(), (const char*)payload, length + 12, 0, (sockaddr *) &addr, sizeof(addr)) != length+12) return -1; #endif @@ -619,7 +624,7 @@ DNSResult DNS::GetResult() const char* ipaddr_from; unsigned short int port_from = 0; - int length = recvfrom(this->GetFd(),buffer,sizeof(DNSHeader),0,from,&x); + int length = recvfrom(this->GetFd(),(char*)buffer,sizeof(DNSHeader),0,from,&x); /* Did we get the whole header? */ if (length < 12) @@ -1146,6 +1151,7 @@ void DNS::CleanResolvers(Module* module) /** Generate pseudo-random number */ unsigned long DNS::PRNG() { +#ifndef WIN32 unsigned long val = 0; timeval n; serverstats* s = ServerInstance->stats; @@ -1154,5 +1160,13 @@ unsigned long DNS::PRNG() val = val + s->statsCollisions ^ s->statsDnsGood - s->statsDnsBad; val += (s->statsConnects ^ (unsigned long)s->statsSent ^ (unsigned long)s->statsRecv) - ServerInstance->Config->ports.size(); return val; +#else + unsigned long val = 0; + serverstats* s = ServerInstance->stats; + val = (time(NULL) ^ GetCurrentProcessId() ^ GetCurrentThreadId() ^ (this->currid++)) ^ s->statsAccept + time(NULL); + val = val + s->statsCollisions ^ s->statsDnsGood - s->statsDnsBad; + val += (s->statsConnects ^ (unsigned long)s->statsSent ^ (unsigned long)s->statsRecv); + return val; +#endif } |