or.h 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084
  1. /* Copyright 2001,2002,2003 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. #ifdef MS_WINDOWS
  8. #define WIN32_WINNT 0x400
  9. #define _WIN32_WINNT 0x400
  10. #define WIN32_LEAN_AND_MEAN
  11. /* Number of fds that select will accept; default is 64. */
  12. #define FD_SETSIZE 512
  13. #endif
  14. #include <stdio.h>
  15. #include <stdlib.h>
  16. #include <limits.h>
  17. #ifdef HAVE_UNISTD_H
  18. #include <unistd.h>
  19. #endif
  20. #ifdef HAVE_STRING_H
  21. #include <string.h>
  22. #endif
  23. #ifdef HAVE_SIGNAL_H
  24. #include <signal.h>
  25. #endif
  26. #ifdef HAVE_NETDB_H
  27. #include <netdb.h>
  28. #endif
  29. #ifdef HAVE_CTYPE_H
  30. #include <ctype.h>
  31. #endif
  32. #include "../common/torint.h"
  33. #include "../common/fakepoll.h"
  34. #ifdef HAVE_SYS_TYPES_H
  35. #include <sys/types.h> /* Must be included before sys/stat.h for Ultrix */
  36. #endif
  37. #ifdef HAVE_SYS_WAIT_H
  38. #include <sys/wait.h>
  39. #endif
  40. #ifdef HAVE_SYS_FCNTL_H
  41. #include <sys/fcntl.h>
  42. #endif
  43. #ifdef HAVE_FCNTL_H
  44. #include <fcntl.h>
  45. #endif
  46. #ifdef HAVE_SYS_IOCTL_H
  47. #include <sys/ioctl.h>
  48. #endif
  49. #ifdef HAVE_SYS_SOCKET_H
  50. #include <sys/socket.h>
  51. #endif
  52. #ifdef HAVE_SYS_TIME_H
  53. #include <sys/time.h>
  54. #endif
  55. #ifdef HAVE_SYS_STAT_H
  56. #include <sys/stat.h>
  57. #endif
  58. #ifdef HAVE_NETINET_IN_H
  59. #include <netinet/in.h>
  60. #endif
  61. #ifdef HAVE_ARPA_INET_H
  62. #include <arpa/inet.h>
  63. #endif
  64. #ifdef HAVE_ERRNO_H
  65. #include <errno.h>
  66. #endif
  67. #ifdef HAVE_ASSERT_H
  68. #include <assert.h>
  69. #endif
  70. #ifdef HAVE_TIME_H
  71. #include <time.h>
  72. #endif
  73. #ifdef HAVE_PWD_H
  74. #include <pwd.h>
  75. #endif
  76. #ifdef HAVE_GRP_H
  77. #include <grp.h>
  78. #endif
  79. #ifdef HAVE_WINSOCK_H
  80. #include <winsock.h>
  81. #endif
  82. #if _MSC_VER > 1300
  83. #include <winsock2.h>
  84. #include <ws2tcpip.h>
  85. #elif defined(_MSC_VER)
  86. #include <winsock.h>
  87. #endif
  88. #ifdef MS_WINDOWS
  89. #include <io.h>
  90. #include <process.h>
  91. #include <direct.h>
  92. #include <windows.h>
  93. #define snprintf _snprintf
  94. #endif
  95. #include "../common/crypto.h"
  96. #include "../common/tortls.h"
  97. #include "../common/log.h"
  98. #include "../common/util.h"
  99. #define MAXCONNECTIONS 1000 /* upper bound on max connections.
  100. can be lowered by config file */
  101. #define DEFAULT_BANDWIDTH_OP (1024 * 1000)
  102. #define MAX_NICKNAME_LEN 32
  103. #define MAX_DIR_SIZE 500000
  104. #ifdef TOR_PERF
  105. #define MAX_DNS_ENTRY_AGE (150*60)
  106. #else
  107. #define MAX_DNS_ENTRY_AGE (15*60)
  108. #endif
  109. #define CIRC_ID_TYPE_LOWER 0
  110. #define CIRC_ID_TYPE_HIGHER 1
  111. #define _CONN_TYPE_MIN 3
  112. #define CONN_TYPE_OR_LISTENER 3
  113. #define CONN_TYPE_OR 4
  114. #define CONN_TYPE_EXIT 5
  115. #define CONN_TYPE_AP_LISTENER 6
  116. #define CONN_TYPE_AP 7
  117. #define CONN_TYPE_DIR_LISTENER 8
  118. #define CONN_TYPE_DIR 9
  119. #define CONN_TYPE_DNSWORKER 10
  120. #define CONN_TYPE_CPUWORKER 11
  121. #define _CONN_TYPE_MAX 11
  122. #define LISTENER_STATE_READY 0
  123. #define _DNSWORKER_STATE_MIN 1
  124. #define DNSWORKER_STATE_IDLE 1
  125. #define DNSWORKER_STATE_BUSY 2
  126. #define _DNSWORKER_STATE_MAX 2
  127. #define _CPUWORKER_STATE_MIN 1
  128. #define CPUWORKER_STATE_IDLE 1
  129. #define CPUWORKER_STATE_BUSY_ONION 2
  130. #define CPUWORKER_STATE_BUSY_HANDSHAKE 3
  131. #define _CPUWORKER_STATE_MAX 3
  132. #define CPUWORKER_TASK_ONION CPUWORKER_STATE_BUSY_ONION
  133. #define _OR_CONN_STATE_MIN 1
  134. #define OR_CONN_STATE_CONNECTING 1 /* waiting for connect() to finish */
  135. #define OR_CONN_STATE_HANDSHAKING 2 /* SSL is handshaking, not done yet */
  136. #define OR_CONN_STATE_OPEN 3 /* ready to send/receive cells. */
  137. #define _OR_CONN_STATE_MAX 3
  138. #define _EXIT_CONN_STATE_MIN 1
  139. #define EXIT_CONN_STATE_RESOLVING 1 /* waiting for response from dns farm */
  140. #define EXIT_CONN_STATE_CONNECTING 2 /* waiting for connect() to finish */
  141. #define EXIT_CONN_STATE_OPEN 3
  142. #define EXIT_CONN_STATE_RESOLVEFAILED 4 /* waiting to be removed */
  143. #define _EXIT_CONN_STATE_MAX 4
  144. #if 0
  145. #define EXIT_CONN_STATE_CLOSE 3 /* flushing the buffer, then will close */
  146. #define EXIT_CONN_STATE_CLOSE_WAIT 4 /* have sent a destroy, awaiting a confirmation */
  147. #endif
  148. /* the AP state values must be disjoint from the EXIT state values */
  149. #define _AP_CONN_STATE_MIN 5
  150. #define AP_CONN_STATE_SOCKS_WAIT 5
  151. #define AP_CONN_STATE_CIRCUIT_WAIT 6
  152. #define AP_CONN_STATE_CONNECT_WAIT 7
  153. #define AP_CONN_STATE_OPEN 8
  154. #define _AP_CONN_STATE_MAX 8
  155. /* only used if state==CIRCUIT_WAIT */
  156. #define _AP_PURPOSE_MIN 1
  157. #define AP_PURPOSE_GENERAL 1
  158. #define AP_PURPOSE_RENDDESC_WAIT 2
  159. #define AP_PURPOSE_RENDPOINT_WAIT 3
  160. #define AP_PURPOSE_INTROPOINT_WAIT 4
  161. #define _AP_PURPOSE_MAX 3
  162. #define _DIR_CONN_STATE_MIN 1
  163. #define DIR_CONN_STATE_CONNECTING 1
  164. #define DIR_CONN_STATE_CLIENT_SENDING 2
  165. #define DIR_CONN_STATE_CLIENT_READING 3
  166. #define DIR_CONN_STATE_SERVER_COMMAND_WAIT 4
  167. #define DIR_CONN_STATE_SERVER_WRITING 5
  168. #define _DIR_CONN_STATE_MAX 5
  169. #define _DIR_PURPOSE_MIN 1
  170. #define DIR_PURPOSE_FETCH_DIR 1
  171. #define DIR_PURPOSE_FETCH_RENDDESC 2
  172. #define DIR_PURPOSE_UPLOAD_DIR 3
  173. #define DIR_PURPOSE_UPLOAD_RENDDESC 4
  174. #define DIR_PURPOSE_SERVER 5
  175. #define _DIR_PURPOSE_MAX 5
  176. #define CIRCUIT_STATE_BUILDING 0 /* I'm the OP, still haven't done all my handshakes */
  177. #define CIRCUIT_STATE_ONIONSKIN_PENDING 1 /* waiting to process the onionskin */
  178. #define CIRCUIT_STATE_OR_WAIT 2 /* I'm the OP, my firsthop is still connecting */
  179. #define CIRCUIT_STATE_OPEN 3 /* onionskin(s) processed, ready to send/receive cells */
  180. #define _CIRCUIT_PURPOSE_MIN 1
  181. /* these circuits were initiated elsewhere */
  182. #define CIRCUIT_PURPOSE_OR 1 /* normal circuit, at OR. */
  183. #define CIRCUIT_PURPOSE_INTRO_POINT 2 /* At OR, from Bob, waiting for intro from Alices */
  184. #define CIRCUIT_PURPOSE_REND_POINT_WAITING 3 /* At OR, from Alice, waiting for Bob */
  185. #define CIRCUIT_PURPOSE_REND_ESTABLISHED 4 /* At OR, both circuits have this purpose */
  186. /* these circuits originate at this node */
  187. #define CIRCUIT_PURPOSE_C_GENERAL 5 /* normal circuit, with cpath */
  188. #define CIRCUIT_PURPOSE_S_ESTABLISH_INTRO 6 /* at Bob, waiting for introductions */
  189. #define CIRCUIT_PURPOSE_C_INTRODUCING 7 /* at Alice, connecting to intro point */
  190. #define CIRCUIT_PURPOSE_C_ESTABLISH_REND 8 /* at Alice, waiting for Bob */
  191. #define CIRCUIT_PURPOSE_S_CONNECT_REND 9 /* at Bob, connecting to rend point */
  192. #define CIRCUIT_PURPOSE_C_REND_JOINED 10 /* at Alice, rendezvous established.*/
  193. #define CIRCUIT_PURPOSE_S_REND_JOINED 11 /* at Bob, rendezvous established.*/
  194. #define _CIRCUIT_PURPOSE_MAX 11
  195. #define RELAY_COMMAND_BEGIN 1
  196. #define RELAY_COMMAND_DATA 2
  197. #define RELAY_COMMAND_END 3
  198. #define RELAY_COMMAND_CONNECTED 4
  199. #define RELAY_COMMAND_SENDME 5
  200. #define RELAY_COMMAND_EXTEND 6
  201. #define RELAY_COMMAND_EXTENDED 7
  202. #define RELAY_COMMAND_TRUNCATE 8
  203. #define RELAY_COMMAND_TRUNCATED 9
  204. #define RELAY_COMMAND_DROP 10
  205. #define RELAY_COMMAND_RESOLVE 11
  206. #define RELAY_COMMAND_RESOLVED 12
  207. #define RELAY_COMMAND_ESTABLISH_INTRO 32
  208. #define RELAY_COMMAND_ESTABLISH_RENDEZVOUS 33
  209. #define RELAY_COMMAND_INTRODUCE1 34
  210. #define RELAY_COMMAND_INTRODUCE2 35
  211. #define RELAY_COMMAND_RENDEZVOUS1 36
  212. #define RELAY_COMMAND_RENDEZVOUS2 37
  213. #define _MIN_END_STREAM_REASON 1
  214. #define END_STREAM_REASON_MISC 1
  215. #define END_STREAM_REASON_RESOLVEFAILED 2
  216. #define END_STREAM_REASON_CONNECTFAILED 3
  217. #define END_STREAM_REASON_EXITPOLICY 4
  218. #define END_STREAM_REASON_DESTROY 5
  219. #define END_STREAM_REASON_DONE 6
  220. #define END_STREAM_REASON_TIMEOUT 7
  221. #define _MAX_END_STREAM_REASON 7
  222. /* length of 'y' portion of 'y.onion' URL. */
  223. #define REND_SERVICE_ID_LEN 16
  224. /* Reasons used by connection_mark_for_close */
  225. #define CLOSE_REASON_UNUSED_OR_CONN 100
  226. /* default cipher function */
  227. #define DEFAULT_CIPHER CRYPTO_CIPHER_AES_CTR
  228. /* Used to en/decrypt onion skins */
  229. #define ONION_CIPHER DEFAULT_CIPHER
  230. /* Used to en/decrypt RELAY cells */
  231. #define CIRCUIT_CIPHER DEFAULT_CIPHER
  232. #define CELL_DIRECTION_IN 1
  233. #define CELL_DIRECTION_OUT 2
  234. #define EDGE_EXIT CONN_TYPE_EXIT
  235. #define EDGE_AP CONN_TYPE_AP
  236. #define CELL_DIRECTION(x) ((x) == EDGE_EXIT ? CELL_DIRECTION_IN : CELL_DIRECTION_OUT)
  237. #ifdef TOR_PERF
  238. #define CIRCWINDOW_START 10000
  239. #define CIRCWINDOW_INCREMENT 1000
  240. #define STREAMWINDOW_START 5000
  241. #define STREAMWINDOW_INCREMENT 500
  242. #else
  243. #define CIRCWINDOW_START 1000
  244. #define CIRCWINDOW_INCREMENT 100
  245. #define STREAMWINDOW_START 500
  246. #define STREAMWINDOW_INCREMENT 50
  247. #endif
  248. /* cell commands */
  249. #define CELL_PADDING 0
  250. #define CELL_CREATE 1
  251. #define CELL_CREATED 2
  252. #define CELL_RELAY 3
  253. #define CELL_DESTROY 4
  254. /* legal characters in a filename */
  255. #define CONFIG_LEGAL_FILENAME_CHARACTERS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_/"
  256. /* legal characters in a nickname */
  257. #define LEGAL_NICKNAME_CHARACTERS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
  258. #define SOCKS4_NETWORK_LEN 8
  259. /*
  260. * Relay payload:
  261. * Relay command [1 byte]
  262. * Recognized [2 bytes]
  263. * Stream ID [2 bytes]
  264. * Partial SHA-1 [4 bytes]
  265. * Length [2 bytes]
  266. * Relay payload [498 bytes]
  267. */
  268. #if 0
  269. #define CELL_RELAY_COMMAND(c) (*(uint8_t*)((c).payload))
  270. #define SET_CELL_RELAY_COMMAND(c,cmd) (*(uint8_t*)((c).payload) = (cmd))
  271. #define CELL_RELAY_RECOGNIZED(c) (ntohs(*(uint16_t*)((c).payload+1)))
  272. #define SET_CELL_RELAY_RECOGNIZED(c,r) (*(uint16_t*)((c).payload+1) = htons(r))
  273. #define STREAM_ID_SIZE 2
  274. //#define SET_CELL_STREAM_ID(c,id) memcpy((c).payload+1,(id),STREAM_ID_SIZE)
  275. #define CELL_RELAY_STREAM_ID(c) (ntohs(*(uint16_t*)((c).payload+3)))
  276. #define SET_CELL_RELAY_STREAM_ID(c,id) (*(uint16_t*)((c).payload+3) = htons(id))
  277. #define ZERO_STREAM 0
  278. /* integrity is the first 32 bits (in network order) of a sha-1 of all
  279. * cell payloads that are relay cells that have been sent / delivered
  280. * to the hop on the * circuit (the integrity is zeroed while doing
  281. * each calculation)
  282. */
  283. #define CELL_RELAY_INTEGRITY(c) (ntohl(*(uint32_t*)((c).payload+5)))
  284. #define SET_CELL_RELAY_INTEGRITY(c,i) (*(uint32_t*)((c).payload+5) = htonl(i))
  285. /* relay length is how many bytes are used in the cell payload past relay_header_size */
  286. #define CELL_RELAY_LENGTH(c) (ntohs(*(uint16_t*)((c).payload+9)))
  287. #define SET_CELL_RELAY_LENGTH(c,len) (*(uint16_t*)((c).payload+9) = htons(len))
  288. #endif
  289. #define CELL_PAYLOAD_SIZE 509
  290. #define CELL_NETWORK_SIZE 512
  291. #define RELAY_HEADER_SIZE (1+2+2+4+2)
  292. #define RELAY_PAYLOAD_SIZE (CELL_PAYLOAD_SIZE-RELAY_HEADER_SIZE)
  293. /* cell definition */
  294. typedef struct {
  295. uint16_t circ_id;
  296. unsigned char command;
  297. unsigned char payload[CELL_PAYLOAD_SIZE];
  298. } cell_t;
  299. typedef struct {
  300. uint8_t command;
  301. uint16_t recognized;
  302. uint16_t stream_id;
  303. char integrity[4];
  304. uint16_t length;
  305. } relay_header_t;
  306. typedef struct buf_t buf_t;
  307. typedef struct socks_request_t socks_request_t;
  308. #define CONNECTION_MAGIC 0x7C3C304Eu
  309. struct connection_t {
  310. uint32_t magic; /* for memory debugging */
  311. uint8_t type;
  312. uint8_t state;
  313. uint8_t purpose; /* only used for DIR and AP types currently */
  314. uint8_t wants_to_read; /* should we start reading again once
  315. * the bandwidth throttler allows it?
  316. */
  317. uint8_t wants_to_write; /* should we start writing again once
  318. * the bandwidth throttler allows reads?
  319. */
  320. int s; /* our socket */
  321. int poll_index; /* index of this conn into the poll_array */
  322. int marked_for_close; /* should we close this conn on the next
  323. * iteration of the main loop?
  324. */
  325. char *marked_for_close_file; /* for debugging: in which file were we marked
  326. * for close? */
  327. int hold_open_until_flushed;
  328. buf_t *inbuf;
  329. int inbuf_reached_eof; /* did read() return 0 on this conn? */
  330. time_t timestamp_lastread; /* when was the last time poll() said we could read? */
  331. buf_t *outbuf;
  332. int outbuf_flushlen; /* how much data should we try to flush from the outbuf? */
  333. time_t timestamp_lastwritten; /* when was the last time poll() said we could write? */
  334. time_t timestamp_created; /* when was this connection_t created? */
  335. uint32_t addr; /* these two uniquely identify a router. Both in host order. */
  336. uint16_t port; /* if non-zero, they identify the guy on the other end
  337. * of the connection. */
  338. char *address; /* FQDN (or IP) of the guy on the other end.
  339. * strdup into this, because free_connection frees it
  340. */
  341. crypto_pk_env_t *onion_pkey; /* public RSA key for the other side's onions */
  342. crypto_pk_env_t *link_pkey; /* public RSA key for the other side's TLS */
  343. crypto_pk_env_t *identity_pkey; /* public RSA key for the other side's signing */
  344. char *nickname;
  345. /* Used only by OR connections: */
  346. tor_tls *tls;
  347. uint16_t next_circ_id; /* Which circ_id do we try to use next on this connection?
  348. * This is always in the range 0..1<<15-1.*/
  349. /* bandwidth and receiver_bucket only used by ORs in OPEN state: */
  350. int bandwidth; /* connection bandwidth. */
  351. int receiver_bucket; /* when this hits 0, stop receiving. Every second we
  352. * add 'bandwidth' to this, capping it at 10*bandwidth.
  353. */
  354. /* Used only by DIR and AP connections: */
  355. char rend_query[REND_SERVICE_ID_LEN+1];
  356. /* Used only by edge connections: */
  357. uint16_t stream_id;
  358. struct connection_t *next_stream; /* points to the next stream at this edge, if any */
  359. struct crypt_path_t *cpath_layer; /* a pointer to which node in the circ this conn exits at */
  360. int package_window; /* how many more relay cells can i send into the circuit? */
  361. int deliver_window; /* how many more relay cells can end at me? */
  362. int done_sending; /* for half-open connections; not used currently */
  363. int done_receiving;
  364. char has_sent_end; /* for debugging: set once we've set the stream end,
  365. and check in circuit_about_to_close_connection() */
  366. char num_retries; /* how many times have we re-tried beginning this stream? */
  367. /* Used only by AP connections */
  368. socks_request_t *socks_request;
  369. };
  370. typedef struct connection_t connection_t;
  371. #define EXIT_POLICY_ACCEPT 1
  372. #define EXIT_POLICY_REJECT 2
  373. struct exit_policy_t {
  374. char policy_type;
  375. char *string;
  376. uint32_t addr;
  377. uint32_t msk;
  378. uint16_t prt_min;
  379. uint16_t prt_max;
  380. struct exit_policy_t *next;
  381. };
  382. /* config stuff we know about the other ORs in the network */
  383. typedef struct {
  384. char *address;
  385. char *nickname;
  386. uint32_t addr; /* all host order */
  387. uint16_t or_port;
  388. uint16_t socks_port;
  389. uint16_t dir_port;
  390. time_t published_on;
  391. crypto_pk_env_t *onion_pkey; /* public RSA key for onions */
  392. crypto_pk_env_t *link_pkey; /* public RSA key for TLS */
  393. crypto_pk_env_t *identity_pkey; /* public RSA key for signing */
  394. int is_running;
  395. /* link info */
  396. uint32_t bandwidthrate;
  397. uint32_t bandwidthburst;
  398. struct exit_policy_t *exit_policy;
  399. } routerinfo_t;
  400. #define MAX_ROUTERS_IN_DIR 1024
  401. typedef struct {
  402. routerinfo_t **routers;
  403. int n_routers;
  404. char *software_versions;
  405. time_t published_on;
  406. } routerlist_t;
  407. struct crypt_path_t {
  408. /* crypto environments */
  409. crypto_cipher_env_t *f_crypto;
  410. crypto_cipher_env_t *b_crypto;
  411. crypto_digest_env_t *f_digest; /* for integrity checking */
  412. crypto_digest_env_t *b_digest;
  413. crypto_dh_env_t *handshake_state;
  414. char handshake_digest[CRYPTO_SHA1_DIGEST];/* KH in tor-spec.txt */
  415. uint32_t addr;
  416. uint16_t port;
  417. uint8_t state;
  418. #define CPATH_STATE_CLOSED 0
  419. #define CPATH_STATE_AWAITING_KEYS 1
  420. #define CPATH_STATE_OPEN 2
  421. struct crypt_path_t *next;
  422. struct crypt_path_t *prev; /* doubly linked list */
  423. int package_window;
  424. int deliver_window;
  425. };
  426. #define DH_KEY_LEN CRYPTO_DH_SIZE
  427. #define ONIONSKIN_CHALLENGE_LEN (16+DH_KEY_LEN)
  428. #define ONIONSKIN_REPLY_LEN (DH_KEY_LEN+20)
  429. #define REND_COOKIE_LEN CRYPTO_SHA1_DIGEST_LEN
  430. typedef struct crypt_path_t crypt_path_t;
  431. typedef struct {
  432. int desired_path_len;
  433. /* nickname of planned exit node */
  434. char *chosen_exit;
  435. /* cpath to append after rendezvous. */
  436. struct crypt_path_t *pending_final_cpath;
  437. } cpath_build_state_t;
  438. /* struct for a path (circuit) through the network */
  439. #define CIRCUIT_MAGIC 0x35315243u
  440. struct circuit_t {
  441. uint32_t magic; /* for memory debugging. */
  442. int marked_for_close; /* Should we close this circuit at the end of the main
  443. * loop? */
  444. char *marked_for_close_file;
  445. uint32_t n_addr;
  446. uint16_t n_port;
  447. connection_t *p_conn;
  448. connection_t *n_conn; /* for the OR conn, if there is one */
  449. connection_t *p_streams;
  450. connection_t *n_streams;
  451. uint16_t next_stream_id;
  452. int package_window;
  453. int deliver_window;
  454. uint16_t p_circ_id; /* circuit identifiers */
  455. uint16_t n_circ_id;
  456. crypto_cipher_env_t *p_crypto; /* used only for intermediate hops */
  457. crypto_cipher_env_t *n_crypto;
  458. crypto_digest_env_t *p_digest; /* for integrity checking, */
  459. crypto_digest_env_t *n_digest; /* intermediate hops only */
  460. cpath_build_state_t *build_state;
  461. crypt_path_t *cpath;
  462. char onionskin[ONIONSKIN_CHALLENGE_LEN]; /* for storage while onionskin pending */
  463. char handshake_digest[CRYPTO_SHA1_DIGEST_LEN]; /* Stores KH for intermediate hops */
  464. time_t timestamp_created;
  465. time_t timestamp_dirty; /* when the circuit was first used, or 0 if clean */
  466. uint8_t state;
  467. uint8_t purpose;
  468. /*
  469. * rend_query holds y portion of y.onion (nul-terminated) if purpose
  470. * is C_INTRODUCING or C_ESTABLISH_REND, or is a C_GENERAL for a
  471. * hidden service.
  472. */
  473. char rend_query[REND_SERVICE_ID_LEN+1];
  474. /* rend_pk_digest holds a hash of location-hidden service's PK if
  475. * purpose is INTRO_POINT or S_ESTABLISH_INTRO or S_RENDEZVOUSING
  476. */
  477. char rend_pk_digest[CRYPTO_SHA1_DIGEST_LEN];
  478. /* Holds rendezvous cookie if purpose is REND_POINT_WAITING or
  479. * C_ESTABLISH_REND. Filled with zeroes otherwise.
  480. */
  481. char rend_cookie[REND_COOKIE_LEN];
  482. /* Points to spliced circuit if purpose is REND_ESTABLISHED, and circuit
  483. * is not marked for close. */
  484. struct circuit_t *rend_splice;
  485. struct circuit_t *next;
  486. };
  487. typedef struct circuit_t circuit_t;
  488. typedef struct circuit_data_rend_point_t {
  489. /* for CIRCUIT_PURPOSE_INTRO_POINT (at OR, from Bob, waiting for intro) */
  490. char rend_cookie[20];
  491. } circuit_data_intro_point_t;
  492. typedef struct {
  493. char *LogLevel;
  494. char *LogFile;
  495. char *DebugLogFile;
  496. char *DataDirectory;
  497. char *RouterFile;
  498. char *Nickname;
  499. char *Address;
  500. char *PidFile;
  501. char *ExitNodes;
  502. char *EntryNodes;
  503. char *ExcludeNodes;
  504. char *RendNodes;
  505. char *RendExcludeNodes;
  506. char *ExitPolicy;
  507. char *SocksBindAddress;
  508. char *ORBindAddress;
  509. char *DirBindAddress;
  510. char *RecommendedVersions;
  511. char *User;
  512. char *Group;
  513. double PathlenCoinWeight;
  514. int ORPort;
  515. int SocksPort;
  516. int DirPort;
  517. int MaxConn;
  518. int TrafficShaping;
  519. int LinkPadding;
  520. int IgnoreVersion;
  521. int RunAsDaemon;
  522. int DirRebuildPeriod;
  523. int DirFetchPostPeriod;
  524. int KeepalivePeriod;
  525. int MaxOnionsPending;
  526. int NewCircuitPeriod;
  527. int BandwidthRate;
  528. int BandwidthBurst;
  529. int NumCpus;
  530. int loglevel;
  531. int RunTesting;
  532. struct config_line_t *RendConfigLines;
  533. } or_options_t;
  534. /* XXX are these good enough defaults? */
  535. #define MAX_SOCKS_REPLY_LEN 1024
  536. #define MAX_SOCKS_ADDR_LEN 256
  537. struct socks_request_t {
  538. char socks_version;
  539. int replylen;
  540. char reply[MAX_SOCKS_REPLY_LEN];
  541. int has_finished; /* has the socks handshake finished? */
  542. char address[MAX_SOCKS_ADDR_LEN];
  543. uint16_t port;
  544. };
  545. /* all the function prototypes go here */
  546. /********************************* buffers.c ***************************/
  547. int find_on_inbuf(char *string, int string_len, buf_t *buf);
  548. buf_t *buf_new();
  549. buf_t *buf_new_with_capacity(size_t size);
  550. void buf_free(buf_t *buf);
  551. void buf_clear(buf_t *buf);
  552. size_t buf_datalen(const buf_t *buf);
  553. size_t buf_capacity(const buf_t *buf);
  554. const char *_buf_peek_raw_buffer(const buf_t *buf);
  555. int read_to_buf(int s, int at_most, buf_t *buf, int *reached_eof);
  556. int read_to_buf_tls(tor_tls *tls, int at_most, buf_t *buf);
  557. int flush_buf(int s, buf_t *buf, int *buf_flushlen);
  558. int flush_buf_tls(tor_tls *tls, buf_t *buf, int *buf_flushlen);
  559. int write_to_buf(const char *string, int string_len, buf_t *buf);
  560. int fetch_from_buf(char *string, int string_len, buf_t *buf);
  561. int fetch_from_buf_http(buf_t *buf,
  562. char **headers_out, int max_headerlen,
  563. char **body_out, int *body_used, int max_bodylen);
  564. int fetch_from_buf_socks(buf_t *buf, socks_request_t *req);
  565. void assert_buf_ok(buf_t *buf);
  566. /********************************* circuit.c ***************************/
  567. void circuit_add(circuit_t *circ);
  568. void circuit_remove(circuit_t *circ);
  569. circuit_t *circuit_new(uint16_t p_circ_id, connection_t *p_conn);
  570. void circuit_close_all_marked(void);
  571. void circuit_free(circuit_t *circ);
  572. void circuit_free_cpath(crypt_path_t *cpath);
  573. int _circuit_mark_for_close(circuit_t *circ);
  574. #define circuit_mark_for_close(c) \
  575. do { \
  576. if (_circuit_mark_for_close(c)<0) { \
  577. log(LOG_WARN,"Duplicate call to circuit_mark_for_close at %s:%d (first at %s:%d)", \
  578. __FILE__,__LINE__,c->marked_for_close_file,c->marked_for_close); \
  579. } else { \
  580. c->marked_for_close_file = __FILE__; \
  581. c->marked_for_close = __LINE__; \
  582. } \
  583. } while (0)
  584. circuit_t *circuit_get_by_circ_id_conn(uint16_t circ_id, connection_t *conn);
  585. circuit_t *circuit_get_by_conn(connection_t *conn);
  586. circuit_t *circuit_get_newest(connection_t *conn,
  587. int must_be_open, uint8_t conn_purpose);
  588. circuit_t *circuit_get_next_by_pk_and_purpose(circuit_t *circuit,
  589. const char *servid, int purpose);
  590. circuit_t *circuit_get_rendezvous(const char *cookie);
  591. void circuit_expire_building(void);
  592. int circuit_count_building(void);
  593. int circuit_stream_is_being_handled(connection_t *conn);
  594. int circuit_receive_relay_cell(cell_t *cell, circuit_t *circ,
  595. int cell_direction);
  596. int circuit_package_relay_cell(cell_t *cell, circuit_t *circ,
  597. int cell_direction, crypt_path_t *layer_hint);
  598. void circuit_resume_edge_reading(circuit_t *circ, int edge_type, crypt_path_t *layer_hint);
  599. int circuit_consider_stop_edge_reading(circuit_t *circ, int edge_type, crypt_path_t *layer_hint);
  600. void circuit_consider_sending_sendme(circuit_t *circ, int edge_type, crypt_path_t *layer_hint);
  601. void circuit_detach_stream(circuit_t *circ, connection_t *conn);
  602. void circuit_about_to_close_connection(connection_t *conn);
  603. void circuit_log_path(int severity, circuit_t *circ);
  604. void circuit_dump_by_conn(connection_t *conn, int severity);
  605. void circuit_expire_unused_circuits(void);
  606. circuit_t *circuit_launch_new(uint8_t purpose, const char *exit_nickname);
  607. void circuit_increment_failure_count(void);
  608. void circuit_reset_failure_count(void);
  609. void circuit_n_conn_open(connection_t *or_conn);
  610. int circuit_send_next_onion_skin(circuit_t *circ);
  611. int circuit_extend(cell_t *cell, circuit_t *circ);
  612. #define CPATH_KEY_MATERIAL_LEN (20*2+16*2)
  613. int circuit_init_cpath_crypto(crypt_path_t *cpath, char *key_data);
  614. int circuit_finish_handshake(circuit_t *circ, char *reply);
  615. int circuit_truncated(circuit_t *circ, crypt_path_t *layer);
  616. void assert_cpath_ok(const crypt_path_t *c);
  617. void assert_cpath_layer_ok(const crypt_path_t *c);
  618. void assert_circuit_ok(const circuit_t *c);
  619. extern unsigned long stats_n_relay_cells_relayed;
  620. extern unsigned long stats_n_relay_cells_delivered;
  621. /********************************* command.c ***************************/
  622. void command_process_cell(cell_t *cell, connection_t *conn);
  623. extern unsigned long stats_n_padding_cells_processed;
  624. extern unsigned long stats_n_create_cells_processed;
  625. extern unsigned long stats_n_created_cells_processed;
  626. extern unsigned long stats_n_relay_cells_processed;
  627. extern unsigned long stats_n_destroy_cells_processed;
  628. /********************************* config.c ***************************/
  629. struct config_line_t {
  630. char *key;
  631. char *value;
  632. struct config_line_t *next;
  633. };
  634. int config_assign_default_dirservers(void);
  635. int getconfig(int argc, char **argv, or_options_t *options);
  636. /********************************* connection.c ***************************/
  637. #define CONN_TYPE_TO_STRING(t) (((t) < _CONN_TYPE_MIN || (t) > _CONN_TYPE_MAX) ? \
  638. "Unknown" : conn_type_to_string[(t)])
  639. extern char *conn_type_to_string[];
  640. connection_t *connection_new(int type);
  641. void connection_free(connection_t *conn);
  642. void connection_free_all(void);
  643. void connection_close_immediate(connection_t *conn);
  644. int _connection_mark_for_close(connection_t *conn, char reason);
  645. #define connection_mark_for_close(c,r) \
  646. do { \
  647. if (_connection_mark_for_close(c,r)<0) { \
  648. log(LOG_WARN,"Duplicate call to connection_mark_for_close at %s:%d (first at %s:%d)", \
  649. __FILE__,__LINE__,c->marked_for_close_file,c->marked_for_close); \
  650. } else { \
  651. c->marked_for_close_file = __FILE__; \
  652. c->marked_for_close = __LINE__; \
  653. } \
  654. } while (0)
  655. void connection_expire_held_open(void);
  656. int connection_create_listener(char *bindaddress, uint16_t bindport, int type);
  657. int connection_connect(connection_t *conn, char *address, uint32_t addr, uint16_t port);
  658. int retry_all_connections(void);
  659. void connection_bucket_init(void);
  660. void connection_bucket_refill(struct timeval *now);
  661. int connection_handle_read(connection_t *conn);
  662. int connection_read_to_buf(connection_t *conn);
  663. int connection_fetch_from_buf(char *string, int len, connection_t *conn);
  664. int connection_find_on_inbuf(char *string, int len, connection_t *conn);
  665. int connection_wants_to_flush(connection_t *conn);
  666. int connection_outbuf_too_full(connection_t *conn);
  667. int connection_handle_write(connection_t *conn);
  668. void connection_write_to_buf(const char *string, int len, connection_t *conn);
  669. connection_t *connection_twin_get_by_addr_port(uint32_t addr, uint16_t port);
  670. connection_t *connection_exact_get_by_addr_port(uint32_t addr, uint16_t port);
  671. connection_t *connection_get_by_type(int type);
  672. connection_t *connection_get_by_type_state(int type, int state);
  673. connection_t *connection_get_by_type_state_lastwritten(int type, int state);
  674. #define connection_speaks_cells(conn) ((conn)->type == CONN_TYPE_OR)
  675. #define connection_has_pending_tls_data(conn) \
  676. ((conn)->type == CONN_TYPE_OR && \
  677. (conn)->state == OR_CONN_STATE_OPEN && \
  678. tor_tls_get_pending_bytes((conn)->tls))
  679. int connection_is_listener(connection_t *conn);
  680. int connection_state_is_open(connection_t *conn);
  681. int connection_send_destroy(uint16_t circ_id, connection_t *conn);
  682. int connection_process_inbuf(connection_t *conn);
  683. int connection_finished_flushing(connection_t *conn);
  684. void assert_connection_ok(connection_t *conn, time_t now);
  685. /********************************* connection_edge.c ***************************/
  686. void relay_header_pack(char *dest, const relay_header_t *src);
  687. void relay_header_unpack(relay_header_t *dest, const char *src);
  688. int connection_edge_process_inbuf(connection_t *conn);
  689. int connection_edge_destroy(uint16_t circ_id, connection_t *conn);
  690. int connection_edge_end(connection_t *conn, char reason, crypt_path_t *cpath_layer);
  691. int connection_edge_send_command(connection_t *fromconn, circuit_t *circ,
  692. int relay_command, void *payload,
  693. int payload_len, crypt_path_t *cpath_layer);
  694. int connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ,
  695. connection_t *conn, int edge_type,
  696. crypt_path_t *layer_hint);
  697. int connection_edge_finished_flushing(connection_t *conn);
  698. int connection_edge_package_raw_inbuf(connection_t *conn);
  699. int connection_ap_handshake_attach_circuit(connection_t *conn);
  700. int connection_ap_make_bridge(char *address, uint16_t port);
  701. void connection_ap_handshake_socks_reply(connection_t *conn, char *reply,
  702. int replylen, char success);
  703. void connection_exit_connect(connection_t *conn);
  704. int connection_ap_can_use_exit(connection_t *conn, routerinfo_t *exit);
  705. void connection_ap_expire_beginning(void);
  706. void connection_ap_attach_pending(void);
  707. extern uint64_t stats_n_data_cells_packaged;
  708. extern uint64_t stats_n_data_bytes_packaged;
  709. extern uint64_t stats_n_data_cells_received;
  710. extern uint64_t stats_n_data_bytes_received;
  711. void client_dns_init(void);
  712. void client_dns_clean(void);
  713. /********************************* connection_or.c ***************************/
  714. int connection_or_process_inbuf(connection_t *conn);
  715. int connection_or_finished_flushing(connection_t *conn);
  716. void connection_or_init_conn_from_router(connection_t *conn, routerinfo_t *router);
  717. connection_t *connection_or_connect(routerinfo_t *router);
  718. int connection_tls_start_handshake(connection_t *conn, int receiving);
  719. int connection_tls_continue_handshake(connection_t *conn);
  720. void connection_or_write_cell_to_buf(const cell_t *cell, connection_t *conn);
  721. /********************************* cpuworker.c *****************************/
  722. void cpu_init(void);
  723. int connection_cpu_finished_flushing(connection_t *conn);
  724. int connection_cpu_process_inbuf(connection_t *conn);
  725. int cpuworker_main(void *data);
  726. int assign_to_cpuworker(connection_t *cpuworker, unsigned char question_type,
  727. void *task);
  728. /********************************* directory.c ***************************/
  729. void directory_initiate_command(routerinfo_t *router, int purpose,
  730. const char *payload, int payload_len);
  731. int connection_dir_process_inbuf(connection_t *conn);
  732. int connection_dir_finished_flushing(connection_t *conn);
  733. /********************************* dns.c ***************************/
  734. void dns_init(void);
  735. int connection_dns_finished_flushing(connection_t *conn);
  736. int connection_dns_process_inbuf(connection_t *conn);
  737. void connection_dns_remove(connection_t *conn);
  738. void assert_connection_edge_not_dns_pending(connection_t *conn);
  739. void dns_cancel_pending_resolve(char *question);
  740. int dns_resolve(connection_t *exitconn);
  741. /********************************* main.c ***************************/
  742. int connection_add(connection_t *conn);
  743. int connection_remove(connection_t *conn);
  744. void connection_set_poll_socket(connection_t *conn);
  745. void get_connection_array(connection_t ***array, int *n);
  746. void connection_watch_events(connection_t *conn, short events);
  747. int connection_is_reading(connection_t *conn);
  748. void connection_stop_reading(connection_t *conn);
  749. void connection_start_reading(connection_t *conn);
  750. int connection_is_writing(connection_t *conn);
  751. void connection_stop_writing(connection_t *conn);
  752. void connection_start_writing(connection_t *conn);
  753. void directory_has_arrived(void);
  754. int main(int argc, char *argv[]);
  755. /********************************* onion.c ***************************/
  756. int decide_circ_id_type(char *local_nick, char *remote_nick);
  757. int onion_pending_add(circuit_t *circ);
  758. circuit_t *onion_next_task(void);
  759. void onion_pending_remove(circuit_t *circ);
  760. int onionskin_answer(circuit_t *circ, unsigned char *payload, unsigned char *keys);
  761. void onion_append_to_cpath(crypt_path_t **head_ptr, crypt_path_t *new_hop);
  762. int onion_extend_cpath(crypt_path_t **head_ptr, cpath_build_state_t *state,
  763. routerinfo_t **router_out);
  764. int onion_skin_create(crypto_pk_env_t *router_key,
  765. crypto_dh_env_t **handshake_state_out,
  766. char *onion_skin_out);
  767. int onion_skin_server_handshake(char *onion_skin,
  768. crypto_pk_env_t *private_key,
  769. char *handshake_reply_out,
  770. char *key_out,
  771. int key_out_len);
  772. int onion_skin_client_handshake(crypto_dh_env_t *handshake_state,
  773. char *handshake_reply,
  774. char *key_out,
  775. int key_out_len);
  776. cpath_build_state_t *onion_new_cpath_build_state(uint8_t purpose,
  777. const char *exit_nickname);
  778. /********************************* router.c ***************************/
  779. void set_onion_key(crypto_pk_env_t *k);
  780. crypto_pk_env_t *get_onion_key(void);
  781. void set_identity_key(crypto_pk_env_t *k);
  782. crypto_pk_env_t *get_identity_key(void);
  783. crypto_pk_env_t *get_link_key(void);
  784. int init_keys(void);
  785. crypto_pk_env_t *init_key_from_file(const char *fname);
  786. void router_retry_connections(void);
  787. void router_upload_dir_desc_to_dirservers(void);
  788. void router_post_to_dirservers(uint8_t purpose, const char *payload, int payload_len);
  789. int router_compare_to_my_exit_policy(connection_t *conn);
  790. const char *router_get_my_descriptor(void);
  791. int router_rebuild_descriptor(void);
  792. int router_dump_router_to_string(char *s, int maxlen, routerinfo_t *router,
  793. crypto_pk_env_t *ident_key);
  794. /********************************* routerlist.c ***************************/
  795. routerinfo_t *router_pick_directory_server(void);
  796. struct smartlist_t;
  797. routerinfo_t *router_choose_random_node(routerlist_t *dir,
  798. char *preferred, char *excluded,
  799. struct smartlist_t *excludedsmartlist);
  800. routerinfo_t *router_get_by_addr_port(uint32_t addr, uint16_t port);
  801. routerinfo_t *router_get_by_link_pk(crypto_pk_env_t *pk);
  802. routerinfo_t *router_get_by_nickname(char *nickname);
  803. void router_get_routerlist(routerlist_t **prouterlist);
  804. void routerinfo_free(routerinfo_t *router);
  805. void router_mark_as_down(char *nickname);
  806. int router_set_routerlist_from_file(char *routerfile);
  807. int router_set_routerlist_from_string(const char *s);
  808. int router_get_dir_hash(const char *s, char *digest);
  809. int router_get_router_hash(const char *s, char *digest);
  810. int router_set_routerlist_from_directory(const char *s, crypto_pk_env_t *pkey);
  811. routerinfo_t *router_get_entry_from_string(const char *s, const char *end);
  812. int router_add_exit_policy_from_string(routerinfo_t *router, const char *s);
  813. int router_compare_addr_to_exit_policy(uint32_t addr, uint16_t port,
  814. struct exit_policy_t *policy);
  815. #define ADDR_POLICY_ACCEPTED 0
  816. #define ADDR_POLICY_REJECTED -1
  817. #define ADDR_POLICY_UNKNOWN 1
  818. int router_exit_policy_all_routers_reject(uint32_t addr, uint16_t port);
  819. int router_exit_policy_rejects_all(routerinfo_t *router);
  820. /********************************* dirserv.c ***************************/
  821. int dirserv_add_own_fingerprint(const char *nickname, crypto_pk_env_t *pk);
  822. int dirserv_parse_fingerprint_file(const char *fname);
  823. int dirserv_router_fingerprint_is_known(const routerinfo_t *router);
  824. void dirserv_free_fingerprint_list();
  825. int dirserv_add_descriptor(const char **desc);
  826. int dirserv_init_from_directory_string(const char *dir);
  827. void dirserv_free_descriptors();
  828. int dirserv_dump_directory_to_string(char *s, int maxlen,
  829. crypto_pk_env_t *private_key);
  830. void directory_set_dirty(void);
  831. size_t dirserv_get_directory(const char **cp);
  832. void dirserv_remove_old_servers(void);
  833. /********************************* rephist.c ***************************/
  834. void rep_hist_init(void);
  835. void rep_hist_note_connect_failed(const char* nickname, time_t when);
  836. void rep_hist_note_connect_succeeded(const char* nickname, time_t when);
  837. void rep_hist_note_disconnect(const char* nickname, time_t when);
  838. void rep_hist_note_connection_died(const char* nickname, time_t when);
  839. void rep_hist_note_extend_succeeded(const char *from_name,
  840. const char *to_name);
  841. void rep_hist_note_extend_failed(const char *from_name, const char *to_name);
  842. void rep_hist_dump_stats(time_t now, int severity);
  843. /********************************* rendclient.c ***************************/
  844. void rend_client_introcirc_is_ready(connection_t *apconn, circuit_t *circ);
  845. void rend_client_rendcirc_is_ready(connection_t *apconn, circuit_t *circ);
  846. void rend_client_rendezvous(connection_t *apconn, circuit_t *circ);
  847. void rend_client_desc_fetched(char *query, int success);
  848. /********************************* rendcommon.c ***************************/
  849. typedef struct rend_service_descriptor_t {
  850. crypto_pk_env_t *pk;
  851. time_t timestamp;
  852. int n_intro_points;
  853. char **intro_points;
  854. } rend_service_descriptor_t;
  855. void rend_service_descriptor_free(rend_service_descriptor_t *desc);
  856. int rend_encode_service_descriptor(rend_service_descriptor_t *desc,
  857. crypto_pk_env_t *key,
  858. char **str_out,
  859. int *len_out);
  860. rend_service_descriptor_t *rend_parse_service_descriptor(const char *str, int len);
  861. int rend_get_service_id(crypto_pk_env_t *pk, char *out);
  862. int rend_cmp_service_ids(char *one, char *two);
  863. void rend_cache_init(void);
  864. void rend_cache_clean(void);
  865. int rend_cache_lookup(char *query, const char **desc, int *desc_len);
  866. int rend_cache_store(char *desc, int desc_len);
  867. int rend_parse_rendezvous_address(char *address);
  868. /********************************* rendservice.c ***************************/
  869. int rend_config_services(or_options_t *options);
  870. int rend_service_init_keys(void);
  871. int rend_services_init(void);
  872. void rend_service_intro_is_ready(circuit_t *circuit);
  873. void rend_service_rendezvous_is_ready(circuit_t *circuit);
  874. #endif
  875. /*
  876. Local Variables:
  877. mode:c
  878. indent-tabs-mode:nil
  879. c-basic-offset:2
  880. End:
  881. */