or.h 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076
  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_INTERMEDIATE 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 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. /* The field rend_service:
  469. * holds hash of location-hidden service's PK if purpose is INTRO_POINT
  470. * or S_ESTABLISH_INTRO or S_RENDEZVOUSING;
  471. * holds y portion of y.onion (zero-padded) if purpose is C_INTRODUCING or
  472. * C_ESTABLISH_REND, or is a C_GENERAL for a hidden service.
  473. * is filled with zeroes otherwise.
  474. */
  475. char rend_service[CRYPTO_SHA1_DIGEST_LEN];
  476. /* Holds rendezvous cookie if purpose is REND_POINT_WAITING or
  477. * C_ESTABLISH_REND. Filled with zeroes otherwise.
  478. */
  479. char rend_cookie[REND_COOKIE_LEN];
  480. /* Points to spliced circuit if purpose is REND_ESTABLISHED, and circuit
  481. * is not marked for close. */
  482. struct circuit_t *rend_splice;
  483. struct circuit_t *next;
  484. };
  485. typedef struct circuit_t circuit_t;
  486. typedef struct circuit_data_rend_point_t {
  487. /* for CIRCUIT_PURPOSE_INTRO_POINT (at OR, from Bob, waiting for intro) */
  488. char rend_cookie[20];
  489. } circuit_data_intro_point_t;
  490. typedef struct {
  491. char *LogLevel;
  492. char *LogFile;
  493. char *DebugLogFile;
  494. char *DataDirectory;
  495. char *RouterFile;
  496. char *Nickname;
  497. char *Address;
  498. char *PidFile;
  499. char *ExitNodes;
  500. char *EntryNodes;
  501. char *ExcludeNodes;
  502. char *RendNodes;
  503. char *RendExcludeNodes;
  504. char *ExitPolicy;
  505. char *SocksBindAddress;
  506. char *ORBindAddress;
  507. char *DirBindAddress;
  508. char *RecommendedVersions;
  509. char *User;
  510. char *Group;
  511. double PathlenCoinWeight;
  512. int ORPort;
  513. int SocksPort;
  514. int DirPort;
  515. int MaxConn;
  516. int TrafficShaping;
  517. int LinkPadding;
  518. int IgnoreVersion;
  519. int RunAsDaemon;
  520. int DirRebuildPeriod;
  521. int DirFetchPostPeriod;
  522. int KeepalivePeriod;
  523. int MaxOnionsPending;
  524. int NewCircuitPeriod;
  525. int BandwidthRate;
  526. int BandwidthBurst;
  527. int NumCpus;
  528. int loglevel;
  529. int RunTesting;
  530. struct config_line_t *RendConfigLines;
  531. } or_options_t;
  532. /* XXX are these good enough defaults? */
  533. #define MAX_SOCKS_REPLY_LEN 1024
  534. #define MAX_SOCKS_ADDR_LEN 256
  535. struct socks_request_t {
  536. char socks_version;
  537. int replylen;
  538. char reply[MAX_SOCKS_REPLY_LEN];
  539. int has_finished; /* has the socks handshake finished? */
  540. char address[MAX_SOCKS_ADDR_LEN];
  541. uint16_t port;
  542. };
  543. /* all the function prototypes go here */
  544. /********************************* buffers.c ***************************/
  545. int find_on_inbuf(char *string, int string_len, buf_t *buf);
  546. buf_t *buf_new();
  547. buf_t *buf_new_with_capacity(size_t size);
  548. void buf_free(buf_t *buf);
  549. void buf_clear(buf_t *buf);
  550. size_t buf_datalen(const buf_t *buf);
  551. size_t buf_capacity(const buf_t *buf);
  552. const char *_buf_peek_raw_buffer(const buf_t *buf);
  553. int read_to_buf(int s, int at_most, buf_t *buf, int *reached_eof);
  554. int read_to_buf_tls(tor_tls *tls, int at_most, buf_t *buf);
  555. int flush_buf(int s, buf_t *buf, int *buf_flushlen);
  556. int flush_buf_tls(tor_tls *tls, buf_t *buf, int *buf_flushlen);
  557. int write_to_buf(const char *string, int string_len, buf_t *buf);
  558. int fetch_from_buf(char *string, int string_len, buf_t *buf);
  559. int fetch_from_buf_http(buf_t *buf,
  560. char **headers_out, int max_headerlen,
  561. char **body_out, int *body_used, int max_bodylen);
  562. int fetch_from_buf_socks(buf_t *buf, socks_request_t *req);
  563. void assert_buf_ok(buf_t *buf);
  564. /********************************* circuit.c ***************************/
  565. void circuit_add(circuit_t *circ);
  566. void circuit_remove(circuit_t *circ);
  567. circuit_t *circuit_new(uint16_t p_circ_id, connection_t *p_conn);
  568. void circuit_close_all_marked(void);
  569. void circuit_free(circuit_t *circ);
  570. void circuit_free_cpath(crypt_path_t *cpath);
  571. int _circuit_mark_for_close(circuit_t *circ);
  572. #define circuit_mark_for_close(c) \
  573. do { \
  574. if (_circuit_mark_for_close(c)<0) { \
  575. log(LOG_WARN,"Duplicate call to circuit_mark_for_close at %s:%d (first at %s:%d)", \
  576. __FILE__,__LINE__,c->marked_for_close_file,c->marked_for_close); \
  577. } else { \
  578. c->marked_for_close_file = __FILE__; \
  579. c->marked_for_close = __LINE__; \
  580. } \
  581. } while (0)
  582. circuit_t *circuit_get_by_circ_id_conn(uint16_t circ_id, connection_t *conn);
  583. circuit_t *circuit_get_by_conn(connection_t *conn);
  584. circuit_t *circuit_get_newest(connection_t *conn,
  585. int must_be_open, uint8_t conn_purpose);
  586. circuit_t *circuit_get_next_by_service_and_purpose(circuit_t *circuit,
  587. const char *servid, int purpose);
  588. circuit_t *circuit_get_rendezvous(const char *cookie);
  589. void circuit_expire_building(void);
  590. int circuit_count_building(void);
  591. int circuit_stream_is_being_handled(connection_t *conn);
  592. int circuit_receive_relay_cell(cell_t *cell, circuit_t *circ,
  593. int cell_direction);
  594. int circuit_package_relay_cell(cell_t *cell, circuit_t *circ,
  595. int cell_direction, crypt_path_t *layer_hint);
  596. void circuit_resume_edge_reading(circuit_t *circ, int edge_type, crypt_path_t *layer_hint);
  597. int circuit_consider_stop_edge_reading(circuit_t *circ, int edge_type, crypt_path_t *layer_hint);
  598. void circuit_consider_sending_sendme(circuit_t *circ, int edge_type, crypt_path_t *layer_hint);
  599. void circuit_detach_stream(circuit_t *circ, connection_t *conn);
  600. void circuit_about_to_close_connection(connection_t *conn);
  601. void circuit_log_path(int severity, circuit_t *circ);
  602. void circuit_dump_by_conn(connection_t *conn, int severity);
  603. void circuit_expire_unused_circuits(void);
  604. circuit_t *circuit_launch_new(uint8_t purpose, const char *exit_nickname);
  605. void circuit_increment_failure_count(void);
  606. void circuit_reset_failure_count(void);
  607. void circuit_n_conn_open(connection_t *or_conn);
  608. int circuit_send_next_onion_skin(circuit_t *circ);
  609. int circuit_extend(cell_t *cell, circuit_t *circ);
  610. #define CPATH_KEY_MATERIAL_LEN (20*2+16*2)
  611. int circuit_init_cpath_crypto(crypt_path_t *cpath, char *key_data);
  612. int circuit_finish_handshake(circuit_t *circ, char *reply);
  613. int circuit_truncated(circuit_t *circ, crypt_path_t *layer);
  614. void assert_cpath_ok(const crypt_path_t *c);
  615. void assert_cpath_layer_ok(const crypt_path_t *c);
  616. void assert_circuit_ok(const circuit_t *c);
  617. extern unsigned long stats_n_relay_cells_relayed;
  618. extern unsigned long stats_n_relay_cells_delivered;
  619. /********************************* command.c ***************************/
  620. void command_process_cell(cell_t *cell, connection_t *conn);
  621. extern unsigned long stats_n_padding_cells_processed;
  622. extern unsigned long stats_n_create_cells_processed;
  623. extern unsigned long stats_n_created_cells_processed;
  624. extern unsigned long stats_n_relay_cells_processed;
  625. extern unsigned long stats_n_destroy_cells_processed;
  626. /********************************* config.c ***************************/
  627. struct config_line_t {
  628. char *key;
  629. char *value;
  630. struct config_line_t *next;
  631. };
  632. int config_assign_default_dirservers(void);
  633. int getconfig(int argc, char **argv, or_options_t *options);
  634. /********************************* connection.c ***************************/
  635. #define CONN_TYPE_TO_STRING(t) (((t) < _CONN_TYPE_MIN || (t) > _CONN_TYPE_MAX) ? \
  636. "Unknown" : conn_type_to_string[(t)])
  637. extern char *conn_type_to_string[];
  638. connection_t *connection_new(int type);
  639. void connection_free(connection_t *conn);
  640. void connection_free_all(void);
  641. void connection_close_immediate(connection_t *conn);
  642. int _connection_mark_for_close(connection_t *conn, char reason);
  643. #define connection_mark_for_close(c,r) \
  644. do { \
  645. if (_connection_mark_for_close(c,r)<0) { \
  646. log(LOG_WARN,"Duplicate call to connection_mark_for_close at %s:%d (first at %s:%d)", \
  647. __FILE__,__LINE__,c->marked_for_close_file,c->marked_for_close); \
  648. } else { \
  649. c->marked_for_close_file = __FILE__; \
  650. c->marked_for_close = __LINE__; \
  651. } \
  652. } while (0)
  653. void connection_expire_held_open(void);
  654. int connection_create_listener(char *bindaddress, uint16_t bindport, int type);
  655. int connection_connect(connection_t *conn, char *address, uint32_t addr, uint16_t port);
  656. int retry_all_connections(void);
  657. void connection_bucket_init(void);
  658. void connection_bucket_refill(struct timeval *now);
  659. int connection_handle_read(connection_t *conn);
  660. int connection_read_to_buf(connection_t *conn);
  661. int connection_fetch_from_buf(char *string, int len, connection_t *conn);
  662. int connection_find_on_inbuf(char *string, int len, connection_t *conn);
  663. int connection_wants_to_flush(connection_t *conn);
  664. int connection_outbuf_too_full(connection_t *conn);
  665. int connection_handle_write(connection_t *conn);
  666. void connection_write_to_buf(const char *string, int len, connection_t *conn);
  667. connection_t *connection_twin_get_by_addr_port(uint32_t addr, uint16_t port);
  668. connection_t *connection_exact_get_by_addr_port(uint32_t addr, uint16_t port);
  669. connection_t *connection_get_by_type(int type);
  670. connection_t *connection_get_by_type_state(int type, int state);
  671. connection_t *connection_get_by_type_state_lastwritten(int type, int state);
  672. #define connection_speaks_cells(conn) ((conn)->type == CONN_TYPE_OR)
  673. #define connection_has_pending_tls_data(conn) \
  674. ((conn)->type == CONN_TYPE_OR && \
  675. (conn)->state == OR_CONN_STATE_OPEN && \
  676. tor_tls_get_pending_bytes((conn)->tls))
  677. int connection_is_listener(connection_t *conn);
  678. int connection_state_is_open(connection_t *conn);
  679. int connection_send_destroy(uint16_t circ_id, connection_t *conn);
  680. int connection_process_inbuf(connection_t *conn);
  681. int connection_finished_flushing(connection_t *conn);
  682. void assert_connection_ok(connection_t *conn, time_t now);
  683. /********************************* connection_edge.c ***************************/
  684. void relay_header_pack(char *dest, const relay_header_t *src);
  685. void relay_header_unpack(relay_header_t *dest, const char *src);
  686. int connection_edge_process_inbuf(connection_t *conn);
  687. int connection_edge_destroy(uint16_t circ_id, connection_t *conn);
  688. int connection_edge_end(connection_t *conn, char reason, crypt_path_t *cpath_layer);
  689. int connection_edge_send_command(connection_t *fromconn, circuit_t *circ,
  690. int relay_command, void *payload,
  691. int payload_len, crypt_path_t *cpath_layer);
  692. int connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ,
  693. connection_t *conn, int edge_type,
  694. crypt_path_t *layer_hint);
  695. int connection_edge_finished_flushing(connection_t *conn);
  696. int connection_edge_package_raw_inbuf(connection_t *conn);
  697. int connection_ap_make_bridge(char *address, uint16_t port);
  698. void connection_ap_handshake_socks_reply(connection_t *conn, char *reply,
  699. int replylen, char success);
  700. void connection_exit_connect(connection_t *conn);
  701. int connection_ap_can_use_exit(connection_t *conn, routerinfo_t *exit);
  702. void connection_ap_expire_beginning(void);
  703. void connection_ap_attach_pending(void);
  704. extern uint64_t stats_n_data_cells_packaged;
  705. extern uint64_t stats_n_data_bytes_packaged;
  706. extern uint64_t stats_n_data_cells_received;
  707. extern uint64_t stats_n_data_bytes_received;
  708. void client_dns_init(void);
  709. void client_dns_clean(void);
  710. /********************************* connection_or.c ***************************/
  711. int connection_or_process_inbuf(connection_t *conn);
  712. int connection_or_finished_flushing(connection_t *conn);
  713. void connection_or_init_conn_from_router(connection_t *conn, routerinfo_t *router);
  714. connection_t *connection_or_connect(routerinfo_t *router);
  715. int connection_tls_start_handshake(connection_t *conn, int receiving);
  716. int connection_tls_continue_handshake(connection_t *conn);
  717. void connection_or_write_cell_to_buf(const cell_t *cell, connection_t *conn);
  718. /********************************* cpuworker.c *****************************/
  719. void cpu_init(void);
  720. int connection_cpu_finished_flushing(connection_t *conn);
  721. int connection_cpu_process_inbuf(connection_t *conn);
  722. int cpuworker_main(void *data);
  723. int assign_to_cpuworker(connection_t *cpuworker, unsigned char question_type,
  724. void *task);
  725. /********************************* directory.c ***************************/
  726. void directory_initiate_command(routerinfo_t *router, int purpose,
  727. const char *payload, int payload_len);
  728. int connection_dir_process_inbuf(connection_t *conn);
  729. int connection_dir_finished_flushing(connection_t *conn);
  730. /********************************* dns.c ***************************/
  731. void dns_init(void);
  732. int connection_dns_finished_flushing(connection_t *conn);
  733. int connection_dns_process_inbuf(connection_t *conn);
  734. void connection_dns_remove(connection_t *conn);
  735. void assert_connection_edge_not_dns_pending(connection_t *conn);
  736. void dns_cancel_pending_resolve(char *question);
  737. int dns_resolve(connection_t *exitconn);
  738. /********************************* main.c ***************************/
  739. int connection_add(connection_t *conn);
  740. int connection_remove(connection_t *conn);
  741. void connection_set_poll_socket(connection_t *conn);
  742. void get_connection_array(connection_t ***array, int *n);
  743. void connection_watch_events(connection_t *conn, short events);
  744. int connection_is_reading(connection_t *conn);
  745. void connection_stop_reading(connection_t *conn);
  746. void connection_start_reading(connection_t *conn);
  747. int connection_is_writing(connection_t *conn);
  748. void connection_stop_writing(connection_t *conn);
  749. void connection_start_writing(connection_t *conn);
  750. void directory_has_arrived(void);
  751. int main(int argc, char *argv[]);
  752. /********************************* onion.c ***************************/
  753. int decide_circ_id_type(char *local_nick, char *remote_nick);
  754. int onion_pending_add(circuit_t *circ);
  755. circuit_t *onion_next_task(void);
  756. void onion_pending_remove(circuit_t *circ);
  757. int onionskin_answer(circuit_t *circ, unsigned char *payload, unsigned char *keys);
  758. void onion_append_to_cpath(crypt_path_t **head_ptr, crypt_path_t *new_hop);
  759. int onion_extend_cpath(crypt_path_t **head_ptr, cpath_build_state_t *state,
  760. routerinfo_t **router_out);
  761. int onion_skin_create(crypto_pk_env_t *router_key,
  762. crypto_dh_env_t **handshake_state_out,
  763. char *onion_skin_out);
  764. int onion_skin_server_handshake(char *onion_skin,
  765. crypto_pk_env_t *private_key,
  766. char *handshake_reply_out,
  767. char *key_out,
  768. int key_out_len);
  769. int onion_skin_client_handshake(crypto_dh_env_t *handshake_state,
  770. char *handshake_reply,
  771. char *key_out,
  772. int key_out_len);
  773. cpath_build_state_t *onion_new_cpath_build_state(uint8_t purpose,
  774. const char *exit_nickname);
  775. /********************************* router.c ***************************/
  776. void set_onion_key(crypto_pk_env_t *k);
  777. crypto_pk_env_t *get_onion_key(void);
  778. void set_identity_key(crypto_pk_env_t *k);
  779. crypto_pk_env_t *get_identity_key(void);
  780. crypto_pk_env_t *get_link_key(void);
  781. int init_keys(void);
  782. crypto_pk_env_t *init_key_from_file(const char *fname);
  783. void router_retry_connections(void);
  784. void router_upload_dir_desc_to_dirservers(void);
  785. void router_post_to_dirservers(uint8_t purpose, const char *payload, int payload_len);
  786. int router_compare_to_my_exit_policy(connection_t *conn);
  787. const char *router_get_my_descriptor(void);
  788. int router_rebuild_descriptor(void);
  789. int router_dump_router_to_string(char *s, int maxlen, routerinfo_t *router,
  790. crypto_pk_env_t *ident_key);
  791. /********************************* routerlist.c ***************************/
  792. routerinfo_t *router_pick_directory_server(void);
  793. routerinfo_t *router_choose_random_node(routerlist_t *dir,
  794. char *preferred, char *excluded,
  795. smartlist_t *excludedsmartlist);
  796. routerinfo_t *router_get_by_addr_port(uint32_t addr, uint16_t port);
  797. routerinfo_t *router_get_by_link_pk(crypto_pk_env_t *pk);
  798. routerinfo_t *router_get_by_nickname(char *nickname);
  799. void router_get_routerlist(routerlist_t **prouterlist);
  800. void routerinfo_free(routerinfo_t *router);
  801. void router_mark_as_down(char *nickname);
  802. int router_set_routerlist_from_file(char *routerfile);
  803. int router_set_routerlist_from_string(const char *s);
  804. int router_get_dir_hash(const char *s, char *digest);
  805. int router_get_router_hash(const char *s, char *digest);
  806. int router_set_routerlist_from_directory(const char *s, crypto_pk_env_t *pkey);
  807. routerinfo_t *router_get_entry_from_string(const char *s, const char *end);
  808. int router_add_exit_policy_from_string(routerinfo_t *router, const char *s);
  809. int router_compare_addr_to_exit_policy(uint32_t addr, uint16_t port,
  810. struct exit_policy_t *policy);
  811. #define ADDR_POLICY_ACCEPTED 0
  812. #define ADDR_POLICY_REJECTED -1
  813. #define ADDR_POLICY_UNKNOWN 1
  814. int router_exit_policy_all_routers_reject(uint32_t addr, uint16_t port);
  815. int router_exit_policy_rejects_all(routerinfo_t *router);
  816. /********************************* dirserv.c ***************************/
  817. int dirserv_add_own_fingerprint(const char *nickname, crypto_pk_env_t *pk);
  818. int dirserv_parse_fingerprint_file(const char *fname);
  819. int dirserv_router_fingerprint_is_known(const routerinfo_t *router);
  820. void dirserv_free_fingerprint_list();
  821. int dirserv_add_descriptor(const char **desc);
  822. int dirserv_init_from_directory_string(const char *dir);
  823. void dirserv_free_descriptors();
  824. int dirserv_dump_directory_to_string(char *s, int maxlen,
  825. crypto_pk_env_t *private_key);
  826. void directory_set_dirty(void);
  827. size_t dirserv_get_directory(const char **cp);
  828. void dirserv_remove_old_servers(void);
  829. /********************************* rephist.c ***************************/
  830. void rep_hist_init(void);
  831. void rep_hist_note_connect_failed(const char* nickname, time_t when);
  832. void rep_hist_note_connect_succeeded(const char* nickname, time_t when);
  833. void rep_hist_note_disconnect(const char* nickname, time_t when);
  834. void rep_hist_note_connection_died(const char* nickname, time_t when);
  835. void rep_hist_note_extend_succeeded(const char *from_name,
  836. const char *to_name);
  837. void rep_hist_note_extend_failed(const char *from_name, const char *to_name);
  838. void rep_hist_dump_stats(time_t now, int severity);
  839. /********************************* rendclient.c ***************************/
  840. void rend_client_desc_fetched(char *query);
  841. void rend_client_desc_not_fetched(char *query);
  842. /********************************* rendcommon.c ***************************/
  843. typedef struct rend_service_descriptor_t {
  844. crypto_pk_env_t *pk;
  845. time_t timestamp;
  846. int n_intro_points;
  847. char **intro_points;
  848. } rend_service_descriptor_t;
  849. void rend_service_descriptor_free(rend_service_descriptor_t *desc);
  850. int rend_encode_service_descriptor(rend_service_descriptor_t *desc,
  851. crypto_pk_env_t *key,
  852. char **str_out,
  853. int *len_out);
  854. rend_service_descriptor_t *rend_parse_service_descriptor(const char *str, int len);
  855. int rend_get_service_id(crypto_pk_env_t *pk, char *out);
  856. int rend_cmp_service_ids(char *one, char *two);
  857. void rend_cache_init(void);
  858. void rend_cache_clean(void);
  859. int rend_cache_lookup(char *query, const char **desc, int *desc_len);
  860. int rend_cache_store(char *desc, int desc_len);
  861. int rend_parse_rendezvous_address(char *address);
  862. /********************************* rendservice.c ***************************/
  863. int rend_config_services(or_options_t *options);
  864. int rend_service_init_keys(void);
  865. int rend_services_init(void);
  866. void rend_service_intro_is_ready(circuit_t *circuit);
  867. void rend_service_rendezvous_is_ready(circuit_t *circuit);
  868. #endif
  869. /*
  870. Local Variables:
  871. mode:c
  872. indent-tabs-mode:nil
  873. c-basic-offset:2
  874. End:
  875. */