]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Change interface of parse_addr_port() to return address in host order, since most...
authorNick Mathewson <nickm@torproject.org>
Sat, 16 Oct 2004 21:53:30 +0000 (21:53 +0000)
committerNick Mathewson <nickm@torproject.org>
Sat, 16 Oct 2004 21:53:30 +0000 (21:53 +0000)
svn:r2542

src/common/util.c
src/or/config.c
src/or/connection.c
src/or/rendservice.c

index 244eb11b4d8eda373b8cce58fa36f171f0233a9f..39c7311e6ba20c318e4ff33ee204e77bba3db044 100644 (file)
@@ -2066,7 +2066,7 @@ int tor_lookup_hostname(const char *name, uint32_t *addr)
  * <b>address</b> is provided, set *<b>address</b> to a copy of the
  * host portion of the string.  If <b>addr</b> is provided, try to
  * resolve the host portion of the string and store it into
- * *<b>addr</b> (in network byte order).  If <b>port</b> is provided,
+ * *<b>addr</b> (in host byte order).  If <b>port</b> is provided,
  * store the port number into *<b>port</b>, or 0 if no port is given.
  * Return 0 on success, -1 on failure.
  */
@@ -2102,6 +2102,7 @@ parse_addr_port(const char *addrport, char **address, uint32_t *addr,
       ok = 0;
       *addr = 0;
     }
+    *addr = ntohl(*addr);
   }
 
   if (address && ok) {
index 41ccd56bd35d1a88a38a7953e4fdd095ff224a42..dea2b6252729d9a50c55603a338be4dec6f8deda 100644 (file)
@@ -847,7 +847,6 @@ getconfig(int argc, char **argv, or_options_t *options)
       log(LOG_WARN,"HttpProxy failed to parse or resolve. Please fix.");
       result = -1;
     }
-    options->HttpProxyAddr = ntohl(options->HttpProxyAddr); /* switch to host-order */
     if (options->HttpProxyPort == 0) { /* give it a default */
       options->HttpProxyPort = 80;
     }
index 971ff370a4fffeefe2e744de5d83cef5da706c2e..87cb3c10d959f8f110cce4fcef35597c19dc502c 100644 (file)
@@ -317,17 +317,19 @@ static int connection_create_listener(const char *bindaddress, uint16_t bindport
   struct sockaddr_in bindaddr; /* where to bind */
   connection_t *conn;
   uint16_t usePort;
+  uint32_t addr;
   int s; /* the socket we're going to make */
   int one=1;
 
   memset(&bindaddr,0,sizeof(struct sockaddr_in));
-  if (parse_addr_port(bindaddress, NULL, &(bindaddr.sin_addr.s_addr),
-                      &usePort)<0) {
+  if (parse_addr_port(bindaddress, NULL, &addr, &usePort)<0) {
     log_fn(LOG_WARN, "Error parsing/resolving BindAddress %s",bindaddress);
     return -1;
   }
+  
   if (usePort==0)
     usePort = bindport;
+  binaddrr.sin_addr.s_addr = htonl(addr);
   bindaddr.sin_family = AF_INET;
   bindaddr.sin_port = htons((uint16_t) usePort);
 
index 090a3a7cf90a5f72185b49d2363f9b42d17eaa15..2c86b4385f1c22e72a94176ef173a7835affd9de 100644 (file)
@@ -165,13 +165,13 @@ static rend_service_port_config_t *parse_port_config(const char *string)
       log_fn(LOG_WARN, "Port out of range");
       return NULL;
     }
-    addr = htonl(0x7F000001u); /* Default to 127.0.0.1 */
+    addr = 0x7F000001u; /* Default to 127.0.0.1 */
   }
 
   result = tor_malloc(sizeof(rend_service_port_config_t));
   result->virtual_port = virtport;
   result->real_port = realport;
-  result->real_address = ntohl(addr);
+  result->real_address = addr;
   return result;
 }