if(test_aci == 0)
return get_unique_aci_by_addr_port(addr, port, aci_type); /* try again */
- conn = connection_get_by_addr_port(addr,port);
+ conn = connection_exact_get_by_addr_port(addr,port);
if(!conn) /* there can't be a conflict -- no connection of that sort yet */
return test_aci;
}
if(circ->n_addr && circ->n_port) { /* must send create cells to the next router */
- n_conn = connection_get_by_addr_port(circ->n_addr,circ->n_port);
+ n_conn = connection_twin_get_by_addr_port(circ->n_addr,circ->n_port);
if(!n_conn || n_conn->type != CONN_TYPE_OR) {
/* i've disabled making connections through OPs, but it's definitely
* possible here. I'm not sure if it would be a bug or a feature. -RD
if(role & ROLE_OR_CONNECT_ALL) {
for (i=0;i<rarray_len;i++) {
router = router_array[i];
- if(!connection_get_by_addr_port(router->addr,router->or_port)) { /* not in the list */
+ if(!connection_exact_get_by_addr_port(router->addr,router->or_port)) { /* not in the list */
log(LOG_DEBUG,"retry_all_connections(): connecting to OR %s:%u.",router->address,ntohs(router->or_port));
connection_or_connect_as_or(router, prkey, &local);
}
log(LOG_DEBUG,"ap_handshake_establish_circuit(): Looking for firsthop '%s:%u'",
firsthop->address,ntohs(firsthop->or_port));
- n_conn = connection_get_by_addr_port(firsthop->addr,firsthop->or_port);
+ n_conn = connection_twin_get_by_addr_port(firsthop->addr,firsthop->or_port);
if(!n_conn) { /* not currently connected */
if(global_role & ROLE_OR_CONNECT_ALL) { /* we would be connected if he were up. but he's not. */
log(LOG_DEBUG,"ap_handshake_establish_circuit(): Route's firsthop isn't connected.");
log(LOG_DEBUG,"or_handshake_server_process_auth() : Router identified as %s:%u.",
router->address,ntohs(router->or_port));
- if(connection_get_by_addr_port(addr,port)) {
+ if(connection_exact_get_by_addr_port(addr,port)) {
log(LOG_DEBUG,"or_handshake_server_process_auth(): That router is already connected. Dropping.");
return -1;
}
return 0;
}
-connection_t *connection_get_by_addr_port(uint32_t addr, uint16_t port) {
+connection_t *connection_twin_get_by_addr_port(uint32_t addr, uint16_t port) {
+ int i;
+ connection_t *conn;
+
+ /* first check if it's there exactly */
+ conn = connection_exact_get_by_addr_port(addr,port);
+ if(conn)
+ return conn;
+
+ /* now check if any of the other open connections are a twin for this one */
+
+ /* XXX */
+
+ /* guess not */
+ return NULL;
+
+}
+
+connection_t *connection_exact_get_by_addr_port(uint32_t addr, uint16_t port) {
int i;
connection_t *conn;
int connection_remove(connection_t *conn);
void connection_set_poll_socket(connection_t *conn);
-connection_t *connection_get_by_addr_port(uint32_t addr, uint16_t port);
+connection_t *connection_twin_get_by_addr_port(uint32_t addr, uint16_t port);
+connection_t *connection_exact_get_by_addr_port(uint32_t addr, uint16_t port);
connection_t *connection_get_by_type(int type);