[or-cvs] [tor/master] Add ability to parse one or more m line from a vote.

Nick Mathewson nickm at seul.org
Mon Oct 19 04:48:28 UTC 2009


Author: Nick Mathewson <nickm at torproject.org>
Date: Thu, 20 Aug 2009 11:39:22 -0400
Subject: Add ability to parse one or more m line from a vote.
Commit: a7ba02f3f1dc267be81bf36f16bc1e69b34af050

---
 src/or/or.h          |   14 ++++++++++++++
 src/or/routerparse.c |   14 ++++++++++++++
 2 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/src/or/or.h b/src/or/or.h
index e7e3869..2c79542 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -1557,6 +1557,14 @@ typedef struct routerstatus_t {
 
 } routerstatus_t;
 
+/**DOCDOC*/
+typedef struct microdescriptor_t {
+  crypto_pk_env_t *onion_pkey;
+  smartlist_t *family;
+  char *exitsummary; /**< exit policy summary -
+                      * XXX weasel: this probably should not stay a string. */
+} microdescriptor_t;
+
 /** How many times will we try to download a router's descriptor before giving
  * up? */
 #define MAX_ROUTERDESC_DOWNLOAD_FAILURES 8
@@ -1599,6 +1607,11 @@ typedef struct networkstatus_v2_t {
                          * sorted by identity_digest. */
 } networkstatus_v2_t;
 
+typedef struct vote_microdesc_hash_t {
+  struct vote_microdesc_hash_t *next;
+  char *microdesc_hash_line;
+} vote_microdesc_hash_t;
+
 /** The claim about a single router, made in a vote. */
 typedef struct vote_routerstatus_t {
   routerstatus_t status; /**< Underlying 'status' object for this router.
@@ -1607,6 +1620,7 @@ typedef struct vote_routerstatus_t {
                    * networkstatus_t.known_flags. */
   char *version; /**< The version that the authority says this router is
                   * running. */
+  vote_microdesc_hash_t *microdesc;
 } vote_routerstatus_t;
 
 /** Information about a single voter in a vote or a consensus. */
diff --git a/src/or/routerparse.c b/src/or/routerparse.c
index bfcf20b..dd0d32e 100644
--- a/src/or/routerparse.c
+++ b/src/or/routerparse.c
@@ -55,6 +55,7 @@ typedef enum {
   K_S,
   K_V,
   K_W,
+  K_M,
   K_EVENTDNS,
   K_EXTRA_INFO,
   K_EXTRA_INFO_DIGEST,
@@ -321,6 +322,7 @@ static token_rule_t rtrstatus_token_table[] = {
   T1( "s",                   K_S,                   ARGS,    NO_OBJ ),
   T01("v",                   K_V,               CONCAT_ARGS, NO_OBJ ),
   T01("w",                   K_W,                   ARGS,    NO_OBJ ),
+  T0N("m",                   K_M,               CONCAT_ARGS, NO_OBJ ),
   T0N("opt",                 K_OPT,             CONCAT_ARGS, OBJ_OK ),
   END_OF_TABLE
 };
@@ -2050,6 +2052,18 @@ routerstatus_parse_entry_from_string(memarea_t *area,
     rs->has_exitsummary = 1;
   }
 
+  if (vote_rs) {
+    SMARTLIST_FOREACH_BEGIN(tokens, directory_token_t *, t) {
+      if (t->tp == K_M && t->n_args) {
+        vote_microdesc_hash_t *line =
+          tor_malloc(sizeof(vote_microdesc_hash_t));
+        line->next = vote_rs->microdesc;
+        line->microdesc_hash_line = tor_strdup(t->args[0]);
+        vote_rs->microdesc = line;
+      }
+    } SMARTLIST_FOREACH_END(t);
+  }
+
   if (!strcasecmp(rs->nickname, UNNAMED_ROUTER_NICKNAME))
     rs->is_named = 0;
 
-- 
1.5.6.5




More information about the tor-commits mailing list