gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r4090 - in GNUnet: . doc/man src/applications/transport src


From: grothoff
Subject: [GNUnet-SVN] r4090 - in GNUnet: . doc/man src/applications/transport src/include src/server src/transports
Date: Thu, 28 Dec 2006 20:23:46 -0800 (PST)

Author: grothoff
Date: 2006-12-28 20:23:37 -0800 (Thu, 28 Dec 2006)
New Revision: 4090

Modified:
   GNUnet/ChangeLog
   GNUnet/configure.ac
   GNUnet/doc/man/gnunet-peer-info.1
   GNUnet/src/applications/transport/transport.c
   GNUnet/src/include/gnunet_transport.h
   GNUnet/src/include/gnunet_transport_service.h
   GNUnet/src/server/gnunet-peer-info.c
   GNUnet/src/server/gnunet-transport-check.c
   GNUnet/src/transports/http.c
   GNUnet/src/transports/nat.c
   GNUnet/src/transports/tcp.c
   GNUnet/src/transports/tcp6.c
   GNUnet/src/transports/tcp_old.c
   GNUnet/src/transports/udp.c
   GNUnet/src/transports/udp6.c
   GNUnet/todo
Log:
addressing feature report #1076

Modified: GNUnet/ChangeLog
===================================================================
--- GNUnet/ChangeLog    2006-12-29 03:51:51 UTC (rev 4089)
+++ GNUnet/ChangeLog    2006-12-29 04:23:37 UTC (rev 4090)
@@ -1,3 +1,6 @@
+Thu Dec 28 21:22:10 MST 2006
+       Hostname resolution with gnunet-peer-info implemented (#1076).
+
 Thu Dec 28 20:44:45 MST 2006
        Hopefully fixing build problems on certain systems with
        unusual installation of iconv.

Modified: GNUnet/configure.ac
===================================================================
--- GNUnet/configure.ac 2006-12-29 03:51:51 UTC (rev 4089)
+++ GNUnet/configure.ac 2006-12-29 04:23:37 UTC (rev 4090)
@@ -457,7 +457,7 @@
 AC_HEADER_SYS_WAIT
 AC_TYPE_OFF_T
 AC_TYPE_UID_T
-AC_CHECK_FUNCS([floor gethostname memmove rmdir strncasecmp strrchr strtol 
atoll dup2 fdatasync ftruncate gethostbyname gettimeofday memset mkdir mkfifo 
select socket strcasecmp strchr strdup strerror strstr clock_gettime getrusage 
rand uname setlocale getcwd mktime gmtime_r gmtime strlcpy strlcat ftruncate 
stat64 sbrk mmap mremap setrlimit])
+AC_CHECK_FUNCS([floor gethostname memmove rmdir strncasecmp strrchr strtol 
atoll dup2 fdatasync ftruncate gethostbyname gettimeofday memset mkdir mkfifo 
select socket strcasecmp strchr strdup strerror strstr clock_gettime getrusage 
rand uname setlocale getcwd mktime gmtime_r gmtime strlcpy strlcat ftruncate 
stat64 sbrk mmap mremap setrlimit gethostbyaddr])
 
 # restore LIBS
 LIBS=$SAVE_LIBS

Modified: GNUnet/doc/man/gnunet-peer-info.1
===================================================================
--- GNUnet/doc/man/gnunet-peer-info.1   2006-12-29 03:51:51 UTC (rev 4089)
+++ GNUnet/doc/man/gnunet-peer-info.1   2006-12-29 04:23:37 UTC (rev 4090)
@@ -1,4 +1,4 @@
-.TH GNUNET-PEER-INFO 1 "April 30, 2005" "GNUnet"
+.TH GNUNET-PEER-INFO 1 "Dec 29, 2006" "GNUnet"
 
 .SH NAME
 gnunet\-peer\-info \- Display information about other known nodes.
@@ -14,12 +14,18 @@
 
 .SH OPTIONS
 .B
+.IP "\-c FILENAME, \-\-config=FILENAME"
+Load config file (default: /etc/gnunet.conf)
+.B
 .IP "\-h, \-\-help"
 Print help page
 .B
-.IP "\-c FILENAME, \-\-config=FILENAME"
-Load config file (default: /etc/gnunet.conf)
+.IP "\-H HOSTNAME, \-\-host=HOSTNAME"
+Specify host on which gnunetd is running
 .B
+.IP "\-n, \-\-numeric"
+Disable resolution of IPs to hostnames
+.B
 .IP "\-v, \-\-version"
 Print the version number
 .B

Modified: GNUnet/src/applications/transport/transport.c
===================================================================
--- GNUnet/src/applications/transport/transport.c       2006-12-29 03:51:51 UTC 
(rev 4089)
+++ GNUnet/src/applications/transport/transport.c       2006-12-29 04:23:37 UTC 
(rev 4090)
@@ -61,32 +61,32 @@
 static void createSignedhello(void * cls) {
   TransportAPI * tapi = cls;
   MUTEX_LOCK(tapis_lock);
-  FREENONNULL(tapi->helo);
-  tapi->helo = tapi->createhello();
-  if (NULL == tapi->helo) {
+  FREENONNULL(tapi->hello);
+  tapi->hello = tapi->createhello();
+  if (NULL == tapi->hello) {
     MUTEX_UNLOCK(tapis_lock);
     return;
   }
-  memcpy(&tapi->helo->publicKey,
+  memcpy(&tapi->hello->publicKey,
         identity->getPublicPrivateKey(),
         sizeof(PublicKey));
-  memcpy(&tapi->helo->senderIdentity,
+  memcpy(&tapi->hello->senderIdentity,
         coreAPI->myIdentity,
         sizeof(PeerIdentity));
-  tapi->helo->expirationTime
+  tapi->hello->expirationTime
     = htonl(TIME(NULL) + helo_live);
-  tapi->helo->header.type
+  tapi->hello->header.type
     = htons(p2p_PROTO_hello);
-  tapi->helo->header.size
-    = htons(P2P_hello_MESSAGE_size(tapi->helo));
-  if (SYSERR == identity->signData(&(tapi->helo)->senderIdentity,
-                                  P2P_hello_MESSAGE_size(tapi->helo)
+  tapi->hello->header.size
+    = htons(P2P_hello_MESSAGE_size(tapi->hello));
+  if (SYSERR == identity->signData(&(tapi->hello)->senderIdentity,
+                                  P2P_hello_MESSAGE_size(tapi->hello)
                                   - sizeof(Signature)
                                   - sizeof(PublicKey)
                                   - sizeof(MESSAGE_HEADER),
-                                  &tapi->helo->signature)) {
-    FREE(tapi->helo);
-    tapi->helo = NULL;
+                                  &tapi->hello->signature)) {
+    FREE(tapi->hello);
+    tapi->hello = NULL;
     GE_BREAK(ectx, 0);
   }
   MUTEX_UNLOCK(tapis_lock);
@@ -117,7 +117,7 @@
     return SYSERR;
   }
   tapis[tapi->protocolNumber] = tapi;
-  tapi->helo = NULL;
+  tapi->hello = NULL;
   cron_add_job(coreAPI->cron,
               &createSignedhello,
               HELLO_RECREATE_FREQ,
@@ -129,19 +129,21 @@
 /**
  * Convert hello to string.
  */
-static char * heloToString(const P2P_hello_MESSAGE * helo) {
+static char * 
+helloToString(const P2P_hello_MESSAGE * hello,
+             int resolve_ip) {
   unsigned short prot;
 
-  prot = ntohs(helo->protocol);
-  if ( (ntohs(helo->protocol) >= tapis_count) ||
+  prot = ntohs(hello->protocol);
+  if ( (ntohs(hello->protocol) >= tapis_count) ||
        (tapis[prot] == NULL) ) {
     GE_LOG(ectx,
           GE_INFO | GE_REQUEST | GE_USER,
           _("Converting peer address to string failed, transport type %d not 
supported\n"),
-          ntohs(helo->protocol));
+          ntohs(hello->protocol));
     return NULL;
   }
-  return tapis[prot]->addressToString(helo);
+  return tapis[prot]->addressToString(hello, resolve_ip);
 }
 
 /**
@@ -354,7 +356,7 @@
     while ( (ttype < tapis_count) &&
            ( (tapis[perm[ttype]] == NULL) ||
              (tapis[perm[ttype]] != NULL &&
-              tapis[perm[ttype]]->helo == NULL) ) )
+              tapis[perm[ttype]]->hello == NULL) ) )
       ttype--; /* unsigned, will wrap around! */
     if (ttype >= tapis_count) {
       FREE(perm);
@@ -374,14 +376,14 @@
     return NULL;
   }
   tapi = tapis[ttype];
-  if (tapi->helo == NULL) {
+  if (tapi->hello == NULL) {
     MUTEX_UNLOCK(tapis_lock);
     return NULL; /* send-only transport */
   }
-  helo = MALLOC(P2P_hello_MESSAGE_size(tapi->helo));
+  helo = MALLOC(P2P_hello_MESSAGE_size(tapi->hello));
   memcpy(helo,
-        tapi->helo,
-        P2P_hello_MESSAGE_size(tapi->helo));
+        tapi->hello,
+        P2P_hello_MESSAGE_size(tapi->hello));
   MUTEX_UNLOCK(tapis_lock);
   return helo;
 }
@@ -489,8 +491,8 @@
   if (ptr != NULL)
     ptr();
   FREE(tapis[i]->transName);
-  FREENONNULL(tapis[i]->helo);
-  tapis[i]->helo = NULL;
+  FREENONNULL(tapis[i]->hello);
+  tapis[i]->hello = NULL;
   os_plugin_unload(tapis[i]->libHandle);
   tapis[i] = NULL;
 }
@@ -685,7 +687,7 @@
   ret.send = &transportSend;
   ret.disconnect = &transportDisconnect;
   ret.verifyhello = &transportVerifyHelo;
-  ret.heloToString = &heloToString;
+  ret.helloToString = &helloToString;
   ret.getMTU = &transportGetMTU;
   ret.createhello = &transportCreatehello;
   ret.getAdvertisedhellos = &getAdvertisedhellos;

Modified: GNUnet/src/include/gnunet_transport.h
===================================================================
--- GNUnet/src/include/gnunet_transport.h       2006-12-29 03:51:51 UTC (rev 
4089)
+++ GNUnet/src/include/gnunet_transport.h       2006-12-29 04:23:37 UTC (rev 
4090)
@@ -199,7 +199,7 @@
    * idea.  The field is updated by a cron job
    * periodically.
    */
-  P2P_hello_MESSAGE * helo;
+  P2P_hello_MESSAGE * hello;
 
   /**
    * The number of the protocol that is supported by this transport
@@ -226,11 +226,11 @@
    * Verify that a hello-Message is correct (a node
    * is potentially reachable at that address). Core
    * will only play ping pong after this verification passed.
-   * @param helo the hello message to verify
+   * @param hello the hello message to verify
    *        (the signature/crc have been verified before)
    * @return OK if the helo is well-formed
    */
-  int (*verifyHelo)(const P2P_hello_MESSAGE * helo);
+  int (*verifyHelo)(const P2P_hello_MESSAGE * hello);
 
   /**
    * Create a hello-Message for the current node. The hello is
@@ -240,8 +240,6 @@
    * responsible for filling in the protocol number,
    * senderAddressSize and the senderAddress itself.
    *
-   * @param helo address where to store the pointer to the hello
-   *        message
    * @return OK on success, SYSERR on error (e.g. send-only
    *  transports return SYSERR here)
    */
@@ -250,11 +248,11 @@
   /**
    * Establish a connection to a remote node.
    *
-   * @param helo the hello-Message for the target node
+   * @param hello the hello-Message for the target node
    * @param tsession the session handle that is to be set
    * @return OK on success, SYSERR if the operation failed
    */
-  int (*connect)(const P2P_hello_MESSAGE * helo,
+  int (*connect)(const P2P_hello_MESSAGE * hello,
                 TSession ** tsession);
 
   /**
@@ -326,8 +324,11 @@
 
   /**
    * Convert transport address to human readable string.
+   *
+   * @param resolve_ip should we try to resolve the IP?
    */
-  char * (*addressToString)(const P2P_hello_MESSAGE * helo);
+  char * (*addressToString)(const P2P_hello_MESSAGE * hello,
+                           int resolve_ip);
 
 } TransportAPI;
 

Modified: GNUnet/src/include/gnunet_transport_service.h
===================================================================
--- GNUnet/src/include/gnunet_transport_service.h       2006-12-29 03:51:51 UTC 
(rev 4089)
+++ GNUnet/src/include/gnunet_transport_service.h       2006-12-29 04:23:37 UTC 
(rev 4090)
@@ -83,10 +83,10 @@
    * layer. This may fail if the appropriate transport mechanism is
    * not available.
    *
-   * @param helo the hello of the target node
+   * @param hello the hello of the target node
    * @return session handle on success, NULL on error
    */
-  TSession * (*connect)(const P2P_hello_MESSAGE * helo);
+  TSession * (*connect)(const P2P_hello_MESSAGE * hello);
 
   /**
    * Connect to another peer, picking any transport that
@@ -149,12 +149,15 @@
    * @return OK if the attempt to verify is on the way,
    *        SYSERR if the transport mechanism is not supported
    */
-  int (*verifyhello)(const P2P_hello_MESSAGE * helo);
+  int (*verifyhello)(const P2P_hello_MESSAGE * hello);
 
   /**
    * Convert hello to string.
+   *
+   * @param resolve_ip should we try to resovle the IP?
    */
-  char * (*heloToString)(const P2P_hello_MESSAGE * helo);
+  char * (*helloToString)(const P2P_hello_MESSAGE * hello,
+                         int resolve_ip);
 
   /**
    * Get the MTU for a given transport type.

Modified: GNUnet/src/server/gnunet-peer-info.c
===================================================================
--- GNUnet/src/server/gnunet-peer-info.c        2006-12-29 03:51:51 UTC (rev 
4089)
+++ GNUnet/src/server/gnunet-peer-info.c        2006-12-29 04:23:37 UTC (rev 
4090)
@@ -43,6 +43,8 @@
 
 static char * cfgFilename = DEFAULT_DAEMON_CONFIG_FILE;
 
+static int no_resolve = NO;
+
 /**
  * All gnunet-peer-info command line options
  */
@@ -51,6 +53,9 @@
   COMMAND_LINE_OPTION_HELP(gettext_noop("Print information about GNUnet 
peers.")), /* -h */
   COMMAND_LINE_OPTION_HOSTNAME, /* -H */
   COMMAND_LINE_OPTION_LOGGING, /* -L */
+  { 'n', "numeric", NULL,
+    gettext_noop("don't resolve host names"),
+    0, &gnunet_getopt_configure_set_one, &no_resolve },
   COMMAND_LINE_OPTION_VERSION(PACKAGE_VERSION), /* -v */
   COMMAND_LINE_OPTION_END,
 };
@@ -86,7 +91,8 @@
     GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
        _("hello message invalid (signature invalid).\n"));
   }
-  info = transport->heloToString(helo);
+  info = transport->helloToString(helo,
+                                 ! no_resolve);
   FREE(helo);
   if (info == NULL) {
     GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
@@ -94,7 +100,6 @@
        &enc);
     return;
   }
-
   printf(_("Peer `%s' with trust %8u and address `%s'\n"),
         (char*)&enc,
         identity->getHostTrust(id),

Modified: GNUnet/src/server/gnunet-transport-check.c
===================================================================
--- GNUnet/src/server/gnunet-transport-check.c  2006-12-29 03:51:51 UTC (rev 
4089)
+++ GNUnet/src/server/gnunet-transport-check.c  2006-12-29 04:23:37 UTC (rev 
4090)
@@ -244,7 +244,9 @@
                                    &verbose);
   if (verbose > 0) {
     char * str;
-    str = transport->heloToString(xhelo);
+
+    str = transport->helloToString(xhelo,
+                                  NO);
     fprintf(stderr,
            _("\nContacting `%s'."),
            str);

Modified: GNUnet/src/transports/http.c
===================================================================
--- GNUnet/src/transports/http.c        2006-12-29 03:51:51 UTC (rev 4089)
+++ GNUnet/src/transports/http.c        2006-12-29 04:23:37 UTC (rev 4090)
@@ -1423,19 +1423,40 @@
 /**
  * Convert HTTP address to a string.
  */
-static char * addressToString(const P2P_hello_MESSAGE * helo) {
+static char * 
+addressToString(const P2P_hello_MESSAGE * hello,
+               int do_resolve) {
   char * ret;
-  HostAddress * haddr;
+  const HostAddress * haddr = (const HostAddress*) &hello[1];
   size_t n;
+  const char * hn = "";
+  struct hostent * ent;
 
-  haddr = (HostAddress*) &helo[1];
-  n = 4*4+6+16;
+#if HAVE_GETHOSTBYADDR
+  if (do_resolve) {
+    ent = gethostbyaddr(haddr,
+                       sizeof(IPaddr),
+                       AF_INET);
+    if (ent != NULL)
+      hn = ent->h_name;
+  }    
+#endif
+  n = 4*4+7+6 + strlen(hn) + 10;
   ret = MALLOC(n);
-  SNPRINTF(ret,
-          n,
-          "%u.%u.%u.%u:%u (HTTP)",
-          PRIP(ntohl(*(int*)&haddr->ip.addr)),
-          ntohs(haddr->port));
+  if (strlen(hn) > 0) {
+    SNPRINTF(ret,
+            n,
+            "%s (%u.%u.%u.%u) HTTP (%u)",
+            hn,
+            PRIP(ntohl(*(int*)&haddr->ip.addr)),
+            ntohs(haddr->port));
+  } else {
+    SNPRINTF(ret,
+            n,
+            "%u.%u.%u.%u HTTP (%u)",
+            PRIP(ntohl(*(int*)&haddr->ip.addr)),
+            ntohs(haddr->port));
+  }
   return ret;
 }
 

Modified: GNUnet/src/transports/nat.c
===================================================================
--- GNUnet/src/transports/nat.c 2006-12-29 03:51:51 UTC (rev 4089)
+++ GNUnet/src/transports/nat.c 2006-12-29 04:23:37 UTC (rev 4090)
@@ -173,7 +173,8 @@
 /**
  * Convert NAT address to a string.
  */
-static char * addressToString(const P2P_hello_MESSAGE * helo) {
+static char * addressToString(const P2P_hello_MESSAGE * hello,
+                             int do_resolve) {
   return STRDUP("NAT");
 }
 

Modified: GNUnet/src/transports/tcp.c
===================================================================
--- GNUnet/src/transports/tcp.c 2006-12-29 03:51:51 UTC (rev 4089)
+++ GNUnet/src/transports/tcp.c 2006-12-29 04:23:37 UTC (rev 4090)
@@ -478,19 +478,40 @@
 /**
  * Convert TCP address to a string.
  */
-static char * addressToString(const P2P_hello_MESSAGE * helo) {
+static char * 
+addressToString(const P2P_hello_MESSAGE * hello,
+               int do_resolve) {
   char * ret;
-  HostAddress * haddr;
+  const HostAddress * haddr = (const HostAddress*) &hello[1];
   size_t n;
+  const char * hn = "";
+  struct hostent * ent;
 
-  haddr = (HostAddress*) &helo[1];
-  n = 4*4+6+6;
+#if HAVE_GETHOSTBYADDR
+  if (do_resolve) {
+    ent = gethostbyaddr(haddr,
+                       sizeof(IPaddr),
+                       AF_INET);
+    if (ent != NULL)
+      hn = ent->h_name;
+  }    
+#endif
+  n = 4*4+6+6 + strlen(hn) + 10;
   ret = MALLOC(n);
-  SNPRINTF(ret,
-          n,
-          "%u.%u.%u.%u:%u (TCP)",
-          PRIP(ntohl(*(int*)&haddr->ip.addr)),
-          ntohs(haddr->port));
+  if (strlen(hn) > 0) {
+    SNPRINTF(ret,
+            n,
+            "%s (%u.%u.%u.%u) TCP (%u)",
+            hn,
+            PRIP(ntohl(*(int*)&haddr->ip.addr)),
+            ntohs(haddr->port));
+  } else {
+    SNPRINTF(ret,
+            n,
+            "%u.%u.%u.%u TCP (%u)",
+            PRIP(ntohl(*(int*)&haddr->ip.addr)),
+            ntohs(haddr->port));
+  }
   return ret;
 }
 

Modified: GNUnet/src/transports/tcp6.c
===================================================================
--- GNUnet/src/transports/tcp6.c        2006-12-29 03:51:51 UTC (rev 4089)
+++ GNUnet/src/transports/tcp6.c        2006-12-29 04:23:37 UTC (rev 4090)
@@ -445,21 +445,47 @@
 /**
  * Convert TCP6 address to a string.
  */
-static char * addressToString(const P2P_hello_MESSAGE * helo) {
+static char * 
+addressToString(const P2P_hello_MESSAGE * hello,
+               int do_resolve) {
   char * ret;
   char inet6[INET6_ADDRSTRLEN];
-  Host6Address * haddr;
+  const Host6Address * haddr = (const Host6Address*) &hello[1];
+  const char * hn = "";
+  struct hostent * ent;
+  size_t n;
 
-  haddr = (Host6Address*) &helo[1];
-  ret = MALLOC(INET6_ADDRSTRLEN+16);
-  SNPRINTF(ret,
-          INET6_ADDRSTRLEN+16,
-          "%s:%d (TCP6)",
-          inet_ntop(AF_INET6,
-                    haddr,
-                    inet6,
-                    INET6_ADDRSTRLEN),
-          ntohs(haddr->port));
+#if HAVE_GETHOSTBYADDR
+  if (do_resolve) {
+    ent = gethostbyaddr(haddr,
+                       sizeof(IPaddr),
+                       AF_INET);
+    if (ent != NULL)
+      hn = ent->h_name;
+  }    
+#endif
+  n = INET6_ADDRSTRLEN + 16 + strlen(hn) + 10;
+  ret = MALLOC(n);
+  if (strlen(hn) > 0) {
+    SNPRINTF(ret,
+            n,
+            "%s (%s) TCP6 (%u)",
+            hn,
+            inet_ntop(AF_INET6,
+                      haddr,
+                      inet6,
+                      INET6_ADDRSTRLEN),
+            ntohs(haddr->port));
+  } else {
+    SNPRINTF(ret,
+            n,
+            "%s TCP6 (%u)",
+            inet_ntop(AF_INET6,
+                      haddr,
+                      inet6,
+                      INET6_ADDRSTRLEN),
+            ntohs(haddr->port));
+  }
   return ret;
 }
 

Modified: GNUnet/src/transports/tcp_old.c
===================================================================
--- GNUnet/src/transports/tcp_old.c     2006-12-29 03:51:51 UTC (rev 4089)
+++ GNUnet/src/transports/tcp_old.c     2006-12-29 04:23:37 UTC (rev 4090)
@@ -1230,19 +1230,40 @@
 /**
  * Convert TCP address to a string.
  */
-static char * addressToString(const P2P_hello_MESSAGE * helo) {
+static char * 
+addressToString(const P2P_hello_MESSAGE * hello,
+               int do_resolve) {
   char * ret;
-  HostAddress * haddr;
+  const HostAddress * haddr = (const HostAddress*) &hello[1];
   size_t n;
+  const char * hn = "";
+  struct hostent * ent;
 
-  haddr = (HostAddress*) &helo[1];
-  n = 4*4+6+6;
+#if HAVE_GETHOSTBYADDR
+  if (do_resolve) {
+    ent = gethostbyaddr(haddr,
+                       sizeof(IPaddr),
+                       AF_INET);
+    if (ent != NULL)
+      hn = ent->h_name;
+  }    
+#endif
+  n = 4*4+6+6 + strlen(hn) + 10;
   ret = MALLOC(n);
-  SNPRINTF(ret,
-          n,
-          "%u.%u.%u.%u:%u (TCP)",
-          PRIP(ntohl(*(int*)&haddr->ip.addr)),
-          ntohs(haddr->port));
+  if (strlen(hn) > 0) {
+    SNPRINTF(ret,
+            n,
+            "%s (%u.%u.%u.%u) TCP (%u)",
+            hn,
+            PRIP(ntohl(*(int*)&haddr->ip.addr)),
+            ntohs(haddr->port));
+  } else {
+    SNPRINTF(ret,
+            n,
+            "%u.%u.%u.%u TCP (%u)",
+            PRIP(ntohl(*(int*)&haddr->ip.addr)),
+            ntohs(haddr->port));
+  }
   return ret;
 }
 

Modified: GNUnet/src/transports/udp.c
===================================================================
--- GNUnet/src/transports/udp.c 2006-12-29 03:51:51 UTC (rev 4089)
+++ GNUnet/src/transports/udp.c 2006-12-29 04:23:37 UTC (rev 4090)
@@ -453,19 +453,40 @@
 /**
  * Convert UDP address to a string.
  */
-static char * addressToString(const P2P_hello_MESSAGE * helo) {
+static char * 
+addressToString(const P2P_hello_MESSAGE * hello,
+               int do_resolve) {
   char * ret;
-  HostAddress * haddr;
+  const HostAddress * haddr = (const HostAddress*) &hello[1];
   size_t n;
+  const char * hn = "";
+  struct hostent * ent;
 
-  haddr = (HostAddress*) &helo[1];
-  n = 4*4+6+6;
+#if HAVE_GETHOSTBYADDR
+  if (do_resolve) {
+    ent = gethostbyaddr(haddr,
+                       sizeof(IPaddr),
+                       AF_INET);
+    if (ent != NULL)
+      hn = ent->h_name;
+  }    
+#endif
+  n = 4*4+6+6 + strlen(hn) + 10;
   ret = MALLOC(n);
-  SNPRINTF(ret,
-          n,
-          "%u.%u.%u.%u:%u (UDP)",
-          PRIP(ntohl(*(int*)&haddr->senderIP.addr)),
-          ntohs(haddr->senderPort));
+  if (strlen(hn) > 0) {
+    SNPRINTF(ret,
+            n,
+            "%s (%u.%u.%u.%u) UDP (%u)",
+            hn,
+            PRIP(ntohl(*(int*)&haddr->senderIP.addr)),
+            ntohs(haddr->senderPort));
+  } else {
+    SNPRINTF(ret,
+            n,
+            "%u.%u.%u.%u UDP (%u)",
+            PRIP(ntohl(*(int*)&haddr->senderIP.addr)),
+            ntohs(haddr->senderPort));
+  }
   return ret;
 }
 

Modified: GNUnet/src/transports/udp6.c
===================================================================
--- GNUnet/src/transports/udp6.c        2006-12-29 03:51:51 UTC (rev 4089)
+++ GNUnet/src/transports/udp6.c        2006-12-29 04:23:37 UTC (rev 4090)
@@ -442,21 +442,47 @@
 /**
  * Convert UDP6 address to a string.
  */
-static char * addressToString(const P2P_hello_MESSAGE * helo) {
+static char * 
+addressToString(const P2P_hello_MESSAGE * hello,
+               int do_resolve) {
   char * ret;
   char inet6[INET6_ADDRSTRLEN];
-  Host6Address * haddr;
+  const Host6Address * haddr = (const Host6Address*) &hello[1];
+  const char * hn = "";
+  struct hostent * ent;
+  size_t n;
 
-  haddr = (Host6Address*) &helo[1];
-  ret = MALLOC(INET6_ADDRSTRLEN+16);
-  SNPRINTF(ret,
-          INET6_ADDRSTRLEN+16,
-          "%s:%d (UDP6)",
-          inet_ntop(AF_INET6,
-                    haddr,
-                    inet6,
-                    INET6_ADDRSTRLEN),
-          ntohs(haddr->senderPort));
+#if HAVE_GETHOSTBYADDR
+  if (do_resolve) {
+    ent = gethostbyaddr(haddr,
+                       sizeof(IPaddr),
+                       AF_INET);
+    if (ent != NULL)
+      hn = ent->h_name;
+  }    
+#endif
+  n = INET6_ADDRSTRLEN + 16 + strlen(hn) + 10;
+  ret = MALLOC(n);
+  if (strlen(hn) > 0) {
+    SNPRINTF(ret,
+            n,
+            "%s (%s) UDP6 (%u)",
+            hn,
+            inet_ntop(AF_INET6,
+                      haddr,
+                      inet6,
+                      INET6_ADDRSTRLEN),
+            ntohs(haddr->senderPort));
+  } else {
+    SNPRINTF(ret,
+            n,
+            "%s UDP6 (%u)",
+            inet_ntop(AF_INET6,
+                      haddr,
+                      inet6,
+                      INET6_ADDRSTRLEN),
+            ntohs(haddr->senderPort));
+  }
   return ret;
 }
 

Modified: GNUnet/todo
===================================================================
--- GNUnet/todo 2006-12-29 03:51:51 UTC (rev 4089)
+++ GNUnet/todo 2006-12-29 04:23:37 UTC (rev 4090)
@@ -15,13 +15,7 @@
 - Windows installer [Nils]
   * uninstall: Remove account
   * libcurl, guile
-- bugfixes:
-  Heikki reports:
-  Ran the current svn over 10 times under gdb (serializetest2)
-  One time it exited with status=1 and said
-  "Download suspended but search reference not set correctly."
 
-
 0.7.2 [3'07]:
 - new features:
   * XFS / support for location URIs [CG] 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]