aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2004-07-12 18:02:54 +0000
committerRoger Dingledine <arma@torproject.org>2004-07-12 18:02:54 +0000
commite167eeb18e344830d5bd0fc6b70720ac41721109 (patch)
tree20068b5b5959b60289752bb03c94ab199d15547b
parent17e5f25214b05a725aa7ec55cfae3a1a0416895f (diff)
downloadtor-e167eeb18e344830d5bd0fc6b70720ac41721109.tar
tor-e167eeb18e344830d5bd0fc6b70720ac41721109.tar.gz
add 'advertisedbandwidth' to router descriptor
svn:r2028
-rw-r--r--src/or/or.h2
-rw-r--r--src/or/router.c3
-rw-r--r--src/or/routerparse.c9
-rw-r--r--src/or/test.c6
4 files changed, 11 insertions, 9 deletions
diff --git a/src/or/or.h b/src/or/or.h
index b13a0af2c..47cb4c9f0 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -578,6 +578,8 @@ typedef struct {
uint32_t bandwidthrate; /**< How many bytes does this OR add to its token
* bucket per second? */
uint32_t bandwidthburst; /**< How large is this OR's token bucket? */
+ /** How many bytes/s is this router known to handle? */
+ uint32_t advertisedbandwidth;
struct exit_policy_t *exit_policy; /**< What streams will this OR permit
* to exit? */
/* local info */
diff --git a/src/or/router.c b/src/or/router.c
index e35c4e5da..4d1d6bf97 100644
--- a/src/or/router.c
+++ b/src/or/router.c
@@ -542,7 +542,7 @@ int router_dump_router_to_string(char *s, int maxlen, routerinfo_t *router,
"router %s %s %d %d %d\n"
"platform %s\n"
"published %s\n"
- "bandwidth %d %d\n"
+ "bandwidth %d %d %d\n"
"onion-key\n%s"
"signing-key\n%s",
router->nickname,
@@ -557,6 +557,7 @@ int router_dump_router_to_string(char *s, int maxlen, routerinfo_t *router,
published,
(int) router->bandwidthrate,
(int) router->bandwidthburst,
+ (int) router->advertisedbandwidth,
onion_pkey, identity_pkey);
tor_free(onion_pkey);
diff --git a/src/or/routerparse.c b/src/or/routerparse.c
index ccf77c9f7..5b8a18a3a 100644
--- a/src/or/routerparse.c
+++ b/src/or/routerparse.c
@@ -662,12 +662,6 @@ routerinfo_t *router_parse_entry_from_string(const char *s,
router->socks_port = atoi(tok->args[3]);
router->dir_port = atoi(tok->args[4]);
ports_set = 1;
- /* XXXX Remove this after everyone has moved to 0.0.6 */
- if (tok->n_args == 6) {
- router->bandwidthrate = atoi(tok->args[5]);
- router->bandwidthburst = router->bandwidthrate * 10;
- bw_set = 1;
- }
}
} else {
log_fn(LOG_WARN,"Wrong # of arguments to \"router\" (%d)",tok->n_args);
@@ -705,12 +699,15 @@ routerinfo_t *router_parse_entry_from_string(const char *s,
log_fn(LOG_WARN,"Redundant bandwidth line");
goto err;
} else if (tok) {
+ /* XXX set this to "< 3" once 0.0.7 is obsolete */
if (tok->n_args < 2) {
log_fn(LOG_WARN,"Not enough arguments to \"bandwidth\"");
goto err;
}
router->bandwidthrate = atoi(tok->args[0]);
router->bandwidthburst = atoi(tok->args[1]);
+ if(tok->n_args > 2)
+ router->advertisedbandwidth = atoi(tok->args[2]);
bw_set = 1;
}
diff --git a/src/or/test.c b/src/or/test.c
index 4dc914589..0ee0f2869 100644
--- a/src/or/test.c
+++ b/src/or/test.c
@@ -682,6 +682,7 @@ test_dir_format()
r1.identity_pkey = pk2;
r1.bandwidthrate = 1000;
r1.bandwidthburst = 5000;
+ r1.advertisedbandwidth = 10000;
r1.exit_policy = NULL;
r1.nickname = "Magri";
r1.platform = tor_strdup(platform);
@@ -706,7 +707,7 @@ test_dir_format()
r2.dir_port = 0;
r2.onion_pkey = pk2;
r2.identity_pkey = pk1;
- r2.bandwidthrate = r2.bandwidthburst = 3000;
+ r2.bandwidthrate = r2.bandwidthburst = r2.advertisedbandwidth = 3000;
r2.exit_policy = &ex1;
r2.nickname = "Fred";
@@ -725,7 +726,7 @@ test_dir_format()
strcat(buf2, get_uname());
strcat(buf2, "\n"
"published 1970-01-01 00:00:00\n"
- "bandwidth 1000 5000\n"
+ "bandwidth 1000 5000 10000\n"
"onion-key\n");
strcat(buf2, pk1_str);
strcat(buf2, "signing-key\n");
@@ -745,6 +746,7 @@ test_dir_format()
test_eq(rp1->dir_port, r1.dir_port);
test_eq(rp1->bandwidthrate, r1.bandwidthrate);
test_eq(rp1->bandwidthburst, r1.bandwidthburst);
+ test_eq(rp1->advertisedbandwidth, r1.advertisedbandwidth);
test_assert(crypto_pk_cmp_keys(rp1->onion_pkey, pk1) == 0);
test_assert(crypto_pk_cmp_keys(rp1->identity_pkey, pk2) == 0);
test_assert(rp1->exit_policy == NULL);