]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Note byte-order on result for parse_addr_port()
authorNick Mathewson <nickm@torproject.org>
Tue, 12 Oct 2004 16:02:15 +0000 (16:02 +0000)
committerNick Mathewson <nickm@torproject.org>
Tue, 12 Oct 2004 16:02:15 +0000 (16:02 +0000)
svn:r2444

src/common/util.c
src/or/test.c

index 4391ac24116d0b5bc3e4040348350b578e154f6c..5065e972162e66c51b7dcab2824c76be3799df93 100644 (file)
@@ -2032,9 +2032,9 @@ 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>.  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.
+ * *<b>addr</b> (in network 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.
  */
 int
 parse_addr_port(const char *addrport, char **address, uint32_t *addr,
index 4d74651edca974729b01d05cfb1ecdd07fed908b..6a13a9db6c7276d0da269974ec104b729ba35452 100644 (file)
@@ -640,12 +640,12 @@ test_util() {
   cp = NULL; u32 = 3; u16 = 3;
   test_assert(!parse_addr_port("1.2.3.4", &cp, &u32, &u16));
   test_streq(cp, "1.2.3.4");
-  test_eq(u32, 0x01020304u);
+  test_eq(u32, htonl(0x01020304u));
   test_eq(u16, 0);
   tor_free(cp);
   test_assert(!parse_addr_port("4.3.2.1:99", &cp, &u32, &u16));
   test_streq(cp, "4.3.2.1");
-  test_eq(u32, 0x04030201u);
+  test_eq(u32, htonl(0x04030201u));
   test_eq(u16, 99);
   tor_free(cp);
   test_assert(!parse_addr_port("nonexistent.address:4040", &cp, NULL, &u16));
@@ -654,7 +654,7 @@ test_util() {
   tor_free(cp);
   test_assert(!parse_addr_port("localhost:9999", &cp, &u32, &u16));
   test_streq(cp, "localhost");
-  test_eq(u32, 0x7f000001u);
+  test_eq(u32, htonl(0x7f000001u));
   test_eq(u16, 9999);
   tor_free(cp);
   u32 = 3;