diff --git a/ChangeLog b/ChangeLog index 15f7c5287a..0c7f3816d3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -40,7 +40,7 @@ Changes in version 0.2.0.1-alpha - 2007-??-?? o Minor bugfixes (other): - Stop allowing hibernating servers to be "stable" or "fast". - - Check return values from pthread_mutex functions. + - Check return values from pthread_mutex functions. - Don't save non-general-purpose router descriptors to the disk cache, because we have no way of remembering what their purpose was when we restart. @@ -56,6 +56,10 @@ Changes in version 0.2.0.1-alpha - 2007-??-?? - Correct the control spec to match how the code actually responds to 'getinfo addr-mappings/*'. + o Code simplifications and refactoring + - Stop passing around crypt_path_t pointers that are implicit in other + procedure arguments. + Changes in version 0.1.2.12-rc - 2007-03-16 o Major bugfixes: diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c index 7dd036e70f..c7ac520059 100644 --- a/src/or/circuitbuild.c +++ b/src/or/circuitbuild.c @@ -653,7 +653,7 @@ circuit_send_next_onion_skin(origin_circuit_t *circ) log_debug(LD_CIRC,"Sending extend relay cell."); /* send it to hop->prev, because it will transfer * it to a create cell and then send to hop */ - if (connection_edge_send_command(NULL, TO_CIRCUIT(circ), + if (relay_send_command_from_edge(0, TO_CIRCUIT(circ), RELAY_COMMAND_EXTEND, payload, payload_len, hop->prev) < 0) return 0; /* circuit is closed */ diff --git a/src/or/command.c b/src/or/command.c index 208df8b22f..e771a8e321 100644 --- a/src/or/command.c +++ b/src/or/command.c @@ -292,7 +292,7 @@ command_process_created_cell(cell_t *cell, or_connection_t *conn) log_debug(LD_OR, "Converting created cell to extended relay cell, sending."); connection_edge_send_command(NULL, circ, RELAY_COMMAND_EXTENDED, - cell->payload, ONIONSKIN_REPLY_LEN, NULL); + cell->payload, ONIONSKIN_REPLY_LEN); } } @@ -384,7 +384,7 @@ command_process_destroy_cell(cell_t *cell, or_connection_t *conn) log_debug(LD_OR, "Delivering 'truncated' back."); payload[0] = (char)reason; connection_edge_send_command(NULL, circ, RELAY_COMMAND_TRUNCATED, - payload, sizeof(payload), NULL); + payload, sizeof(payload)); } } } diff --git a/src/or/connection.c b/src/or/connection.c index 91c7a058dc..0d21ee759c 100644 --- a/src/or/connection.c +++ b/src/or/connection.c @@ -1506,7 +1506,7 @@ loop_again: connection_close_immediate(conn); /* Don't flush; connection is dead. */ if (CONN_IS_EDGE(conn)) { edge_connection_t *edge_conn = TO_EDGE_CONN(conn); - connection_edge_end_errno(edge_conn, edge_conn->cpath_layer); + connection_edge_end_errno(edge_conn); if (edge_conn->socks_request) /* broken, don't send a socks reply back */ edge_conn->socks_request->has_finished = 1; } @@ -1737,8 +1737,7 @@ connection_handle_write(connection_t *conn, int force) log_warn(LD_BUG, "getsockopt() syscall failed?! Please report to tor-ops."); if (CONN_IS_EDGE(conn)) - connection_edge_end_errno(TO_EDGE_CONN(conn), - TO_EDGE_CONN(conn)->cpath_layer); + connection_edge_end_errno(TO_EDGE_CONN(conn)); connection_mark_for_close(conn); return -1; } @@ -1747,8 +1746,7 @@ connection_handle_write(connection_t *conn, int force) if (!ERRNO_IS_CONN_EINPROGRESS(e)) { log_info(LD_NET,"in-progress connect failed. Removing."); if (CONN_IS_EDGE(conn)) - connection_edge_end_errno(TO_EDGE_CONN(conn), - TO_EDGE_CONN(conn)->cpath_layer); + connection_edge_end_errno(TO_EDGE_CONN(conn)); connection_close_immediate(conn); connection_mark_for_close(conn); @@ -1827,8 +1825,7 @@ connection_handle_write(connection_t *conn, int force) max_to_write, &conn->outbuf_flushlen)); if (result < 0) { if (CONN_IS_EDGE(conn)) - connection_edge_end_errno(TO_EDGE_CONN(conn), - TO_EDGE_CONN(conn)->cpath_layer); + connection_edge_end_errno(TO_EDGE_CONN(conn)); connection_close_immediate(conn); /* Don't flush; connection is dead. */ connection_mark_for_close(conn); diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c index beb1caeea6..4f326cdbdf 100644 --- a/src/or/connection_edge.c +++ b/src/or/connection_edge.c @@ -83,7 +83,7 @@ connection_edge_reached_eof(edge_connection_t *conn) if (!conn->_base.marked_for_close) { /* only mark it if not already marked. it's possible to * get the 'end' right around when the client hangs up on us. */ - connection_edge_end(conn, END_STREAM_REASON_DONE, conn->cpath_layer); + connection_edge_end(conn, END_STREAM_REASON_DONE); if (conn->socks_request) /* eof, so don't send a socks reply back */ conn->socks_request->has_finished = 1; connection_mark_for_close(TO_CONN(conn)); @@ -140,7 +140,7 @@ connection_edge_process_inbuf(edge_connection_t *conn, int package_partial) } log_warn(LD_BUG,"Got unexpected state %d. Closing.",conn->_base.state); tor_fragile_assert(); - connection_edge_end(conn, END_STREAM_REASON_INTERNAL, conn->cpath_layer); + connection_edge_end(conn, END_STREAM_REASON_INTERNAL); connection_mark_for_close(TO_CONN(conn)); return -1; } @@ -173,17 +173,14 @@ connection_edge_destroy(uint16_t circ_id, edge_connection_t *conn) return 0; } -/** Send a relay end cell from stream conn to conn's circuit, - * with a destination of cpath_layer. (If cpath_layer is NULL, the - * destination is the circuit's origin.) Set the relay end cell's - * reason for closing as reason. +/** Send a relay end cell from stream conn down conn's circuit. Set + * the relay end cell's reason for closing as reason. * * Return -1 if this function has already been called on this conn, * else return 0. */ int -connection_edge_end(edge_connection_t *conn, char reason, - crypt_path_t *cpath_layer) +connection_edge_end(edge_connection_t *conn, char reason) { char payload[RELAY_PAYLOAD_SIZE]; size_t payload_len=1; @@ -215,7 +212,7 @@ connection_edge_end(edge_connection_t *conn, char reason, if (circ && !circ->marked_for_close) { log_debug(LD_EDGE,"Sending end on conn (fd %d).",conn->_base.s); connection_edge_send_command(conn, circ, RELAY_COMMAND_END, - payload, payload_len, cpath_layer); + payload, payload_len); } else { log_debug(LD_EDGE,"No circ to send end on conn (fd %d).", conn->_base.s); @@ -227,16 +224,16 @@ connection_edge_end(edge_connection_t *conn, char reason, } /** An error has just occured on an operation on an edge connection - * conn. Extract the errno; convert it to an end reason, and send - * an appropriate relay end cell to cpath_layer. + * conn. Extract the errno; convert it to an end reason, and send an + * appropriate relay end cell to the other end of the connection's circuit. **/ int -connection_edge_end_errno(edge_connection_t *conn, crypt_path_t *cpath_layer) +connection_edge_end_errno(edge_connection_t *conn) { uint8_t reason; tor_assert(conn); reason = (uint8_t)errno_to_end_reason(tor_socket_errno(conn->_base.s)); - return connection_edge_end(conn, reason, cpath_layer); + return connection_edge_end(conn, reason); } /** Connection conn has finished writing and has no bytes left on @@ -305,8 +302,7 @@ connection_edge_finished_connecting(edge_connection_t *edge_conn) if (connection_edge_is_rendezvous_stream(edge_conn)) { if (connection_edge_send_command(edge_conn, circuit_get_by_edge_conn(edge_conn), - RELAY_COMMAND_CONNECTED, NULL, 0, - edge_conn->cpath_layer) < 0) + RELAY_COMMAND_CONNECTED, NULL, 0) < 0) return 0; /* circuit is closed, don't continue */ } else { char connected_payload[8]; @@ -316,8 +312,7 @@ connection_edge_finished_connecting(edge_connection_t *edge_conn) if (connection_edge_send_command(edge_conn, circuit_get_by_edge_conn(edge_conn), RELAY_COMMAND_CONNECTED, - connected_payload, 8, - edge_conn->cpath_layer) < 0) + connected_payload, 8) < 0) return 0; /* circuit is closed, don't continue */ } tor_assert(edge_conn->package_window > 0); @@ -408,8 +403,7 @@ connection_ap_expire_beginning(void) " '%s.onion'.", seconds_idle, safe_str(conn->socks_request->address)); - connection_edge_end(conn, END_STREAM_REASON_TIMEOUT, - conn->cpath_layer); + connection_edge_end(conn, END_STREAM_REASON_TIMEOUT); connection_mark_unattached_ap(conn, END_STREAM_REASON_TIMEOUT); } continue; @@ -423,7 +417,7 @@ connection_ap_expire_beginning(void) seconds_idle, safe_str(conn->socks_request->address), nickname ? nickname : "*unnamed*"); /* send an end down the circuit */ - connection_edge_end(conn, END_STREAM_REASON_TIMEOUT, conn->cpath_layer); + connection_edge_end(conn, END_STREAM_REASON_TIMEOUT); /* un-mark it as ending, since we're going to reuse it */ conn->_base.edge_has_sent_end = 0; conn->end_reason = 0; @@ -1782,8 +1776,7 @@ connection_ap_handshake_send_begin(edge_connection_t *ap_conn, if (connection_edge_send_command(ap_conn, TO_CIRCUIT(circ), begin_type, begin_type == RELAY_COMMAND_BEGIN ? payload : NULL, - begin_type == RELAY_COMMAND_BEGIN ? payload_len : 0, - ap_conn->cpath_layer) < 0) + begin_type == RELAY_COMMAND_BEGIN ? payload_len : 0) < 0) return -1; /* circuit is closed, don't continue */ ap_conn->package_window = STREAMWINDOW_START; @@ -1850,7 +1843,7 @@ connection_ap_handshake_send_resolve(edge_connection_t *ap_conn, if (connection_edge_send_command(ap_conn, TO_CIRCUIT(circ), RELAY_COMMAND_RESOLVE, - string_addr, payload_len, ap_conn->cpath_layer) < 0) + string_addr, payload_len) < 0) return -1; /* circuit is closed, don't continue */ ap_conn->_base.state = AP_CONN_STATE_RESOLVE_WAIT; @@ -2340,8 +2333,7 @@ connection_exit_connect(edge_connection_t *edge_conn) router_compare_to_my_exit_policy(edge_conn)) { log_info(LD_EXIT,"%s:%d failed exit policy. Closing.", escaped_safe_str(conn->address), conn->port); - connection_edge_end(edge_conn, END_STREAM_REASON_EXITPOLICY, - edge_conn->cpath_layer); + connection_edge_end(edge_conn, END_STREAM_REASON_EXITPOLICY); circuit_detach_stream(circuit_get_by_edge_conn(edge_conn), edge_conn); connection_free(conn); return; @@ -2373,7 +2365,7 @@ connection_exit_connect(edge_connection_t *edge_conn) log_debug(LD_EXIT,"about to try connecting"); switch (connection_connect(conn, conn->address, addr, port)) { case -1: - connection_edge_end_errno(edge_conn, edge_conn->cpath_layer); + connection_edge_end_errno(edge_conn); circuit_detach_stream(circuit_get_by_edge_conn(edge_conn), edge_conn); connection_free(conn); return; @@ -2402,7 +2394,7 @@ connection_exit_connect(edge_connection_t *edge_conn) connection_edge_send_command(edge_conn, circuit_get_by_edge_conn(edge_conn), RELAY_COMMAND_CONNECTED, - NULL, 0, edge_conn->cpath_layer); + NULL, 0); } else { /* normal stream */ /* This must be the original address, not the redirected address. */ char connected_payload[8]; @@ -2412,7 +2404,7 @@ connection_exit_connect(edge_connection_t *edge_conn) connection_edge_send_command(edge_conn, circuit_get_by_edge_conn(edge_conn), RELAY_COMMAND_CONNECTED, - connected_payload, 8, edge_conn->cpath_layer); + connected_payload, 8); } } @@ -2437,8 +2429,7 @@ connection_exit_connect_dir(edge_connection_t *exit_conn) "Couldn't construct socketpair (%s). " "Network down? Out of sockets?", tor_socket_strerror(-err)); - connection_edge_end(exit_conn, END_STREAM_REASON_RESOURCELIMIT, - exit_conn->cpath_layer); + connection_edge_end(exit_conn, END_STREAM_REASON_RESOURCELIMIT); connection_free(TO_CONN(exit_conn)); return 0; } @@ -2463,16 +2454,14 @@ connection_exit_connect_dir(edge_connection_t *exit_conn) dir_conn->_base.state = DIR_CONN_STATE_SERVER_COMMAND_WAIT; if (connection_add(TO_CONN(exit_conn))<0) { - connection_edge_end(exit_conn, END_STREAM_REASON_RESOURCELIMIT, - exit_conn->cpath_layer); + connection_edge_end(exit_conn, END_STREAM_REASON_RESOURCELIMIT); connection_free(TO_CONN(exit_conn)); connection_free(TO_CONN(dir_conn)); return 0; } if (connection_add(TO_CONN(dir_conn))<0) { - connection_edge_end(exit_conn, END_STREAM_REASON_RESOURCELIMIT, - exit_conn->cpath_layer); + connection_edge_end(exit_conn, END_STREAM_REASON_RESOURCELIMIT); connection_close_immediate(TO_CONN(exit_conn)); connection_mark_for_close(TO_CONN(exit_conn)); connection_free(TO_CONN(dir_conn)); @@ -2487,8 +2476,7 @@ connection_exit_connect_dir(edge_connection_t *exit_conn) if (connection_edge_send_command(exit_conn, circuit_get_by_edge_conn(exit_conn), - RELAY_COMMAND_CONNECTED, NULL, 0, - exit_conn->cpath_layer) < 0) { + RELAY_COMMAND_CONNECTED, NULL, 0) < 0) { connection_mark_for_close(TO_CONN(exit_conn)); connection_mark_for_close(TO_CONN(dir_conn)); return 0; diff --git a/src/or/control.c b/src/or/control.c index b644435a4c..e8ed0acdde 100644 --- a/src/or/control.c +++ b/src/or/control.c @@ -1931,8 +1931,7 @@ handle_control_attachstream(control_connection_t *conn, uint32_t len, /* Do we need to detach it first? */ if (ap_conn->_base.state != AP_CONN_STATE_CONTROLLER_WAIT) { circuit_t *tmpcirc = circuit_get_by_edge_conn(ap_conn); - connection_edge_end(ap_conn, END_STREAM_REASON_TIMEOUT, - ap_conn->cpath_layer); + connection_edge_end(ap_conn, END_STREAM_REASON_TIMEOUT); /* Un-mark it as ending, since we're going to reuse it. */ ap_conn->_base.edge_has_sent_end = 0; ap_conn->end_reason = 0; diff --git a/src/or/dns.c b/src/or/dns.c index 3cf106a04f..be60574a18 100644 --- a/src/or/dns.c +++ b/src/or/dns.c @@ -348,8 +348,7 @@ purge_expired_resolves(time_t now) /* Connections should only be pending if they have no socket. */ tor_assert(pend->conn->_base.s == -1); pendconn = pend->conn; - connection_edge_end(pendconn, END_STREAM_REASON_TIMEOUT, - pendconn->cpath_layer); + connection_edge_end(pendconn, END_STREAM_REASON_TIMEOUT); circuit_detach_stream(circuit_get_by_edge_conn(pendconn), pendconn); connection_free(TO_CONN(pendconn)); tor_free(pend); @@ -433,8 +432,7 @@ send_resolved_cell(edge_connection_t *conn, or_circuit_t *circ, } connection_edge_send_command(conn, TO_CIRCUIT(circ), - RELAY_COMMAND_RESOLVED, buf, buflen, - conn->cpath_layer); + RELAY_COMMAND_RESOLVED, buf, buflen); } /** Send a response to the RESOLVE request of a connection for an in-addr.arpa @@ -472,8 +470,7 @@ send_resolved_hostname_cell(edge_connection_t *conn, or_circuit_t *circ, // log_notice(LD_EXIT, "Sending a reply RESOLVED reply: %s", hostname); connection_edge_send_command(conn, TO_CIRCUIT(circ), - RELAY_COMMAND_RESOLVED, buf, buflen, - conn->cpath_layer); + RELAY_COMMAND_RESOLVED, buf, buflen); // log_notice(LD_EXIT, "Sent"); } @@ -817,8 +814,7 @@ dns_cancel_pending_resolve(const char *address) assert_connection_ok(TO_CONN(pendconn), 0); tor_assert(pendconn->_base.s == -1); if (!pendconn->_base.marked_for_close) { - connection_edge_end(pendconn, END_STREAM_REASON_RESOURCELIMIT, - pendconn->cpath_layer); + connection_edge_end(pendconn, END_STREAM_REASON_RESOURCELIMIT); } circ = circuit_get_by_edge_conn(pendconn); if (circ) @@ -953,8 +949,7 @@ dns_found_answer(const char *address, int is_reverse, uint32_t addr, /* prevent double-remove. */ pendconn->_base.state = EXIT_CONN_STATE_RESOLVEFAILED; if (pendconn->_base.purpose == EXIT_PURPOSE_CONNECT) { - connection_edge_end(pendconn, END_STREAM_REASON_RESOLVEFAILED, - pendconn->cpath_layer); + connection_edge_end(pendconn, END_STREAM_REASON_RESOLVEFAILED); /* This detach must happen after we send the end cell. */ circuit_detach_stream(circuit_get_by_edge_conn(pendconn), pendconn); } else { diff --git a/src/or/hibernate.c b/src/or/hibernate.c index 5ff2f5827b..8dd9997465 100644 --- a/src/or/hibernate.c +++ b/src/or/hibernate.c @@ -849,8 +849,7 @@ hibernate_go_dormant(time_t now) (conn = connection_get_by_type(CONN_TYPE_AP)) || (conn = connection_get_by_type(CONN_TYPE_EXIT))) { if (CONN_IS_EDGE(conn)) - connection_edge_end(TO_EDGE_CONN(conn), END_STREAM_REASON_HIBERNATING, - TO_EDGE_CONN(conn)->cpath_layer); + connection_edge_end(TO_EDGE_CONN(conn), END_STREAM_REASON_HIBERNATING); log_info(LD_NET,"Closing conn type %d", conn->type); if (conn->type == CONN_TYPE_AP) /* send socks failure if needed */ connection_mark_unattached_ap(TO_EDGE_CONN(conn), diff --git a/src/or/main.c b/src/or/main.c index 24caba0b52..77d8db1e3a 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -433,8 +433,7 @@ conn_read_callback(int fd, short event, void *_conn) tor_fragile_assert(); #endif if (CONN_IS_EDGE(conn)) - connection_edge_end_errno(TO_EDGE_CONN(conn), - TO_EDGE_CONN(conn)->cpath_layer); + connection_edge_end_errno(TO_EDGE_CONN(conn)); connection_mark_for_close(conn); } } diff --git a/src/or/or.h b/src/or/or.h index 62a3442c77..a468792201 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -2190,10 +2190,8 @@ int connection_edge_reached_eof(edge_connection_t *conn); int connection_edge_process_inbuf(edge_connection_t *conn, int package_partial); int connection_edge_destroy(uint16_t circ_id, edge_connection_t *conn); -int connection_edge_end(edge_connection_t *conn, char reason, - crypt_path_t *cpath_layer); -int connection_edge_end_errno(edge_connection_t *conn, - crypt_path_t *cpath_layer); +int connection_edge_end(edge_connection_t *conn, char reason); +int connection_edge_end_errno(edge_connection_t *conn); int connection_edge_finished_flushing(edge_connection_t *conn); int connection_edge_finished_connecting(edge_connection_t *conn); @@ -2623,8 +2621,7 @@ int relay_send_command_from_edge(uint16_t stream_id, circuit_t *circ, size_t payload_len, crypt_path_t *cpath_layer); int connection_edge_send_command(edge_connection_t *fromconn, circuit_t *circ, int relay_command, const char *payload, - size_t payload_len, - crypt_path_t *cpath_layer); + size_t payload_len); int connection_edge_package_raw_inbuf(edge_connection_t *conn, int package_partial); void connection_edge_consider_sending_sendme(edge_connection_t *conn); diff --git a/src/or/relay.c b/src/or/relay.c index ce7c29619f..3b8eed4c16 100644 --- a/src/or/relay.c +++ b/src/or/relay.c @@ -514,9 +514,10 @@ relay_send_command_from_edge(uint16_t stream_id, circuit_t *circ, int connection_edge_send_command(edge_connection_t *fromconn, circuit_t *circ, int relay_command, const char *payload, - size_t payload_len, crypt_path_t *cpath_layer) + size_t payload_len) { /* XXXX NM Split this function into a separate versions per circuit type? */ + crypt_path_t *cpath_layer = fromconn ? fromconn->cpath_layer : NULL; if (fromconn && fromconn->_base.marked_for_close) { log_warn(LD_BUG, @@ -882,8 +883,7 @@ connection_edge_process_relay_cell_not_open( if (!addr) { log_info(LD_APP, "...but it claims the IP address was 0.0.0.0. Closing."); - connection_edge_end(conn, END_STREAM_REASON_TORPROTOCOL, - conn->cpath_layer); + connection_edge_end(conn, END_STREAM_REASON_TORPROTOCOL); connection_mark_unattached_ap(conn, END_STREAM_REASON_TORPROTOCOL); return 0; } @@ -953,8 +953,7 @@ connection_edge_process_relay_cell_not_open( rh->command, conn->_base.state, conn_state_to_string(conn->_base.type, conn->_base.state)); return 0; /* for forward compatibility, don't kill the circuit */ -// connection_edge_end(conn, END_STREAM_REASON_TORPROTOCOL, -// conn->cpath_layer); +// connection_edge_end(conn, END_STREAM_REASON_TORPROTOCOL); // connection_mark_for_close(conn); // return -1; } @@ -1023,8 +1022,7 @@ connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ, (!layer_hint && --circ->deliver_window < 0)) { log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL, "(relay data) circ deliver_window below 0. Killing."); - connection_edge_end(conn, END_STREAM_REASON_TORPROTOCOL, - conn->cpath_layer); + connection_edge_end(conn, END_STREAM_REASON_TORPROTOCOL); connection_mark_for_close(TO_CONN(conn)); return -END_CIRC_REASON_TORPROTOCOL; } @@ -1117,7 +1115,7 @@ connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ, char payload[1]; payload[0] = (char)END_CIRC_REASON_REQUESTED; connection_edge_send_command(NULL, circ, RELAY_COMMAND_TRUNCATED, - payload, sizeof(payload), NULL); + payload, sizeof(payload)); } return 0; case RELAY_COMMAND_TRUNCATED: @@ -1280,7 +1278,7 @@ repeat_connection_edge_package_raw_inbuf: (int)length, (int)buf_datalen(conn->_base.inbuf)); if (connection_edge_send_command(conn, circ, RELAY_COMMAND_DATA, - payload, length, conn->cpath_layer) < 0) + payload, length) < 0 ) /* circuit got marked for close, don't continue, don't need to mark conn */ return 0; @@ -1332,7 +1330,7 @@ connection_edge_consider_sending_sendme(edge_connection_t *conn) (int)conn->_base.outbuf_flushlen); conn->deliver_window += STREAMWINDOW_INCREMENT; if (connection_edge_send_command(conn, circ, RELAY_COMMAND_SENDME, - NULL, 0, conn->cpath_layer) < 0) { + NULL, 0) < 0) { log_warn(LD_APP,"connection_edge_send_command failed. Returning."); return; /* the circuit's closed, don't continue */ } @@ -1447,7 +1445,7 @@ circuit_consider_sending_sendme(circuit_t *circ, crypt_path_t *layer_hint) layer_hint->deliver_window += CIRCWINDOW_INCREMENT; else circ->deliver_window += CIRCWINDOW_INCREMENT; - if (connection_edge_send_command(NULL, circ, RELAY_COMMAND_SENDME, + if (relay_send_command_from_edge(0, circ, RELAY_COMMAND_SENDME, NULL, 0, layer_hint) < 0) { log_warn(LD_CIRC, "connection_edge_send_command failed. Circuit's closed."); diff --git a/src/or/rendclient.c b/src/or/rendclient.c index eedb38deaa..fad32f648f 100644 --- a/src/or/rendclient.c +++ b/src/or/rendclient.c @@ -37,7 +37,7 @@ rend_client_send_establish_rendezvous(origin_circuit_t *circ) circuit_mark_for_close(TO_CIRCUIT(circ), END_CIRC_REASON_INTERNAL); return -1; } - if (connection_edge_send_command(NULL,TO_CIRCUIT(circ), + if (relay_send_command_from_edge(0, TO_CIRCUIT(circ), RELAY_COMMAND_ESTABLISH_RENDEZVOUS, circ->rend_cookie, REND_COOKIE_LEN, circ->cpath->prev)<0) { @@ -144,7 +144,7 @@ rend_client_send_introduction(origin_circuit_t *introcirc, tor_assert(DIGEST_LEN + r <= RELAY_PAYLOAD_SIZE); /* we overran something */ payload_len = DIGEST_LEN + r; - if (connection_edge_send_command(NULL, TO_CIRCUIT(introcirc), + if (relay_send_command_from_edge(0, TO_CIRCUIT(introcirc), RELAY_COMMAND_INTRODUCE1, payload, payload_len, introcirc->cpath->prev)<0) { diff --git a/src/or/rendmid.c b/src/or/rendmid.c index b5dcb4dbf6..c6f45a48ff 100644 --- a/src/or/rendmid.c +++ b/src/or/rendmid.c @@ -98,7 +98,7 @@ rend_mid_establish_intro(or_circuit_t *circ, const char *request, /* Acknowledge the request. */ if (connection_edge_send_command(NULL,TO_CIRCUIT(circ), RELAY_COMMAND_INTRO_ESTABLISHED, - "", 0, NULL)<0) { + "", 0)<0) { log_info(LD_GENERAL, "Couldn't send INTRO_ESTABLISHED cell."); goto err; } @@ -172,7 +172,7 @@ rend_mid_introduce(or_circuit_t *circ, const char *request, size_t request_len) /* Great. Now we just relay the cell down the circuit. */ if (connection_edge_send_command(NULL, TO_CIRCUIT(intro_circ), RELAY_COMMAND_INTRODUCE2, - request, request_len, NULL)) { + request, request_len)) { log_warn(LD_GENERAL, "Unable to send INTRODUCE2 cell to Tor client."); goto err; @@ -180,7 +180,7 @@ rend_mid_introduce(or_circuit_t *circ, const char *request, size_t request_len) /* And sent an ack down Alice's circuit. Empty body means succeeded. */ if (connection_edge_send_command(NULL,TO_CIRCUIT(circ), RELAY_COMMAND_INTRODUCE_ACK, - NULL,0,NULL)) { + NULL,0)) { log_warn(LD_GENERAL, "Unable to send INTRODUCE_ACK cell to Tor client."); circuit_mark_for_close(TO_CIRCUIT(circ), END_CIRC_REASON_INTERNAL); return -1; @@ -192,7 +192,7 @@ rend_mid_introduce(or_circuit_t *circ, const char *request, size_t request_len) nak_body[0] = 1; if (connection_edge_send_command(NULL,TO_CIRCUIT(circ), RELAY_COMMAND_INTRODUCE_ACK, - nak_body, 1, NULL)) { + nak_body, 1)) { log_warn(LD_GENERAL, "Unable to send NAK to Tor client."); /* Is this right? */ circuit_mark_for_close(TO_CIRCUIT(circ), END_CIRC_REASON_INTERNAL); @@ -230,7 +230,7 @@ rend_mid_establish_rendezvous(or_circuit_t *circ, const char *request, /* Acknowledge the request. */ if (connection_edge_send_command(NULL,TO_CIRCUIT(circ), RELAY_COMMAND_RENDEZVOUS_ESTABLISHED, - "", 0, NULL)<0) { + "", 0)<0) { log_warn(LD_PROTOCOL, "Couldn't send RENDEZVOUS_ESTABLISHED cell."); reason = END_CIRC_REASON_INTERNAL; goto err; @@ -299,7 +299,7 @@ rend_mid_rendezvous(or_circuit_t *circ, const char *request, if (connection_edge_send_command(NULL, TO_CIRCUIT(rend_circ), RELAY_COMMAND_RENDEZVOUS2, request+REND_COOKIE_LEN, - request_len-REND_COOKIE_LEN, NULL)) { + request_len-REND_COOKIE_LEN)) { log_warn(LD_GENERAL, "Unable to send RENDEZVOUS2 cell to client on circuit %d.", rend_circ->p_circ_id); diff --git a/src/or/rendservice.c b/src/or/rendservice.c index db34797ef2..fdacefaa97 100644 --- a/src/or/rendservice.c +++ b/src/or/rendservice.c @@ -768,7 +768,7 @@ rend_service_intro_has_opened(origin_circuit_t *circuit) } len += r; - if (connection_edge_send_command(NULL, TO_CIRCUIT(circuit), + if (relay_send_command_from_edge(0, TO_CIRCUIT(circuit), RELAY_COMMAND_ESTABLISH_INTRO, buf, len, circuit->cpath->prev)<0) { log_info(LD_GENERAL, @@ -862,7 +862,7 @@ rend_service_rendezvous_has_opened(origin_circuit_t *circuit) DIGEST_LEN); /* Send the cell */ - if (connection_edge_send_command(NULL, TO_CIRCUIT(circuit), + if (relay_send_command_from_edge(0, TO_CIRCUIT(circuit), RELAY_COMMAND_RENDEZVOUS1, buf, REND_COOKIE_LEN+DH_KEY_LEN+DIGEST_LEN, circuit->cpath->prev)<0) { diff --git a/src/or/router.c b/src/or/router.c index a9b8518100..6815554ea3 100644 --- a/src/or/router.c +++ b/src/or/router.c @@ -576,7 +576,7 @@ router_perform_bandwidth_test(int num_circs, time_t now) continue; circ->_base.timestamp_dirty = now; while (i-- > 0) { - if (connection_edge_send_command(NULL, TO_CIRCUIT(circ), + if (relay_send_command_from_edge(0, TO_CIRCUIT(circ), RELAY_COMMAND_DROP, NULL, 0, circ->cpath->prev)<0) { return; /* stop if error */