summaryrefslogtreecommitdiff
path: root/src/feature/nodelist/describe.h
diff options
context:
space:
mode:
authorteor <teor@torproject.org>2019-08-19 16:35:24 +1000
committerteor <teor@torproject.org>2019-08-19 16:41:35 +1000
commit23844bc7399a3517af23fe7f6429333b9f66df9e (patch)
tree416fb3377b1fd98b608a1f633d197d8a57422ff0 /src/feature/nodelist/describe.h
parent03be44e216ed9e4cdba66e120094329df71e7dce (diff)
downloadtor-23844bc7399a3517af23fe7f6429333b9f66df9e.tar.gz
tor-23844bc7399a3517af23fe7f6429333b9f66df9e.zip
nodelist: Add support for multiple addresses in describe.c
Also prepare for unit tests. Part of 21003.
Diffstat (limited to 'src/feature/nodelist/describe.h')
-rw-r--r--src/feature/nodelist/describe.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/feature/nodelist/describe.h b/src/feature/nodelist/describe.h
index 05f52c47c9..6c0d6dc48d 100644
--- a/src/feature/nodelist/describe.h
+++ b/src/feature/nodelist/describe.h
@@ -24,4 +24,34 @@ const char *routerstatus_describe(const struct routerstatus_t *ri);
void router_get_verbose_nickname(char *buf, const routerinfo_t *router);
+#if defined(DESCRIBE_PRIVATE) || defined(TOR_UNIT_TESTS)
+
+/**
+ * Longest allowed output for an IPv4 address "255.255.255.255", with NO
+ * terminating NUL.
+ */
+#define IPV4_BUF_LEN_NO_NUL 15
+
+/**
+ * Longest allowed output of format_node_description, plus 1 character for
+ * NUL. This allows space for:
+ * "$FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF~xxxxxxxxxxxxxxxxxxx at"
+ * " 255.255.255.255 and [ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255]"
+ * plus a terminating NUL.
+ */
+#define NODE_DESC_BUF_LEN \
+ (MAX_VERBOSE_NICKNAME_LEN+4+IPV4_BUF_LEN_NO_NUL+5+TOR_ADDR_BUF_LEN)
+
+#endif /* defined(DESCRIBE_PRIVATE) || defined(TOR_UNIT_TESTS) */
+
+#ifdef TOR_UNIT_TESTS
+
+STATIC const char *format_node_description(char *buf,
+ const char *id_digest,
+ const char *nickname,
+ const tor_addr_t *addr,
+ uint32_t addr32h);
+
+#endif /* defined(TOR_UNIT_TESTS) */
+
#endif /* !defined(TOR_DESCRIBE_H) */