aboutsummaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2013-07-18 15:51:29 -0400
committerNick Mathewson <nickm@torproject.org>2013-08-15 12:03:36 -0400
commitc342ea98791ccbeb67b1255816ca2e92167cefb0 (patch)
tree81a9f7a8ff193bfc4b4bfe863179057882d558e6 /src/or
parent7da59721a9963862b7b19dbba4e55d010c296d34 (diff)
downloadtor-c342ea98791ccbeb67b1255816ca2e92167cefb0.tar.gz
tor-c342ea98791ccbeb67b1255816ca2e92167cefb0.zip
Unit tests for ext_or_id_map.
Diffstat (limited to 'src/or')
-rw-r--r--src/or/connection.c3
-rw-r--r--src/or/connection.h4
-rw-r--r--src/or/connection_or.c10
-rw-r--r--src/or/ext_orport.h1
4 files changed, 17 insertions, 1 deletions
diff --git a/src/or/connection.c b/src/or/connection.c
index 57a9c5838b..f1d7961a17 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -10,6 +10,7 @@
* on connections.
**/
+#define CONNECTION_PRIVATE
#include "or.h"
#include "buffers.h"
/*
@@ -458,7 +459,7 @@ connection_link_connections(connection_t *conn_a, connection_t *conn_b)
* necessary, close its socket if necessary, and mark the directory as dirty
* if <b>conn</b> is an OR or OP connection.
*/
-static void
+STATIC void
connection_free_(connection_t *conn)
{
void *mem;
diff --git a/src/or/connection.h b/src/or/connection.h
index 5ca8ca3430..19f11c7439 100644
--- a/src/or/connection.h
+++ b/src/or/connection.h
@@ -214,5 +214,9 @@ void connection_enable_rate_limiting(connection_t *conn);
#define connection_type_uses_bufferevent(c) (0)
#endif
+#ifdef CONNECTION_PRIVATE
+STATIC void connection_free_(connection_t *conn);
+#endif
+
#endif
diff --git a/src/or/connection_or.c b/src/or/connection_or.c
index 3711cfeb33..a55ca3aa01 100644
--- a/src/or/connection_or.c
+++ b/src/or/connection_or.c
@@ -197,6 +197,16 @@ connection_or_remove_from_ext_or_id_map(or_connection_t *conn)
memset(conn->ext_or_conn_id, 0, EXT_OR_CONN_ID_LEN);
}
+/** Return the connection whose ext_or_id is <b>id</b>. Return NULL if no such
+ * connection is found. */
+or_connection_t *
+connection_or_get_by_ext_or_id(const char *id)
+{
+ if (!orconn_ext_or_id_map)
+ return NULL;
+ return digestmap_get(orconn_ext_or_id_map, id);
+}
+
/** Deallocate the global Extended ORPort identifier list */
void
connection_or_clear_ext_or_id_map(void)
diff --git a/src/or/ext_orport.h b/src/or/ext_orport.h
index 89c3032dfc..92ace7779c 100644
--- a/src/or/ext_orport.h
+++ b/src/or/ext_orport.h
@@ -14,6 +14,7 @@ void ext_or_cmd_free(ext_or_cmd_t *cmd);
void connection_or_set_ext_or_identifier(or_connection_t *conn);
void connection_or_remove_from_ext_or_id_map(or_connection_t *conn);
void connection_or_clear_ext_or_id_map(void);
+or_connection_t *connection_or_get_by_ext_or_id(const char *id);
int connection_ext_or_finished_flushing(or_connection_t *conn);
int connection_ext_or_process_inbuf(or_connection_t *or_conn);