aboutsummaryrefslogtreecommitdiff
path: root/src/or/router.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2009-03-18 19:30:26 +0000
committerNick Mathewson <nickm@torproject.org>2009-03-18 19:30:26 +0000
commite591aafca420b673a63881573581a9cdb178c3f9 (patch)
tree1e42c39f3380fb284d4506449e3830524842a5c4 /src/or/router.c
parent49308dcc7ad498d03d5460c0078d1e684cb1a1a2 (diff)
downloadtor-e591aafca420b673a63881573581a9cdb178c3f9.tar.gz
tor-e591aafca420b673a63881573581a9cdb178c3f9.zip
Add a function to get a LongName from a routerstatus. Needed for partial bug 941 fix.
svn:r19077
Diffstat (limited to 'src/or/router.c')
-rw-r--r--src/or/router.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/or/router.c b/src/or/router.c
index f3e09e6db2..ec33eb5905 100644
--- a/src/or/router.c
+++ b/src/or/router.c
@@ -1980,7 +1980,7 @@ is_legal_hexdigest(const char *s)
* The router's nickname.
**/
void
-router_get_verbose_nickname(char *buf, routerinfo_t *router)
+router_get_verbose_nickname(char *buf, const routerinfo_t *router)
{
buf[0] = '$';
base16_encode(buf+1, HEX_DIGEST_LEN+1, router->cache_info.identity_digest,
@@ -1989,6 +1989,23 @@ router_get_verbose_nickname(char *buf, routerinfo_t *router)
strlcpy(buf+1+HEX_DIGEST_LEN+1, router->nickname, MAX_NICKNAME_LEN+1);
}
+/** Set <b>buf</b> (which must have MAX_VERBOSE_NICKNAME_LEN+1 bytes) to the
+ * verbose representation of the identity of <b>router</b>. The format is:
+ * A dollar sign.
+ * The upper-case hexadecimal encoding of the SHA1 hash of router's identity.
+ * A "=" if the router is named; a "~" if it is not.
+ * The router's nickname.
+ **/
+void
+routerstatus_get_verbose_nickname(char *buf, const routerstatus_t *router)
+{
+ buf[0] = '$';
+ base16_encode(buf+1, HEX_DIGEST_LEN+1, router->identity_digest,
+ DIGEST_LEN);
+ buf[1+HEX_DIGEST_LEN] = router->is_named ? '=' : '~';
+ strlcpy(buf+1+HEX_DIGEST_LEN+1, router->nickname, MAX_NICKNAME_LEN+1);
+}
+
/** Forget that we have issued any router-related warnings, so that we'll
* warn again if we see the same errors. */
void