[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] [tor/master 15/40] Create connection.h



Author: Sebastian Hahn <sebastian@xxxxxxxxxxxxxx>
Date: Thu, 22 Jul 2010 10:32:52 +0200
Subject: Create connection.h
Commit: 2a74101f7a45308458ce30a3ea95e58593709613

---
 src/or/circuitbuild.c    |    1 +
 src/or/circuitlist.c     |    1 +
 src/or/circuituse.c      |    1 +
 src/or/command.c         |    1 +
 src/or/config.c          |    1 +
 src/or/connection.c      |    1 +
 src/or/connection.h      |  100 ++++++++++++++++++++++++++++++++++++++++++++++
 src/or/connection_edge.c |    1 +
 src/or/connection_or.c   |    1 +
 src/or/control.c         |    1 +
 src/or/cpuworker.c       |    1 +
 src/or/directory.c       |    1 +
 src/or/dirserv.c         |    1 +
 src/or/dns.c             |    1 +
 src/or/dnsserv.c         |    1 +
 src/or/hibernate.c       |    1 +
 src/or/main.c            |    1 +
 src/or/networkstatus.c   |    1 +
 src/or/or.h              |   86 ---------------------------------------
 src/or/relay.c           |    1 +
 src/or/rendclient.c      |    1 +
 src/or/router.c          |    1 +
 src/or/routerlist.c      |    1 +
 23 files changed, 121 insertions(+), 86 deletions(-)
 create mode 100644 src/or/connection.h

diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index 041aed3..0045080 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -16,6 +16,7 @@
 #include "circuitlist.h"
 #include "circuituse.h"
 #include "config.h"
+#include "connection.h"
 #include "router.h"
 #include "routerlist.h"
 #include "crypto.h"
diff --git a/src/or/circuitlist.c b/src/or/circuitlist.c
index a4ec4c0..3f06e6e 100644
--- a/src/or/circuitlist.c
+++ b/src/or/circuitlist.c
@@ -13,6 +13,7 @@
 #include "circuitbuild.h"
 #include "circuitlist.h"
 #include "circuituse.h"
+#include "connection.h"
 #include "config.h"
 #include "rendclient.h"
 #include "rendcommon.h"
diff --git a/src/or/circuituse.c b/src/or/circuituse.c
index 70def3d..f9bf6fe 100644
--- a/src/or/circuituse.c
+++ b/src/or/circuituse.c
@@ -14,6 +14,7 @@
 #include "circuitlist.h"
 #include "circuituse.h"
 #include "config.h"
+#include "connection.h"
 #include "rendclient.h"
 #include "rendcommon.h"
 #include "rendservice.h"
diff --git a/src/or/command.c b/src/or/command.c
index 96c5fca..22f36ff 100644
--- a/src/or/command.c
+++ b/src/or/command.c
@@ -19,6 +19,7 @@
 #include "circuitbuild.h"
 #include "circuitlist.h"
 #include "command.h"
+#include "connection.h"
 #include "config.h"
 #include "router.h"
 #include "routerlist.h"
diff --git a/src/or/config.c b/src/or/config.c
index a87238b..41716d0 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -15,6 +15,7 @@
 #include "circuitbuild.h"
 #include "circuitlist.h"
 #include "config.h"
+#include "connection.h"
 #include "geoip.h"
 #include "rendclient.h"
 #include "rendservice.h"
diff --git a/src/or/connection.c b/src/or/connection.c
index 5265430..c7d7671 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -16,6 +16,7 @@
 #include "circuitlist.h"
 #include "circuituse.h"
 #include "config.h"
+#include "connection.h"
 #include "dnsserv.h"
 #include "geoip.h"
 #include "rendclient.h"
diff --git a/src/or/connection.h b/src/or/connection.h
new file mode 100644
index 0000000..f38927e
--- /dev/null
+++ b/src/or/connection.h
@@ -0,0 +1,100 @@
+/* Copyright (c) 2001 Matej Pfajfar.
+ * Copyright (c) 2001-2004, Roger Dingledine.
+ * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
+ * Copyright (c) 2007-2010, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+/**
+ * \file connection.h
+ * \brief Header file for connection.c.
+ **/
+
+#ifndef _TOR_CONNECTION_H
+#define _TOR_CONNECTION_H
+
+const char *conn_type_to_string(int type);
+const char *conn_state_to_string(int type, int state);
+
+dir_connection_t *dir_connection_new(int socket_family);
+or_connection_t *or_connection_new(int socket_family);
+edge_connection_t *edge_connection_new(int type, int socket_family);
+control_connection_t *control_connection_new(int socket_family);
+connection_t *connection_new(int type, int socket_family);
+
+void connection_link_connections(connection_t *conn_a, connection_t *conn_b);
+void connection_free(connection_t *conn);
+void connection_free_all(void);
+void connection_about_to_close_connection(connection_t *conn);
+void connection_close_immediate(connection_t *conn);
+void _connection_mark_for_close(connection_t *conn,int line, const char *file);
+
+#define connection_mark_for_close(c) \
+  _connection_mark_for_close((c), __LINE__, _SHORT_FILE_)
+
+void connection_expire_held_open(void);
+
+int connection_connect(connection_t *conn, const char *address,
+                       const tor_addr_t *addr,
+                       uint16_t port, int *socket_error);
+
+int connection_proxy_connect(connection_t *conn, int type);
+int connection_read_proxy_handshake(connection_t *conn);
+
+int retry_all_listeners(smartlist_t *replaced_conns,
+                        smartlist_t *new_conns);
+
+ssize_t connection_bucket_write_limit(connection_t *conn, time_t now);
+int global_write_bucket_low(connection_t *conn, size_t attempt, int priority);
+void connection_bucket_init(void);
+void connection_bucket_refill(int seconds_elapsed, time_t now);
+
+int connection_handle_read(connection_t *conn);
+
+int connection_fetch_from_buf(char *string, size_t len, connection_t *conn);
+
+int connection_wants_to_flush(connection_t *conn);
+int connection_outbuf_too_full(connection_t *conn);
+int connection_handle_write(connection_t *conn, int force);
+void _connection_write_to_buf_impl(const char *string, size_t len,
+                                   connection_t *conn, int zlib);
+static void connection_write_to_buf(const char *string, size_t len,
+                                    connection_t *conn);
+static void connection_write_to_buf_zlib(const char *string, size_t len,
+                                         dir_connection_t *conn, int done);
+static INLINE void
+connection_write_to_buf(const char *string, size_t len, connection_t *conn)
+{
+  _connection_write_to_buf_impl(string, len, conn, 0);
+}
+static INLINE void
+connection_write_to_buf_zlib(const char *string, size_t len,
+                             dir_connection_t *conn, int done)
+{
+  _connection_write_to_buf_impl(string, len, TO_CONN(conn), done ? -1 : 1);
+}
+
+connection_t *connection_get_by_global_id(uint64_t id);
+
+connection_t *connection_get_by_type(int type);
+connection_t *connection_get_by_type_purpose(int type, int purpose);
+connection_t *connection_get_by_type_addr_port_purpose(int type,
+                                                   const tor_addr_t *addr,
+                                                   uint16_t port, int purpose);
+connection_t *connection_get_by_type_state(int type, int state);
+connection_t *connection_get_by_type_state_rendquery(int type, int state,
+                                                     const char *rendquery);
+
+#define connection_speaks_cells(conn) ((conn)->type == CONN_TYPE_OR)
+int connection_is_listener(connection_t *conn);
+int connection_state_is_open(connection_t *conn);
+int connection_state_is_connecting(connection_t *conn);
+
+char *alloc_http_authenticator(const char *authenticator);
+
+void assert_connection_ok(connection_t *conn, time_t now);
+int connection_or_nonopen_was_started_here(or_connection_t *conn);
+void connection_dump_buffer_mem_stats(int severity);
+void remove_file_if_very_old(const char *fname, time_t now);
+
+#endif
+
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c
index ec49d66..530d8b7 100644
--- a/src/or/connection_edge.c
+++ b/src/or/connection_edge.c
@@ -14,6 +14,7 @@
 #include "circuitlist.h"
 #include "circuituse.h"
 #include "config.h"
+#include "connection.h"
 #include "dnsserv.h"
 #include "rendclient.h"
 #include "rendcommon.h"
diff --git a/src/or/connection_or.c b/src/or/connection_or.c
index f9fda65..e8633c1 100644
--- a/src/or/connection_or.c
+++ b/src/or/connection_or.c
@@ -15,6 +15,7 @@
 #include "circuitbuild.h"
 #include "command.h"
 #include "config.h"
+#include "connection.h"
 #include "geoip.h"
 #include "router.h"
 #include "routerlist.h"
diff --git a/src/or/control.c b/src/or/control.c
index f6363e5..75c4ae4 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -16,6 +16,7 @@
 #include "circuitlist.h"
 #include "circuituse.h"
 #include "config.h"
+#include "connection.h"
 #include "dnsserv.h"
 #include "geoip.h"
 #include "router.h"
diff --git a/src/or/cpuworker.c b/src/or/cpuworker.c
index babc6d6..9f49e2e 100644
--- a/src/or/cpuworker.c
+++ b/src/or/cpuworker.c
@@ -17,6 +17,7 @@
 #include "circuitbuild.h"
 #include "circuitlist.h"
 #include "config.h"
+#include "connection.h"
 #include "router.h"
 
 /** The maximum number of cpuworker processes we will keep around. */
diff --git a/src/or/directory.c b/src/or/directory.c
index fa340c1..59e6d0d 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -7,6 +7,7 @@
 #include "buffers.h"
 #include "circuitbuild.h"
 #include "config.h"
+#include "connection.h"
 #include "geoip.h"
 #include "rendclient.h"
 #include "rendcommon.h"
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index 2177344..dc07e80 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -7,6 +7,7 @@
 #include "or.h"
 #include "buffers.h"
 #include "config.h"
+#include "connection.h"
 #include "router.h"
 #include "routerlist.h"
 
diff --git a/src/or/dns.c b/src/or/dns.c
index 905be3e..e8b75d5 100644
--- a/src/or/dns.c
+++ b/src/or/dns.c
@@ -15,6 +15,7 @@
 #include "circuitlist.h"
 #include "circuituse.h"
 #include "config.h"
+#include "connection.h"
 #include "router.h"
 #include "ht.h"
 #ifdef HAVE_EVENT2_DNS_H
diff --git a/src/or/dnsserv.c b/src/or/dnsserv.c
index 68d8122..6e3ccfb 100644
--- a/src/or/dnsserv.c
+++ b/src/or/dnsserv.c
@@ -11,6 +11,7 @@
 #include "or.h"
 #include "dnsserv.h"
 #include "config.h"
+#include "connection.h"
 #ifdef HAVE_EVENT2_DNS_H
 #include <event2/dns.h>
 #include <event2/dns_compat.h>
diff --git a/src/or/hibernate.c b/src/or/hibernate.c
index 74b1d85..2a08899 100644
--- a/src/or/hibernate.c
+++ b/src/or/hibernate.c
@@ -23,6 +23,7 @@ hibernating, phase 2:
 
 #include "or.h"
 #include "config.h"
+#include "connection.h"
 #include "router.h"
 
 /** Possible values of hibernate_state */
diff --git a/src/or/main.c b/src/or/main.c
index 4af66c3..9b40338 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -18,6 +18,7 @@
 #include "circuituse.h"
 #include "command.h"
 #include "config.h"
+#include "connection.h"
 #include "dnsserv.h"
 #include "geoip.h"
 #include "rendclient.h"
diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c
index 34ead6f..c73a30b 100644
--- a/src/or/networkstatus.c
+++ b/src/or/networkstatus.c
@@ -13,6 +13,7 @@
 #include "or.h"
 #include "circuitbuild.h"
 #include "config.h"
+#include "connection.h"
 #include "router.h"
 #include "routerlist.h"
 
diff --git a/src/or/or.h b/src/or/or.h
index d2b6dd8..bbc31b6 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -3066,92 +3066,6 @@ typedef enum setopt_err_t {
   SETOPT_ERR_SETTING = -4,
 } setopt_err_t;
 
-/********************************* connection.c ***************************/
-
-const char *conn_type_to_string(int type);
-const char *conn_state_to_string(int type, int state);
-
-dir_connection_t *dir_connection_new(int socket_family);
-or_connection_t *or_connection_new(int socket_family);
-edge_connection_t *edge_connection_new(int type, int socket_family);
-control_connection_t *control_connection_new(int socket_family);
-connection_t *connection_new(int type, int socket_family);
-
-void connection_link_connections(connection_t *conn_a, connection_t *conn_b);
-void connection_free(connection_t *conn);
-void connection_free_all(void);
-void connection_about_to_close_connection(connection_t *conn);
-void connection_close_immediate(connection_t *conn);
-void _connection_mark_for_close(connection_t *conn,int line, const char *file);
-
-#define connection_mark_for_close(c) \
-  _connection_mark_for_close((c), __LINE__, _SHORT_FILE_)
-
-void connection_expire_held_open(void);
-
-int connection_connect(connection_t *conn, const char *address,
-                       const tor_addr_t *addr,
-                       uint16_t port, int *socket_error);
-
-int connection_proxy_connect(connection_t *conn, int type);
-int connection_read_proxy_handshake(connection_t *conn);
-
-int retry_all_listeners(smartlist_t *replaced_conns,
-                        smartlist_t *new_conns);
-
-ssize_t connection_bucket_write_limit(connection_t *conn, time_t now);
-int global_write_bucket_low(connection_t *conn, size_t attempt, int priority);
-void connection_bucket_init(void);
-void connection_bucket_refill(int seconds_elapsed, time_t now);
-
-int connection_handle_read(connection_t *conn);
-
-int connection_fetch_from_buf(char *string, size_t len, connection_t *conn);
-
-int connection_wants_to_flush(connection_t *conn);
-int connection_outbuf_too_full(connection_t *conn);
-int connection_handle_write(connection_t *conn, int force);
-void _connection_write_to_buf_impl(const char *string, size_t len,
-                                   connection_t *conn, int zlib);
-static void connection_write_to_buf(const char *string, size_t len,
-                                    connection_t *conn);
-static void connection_write_to_buf_zlib(const char *string, size_t len,
-                                         dir_connection_t *conn, int done);
-static INLINE void
-connection_write_to_buf(const char *string, size_t len, connection_t *conn)
-{
-  _connection_write_to_buf_impl(string, len, conn, 0);
-}
-static INLINE void
-connection_write_to_buf_zlib(const char *string, size_t len,
-                             dir_connection_t *conn, int done)
-{
-  _connection_write_to_buf_impl(string, len, TO_CONN(conn), done ? -1 : 1);
-}
-
-connection_t *connection_get_by_global_id(uint64_t id);
-
-connection_t *connection_get_by_type(int type);
-connection_t *connection_get_by_type_purpose(int type, int purpose);
-connection_t *connection_get_by_type_addr_port_purpose(int type,
-                                                   const tor_addr_t *addr,
-                                                   uint16_t port, int purpose);
-connection_t *connection_get_by_type_state(int type, int state);
-connection_t *connection_get_by_type_state_rendquery(int type, int state,
-                                                     const char *rendquery);
-
-#define connection_speaks_cells(conn) ((conn)->type == CONN_TYPE_OR)
-int connection_is_listener(connection_t *conn);
-int connection_state_is_open(connection_t *conn);
-int connection_state_is_connecting(connection_t *conn);
-
-char *alloc_http_authenticator(const char *authenticator);
-
-void assert_connection_ok(connection_t *conn, time_t now);
-int connection_or_nonopen_was_started_here(or_connection_t *conn);
-void connection_dump_buffer_mem_stats(int severity);
-void remove_file_if_very_old(const char *fname, time_t now);
-
 /********************************* connection_edge.c *************************/
 
 #define connection_mark_unattached_ap(conn, endreason) \
diff --git a/src/or/relay.c b/src/or/relay.c
index 53631ab..59d7282 100644
--- a/src/or/relay.c
+++ b/src/or/relay.c
@@ -16,6 +16,7 @@
 #include "circuitbuild.h"
 #include "circuitlist.h"
 #include "config.h"
+#include "connection.h"
 #include "geoip.h"
 #include "mempool.h"
 #include "rendcommon.h"
diff --git a/src/or/rendclient.c b/src/or/rendclient.c
index 5e1f81e..eb971ac 100644
--- a/src/or/rendclient.c
+++ b/src/or/rendclient.c
@@ -12,6 +12,7 @@
 #include "circuitlist.h"
 #include "circuituse.h"
 #include "config.h"
+#include "connection.h"
 #include "rendclient.h"
 #include "rendcommon.h"
 #include "routerlist.h"
diff --git a/src/or/router.c b/src/or/router.c
index 20990b2..9cb7ad4 100644
--- a/src/or/router.c
+++ b/src/or/router.c
@@ -10,6 +10,7 @@
 #include "circuitlist.h"
 #include "circuituse.h"
 #include "config.h"
+#include "connection.h"
 #include "geoip.h"
 #include "router.h"
 #include "routerlist.h"
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index 5cf698a..df29600 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -14,6 +14,7 @@
 #include "or.h"
 #include "circuitbuild.h"
 #include "config.h"
+#include "connection.h"
 #include "geoip.h"
 #include "rendcommon.h"
 #include "rendservice.h"
-- 
1.7.1