diff options
author | Nick Mathewson <nickm@torproject.org> | 2014-04-02 13:38:50 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2014-04-02 15:38:00 -0400 |
commit | da908a593fded0c4774c6cdfb6b5e51c87f65d88 (patch) | |
tree | 4bce2b353cc03c648403170b213e84b573864f37 /src/or | |
parent | 4215c801ffc11f19949be3da2d46158664f0bf97 (diff) | |
download | tor-da908a593fded0c4774c6cdfb6b5e51c87f65d88.tar.gz tor-da908a593fded0c4774c6cdfb6b5e51c87f65d88.zip |
Unit tests for connection_edge_process_resolved_cell
Also rename a function to be more accurate (resolve->resolved)
Diffstat (limited to 'src/or')
-rw-r--r-- | src/or/connection_edge.c | 12 | ||||
-rw-r--r-- | src/or/connection_edge.h | 24 | ||||
-rw-r--r-- | src/or/relay.c | 16 | ||||
-rw-r--r-- | src/or/relay.h | 7 |
4 files changed, 30 insertions, 29 deletions
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c index 1ecc553e56..41ca6119b0 100644 --- a/src/or/connection_edge.c +++ b/src/or/connection_edge.c @@ -67,9 +67,9 @@ static int connection_ap_supports_optimistic_data(const entry_connection_t *); * a socks reply, send one now (based on endreason). Also set * has_sent_end to 1, and mark the conn. */ -void -connection_mark_unattached_ap_(entry_connection_t *conn, int endreason, - int line, const char *file) +MOCK_IMPL(void, +connection_mark_unattached_ap_,(entry_connection_t *conn, int endreason, + int line, const char *file)) { connection_t *base_conn = ENTRY_TO_CONN(conn); edge_connection_t *edge_conn = ENTRY_TO_EDGE_CONN(conn); @@ -2093,13 +2093,13 @@ connection_ap_handshake_socks_resolved_addr(entry_connection_t *conn, **/ /* XXXX the use of the ttl and expires fields is nutty. Let's make this * interface and those that use it less ugly. */ -void -connection_ap_handshake_socks_resolved(entry_connection_t *conn, +MOCK_IMPL(void, +connection_ap_handshake_socks_resolved,(entry_connection_t *conn, int answer_type, size_t answer_len, const uint8_t *answer, int ttl, - time_t expires) + time_t expires)) { char buf[384]; size_t replylen; diff --git a/src/or/connection_edge.h b/src/or/connection_edge.h index cbca31a21b..3c0e30a973 100644 --- a/src/or/connection_edge.h +++ b/src/or/connection_edge.h @@ -17,8 +17,9 @@ #define connection_mark_unattached_ap(conn, endreason) \ connection_mark_unattached_ap_((conn), (endreason), __LINE__, SHORT_FILE__) -void connection_mark_unattached_ap_(entry_connection_t *conn, int endreason, - int line, const char *file); +MOCK_DECL(void,connection_mark_unattached_ap_, + (entry_connection_t *conn, int endreason, + int line, const char *file)); int connection_edge_reached_eof(edge_connection_t *conn); int connection_edge_process_inbuf(edge_connection_t *conn, int package_partial); @@ -44,16 +45,17 @@ entry_connection_t *connection_ap_make_link(connection_t *partner, void connection_ap_handshake_socks_reply(entry_connection_t *conn, char *reply, size_t replylen, int endreason); -void connection_ap_handshake_socks_resolved(entry_connection_t *conn, - int answer_type, - size_t answer_len, - const uint8_t *answer, - int ttl, - time_t expires); +MOCK_DECL(void,connection_ap_handshake_socks_resolved, + (entry_connection_t *conn, + int answer_type, + size_t answer_len, + const uint8_t *answer, + int ttl, + time_t expires)); void connection_ap_handshake_socks_resolved_addr(entry_connection_t *conn, - const tor_addr_t *answer, - int ttl, - time_t expires); + const tor_addr_t *answer, + int ttl, + time_t expires); int connection_exit_begin_conn(cell_t *cell, circuit_t *circ); int connection_exit_begin_resolve(cell_t *cell, or_circuit_t *circ); diff --git a/src/or/relay.c b/src/or/relay.c index ed24397f59..f8b0deedb9 100644 --- a/src/or/relay.c +++ b/src/or/relay.c @@ -1121,10 +1121,10 @@ resolved_cell_parse(const cell_t *cell, const relay_header_t *rh, /** Helper for connection_edge_process_resolved_cell: given an error code, * an entry_connection, and a list of address_ttl_t *, report the best answer * to the entry_connection. */ -STATIC void -connection_ap_handshake_socks_got_resolve_cell(entry_connection_t *conn, - int error_code, - smartlist_t *results) +static void +connection_ap_handshake_socks_got_resolved_cell(entry_connection_t *conn, + int error_code, + smartlist_t *results) { address_ttl_t *addr_ipv4 = NULL; address_ttl_t *addr_ipv6 = NULL; @@ -1195,7 +1195,7 @@ connection_ap_handshake_socks_got_resolve_cell(entry_connection_t *conn, /** Handle a RELAY_COMMAND_RESOLVED cell that we received on a non-open AP * stream. */ -static int +STATIC int connection_edge_process_resolved_cell(edge_connection_t *conn, const cell_t *cell, const relay_header_t *rh) @@ -1242,9 +1242,9 @@ connection_edge_process_resolved_cell(edge_connection_t *conn, } } - connection_ap_handshake_socks_got_resolve_cell(entry_conn, - errcode, - resolved_addresses); + connection_ap_handshake_socks_got_resolved_cell(entry_conn, + errcode, + resolved_addresses); connection_mark_unattached_ap(entry_conn, END_STREAM_REASON_DONE | diff --git a/src/or/relay.h b/src/or/relay.h index bd5c908579..9c0e21c14f 100644 --- a/src/or/relay.h +++ b/src/or/relay.h @@ -92,10 +92,9 @@ typedef struct address_ttl_s { STATIC void address_ttl_free(address_ttl_t *addr); STATIC int resolved_cell_parse(const cell_t *cell, const relay_header_t *rh, smartlist_t *addresses_out, int *errcode_out); -STATIC void connection_ap_handshake_socks_got_resolve_cell( - entry_connection_t *conn, - int error_code, - smartlist_t *results); +STATIC int connection_edge_process_resolved_cell(edge_connection_t *conn, + const cell_t *cell, + const relay_header_t *rh); STATIC packed_cell_t *packed_cell_new(void); STATIC packed_cell_t *cell_queue_pop(cell_queue_t *queue); STATIC size_t cell_queues_get_total_allocation(void); |