diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/or/buffers.c | 16 | ||||
-rw-r--r-- | src/or/circuit.c | 28 | ||||
-rw-r--r-- | src/or/command.c | 4 | ||||
-rw-r--r-- | src/or/config.c | 12 | ||||
-rw-r--r-- | src/or/connection.c | 40 | ||||
-rw-r--r-- | src/or/connection_edge.c | 12 | ||||
-rw-r--r-- | src/or/connection_or.c | 10 | ||||
-rw-r--r-- | src/or/directory.c | 2 | ||||
-rw-r--r-- | src/or/dirserv.c | 10 | ||||
-rw-r--r-- | src/or/onion.c | 18 | ||||
-rw-r--r-- | src/or/or.h | 14 | ||||
-rw-r--r-- | src/or/router.c | 16 | ||||
-rw-r--r-- | src/or/routerlist.c | 65 | ||||
-rw-r--r-- | src/or/test.c | 76 | ||||
-rw-r--r-- | src/or/tor_main.c | 2 |
15 files changed, 162 insertions, 163 deletions
diff --git a/src/or/buffers.c b/src/or/buffers.c index a1ad82b50..56c31b55c 100644 --- a/src/or/buffers.c +++ b/src/or/buffers.c @@ -71,7 +71,7 @@ static INLINE void buf_shrink_if_underfull(buf_t *buf) { * MIN_BUF_SHRINK_SIZE. */ new_len = buf->len / 2; - while (buf->datalen < new_len/4 && new_len/2 > MIN_BUF_SHRINK_SIZE) + while (buf->datalen < new_len/4 && new_len/2 > MIN_BUF_SHRINK_SIZE) new_len /= 2; log_fn(LOG_DEBUG,"Shrinking buffer from %d to %d bytes.", (int)buf->len, (int)new_len); @@ -91,7 +91,7 @@ static INLINE void buf_remove_from_front(buf_t *buf, size_t n) { * Otherwise, return index of the first character in buf _after_ the * first instance of str. */ -static int find_str_in_str(const char *str, int str_len, +static int find_str_in_str(const char *str, int str_len, const char *buf, int buf_len) { const char *location; @@ -216,14 +216,14 @@ int read_to_buf_tls(tor_tls *tls, int at_most, buf_t *buf) { return 0; r = tor_tls_read(tls, buf->mem+buf->datalen, at_most); - if (r<0) + if (r<0) return r; buf->datalen += r; log_fn(LOG_DEBUG,"Read %d bytes. %d on inbuf.",r, (int)buf->datalen); return r; -} +} -int flush_buf(int s, buf_t *buf, int *buf_flushlen) +int flush_buf(int s, buf_t *buf, int *buf_flushlen) { /* push from buf onto s @@ -264,7 +264,7 @@ int flush_buf(int s, buf_t *buf, int *buf_flushlen) } } -int flush_buf_tls(tor_tls *tls, buf_t *buf, int *buf_flushlen) +int flush_buf_tls(tor_tls *tls, buf_t *buf, int *buf_flushlen) { int r; assert(tls && BUF_OK(buf) && buf_flushlen); @@ -325,7 +325,7 @@ int fetch_from_buf(char *string, int string_len, buf_t *buf) { * them), remove them from buf, and return 1. * (If headers or body is NULL, discard that part of the buf.) * If a headers or body doesn't fit in the arg, return -1. - * + * * Else, change nothing and return 0. */ int fetch_from_buf_http(buf_t *buf, @@ -358,7 +358,7 @@ int fetch_from_buf_http(buf_t *buf, } #define CONTENT_LENGTH "\r\nContent-Length: " - i = find_str_in_str(CONTENT_LENGTH, strlen(CONTENT_LENGTH), + i = find_str_in_str(CONTENT_LENGTH, strlen(CONTENT_LENGTH), headers, headerlen); if(i > 0) { contentlen = atoi(headers+i); diff --git a/src/or/circuit.c b/src/or/circuit.c index e9bf1db18..dda3077ec 100644 --- a/src/or/circuit.c +++ b/src/or/circuit.c @@ -7,7 +7,7 @@ extern or_options_t options; /* command-line and config-file options */ static void circuit_free_cpath_node(crypt_path_t *victim); -static circ_id_t get_unique_circ_id_by_conn(connection_t *conn, int circ_id_type); +static circ_id_t get_unique_circ_id_by_conn(connection_t *conn, int circ_id_type); unsigned long stats_n_relay_cells_relayed = 0; unsigned long stats_n_relay_cells_delivered = 0; @@ -54,7 +54,7 @@ void circuit_remove(circuit_t *circ) { } circuit_t *circuit_new(circ_id_t p_circ_id, connection_t *p_conn) { - circuit_t *circ; + circuit_t *circ; circ = tor_malloc_zero(sizeof(circuit_t)); @@ -344,7 +344,7 @@ int circuit_deliver_relay_cell(cell_t *cell, circuit_t *circ, char recognized=0; assert(cell && circ); - assert(cell_direction == CELL_DIRECTION_OUT || cell_direction == CELL_DIRECTION_IN); + assert(cell_direction == CELL_DIRECTION_OUT || cell_direction == CELL_DIRECTION_IN); log_fn(LOG_DEBUG,"direction %d, streamid %d before crypt.", cell_direction, *(int*)(cell->payload+1)); @@ -409,7 +409,7 @@ int relay_crypt(circuit_t *circ, char *in, int inlen, char cell_direction, assert(inlen < CELL_NETWORK_SIZE); - if(cell_direction == CELL_DIRECTION_IN) { + if(cell_direction == CELL_DIRECTION_IN) { if(circ->cpath) { /* we're at the beginning of the circuit. We'll want to do layered crypts. */ thishop = circ->cpath; @@ -453,7 +453,7 @@ int relay_crypt(circuit_t *circ, char *in, int inlen, char cell_direction, /* don't check for recognized. only the OP can recognize a stream on the way back. */ } - } else if(cell_direction == CELL_DIRECTION_OUT) { + } else if(cell_direction == CELL_DIRECTION_OUT) { if(circ->cpath) { /* we're at the beginning of the circuit. We'll want to do layered crypts. */ thishop = *layer_hint; /* we already know which layer, from when we package_raw_inbuf'ed */ @@ -604,12 +604,12 @@ void circuit_close(circuit_t *circ) { if(circ->n_conn) connection_send_destroy(circ->n_circ_id, circ->n_conn); for(conn=circ->n_streams; conn; conn=conn->next_stream) { - connection_send_destroy(circ->n_circ_id, conn); + connection_send_destroy(circ->n_circ_id, conn); } if(circ->p_conn) connection_send_destroy(circ->n_circ_id, circ->p_conn); for(conn=circ->p_streams; conn; conn=conn->next_stream) { - connection_send_destroy(circ->p_circ_id, conn); + connection_send_destroy(circ->p_circ_id, conn); } if (circ->state == CIRCUIT_STATE_BUILDING || circ->state == CIRCUIT_STATE_OR_WAIT) { @@ -638,7 +638,7 @@ void circuit_about_to_close_connection(connection_t *conn) { if(circ->p_conn == conn) /* it's closing behind us */ circ->p_conn = NULL; circuit_close(circ); - } + } return; case CONN_TYPE_AP: case CONN_TYPE_EXIT: @@ -692,8 +692,8 @@ void circuit_dump_details(int severity, circuit_t *circ, int poll_index, log(severity,"Building: desired len %d, planned exit node %s.", circ->build_state->desired_path_len, circ->build_state->chosen_exit); for(hop=circ->cpath;hop->next != circ->cpath; hop=hop->next) - log(severity,"hop: state %d, addr %x, port %d", hop->state, - (unsigned int)hop->addr, + log(severity,"hop: state %d, addr %x, port %d", hop->state, + (unsigned int)hop->addr, (int)hop->port); } } @@ -744,7 +744,7 @@ void circuit_expire_unused_circuits(void) { /* Number of consecutive failures so far; should only be touched by * circuit_launch_new and circuit_*_failure_count. */ -static int n_circuit_failures = 0; +static int n_circuit_failures = 0; /* Return -1 if you aren't going to try to make a circuit, 0 if you did try. */ int circuit_launch_new(void) { @@ -820,7 +820,7 @@ int circuit_establish_circuit(void) { log_fn(LOG_DEBUG,"connecting in progress (or finished). Good."); return 0; /* return success. The onion/circuit/etc will be taken care of automatically * (may already have been) whenever n_conn reaches OR_CONN_STATE_OPEN. - */ + */ } else { /* it (or a twin) is already open. use it. */ circ->n_addr = n_conn->addr; circ->n_port = n_conn->port; @@ -1084,7 +1084,7 @@ void assert_cpath_layer_ok(const crypt_path_t *cp) assert(cp->b_crypto); assert(cp->addr); assert(cp->port); - switch(cp->state) + switch(cp->state) { case CPATH_STATE_CLOSED: case CPATH_STATE_OPEN: @@ -1120,7 +1120,7 @@ void assert_cpath_ok(const crypt_path_t *cp) } } -void assert_circuit_ok(const circuit_t *c) +void assert_circuit_ok(const circuit_t *c) { connection_t *conn; diff --git a/src/or/command.c b/src/or/command.c index 8935fcb08..3d65b2b9a 100644 --- a/src/or/command.c +++ b/src/or/command.c @@ -21,7 +21,7 @@ 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; - long time_passed; + long time_passed; *num += 1; @@ -46,7 +46,7 @@ void command_process_cell(cell_t *cell, connection_t *conn) { if(now > current_second) { /* the second has rolled over */ /* print stats */ - log(LOG_INFO,"At end of second:"); + log(LOG_INFO,"At end of second:"); log(LOG_INFO,"Create: %d (%d ms)", num_create, create_time/1000); log(LOG_INFO,"Created: %d (%d ms)", num_created, created_time/1000); log(LOG_INFO,"Relay: %d (%d ms)", num_relay, relay_time/1000); diff --git a/src/or/config.c b/src/or/config.c index d05b5ba24..16efde10e 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -50,7 +50,7 @@ static struct config_line *config_get_commandlines(int argc, char **argv) { char *s; int i = 1; - while(i < argc-1) { + while(i < argc-1) { if(!strcmp(argv[i],"-f")) { // log(LOG_DEBUG,"Commandline: skipping over -f."); i+=2; /* this is the config file option. ignore it. */ @@ -119,7 +119,7 @@ static int config_compare(struct config_line *c, char *key, int type, void *arg) log_fn(LOG_DEBUG,"Recognized keyword '%s' as %s, using value '%s'.",c->key,key,c->value); switch(type) { - case CONFIG_TYPE_INT: + case CONFIG_TYPE_INT: *(int *)arg = atoi(c->value); break; case CONFIG_TYPE_BOOL: @@ -205,7 +205,7 @@ static void config_assign(or_options_t *options, struct config_line *list) { } list = list->next; - } + } } /* prints the usage of tor. */ @@ -300,7 +300,7 @@ int getconfig(int argc, char **argv, or_options_t *options) { previous_runasdaemon = options->RunAsDaemon; free_options(options); } - init_options(options); + init_options(options); if(argc > 1 && (!strcmp(argv[1], "-h") || !strcmp(argv[1],"--help"))) { print_usage(); @@ -330,7 +330,7 @@ int getconfig(int argc, char **argv, or_options_t *options) { config_assign(options,cl); config_free_lines(cl); config_close(cf); - + /* go through command-line variables too */ cl = config_get_commandlines(argc,argv); config_assign(options,cl); @@ -394,7 +394,7 @@ int getconfig(int argc, char **argv, or_options_t *options) { if(options->SocksPort == 0 && options->ORPort == 0) { log(LOG_WARN,"SocksPort and ORPort are both undefined? Quitting."); result = -1; - } + } if(options->DirPort < 0) { log(LOG_WARN,"DirPort option can't be negative."); diff --git a/src/or/connection.c b/src/or/connection.c index 11852a973..aaf01b6b9 100644 --- a/src/or/connection.c +++ b/src/or/connection.c @@ -146,7 +146,7 @@ int connection_create_listener(char *bindaddress, uint16_t bindport, int type) { memcpy(&(bindaddr.sin_addr.s_addr),rent->h_addr,rent->h_length); s = socket(PF_INET,SOCK_STREAM,IPPROTO_TCP); - if (s < 0) { + if (s < 0) { log_fn(LOG_WARN,"Socket creation failed."); return -1; } @@ -246,7 +246,7 @@ static int connection_init_accepted_conn(connection_t *conn) { return 0; } -/* take conn, make a nonblocking socket; try to connect to +/* take conn, make a nonblocking socket; try to connect to * addr:port (they arrive in *host order*). If fail, return -1. Else * assign s to conn->s: if connected return 1, if eagain return 0. * address is used to make the logs useful. @@ -343,7 +343,7 @@ int connection_handle_read(connection_t *conn) { } if(connection_read_to_buf(conn) < 0) { - if(conn->type == CONN_TYPE_DIR && + if(conn->type == CONN_TYPE_DIR && (conn->state == DIR_CONN_STATE_CONNECTING_FETCH || conn->state == DIR_CONN_STATE_CONNECTING_UPLOAD)) { /* it's a directory server and connecting failed: forget about this router */ @@ -485,7 +485,7 @@ int connection_handle_write(connection_t *conn) { /* case TOR_TLS_DONE: * for TOR_TLS_DONE, fall through to check if the flushlen * is empty, so we can stop writing. - */ + */ } } else { if(flush_buf(conn->s, conn->outbuf, &conn->outbuf_flushlen) < 0) @@ -520,7 +520,7 @@ connection_t *connection_exact_get_by_addr_port(uint32_t addr, uint16_t port) { int i, n; connection_t *conn; connection_t **carray; - + get_connection_array(&carray,&n); for(i=0;i<n;i++) { conn = carray[i]; @@ -547,13 +547,13 @@ connection_t *connection_twin_get_by_addr_port(uint32_t addr, uint16_t port) { log(LOG_INFO,"connection_twin_get_by_addr_port(): Found exact match."); return conn; } - + /* now check if any of the other open connections are a twin for this one */ - + router = router_get_by_addr_port(addr,port); if(!router) return NULL; - + get_connection_array(&carray,&n); for(i=0;i<n;i++) { conn = carray[i]; @@ -571,7 +571,7 @@ connection_t *connection_get_by_type(int type) { int i, n; connection_t *conn; connection_t **carray; - + get_connection_array(&carray,&n); for(i=0;i<n;i++) { conn = carray[i]; @@ -585,7 +585,7 @@ connection_t *connection_get_by_type_state(int type, int state) { int i, n; connection_t *conn; connection_t **carray; - + get_connection_array(&carray,&n); for(i=0;i<n;i++) { conn = carray[i]; @@ -599,7 +599,7 @@ connection_t *connection_get_by_type_state_lastwritten(int type, int state) { int i, n; connection_t *conn, *best=NULL; connection_t **carray; - + get_connection_array(&carray,&n); for(i=0;i<n;i++) { conn = carray[i]; @@ -616,7 +616,7 @@ int connection_receiver_bucket_should_increase(connection_t *conn) { if(!connection_speaks_cells(conn)) return 0; /* edge connections don't use receiver_buckets */ if(conn->state != OR_CONN_STATE_OPEN) - return 0; /* only open connections play the rate limiting game */ + return 0; /* only open connections play the rate limiting game */ assert(conn->bandwidth > 0); if(conn->receiver_bucket > 9*conn->bandwidth) @@ -653,7 +653,7 @@ int connection_send_destroy(circ_id_t circ_id, connection_t *conn) { assert(conn); if(!connection_speaks_cells(conn)) { - log_fn(LOG_INFO,"CircID %d: At an edge. Marking connection for close.", + log_fn(LOG_INFO,"CircID %d: At an edge. Marking connection for close.", circ_id); if(connection_edge_end(conn, END_STREAM_REASON_DESTROY, conn->cpath_layer) < 0) log_fn(LOG_WARN,"1: I called connection_edge_end redundantly."); @@ -682,9 +682,9 @@ int connection_process_inbuf(connection_t *conn) { case CONN_TYPE_DIR: return connection_dir_process_inbuf(conn); case CONN_TYPE_DNSWORKER: - return connection_dns_process_inbuf(conn); + return connection_dns_process_inbuf(conn); case CONN_TYPE_CPUWORKER: - return connection_cpu_process_inbuf(conn); + return connection_cpu_process_inbuf(conn); default: log_fn(LOG_WARN,"got unexpected conn->type %d.", conn->type); return -1; @@ -724,7 +724,7 @@ void assert_connection_ok(connection_t *conn, time_t now) /* XXX check: wants_to_read, wants_to_write, s, poll_index, * marked_for_close. */ - + /* buffers */ if (!connection_is_listener(conn)) { assert(conn->inbuf); @@ -735,7 +735,7 @@ void assert_connection_ok(connection_t *conn, time_t now) assert(!now || conn->timestamp_lastwritten <= now); assert(conn->timestamp_created <= conn->timestamp_lastread); assert(conn->timestamp_created <= conn->timestamp_lastwritten); - + /* XXX Fix this; no longer so.*/ #if 0 if(conn->type != CONN_TYPE_OR && conn->type != CONN_TYPE_DIR) @@ -758,7 +758,7 @@ void assert_connection_ok(connection_t *conn, time_t now) if (conn->state != OR_CONN_STATE_CONNECTING) assert(conn->tls); } - + if (conn->type != CONN_TYPE_EXIT && conn->type != CONN_TYPE_AP) { assert(!conn->stream_id[0]); assert(!conn->next_stream); @@ -768,7 +768,7 @@ void assert_connection_ok(connection_t *conn, time_t now) assert(!conn->done_sending); assert(!conn->done_receiving); } else { - assert(!conn->next_stream || + assert(!conn->next_stream || conn->next_stream->type == CONN_TYPE_EXIT || conn->next_stream->type == CONN_TYPE_AP); if(conn->type == CONN_TYPE_AP && conn->state == AP_CONN_STATE_OPEN) @@ -781,7 +781,7 @@ void assert_connection_ok(connection_t *conn, time_t now) assert(!conn->socks_request); } - switch(conn->type) + switch(conn->type) { case CONN_TYPE_OR_LISTENER: case CONN_TYPE_AP_LISTENER: diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c index 73c5b373c..e5c591954 100644 --- a/src/or/connection_edge.c +++ b/src/or/connection_edge.c @@ -27,7 +27,7 @@ int connection_edge_process_inbuf(connection_t *conn) { if(conn->inbuf_reached_eof) { #ifdef HALF_OPEN - /* eof reached; we're done reading, but we might want to write more. */ + /* eof reached; we're done reading, but we might want to write more. */ conn->done_receiving = 1; shutdown(conn->s, 0); /* XXX check return, refactor NM */ if (conn->done_sending) { @@ -38,7 +38,7 @@ int connection_edge_process_inbuf(connection_t *conn) { NULL, 0, conn->cpath_layer); } return 0; -#else +#else /* eof reached, kill it. */ log_fn(LOG_INFO,"conn (fd %d) reached eof. Closing.", conn->s); if(connection_edge_end(conn, END_STREAM_REASON_DONE, conn->cpath_layer) < 0) @@ -676,7 +676,7 @@ static void connection_ap_handshake_send_begin(connection_t *ap_conn, circuit_t memcpy(payload, ap_conn->stream_id, STREAM_ID_SIZE); payload_len = STREAM_ID_SIZE + 1 + snprintf(payload+STREAM_ID_SIZE,CELL_PAYLOAD_SIZE-RELAY_HEADER_SIZE-STREAM_ID_SIZE, - "%s:%d", + "%s:%d", string_addr ? string_addr : ap_conn->socks_request->address, ap_conn->socks_request->port); @@ -692,7 +692,7 @@ static void connection_ap_handshake_send_begin(connection_t *ap_conn, circuit_t /* XXX Right now, we rely on the socks client not to send us any data * XXX until we've sent back a socks reply. (If it does, we could wind * XXX up packaging that data and sending it to the exit, then later having - * XXX the exit refuse us.) + * XXX the exit refuse us.) * XXX Perhaps we should grow an AP_CONN_STATE_CONNECTING state. */ log_fn(LOG_INFO,"Address/port sent, ap socket %d, n_circ_id %d",ap_conn->s,circ->n_circ_id); @@ -865,7 +865,7 @@ static int client_dns_size = 0; static SPLAY_HEAD(client_dns_tree, client_dns_entry) client_dns_root; static int compare_client_dns_entries(struct client_dns_entry *a, - struct client_dns_entry *b) + struct client_dns_entry *b) { return strcasecmp(a->address, b->address); } @@ -962,7 +962,7 @@ void client_dns_clean(void) if(!client_dns_size) return; - expired_entries = tor_malloc(client_dns_size * + expired_entries = tor_malloc(client_dns_size * sizeof(struct client_dns_entry *)); now = time(NULL); diff --git a/src/or/connection_or.c b/src/or/connection_or.c index e51691387..8a5e20172 100644 --- a/src/or/connection_or.c +++ b/src/or/connection_or.c @@ -118,7 +118,7 @@ connection_t *connection_or_connect(routerinfo_t *router) { return NULL; case 0: connection_set_poll_socket(conn); - connection_watch_events(conn, POLLIN | POLLOUT | POLLERR); + connection_watch_events(conn, POLLIN | POLLOUT | POLLERR); /* writable indicates finish, readable indicates broken link, error indicates broken link on windows */ conn->state = OR_CONN_STATE_CONNECTING; @@ -248,7 +248,7 @@ void connection_or_write_cell_to_buf(const cell_t *cellp, connection_t *conn) { assert(connection_speaks_cells(conn)); cell_pack(n, cellp); - + connection_write_to_buf(n, CELL_NETWORK_SIZE, conn); } @@ -262,13 +262,13 @@ loop: conn->s,(int)buf_datalen(conn->inbuf),tor_tls_get_pending_bytes(conn->tls)); if(buf_datalen(conn->inbuf) < CELL_NETWORK_SIZE) /* entire response available? */ return 0; /* not yet */ - + connection_fetch_from_buf(buf, CELL_NETWORK_SIZE, conn); - + /* retrieve cell info from buf (create the host-order struct from the * network-order string) */ cell_unpack(&cell, buf); - + command_process_cell(&cell, conn); goto loop; /* process the remainder of the buffer */ diff --git a/src/or/directory.c b/src/or/directory.c index 78ab7e11a..6ea453a98 100644 --- a/src/or/directory.c +++ b/src/or/directory.c @@ -165,7 +165,7 @@ static int directory_handle_command_get(connection_t *conn, return -1; /* XXX send some helpful http error code */ } - log_fn(LOG_DEBUG,"Dumping directory to client."); + log_fn(LOG_DEBUG,"Dumping directory to client."); connection_write_to_buf(answerstring, strlen(answerstring), conn); connection_write_to_buf(cp, dlen, conn); conn->state = DIR_CONN_STATE_SERVER_WRITING; diff --git a/src/or/dirserv.c b/src/or/dirserv.c index 10197e27c..a3a29d939 100644 --- a/src/or/dirserv.c +++ b/src/or/dirserv.c @@ -141,7 +141,7 @@ dirserv_router_fingerprint_is_known(const routerinfo_t *router) } } -void +void dirserv_free_fingerprint_list() { int i; @@ -285,17 +285,17 @@ dirserv_add_descriptor(const char **desc) tor_free(desc_tmp); if (ri) routerinfo_free(ri); - + return -1; } -void +void directory_set_dirty() { the_directory_is_dirty = 1; } -int +int dirserv_init_from_directory_string(const char *dir) { const char *cp = dir; @@ -343,7 +343,7 @@ list_running_servers(char **nicknames_out) if (i) strcat(cp, " "); strcat(cp, nickname_lst[i]); - while (*cp) + while (*cp) ++cp; } return 0; diff --git a/src/or/onion.c b/src/or/onion.c index dd7db6162..7e3c7d343 100644 --- a/src/or/onion.c +++ b/src/or/onion.c @@ -111,7 +111,7 @@ void onion_pending_remove(circuit_t *circ) { /* now victim points to the element that needs to be removed */ - free(victim); + free(victim); } /* given a response payload and keys, initialize, then send a created cell back */ @@ -266,7 +266,7 @@ static routerinfo_t *choose_good_exit_server(routerlist_t *dir) carray[j]->marked_for_close || circuit_stream_is_being_handled(carray[j])) continue; /* Skip everything but APs in CIRCUIT_WAIT */ - switch (connection_ap_can_use_exit(carray[j], dir->routers[i])) + switch (connection_ap_can_use_exit(carray[j], dir->routers[i])) { case -1: log_fn(LOG_DEBUG,"%s (index %d) would reject this stream.", @@ -283,7 +283,7 @@ static routerinfo_t *choose_good_exit_server(routerlist_t *dir) dir->routers[i]->nickname, i, n_maybe_supported[i]); } } /* End looping over connections. */ - if (n_supported[i] > best_support) { + if (n_supported[i] > best_support) { /* If this router is better than previous ones, remember its index * and goodness, and start counting how many routers are this good. */ best_support = n_supported[i]; best_support_idx = i; n_best_support=1; @@ -372,7 +372,7 @@ cpath_build_state_t *onion_new_cpath_build_state(void) { router_get_routerlist(&rl); r = new_route_len(options.PathlenCoinWeight, rl->routers, rl->n_routers); - if (r < 0) + if (r < 0) return NULL; exit = choose_good_exit_server(rl); if(!exit) @@ -459,10 +459,10 @@ int onion_extend_cpath(crypt_path_t **head_ptr, cpath_build_state_t *state, rout ++cur_len; } } - if (cur_len >= state->desired_path_len) { - log_fn(LOG_DEBUG, "Path is complete: %d steps long", + if (cur_len >= state->desired_path_len) { + log_fn(LOG_DEBUG, "Path is complete: %d steps long", state->desired_path_len); - return 1; + return 1; } log_fn(LOG_DEBUG, "Path is %d long; we want %d", cur_len, state->desired_path_len); @@ -544,7 +544,7 @@ int onion_extend_cpath(crypt_path_t **head_ptr, cpath_build_state_t *state, rout hop->package_window = CIRCWINDOW_START; hop->deliver_window = CIRCWINDOW_START; - log_fn(LOG_DEBUG, "Extended circuit path with %s for hop %d", + log_fn(LOG_DEBUG, "Extended circuit path with %s for hop %d", choice->nickname, cur_len); *router_out = choice; @@ -600,7 +600,7 @@ onion_skin_create(crypto_pk_env_t *dest_router_key, * of 'challenge' to 0. This means that our symmetric key is really * only 127 bits. */ - challenge[0] &= 0x7f; + challenge[0] &= 0x7f; if (crypto_dh_get_public(dh, challenge+16, dhbytes)) goto err; diff --git a/src/or/or.h b/src/or/or.h index 076d2b907..74929fe78 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -317,7 +317,7 @@ struct connection_t { /* Used only by OR connections: */ tor_tls *tls; - circ_id_t next_circ_id; /* Which circ_id do we try to use next on this connection? + circ_id_t next_circ_id; /* Which circ_id do we try to use next on this connection? * This is always in the range 0..1<<15-1.*/ /* bandwidth and receiver_bucket only used by ORs in OPEN state: */ @@ -337,7 +337,7 @@ struct connection_t { int done_receiving; char has_sent_end; /* for debugging: set once we've set the stream end, and check in circuit_about_to_close_connection() */ - + /* Used only by AP connections */ socks_request_t *socks_request; }; @@ -362,18 +362,18 @@ struct exit_policy_t { typedef struct { char *address; char *nickname; - + uint32_t addr; /* all host order */ uint16_t or_port; uint16_t socks_port; uint16_t dir_port; time_t published_on; - + crypto_pk_env_t *onion_pkey; /* public RSA key for onions */ crypto_pk_env_t *link_pkey; /* public RSA key for TLS */ crypto_pk_env_t *identity_pkey; /* public RSA key for signing */ - + int is_running; /* link info */ @@ -389,7 +389,7 @@ typedef struct { time_t published_on; } routerlist_t; -struct crypt_path_t { +struct crypt_path_t { /* crypto environments */ crypto_cipher_env_t *f_crypto; @@ -735,7 +735,7 @@ void onion_pending_remove(circuit_t *circ); int onionskin_answer(circuit_t *circ, unsigned char *payload, unsigned char *keys); -int onion_extend_cpath(crypt_path_t **head_ptr, cpath_build_state_t *state, +int onion_extend_cpath(crypt_path_t **head_ptr, cpath_build_state_t *state, routerinfo_t **router_out); int onion_skin_create(crypto_pk_env_t *router_key, diff --git a/src/or/router.c b/src/or/router.c index 54e81dc90..af1309c9d 100644 --- a/src/or/router.c +++ b/src/or/router.c @@ -224,7 +224,7 @@ void router_retry_connections(void) { router_get_routerlist(&rl); for (i=0;i<rl->n_routers;i++) { router = rl->routers[i]; - if(!connection_exact_get_by_addr_port(router->addr,router->or_port)) { + if(!connection_exact_get_by_addr_port(router->addr,router->or_port)) { /* not in the list */ log_fn(LOG_DEBUG,"connecting to OR %s:%u.",router->address,router->or_port); connection_or_connect(router); @@ -378,11 +378,11 @@ int router_dump_router_to_string(char *s, int maxlen, routerinfo_t *router, int result=0; struct exit_policy_t *tmpe; #ifdef DEBUG_ROUTER_DUMP_ROUTER_TO_STRING - char *s_tmp, *s_dup; + char *s_tmp, *s_dup; const char *cp; routerinfo_t *ri_tmp; #endif - + get_platform_str(platform, sizeof(platform)); if (crypto_pk_cmp_keys(ident_key, router->identity_pkey)) { @@ -408,8 +408,8 @@ int router_dump_router_to_string(char *s, int maxlen, routerinfo_t *router, return -1; } strftime(published, 32, "%Y-%m-%d %H:%M:%S", gmtime(&router->published_on)); - - result = snprintf(s, maxlen, + + result = snprintf(s, maxlen, "router %s %s %d %d %d %d\n" "platform %s\n" "published %s\n" @@ -493,8 +493,8 @@ int router_dump_router_to_string(char *s, int maxlen, routerinfo_t *router, written += strlen(s+written); strcat(s+written, "-----END SIGNATURE-----\n"); written += strlen(s+written); - - if (written > maxlen-2) + + if (written > maxlen-2) return -1; /* include a last '\n' */ s[written] = '\n'; @@ -504,7 +504,7 @@ int router_dump_router_to_string(char *s, int maxlen, routerinfo_t *router, cp = s_tmp = s_dup = tor_strdup(s); ri_tmp = router_get_entry_from_string(&cp); if (!ri_tmp) { - log_fn(LOG_ERR, "We just generated a router descriptor we can't parse: <<%s>>", + log_fn(LOG_ERR, "We just generated a router descriptor we can't parse: <<%s>>", s); return -1; } diff --git a/src/or/routerlist.c b/src/or/routerlist.c index 84716591c..ba9c33b74 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -75,7 +75,7 @@ router_get_list_from_string_impl(const char **s, routerlist_t **dest, static int router_get_routerlist_from_directory_impl(const char *s, routerlist_t **dest, crypto_pk_env_t *pkey); -static int router_add_exit_policy(routerinfo_t *router, +static int router_add_exit_policy(routerinfo_t *router, directory_token_t *tok); static int router_resolve_routerlist(routerlist_t *dir); @@ -87,7 +87,7 @@ static int router_get_next_token(const char **s, directory_token_t *tok); #else #define router_get_next_token _router_get_next_token #endif -static int router_get_hash_impl(const char *s, char *digest, +static int router_get_hash_impl(const char *s, char *digest, const char *start_str, const char *end_str); static void router_release_token(directory_token_t *tok); @@ -161,7 +161,7 @@ routerinfo_t *router_get_by_addr_port(uint32_t addr, uint16_t port) { return NULL; } -routerinfo_t *router_get_by_link_pk(crypto_pk_env_t *pk) +routerinfo_t *router_get_by_link_pk(crypto_pk_env_t *pk) { int i; routerinfo_t *router; @@ -296,16 +296,16 @@ int router_get_router_hash(const char *s, char *digest) "router ","router-signature"); } -/* return 0 if myversion is in versionlist. Else return -1. (versionlist +/* return 0 if myversion is in versionlist. Else return -1. (versionlist * contains a comma-separated list of versions.) */ -int compare_recommended_versions(const char *myversion, +int compare_recommended_versions(const char *myversion, const char *versionlist) { int len_myversion = strlen(myversion); char *comma; const char *end = versionlist + strlen(versionlist); log_fn(LOG_DEBUG,"checking '%s' in '%s'.", myversion, versionlist); - + for(;;) { comma = strchr(versionlist, ','); if( ((comma ? comma : end) - versionlist == len_myversion) && @@ -356,7 +356,7 @@ router_resolve(routerinfo_t *router) rent = (struct hostent *)gethostbyname(router->address); if (!rent) { log_fn(LOG_WARN,"Could not get address for router %s.",router->address); - return -1; + return -1; } assert(rent->h_length == 4); memcpy(&router->addr, rent->h_addr,rent->h_length); @@ -426,7 +426,7 @@ int router_compare_addr_to_exit_policy(uint32_t addr, uint16_t port, if (tmpe->msk == 0 && (port >= tmpe->prt_min && port <= tmpe->prt_max)) { /* The exit policy is accept/reject *:port */ match = 1; - } else if (port >= tmpe->prt_min && port <= tmpe->prt_max && + } else if (port >= tmpe->prt_min && port <= tmpe->prt_max && tmpe->policy_type == EXIT_POLICY_REJECT) { /* The exit policy is reject ???:port */ maybe_reject = 1; @@ -477,7 +477,6 @@ int router_exit_policy_rejects_all(routerinfo_t *router) { return 0; /* no, might accept some */ } - /* Helper function: parse a directory from 's' and, when done, store the * resulting routerlist in *dest, freeing the old value if necessary. * If pkey is provided, we check the directory signature with pkey. @@ -496,7 +495,7 @@ router_get_routerlist_from_directory_impl(const char *s, routerlist_t **dest, char *good_nickname_lst[1024]; int n_good_nicknames = 0; int i; - + /* Local helper macro: get the next token from s (advancing s) and * bail on failure. */ #define NEXT_TOK() \ @@ -538,7 +537,7 @@ router_get_routerlist_from_directory_impl(const char *s, routerlist_t **dest, if (!strptime(ARGS[0], "%Y-%m-%d %H:%M:%S", &published)) { log_fn(LOG_WARN, "Published time was unparseable"); goto err; } - published_on = tor_timegm(&published); + published_on = tor_timegm(&published); NEXT_TOK(); TOK_IS(K_RECOMMENDED_SOFTWARE, "recommended-software"); @@ -558,7 +557,7 @@ router_get_routerlist_from_directory_impl(const char *s, routerlist_t **dest, /* Read the router list from s, advancing s up past the end of the last * router. */ if (router_get_list_from_string_impl(&s, &new_dir, - n_good_nicknames, + n_good_nicknames, (const char**)good_nickname_lst)) { log_fn(LOG_WARN, "Error reading routers from directory"); goto err; @@ -588,7 +587,7 @@ router_get_routerlist_from_directory_impl(const char *s, routerlist_t **dest, NEXT_TOK(); TOK_IS(_EOF, "end of directory"); - if (*dest) + if (*dest) routerlist_free(*dest); *dest = new_dir; @@ -648,7 +647,7 @@ router_get_list_from_string_impl(const char **s, routerlist_t **dest, log_fn(LOG_WARN, "too many routers"); routerinfo_free(router); continue; - } + } if (n_good_nicknames>=0) { router->is_running = 0; for (i = 0; i < n_good_nicknames; ++i) { @@ -714,7 +713,7 @@ routerinfo_t *router_get_entry_from_string(const char**s) { } router = tor_malloc_zero(sizeof(routerinfo_t)); - router->onion_pkey = router->identity_pkey = router->link_pkey = NULL; + router->onion_pkey = router->identity_pkey = router->link_pkey = NULL; if (N_ARGS != 6) { log_fn(LOG_WARN,"Wrong # of arguments to \"router\""); @@ -725,12 +724,12 @@ routerinfo_t *router_get_entry_from_string(const char**s) { log_fn(LOG_WARN,"Router nickname too long."); goto err; } - if (strspn(router->nickname, LEGAL_NICKNAME_CHARACTERS) != + if (strspn(router->nickname, LEGAL_NICKNAME_CHARACTERS) != strlen(router->nickname)) { log_fn(LOG_WARN, "Router nickname contains illegal characters."); goto err; } - + /* read router.address */ router->address = tor_strdup(ARGS[1]); router->addr = 0; @@ -741,10 +740,10 @@ routerinfo_t *router_get_entry_from_string(const char**s) { log_fn(LOG_WARN,"or_port unreadable or 0. Failing."); goto err; } - + /* Router->socks_port */ router->socks_port = atoi(ARGS[3]); - + /* Router->dir_port */ router->dir_port = atoi(ARGS[4]); @@ -754,9 +753,9 @@ routerinfo_t *router_get_entry_from_string(const char**s) { log_fn(LOG_WARN,"bandwidth unreadable or 0. Failing."); goto err; } - + log_fn(LOG_DEBUG,"or_port %d, socks_port %d, dir_port %d, bandwidth %u.", - router->or_port, router->socks_port, router->dir_port, + router->or_port, router->socks_port, router->dir_port, (unsigned) router->bandwidth); /* XXX Later, require platform before published. */ @@ -764,7 +763,7 @@ routerinfo_t *router_get_entry_from_string(const char**s) { if (tok->tp == K_PLATFORM) { NEXT_TOKEN(); } - + if (tok->tp != K_PUBLISHED) { log_fn(LOG_WARN, "Missing published time"); goto err; } @@ -809,7 +808,7 @@ routerinfo_t *router_get_entry_from_string(const char**s) { router_add_exit_policy(router, tok); NEXT_TOKEN(); } - + if (tok->tp != K_ROUTER_SIGNATURE) { log_fn(LOG_WARN,"Missing router signature"); goto err; @@ -830,12 +829,12 @@ routerinfo_t *router_get_entry_from_string(const char**s) { log_fn(LOG_WARN, "Mismatched signature"); goto err; } - + router_release_token(tok); /* free the signature */ return router; err: - router_release_token(tok); + router_release_token(tok); routerinfo_free(router); return NULL; #undef ARGS @@ -912,7 +911,7 @@ static int router_add_exit_policy(routerinfo_t *router, address = arg; mask = strchr(arg,'/'); port = strchr(mask?mask:arg,':'); - /* Break 'arg' into separate strings. 'arg' was already strdup'd by + /* Break 'arg' into separate strings. 'arg' was already strdup'd by * _router_get_next_token, so it's safe to modify. */ if (mask) @@ -1034,7 +1033,7 @@ static void router_release_token(directory_token_t *tok) { int i; - switch (tok->tp) + switch (tok->tp) { case _SIGNATURE: free(tok->val.signature); @@ -1071,7 +1070,7 @@ _router_get_next_token(const char **s, directory_token_t *tok) { tok->val.error = ""; router_release_token(tok); - + *s = eat_whitespace(*s); if (!**s) { tok->tp = _EOF; @@ -1086,7 +1085,7 @@ _router_get_next_token(const char **s, directory_token_t *tok) { if (!next) { tok->val.error = "No public key end tag found"; return -1; } next = strchr(next, '\n'); /* Part of OR_PUBLICKEY_END_TAG; can't fail.*/ ++next; - if (!(pkey = crypto_new_pk_env(CRYPTO_PK_RSA))) + if (!(pkey = crypto_new_pk_env(CRYPTO_PK_RSA))) return -1; if (crypto_pk_read_public_key_from_string(pkey, *s, next-*s)) { crypto_free_pk_env(pkey); @@ -1100,7 +1099,7 @@ _router_get_next_token(const char **s, directory_token_t *tok) { } else if (! strncmp(*s, OR_SIGNATURE_BEGIN_TAG, next-*s)) { /* We have a -----BEGIN SIGNATURE----- */ /* Advance past newline; can't fail. */ - *s = strchr(*s, '\n'); + *s = strchr(*s, '\n'); ++*s; /* Find end of base64'd data */ next = strstr(*s, OR_SIGNATURE_END_TAG); @@ -1182,10 +1181,10 @@ _router_get_next_token(const char **s, directory_token_t *tok) { } #ifdef DEBUG_ROUTER_TOKENS -static void +static void router_dump_token(directory_token_t *tok) { int i; - switch(tok->tp) + switch(tok->tp) { case _SIGNATURE: puts("(signature)"); @@ -1239,7 +1238,7 @@ router_get_next_token(const char **s, directory_token_t *tok) { * * If no such substring exists, return -1. */ -static int router_get_hash_impl(const char *s, char *digest, +static int router_get_hash_impl(const char *s, char *digest, const char *start_str, const char *end_str) { diff --git a/src/or/test.c b/src/or/test.c index 511cda861..34fe2d692 100644 --- a/src/or/test.c +++ b/src/or/test.c @@ -73,7 +73,7 @@ test_buffers() { } write(s, str, 256); close(s); - + s = open("/tmp/tor_test/data", O_RDONLY, 0); eof = 0; i = read_to_buf(s, 10, buf, &eof); @@ -99,7 +99,7 @@ test_buffers() { test_eq(i, 6); test_memeq(str+10, (char*)_buf_peek_raw_buffer(buf2), 6); buf_free(buf2); - + /* Now test when buffer is filled with more data to read. */ buf2 = buf_new_with_capacity(32); i = read_to_buf(s, 128, buf2, &eof); @@ -126,14 +126,14 @@ test_buffers() { close(s); - /**** + /**** * find_on_inbuf ****/ buf_free(buf); buf = buf_new(); s = open("/tmp/tor_test/data", O_RDONLY, 0); eof = 0; - i = read_to_buf(s, 1024, buf, &eof); + i = read_to_buf(s, 1024, buf, &eof); test_eq(256, i); close(s); @@ -176,7 +176,7 @@ test_buffers() { /* Test when buffer is overfull. */ #if 0 buflen = 18; - test_eq(-1, write_to_buf("This string will not fit.", 25, + test_eq(-1, write_to_buf("This string will not fit.", 25, &buf, &buflen, &buf_datalen)); test_eq(buf_datalen, 16); test_memeq(buf, "Hello worldXYZZY--", 18); @@ -213,7 +213,7 @@ test_crypto_dh() test_memneq(p1, p2, CRYPTO_DH_SIZE); test_assert(! crypto_dh_get_public(dh2, p2, CRYPTO_DH_SIZE)); test_memneq(p1, p2, CRYPTO_DH_SIZE); - + memset(s1, 0, CRYPTO_DH_SIZE); memset(s2, 0xFF, CRYPTO_DH_SIZE); s1len = crypto_dh_compute_secret(dh1, p2, CRYPTO_DH_SIZE, s1, 50); @@ -221,20 +221,20 @@ test_crypto_dh() test_assert(s1len > 0); test_eq(s1len, s2len); test_memeq(s1, s2, s1len); - + crypto_dh_free(dh1); crypto_dh_free(dh2); } -void -test_crypto() +void +test_crypto() { crypto_cipher_env_t *env1, *env2; crypto_pk_env_t *pk1, *pk2; char *data1, *data2, *data3, *cp; FILE *f; int i, j; - int str_ciphers[] = { CRYPTO_CIPHER_IDENTITY, + int str_ciphers[] = { CRYPTO_CIPHER_IDENTITY, CRYPTO_CIPHER_DES, CRYPTO_CIPHER_RC4, CRYPTO_CIPHER_3DES, @@ -251,7 +251,7 @@ test_crypto() crypto_rand(100, data1); crypto_rand(100, data2); test_memneq(data1,data2,100); - + /* Try out identity ciphers. */ env1 = crypto_new_cipher_env(CRYPTO_CIPHER_IDENTITY); test_neq(env1, 0); @@ -261,10 +261,10 @@ test_crypto() for(i = 0; i < 1024; ++i) { data1[i] = (char) i*73; } - crypto_cipher_encrypt(env1, data1, 1024, data2); + crypto_cipher_encrypt(env1, data1, 1024, data2); test_memeq(data1, data2, 1024); crypto_free_cipher_env(env1); - + /* Now, test encryption and decryption with stream ciphers. */ data1[0]='\0'; for(i = 1023; i>0; i -= 35) @@ -335,7 +335,7 @@ test_crypto() crypto_free_cipher_env(env1); crypto_free_cipher_env(env2); } - + /* Test vectors for stream ciphers. */ /* XXXX Look up some test vectors for the ciphers and make sure we match. */ @@ -356,7 +356,7 @@ test_crypto() test_eq(128, crypto_pk_keysize(pk1)); test_eq(128, crypto_pk_keysize(pk2)); - + test_eq(128, crypto_pk_public_encrypt(pk2, "Hello whirled.", 15, data1, RSA_PKCS1_OAEP_PADDING)); test_eq(128, crypto_pk_public_encrypt(pk1, "Hello whirled.", 15, data2, @@ -377,7 +377,7 @@ test_crypto() memcpy(data2+1, "XYZZY", 5); /* This has fails ~ once-in-2^40 */ test_eq(-1, crypto_pk_private_decrypt(pk1, data2, 128, data3, RSA_PKCS1_OAEP_PADDING)); - + /* File operations: save and load private key */ f = fopen("/tmp/tor_test/pkey1", "wb"); test_assert(! crypto_pk_write_private_key_to_file(pk1, f)); @@ -387,7 +387,7 @@ test_crypto() fclose(f); test_eq(15, crypto_pk_private_decrypt(pk2, data1, 128, data3, RSA_PKCS1_OAEP_PADDING)); - test_assert(! crypto_pk_read_private_key_from_filename(pk2, + test_assert(! crypto_pk_read_private_key_from_filename(pk2, "/tmp/tor_test/pkey1")); test_eq(15, crypto_pk_private_decrypt(pk2, data1, 128, data3, RSA_PKCS1_OAEP_PADDING)); @@ -398,9 +398,9 @@ test_crypto() test_eq(10, crypto_pk_public_checksig(pk1, data2, 128, data3)); test_streq(data3, "Ossifrage"); /*XXXX test failed signing*/ - - crypto_free_pk_env(pk1); - crypto_free_pk_env(pk2); + + crypto_free_pk_env(pk1); + crypto_free_pk_env(pk2); /* Base64 tests */ strcpy(data1, "Test string that contains 35 chars."); @@ -419,7 +419,7 @@ test_crypto() } -void +void test_util() { struct timeval start, end; struct tm a_time; @@ -470,7 +470,7 @@ void test_onion() { int i,num; names = parse_nickname_list(" foo bar baz quux ", &num); - test_eq(num,4); + test_eq(num,4); test_streq(names[0],"foo"); test_streq(names[1],"bar"); test_streq(names[2],"baz"); @@ -491,7 +491,7 @@ test_onion_handshake() { /* server-side */ char s_buf[ONIONSKIN_REPLY_LEN]; char s_keys[40]; - + /* shared */ crypto_pk_env_t *pk = NULL; @@ -506,11 +506,11 @@ test_onion_handshake() { memset(s_buf, 0, ONIONSKIN_REPLY_LEN); memset(s_keys, 0, 40); test_assert(! onion_skin_server_handshake(c_buf, pk, s_buf, s_keys, 40)); - + /* client handshake 2 */ memset(c_keys, 0, 40); test_assert(! onion_skin_client_handshake(c_dh, s_buf, c_keys, 40)); - + crypto_dh_free(c_dh); if (memcmp(c_keys, s_keys, 40)) { @@ -544,7 +544,7 @@ test_dir_format() test_assert(! crypto_pk_generate_key(pk1)); test_assert(! crypto_pk_generate_key(pk2)); test_assert(! crypto_pk_generate_key(pk3)); - + r1.address = "testaddr1.foo.bar"; r1.addr = 0xc0a80001u; /* 192.168.0.1 */ r1.published_on = 0; @@ -581,16 +581,16 @@ test_dir_format() r2.bandwidth = 3000; r2.exit_policy = &ex1; - test_assert(!crypto_pk_write_public_key_to_string(pk1, &pk1_str, + test_assert(!crypto_pk_write_public_key_to_string(pk1, &pk1_str, &pk1_str_len)); - test_assert(!crypto_pk_write_public_key_to_string(pk2 , &pk2_str, + test_assert(!crypto_pk_write_public_key_to_string(pk2 , &pk2_str, &pk2_str_len)); - test_assert(!crypto_pk_write_public_key_to_string(pk3 , &pk3_str, + test_assert(!crypto_pk_write_public_key_to_string(pk3 , &pk3_str, &pk3_str_len)); memset(buf, 0, 2048); test_assert(router_dump_router_to_string(buf, 2048, &r1, pk2)>0); - + strcpy(buf2, "router Magri testaddr1.foo.bar 9000 9002 9003 1000\n" "platform Tor "VERSION" on "); strcat(buf2, get_uname()); @@ -604,9 +604,9 @@ test_dir_format() strcat(buf2, pk2_str); strcat(buf2, "router-signature\n"); buf[strlen(buf2)] = '\0'; /* Don't compare the sig; it's never the same twice*/ - + test_streq(buf, buf2); - + test_assert(router_dump_router_to_string(buf, 2048, &r1, pk2)>0); cp = buf; rp1 = router_get_entry_from_string((const char**)&cp); @@ -621,7 +621,7 @@ test_dir_format() test_assert(crypto_pk_cmp_keys(rp1->identity_pkey, pk2) == 0); test_assert(rp1->exit_policy == NULL); -#if 0 +#if 0 /* XXX Once we have exit policies, test this again. XXX */ strcpy(buf2, "router tor.tor.tor 9005 0 0 3000\n"); strcat(buf2, pk2_str); @@ -652,7 +652,7 @@ test_dir_format() test_assert(rp2->exit_policy->next->next == NULL); #endif -#if 0 +#if 0 /* XXX To re-enable this test, we need to separate directory generation * XXX from the directory backend again. Do this the next time we have * XXX directory trouble. */ @@ -664,11 +664,11 @@ test_dir_format() dir1->routers[1] = &r2; test_assert(! dump_signed_directory_to_string_impl(buf, 4096, dir1, pk1)); /* puts(buf); */ - + test_assert(! router_get_dir_from_string_impl(buf, &dir2, pk1)); test_eq(2, dir2->n_routers); #endif - + tor_free(pk1_str); tor_free(pk2_str); if (pk1) crypto_free_pk_env(pk1); @@ -689,8 +689,8 @@ test_dir_format() test_eq(-1, compare_recommended_versions("a", "")); } -int -main(int c, char**v){ +int +main(int c, char**v){ #if 0 or_options_t options; /* command-line and config-file options */ diff --git a/src/or/tor_main.c b/src/or/tor_main.c index 32f9b1d9d..28af14147 100644 --- a/src/or/tor_main.c +++ b/src/or/tor_main.c @@ -4,7 +4,7 @@ int tor_main(int argc, char *argv[]); -int main(int argc, char *argv[]) +int main(int argc, char *argv[]) { return tor_main(argc, argv); } |