|
@@ -55,6 +55,11 @@ static cached_resolve_t *cache_entry = NULL;
|
|
|
|
|
|
static int n_fake_impl = 0;
|
|
static int n_fake_impl = 0;
|
|
|
|
|
|
|
|
+NS_DECL(int, dns_resolve_impl, (edge_connection_t *exitconn, int is_resolve,
|
|
|
|
+ or_circuit_t *oncirc, char **hostname_out,
|
|
|
|
+ int *made_connection_pending_out,
|
|
|
|
+ cached_resolve_t **resolve_out));
|
|
|
|
+
|
|
|
|
|
|
* dns.c. It will return <b>resolve_retval</b>,
|
|
* dns.c. It will return <b>resolve_retval</b>,
|
|
* and set <b>resolve_made_conn_pending</b> to
|
|
* and set <b>resolve_made_conn_pending</b> to
|
|
@@ -64,10 +69,10 @@ static int n_fake_impl = 0;
|
|
* 1.
|
|
* 1.
|
|
*/
|
|
*/
|
|
static int
|
|
static int
|
|
-dns_resolve_fake_impl(edge_connection_t *exitconn, int is_resolve,
|
|
+NS(dns_resolve_impl)(edge_connection_t *exitconn, int is_resolve,
|
|
- or_circuit_t *oncirc, char **hostname_out,
|
|
+ or_circuit_t *oncirc, char **hostname_out,
|
|
- int *made_connection_pending_out,
|
|
+ int *made_connection_pending_out,
|
|
- cached_resolve_t **resolve_out)
|
|
+ cached_resolve_t **resolve_out)
|
|
{
|
|
{
|
|
(void)oncirc;
|
|
(void)oncirc;
|
|
(void)exitconn;
|
|
(void)exitconn;
|
|
@@ -94,8 +99,8 @@ static uint8_t last_answer_type = 0;
|
|
static cached_resolve_t *last_resolved;
|
|
static cached_resolve_t *last_resolved;
|
|
|
|
|
|
static void
|
|
static void
|
|
-send_resolved_cell_replacement(edge_connection_t *conn, uint8_t answer_type,
|
|
+NS(send_resolved_cell)(edge_connection_t *conn, uint8_t answer_type,
|
|
- const cached_resolve_t *resolved)
|
|
+ const cached_resolve_t *resolved)
|
|
{
|
|
{
|
|
conn_for_resolved_cell = conn;
|
|
conn_for_resolved_cell = conn;
|
|
|
|
|
|
@@ -110,8 +115,8 @@ static int n_send_resolved_hostname_cell_replacement = 0;
|
|
static char *last_resolved_hostname = NULL;
|
|
static char *last_resolved_hostname = NULL;
|
|
|
|
|
|
static void
|
|
static void
|
|
-send_resolved_hostname_cell_replacement(edge_connection_t *conn,
|
|
+NS(send_resolved_hostname_cell)(edge_connection_t *conn,
|
|
- const char *hostname)
|
|
+ const char *hostname)
|
|
{
|
|
{
|
|
conn_for_resolved_cell = conn;
|
|
conn_for_resolved_cell = conn;
|
|
|
|
|
|
@@ -124,7 +129,7 @@ send_resolved_hostname_cell_replacement(edge_connection_t *conn,
|
|
static int n_dns_cancel_pending_resolve_replacement = 0;
|
|
static int n_dns_cancel_pending_resolve_replacement = 0;
|
|
|
|
|
|
static void
|
|
static void
|
|
-dns_cancel_pending_resolve_replacement(const char *address)
|
|
+NS(dns_cancel_pending_resolve)(const char *address)
|
|
{
|
|
{
|
|
(void) address;
|
|
(void) address;
|
|
n_dns_cancel_pending_resolve_replacement++;
|
|
n_dns_cancel_pending_resolve_replacement++;
|
|
@@ -134,7 +139,7 @@ static int n_connection_free = 0;
|
|
static connection_t *last_freed_conn = NULL;
|
|
static connection_t *last_freed_conn = NULL;
|
|
|
|
|
|
static void
|
|
static void
|
|
-connection_free_replacement(connection_t *conn)
|
|
+NS(connection_free)(connection_t *conn)
|
|
{
|
|
{
|
|
n_connection_free++;
|
|
n_connection_free++;
|
|
|
|
|
|
@@ -161,9 +166,9 @@ NS(test_main)(void *arg)
|
|
memset(exitconn,0,sizeof(edge_connection_t));
|
|
memset(exitconn,0,sizeof(edge_connection_t));
|
|
memset(nextconn,0,sizeof(edge_connection_t));
|
|
memset(nextconn,0,sizeof(edge_connection_t));
|
|
|
|
|
|
- MOCK(dns_resolve_impl,dns_resolve_fake_impl);
|
|
+ NS_MOCK(dns_resolve_impl);
|
|
- MOCK(send_resolved_cell,send_resolved_cell_replacement);
|
|
+ NS_MOCK(send_resolved_cell);
|
|
- MOCK(send_resolved_hostname_cell,send_resolved_hostname_cell_replacement);
|
|
+ NS_MOCK(send_resolved_hostname_cell);
|
|
|
|
|
|
|
|
|
|
* CASE 1: dns_resolve_impl returns 1 and sets a hostname. purpose is
|
|
* CASE 1: dns_resolve_impl returns 1 and sets a hostname. purpose is
|
|
@@ -276,8 +281,8 @@ NS(test_main)(void *arg)
|
|
* on exitconn with type being RESOLVED_TYPE_ERROR.
|
|
* on exitconn with type being RESOLVED_TYPE_ERROR.
|
|
*/
|
|
*/
|
|
|
|
|
|
- MOCK(dns_cancel_pending_resolve,dns_cancel_pending_resolve_replacement);
|
|
+ NS_MOCK(dns_cancel_pending_resolve);
|
|
- MOCK(connection_free,connection_free_replacement);
|
|
+ NS_MOCK(connection_free);
|
|
|
|
|
|
exitconn->on_circuit = &(on_circuit->base_);
|
|
exitconn->on_circuit = &(on_circuit->base_);
|
|
exitconn->base_.purpose = EXIT_PURPOSE_RESOLVE;
|
|
exitconn->base_.purpose = EXIT_PURPOSE_RESOLVE;
|
|
@@ -300,11 +305,11 @@ NS(test_main)(void *arg)
|
|
tt_assert(last_freed_conn == TO_CONN(exitconn));
|
|
tt_assert(last_freed_conn == TO_CONN(exitconn));
|
|
|
|
|
|
done:
|
|
done:
|
|
- UNMOCK(dns_resolve_impl);
|
|
+ NS_UNMOCK(dns_resolve_impl);
|
|
- UNMOCK(send_resolved_cell);
|
|
+ NS_UNMOCK(send_resolved_cell);
|
|
- UNMOCK(send_resolved_hostname_cell);
|
|
+ NS_UNMOCK(send_resolved_hostname_cell);
|
|
- UNMOCK(dns_cancel_pending_resolve);
|
|
+ NS_UNMOCK(dns_cancel_pending_resolve);
|
|
- UNMOCK(connection_free);
|
|
+ NS_UNMOCK(connection_free);
|
|
tor_free(on_circuit);
|
|
tor_free(on_circuit);
|
|
tor_free(exitconn);
|
|
tor_free(exitconn);
|
|
tor_free(nextconn);
|
|
tor_free(nextconn);
|