[or-cvs] add "advertisedbandwidth" to router descriptor

Roger Dingledine arma at seul.org
Mon Jul 12 18:02:57 UTC 2004


Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/or

Modified Files:
	or.h router.c routerparse.c test.c 
Log Message:
add 'advertisedbandwidth' to router descriptor


Index: or.h
===================================================================
RCS file: /home/or/cvsroot/src/or/or.h,v
retrieving revision 1.375
retrieving revision 1.376
diff -u -d -r1.375 -r1.376
--- or.h	2 Jul 2004 23:40:03 -0000	1.375
+++ or.h	12 Jul 2004 18:02:54 -0000	1.376
@@ -578,6 +578,8 @@
   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 */

Index: router.c
===================================================================
RCS file: /home/or/cvsroot/src/or/router.c,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -d -r1.61 -r1.62
--- router.c	7 Jul 2004 19:51:20 -0000	1.61
+++ router.c	12 Jul 2004 18:02:54 -0000	1.62
@@ -542,7 +542,7 @@
                     "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 @@
     published,
     (int) router->bandwidthrate,
     (int) router->bandwidthburst,
+    (int) router->advertisedbandwidth,
     onion_pkey, identity_pkey);
 
   tor_free(onion_pkey);

Index: routerparse.c
===================================================================
RCS file: /home/or/cvsroot/src/or/routerparse.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- routerparse.c	2 Jul 2004 23:40:03 -0000	1.9
+++ routerparse.c	12 Jul 2004 18:02:54 -0000	1.10
@@ -662,12 +662,6 @@
       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 @@
     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;
   }
 

Index: test.c
===================================================================
RCS file: /home/or/cvsroot/src/or/test.c,v
retrieving revision 1.96
retrieving revision 1.97
diff -u -d -r1.96 -r1.97
--- test.c	2 Jul 2004 23:40:03 -0000	1.96
+++ test.c	12 Jul 2004 18:02:54 -0000	1.97
@@ -682,6 +682,7 @@
   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 @@
   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 @@
   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_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);



More information about the tor-commits mailing list