[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r16550: {tor} Parse policies and weight (bw) into routerstatuses (tor/trunk/src/or)
Author: weasel
Date: 2008-08-14 19:00:44 -0400 (Thu, 14 Aug 2008)
New Revision: 16550
Modified:
tor/trunk/src/or/or.h
tor/trunk/src/or/routerparse.c
Log:
Parse policies and weight (bw) into routerstatuses
Modified: tor/trunk/src/or/or.h
===================================================================
--- tor/trunk/src/or/or.h 2008-08-14 18:01:20 UTC (rev 16549)
+++ tor/trunk/src/or/or.h 2008-08-14 23:00:44 UTC (rev 16550)
@@ -1415,6 +1415,13 @@
* we can get v3 downloads from. */
unsigned int version_supports_v3_dir:1;
+ uint32_t bandwidth; /**< Bandwidth (capacity) of the router as reported in
+ * the vote/consensus, in kilobytes/sec. */
+ addr_policy_action_t exitsummarytype; /**< is the list of ports a list of
+ * rejected or accepted ports? */
+ char *exitsummary; /**< exit policy summary -
+ * XXX weasel: this probably should not stay a string. */
+
/* ---- The fields below aren't derived from the networkstatus; they
* hold local information only. */
Modified: tor/trunk/src/or/routerparse.c
===================================================================
--- tor/trunk/src/or/routerparse.c 2008-08-14 18:01:20 UTC (rev 16549)
+++ tor/trunk/src/or/routerparse.c 2008-08-14 23:00:44 UTC (rev 16550)
@@ -53,9 +53,11 @@
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 @@
/** 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 @@
}
}
+ /* 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;