summaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
Diffstat (limited to 'src/or')
-rw-r--r--src/or/connection.c3
-rw-r--r--src/or/dirserv.c2
-rw-r--r--src/or/main.c4
-rw-r--r--src/or/or.h9
-rw-r--r--src/or/relay.c3
-rw-r--r--src/or/routerlist.c3
-rw-r--r--src/or/routerparse.c2
-rw-r--r--src/or/test.c64
8 files changed, 37 insertions, 53 deletions
diff --git a/src/or/connection.c b/src/or/connection.c
index f35764ae5f..e8bb977bbf 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -83,6 +83,7 @@ static int connection_finished_flushing(connection_t *conn);
static int connection_finished_connecting(connection_t *conn);
static int connection_read_to_buf(connection_t *conn);
static int connection_process_inbuf(connection_t *conn);
+static int connection_bucket_read_limit(connection_t *conn);
/**************************************************************/
@@ -642,7 +643,7 @@ int retry_all_listeners(int force) {
extern int global_read_bucket, global_write_bucket;
/** How many bytes at most can we read onto this connection? */
-int connection_bucket_read_limit(connection_t *conn) {
+static int connection_bucket_read_limit(connection_t *conn) {
int at_most;
/* do a rudimentary round-robin so one circuit can't hog a connection */
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index 0889612e67..2483efc74d 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -24,6 +24,8 @@ static int list_server_status(char **running_routers_out,
char **router_status_out);
static void directory_remove_unrecognized(void);
static int dirserv_regenerate_directory(void);
+/* Should be static; exposed for testing */
+void add_fingerprint_to_dir(const char *nickname, const char *fp);
/************** Fingerprint handling code ************/
diff --git a/src/or/main.c b/src/or/main.c
index 942e6cd330..c3e8c6c386 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -1019,7 +1019,7 @@ static int network_init(void)
/** Called by exit() as we shut down the process.
*/
-void exit_function(void)
+static void exit_function(void)
{
/* XXX if we ever daemonize, this gets called immediately */
#ifdef MS_WINDOWS
@@ -1096,7 +1096,7 @@ void tor_cleanup(void) {
}
/** Read/create keys as needed, and echo our fingerprint to stdout. */
-void do_list_fingerprint(void)
+static void do_list_fingerprint(void)
{
char buf[FINGERPRINT_LEN+1];
crypto_pk_env_t *k;
diff --git a/src/or/or.h b/src/or/or.h
index d5c07b8944..f17ce47f8f 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -1038,13 +1038,6 @@ circuit_t *circuit_launch_by_identity(uint8_t purpose, const char *exit_digest);
void circuit_reset_failure_count(int timeout);
int connection_ap_handshake_attach_circuit(connection_t *conn);
-int circuit_init_cpath_crypto(crypt_path_t *cpath, char *key_data,int reverse);
-int circuit_finish_handshake(circuit_t *circ, char *reply);
-int circuit_truncated(circuit_t *circ, crypt_path_t *layer);
-
-void assert_cpath_layer_ok(const crypt_path_t *c);
-void assert_circuit_ok(const circuit_t *c);
-
/********************************* command.c ***************************/
void command_process_cell(cell_t *cell, connection_t *conn);
@@ -1271,6 +1264,8 @@ int proxy_mode(void);
void handle_signals(int is_parent);
void tor_cleanup(void);
+int tor_main(int argc, char *argv[]);
+
/********************************* onion.c ***************************/
int onion_pending_add(circuit_t *circ);
diff --git a/src/or/relay.c b/src/or/relay.c
index 19fd30e8da..2c256548c1 100644
--- a/src/or/relay.c
+++ b/src/or/relay.c
@@ -30,9 +30,6 @@ circuit_resume_edge_reading_helper(connection_t *conn,
crypt_path_t *layer_hint);
static int
circuit_consider_stop_edge_reading(circuit_t *circ, crypt_path_t *layer_hint);
-void connection_edge_consider_sending_sendme(connection_t *conn);
-
-
/** Stats: how many relay cells have originated at this hop, or have
* been relayed onward (not recognized at this hop)?
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index 65479536bc..abca6d4d50 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -737,7 +737,8 @@ void router_mark_as_down(const char *digest) {
* will either be inserted into the routerlist or freed. Returns 0 if the
* router was added; -1 if it was not.
*/
-int router_add_to_routerlist(routerinfo_t *router) {
+static int
+router_add_to_routerlist(routerinfo_t *router) {
int i;
routerinfo_t *r;
char id_digest[DIGEST_LEN];
diff --git a/src/or/routerparse.c b/src/or/routerparse.c
index aaed573498..eb02167660 100644
--- a/src/or/routerparse.c
+++ b/src/or/routerparse.c
@@ -139,6 +139,8 @@ static int check_directory_signature(const char *digest,
crypto_pk_env_t *pkey,
crypto_pk_env_t *declared_key);
static crypto_pk_env_t *find_dir_signing_key(const char *str);
+/* static */ int is_obsolete_version(const char *myversion,
+ const char *versionlist);
/** Set <b>digest</b> to the SHA-1 digest of the hash of the directory in
* <b>s</b>. Return 0 on success, nonzero on failure.
diff --git a/src/or/test.c b/src/or/test.c
index 22397775ee..d278d771de 100644
--- a/src/or/test.c
+++ b/src/or/test.c
@@ -23,27 +23,11 @@ int have_failed = 0;
/* These functions are file-local, but are exposed so we can test. */
void add_fingerprint_to_dir(const char *nickname, const char *fp);
void get_platform_str(char *platform, size_t len);
-
-void
-dump_hex(char *s, size_t len)
-{
- static const char TABLE[] = "0123456789ABCDEF";
- unsigned char *d = s;
- size_t i;
- int j, nyb;
- for(i=0;i<len;++i) {
- for (j=1;j>=0;--j) {
- nyb = (((int) d[i]) >> (j*4)) & 0x0f;
- tor_assert(0 <= nyb);
- tor_assert(nyb <= 15);
- putchar(TABLE[nyb]);
- }
- }
-}
+int is_obsolete_version(const char *myversion, const char *start);
static char temp_dir[256];
-void
+static void
setup_directory(void)
{
static int is_setup = 0;
@@ -64,7 +48,7 @@ setup_directory(void)
is_setup = 1;
}
-const char *
+static const char *
get_fname(const char *name)
{
static char buf[1024];
@@ -73,7 +57,7 @@ get_fname(const char *name)
return buf;
}
-void
+static void
remove_directory(void)
{
DIR *dirp;
@@ -97,7 +81,7 @@ remove_directory(void)
rmdir(temp_dir);
}
-void
+static void
test_buffers(void) {
#define MAX_BUF_SIZE 1024*1024
char str[256];
@@ -223,7 +207,7 @@ test_buffers(void) {
buf_free(buf);
}
-void
+static void
test_crypto_dh(void)
{
crypto_dh_env_t *dh1, *dh2;
@@ -258,7 +242,7 @@ test_crypto_dh(void)
crypto_dh_free(dh2);
}
-void
+static void
test_crypto(void)
{
crypto_cipher_env_t *env1, *env2;
@@ -494,7 +478,7 @@ test_crypto(void)
free(data3);
}
-void
+static void
test_util(void) {
struct timeval start, end;
struct tm a_time;
@@ -694,7 +678,7 @@ test_util(void) {
smartlist_free(sl);
}
-void
+static void
test_gzip(void)
{
char *buf1, *buf2=NULL, *buf3=NULL;
@@ -729,7 +713,8 @@ test_gzip(void)
tor_free(buf1);
}
-static void* _squareAndRemoveK4(const char *key, void*val, void *data)
+static void *
+_squareAndRemoveK4(const char *key, void*val, void *data)
{
int *ip = (int*)data;
intptr_t v;
@@ -741,7 +726,8 @@ static void* _squareAndRemoveK4(const char *key, void*val, void *data)
return (void*)(v*v);
}
-void test_strmap(void)
+static void
+test_strmap(void)
{
strmap_t *map;
strmap_iter_t *iter;
@@ -815,7 +801,8 @@ void test_strmap(void)
strmap_free(map,NULL);
}
-void test_onion(void)
+static void
+test_onion(void)
{
#if 0
char **names;
@@ -833,7 +820,7 @@ void test_onion(void)
#endif
}
-void
+static void
test_onion_handshake(void)
{
/* client-side */
@@ -876,10 +863,8 @@ test_onion_handshake(void)
crypto_free_pk_env(pk);
}
-/* from routerparse.c */
-int is_obsolete_version(const char *myversion, const char *start);
-void
+static void
test_dir_format(void)
{
char buf[8192], buf2[8192];
@@ -925,7 +910,7 @@ test_dir_format(void)
get_platform_str(platform, sizeof(platform));
memset(&r1,0,sizeof(r1));
memset(&r2,0,sizeof(r2));
- r1.address = "testaddr1.foo.bar";
+ r1.address = tor_strdup("testaddr1.foo.bar");
r1.addr = 0xc0a80001u; /* 192.168.0.1 */
r1.published_on = 0;
r1.or_port = 9000;
@@ -937,7 +922,7 @@ test_dir_format(void)
r1.bandwidthburst = 5000;
r1.bandwidthcapacity = 10000;
r1.exit_policy = NULL;
- r1.nickname = "Magri";
+ r1.nickname = tor_strdup("Magri");
r1.platform = tor_strdup(platform);
ex1.policy_type = EXIT_POLICY_ACCEPT;
@@ -951,7 +936,7 @@ test_dir_format(void)
ex2.msk = 0xFF000000u;
ex2.prt_min = ex2.prt_max = 24;
ex2.next = NULL;
- r2.address = "tor.tor.tor";
+ r2.address = tor_strdup("tor.tor.tor");
r2.addr = 0x0a030201u; /* 10.3.2.1 */
r2.platform = tor_strdup(platform);
r2.published_on = 5;
@@ -962,7 +947,7 @@ test_dir_format(void)
r2.identity_pkey = pk1;
r2.bandwidthrate = r2.bandwidthburst = r2.bandwidthcapacity = 3000;
r2.exit_policy = &ex1;
- r2.nickname = "Fred";
+ r2.nickname = tor_strdup("Fred");
bw_lines = rep_hist_get_bandwidth_lines();
test_assert(bw_lines);
@@ -1062,7 +1047,7 @@ test_dir_format(void)
test_assert(router_dump_router_to_string(buf, 2048, &r2, pk1)>0);
cp = buf;
test_eq(dirserv_add_descriptor((const char**)&cp), 1);
- options.Nickname = "DirServer";
+ options.Nickname = tor_strdup("DirServer");
test_assert(!dirserv_dump_directory_to_string(buf,8192,pk3));
cp = buf;
test_assert(!router_parse_routerlist_from_directory(buf, &dir1, pk3, 1));
@@ -1128,7 +1113,8 @@ test_dir_format(void)
}
-void test_rend_fns(void)
+static void
+test_rend_fns(void)
{
char address1[] = "fooaddress.onion";
char address2[] = "aaaaaaaaaaaaaaaa.onion";
@@ -1182,7 +1168,7 @@ main(int c, char**v){
atexit(remove_directory);
// puts("========================== Buffers =========================");
-// test_buffers();
+ if (0) test_buffers();
puts("\n========================== Crypto ==========================");
// add_stream_log(LOG_DEBUG, LOG_ERR, "<stdout>", stdout);
test_crypto();