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

[or-cvs] clean up exported api"s



Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/or

Modified Files:
	circuit.c command.c connection.c connection_edge.c 
	connection_or.c directory.c onion.c or.h routers.c 
Log Message:
clean up exported api's


Index: circuit.c
===================================================================
RCS file: /home/or/cvsroot/src/or/circuit.c,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -d -r1.60 -r1.61
--- circuit.c	14 Sep 2003 08:17:13 -0000	1.60
+++ circuit.c	16 Sep 2003 05:41:49 -0000	1.61
@@ -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 @@
   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 @@
   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 @@
 }
 
 /* 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;
 

Index: command.c
===================================================================
RCS file: /home/or/cvsroot/src/or/command.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- command.c	20 Aug 2003 23:05:22 -0000	1.36
+++ command.c	16 Sep 2003 05:41:49 -0000	1.37
@@ -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_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 @@
   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_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_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);

Index: connection.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection.c,v
retrieving revision 1.92
retrieving revision 1.93
diff -u -d -r1.92 -r1.93
--- connection.c	16 Sep 2003 01:58:46 -0000	1.92
+++ connection.c	16 Sep 2003 05:41:49 -0000	1.93
@@ -765,26 +765,6 @@
   }
 }
 
-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

Index: connection_edge.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection_edge.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- connection_edge.c	16 Sep 2003 01:58:46 -0000	1.20
+++ connection_edge.c	16 Sep 2003 05:41:49 -0000	1.21
@@ -535,7 +535,7 @@
   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 @@
   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);

Index: connection_or.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection_or.c,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -d -r1.49 -r1.50
--- connection_or.c	16 Sep 2003 01:58:46 -0000	1.49
+++ connection_or.c	16 Sep 2003 05:41:49 -0000	1.50
@@ -20,11 +20,25 @@
 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 @@
   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 @@
 
 static void 
 conn_or_init_crypto(connection_t *conn) {
-  //int x;
   unsigned char iv[16];
 
   assert(conn);
@@ -718,21 +725,9 @@
   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 @@
     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;

Index: directory.c
===================================================================
RCS file: /home/or/cvsroot/src/or/directory.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- directory.c	16 Sep 2003 01:58:46 -0000	1.24
+++ directory.c	16 Sep 2003 05:41:49 -0000	1.25
@@ -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 @@
   }
 }
 
-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 @@
   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 @@
   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 @@
   return 0;
 }
 
-int directory_handle_reading(connection_t *conn) {
+static int directory_handle_reading(connection_t *conn) {
   int amt;
   char *headers;
 

Index: onion.c
===================================================================
RCS file: /home/or/cvsroot/src/or/onion.c,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -d -r1.63 -r1.64
--- onion.c	14 Sep 2003 08:17:14 -0000	1.63
+++ onion.c	16 Sep 2003 05:41:49 -0000	1.64
@@ -155,8 +155,7 @@
 }
 
 /* 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 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;

Index: or.h
===================================================================
RCS file: /home/or/cvsroot/src/or/or.h,v
retrieving revision 1.125
retrieving revision 1.126
diff -u -d -r1.125 -r1.126
--- or.h	16 Sep 2003 01:58:46 -0000	1.125
+++ or.h	16 Sep 2003 05:41:49 -0000	1.126
@@ -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 @@
 /********************************* 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 @@
 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 @@
 
 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 @@
 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_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_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 @@
 /********************************* 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 @@
 
 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 @@
 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);

Index: routers.c
===================================================================
RCS file: /home/or/cvsroot/src/or/routers.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- routers.c	13 Sep 2003 21:53:38 -0000	1.46
+++ routers.c	16 Sep 2003 05:41:49 -0000	1.47
@@ -34,6 +34,8 @@
                                            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 @@
 #undef TOK_IS
 }
 
-
 static int router_get_list_from_string_tok(char **s, directory_t **dest,
                                            directory_token_t *tok)
 {
@@ -702,7 +703,7 @@
   return 0;
 }
 
-int 
+static int 
 router_resolve(routerinfo_t *router)
 {
   struct hostent *rent;
@@ -719,7 +720,7 @@
   return 0;
 }
 
-int 
+static int 
 router_resolve_directory(directory_t *dir)
 {
   int i, max, remove;