[or-cvs] Switch most uses of *_by_addr_port to *_by_identity_digest

Nick Mathewson nickm at seul.org
Thu Jul 1 23:13:09 UTC 2004


Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/tmp/cvs-serv24037/src/or

Modified Files:
	circuitbuild.c connection_or.c cpuworker.c router.c 
	routerlist.c 
Log Message:
Switch most uses of *_by_addr_port to *_by_identity_digest

Index: circuitbuild.c
===================================================================
RCS file: /home/or/cvsroot/src/or/circuitbuild.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- circuitbuild.c	1 Jul 2004 01:16:58 -0000	1.3
+++ circuitbuild.c	1 Jul 2004 23:13:04 -0000	1.4
@@ -77,7 +77,7 @@
   hop=circ->cpath;
   do {
     s = buf + strlen(buf);
-    router = router_get_by_addr_port(hop->addr,hop->port);
+    router = router_get_by_digest(hop->identity_digest);
     if(router) {
       snprintf(s, sizeof(buf) - (s - buf), "%s(%s) ",
                router->nickname, states[hop->state]);
@@ -115,7 +115,7 @@
     prev_nickname = options.Nickname;
   }
   do {
-    router = router_get_by_addr_port(hop->addr,hop->port);
+    router = router_get_by_digest(hop->identity_digest);
     if (router) {
       if (prev_nickname) {
         if (hop->state == CPATH_STATE_OPEN)
@@ -218,7 +218,8 @@
 
   log_fn(LOG_DEBUG,"Looking for firsthop '%s:%u'",
       firsthop->address,firsthop->or_port);
-  n_conn = connection_twin_get_by_addr_port(firsthop->addr,firsthop->or_port);
+  n_conn = connection_get_by_identity_digest(firsthop->identity_digest,
+                                             CONN_TYPE_OR);
   if(!n_conn || n_conn->state != OR_CONN_STATE_OPEN) { /* not currently connected */
     circ->n_addr = firsthop->addr;
     circ->n_port = firsthop->or_port;
@@ -954,7 +955,8 @@
       goto next_i_loop;
     }
     if(options.ORPort) {
-      conn = connection_exact_get_by_addr_port(r->addr, r->or_port);
+      conn = connection_get_by_identity_digest(r->identity_digest,
+                                               CONN_TYPE_OR);
       if(!conn || conn->type != CONN_TYPE_OR || conn->state != OR_CONN_STATE_OPEN) {
         log_fn(LOG_DEBUG,"Nope, %d is not connected.",i);
         goto next_i_loop;
@@ -1090,7 +1092,7 @@
     remove_twins_from_smartlist(sl,router_get_by_nickname(state->chosen_exit));
     remove_twins_from_smartlist(sl,router_get_my_routerinfo());
     for (i = 0, cpath = *head_ptr; i < cur_len; ++i, cpath=cpath->next) {
-      r = router_get_by_addr_port(cpath->addr, cpath->port);
+      r = router_get_by_digest(cpath->identity_digest);
       tor_assert(r);
       remove_twins_from_smartlist(sl,r);
     }

Index: connection_or.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection_or.c,v
retrieving revision 1.110
retrieving revision 1.111
diff -u -d -r1.110 -r1.111
--- connection_or.c	1 Jul 2004 01:16:58 -0000	1.110
+++ connection_or.c	1 Jul 2004 23:13:04 -0000	1.111
@@ -160,7 +160,8 @@
 
   /* this function should never be called if we're already connected to router, but */
   /* check first to be sure */
-  conn = connection_exact_get_by_addr_port(router->addr,router->or_port);
+  conn = connection_get_by_identity_digest(router->identity_digest,
+                                           CONN_TYPE_OR);
   if(conn)
     return conn;
 
@@ -304,7 +305,7 @@
       return -1;
     }
   } else {
-    if((c=connection_exact_get_by_addr_port(router->addr,router->or_port))) {
+    if((c=connection_get_by_identity_digest(router->identity_digest, CONN_TYPE_OR))) {
       log_fn(LOG_INFO,"Router %s is already connected on fd %d. Dropping fd %d.", router->nickname, c->s, conn->s);
       return -1;
     }

Index: cpuworker.c
===================================================================
RCS file: /home/or/cvsroot/src/or/cpuworker.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- cpuworker.c	5 Jun 2004 01:56:54 -0000	1.44
+++ cpuworker.c	1 Jul 2004 23:13:04 -0000	1.45
@@ -132,6 +132,8 @@
     /* parse out the circ it was talking about */
     tag_unpack(buf, &addr, &port, &circ_id);
     circ = NULL;
+    /* XXXX This is actually right: we want a specific port here in
+     * case there are multiple connections. */
     p_conn = connection_exact_get_by_addr_port(addr,port);
     if(p_conn)
       circ = circuit_get_by_circ_id_conn(circ_id, p_conn);

Index: router.c
===================================================================
RCS file: /home/or/cvsroot/src/or/router.c,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -d -r1.55 -r1.56
--- router.c	1 Jul 2004 11:32:26 -0000	1.55
+++ router.c	1 Jul 2004 23:13:04 -0000	1.56
@@ -317,7 +317,8 @@
     router = smartlist_get(rl->routers, i);
     if(router_is_me(router))
       continue;
-    if(!connection_exact_get_by_addr_port(router->addr,router->or_port)) {
+    if(!connection_get_by_identity_digest(router->identity_digest,
+                                          CONN_TYPE_OR)) {
       /* not in the list */
       log_fn(LOG_DEBUG,"connecting to OR %s:%u.",router->address,router->or_port);
       connection_or_connect(router);

Index: routerlist.c
===================================================================
RCS file: /home/or/cvsroot/src/or/routerlist.c,v
retrieving revision 1.90
retrieving revision 1.91
diff -u -d -r1.90 -r1.91
--- routerlist.c	1 Jul 2004 01:16:59 -0000	1.90
+++ routerlist.c	1 Jul 2004 23:13:04 -0000	1.91
@@ -147,7 +147,8 @@
     router = smartlist_get(routerlist->routers, i);
     if(router->is_running &&
        (!options.ORPort ||
-        connection_twin_get_by_addr_port(router->addr, router->or_port) ))
+        connection_get_by_identity_digest(router->identity_digest,
+                                          CONN_TYPE_OR)))
       smartlist_add(sl, router);
   }
 }



More information about the tor-commits mailing list