diff options
author | Roger Dingledine <arma@torproject.org> | 2003-09-16 05:41:49 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2003-09-16 05:41:49 +0000 |
commit | 8b71b7338faeaedf60e40b335b865781106ad1a2 (patch) | |
tree | 8d377cc8a77134d9cfd39b7a0b2b72cf7e93852b /src | |
parent | 9c6343fdf8ab6e8241c613c54bb3bd9cb6c78a91 (diff) | |
download | tor-8b71b7338faeaedf60e40b335b865781106ad1a2.tar tor-8b71b7338faeaedf60e40b335b865781106ad1a2.tar.gz |
clean up exported api's
svn:r461
Diffstat (limited to 'src')
-rw-r--r-- | src/or/circuit.c | 10 | ||||
-rw-r--r-- | src/or/command.c | 15 | ||||
-rw-r--r-- | src/or/connection.c | 20 | ||||
-rw-r--r-- | src/or/connection_edge.c | 4 | ||||
-rw-r--r-- | src/or/connection_or.c | 55 | ||||
-rw-r--r-- | src/or/directory.c | 13 | ||||
-rw-r--r-- | src/or/onion.c | 6 | ||||
-rw-r--r-- | src/or/or.h | 87 | ||||
-rw-r--r-- | src/or/routers.c | 7 |
9 files changed, 67 insertions, 150 deletions
diff --git a/src/or/circuit.c b/src/or/circuit.c index 65a1f4e0d..71258366e 100644 --- a/src/or/circuit.c +++ b/src/or/circuit.c @@ -6,6 +6,10 @@ extern or_options_t options; /* command-line and config-file options */ +static void circuit_free_cpath(crypt_path_t *cpath); +static void circuit_free_cpath_node(crypt_path_t *victim); +static aci_t get_unique_aci_by_addr_port(uint32_t addr, uint16_t port, int aci_type); + /********* START VARIABLES **********/ static circuit_t *global_circuitlist=NULL; @@ -86,7 +90,7 @@ void circuit_free(circuit_t *circ) { free(circ); } -void circuit_free_cpath(crypt_path_t *cpath) { +static void circuit_free_cpath(crypt_path_t *cpath) { crypt_path_t *victim, *head=cpath; if(!cpath) @@ -103,7 +107,7 @@ void circuit_free_cpath(crypt_path_t *cpath) { circuit_free_cpath_node(cpath); } -void circuit_free_cpath_node(crypt_path_t *victim) { +static void circuit_free_cpath_node(crypt_path_t *victim) { if(victim->f_crypto) crypto_free_cipher_env(victim->f_crypto); if(victim->b_crypto) @@ -114,7 +118,7 @@ void circuit_free_cpath_node(crypt_path_t *victim) { } /* return 0 if can't get a unique aci. */ -aci_t get_unique_aci_by_addr_port(uint32_t addr, uint16_t port, int aci_type) { +static aci_t get_unique_aci_by_addr_port(uint32_t addr, uint16_t port, int aci_type) { aci_t test_aci; connection_t *conn; diff --git a/src/or/command.c b/src/or/command.c index f38708e2f..9a32b0abb 100644 --- a/src/or/command.c +++ b/src/or/command.c @@ -6,7 +6,12 @@ extern or_options_t options; /* command-line and config-file options */ -void command_time_process_cell(cell_t *cell, connection_t *conn, +static void command_process_create_cell(cell_t *cell, connection_t *conn); +static void command_process_created_cell(cell_t *cell, connection_t *conn); +static void command_process_relay_cell(cell_t *cell, connection_t *conn); +static void command_process_destroy_cell(cell_t *cell, connection_t *conn); + +static void command_time_process_cell(cell_t *cell, connection_t *conn, int *num, int *time, void (*func)(cell_t *, connection_t *)) { struct timeval start, end; @@ -77,7 +82,7 @@ void command_process_cell(cell_t *cell, connection_t *conn) { } } -void command_process_create_cell(cell_t *cell, connection_t *conn) { +static void command_process_create_cell(cell_t *cell, connection_t *conn) { circuit_t *circ; circ = circuit_get_by_aci_conn(cell->aci, conn); @@ -106,7 +111,7 @@ void command_process_create_cell(cell_t *cell, connection_t *conn) { log_fn(LOG_DEBUG,"success: handed off onionskin."); } -void command_process_created_cell(cell_t *cell, connection_t *conn) { +static void command_process_created_cell(cell_t *cell, connection_t *conn) { circuit_t *circ; cell_t newcell; @@ -155,7 +160,7 @@ void command_process_created_cell(cell_t *cell, connection_t *conn) { } } -void command_process_relay_cell(cell_t *cell, connection_t *conn) { +static void command_process_relay_cell(cell_t *cell, connection_t *conn) { circuit_t *circ; circ = circuit_get_by_aci_conn(cell->aci, conn); @@ -187,7 +192,7 @@ void command_process_relay_cell(cell_t *cell, connection_t *conn) { } } -void command_process_destroy_cell(cell_t *cell, connection_t *conn) { +static void command_process_destroy_cell(cell_t *cell, connection_t *conn) { circuit_t *circ; circ = circuit_get_by_aci_conn(cell->aci, conn); diff --git a/src/or/connection.c b/src/or/connection.c index d071910a3..a6505931a 100644 --- a/src/or/connection.c +++ b/src/or/connection.c @@ -765,26 +765,6 @@ int connection_finished_flushing(connection_t *conn) { } } -void -cell_pack(char *dest, const cell_t *src) -{ - *(uint16_t*)dest = htons(src->aci); - *(uint8_t*)(dest+2) = src->command; - *(uint8_t*)(dest+3) = src->length; - *(uint32_t*)(dest+4) = 0; /* Reserved */ - memcpy(dest+8, src->payload, CELL_PAYLOAD_SIZE); -} - -void -cell_unpack(cell_t *dest, const char *src) -{ - dest->aci = ntohs(*(uint16_t*)(src)); - dest->command = *(uint8_t*)(src+2); - dest->length = *(uint8_t*)(src+3); - dest->seq = ntohl(*(uint32_t*)(src+4)); - memcpy(dest->payload, src+8, CELL_PAYLOAD_SIZE); -} - /* Local Variables: mode:c diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c index cfd9f7566..e47983a12 100644 --- a/src/or/connection_edge.c +++ b/src/or/connection_edge.c @@ -535,7 +535,7 @@ static int connection_ap_handshake_process_socks(connection_t *conn) { return 0; } -int connection_ap_handshake_send_begin(connection_t *ap_conn, circuit_t *circ) { +static int connection_ap_handshake_send_begin(connection_t *ap_conn, circuit_t *circ) { cell_t cell; memset(&cell, 0, sizeof(cell_t)); @@ -565,7 +565,7 @@ int connection_ap_handshake_send_begin(connection_t *ap_conn, circuit_t *circ) { return 0; } -int connection_ap_handshake_socks_reply(connection_t *conn, char result) { +static int connection_ap_handshake_socks_reply(connection_t *conn, char result) { socks4_t socks4_info; assert(conn); diff --git a/src/or/connection_or.c b/src/or/connection_or.c index 72c4dd12e..cacdaf203 100644 --- a/src/or/connection_or.c +++ b/src/or/connection_or.c @@ -20,11 +20,25 @@ static void conn_or_init_crypto(connection_t *conn); static void connection_or_set_open(connection_t *conn); #endif -/* - * - * these two functions are the main ways 'in' to connection_or - * - */ +/**************************************************************/ + +static void cell_pack(char *dest, const cell_t *src) { + *(uint16_t*)dest = htons(src->aci); + *(uint8_t*)(dest+2) = src->command; + *(uint8_t*)(dest+3) = src->length; + *(uint32_t*)(dest+4) = 0; /* Reserved */ + memcpy(dest+8, src->payload, CELL_PAYLOAD_SIZE); +} + +static void cell_unpack(cell_t *dest, const char *src) { + dest->aci = ntohs(*(uint16_t*)(src)); + dest->command = *(uint8_t*)(src+2); + dest->length = *(uint8_t*)(src+3); + dest->seq = ntohl(*(uint32_t*)(src+4)); + memcpy(dest->payload, src+8, CELL_PAYLOAD_SIZE); +} + +/**************************************************************/ int connection_or_process_inbuf(connection_t *conn) { @@ -424,14 +438,8 @@ or_handshake_client_process_auth(connection_t *conn) { return connection_process_inbuf(conn); /* process the rest of the inbuf */ } -/* - * - * auth handshake, as performed by OR *receiving* the connection - * - */ - -static int -or_handshake_server_process_auth(connection_t *conn) { +/* auth handshake, as performed by OR *receiving* the connection */ +static int or_handshake_server_process_auth(connection_t *conn) { int retval; char buf[128]; /* 50 of this is expected to be used for OR, 38 for OP */ @@ -639,7 +647,6 @@ connection_or_set_open(connection_t *conn) { static void conn_or_init_crypto(connection_t *conn) { - //int x; unsigned char iv[16]; assert(conn); @@ -718,21 +725,9 @@ int connection_process_cell_from_inbuf(connection_t *conn) { return connection_process_inbuf(conn); /* process the remainder of the buffer */ } - #ifndef USE_TLS int connection_encrypt_cell(char *cellp, connection_t *conn) { char cryptcell[CELL_NETWORK_SIZE]; -#if 0 - int x; - char *px; - - printf("Sending: Cell header plaintext: "); - px = (char *)cellp; - for(x=0;x<8;x++) { - printf("%u ",px[x]); - }# - printf("\n"); -#endif assert(conn); @@ -740,14 +735,6 @@ int connection_encrypt_cell(char *cellp, connection_t *conn) { log(LOG_ERR,"Could not encrypt cell for connection %s:%u.",conn->address,conn->port); return -1; } -#if 0 - printf("Sending: Cell header crypttext: "); - px = (char *)&newcell; - for(x=0;x<8;x++) { - printf("%u ",px[x]); - } - printf("\n"); -#endif memcpy(cellp,cryptcell,CELL_NETWORK_SIZE); return 0; diff --git a/src/or/directory.c b/src/or/directory.c index ed4c72027..db2287b7c 100644 --- a/src/or/directory.c +++ b/src/or/directory.c @@ -6,6 +6,11 @@ #define MAX_DIR_SIZE 50000 /* XXX, big enough? */ +static int directory_send_command(connection_t *conn); +static void directory_rebuild(void); +static int directory_handle_command(connection_t *conn); +static int directory_handle_reading(connection_t *conn); + /********* START VARIABLES **********/ extern or_options_t options; /* command-line and config-file options */ @@ -77,7 +82,7 @@ void directory_initiate_fetch(routerinfo_t *router) { } } -int directory_send_command(connection_t *conn) { +static int directory_send_command(connection_t *conn) { assert(conn && conn->type == CONN_TYPE_DIR); @@ -94,7 +99,7 @@ void directory_set_dirty(void) { directory_dirty = 1; } -void directory_rebuild(void) { +static void directory_rebuild(void) { if(directory_dirty) { if (dump_signed_directory_to_string(the_directory, MAX_DIR_SIZE, get_signing_privatekey())) { @@ -150,7 +155,7 @@ int connection_dir_process_inbuf(connection_t *conn) { return 0; } -int directory_handle_command(connection_t *conn) { +static int directory_handle_command(connection_t *conn) { char buf[15]; assert(conn && conn->type == CONN_TYPE_DIR); @@ -185,7 +190,7 @@ int directory_handle_command(connection_t *conn) { return 0; } -int directory_handle_reading(connection_t *conn) { +static int directory_handle_reading(connection_t *conn) { int amt; char *headers; diff --git a/src/or/onion.c b/src/or/onion.c index 1ba4c1789..5088fb59a 100644 --- a/src/or/onion.c +++ b/src/or/onion.c @@ -155,8 +155,7 @@ int onionskin_answer(circuit_t *circ, unsigned char *payload, unsigned char *key } /* uses a weighted coin with weight cw to choose a route length */ -int chooselen(double cw) -{ +static int chooselen(double cw) { int len = 2; uint8_t coin; @@ -181,8 +180,7 @@ int chooselen(double cw) * int cw is the coin weight to use when choosing the route * order of routers is from last to first */ -unsigned int *new_route(double cw, routerinfo_t **rarray, int rarray_len, int *routelen) -{ +static unsigned int *new_route(double cw, routerinfo_t **rarray, int rarray_len, int *routelen) { int i; int num_acceptable_routers; unsigned int *route; diff --git a/src/or/or.h b/src/or/or.h index 207b80957..c52fb3525 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -96,7 +96,7 @@ #include "../common/log.h" #include "../common/util.h" -#define RECOMMENDED_SOFTWARE_VERSIONS "0.0.2pre7,0.0.2pre8" +#define RECOMMENDED_SOFTWARE_VERSIONS "0.0.2pre8,0.0.2pre9" #define MAXCONNECTIONS 1000 /* upper bound on max connections. can be lowered by config file */ @@ -466,60 +466,29 @@ typedef struct { /********************************* buffers.c ***************************/ int buf_new(char **buf, int *buflen, int *buf_datalen); - void buf_free(char *buf); int read_to_buf(int s, int at_most, char **buf, int *buflen, int *buf_datalen, int *reached_eof); - /* grab from s, put onto buf, return how many bytes read */ int read_to_buf_tls(tor_tls *tls, int at_most, char **buf, int *buflen, int *buf_datalen); - /* grab from tls, put onto buf, return how many bytes read or a TLS - * status (same status codes as tor_tls_read) */ int flush_buf(int s, char **buf, int *buflen, int *buf_flushlen, int *buf_datalen); - /* push from buf onto s - * then memmove to front of buf - * return -1 or how many bytes remain on the buf */ int flush_buf_tls(tor_tls *tls, char **buf, int *buflen, int *buf_flushlen, int *buf_datalen); - /* As flush_buf, but returns number of bytes written or TLS status - * (same status codes as tor_tls_write) */ - -int write_to_buf(char *string, int string_len, - char **buf, int *buflen, int *buf_datalen); - /* append string to buf (growing as needed, return -1 if "too big") - * return total number of bytes on the buf - */ - -int fetch_from_buf(char *string, int string_len, - char **buf, int *buflen, int *buf_datalen); - /* if there is string_len bytes in buf, write them onto string, - * then memmove buf back (that is, remove them from buf) - */ - -int find_on_inbuf(char *string, int string_len, - char *buf, int buf_datalen); - /* find first instance of needle 'string' on haystack 'buf'. return how - * many bytes from the beginning of buf to the end of string. - * If it's not there, return -1. - */ -/********************************* cell.c ***************************/ - -int pack_create(uint16_t aci, unsigned char *onion, uint32_t onionlen, unsigned char **cellbuf, unsigned int *cellbuflen); +int write_to_buf(char *string, int string_len, char **buf, int *buflen, int *buf_datalen); +int fetch_from_buf(char *string, int string_len, char **buf, int *buflen, int *buf_datalen); +int find_on_inbuf(char *string, int string_len, char *buf, int buf_datalen); /********************************* circuit.c ***************************/ void circuit_add(circuit_t *circ); void circuit_remove(circuit_t *circ); - circuit_t *circuit_new(aci_t p_aci, connection_t *p_conn); +void circuit_free(circuit_t *circ); -/* internal */ -aci_t get_unique_aci_by_addr_port(uint32_t addr, uint16_t port, int aci_type); - +circuit_t *circuit_enumerate_by_naddr_nport(circuit_t *start, uint32_t naddr, uint16_t nport); circuit_t *circuit_get_by_aci_conn(aci_t aci, connection_t *conn); circuit_t *circuit_get_by_conn(connection_t *conn); circuit_t *circuit_get_newest_ap(void); -circuit_t *circuit_enumerate_by_naddr_nport(circuit_t *start, uint32_t naddr, uint16_t nport); int circuit_deliver_relay_cell(cell_t *cell, circuit_t *circ, int cell_direction, crypt_path_t *layer_hint); @@ -531,14 +500,8 @@ void circuit_resume_edge_reading(circuit_t *circ, int edge_type, crypt_path_t *l int circuit_consider_stop_edge_reading(circuit_t *circ, int edge_type, crypt_path_t *layer_hint); int circuit_consider_sending_sendme(circuit_t *circ, int edge_type, crypt_path_t *layer_hint); -void circuit_free(circuit_t *circ); -void circuit_free_cpath(crypt_path_t *cpath); -void circuit_free_cpath_node(crypt_path_t *victim); - void circuit_close(circuit_t *circ); - void circuit_about_to_close_connection(connection_t *conn); - /* flush and send destroys for all circuits using conn */ void circuit_dump_by_conn(connection_t *conn); @@ -555,16 +518,8 @@ int circuit_truncated(circuit_t *circ, crypt_path_t *layer); void command_process_cell(cell_t *cell, connection_t *conn); -void command_process_create_cell(cell_t *cell, connection_t *conn); -void command_process_created_cell(cell_t *cell, connection_t *conn); -void command_process_sendme_cell(cell_t *cell, connection_t *conn); -void command_process_relay_cell(cell_t *cell, connection_t *conn); -void command_process_destroy_cell(cell_t *cell, connection_t *conn); -void command_process_connected_cell(cell_t *cell, connection_t *conn); - /********************************* config.c ***************************/ -/* return 0 if success, <0 if failure. */ int getconfig(int argc, char **argv, or_options_t *options); /********************************* connection.c ***************************/ @@ -575,7 +530,9 @@ void connection_free(connection_t *conn); int connection_create_listener(struct sockaddr_in *bindaddr, int type); int connection_handle_listener_read(connection_t *conn, int new_type); +#ifdef USE_TLS int connection_tls_start_handshake(connection_t *conn, int receiving); +#endif int connection_connect(connection_t *conn, char *address, uint32_t addr, uint16_t port); int retry_all_connections(uint16_t or_listenport, uint16_t ap_listenport, uint16_t dir_listenport); @@ -584,13 +541,12 @@ int connection_handle_read(connection_t *conn); int connection_read_to_buf(connection_t *conn); int connection_fetch_from_buf(char *string, int len, connection_t *conn); - -int connection_outbuf_too_full(connection_t *conn); int connection_find_on_inbuf(char *string, int len, connection_t *conn); + int connection_wants_to_flush(connection_t *conn); +int connection_outbuf_too_full(connection_t *conn); int connection_flush_buf(connection_t *conn); int connection_handle_write(connection_t *conn); - int connection_write_to_buf(char *string, int len, connection_t *conn); int connection_receiver_bucket_should_increase(connection_t *conn); @@ -600,20 +556,16 @@ int connection_is_listener(connection_t *conn); int connection_state_is_open(connection_t *conn); int connection_send_destroy(aci_t aci, connection_t *conn); -int connection_send_connected(aci_t aci, connection_t *conn); int connection_process_inbuf(connection_t *conn); - int connection_finished_flushing(connection_t *conn); -void cell_pack(char *dest, const cell_t *src); -void cell_unpack(cell_t *dest, const char *src); - /********************************* connection_edge.c ***************************/ int connection_edge_process_inbuf(connection_t *conn); int connection_edge_send_command(connection_t *fromconn, circuit_t *circ, int relay_command); -int connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ, connection_t *conn, int edge_type, crypt_path_t *layer_hint); +int connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ, connection_t *conn, + int edge_type, crypt_path_t *layer_hint); int connection_edge_finished_flushing(connection_t *conn); int connection_package_raw_inbuf(connection_t *conn); @@ -646,12 +598,8 @@ int assign_to_cpuworker(connection_t *cpuworker, unsigned char question_type, /********************************* directory.c ***************************/ void directory_initiate_fetch(routerinfo_t *router); -int directory_send_command(connection_t *conn); void directory_set_dirty(void); -void directory_rebuild(void); int connection_dir_process_inbuf(connection_t *conn); -int directory_handle_command(connection_t *conn); -int directory_handle_reading(connection_t *conn); int connection_dir_finished_flushing(connection_t *conn); /********************************* dns.c ***************************/ @@ -706,15 +654,6 @@ void onion_pending_remove(circuit_t *circ); int onionskin_answer(circuit_t *circ, unsigned char *payload, unsigned char *keys); -/* uses a weighted coin with weight cw to choose a route length */ -int chooselen(double cw); - -/* returns an array of pointers to routent that define a new route through the OR network - * int cw is the coin weight to use when choosing the route - * order of routers is from last to first - */ -unsigned int *new_route(double cw, routerinfo_t **rarray, int rarray_len, int *routelen); - crypt_path_t *onion_generate_cpath(routerinfo_t **firsthop); int onion_skin_create(crypto_pk_env_t *router_key, @@ -743,8 +682,6 @@ void router_get_directory(directory_t **pdirectory); int router_is_me(uint32_t addr, uint16_t port); void router_forget_router(uint32_t addr, uint16_t port); int router_get_list_from_file(char *routerfile); -int router_resolve(routerinfo_t *router); -int router_resolve_directory(directory_t *dir); /* Reads a list of known routers, unsigned. */ int router_get_list_from_string(char *s); diff --git a/src/or/routers.c b/src/or/routers.c index b1ebbe7cd..180713fa8 100644 --- a/src/or/routers.c +++ b/src/or/routers.c @@ -34,6 +34,8 @@ static int router_get_list_from_string_tok(char **s, directory_t **dest, directory_token_t *tok); static int router_add_exit_policy(routerinfo_t *router, directory_token_t *tok); +static int +router_resolve_directory(directory_t *dir); /****************************************************************************/ @@ -667,7 +669,6 @@ int router_get_dir_from_string_impl(char *s, directory_t **dest, #undef TOK_IS } - static int router_get_list_from_string_tok(char **s, directory_t **dest, directory_token_t *tok) { @@ -702,7 +703,7 @@ static int router_get_list_from_string_tok(char **s, directory_t **dest, return 0; } -int +static int router_resolve(routerinfo_t *router) { struct hostent *rent; @@ -719,7 +720,7 @@ router_resolve(routerinfo_t *router) return 0; } -int +static int router_resolve_directory(directory_t *dir) { int i, max, remove; |