Commit da6bd21b authored by Nick Mathewson's avatar Nick Mathewson 🏃
Browse files

r12644@0-41-wifi: nickm | 2007-03-23 16:02:23 -0400

 Eliminate more redundant circuit_t arguments when edge_connection_t is already supplied and the circuit is already attached.


svn:r9900
parent 306d5400
......@@ -1183,11 +1183,11 @@ connection_ap_handshake_attach_chosen_circuit(edge_connection_t *conn,
consider_recording_trackhost(conn, circ);
/* fall through */
case SOCKS_COMMAND_CONNECT_DIR:
if (connection_ap_handshake_send_begin(conn, circ)<0)
if (connection_ap_handshake_send_begin(conn)<0)
return -1;
break;
default:
if (connection_ap_handshake_send_resolve(conn, circ)<0)
if (connection_ap_handshake_send_resolve(conn)<0)
return -1;
}
......@@ -1286,7 +1286,7 @@ connection_ap_handshake_attach_circuit(edge_connection_t *conn)
*/
rendcirc->_base.timestamp_dirty = time(NULL);
link_apconn_to_circ(conn, rendcirc);
if (connection_ap_handshake_send_begin(conn, rendcirc) < 0)
if (connection_ap_handshake_send_begin(conn) < 0)
return 0; /* already marked, let them fade away */
return 1;
}
......
......@@ -291,8 +291,9 @@ command_process_created_cell(cell_t *cell, or_connection_t *conn)
} else { /* pack it into an extended relay cell, and send it. */
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);
relay_send_command_from_edge(0, circ, RELAY_COMMAND_EXTENDED,
cell->payload, ONIONSKIN_REPLY_LEN,
NULL);
}
}
......@@ -383,8 +384,8 @@ command_process_destroy_cell(cell_t *cell, or_connection_t *conn)
char payload[1];
log_debug(LD_OR, "Delivering 'truncated' back.");
payload[0] = (char)reason;
connection_edge_send_command(NULL, circ, RELAY_COMMAND_TRUNCATED,
payload, sizeof(payload));
relay_send_command_from_edge(0, circ, RELAY_COMMAND_TRUNCATED,
payload, sizeof(payload), NULL);
}
}
}
......
......@@ -211,7 +211,7 @@ connection_edge_end(edge_connection_t *conn, char reason)
circ = circuit_get_by_edge_conn(conn);
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,
connection_edge_send_command(conn, RELAY_COMMAND_END,
payload, payload_len);
} else {
log_debug(LD_EDGE,"No circ to send end on conn (fd %d).",
......@@ -301,7 +301,6 @@ connection_edge_finished_connecting(edge_connection_t *edge_conn)
/* deliver a 'connected' relay cell back through the circuit. */
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) < 0)
return 0; /* circuit is closed, don't continue */
} else {
......@@ -310,7 +309,6 @@ connection_edge_finished_connecting(edge_connection_t *edge_conn)
set_uint32(connected_payload+4,
htonl(dns_clip_ttl(edge_conn->address_ttl)));
if (connection_edge_send_command(edge_conn,
circuit_get_by_edge_conn(edge_conn),
RELAY_COMMAND_CONNECTED,
connected_payload, 8) < 0)
return 0; /* circuit is closed, don't continue */
......@@ -1740,12 +1738,14 @@ again:
* If ap_conn is broken, mark it for close and return -1. Else return 0.
*/
int
connection_ap_handshake_send_begin(edge_connection_t *ap_conn,
origin_circuit_t *circ)
connection_ap_handshake_send_begin(edge_connection_t *ap_conn)
{
char payload[CELL_PAYLOAD_SIZE];
int payload_len;
int begin_type;
origin_circuit_t *circ;
tor_assert(ap_conn->on_circuit);
circ = TO_ORIGIN_CIRCUIT(ap_conn->on_circuit);
tor_assert(ap_conn->_base.type == CONN_TYPE_AP);
tor_assert(ap_conn->_base.state == AP_CONN_STATE_CIRCUIT_WAIT);
......@@ -1774,7 +1774,7 @@ connection_ap_handshake_send_begin(edge_connection_t *ap_conn,
tor_assert(circ->build_state->onehop_tunnel == 0);
}
if (connection_edge_send_command(ap_conn, TO_CIRCUIT(circ), begin_type,
if (connection_edge_send_command(ap_conn, begin_type,
begin_type == RELAY_COMMAND_BEGIN ? payload : NULL,
begin_type == RELAY_COMMAND_BEGIN ? payload_len : 0) < 0)
return -1; /* circuit is closed, don't continue */
......@@ -1794,12 +1794,14 @@ connection_ap_handshake_send_begin(edge_connection_t *ap_conn,
* If ap_conn is broken, mark it for close and return -1. Else return 0.
*/
int
connection_ap_handshake_send_resolve(edge_connection_t *ap_conn,
origin_circuit_t *circ)
connection_ap_handshake_send_resolve(edge_connection_t *ap_conn)
{
int payload_len, command;
const char *string_addr;
char inaddr_buf[32];
origin_circuit_t *circ;
tor_assert(ap_conn->on_circuit);
circ = TO_ORIGIN_CIRCUIT(ap_conn->on_circuit);
tor_assert(ap_conn->_base.type == CONN_TYPE_AP);
tor_assert(ap_conn->_base.state == AP_CONN_STATE_CIRCUIT_WAIT);
......@@ -1841,7 +1843,7 @@ connection_ap_handshake_send_resolve(edge_connection_t *ap_conn,
log_debug(LD_APP,
"Sending relay cell to begin stream %d.", ap_conn->stream_id);
if (connection_edge_send_command(ap_conn, TO_CIRCUIT(circ),
if (connection_edge_send_command(ap_conn,
RELAY_COMMAND_RESOLVE,
string_addr, payload_len) < 0)
return -1; /* circuit is closed, don't continue */
......@@ -2238,13 +2240,14 @@ connection_exit_begin_conn(cell_t *cell, circuit_t *circ)
return connection_exit_connect_dir(n_stream);
}
TO_OR_CIRCUIT(circ)->n_streams = n_stream; n_stream->on_circuit = circ;
/* send it off to the gethostbyname farm */
switch (dns_resolve(n_stream, NULL)) {
switch (dns_resolve(n_stream)) {
case 1: /* resolve worked */
/* add it into the linked list of n_streams on this circuit */
n_stream->next_stream = TO_OR_CIRCUIT(circ)->n_streams;
n_stream->on_circuit = circ;
TO_OR_CIRCUIT(circ)->n_streams = n_stream;
assert_circuit_ok(circ);
......@@ -2255,12 +2258,11 @@ connection_exit_begin_conn(cell_t *cell, circuit_t *circ)
end_payload[0] = END_STREAM_REASON_RESOLVEFAILED;
relay_send_command_from_edge(rh.stream_id, circ, RELAY_COMMAND_END,
end_payload, 1, NULL);
/* n_stream got freed. don't touch it. */
/* n_stream got detached and freed. don't touch it. */
break;
case 0: /* resolve added to pending list */
/* add it into the linked list of resolving_streams on this circuit */
n_stream->next_stream = TO_OR_CIRCUIT(circ)->resolving_streams;
n_stream->on_circuit = circ;
TO_OR_CIRCUIT(circ)->resolving_streams = n_stream;
assert_circuit_ok(circ);
;
......@@ -2296,8 +2298,10 @@ connection_exit_begin_resolve(cell_t *cell, or_circuit_t *circ)
dummy_conn->_base.state = EXIT_CONN_STATE_RESOLVEFAILED;
dummy_conn->_base.purpose = EXIT_PURPOSE_RESOLVE;
dummy_conn->on_circuit = TO_CIRCUIT(circ);
/* send it off to the gethostbyname farm */
switch (dns_resolve(dummy_conn, circ)) {
switch (dns_resolve(dummy_conn)) {
case -1: /* Impossible to resolve; a resolved cell was sent. */
/* Connection freed; don't touch it. */
return 0;
......@@ -2307,7 +2311,6 @@ connection_exit_begin_resolve(cell_t *cell, or_circuit_t *circ)
return 0;
case 0: /* resolve added to pending list */
dummy_conn->next_stream = circ->resolving_streams;
dummy_conn->on_circuit = TO_CIRCUIT(circ);
circ->resolving_streams = dummy_conn;
assert_circuit_ok(TO_CIRCUIT(circ));
break;
......@@ -2392,7 +2395,6 @@ connection_exit_connect(edge_connection_t *edge_conn)
/* rendezvous stream */
/* don't send an address back! */
connection_edge_send_command(edge_conn,
circuit_get_by_edge_conn(edge_conn),
RELAY_COMMAND_CONNECTED,
NULL, 0);
} else { /* normal stream */
......@@ -2402,7 +2404,6 @@ connection_exit_connect(edge_connection_t *edge_conn)
set_uint32(connected_payload+4,
htonl(dns_clip_ttl(edge_conn->address_ttl)));
connection_edge_send_command(edge_conn,
circuit_get_by_edge_conn(edge_conn),
RELAY_COMMAND_CONNECTED,
connected_payload, 8);
}
......@@ -2475,7 +2476,6 @@ connection_exit_connect_dir(edge_connection_t *exit_conn)
connection_start_reading(TO_CONN(exit_conn));
if (connection_edge_send_command(exit_conn,
circuit_get_by_edge_conn(exit_conn),
RELAY_COMMAND_CONNECTED, NULL, 0) < 0) {
connection_mark_for_close(TO_CONN(exit_conn));
connection_mark_for_close(TO_CONN(dir_conn));
......
......@@ -92,9 +92,8 @@ static void purge_expired_resolves(time_t now);
static void dns_found_answer(const char *address, int is_reverse,
uint32_t addr, const char *hostname, char outcome,
uint32_t ttl);
static void send_resolved_cell(edge_connection_t *conn, or_circuit_t *circ,
uint8_t answer_type);
static int launch_resolve(edge_connection_t *exitconn, or_circuit_t *circ);
static void send_resolved_cell(edge_connection_t *conn, uint8_t answer_type);
static int launch_resolve(edge_connection_t *exitconn);
static void add_wildcarded_test_address(const char *address);
static int configure_nameservers(int force);
static int answer_is_wildcarded(const char *ip);
......@@ -389,8 +388,7 @@ purge_expired_resolves(time_t now)
* <b>conn</b>'s attached circuit.
*/
static void
send_resolved_cell(edge_connection_t *conn, or_circuit_t *circ,
uint8_t answer_type)
send_resolved_cell(edge_connection_t *conn, uint8_t answer_type)
{
char buf[RELAY_PAYLOAD_SIZE];
size_t buflen;
......@@ -425,14 +423,7 @@ send_resolved_cell(edge_connection_t *conn, or_circuit_t *circ,
}
// log_notice(LD_EXIT, "Sending a regular RESOLVED reply: ");
if (!circ) {
circuit_t *tmp = circuit_get_by_edge_conn(conn);
if (! CIRCUIT_IS_ORIGIN(tmp))
circ = TO_OR_CIRCUIT(tmp);
}
connection_edge_send_command(conn, TO_CIRCUIT(circ),
RELAY_COMMAND_RESOLVED, buf, buflen);
connection_edge_send_command(conn, RELAY_COMMAND_RESOLVED, buf, buflen);
}
/** Send a response to the RESOLVE request of a connection for an in-addr.arpa
......@@ -444,8 +435,7 @@ send_resolved_cell(edge_connection_t *conn, or_circuit_t *circ,
* <b>conn</b>'s attached circuit.
*/
static void
send_resolved_hostname_cell(edge_connection_t *conn, or_circuit_t *circ,
const char *hostname)
send_resolved_hostname_cell(edge_connection_t *conn, const char *hostname)
{
char buf[RELAY_PAYLOAD_SIZE];
size_t buflen;
......@@ -462,15 +452,8 @@ send_resolved_hostname_cell(edge_connection_t *conn, or_circuit_t *circ,
set_uint32(buf+2+namelen, htonl(ttl));
buflen = 2+namelen+4;
if (!circ) {
circuit_t *tmp = circuit_get_by_edge_conn(conn);
if (! CIRCUIT_IS_ORIGIN(tmp))
circ = TO_OR_CIRCUIT(tmp);
}
// log_notice(LD_EXIT, "Sending a reply RESOLVED reply: %s", hostname);
connection_edge_send_command(conn, TO_CIRCUIT(circ),
RELAY_COMMAND_RESOLVED, buf, buflen);
connection_edge_send_command(conn, RELAY_COMMAND_RESOLVED, buf, buflen);
// log_notice(LD_EXIT, "Sent");
}
......@@ -525,9 +508,8 @@ parse_inaddr_arpa_address(const char *address, struct in_addr *in)
* need to send back an END cell, since connection_exit_begin_conn will
* do that for us.)
*
* If <b>oncirc</b> is provided, and this is a resolve request, we have
* a cached answer, send the answer back along oncirc; otherwise, send
* the answer back along <b>exitconn</b>'s attached circuit.
* If we have a cached answer, send the answer back along <b>exitconn</b>'s
* attached circuit.
*
* Else, if seen before and pending, add conn to the pending list,
* and return 0.
......@@ -536,18 +518,17 @@ parse_inaddr_arpa_address(const char *address, struct in_addr *in)
* dns farm, and return 0.
*/
int
dns_resolve(edge_connection_t *exitconn, or_circuit_t *oncirc)
dns_resolve(edge_connection_t *exitconn)
{
cached_resolve_t *resolve;
cached_resolve_t search;
pending_connection_t *pending_connection;
circuit_t *circ;
struct in_addr in;
time_t now = time(NULL);
int is_reverse = 0, is_resolve, r;
or_circuit_t *oncirc = TO_OR_CIRCUIT(exitconn->on_circuit);
assert_connection_ok(TO_CONN(exitconn), 0);
tor_assert(exitconn->_base.s == -1);
assert_cache_ok();
is_resolve = exitconn->_base.purpose == EXIT_PURPOSE_RESOLVE;
......@@ -558,7 +539,7 @@ dns_resolve(edge_connection_t *exitconn, or_circuit_t *oncirc)
exitconn->_base.addr = ntohl(in.s_addr);
exitconn->address_ttl = DEFAULT_DNS_TTL;
if (is_resolve)
send_resolved_cell(exitconn, oncirc, RESOLVED_TYPE_IPV4);
send_resolved_cell(exitconn, RESOLVED_TYPE_IPV4);
return 1;
}
if (address_is_invalid_destination(exitconn->_base.address, 0)) {
......@@ -566,10 +547,8 @@ dns_resolve(edge_connection_t *exitconn, or_circuit_t *oncirc)
"Rejecting invalid destination address %s",
escaped_safe_str(exitconn->_base.address));
if (is_resolve)
send_resolved_cell(exitconn, oncirc, RESOLVED_TYPE_ERROR);
circ = circuit_get_by_edge_conn(exitconn);
if (circ)
circuit_detach_stream(circ, exitconn);
send_resolved_cell(exitconn, RESOLVED_TYPE_ERROR);
circuit_detach_stream(TO_CIRCUIT(oncirc), exitconn);
if (!exitconn->_base.marked_for_close)
connection_free(TO_CONN(exitconn));
return -1;
......@@ -601,10 +580,8 @@ dns_resolve(edge_connection_t *exitconn, or_circuit_t *oncirc)
escaped_safe_str(exitconn->_base.address));
if (exitconn->_base.purpose == EXIT_PURPOSE_RESOLVE)
send_resolved_cell(exitconn, oncirc, RESOLVED_TYPE_ERROR);
circ = circuit_get_by_edge_conn(exitconn);
if (circ)
circuit_detach_stream(circ, exitconn);
send_resolved_cell(exitconn, RESOLVED_TYPE_ERROR);
circuit_detach_stream(TO_CIRCUIT(oncirc), exitconn);
if (!exitconn->_base.marked_for_close)
connection_free(TO_CONN(exitconn));
return -1;
......@@ -637,12 +614,12 @@ dns_resolve(edge_connection_t *exitconn, or_circuit_t *oncirc)
exitconn->address_ttl = resolve->ttl;
if (resolve->is_reverse) {
tor_assert(is_resolve);
send_resolved_hostname_cell(exitconn, oncirc,
send_resolved_hostname_cell(exitconn,
resolve->result.hostname);
} else {
exitconn->_base.addr = resolve->result.addr;
if (is_resolve)
send_resolved_cell(exitconn, oncirc, RESOLVED_TYPE_IPV4);
send_resolved_cell(exitconn, RESOLVED_TYPE_IPV4);
}
return 1;
case CACHE_STATE_CACHED_FAILED:
......@@ -650,10 +627,8 @@ dns_resolve(edge_connection_t *exitconn, or_circuit_t *oncirc)
exitconn->_base.s,
escaped_safe_str(exitconn->_base.address));
if (is_resolve)
send_resolved_cell(exitconn, oncirc, RESOLVED_TYPE_ERROR);
circ = circuit_get_by_edge_conn(exitconn);
if (circ)
circuit_detach_stream(circ, exitconn);
send_resolved_cell(exitconn, RESOLVED_TYPE_ERROR);
circuit_detach_stream(TO_CIRCUIT(oncirc), exitconn);
if (!exitconn->_base.marked_for_close)
connection_free(TO_CONN(exitconn));
return -1;
......@@ -683,7 +658,7 @@ dns_resolve(edge_connection_t *exitconn, or_circuit_t *oncirc)
log_debug(LD_EXIT,"Launching %s.",
escaped_safe_str(exitconn->_base.address));
assert_cache_ok();
return launch_resolve(exitconn, oncirc);
return launch_resolve(exitconn);
}
/** Log an error and abort if conn is waiting for a DNS resolve.
......@@ -953,7 +928,7 @@ dns_found_answer(const char *address, int is_reverse, uint32_t addr,
/* This detach must happen after we send the end cell. */
circuit_detach_stream(circuit_get_by_edge_conn(pendconn), pendconn);
} else {
send_resolved_cell(pendconn, NULL, RESOLVED_TYPE_ERROR);
send_resolved_cell(pendconn, RESOLVED_TYPE_ERROR);
/* This detach must happen after we send the resolved cell. */
circuit_detach_stream(circuit_get_by_edge_conn(pendconn), pendconn);
}
......@@ -980,9 +955,9 @@ dns_found_answer(const char *address, int is_reverse, uint32_t addr,
* but it does the right thing. */
pendconn->_base.state = EXIT_CONN_STATE_RESOLVEFAILED;
if (is_reverse)
send_resolved_hostname_cell(pendconn, NULL, hostname);
send_resolved_hostname_cell(pendconn, hostname);
else
send_resolved_cell(pendconn, NULL, RESOLVED_TYPE_IPV4);
send_resolved_cell(pendconn, RESOLVED_TYPE_IPV4);
circ = circuit_get_by_edge_conn(pendconn);
tor_assert(circ);
circuit_detach_stream(circ, pendconn);
......@@ -1187,7 +1162,7 @@ evdns_callback(int result, char type, int count, int ttl, void *addresses,
/** For eventdns: start resolving as necessary to find the target for
* <b>exitconn</b> */
static int
launch_resolve(edge_connection_t *exitconn, or_circuit_t *circ)
launch_resolve(edge_connection_t *exitconn)
{
char *addr = tor_strdup(exitconn->_base.address);
struct in_addr in;
......@@ -1222,10 +1197,10 @@ launch_resolve(edge_connection_t *exitconn, or_circuit_t *circ)
escaped_safe_str(addr), r);
if (exitconn->_base.purpose == EXIT_PURPOSE_RESOLVE) {
if (evdns_err_is_transient(r))
send_resolved_cell(exitconn, circ, RESOLVED_TYPE_ERROR_TRANSIENT);
send_resolved_cell(exitconn, RESOLVED_TYPE_ERROR_TRANSIENT);
else {
exitconn->address_ttl = DEFAULT_DNS_TTL;
send_resolved_cell(exitconn, circ, RESOLVED_TYPE_ERROR);
send_resolved_cell(exitconn, RESOLVED_TYPE_ERROR);
}
}
dns_cancel_pending_resolve(addr); /* also sends end and frees */
......
......@@ -2195,10 +2195,8 @@ 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);
int connection_ap_handshake_send_begin(edge_connection_t *ap_conn,
origin_circuit_t *circ);
int connection_ap_handshake_send_resolve(edge_connection_t *ap_conn,
origin_circuit_t *circ);
int connection_ap_handshake_send_begin(edge_connection_t *ap_conn);
int connection_ap_handshake_send_resolve(edge_connection_t *ap_conn);
int connection_ap_make_bridge(char *address, uint16_t port,
const char *digest, int command);
......@@ -2477,7 +2475,7 @@ void connection_dns_remove(edge_connection_t *conn);
void assert_connection_edge_not_dns_pending(edge_connection_t *conn);
void assert_all_pending_dns_resolves_ok(void);
void dns_cancel_pending_resolve(const char *question);
int dns_resolve(edge_connection_t *exitconn, or_circuit_t *circ);
int dns_resolve(edge_connection_t *exitconn);
void dns_launch_correctness_checks(void);
int dns_seems_to_be_broken(void);
void dns_reset_correctness_checks(void);
......@@ -2619,7 +2617,7 @@ void relay_header_unpack(relay_header_t *dest, const char *src);
int relay_send_command_from_edge(uint16_t stream_id, circuit_t *circ,
int relay_command, const char *payload,
size_t payload_len, crypt_path_t *cpath_layer);
int connection_edge_send_command(edge_connection_t *fromconn, circuit_t *circ,
int connection_edge_send_command(edge_connection_t *fromconn,
int relay_command, const char *payload,
size_t payload_len);
int connection_edge_package_raw_inbuf(edge_connection_t *conn,
......
......@@ -512,14 +512,18 @@ relay_send_command_from_edge(uint16_t stream_id, circuit_t *circ,
* return -1. Else return 0.
*/
int
connection_edge_send_command(edge_connection_t *fromconn, circuit_t *circ,
connection_edge_send_command(edge_connection_t *fromconn,
int relay_command, const char *payload,
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;
crypt_path_t *cpath_layer;
circuit_t *circ;
tor_assert(fromconn);
cpath_layer = fromconn ? fromconn->cpath_layer : NULL;
circ = fromconn->on_circuit;
if (fromconn && fromconn->_base.marked_for_close) {
if (fromconn->_base.marked_for_close) {
log_warn(LD_BUG,
"called on conn that's already marked for close at %s:%d.",
fromconn->_base.marked_for_close_file,
......@@ -528,7 +532,6 @@ connection_edge_send_command(edge_connection_t *fromconn, circuit_t *circ,
}
if (!circ) {
tor_assert(fromconn);
if (fromconn->_base.type == CONN_TYPE_AP) {
log_info(LD_APP,"no circ. Closing conn.");
connection_mark_unattached_ap(fromconn, END_STREAM_REASON_INTERNAL);
......@@ -541,9 +544,9 @@ connection_edge_send_command(edge_connection_t *fromconn, circuit_t *circ,
return -1;
}
return relay_send_command_from_edge(fromconn ? fromconn->stream_id : 0,
circ, relay_command, payload,
payload_len, cpath_layer);
return relay_send_command_from_edge(fromconn->stream_id, circ,
relay_command, payload,
payload_len, fromconn->cpath_layer);
}
/** Translate <b>reason</b>, which came from a relay 'end' cell,
......@@ -1114,8 +1117,8 @@ 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));
relay_send_command_from_edge(0, circ, RELAY_COMMAND_TRUNCATED,
payload, sizeof(payload), NULL);
}
return 0;
case RELAY_COMMAND_TRUNCATED:
......@@ -1277,7 +1280,7 @@ repeat_connection_edge_package_raw_inbuf:
log_debug(domain,"(%d) Packaging %d bytes (%d waiting).", conn->_base.s,
(int)length, (int)buf_datalen(conn->_base.inbuf));
if (connection_edge_send_command(conn, circ, RELAY_COMMAND_DATA,
if (connection_edge_send_command(conn, RELAY_COMMAND_DATA,
payload, length) < 0 )
/* circuit got marked for close, don't continue, don't need to mark conn */
return 0;
......@@ -1329,7 +1332,7 @@ connection_edge_consider_sending_sendme(edge_connection_t *conn)
"Outbuf %d, Queueing stream sendme.",
(int)conn->_base.outbuf_flushlen);
conn->deliver_window += STREAMWINDOW_INCREMENT;
if (connection_edge_send_command(conn, circ, RELAY_COMMAND_SENDME,
if (connection_edge_send_command(conn, RELAY_COMMAND_SENDME,
NULL, 0) < 0) {
log_warn(LD_APP,"connection_edge_send_command failed. Returning.");
return; /* the circuit's closed, don't continue */
......
......@@ -96,9 +96,9 @@ rend_mid_establish_intro(or_circuit_t *circ, const char *request,
}
/* Acknowledge the request. */
if (connection_edge_send_command(NULL,TO_CIRCUIT(circ),
if (relay_send_command_from_edge(0, TO_CIRCUIT(circ),
RELAY_COMMAND_INTRO_ESTABLISHED,
"", 0)<0) {
"", 0, NULL)<0) {
log_info(LD_GENERAL, "Couldn't send INTRO_ESTABLISHED cell.");
goto err;
}
......@@ -170,17 +170,17 @@ rend_mid_introduce(or_circuit_t *circ, const char *request, size_t request_len)
intro_circ->p_circ_id);
/* Great. Now we just relay the cell down the circuit. */
if (connection_edge_send_command(NULL, TO_CIRCUIT(intro_circ),
if (relay_send_command_from_edge(0, TO_CIRCUIT(intro_circ),
RELAY_COMMAND_INTRODUCE2,
request, request_len)) {
request, request_len, NULL)) {
log_warn(LD_GENERAL,
"Unable to send INTRODUCE2 cell to Tor client.");
goto err;
}
/* And sent an ack down Alice's circuit. Empty body means succeeded. */
if (connection_edge_send_command(NULL,TO_CIRCUIT(circ),
if (relay_send_command_from_edge(0,TO_CIRCUIT(circ),
RELAY_COMMAND_INTRODUCE_ACK,
NULL,0)) {
NULL,0,NULL)) {
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;
......@@ -190,9 +190,9 @@ rend_mid_introduce(or_circuit_t *circ, const char *request, size_t request_len)
err:
/* Send the client an NACK */
nak_body[0] = 1;
if (connection_edge_send_command(NULL,TO_CIRCUIT(circ),
if (relay_send_command_from_edge(0,TO_CIRCUIT(circ),
RELAY_COMMAND_INTRODUCE_ACK,
nak_body, 1)) {
nak_body, 1, NULL)) {
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);
......@@ -228,9 +228,9 @@ rend_mid_establish_rendezvous(or_circuit_t *circ, const char *request,
}
/* Acknowledge the request. */
if (connection_edge_send_command(NULL,TO_CIRCUIT(circ),
if (relay_send_command_from_edge(0,TO_CIRCUIT(circ),
RELAY_COMMAND_RENDEZVOUS_ESTABLISHED,
"", 0)<0) {
"", 0, NULL)<0) {
log_warn(LD_PROTOCOL, "Couldn't send RENDEZVOUS_ESTABLISHED cell.");
reason = END_CIRC_REASON_INTERNAL;
goto err;
......@@ -296,10 +296,10 @@ rend_mid_rendezvous(or_circuit_t *circ, const char *request,
}
/* Send the RENDEZVOUS2 cell to Alice. */
if (connection_edge_send_command(NULL, TO_CIRCUIT(rend_circ),
if (relay_send_command_from_edge(0, TO_CIRCUIT(rend_circ),
RELAY_COMMAND_RENDEZVOUS2,
request+REND_COOKIE_LEN,
request_len-REND_COOKIE_LEN)) {
request_len-REND_COOKIE_LEN, NULL)) {
log_warn(LD_GENERAL,
"Unable to send RENDEZVOUS2 cell to client on circuit %d.",
rend_circ->p_circ_id);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment