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

[or-cvs] r8358: parameterize the loudness of get_interface_address() (in tor/trunk/src: common or)



Author: arma
Date: 2006-09-09 15:20:27 -0400 (Sat, 09 Sep 2006)
New Revision: 8358

Modified:
   tor/trunk/src/common/util.c
   tor/trunk/src/common/util.h
   tor/trunk/src/or/config.c
   tor/trunk/src/or/connection.c
Log:
parameterize the loudness of get_interface_address()


Modified: tor/trunk/src/common/util.c
===================================================================
--- tor/trunk/src/common/util.c	2006-09-09 19:16:07 UTC (rev 8357)
+++ tor/trunk/src/common/util.c	2006-09-09 19:20:27 UTC (rev 8358)
@@ -1770,7 +1770,7 @@
  * failure.
  */
 int
-get_interface_address(uint32_t *addr)
+get_interface_address(int severity, uint32_t *addr)
 {
   int sock=-1, r=-1;
   struct sockaddr_in target_addr, my_addr;
@@ -1782,7 +1782,8 @@
   sock = socket(PF_INET,SOCK_DGRAM,IPPROTO_UDP);
   if (sock < 0) {
     int e = tor_socket_errno(-1);
-    log_warn(LD_NET, "unable to create socket: %s", tor_socket_strerror(e));
+    log_fn(severity, LD_NET, "unable to create socket: %s",
+           tor_socket_strerror(e));
     goto err;
   }
 
@@ -1796,14 +1797,15 @@
 
   if (connect(sock,(struct sockaddr *)&target_addr,sizeof(target_addr))<0) {
     int e = tor_socket_errno(sock);
-    log_warn(LD_NET, "connect() failed: %s", tor_socket_strerror(e));
+    log_fn(severity, LD_NET, "connect() failed: %s", tor_socket_strerror(e));
     goto err;
   }
 
   /* XXXX Can this be right on IPv6 clients? */
   if (getsockname(sock, (struct sockaddr*)&my_addr, &my_addr_len)) {
     int e = tor_socket_errno(sock);
-    log_warn(LD_NET, "getsockname() failed: %s", tor_socket_strerror(e));
+    log_fn(severity, LD_NET, "getsockname() failed: %s",
+           tor_socket_strerror(e));
     goto err;
   }
 

Modified: tor/trunk/src/common/util.h
===================================================================
--- tor/trunk/src/common/util.h	2006-09-09 19:16:07 UTC (rev 8357)
+++ tor/trunk/src/common/util.h	2006-09-09 19:20:27 UTC (rev 8358)
@@ -200,7 +200,7 @@
 int tor_inet_ntoa(struct in_addr *in, char *buf, size_t buf_len);
 char *tor_dup_addr(uint32_t addr) ATTR_MALLOC;
 int is_plausible_address(const char *name);
-int get_interface_address(uint32_t *addr);
+int get_interface_address(int severity, uint32_t *addr);
 
 /* Process helpers */
 void start_daemon(void);

Modified: tor/trunk/src/or/config.c
===================================================================
--- tor/trunk/src/or/config.c	2006-09-09 19:16:07 UTC (rev 8357)
+++ tor/trunk/src/or/config.c	2006-09-09 19:20:27 UTC (rev 8358)
@@ -1638,7 +1638,7 @@
       log_fn(notice_severity, LD_CONFIG,
              "Could not resolve guessed local hostname '%s'. "
              "Trying something else.", hostname);
-      if (get_interface_address(&interface_ip)) {
+      if (get_interface_address(warn_severity, &interface_ip)) {
         log_fn(warn_severity, LD_CONFIG,
                "Could not get local interface IP address. Failing.");
         return -1;
@@ -1661,7 +1661,7 @@
                "resolves to a private IP address (%s).  Trying something "
                "else.", hostname, tmpbuf);
 
-        if (get_interface_address(&interface_ip)) {
+        if (get_interface_address(warn_severity, &interface_ip)) {
           log_fn(warn_severity, LD_CONFIG,
                  "Could not get local interface IP address. Too bad.");
         } else if (is_internal_IP(interface_ip, 0)) {

Modified: tor/trunk/src/or/connection.c
===================================================================
--- tor/trunk/src/or/connection.c	2006-09-09 19:16:07 UTC (rev 8357)
+++ tor/trunk/src/or/connection.c	2006-09-09 19:20:27 UTC (rev 8358)
@@ -1999,7 +1999,7 @@
   uint32_t *ip;
 
   if (!last_interface_ip)
-    get_interface_address(&last_interface_ip);
+    get_interface_address(LOG_INFO, &last_interface_ip);
   if (!outgoing_addrs)
     outgoing_addrs = smartlist_create();
 
@@ -2017,7 +2017,7 @@
 
   /* Uh-oh.  We haven't connected from this address before. Has the interface
    * address changed? */
-  if (get_interface_address(&iface_ip)<0)
+  if (get_interface_address(LOG_INFO, &iface_ip)<0)
     return;
   ip = tor_malloc(sizeof(uint32_t));
   *ip = ip_out;