add 'advertisedbandwidth' to router descriptor

svn:r2028
This commit is contained in:
Roger Dingledine 2004-07-12 18:02:54 +00:00
parent 17e5f25214
commit e167eeb18e
4 changed files with 11 additions and 9 deletions

View File

@ -578,6 +578,8 @@ typedef struct {
uint32_t bandwidthrate; /**< How many bytes does this OR add to its token uint32_t bandwidthrate; /**< How many bytes does this OR add to its token
* bucket per second? */ * bucket per second? */
uint32_t bandwidthburst; /**< How large is this OR's token bucket? */ 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 struct exit_policy_t *exit_policy; /**< What streams will this OR permit
* to exit? */ * to exit? */
/* local info */ /* local info */

View File

@ -542,7 +542,7 @@ int router_dump_router_to_string(char *s, int maxlen, routerinfo_t *router,
"router %s %s %d %d %d\n" "router %s %s %d %d %d\n"
"platform %s\n" "platform %s\n"
"published %s\n" "published %s\n"
"bandwidth %d %d\n" "bandwidth %d %d %d\n"
"onion-key\n%s" "onion-key\n%s"
"signing-key\n%s", "signing-key\n%s",
router->nickname, router->nickname,
@ -557,6 +557,7 @@ int router_dump_router_to_string(char *s, int maxlen, routerinfo_t *router,
published, published,
(int) router->bandwidthrate, (int) router->bandwidthrate,
(int) router->bandwidthburst, (int) router->bandwidthburst,
(int) router->advertisedbandwidth,
onion_pkey, identity_pkey); onion_pkey, identity_pkey);
tor_free(onion_pkey); tor_free(onion_pkey);

View File

@ -662,12 +662,6 @@ routerinfo_t *router_parse_entry_from_string(const char *s,
router->socks_port = atoi(tok->args[3]); router->socks_port = atoi(tok->args[3]);
router->dir_port = atoi(tok->args[4]); router->dir_port = atoi(tok->args[4]);
ports_set = 1; 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 { } else {
log_fn(LOG_WARN,"Wrong # of arguments to \"router\" (%d)",tok->n_args); 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"); log_fn(LOG_WARN,"Redundant bandwidth line");
goto err; goto err;
} else if (tok) { } else if (tok) {
/* XXX set this to "< 3" once 0.0.7 is obsolete */
if (tok->n_args < 2) { if (tok->n_args < 2) {
log_fn(LOG_WARN,"Not enough arguments to \"bandwidth\""); log_fn(LOG_WARN,"Not enough arguments to \"bandwidth\"");
goto err; goto err;
} }
router->bandwidthrate = atoi(tok->args[0]); router->bandwidthrate = atoi(tok->args[0]);
router->bandwidthburst = atoi(tok->args[1]); router->bandwidthburst = atoi(tok->args[1]);
if(tok->n_args > 2)
router->advertisedbandwidth = atoi(tok->args[2]);
bw_set = 1; bw_set = 1;
} }

View File

@ -682,6 +682,7 @@ test_dir_format()
r1.identity_pkey = pk2; r1.identity_pkey = pk2;
r1.bandwidthrate = 1000; r1.bandwidthrate = 1000;
r1.bandwidthburst = 5000; r1.bandwidthburst = 5000;
r1.advertisedbandwidth = 10000;
r1.exit_policy = NULL; r1.exit_policy = NULL;
r1.nickname = "Magri"; r1.nickname = "Magri";
r1.platform = tor_strdup(platform); r1.platform = tor_strdup(platform);
@ -706,7 +707,7 @@ test_dir_format()
r2.dir_port = 0; r2.dir_port = 0;
r2.onion_pkey = pk2; r2.onion_pkey = pk2;
r2.identity_pkey = pk1; r2.identity_pkey = pk1;
r2.bandwidthrate = r2.bandwidthburst = 3000; r2.bandwidthrate = r2.bandwidthburst = r2.advertisedbandwidth = 3000;
r2.exit_policy = &ex1; r2.exit_policy = &ex1;
r2.nickname = "Fred"; r2.nickname = "Fred";
@ -725,7 +726,7 @@ test_dir_format()
strcat(buf2, get_uname()); strcat(buf2, get_uname());
strcat(buf2, "\n" strcat(buf2, "\n"
"published 1970-01-01 00:00:00\n" "published 1970-01-01 00:00:00\n"
"bandwidth 1000 5000\n" "bandwidth 1000 5000 10000\n"
"onion-key\n"); "onion-key\n");
strcat(buf2, pk1_str); strcat(buf2, pk1_str);
strcat(buf2, "signing-key\n"); strcat(buf2, "signing-key\n");
@ -745,6 +746,7 @@ test_dir_format()
test_eq(rp1->dir_port, r1.dir_port); test_eq(rp1->dir_port, r1.dir_port);
test_eq(rp1->bandwidthrate, r1.bandwidthrate); test_eq(rp1->bandwidthrate, r1.bandwidthrate);
test_eq(rp1->bandwidthburst, r1.bandwidthburst); 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->onion_pkey, pk1) == 0);
test_assert(crypto_pk_cmp_keys(rp1->identity_pkey, pk2) == 0); test_assert(crypto_pk_cmp_keys(rp1->identity_pkey, pk2) == 0);
test_assert(rp1->exit_policy == NULL); test_assert(rp1->exit_policy == NULL);