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

[tor-commits] [tor/master] Generalize fmt_addr() to support IPv6 decorations.



commit da6e0993dc4a0037933a522e2f578c145f6538cc
Author: George Kadianakis <desnacked@xxxxxxxxxx>
Date:   Sat Mar 31 13:48:20 2012 +0200

    Generalize fmt_addr() to support IPv6 decorations.
---
 src/common/address.c |    4 ++--
 src/common/address.h |    4 +++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/common/address.c b/src/common/address.c
index 676c485..62cf16c 100644
--- a/src/common/address.c
+++ b/src/common/address.c
@@ -991,11 +991,11 @@ tor_dup_addr(const tor_addr_t *addr)
  * <b>fmt_addr</b> invalidates the last result of the function.  This
  * function is not thread-safe. */
 const char *
-fmt_addr(const tor_addr_t *addr)
+fmt_addr_impl(const tor_addr_t *addr, int decorate)
 {
   static char buf[TOR_ADDR_BUF_LEN];
   if (!addr) return "<null>";
-  if (tor_addr_to_str(buf, addr, sizeof(buf), 0))
+  if (tor_addr_to_str(buf, addr, sizeof(buf), decorate))
     return buf;
   else
     return "???";
diff --git a/src/common/address.h b/src/common/address.h
index ede035d..bdb14eb 100644
--- a/src/common/address.h
+++ b/src/common/address.h
@@ -135,7 +135,9 @@ tor_addr_eq_ipv4h(const tor_addr_t *a, uint32_t u)
 
 int tor_addr_lookup(const char *name, uint16_t family, tor_addr_t *addr_out);
 char *tor_dup_addr(const tor_addr_t *addr) ATTR_MALLOC;
-const char *fmt_addr(const tor_addr_t *addr);
+#define fmt_addr(a) fmt_addr_impl(a, 0)
+#define fmt_and_decorate_addr(a) fmt_addr_impl(a, 1)
+const char *fmt_addr_impl(const tor_addr_t *addr, int decorate);
 const char * fmt_addr32(uint32_t addr);
 int get_interface_address6(int severity, sa_family_t family, tor_addr_t *addr);
 



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits