summaryrefslogtreecommitdiff
path: root/src/or/networkstatus.c
diff options
context:
space:
mode:
authorAndrea Shepard <andrea@torproject.org>2016-06-28 02:21:39 +0000
committerAndrea Shepard <andrea@torproject.org>2016-06-29 05:55:42 +0000
commit8798ca4be299855a9a87a48df772081e06e9040c (patch)
treeec60d000b9012f0110ce2aa8cbe77ddacafa81b5 /src/or/networkstatus.c
parent18c6e139932630615bf3fee232dc5e08fac42449 (diff)
downloadtor-8798ca4be299855a9a87a48df772081e06e9040c.tar.gz
tor-8798ca4be299855a9a87a48df772081e06e9040c.zip
Add router descriptor download status queries to GETINFO
Diffstat (limited to 'src/or/networkstatus.c')
-rw-r--r--src/or/networkstatus.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c
index 45688b18f6..a582b852ae 100644
--- a/src/or/networkstatus.c
+++ b/src/or/networkstatus.c
@@ -659,6 +659,43 @@ router_get_consensus_status_by_descriptor_digest(networkstatus_t *consensus,
consensus, digest);
}
+/** Return a smartlist of all router descriptor digests in a consensus */
+static smartlist_t *
+router_get_descriptor_digests_in_consensus(networkstatus_t *consensus)
+{
+ smartlist_t *result = smartlist_new();
+ digestmap_iter_t *i;
+ const char *digest;
+ void *rs;
+ char *digest_tmp;
+
+ for (i = digestmap_iter_init(consensus->desc_digest_map);
+ !(digestmap_iter_done(i));
+ i = digestmap_iter_next(consensus->desc_digest_map, i)) {
+ digestmap_iter_get(i, &digest, &rs);
+ digest_tmp = tor_malloc(DIGEST_LEN);
+ memcpy(digest_tmp, digest, DIGEST_LEN);
+ smartlist_add(result, digest_tmp);
+ }
+
+ return result;
+}
+
+/** Return a smartlist of all router descriptor digests in the current
+ * consensus */
+smartlist_t *
+router_get_descriptor_digests(void)
+{
+ smartlist_t *result = NULL;
+
+ if (current_ns_consensus) {
+ result =
+ router_get_descriptor_digests_in_consensus(current_ns_consensus);
+ }
+
+ return result;
+}
+
/** Given the digest of a router descriptor, return its current download
* status, or NULL if the digest is unrecognized. */
MOCK_IMPL(download_status_t *,