[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [obfsproxy/master] Kludge back to building on windows. I leave fixing it properly to someone who cares about windows.



commit 674d07350657a14ed25f643154eea4a406be17a4
Author: Zack Weinberg <zackw@xxxxxxxxx>
Date:   Fri Jul 29 10:03:07 2011 -0700

    Kludge back to building on windows. I leave fixing it properly to someone who cares about windows.
---
 src/network.c         |   12 ++++--------
 src/protocols/obfs2.c |   25 +++++++++++++------------
 src/util.c            |    7 ++++++-
 3 files changed, 23 insertions(+), 21 deletions(-)

diff --git a/src/network.c b/src/network.c
index 10e45fd..c9eafce 100644
--- a/src/network.c
+++ b/src/network.c
@@ -538,7 +538,7 @@ upstream_read_cb(struct bufferevent *bev, void *arg)
 {
   conn_t *conn = arg;
   log_debug("%s: %s, %lu bytes available", conn->peername, __func__,
-            evbuffer_get_length(bufferevent_get_input(bev)));
+            (unsigned long)evbuffer_get_length(bufferevent_get_input(bev)));
   obfs_assert(bev == conn->upstream);
 
   if (proto_send(conn->proto,
@@ -560,7 +560,7 @@ downstream_read_cb(struct bufferevent *bev, void *arg)
   conn_t *conn = arg;
   enum recv_ret r;
   log_debug("%s: %s, %lu bytes available", conn->peername, __func__,
-            evbuffer_get_length(bufferevent_get_input(bev)));
+            (unsigned long)evbuffer_get_length(bufferevent_get_input(bev)));
   obfs_assert(bev == conn->downstream);
 
   r = proto_recv(conn->proto,
@@ -571,7 +571,8 @@ downstream_read_cb(struct bufferevent *bev, void *arg)
     log_debug("%s: Error during receive.", conn->peername);
     close_conn(conn);
   } else if (r == RECV_SEND_PENDING) {
-    log_debug("%s: Reply of %ld bytes", conn->peername,
+    log_debug("%s: Reply of %lu bytes", conn->peername,
+              (unsigned long)
               evbuffer_get_length(bufferevent_get_input(conn->upstream)));
     if (proto_send(conn->proto,
                    bufferevent_get_input(conn->upstream),
@@ -632,11 +633,6 @@ error_cb(struct bufferevent *bev, short what, void *arg)
   obfs_assert(!(what & BEV_EVENT_CONNECTED));
 
   if (what & BEV_EVENT_ERROR) {
-    /* If we get EAGAIN, EINTR, or EINPROGRESS here, something has
-       gone horribly wrong. */
-    obfs_assert(errcode != EAGAIN && errcode != EINTR &&
-                errcode != EINPROGRESS);
-
     log_warn("Error on %s side of connection from %s: %s",
              bev == conn->upstream ? "upstream" : "downstream",
              conn->peername,
diff --git a/src/protocols/obfs2.c b/src/protocols/obfs2.c
index 7d57e20..f313204 100644
--- a/src/protocols/obfs2.c
+++ b/src/protocols/obfs2.c
@@ -349,9 +349,9 @@ obfs2_handshake(protocol_t *s, struct evbuffer *buf)
   /* Put it on the buffer */
   evbuffer_add(buf, msg, OBFUSCATE_SEED_LENGTH+8+plength);
 
-  log_debug("obfs2_handshake: %s queued %ld bytes",
+  log_debug("obfs2_handshake: %s queued %lu bytes",
             state->we_are_initiator ? "initiator" : "responder",
-            evbuffer_get_length(buf));
+            (unsigned long)evbuffer_get_length(buf));
 
   return 0;
 }
@@ -389,8 +389,8 @@ obfs2_send(protocol_t *s,
   if (state->send_crypto) {
     /* First of all, send any data that we've been waiting to send. */
     if (state->pending_data_to_send) {
-      log_debug("%s: transmitting %ld bytes previously queued.", __func__,
-                evbuffer_get_length(state->pending_data_to_send));
+      log_debug("%s: transmitting %lu bytes previously queued.", __func__,
+                (unsigned long)evbuffer_get_length(state->pending_data_to_send));
       obfs2_crypt_and_transmit(state->send_crypto,
                                state->pending_data_to_send,
                                dest);
@@ -399,15 +399,15 @@ obfs2_send(protocol_t *s,
     }
     /* Our crypto is set up; just relay the bytes */
     if (evbuffer_get_length(source)) {
-      log_debug("%s: transmitting %ld bytes.", __func__,
-                evbuffer_get_length(source));
+      log_debug("%s: transmitting %lu bytes.", __func__,
+                (unsigned long)evbuffer_get_length(source));
     }
     return obfs2_crypt_and_transmit(state->send_crypto, source, dest);
   } else {
     /* Our crypto isn't set up yet, we'll have to queue the data */
     if (evbuffer_get_length(source)) {
-      log_debug("%s: handshake incomplete, queueing %ld bytes.", __func__,
-                evbuffer_get_length(source));
+      log_debug("%s: handshake incomplete, queueing %lu bytes.", __func__,
+                (unsigned long)evbuffer_get_length(source));
       if (! state->pending_data_to_send) {
         if ((state->pending_data_to_send = evbuffer_new()) == NULL)
           return -1;
@@ -474,8 +474,9 @@ obfs2_recv(protocol_t *s, struct evbuffer *source,
     uchar buf[OBFUSCATE_SEED_LENGTH+8], *other_seed;
     uint32_t magic, plength;
     if (evbuffer_get_length(source) < OBFUSCATE_SEED_LENGTH+8) {
-      log_debug("%s: waiting for key, %ld/%d bytes so far",
-                __func__, evbuffer_get_length(source), OBFUSCATE_SEED_LENGTH+8);
+      log_debug("%s: waiting for key, %lu/%u bytes so far",
+                __func__, (unsigned long)evbuffer_get_length(source),
+                OBFUSCATE_SEED_LENGTH+8);
       /* data not here yet */
       return RECV_INCOMPLETE;
     }
@@ -532,8 +533,8 @@ obfs2_recv(protocol_t *s, struct evbuffer *source,
   /* Okay; now we're definitely open.  Process whatever data we have. */
   state->state = ST_OPEN;
 
-  log_debug("%s: Processing %ld bytes application data",
-            __func__, evbuffer_get_length(source));
+  log_debug("%s: Processing %lu bytes application data",
+            __func__, (unsigned long)evbuffer_get_length(source));
   obfs2_crypt_and_transmit(state->recv_crypto, source, dest);
 
   /* If we have pending data to send, transmit it now. */
diff --git a/src/util.c b/src/util.c
index 46d4b42..fa1a62c 100644
--- a/src/util.c
+++ b/src/util.c
@@ -10,7 +10,9 @@
 #include <unistd.h>
 
 #include <event2/dns.h>
+#ifndef _WIN32
 #include <arpa/inet.h>
+#endif
 #ifdef AF_LOCAL
 #include <sys/un.h>
 #endif
@@ -202,11 +204,12 @@ resolve_address_port(const char *address, int nodns, int passive,
 char *
 printable_address(struct sockaddr *addr, socklen_t addrlen)
 {
-  char abuf[INET6_ADDRSTRLEN];
   char apbuf[INET6_ADDRSTRLEN + 8]; /* []:65535 is 8 characters */
 
   switch (addr->sa_family) {
+#ifndef _WIN32 /* Windows XP doesn't have inet_ntop. Fix later. */
   case AF_INET: {
+    char abuf[INET6_ADDRSTRLEN];
     struct sockaddr_in *sin = (struct sockaddr_in*)addr;
     if (!inet_ntop(AF_INET, &sin->sin_addr, abuf, INET6_ADDRSTRLEN))
       break;
@@ -215,6 +218,7 @@ printable_address(struct sockaddr *addr, socklen_t addrlen)
   }
 
   case AF_INET6: {
+    char abuf[INET6_ADDRSTRLEN];
     struct sockaddr_in6 *sin6 = (struct sockaddr_in6*)addr;
     if (!inet_ntop(AF_INET, &sin6->sin6_addr, abuf, INET6_ADDRSTRLEN))
       break;
@@ -222,6 +226,7 @@ printable_address(struct sockaddr *addr, socklen_t addrlen)
                   ntohs(sin6->sin6_port));
     return xstrdup(apbuf);
   }
+#endif
 
 #ifdef AF_LOCAL
   case AF_LOCAL:



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits