summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2004-10-16 21:53:30 +0000
committerNick Mathewson <nickm@torproject.org>2004-10-16 21:53:30 +0000
commit47dc024f7eb268dca65949d68914aa29b2840711 (patch)
treef22f9795384bff92c731d95872804bc416abca82
parent8300c4ae6a0d55c40d94613b5e22cb25b5723bd1 (diff)
downloadtor-47dc024f7eb268dca65949d68914aa29b2840711.tar.gz
tor-47dc024f7eb268dca65949d68914aa29b2840711.zip
Change interface of parse_addr_port() to return address in host order, since most users seem to want that.
svn:r2542
-rw-r--r--src/common/util.c3
-rw-r--r--src/or/config.c1
-rw-r--r--src/or/connection.c6
-rw-r--r--src/or/rendservice.c4
4 files changed, 8 insertions, 6 deletions
diff --git a/src/common/util.c b/src/common/util.c
index 244eb11b4d..39c7311e6b 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -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) {
diff --git a/src/or/config.c b/src/or/config.c
index 41ccd56bd3..dea2b62527 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -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;
}
diff --git a/src/or/connection.c b/src/or/connection.c
index 971ff370a4..87cb3c10d9 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -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);
diff --git a/src/or/rendservice.c b/src/or/rendservice.c
index 090a3a7cf9..2c86b4385f 100644
--- a/src/or/rendservice.c
+++ b/src/or/rendservice.c
@@ -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;
}