[or-cvs] more debugging info, to track down bruce"s IP problems

Roger Dingledine arma at seul.org
Tue Aug 27 19:28:38 UTC 2002


Update of /home/or/cvsroot/src/or
In directory moria.seul.org:/home/arma/work/onion/cvs/src/or

Modified Files:
	connection.c routers.c 
Log Message:
more debugging info, to track down bruce's IP problems


Index: connection.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- connection.c	24 Aug 2002 08:24:24 -0000	1.15
+++ connection.c	27 Aug 2002 19:28:35 -0000	1.16
@@ -207,7 +207,7 @@
   /* learn things from parent, so we can perform auth */
   memcpy(&newconn->local,&conn->local,sizeof(struct sockaddr_in));
   newconn->prkey = conn->prkey;
-  newconn->address = strdup(inet_ntoa(*(struct in_addr *)&remote.sin_addr.s_addr)); /* remember the remote address */
+  newconn->address = strdup(inet_ntoa(remote.sin_addr)); /* remember the remote address */
 
   if(connection_add(newconn) < 0) { /* no space, forget it */
     connection_free(newconn);
@@ -232,6 +232,7 @@
     log(LOG_ERR,"Error obtaining local hostname.");
     return -1;
   }
+  log(LOG_DEBUG,"learn_local: localhostname is '%s'.",localhostname);
   localhost = gethostbyname(localhostname);
   if (!localhost) {
     log(LOG_ERR,"Error obtaining local host info.");
@@ -239,8 +240,8 @@
   }
   memset((void *)local,0,sizeof(struct sockaddr_in));
   local->sin_family = AF_INET;
-  local->sin_addr.s_addr = INADDR_ANY;
   memcpy((void *)&local->sin_addr,(void *)localhost->h_addr,sizeof(struct in_addr));
+  log(LOG_DEBUG,"learn_local: chose address as '%s'.",inet_ntoa(local->sin_addr));
 
   return 0;
 }

Index: routers.c
===================================================================
RCS file: /home/or/cvsroot/src/or/routers.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- routers.c	24 Aug 2002 07:55:49 -0000	1.8
+++ routers.c	27 Aug 2002 19:28:35 -0000	1.9
@@ -20,6 +20,8 @@
   /* local host information */
   char localhostname[512];
   struct hostent *localhost;
+  struct in_addr *a;
+  char *tmp1;
   
   char *addr = NULL;
   int i = 0;
@@ -39,10 +41,20 @@
   addr = localhost->h_addr_list[i++]; /* set to the first local address */
   while(addr)
   {
+    a = (struct in_addr *)addr;
+
+    tmp1 = strdup(inet_ntoa(*a)); /* can't call inet_ntoa twice in the same
+				     printf, since it overwrites its static
+				     memory each time */
+    log(LOG_DEBUG,"router_is_me(): Comparing '%s' to '%s'.",tmp1,
+       inet_ntoa( *((struct in_addr *)&or_address) ) );
+    free(tmp1);
     if (!memcmp((void *)&or_address, (void *)addr, sizeof(uint32_t))) { /* addresses match */
-/* FIXME one's a string, one's a uint32_t? does this make sense? */
-      if (or_listenport == my_or_listenport) /* ports also match */
+      log(LOG_DEBUG,"router_is_me(): Addresses match. Comparing ports.");
+      if (or_listenport == my_or_listenport) { /* ports also match */
+        log(LOG_DEBUG,"router_is_me(): Ports match too.");
         return 1;
+      }
     }
     
     addr = localhost->h_addr_list[i++];



More information about the tor-commits mailing list