or.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  1. /* Copyright 2001,2002 Roger Dingledine, Matej Pfajfar. */
  2. /* See LICENSE for licensing information */
  3. /* $Id$ */
  4. #ifndef __OR_H
  5. #define __OR_H
  6. #include "orconfig.h"
  7. #undef VERSION
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <limits.h>
  11. #include <unistd.h>
  12. #include <string.h>
  13. #include <signal.h>
  14. #include <netdb.h>
  15. #include <ctype.h>
  16. #ifdef HAVE_STDINT_H
  17. #include <stdint.h>
  18. #endif
  19. #ifdef HAVE_SYS_POLL_H
  20. #include <sys/poll.h>
  21. #elif HAVE_POLL_H
  22. #include <poll.h>
  23. #else
  24. #include "../common/fakepoll.h"
  25. #endif
  26. #include <sys/types.h>
  27. #include <sys/fcntl.h>
  28. #include <sys/ioctl.h>
  29. #include <sys/socket.h>
  30. #include <sys/time.h>
  31. #include <netinet/in.h>
  32. #include <arpa/inet.h>
  33. #include <errno.h>
  34. #include <assert.h>
  35. #include <time.h>
  36. #include "../common/config.h"
  37. #include "../common/crypto.h"
  38. #include "../common/log.h"
  39. #include "../common/ss.h"
  40. #include "../common/version.h"
  41. #define MAXCONNECTIONS 200 /* upper bound on max connections.
  42. can be overridden by config file */
  43. #define MAX_BUF_SIZE (640*1024)
  44. #define DEFAULT_BANDWIDTH_OP 1024
  45. #define ACI_TYPE_LOWER 0
  46. #define ACI_TYPE_HIGHER 1
  47. #define ACI_TYPE_BOTH 2
  48. /* bitvector of the roles that we might want to play. You can or (|) them together */
  49. #define ROLE_OR_LISTEN 1
  50. #define ROLE_OR_CONNECT_ALL 2
  51. #define ROLE_OP_LISTEN 4
  52. #define ROLE_AP_LISTEN 8
  53. #define ROLE_IS_OR(role) ((role & ROLE_OR_LISTEN) || (role & ROLE_OR_CONNECT_ALL) || (role & ROLE_OP_LISTEN))
  54. #define CONN_TYPE_OP_LISTENER 1
  55. #define CONN_TYPE_OP 2
  56. #define CONN_TYPE_OR_LISTENER 3
  57. #define CONN_TYPE_OR 4
  58. #define CONN_TYPE_EXIT 5
  59. #define CONN_TYPE_AP_LISTENER 6
  60. #define CONN_TYPE_AP 7
  61. #define LISTENER_STATE_READY 0
  62. #define OP_CONN_STATE_AWAITING_KEYS 0
  63. #define OP_CONN_STATE_OPEN 1
  64. #if 0
  65. #define OP_CONN_STATE_CLOSE 2 /* flushing the buffer, then will close */
  66. #define OP_CONN_STATE_CLOSE_WAIT 3 /* have sent a destroy, awaiting a confirmation */
  67. #endif
  68. /* how to read these states:
  69. * foo_CONN_STATE_bar_baz:
  70. * "I am acting as a bar, currently in stage baz of talking with a foo."
  71. */
  72. #define OR_CONN_STATE_OP_CONNECTING 0 /* an application proxy wants me to connect to this OR */
  73. #define OR_CONN_STATE_OP_SENDING_KEYS 1
  74. #define OR_CONN_STATE_CLIENT_CONNECTING 2 /* I'm connecting to this OR as an OR */
  75. #define OR_CONN_STATE_CLIENT_SENDING_AUTH 3 /* sending address and info */
  76. #define OR_CONN_STATE_CLIENT_AUTH_WAIT 4 /* have sent address and info, waiting */
  77. #define OR_CONN_STATE_CLIENT_SENDING_NONCE 5 /* sending nonce, last piece of handshake */
  78. #define OR_CONN_STATE_SERVER_AUTH_WAIT 6 /* waiting for address and info */
  79. #define OR_CONN_STATE_SERVER_SENDING_AUTH 7 /* writing auth and nonce */
  80. #define OR_CONN_STATE_SERVER_NONCE_WAIT 8 /* waiting for confirmation of nonce */
  81. #define OR_CONN_STATE_OPEN 9 /* ready to send/receive cells. */
  82. #define EXIT_CONN_STATE_CONNECTING_WAIT 0 /* waiting for standard structure or dest info */
  83. #define EXIT_CONN_STATE_CONNECTING 1
  84. #define EXIT_CONN_STATE_OPEN 2
  85. #if 0
  86. #define EXIT_CONN_STATE_CLOSE 3 /* flushing the buffer, then will close */
  87. #define EXIT_CONN_STATE_CLOSE_WAIT 4 /* have sent a destroy, awaiting a confirmation */
  88. #endif
  89. #define AP_CONN_STATE_SS_WAIT 0
  90. #define AP_CONN_STATE_OR_WAIT 1
  91. #define AP_CONN_STATE_OPEN 2
  92. #define CIRCUIT_STATE_OPEN_WAIT 0 /* receiving/processing the onion */
  93. #define CIRCUIT_STATE_OR_WAIT 1 /* I'm at the beginning of the path, my firsthop is still connecting */
  94. #define CIRCUIT_STATE_OPEN 2 /* onion processed, ready to send data along the connection */
  95. #define CIRCUIT_STATE_CLOSE_WAIT1 3 /* sent two "destroy" signals, waiting for acks */
  96. #define CIRCUIT_STATE_CLOSE_WAIT2 4 /* received one ack, waiting for one more
  97. (or if just one was sent, waiting for that one */
  98. //#define CIRCUIT_STATE_CLOSE 4 /* both acks received, connection is dead */ /* NOT USED */
  99. /* available cipher functions */
  100. #define ONION_CIPHER_IDENTITY 0
  101. #define ONION_CIPHER_DES 1
  102. #define ONION_CIPHER_RC4 2
  103. /* default cipher function */
  104. #define ONION_DEFAULT_CIPHER ONION_CIPHER_DES
  105. #define RECEIVE_WINDOW_START 100
  106. #define RECEIVE_WINDOW_INCREMENT 10
  107. /* cell commands */
  108. #define CELL_PADDING 0
  109. #define CELL_CREATE 1
  110. #define CELL_DATA 2
  111. #define CELL_DESTROY 3
  112. #define CELL_ACK 4
  113. #define CELL_NACK 5
  114. #define CELL_SENDME 6
  115. #define CELL_CONNECTED 7
  116. #define CELL_PAYLOAD_SIZE 120
  117. typedef uint16_t aci_t;
  118. /* cell definition */
  119. typedef struct
  120. {
  121. aci_t aci; /* Anonymous Connection Identifier */
  122. unsigned char command;
  123. unsigned char length; /* of payload if data cell, else value of sendme */
  124. uint32_t seq; /* sequence number */
  125. unsigned char payload[120];
  126. } cell_t;
  127. typedef struct
  128. {
  129. /* Used by all types: */
  130. unsigned char type;
  131. int state;
  132. int s; /* our socket */
  133. int poll_index;
  134. int marked_for_close;
  135. char *inbuf;
  136. int inbuflen;
  137. int inbuf_datalen;
  138. int inbuf_reached_eof;
  139. char *outbuf;
  140. int outbuflen; /* how many bytes are allocated for the outbuf? */
  141. int outbuf_flushlen; /* how much data should we try to flush from the outbuf? */
  142. int outbuf_datalen; /* how much data is there total on the outbuf? */
  143. // uint16_t aci; /* anonymous connection identifier */
  144. /* used by OR and OP: */
  145. uint32_t bandwidth; /* connection bandwidth */
  146. int receiver_bucket; /* when this hits 0, stop receiving. Every second we
  147. * add 'bandwidth' to this, capping it at 10*bandwidth.
  148. */
  149. struct timeval send_timeval; /* for determining when to send the next cell */
  150. /* link encryption */
  151. crypto_cipher_env_t *f_crypto;
  152. crypto_cipher_env_t *b_crypto;
  153. // struct timeval lastsend; /* time of last transmission to the client */
  154. // struct timeval interval; /* transmission interval */
  155. uint32_t addr; /* these two uniquely identify a router */
  156. uint16_t port;
  157. /* used by exit and ap: */
  158. ss_t ss; /* standard structure */
  159. int ss_received; /* size of ss, received so far */
  160. char *dest_addr, *dest_port;
  161. uint16_t dest_addr_len, dest_port_len;
  162. uint16_t dest_addr_received, dest_port_received;
  163. /* used by OR, to keep state while connect()ing: Kludge. */
  164. crypto_pk_env_t *prkey;
  165. struct sockaddr_in local;
  166. #if 0 /* obsolete, we now use conn->bandwidth */
  167. /* link info */
  168. uint32_t min;
  169. uint32_t max;
  170. #endif
  171. char *address; /* strdup into this, because free_connection frees it */
  172. crypto_pk_env_t *pkey; /* public RSA key for the other side */
  173. char nonce[8];
  174. } connection_t;
  175. /* config stuff we know about the other ORs in the network */
  176. typedef struct
  177. {
  178. char *address;
  179. uint32_t addr;
  180. uint16_t or_port;
  181. uint16_t op_port;
  182. uint16_t ap_port;
  183. crypto_pk_env_t *pkey; /* public RSA key */
  184. /* link info */
  185. uint32_t min;
  186. uint32_t max;
  187. // struct timeval min_interval;
  188. /* time when last data was sent to that router */
  189. // struct timeval lastsend;
  190. /* socket */
  191. // int s;
  192. void *next;
  193. } routerinfo_t;
  194. typedef struct
  195. {
  196. unsigned int forwf;
  197. unsigned int backf;
  198. char digest2[20]; /* second SHA output for onion_layer_t.keyseed */
  199. char digest3[20]; /* third SHA output for onion_layer_t.keyseed */
  200. /* crypto environments */
  201. crypto_cipher_env_t *f_crypto;
  202. crypto_cipher_env_t *b_crypto;
  203. } crypt_path_t;
  204. /* per-anonymous-connection struct */
  205. typedef struct
  206. {
  207. #if 0
  208. uint32_t p_addr; /* all in network order */
  209. uint16_t p_port;
  210. #endif
  211. uint32_t n_addr;
  212. uint16_t n_port;
  213. connection_t *p_conn;
  214. connection_t *n_conn;
  215. int n_receive_window;
  216. int p_receive_window;
  217. aci_t p_aci; /* connection identifiers */
  218. aci_t n_aci;
  219. unsigned char p_f; /* crypto functions */
  220. unsigned char n_f;
  221. crypto_cipher_env_t *p_crypto; /* crypto environments */
  222. crypto_cipher_env_t *n_crypto;
  223. crypt_path_t **cpath;
  224. int cpathlen;
  225. uint32_t expire; /* expiration time for the corresponding onion */
  226. int state;
  227. unsigned char *onion; /* stores the onion when state is CONN_STATE_OPEN_WAIT */
  228. uint32_t onionlen; /* total onion length */
  229. uint32_t recvlen; /* length of the onion so far */
  230. void *next;
  231. } circuit_t;
  232. typedef struct
  233. {
  234. int zero:1;
  235. int version:7;
  236. int backf:4;
  237. int forwf:4;
  238. uint16_t port;
  239. uint32_t addr;
  240. time_t expire;
  241. unsigned char keyseed[16];
  242. } onion_layer_t;
  243. typedef struct
  244. {
  245. time_t expire;
  246. char digest[20]; /* SHA digest of the onion */
  247. void *prev;
  248. void *next;
  249. } tracked_onion_t;
  250. typedef struct
  251. {
  252. char *LogLevel;
  253. char *RouterFile;
  254. char *PrivateKeyFile;
  255. float CoinWeight;
  256. int ORPort;
  257. int OPPort;
  258. int APPort;
  259. int MaxConn;
  260. int TrafficShaping;
  261. int LinkPadding;
  262. int Role;
  263. int loglevel;
  264. } or_options_t;
  265. /* all the function prototypes go here */
  266. /********************************* buffers.c ***************************/
  267. int buf_new(char **buf, int *buflen, int *buf_datalen);
  268. void buf_free(char *buf);
  269. int read_to_buf(int s, int at_most, char **buf, int *buflen, int *buf_datalen, int *reached_eof);
  270. /* grab from s, put onto buf, return how many bytes read */
  271. int flush_buf(int s, char **buf, int *buflen, int *buf_flushlen, int *buf_datalen);
  272. /* push from buf onto s
  273. * then memmove to front of buf
  274. * return -1 or how many bytes remain on the buf */
  275. int write_to_buf(char *string, int string_len,
  276. char **buf, int *buflen, int *buf_datalen);
  277. /* append string to buf (growing as needed, return -1 if "too big")
  278. * return total number of bytes on the buf
  279. */
  280. int fetch_from_buf(char *string, int string_len,
  281. char **buf, int *buflen, int *buf_datalen);
  282. /* if there is string_len bytes in buf, write them onto string,
  283. * * then memmove buf back (that is, remove them from buf) */
  284. /********************************* cell.c ***************************/
  285. int pack_create(uint16_t aci, unsigned char *onion, uint32_t onionlen, unsigned char **cellbuf, unsigned int *cellbuflen);
  286. /********************************* circuit.c ***************************/
  287. void circuit_add(circuit_t *circ);
  288. void circuit_remove(circuit_t *circ);
  289. circuit_t *circuit_new(aci_t p_aci, connection_t *p_conn);
  290. /* internal */
  291. aci_t get_unique_aci_by_addr_port(uint32_t addr, uint16_t port, int aci_type);
  292. circuit_t *circuit_get_by_aci_conn(aci_t aci, connection_t *conn);
  293. circuit_t *circuit_get_by_conn(connection_t *conn);
  294. circuit_t *circuit_get_by_naddr_nport(uint32_t naddr, uint16_t nport);
  295. int circuit_deliver_data_cell(cell_t *cell, circuit_t *circ, connection_t *conn, int crypt_type);
  296. int circuit_crypt(circuit_t *circ, char *in, int inlen, char crypt_type);
  297. int circuit_init(circuit_t *circ, int aci_type);
  298. void circuit_free(circuit_t *circ);
  299. void circuit_free_cpath(crypt_path_t **cpath, int cpathlen);
  300. void circuit_close(circuit_t *circ);
  301. void circuit_about_to_close_connection(connection_t *conn);
  302. /* flush and send destroys for all circuits using conn */
  303. /********************************* command.c ***************************/
  304. void command_process_cell(cell_t *cell, connection_t *conn);
  305. void command_process_create_cell(cell_t *cell, connection_t *conn);
  306. void command_process_sendme_cell(cell_t *cell, connection_t *conn);
  307. void command_process_data_cell(cell_t *cell, connection_t *conn);
  308. void command_process_destroy_cell(cell_t *cell, connection_t *conn);
  309. void command_process_connected_cell(cell_t *cell, connection_t *conn);
  310. /********************************* config.c ***************************/
  311. /* loads the configuration file */
  312. int getconfig(char *filename, config_opt_t *options);
  313. /* create or_options_t from command-line args and config files(s) */
  314. int getoptions(int argc, char **argv, or_options_t *options);
  315. /********************************* connection.c ***************************/
  316. int tv_cmp(struct timeval *a, struct timeval *b);
  317. connection_t *connection_new(int type);
  318. void connection_free(connection_t *conn);
  319. int connection_create_listener(crypto_pk_env_t *prkey, struct sockaddr_in *local, int type);
  320. int connection_handle_listener_read(connection_t *conn, int new_type, int new_state);
  321. /* start all connections that should be up but aren't */
  322. int retry_all_connections(int role, routerinfo_t **router_array, int rarray_len,
  323. crypto_pk_env_t *prkey, uint16_t or_port, uint16_t op_port, uint16_t ap_port);
  324. connection_t *connection_connect_to_router_as_op(routerinfo_t *router, uint16_t local_or_port);
  325. int connection_read_to_buf(connection_t *conn);
  326. int connection_fetch_from_buf(char *string, int len, connection_t *conn);
  327. int connection_outbuf_too_full(connection_t *conn);
  328. int connection_wants_to_flush(connection_t *conn);
  329. int connection_flush_buf(connection_t *conn);
  330. int connection_write_to_buf(char *string, int len, connection_t *conn);
  331. void connection_send_cell(connection_t *conn);
  332. int connection_receiver_bucket_should_increase(connection_t *conn);
  333. void connection_increment_receiver_bucket (connection_t *conn);
  334. void connection_increment_send_timeval(connection_t *conn);
  335. void connection_init_timeval(connection_t *conn);
  336. int connection_speaks_cells(connection_t *conn);
  337. int connection_state_is_open(connection_t *conn);
  338. int connection_send_destroy(aci_t aci, connection_t *conn);
  339. int connection_send_connected(aci_t aci, connection_t *conn);
  340. int connection_encrypt_cell(cell_t *cellp, connection_t *conn);
  341. int connection_write_cell_to_buf(cell_t *cellp, connection_t *conn);
  342. int connection_process_inbuf(connection_t *conn);
  343. int connection_package_raw_inbuf(connection_t *conn);
  344. int connection_process_cell_from_inbuf(connection_t *conn);
  345. int connection_consider_sending_sendme(connection_t *conn);
  346. int connection_finished_flushing(connection_t *conn);
  347. /********************************* connection_ap.c ****************************/
  348. int connection_ap_process_inbuf(connection_t *conn);
  349. int ap_handshake_process_ss(connection_t *conn);
  350. int ap_handshake_create_onion(connection_t *conn);
  351. int ap_handshake_establish_circuit(connection_t *conn, unsigned int *route, int routelen, char *onion,
  352. int onionlen, crypt_path_t **cpath);
  353. /* find the circ that's waiting on me, if any, and get it to send its onion */
  354. int ap_handshake_n_conn_open(connection_t *or_conn);
  355. int ap_handshake_send_onion(connection_t *ap_conn, connection_t *or_conn, circuit_t *circ);
  356. int connection_ap_send_connected(connection_t *conn);
  357. int connection_ap_process_data_cell(cell_t *cell, connection_t *conn);
  358. int connection_ap_finished_flushing(connection_t *conn);
  359. int connection_ap_create_listener(crypto_pk_env_t *prkey, struct sockaddr_in *local);
  360. int connection_ap_handle_listener_read(connection_t *conn);
  361. /********************************* connection_exit.c ***************************/
  362. int connection_exit_process_inbuf(connection_t *conn);
  363. int connection_exit_package_inbuf(connection_t *conn);
  364. int connection_exit_send_connected(connection_t *conn);
  365. int connection_exit_process_data_cell(cell_t *cell, connection_t *conn);
  366. int connection_exit_finished_flushing(connection_t *conn);
  367. /********************************* connection_op.c ***************************/
  368. int op_handshake_process_keys(connection_t *conn);
  369. int connection_op_process_inbuf(connection_t *conn);
  370. int connection_op_finished_flushing(connection_t *conn);
  371. int connection_op_create_listener(crypto_pk_env_t *prkey, struct sockaddr_in *local);
  372. int connection_op_handle_listener_read(connection_t *conn);
  373. /********************************* connection_or.c ***************************/
  374. int connection_or_process_inbuf(connection_t *conn);
  375. int connection_or_finished_flushing(connection_t *conn);
  376. void conn_or_init_crypto(connection_t *conn);
  377. int or_handshake_op_send_keys(connection_t *conn);
  378. int or_handshake_op_finished_sending_keys(connection_t *conn);
  379. int or_handshake_client_process_auth(connection_t *conn);
  380. int or_handshake_client_send_auth(connection_t *conn);
  381. int or_handshake_server_process_auth(connection_t *conn);
  382. int or_handshake_server_process_nonce(connection_t *conn);
  383. connection_t *connect_to_router_as_or(routerinfo_t *router, crypto_pk_env_t *prkey, struct sockaddr_in *local);
  384. connection_t *connection_or_connect_as_or(routerinfo_t *router, crypto_pk_env_t *prkey, struct sockaddr_in *local);
  385. connection_t *connection_or_connect_as_op(routerinfo_t *router, struct sockaddr_in *local);
  386. int connection_or_create_listener(crypto_pk_env_t *prkey, struct sockaddr_in *local);
  387. int connection_or_handle_listener_read(connection_t *conn);
  388. /********************************* main.c ***************************/
  389. int connection_add(connection_t *conn);
  390. int connection_remove(connection_t *conn);
  391. void connection_set_poll_socket(connection_t *conn);
  392. int pkey_cmp(crypto_pk_env_t *a, crypto_pk_env_t *b);
  393. connection_t *connection_twin_get_by_addr_port(uint32_t addr, uint16_t port);
  394. connection_t *connection_exact_get_by_addr_port(uint32_t addr, uint16_t port);
  395. connection_t *connection_get_by_type(int type);
  396. routerinfo_t *router_get_by_addr_port(uint32_t addr, uint16_t port);
  397. unsigned int *router_new_route(int *routelen);
  398. unsigned char *router_create_onion(unsigned int *route, int routelen, int *len, crypt_path_t **cpath);
  399. routerinfo_t *router_get_first_in_route(unsigned int *route, int routelen);
  400. connection_t *connect_to_router_as_op(routerinfo_t *router);
  401. void connection_watch_events(connection_t *conn, short events);
  402. void connection_stop_reading(connection_t *conn);
  403. void connection_start_reading(connection_t *conn);
  404. void connection_stop_writing(connection_t *conn);
  405. void connection_start_writing(connection_t *conn);
  406. void check_conn_read(int i);
  407. void check_conn_marked(int i);
  408. void check_conn_write(int i);
  409. int prepare_for_poll(int *timeout);
  410. int do_main_loop(void);
  411. int main(int argc, char *argv[]);
  412. /********************************* onion.c ***************************/
  413. int decide_aci_type(uint32_t local_addr, uint16_t local_port,
  414. uint32_t remote_addr, uint16_t remote_port);
  415. int process_onion(circuit_t *circ, connection_t *conn);
  416. /* uses a weighted coin with weight cw to choose a route length */
  417. int chooselen(double cw);
  418. /* returns an array of pointers to routent that define a new route through the OR network
  419. * int cw is the coin weight to use when choosing the route
  420. * order of routers is from last to first
  421. */
  422. unsigned int *new_route(double cw, routerinfo_t **rarray, int rarray_len, int *routelen);
  423. /* creates a new onion from route, stores it and its length into bufp and lenp respectively */
  424. unsigned char *create_onion(routerinfo_t **rarray, int rarray_len, unsigned int *route, int routelen, int *len, crypt_path_t **cpath);
  425. /* encrypts 128 bytes of the onion with the specified public key, the rest with
  426. * DES OFB with the key as defined in the outter layer */
  427. unsigned char *encrypt_onion(onion_layer_t *onion, uint32_t onionlen, crypto_pk_env_t *pkey);
  428. /* decrypts the first 128 bytes using RSA and prkey, decrypts the rest with DES OFB with key1 */
  429. unsigned char *decrypt_onion(onion_layer_t *onion, uint32_t onionlen, crypto_pk_env_t *prkey);
  430. /* delete first n bytes of the onion and pads the end with n bytes of random data */
  431. void pad_onion(unsigned char *onion, uint32_t onionlen, int n);
  432. /* create a new tracked_onion entry */
  433. tracked_onion_t *new_tracked_onion(unsigned char *onion, uint32_t onionlen, tracked_onion_t **tracked_onions, tracked_onion_t **last_tracked_onion);
  434. /* delete a tracked onion entry */
  435. void remove_tracked_onion(tracked_onion_t *to, tracked_onion_t **tracked_onions, tracked_onion_t **last_tracked_onion);
  436. /* find a tracked onion in the linked list of tracked onions */
  437. tracked_onion_t *id_tracked_onion(unsigned char *onion, uint32_t onionlen, tracked_onion_t *tracked_onions);
  438. /********************************* routers.c ***************************/
  439. routerinfo_t **getrouters(char *routerfile, int *listlenp, uint16_t or_listenport);
  440. void delete_routerlist(routerinfo_t *list);
  441. /* create an NULL-terminated array of pointers pointing to elements of a router list */
  442. routerinfo_t **make_rarray(routerinfo_t* list, int *len);
  443. #endif