summaryrefslogtreecommitdiff
path: root/src/or/connection.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2005-09-12 06:56:42 +0000
committerNick Mathewson <nickm@torproject.org>2005-09-12 06:56:42 +0000
commit3dc5e77b5867815244e9f37beba56dc995a2fe2b (patch)
tree412299f73e6a108fcd8cfe1f4a5df35e4dd6e7ce /src/or/connection.c
parente4272f197839c2a9cc81e29ed28a0b3ce2ce253b (diff)
downloadtor-3dc5e77b5867815244e9f37beba56dc995a2fe2b.tar.gz
tor-3dc5e77b5867815244e9f37beba56dc995a2fe2b.zip
Numerous changes to move towards client-side v2 directories.
connection.c: - Add some more connection accessor functions to make directory download redundancy checking work. directory.c, or.h, router.c, routerlist.c: - Start on logic to note when networkstatus downloads fail. dirserv.c, routerlist.c, routerparse.c: - Start maintaining an is_named field in routerstatus_t. Don't actually look at it yet. dirserv.c, routerlist.c: - Remove expired networkstatus objects. or.h: - Make some booleans into bitfields - Add prototypes routerlist.c: - Sort networkstatus list by publication time - Function to remove old (older than 10 days) networkstatus objects. - Function to set a list of routerinfo_ts' status info from the current set of networkstatus objects. - Function to tell which routerinfos we need to download based no the current set of networkstatus objects. - Do not launch a networkstatus download if a redundant one is in progress. routerparse.c: - Keep router entries in networkstatus sorted by digest. svn:r5012
Diffstat (limited to 'src/or/connection.c')
-rw-r--r--src/or/connection.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/or/connection.c b/src/or/connection.c
index a5a4fb45b5..156bbc0b73 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -1479,6 +1479,29 @@ connection_or_exact_get_by_addr_port(uint32_t addr, uint16_t port)
return best;
}
+/** Return a connection with give type, address, port, and purpose or NULL if
+ * no such connection exists. */
+connection_t *
+connection_get_by_type_addr_port_purpose(int type, uint32_t addr, uint16_t port,
+ int purpose)
+{
+ int i, n;
+ connection_t *conn;
+ connection_t **carray;
+
+ get_connection_array(&carray,&n);
+ for (i=0;i<n;i++) {
+ conn = carray[i];
+ if (conn->type == type &&
+ conn->addr == addr &&
+ conn->port == port &&
+ conn->purpose == purpose &&
+ !conn->marked_for_close)
+ return conn;
+ }
+ return NULL;
+}
+
connection_t *
connection_get_by_identity_digest(const char *digest, int type)
{
@@ -1603,6 +1626,26 @@ connection_get_by_type_state_rendquery(int type, int state, const char *rendquer
return NULL;
}
+/** Return an open, non-marked connection of a given type and purpose, or NULL
+ * if no such connection exists. */
+connection_t *
+connection_get_by_type_purpose(int type, int purpose)
+{
+ int i, n;
+ connection_t *conn;
+ connection_t **carray;
+
+ get_connection_array(&carray,&n);
+ for (i=0;i<n;i++) {
+ conn = carray[i];
+ if (conn->type == type &&
+ !conn->marked_for_close &&
+ (purpose == conn->purpose))
+ return conn;
+ }
+ return NULL;
+}
+
/** Return 1 if <b>conn</b> is a listener conn, else return 0. */
int
connection_is_listener(connection_t *conn)