diff options
author | Peter Palfrader <peter@palfrader.org> | 2008-08-14 23:00:44 +0000 |
---|---|---|
committer | Peter Palfrader <peter@palfrader.org> | 2008-08-14 23:00:44 +0000 |
commit | 82f8050ac428416a91997003b205ac90019768dd (patch) | |
tree | f79e94527d760f5658ff54629a2c76466192fb6f /src/or/routerparse.c | |
parent | e8de3ff54d043407c490c538dc75f1566c478bff (diff) | |
download | tor-82f8050ac428416a91997003b205ac90019768dd.tar.gz tor-82f8050ac428416a91997003b205ac90019768dd.zip |
Parse policies and weight (bw) into routerstatuses
svn:r16550
Diffstat (limited to 'src/or/routerparse.c')
-rw-r--r-- | src/or/routerparse.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/or/routerparse.c b/src/or/routerparse.c index 0cc100a6e6..8c66127cf3 100644 --- a/src/or/routerparse.c +++ b/src/or/routerparse.c @@ -53,9 +53,11 @@ typedef enum { K_DIR_OPTIONS, K_CLIENT_VERSIONS, K_SERVER_VERSIONS, + K_P, K_R, K_S, K_V, + K_W, K_EVENTDNS, K_EXTRA_INFO, K_EXTRA_INFO_DIGEST, @@ -264,9 +266,11 @@ static token_rule_t extrainfo_token_table[] = { /** List of tokens allowable in the body part of v2 and v3 networkstatus * documents. */ static token_rule_t rtrstatus_token_table[] = { + T01("p", K_P, GE(2), NO_OBJ ), T1( "r", K_R, GE(8), NO_OBJ ), T1( "s", K_S, ARGS, NO_OBJ ), T01("v", K_V, CONCAT_ARGS, NO_OBJ ), + T01("w", K_W, ARGS, NO_OBJ ), T0N("opt", K_OPT, CONCAT_ARGS, OBJ_OK ), END_OF_TABLE }; @@ -1863,6 +1867,38 @@ routerstatus_parse_entry_from_string(memarea_t *area, } } + /* handle weighting/bandwidth info */ + if ((tok = find_first_by_keyword(tokens, K_W))) { + int i; + for (i=0; i < tok->n_args; ++i) { + if (!strcmpstart(tok->args[i], "Bandwidth=")) { + int ok; + rs->bandwidth = tor_parse_ulong(strchr(tok->args[i], '=')+1, 10, + 0, UINT32_MAX, &ok, NULL); + if (!ok) { + log_warn(LD_DIR, "Invalid Bandwidth %s", escaped(tok->args[i])); + goto err; + } + } + } + } + + /* parse exit policy summaries */ + if ((tok = find_first_by_keyword(tokens, K_P))) { + tor_assert(tok->n_args == 2); + if (!strcmp(tok->args[0], "accept")) + rs->exitsummarytype = ADDR_POLICY_ACCEPT; + else if (!strcmp(tok->args[0], "reject")) + rs->exitsummarytype = ADDR_POLICY_REJECT; + else { + log_warn(LD_DIR, "Unknown exit policy summary type %s.", + escaped(tok->args[0])); + goto err; + } + /* XXX weasel: parse this into ports and represent them somehow smart */ + rs->exitsummary = tor_strdup(tok->args[1]); + } + if (!strcasecmp(rs->nickname, UNNAMED_ROUTER_NICKNAME)) rs->is_named = 0; |