aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2006-09-06 20:33:28 +0000
committerNick Mathewson <nickm@torproject.org>2006-09-06 20:33:28 +0000
commit1e26233957be82fdc7eba8f6a6b526e11f0106b2 (patch)
tree5572332cda093b6dae0e2f19485561c07836413c
parente10e9213868ffba8d62f550457a4620fed87c149 (diff)
downloadtor-1e26233957be82fdc7eba8f6a6b526e11f0106b2.tar
tor-1e26233957be82fdc7eba8f6a6b526e11f0106b2.tar.gz
r8731@Kushana: nickm | 2006-09-06 16:33:19 -0400
Try to fix eventdns.c build on windows. svn:r8329
-rw-r--r--src/or/eventdns.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/src/or/eventdns.c b/src/or/eventdns.c
index f7489d968..8ab378c08 100644
--- a/src/or/eventdns.c
+++ b/src/or/eventdns.c
@@ -261,15 +261,12 @@
#include <string.h>
#include <sys/types.h>
#include <fcntl.h>
-#include <sys/socket.h>
#include <sys/time.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <assert.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
#include <unistd.h>
#include <limits.h>
#include <sys/stat.h>
@@ -277,6 +274,16 @@
#include <stdio.h>
#include <stdarg.h>
+#ifdef WIN32
+#include <windows.h>
+#include <winsock2.h>
+#include <iphlpapi.h>
+#else
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#endif
+
#define EVENTDNS_LOG_DEBUG 0
#define EVENTDNS_LOG_WARN 1
@@ -436,6 +443,19 @@ error_is_eagain(int err)
{
return err == EAGAIN || err == WSAEWOULDBLOCK;
}
+static int
+inet_aton(const char *c, struct in_addr *addr)
+{
+ uint32_t r;
+ if (strcmp(c, "255.255.255.255") == 0) {
+ addr->s_addr = 0xffffffffu;
+ } else {
+ uint32_t r = inet_addr(c);
+ if (r == INADDR_NONE)
+ return 0;
+ addr->a_addr = r;
+ }
+}
#define CLOSE_SOCKET(x) closesocket(x)
#else
#define last_error(sock) (errno)
@@ -1052,7 +1072,7 @@ nameserver_read(struct nameserver *ns) {
for (;;) {
const int r = recv(ns->socket, packet, sizeof(packet), 0);
if (r < 0) {
- int err = last_error(ns_socket);
+ int err = last_error(ns->socket);
if (error_is_eagain(err)) return;
nameserver_failed(ns, strerror(err));
return;
@@ -2115,7 +2135,7 @@ load_nameservers_from_registry(void)
found = 1; \
}
- if (IS_NT()) {
+ if (((int)GetVersion()) > 0) { /* NT */
HKEY nt_key = 0, interfaces_key = 0;
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0,