tor  master
or.h
Go to the documentation of this file.
1 /* Copyright (c) 2001 Matej Pfajfar.
2  * Copyright (c) 2001-2004, Roger Dingledine.
3  * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
4  * Copyright (c) 2007-2017, The Tor Project, Inc. */
5 /* See LICENSE for licensing information */
6 
12 #ifndef TOR_OR_H
13 #define TOR_OR_H
14 
15 #include "orconfig.h"
16 
17 #ifdef HAVE_UNISTD_H
18 #include <unistd.h>
19 #endif
20 #ifdef HAVE_SIGNAL_H
21 #include <signal.h>
22 #endif
23 #ifdef HAVE_NETDB_H
24 #include <netdb.h>
25 #endif
26 #ifdef HAVE_SYS_PARAM_H
27 #include <sys/param.h> /* FreeBSD needs this to know what version it is */
28 #endif
29 #include "torint.h"
30 #ifdef HAVE_SYS_FCNTL_H
31 #include <sys/fcntl.h>
32 #endif
33 #ifdef HAVE_FCNTL_H
34 #include <fcntl.h>
35 #endif
36 #ifdef HAVE_SYS_IOCTL_H
37 #include <sys/ioctl.h>
38 #endif
39 #ifdef HAVE_SYS_UN_H
40 #include <sys/un.h>
41 #endif
42 #ifdef HAVE_SYS_STAT_H
43 #include <sys/stat.h>
44 #endif
45 #ifdef HAVE_NETINET_IN_H
46 #include <netinet/in.h>
47 #endif
48 #ifdef HAVE_ARPA_INET_H
49 #include <arpa/inet.h>
50 #endif
51 #ifdef HAVE_ERRNO_H
52 #include <errno.h>
53 #endif
54 #ifdef HAVE_ASSERT_H
55 #include <assert.h>
56 #endif
57 #ifdef HAVE_TIME_H
58 #include <time.h>
59 #endif
60 
61 #ifdef _WIN32
62 #include <winsock2.h>
63 #include <io.h>
64 #include <process.h>
65 #include <direct.h>
66 #include <windows.h>
67 #endif /* defined(_WIN32) */
68 
69 #include "crypto.h"
70 #include "crypto_format.h"
71 #include "tortls.h"
72 #include "torlog.h"
73 #include "container.h"
74 #include "compress.h"
75 #include "address.h"
76 #include "compat_libevent.h"
77 #include "ht.h"
78 #include "confline.h"
79 #include "replaycache.h"
80 #include "crypto_curve25519.h"
81 #include "crypto_ed25519.h"
82 #include "tor_queue.h"
83 #include "token_bucket.h"
84 #include "util_format.h"
85 #include "hs_circuitmap.h"
86 
87 /* These signals are defined to help handle_control_signal work.
88  */
89 #ifndef SIGHUP
90 #define SIGHUP 1
91 #endif
92 #ifndef SIGINT
93 #define SIGINT 2
94 #endif
95 #ifndef SIGUSR1
96 #define SIGUSR1 10
97 #endif
98 #ifndef SIGUSR2
99 #define SIGUSR2 12
100 #endif
101 #ifndef SIGTERM
102 #define SIGTERM 15
103 #endif
104 /* Controller signals start at a high number so we don't
105  * conflict with system-defined signals. */
106 #define SIGNEWNYM 129
107 #define SIGCLEARDNSCACHE 130
108 #define SIGHEARTBEAT 131
109 
110 #if (SIZEOF_CELL_T != 0)
111 /* On Irix, stdlib.h defines a cell_t type, so we need to make sure
112  * that our stuff always calls cell_t something different. */
113 #define cell_t tor_cell_t
114 #endif
115 
116 #ifdef ENABLE_TOR2WEB_MODE
117 #define NON_ANONYMOUS_MODE_ENABLED 1
118 #endif
119 
121 #define DOWNCAST(to, ptr) ((to*)SUBTYPE_P(ptr, to, base_))
122 
124 #define MAX_NICKNAME_LEN 19
125 
127 #define MAX_HEX_NICKNAME_LEN (HEX_DIGEST_LEN+1)
128 
130 #define MAX_VERBOSE_NICKNAME_LEN (1+HEX_DIGEST_LEN+1+MAX_NICKNAME_LEN)
131 
133 #define MAX_BUF_SIZE ((1<<24)-1) /* 16MB-1 */
134 
135 #define MAX_DIR_DL_SIZE MAX_BUF_SIZE
136 
139 #define MAX_HEADERS_SIZE 50000
140 
142 #define MAX_DIR_UL_SIZE MAX_BUF_SIZE
143 
147 #define MAX_DESCRIPTOR_UPLOAD_SIZE 20000
148 
150 #define MAX_EXTRAINFO_UPLOAD_SIZE 50000
151 
153 #define MIN_ONION_KEY_LIFETIME_DAYS (1)
154 
156 #define MAX_ONION_KEY_LIFETIME_DAYS (90)
157 
159 #define DEFAULT_ONION_KEY_LIFETIME_DAYS (28)
160 
164 #define MIN_ONION_KEY_GRACE_PERIOD_DAYS (1)
165 
167 #define DEFAULT_ONION_KEY_GRACE_PERIOD_DAYS (7)
168 
171 #define ONION_KEY_CONSENSUS_CHECK_INTERVAL (60*60)
172 
174 #define MAX_SSL_KEY_LIFETIME_INTERNAL (2*60*60)
175 
178 #define ROUTER_MAX_AGE (60*60*48)
179 
181 #define ROUTER_MAX_AGE_TO_PUBLISH (60*60*24)
182 
183 #define OLD_ROUTER_DESC_MAX_AGE (60*60*24*5)
184 
186 typedef enum {
193 #define circ_id_type_bitfield_t ENUM_BF(circ_id_type_t)
194 
195 #define CONN_TYPE_MIN_ 3
196 
197 #define CONN_TYPE_OR_LISTENER 3
198 
200 #define CONN_TYPE_OR 4
201 
202 #define CONN_TYPE_EXIT 5
203 
204 #define CONN_TYPE_AP_LISTENER 6
205 
207 #define CONN_TYPE_AP 7
208 
209 #define CONN_TYPE_DIR_LISTENER 8
210 
211 #define CONN_TYPE_DIR 9
212 /* Type 10 is unused. */
214 #define CONN_TYPE_CONTROL_LISTENER 11
215 
216 #define CONN_TYPE_CONTROL 12
217 
219 #define CONN_TYPE_AP_TRANS_LISTENER 13
220 
222 #define CONN_TYPE_AP_NATD_LISTENER 14
223 
224 #define CONN_TYPE_AP_DNS_LISTENER 15
225 
227 #define CONN_TYPE_EXT_OR 16
228 
229 #define CONN_TYPE_EXT_OR_LISTENER 17
230 
231 #define CONN_TYPE_AP_HTTP_CONNECT_LISTENER 18
232 
233 #define CONN_TYPE_MAX_ 19
234 /* !!!! If _CONN_TYPE_MAX is ever over 31, we must grow the type field in
235  * connection_t. */
236 
237 /* Proxy client types */
238 #define PROXY_NONE 0
239 #define PROXY_CONNECT 1
240 #define PROXY_SOCKS4 2
241 #define PROXY_SOCKS5 3
242 /* !!!! If there is ever a PROXY_* type over 3, we must grow the proxy_type
243  * field in or_connection_t */
244 
245 /* Pluggable transport proxy type. Don't use this in or_connection_t,
246  * instead use the actual underlying proxy type (see above). */
247 #define PROXY_PLUGGABLE 4
248 
249 /* Proxy client handshake states */
250 /* We use a proxy but we haven't even connected to it yet. */
251 #define PROXY_INFANT 1
252 /* We use an HTTP proxy and we've sent the CONNECT command. */
253 #define PROXY_HTTPS_WANT_CONNECT_OK 2
254 /* We use a SOCKS4 proxy and we've sent the CONNECT command. */
255 #define PROXY_SOCKS4_WANT_CONNECT_OK 3
256 /* We use a SOCKS5 proxy and we try to negotiate without
257  any authentication . */
258 #define PROXY_SOCKS5_WANT_AUTH_METHOD_NONE 4
259 /* We use a SOCKS5 proxy and we try to negotiate with
260  Username/Password authentication . */
261 #define PROXY_SOCKS5_WANT_AUTH_METHOD_RFC1929 5
262 /* We use a SOCKS5 proxy and we just sent our credentials. */
263 #define PROXY_SOCKS5_WANT_AUTH_RFC1929_OK 6
264 /* We use a SOCKS5 proxy and we just sent our CONNECT command. */
265 #define PROXY_SOCKS5_WANT_CONNECT_OK 7
266 /* We use a proxy and we CONNECTed successfully!. */
267 #define PROXY_CONNECTED 8
268 
270 #define CONN_IS_EDGE(x) \
271  ((x)->type == CONN_TYPE_EXIT || (x)->type == CONN_TYPE_AP)
272 
274 #define LISTENER_STATE_READY 0
275 
276 #define OR_CONN_STATE_MIN_ 1
277 
278 #define OR_CONN_STATE_CONNECTING 1
279 
280 #define OR_CONN_STATE_PROXY_HANDSHAKING 2
281 
283 #define OR_CONN_STATE_TLS_HANDSHAKING 3
284 
286 #define OR_CONN_STATE_TLS_CLIENT_RENEGOTIATING 4
287 
290 #define OR_CONN_STATE_TLS_SERVER_RENEGOTIATING 5
291 
294 #define OR_CONN_STATE_OR_HANDSHAKING_V2 6
295 
298 #define OR_CONN_STATE_OR_HANDSHAKING_V3 7
299 
300 #define OR_CONN_STATE_OPEN 8
301 #define OR_CONN_STATE_MAX_ 8
302 
305 #define EXT_OR_CONN_STATE_MIN_ 1
306 
308 #define EXT_OR_CONN_STATE_AUTH_WAIT_AUTH_TYPE 1
309 
310 #define EXT_OR_CONN_STATE_AUTH_WAIT_CLIENT_NONCE 2
311 
312 #define EXT_OR_CONN_STATE_AUTH_WAIT_CLIENT_HASH 3
313 #define EXT_OR_CONN_STATE_AUTH_MAX 3
314 
316 #define EXT_OR_CONN_STATE_OPEN 4
317 
319 #define EXT_OR_CONN_STATE_FLUSHING 5
320 #define EXT_OR_CONN_STATE_MAX_ 5
321 
322 #define EXIT_CONN_STATE_MIN_ 1
323 
324 #define EXIT_CONN_STATE_RESOLVING 1
325 
326 #define EXIT_CONN_STATE_CONNECTING 2
327 
328 #define EXIT_CONN_STATE_OPEN 3
329 
330 #define EXIT_CONN_STATE_RESOLVEFAILED 4
331 #define EXIT_CONN_STATE_MAX_ 4
332 
333 /* The AP state values must be disjoint from the EXIT state values. */
334 #define AP_CONN_STATE_MIN_ 5
335 
336 #define AP_CONN_STATE_SOCKS_WAIT 5
337 
339 #define AP_CONN_STATE_RENDDESC_WAIT 6
340 
342 #define AP_CONN_STATE_CONTROLLER_WAIT 7
343 
344 #define AP_CONN_STATE_CIRCUIT_WAIT 8
345 
346 #define AP_CONN_STATE_CONNECT_WAIT 9
347 
348 #define AP_CONN_STATE_RESOLVE_WAIT 10
349 
350 #define AP_CONN_STATE_OPEN 11
351 
353 #define AP_CONN_STATE_NATD_WAIT 12
354 
355 #define AP_CONN_STATE_HTTP_CONNECT_WAIT 13
356 #define AP_CONN_STATE_MAX_ 13
357 
360 #define AP_CONN_STATE_IS_UNATTACHED(s) \
361  ((s) <= AP_CONN_STATE_CIRCUIT_WAIT || (s) == AP_CONN_STATE_NATD_WAIT)
362 
363 #define DIR_CONN_STATE_MIN_ 1
364 
365 #define DIR_CONN_STATE_CONNECTING 1
366 
367 #define DIR_CONN_STATE_CLIENT_SENDING 2
368 
369 #define DIR_CONN_STATE_CLIENT_READING 3
370 
371 #define DIR_CONN_STATE_CLIENT_FINISHED 4
372 
373 #define DIR_CONN_STATE_SERVER_COMMAND_WAIT 5
374 
375 #define DIR_CONN_STATE_SERVER_WRITING 6
376 #define DIR_CONN_STATE_MAX_ 6
377 
380 #define DIR_CONN_IS_SERVER(conn) ((conn)->purpose == DIR_PURPOSE_SERVER)
381 
382 #define CONTROL_CONN_STATE_MIN_ 1
383 
384 #define CONTROL_CONN_STATE_OPEN 1
385 
387 #define CONTROL_CONN_STATE_NEEDAUTH 2
388 #define CONTROL_CONN_STATE_MAX_ 2
389 
390 #define DIR_PURPOSE_MIN_ 4
391 
393 #define DIR_PURPOSE_HAS_FETCHED_RENDDESC_V2 4
394 
396 #define DIR_PURPOSE_FETCH_SERVERDESC 6
397 
399 #define DIR_PURPOSE_FETCH_EXTRAINFO 7
400 
401 #define DIR_PURPOSE_UPLOAD_DIR 8
402 
403 #define DIR_PURPOSE_UPLOAD_VOTE 10
404 
405 #define DIR_PURPOSE_UPLOAD_SIGNATURES 11
406 
408 #define DIR_PURPOSE_FETCH_STATUS_VOTE 12
409 
411 #define DIR_PURPOSE_FETCH_DETACHED_SIGNATURES 13
412 
414 #define DIR_PURPOSE_FETCH_CONSENSUS 14
415 
417 #define DIR_PURPOSE_FETCH_CERTIFICATE 15
418 
420 #define DIR_PURPOSE_SERVER 16
421 
423 #define DIR_PURPOSE_UPLOAD_RENDDESC_V2 17
424 
426 #define DIR_PURPOSE_FETCH_RENDDESC_V2 18
427 
428 #define DIR_PURPOSE_FETCH_MICRODESC 19
429 
430 #define DIR_PURPOSE_UPLOAD_HSDESC 20
431 
432 #define DIR_PURPOSE_FETCH_HSDESC 21
433 
435 #define DIR_PURPOSE_HAS_FETCHED_HSDESC 22
436 #define DIR_PURPOSE_MAX_ 22
437 
440 #define DIR_PURPOSE_IS_UPLOAD(p) \
441  ((p)==DIR_PURPOSE_UPLOAD_DIR || \
442  (p)==DIR_PURPOSE_UPLOAD_VOTE || \
443  (p)==DIR_PURPOSE_UPLOAD_SIGNATURES || \
444  (p)==DIR_PURPOSE_UPLOAD_RENDDESC_V2 || \
445  (p)==DIR_PURPOSE_UPLOAD_HSDESC)
446 
447 #define EXIT_PURPOSE_MIN_ 1
448 
449 #define EXIT_PURPOSE_CONNECT 1
450 
451 #define EXIT_PURPOSE_RESOLVE 2
452 #define EXIT_PURPOSE_MAX_ 2
453 
454 /* !!!! If any connection purpose is ever over 31, we must grow the type
455  * field in connection_t. */
456 
458 #define CIRCUIT_STATE_BUILDING 0
459 
460 #define CIRCUIT_STATE_ONIONSKIN_PENDING 1
461 
463 #define CIRCUIT_STATE_CHAN_WAIT 2
464 
467 #define CIRCUIT_STATE_GUARD_WAIT 3
468 
469 #define CIRCUIT_STATE_OPEN 4
470 
471 #define CIRCUIT_PURPOSE_MIN_ 1
472 
473 /* these circuits were initiated elsewhere */
474 #define CIRCUIT_PURPOSE_OR_MIN_ 1
475 
476 #define CIRCUIT_PURPOSE_OR 1
477 
479 #define CIRCUIT_PURPOSE_INTRO_POINT 2
480 
482 #define CIRCUIT_PURPOSE_REND_POINT_WAITING 3
483 
484 #define CIRCUIT_PURPOSE_REND_ESTABLISHED 4
485 #define CIRCUIT_PURPOSE_OR_MAX_ 4
486 
487 /* these circuits originate at this node */
488 
489 /* here's how circ client-side purposes work:
490  * normal circuits are C_GENERAL.
491  * circuits that are c_introducing are either on their way to
492  * becoming open, or they are open and waiting for a
493  * suitable rendcirc before they send the intro.
494  * circuits that are c_introduce_ack_wait have sent the intro,
495  * but haven't gotten a response yet.
496  * circuits that are c_establish_rend are either on their way
497  * to becoming open, or they are open and have sent the
498  * establish_rendezvous cell but haven't received an ack.
499  * circuits that are c_rend_ready are open and have received a
500  * rend ack, but haven't heard from the service yet. if they have a
501  * buildstate->pending_final_cpath then they're expecting a
502  * cell from the service, else they're not.
503  * circuits that are c_rend_ready_intro_acked are open, and
504  * some intro circ has sent its intro and received an ack.
505  * circuits that are c_rend_joined are open, have heard from
506  * the service, and are talking to it.
507  */
509 #define CIRCUIT_PURPOSE_C_GENERAL 5
510 #define CIRCUIT_PURPOSE_C_HS_MIN_ 6
511 
512 #define CIRCUIT_PURPOSE_C_INTRODUCING 6
513 
515 #define CIRCUIT_PURPOSE_C_INTRODUCE_ACK_WAIT 7
516 
518 #define CIRCUIT_PURPOSE_C_INTRODUCE_ACKED 8
519 
520 #define CIRCUIT_PURPOSE_C_ESTABLISH_REND 9
521 
522 #define CIRCUIT_PURPOSE_C_REND_READY 10
523 
525 #define CIRCUIT_PURPOSE_C_REND_READY_INTRO_ACKED 11
526 
527 #define CIRCUIT_PURPOSE_C_REND_JOINED 12
528 
529 #define CIRCUIT_PURPOSE_C_HSDIR_GET 13
530 #define CIRCUIT_PURPOSE_C_HS_MAX_ 13
531 
532 #define CIRCUIT_PURPOSE_C_MEASURE_TIMEOUT 14
533 #define CIRCUIT_PURPOSE_C_MAX_ 14
534 
535 #define CIRCUIT_PURPOSE_S_HS_MIN_ 15
536 
538 #define CIRCUIT_PURPOSE_S_ESTABLISH_INTRO 15
539 
541 #define CIRCUIT_PURPOSE_S_INTRO 16
542 
544 #define CIRCUIT_PURPOSE_S_CONNECT_REND 17
545 
547 #define CIRCUIT_PURPOSE_S_REND_JOINED 18
548 
549 #define CIRCUIT_PURPOSE_S_HSDIR_POST 19
550 #define CIRCUIT_PURPOSE_S_HS_MAX_ 19
551 
553 #define CIRCUIT_PURPOSE_TESTING 20
554 
555 #define CIRCUIT_PURPOSE_CONTROLLER 21
556 
557 #define CIRCUIT_PURPOSE_PATH_BIAS_TESTING 22
558 
565 #define CIRCUIT_PURPOSE_HS_VANGUARDS 23
566 
567 #define CIRCUIT_PURPOSE_MAX_ 23
568 
570 #define CIRCUIT_PURPOSE_UNKNOWN 255
571 
574 #define CIRCUIT_PURPOSE_IS_ORIGIN(p) ((p)>CIRCUIT_PURPOSE_OR_MAX_)
575 
577 #define CIRCUIT_PURPOSE_IS_CLIENT(p) \
578  ((p)> CIRCUIT_PURPOSE_OR_MAX_ && \
579  (p)<=CIRCUIT_PURPOSE_C_MAX_)
580 
581 #define CIRCUIT_IS_ORIGIN(c) (CIRCUIT_PURPOSE_IS_ORIGIN((c)->purpose))
582 
584 #define CIRCUIT_PURPOSE_IS_ESTABLISHED_REND(p) \
585  ((p) == CIRCUIT_PURPOSE_C_REND_JOINED || \
586  (p) == CIRCUIT_PURPOSE_S_REND_JOINED)
587 
588 #define CIRCUIT_IS_ORCIRC(c) (((circuit_t *)(c))->magic == OR_CIRCUIT_MAGIC)
589 
594 #define CIRCUIT_PURPOSE_COUNTS_TOWARDS_MAXPENDING(p) \
595  ((p) == CIRCUIT_PURPOSE_C_GENERAL || \
596  (p) == CIRCUIT_PURPOSE_C_HSDIR_GET)
597 
600 #define MIN_CIRCUITS_HANDLING_STREAM 2
601 
602 /* These RELAY_COMMAND constants define values for relay cell commands, and
603 * must match those defined in tor-spec.txt. */
604 #define RELAY_COMMAND_BEGIN 1
605 #define RELAY_COMMAND_DATA 2
606 #define RELAY_COMMAND_END 3
607 #define RELAY_COMMAND_CONNECTED 4
608 #define RELAY_COMMAND_SENDME 5
609 #define RELAY_COMMAND_EXTEND 6
610 #define RELAY_COMMAND_EXTENDED 7
611 #define RELAY_COMMAND_TRUNCATE 8
612 #define RELAY_COMMAND_TRUNCATED 9
613 #define RELAY_COMMAND_DROP 10
614 #define RELAY_COMMAND_RESOLVE 11
615 #define RELAY_COMMAND_RESOLVED 12
616 #define RELAY_COMMAND_BEGIN_DIR 13
617 #define RELAY_COMMAND_EXTEND2 14
618 #define RELAY_COMMAND_EXTENDED2 15
619 
620 #define RELAY_COMMAND_ESTABLISH_INTRO 32
621 #define RELAY_COMMAND_ESTABLISH_RENDEZVOUS 33
622 #define RELAY_COMMAND_INTRODUCE1 34
623 #define RELAY_COMMAND_INTRODUCE2 35
624 #define RELAY_COMMAND_RENDEZVOUS1 36
625 #define RELAY_COMMAND_RENDEZVOUS2 37
626 #define RELAY_COMMAND_INTRO_ESTABLISHED 38
627 #define RELAY_COMMAND_RENDEZVOUS_ESTABLISHED 39
628 #define RELAY_COMMAND_INTRODUCE_ACK 40
629 
630 /* Reasons why an OR connection is closed. */
631 #define END_OR_CONN_REASON_DONE 1
632 #define END_OR_CONN_REASON_REFUSED 2 /* connection refused */
633 #define END_OR_CONN_REASON_OR_IDENTITY 3
634 #define END_OR_CONN_REASON_CONNRESET 4 /* connection reset by peer */
635 #define END_OR_CONN_REASON_TIMEOUT 5
636 #define END_OR_CONN_REASON_NO_ROUTE 6 /* no route to host/net */
637 #define END_OR_CONN_REASON_IO_ERROR 7 /* read/write error */
638 #define END_OR_CONN_REASON_RESOURCE_LIMIT 8 /* sockets, buffers, etc */
639 #define END_OR_CONN_REASON_PT_MISSING 9 /* PT failed or not available */
640 #define END_OR_CONN_REASON_MISC 10
641 
642 /* Reasons why we (or a remote OR) might close a stream. See tor-spec.txt for
643  * documentation of these. The values must match. */
644 #define END_STREAM_REASON_MISC 1
645 #define END_STREAM_REASON_RESOLVEFAILED 2
646 #define END_STREAM_REASON_CONNECTREFUSED 3
647 #define END_STREAM_REASON_EXITPOLICY 4
648 #define END_STREAM_REASON_DESTROY 5
649 #define END_STREAM_REASON_DONE 6
650 #define END_STREAM_REASON_TIMEOUT 7
651 #define END_STREAM_REASON_NOROUTE 8
652 #define END_STREAM_REASON_HIBERNATING 9
653 #define END_STREAM_REASON_INTERNAL 10
654 #define END_STREAM_REASON_RESOURCELIMIT 11
655 #define END_STREAM_REASON_CONNRESET 12
656 #define END_STREAM_REASON_TORPROTOCOL 13
657 #define END_STREAM_REASON_NOTDIRECTORY 14
658 #define END_STREAM_REASON_ENTRYPOLICY 15
659 
660 /* These high-numbered end reasons are not part of the official spec,
661  * and are not intended to be put in relay end cells. They are here
662  * to be more informative when sending back socks replies to the
663  * application. */
664 /* XXXX 256 is no longer used; feel free to reuse it. */
666 /* XXXX the ways we use this one don't make a lot of sense. */
667 #define END_STREAM_REASON_CANT_ATTACH 257
668 
670 #define END_STREAM_REASON_NET_UNREACHABLE 258
671 
673 #define END_STREAM_REASON_SOCKSPROTOCOL 259
674 
676 #define END_STREAM_REASON_CANT_FETCH_ORIG_DEST 260
677 
679 #define END_STREAM_REASON_INVALID_NATD_DEST 261
680 
682 #define END_STREAM_REASON_PRIVATE_ADDR 262
683 
686 #define END_STREAM_REASON_HTTPPROTOCOL 263
687 
689 #define END_STREAM_REASON_MASK 511
690 
693 #define END_STREAM_REASON_FLAG_REMOTE 512
694 
696 #define END_STREAM_REASON_FLAG_ALREADY_SENT_CLOSED 1024
697 
700 #define END_STREAM_REASON_FLAG_ALREADY_SOCKS_REPLIED 2048
701 
704 #define REMAP_STREAM_SOURCE_CACHE 1
705 
707 #define REMAP_STREAM_SOURCE_EXIT 2
708 
709 /* 'type' values to use in RESOLVED cells. Specified in tor-spec.txt. */
710 #define RESOLVED_TYPE_HOSTNAME 0
711 #define RESOLVED_TYPE_IPV4 4
712 #define RESOLVED_TYPE_IPV6 6
713 #define RESOLVED_TYPE_ERROR_TRANSIENT 0xF0
714 #define RESOLVED_TYPE_ERROR 0xF1
715 
716 /* Negative reasons are internal: we never send them in a DESTROY or TRUNCATE
717  * call; they only go to the controller for tracking */
718 
719 /* Closing introduction point that were opened in parallel. */
720 #define END_CIRC_REASON_IP_NOW_REDUNDANT -4
721 
724 #define END_CIRC_REASON_MEASUREMENT_EXPIRED -3
725 
727 #define END_CIRC_REASON_NOPATH -2
728 
729 #define END_CIRC_AT_ORIGIN -1
730 
731 /* Reasons why we (or a remote OR) might close a circuit. See tor-spec.txt
732  * section 5.4 for documentation of these. */
733 #define END_CIRC_REASON_MIN_ 0
734 #define END_CIRC_REASON_NONE 0
735 #define END_CIRC_REASON_TORPROTOCOL 1
736 #define END_CIRC_REASON_INTERNAL 2
737 #define END_CIRC_REASON_REQUESTED 3
738 #define END_CIRC_REASON_HIBERNATING 4
739 #define END_CIRC_REASON_RESOURCELIMIT 5
740 #define END_CIRC_REASON_CONNECTFAILED 6
741 #define END_CIRC_REASON_OR_IDENTITY 7
742 #define END_CIRC_REASON_CHANNEL_CLOSED 8
743 #define END_CIRC_REASON_FINISHED 9
744 #define END_CIRC_REASON_TIMEOUT 10
745 #define END_CIRC_REASON_DESTROYED 11
746 #define END_CIRC_REASON_NOSUCHSERVICE 12
747 #define END_CIRC_REASON_MAX_ 12
748 
752 #define END_CIRC_REASON_FLAG_REMOTE 512
753 
755 #define REND_SERVICE_ID_LEN_BASE32 16
756 
758 #define REND_SERVICE_ADDRESS_LEN (16+1+5)
759 
761 #define REND_SERVICE_ID_LEN 10
762 
764 #define REND_TIME_PERIOD_V2_DESC_VALIDITY (24*60*60)
765 
768 #define REND_TIME_PERIOD_OVERLAPPING_V2_DESCS (60*60)
769 
772 #define REND_NUMBER_OF_NON_CONSECUTIVE_REPLICAS 2
773 
775 #define REND_NUMBER_OF_CONSECUTIVE_REPLICAS 3
776 
778 #define REND_DESC_ID_V2_LEN_BASE32 BASE32_DIGEST_LEN
779 
782 #define REND_SECRET_ID_PART_LEN_BASE32 BASE32_DIGEST_LEN
783 
786 #define REND_INTRO_POINT_ID_LEN_BASE32 BASE32_DIGEST_LEN
787 
790 #define REND_DESC_COOKIE_LEN 16
791 
794 #define REND_DESC_COOKIE_LEN_BASE64 22
795 
798 #define REND_BASIC_AUTH_CLIENT_ID_LEN 4
799 
803 #define REND_BASIC_AUTH_CLIENT_MULTIPLE 16
804 
807 #define REND_BASIC_AUTH_CLIENT_ENTRY_LEN (REND_BASIC_AUTH_CLIENT_ID_LEN \
808  + CIPHER_KEY_LEN)
809 
811 #define REND_DESC_MAX_SIZE (20 * 1024)
812 
815 #define REND_LEGAL_CLIENTNAME_CHARACTERS \
816  "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+-_"
817 
819 #define REND_CLIENTNAME_MAX_LEN 16
820 
823 #define REND_COOKIE_LEN DIGEST_LEN
824 
826 typedef enum rend_auth_type_t {
827  REND_NO_AUTH = 0,
828  REND_BASIC_AUTH = 1,
829  REND_STEALTH_AUTH = 2,
831 
834  uint8_t descriptor_cookie[REND_DESC_COOKIE_LEN];
835  char onion_address[REND_SERVICE_ADDRESS_LEN+1];
836  rend_auth_type_t auth_type;
838 
842 typedef struct rend_data_t {
843  /* Hidden service protocol version of this base object. */
844  uint32_t version;
845 
849 
851  char rend_cookie[REND_COOKIE_LEN];
852 
855 } rend_data_t;
856 
857 typedef struct rend_data_v2_t {
858  /* Rendezvous base data. */
859  rend_data_t base_;
860 
862  char onion_address[REND_SERVICE_ID_LEN_BASE32+1];
863 
868 
870  char descriptor_cookie[REND_DESC_COOKIE_LEN];
871 
874 
878  char desc_id_fetch[DIGEST_LEN];
879 
881  char rend_pk_digest[DIGEST_LEN];
883 
884 /* From a base rend_data_t object <b>d</d>, return the v2 object. */
885 static inline
886 rend_data_v2_t *TO_REND_DATA_V2(const rend_data_t *d)
887 {
888  tor_assert(d);
889  tor_assert(d->version == 2);
890  return DOWNCAST(rend_data_v2_t, d);
891 }
892 
893 /* Stub because we can't include hs_ident.h. */
894 struct hs_ident_edge_conn_t;
895 struct hs_ident_dir_conn_t;
896 struct hs_ident_circuit_t;
897 
898 /* Hidden service directory index used in a node_t which is set once we set
899  * the consensus. */
900 typedef struct hsdir_index_t {
901  /* HSDir index to use when fetching a descriptor. */
902  uint8_t fetch[DIGEST256_LEN];
903 
904  /* HSDir index used by services to store their first and second
905  * descriptor. The first descriptor is chronologically older than the second
906  * one and uses older TP and SRV values. */
907  uint8_t store_first[DIGEST256_LEN];
908  uint8_t store_second[DIGEST256_LEN];
909 } hsdir_index_t;
910 
914 #define REND_REPLAY_TIME_INTERVAL (5 * 60)
915 
917 typedef enum {
921 
924 #define CIRCWINDOW_START 1000
925 #define CIRCWINDOW_START_MIN 100
926 #define CIRCWINDOW_START_MAX 1000
927 
928 #define CIRCWINDOW_INCREMENT 100
929 
931 #define STREAMWINDOW_START 500
932 
933 #define STREAMWINDOW_INCREMENT 50
934 
942 #define ORCIRC_MAX_MIDDLE_CELLS (CIRCWINDOW_START_MAX*2)
943 
946 #define ORCIRC_MAX_MIDDLE_KILL_THRESH (1.1f)
947 
948 /* Cell commands. These values are defined in tor-spec.txt. */
949 #define CELL_PADDING 0
950 #define CELL_CREATE 1
951 #define CELL_CREATED 2
952 #define CELL_RELAY 3
953 #define CELL_DESTROY 4
954 #define CELL_CREATE_FAST 5
955 #define CELL_CREATED_FAST 6
956 #define CELL_VERSIONS 7
957 #define CELL_NETINFO 8
958 #define CELL_RELAY_EARLY 9
959 #define CELL_CREATE2 10
960 #define CELL_CREATED2 11
961 #define CELL_PADDING_NEGOTIATE 12
962 
963 #define CELL_VPADDING 128
964 #define CELL_CERTS 129
965 #define CELL_AUTH_CHALLENGE 130
966 #define CELL_AUTHENTICATE 131
967 #define CELL_AUTHORIZE 132
968 #define CELL_COMMAND_MAX_ 132
969 
971 #define TIMEOUT_UNTIL_UNREACHABILITY_COMPLAINT (20*60)
972 
974 #define LEGAL_NICKNAME_CHARACTERS \
975  "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
976 
979 #define DEFAULT_CLIENT_NICKNAME "client"
980 
982 #define UNNAMED_ROUTER_NICKNAME "Unnamed"
983 
985 #define SOCKS4_NETWORK_LEN 8
986 
987 /*
988  * Relay payload:
989  * Relay command [1 byte]
990  * Recognized [2 bytes]
991  * Stream ID [2 bytes]
992  * Partial SHA-1 [4 bytes]
993  * Length [2 bytes]
994  * Relay payload [498 bytes]
995  */
996 
998 #define CELL_PAYLOAD_SIZE 509
999 
1001 #define CELL_MAX_NETWORK_SIZE 514
1002 
1004 #define VAR_CELL_MAX_HEADER_SIZE 7
1005 
1006 static int get_cell_network_size(int wide_circ_ids);
1007 static inline int get_cell_network_size(int wide_circ_ids)
1008 {
1009  return wide_circ_ids ? CELL_MAX_NETWORK_SIZE : CELL_MAX_NETWORK_SIZE - 2;
1010 }
1011 static int get_var_cell_header_size(int wide_circ_ids);
1012 static inline int get_var_cell_header_size(int wide_circ_ids)
1013 {
1014  return wide_circ_ids ? VAR_CELL_MAX_HEADER_SIZE :
1016 }
1017 static int get_circ_id_size(int wide_circ_ids);
1018 static inline int get_circ_id_size(int wide_circ_ids)
1019 {
1020  return wide_circ_ids ? 4 : 2;
1021 }
1022 
1025 #define RELAY_HEADER_SIZE (1+2+2+4+2)
1026 
1027 #define RELAY_PAYLOAD_SIZE (CELL_PAYLOAD_SIZE-RELAY_HEADER_SIZE)
1028 
1030 typedef uint32_t circid_t;
1032 typedef uint16_t streamid_t;
1033 
1034 /* channel_t typedef; struct channel_s is in channel.h */
1035 
1036 typedef struct channel_s channel_t;
1037 
1038 /* channel_listener_t typedef; struct channel_listener_s is in channel.h */
1039 
1040 typedef struct channel_listener_s channel_listener_t;
1041 
1042 /* channel states for channel_t */
1043 
1044 typedef enum {
1045  /*
1046  * Closed state - channel is inactive
1047  *
1048  * Permitted transitions from:
1049  * - CHANNEL_STATE_CLOSING
1050  * Permitted transitions to:
1051  * - CHANNEL_STATE_OPENING
1052  */
1053  CHANNEL_STATE_CLOSED = 0,
1054  /*
1055  * Opening state - channel is trying to connect
1056  *
1057  * Permitted transitions from:
1058  * - CHANNEL_STATE_CLOSED
1059  * Permitted transitions to:
1060  * - CHANNEL_STATE_CLOSING
1061  * - CHANNEL_STATE_ERROR
1062  * - CHANNEL_STATE_OPEN
1063  */
1064  CHANNEL_STATE_OPENING,
1065  /*
1066  * Open state - channel is active and ready for use
1067  *
1068  * Permitted transitions from:
1069  * - CHANNEL_STATE_MAINT
1070  * - CHANNEL_STATE_OPENING
1071  * Permitted transitions to:
1072  * - CHANNEL_STATE_CLOSING
1073  * - CHANNEL_STATE_ERROR
1074  * - CHANNEL_STATE_MAINT
1075  */
1076  CHANNEL_STATE_OPEN,
1077  /*
1078  * Maintenance state - channel is temporarily offline for subclass specific
1079  * maintenance activities such as TLS renegotiation.
1080  *
1081  * Permitted transitions from:
1082  * - CHANNEL_STATE_OPEN
1083  * Permitted transitions to:
1084  * - CHANNEL_STATE_CLOSING
1085  * - CHANNEL_STATE_ERROR
1086  * - CHANNEL_STATE_OPEN
1087  */
1088  CHANNEL_STATE_MAINT,
1089  /*
1090  * Closing state - channel is shutting down
1091  *
1092  * Permitted transitions from:
1093  * - CHANNEL_STATE_MAINT
1094  * - CHANNEL_STATE_OPEN
1095  * Permitted transitions to:
1096  * - CHANNEL_STATE_CLOSED,
1097  * - CHANNEL_STATE_ERROR
1098  */
1099  CHANNEL_STATE_CLOSING,
1100  /*
1101  * Error state - channel has experienced a permanent error
1102  *
1103  * Permitted transitions from:
1104  * - CHANNEL_STATE_CLOSING
1105  * - CHANNEL_STATE_MAINT
1106  * - CHANNEL_STATE_OPENING
1107  * - CHANNEL_STATE_OPEN
1108  * Permitted transitions to:
1109  * - None
1110  */
1111  CHANNEL_STATE_ERROR,
1112  /*
1113  * Placeholder for maximum state value
1114  */
1115  CHANNEL_STATE_LAST
1116 } channel_state_t;
1117 
1118 /* channel listener states for channel_listener_t */
1119 
1120 typedef enum {
1121  /*
1122  * Closed state - channel listener is inactive
1123  *
1124  * Permitted transitions from:
1125  * - CHANNEL_LISTENER_STATE_CLOSING
1126  * Permitted transitions to:
1127  * - CHANNEL_LISTENER_STATE_LISTENING
1128  */
1129  CHANNEL_LISTENER_STATE_CLOSED = 0,
1130  /*
1131  * Listening state - channel listener is listening for incoming
1132  * connections
1133  *
1134  * Permitted transitions from:
1135  * - CHANNEL_LISTENER_STATE_CLOSED
1136  * Permitted transitions to:
1137  * - CHANNEL_LISTENER_STATE_CLOSING
1138  * - CHANNEL_LISTENER_STATE_ERROR
1139  */
1140  CHANNEL_LISTENER_STATE_LISTENING,
1141  /*
1142  * Closing state - channel listener is shutting down
1143  *
1144  * Permitted transitions from:
1145  * - CHANNEL_LISTENER_STATE_LISTENING
1146  * Permitted transitions to:
1147  * - CHANNEL_LISTENER_STATE_CLOSED,
1148  * - CHANNEL_LISTENER_STATE_ERROR
1149  */
1150  CHANNEL_LISTENER_STATE_CLOSING,
1151  /*
1152  * Error state - channel listener has experienced a permanent error
1153  *
1154  * Permitted transitions from:
1155  * - CHANNEL_STATE_CLOSING
1156  * - CHANNEL_STATE_LISTENING
1157  * Permitted transitions to:
1158  * - None
1159  */
1160  CHANNEL_LISTENER_STATE_ERROR,
1161  /*
1162  * Placeholder for maximum state value
1163  */
1164  CHANNEL_LISTENER_STATE_LAST
1165 } channel_listener_state_t;
1166 
1167 /* TLS channel stuff */
1168 
1169 typedef struct channel_tls_s channel_tls_t;
1170 
1171 /* circuitmux_t typedef; struct circuitmux_s is in circuitmux.h */
1172 
1173 typedef struct circuitmux_s circuitmux_t;
1174 
1177 typedef struct cell_t {
1179  uint8_t command;
1181  uint8_t payload[CELL_PAYLOAD_SIZE];
1182 } cell_t;
1183 
1185 typedef struct var_cell_t {
1187  uint8_t command;
1191  uint16_t payload_len;
1193  uint8_t payload[FLEXIBLE_ARRAY_MEMBER];
1194 } var_cell_t;
1195 
1197 typedef struct ext_or_cmd_t {
1198  uint16_t cmd;
1199  uint16_t len;
1200  char body[FLEXIBLE_ARRAY_MEMBER];
1201 } ext_or_cmd_t;
1202 
1204 typedef struct packed_cell_t {
1206  TOR_SIMPLEQ_ENTRY(packed_cell_t) next;
1210 } packed_cell_t;
1211 
1214 typedef struct cell_queue_t {
1216  TOR_SIMPLEQ_HEAD(cell_simpleq, packed_cell_t) head;
1217  int n;
1218 } cell_queue_t;
1219 
1221 typedef struct destroy_cell_t {
1222  TOR_SIMPLEQ_ENTRY(destroy_cell_t) next;
1223  circid_t circid;
1226  uint8_t reason;
1227 } destroy_cell_t;
1228 
1230 typedef struct destroy_cell_queue_t {
1232  TOR_SIMPLEQ_HEAD(dcell_simpleq, destroy_cell_t) head;
1233  int n;
1235 
1237 typedef struct {
1238  uint8_t command;
1239  uint16_t recognized;
1241  char integrity[4];
1242  uint16_t length;
1243 } relay_header_t;
1244 
1245 typedef struct socks_request_t socks_request_t;
1246 
1247 typedef struct entry_port_cfg_t {
1248  /* Client port types (socks, dns, trans, natd) only: */
1253  /* Socks only: */
1256  unsigned int socks_prefer_no_auth : 1;
1258  unsigned int socks_iso_keep_alive : 1;
1259 
1260  /* Client port types only: */
1261  unsigned int ipv4_traffic : 1;
1262  unsigned int ipv6_traffic : 1;
1263  unsigned int prefer_ipv6 : 1;
1264  unsigned int dns_request : 1;
1265  unsigned int onion_traffic : 1;
1266 
1271  unsigned int cache_ipv4_answers : 1;
1272  unsigned int cache_ipv6_answers : 1;
1278  unsigned int use_cached_ipv4_answers : 1;
1279  unsigned int use_cached_ipv6_answers : 1;
1283  unsigned int prefer_ipv6_virtaddr : 1;
1284 
1286 
1287 typedef struct server_port_cfg_t {
1288  /* Server port types (or, dir) only: */
1289  unsigned int no_advertise : 1;
1290  unsigned int no_listen : 1;
1291  unsigned int all_addrs : 1;
1292  unsigned int bind_ipv4_only : 1;
1293  unsigned int bind_ipv6_only : 1;
1295 
1296 /* Values for connection_t.magic: used to make sure that downcasts (casts from
1297 * connection_t to foo_connection_t) are safe. */
1298 #define BASE_CONNECTION_MAGIC 0x7C3C304Eu
1299 #define OR_CONNECTION_MAGIC 0x7D31FF03u
1300 #define EDGE_CONNECTION_MAGIC 0xF0374013u
1301 #define ENTRY_CONNECTION_MAGIC 0xbb4a5703
1302 #define DIR_CONNECTION_MAGIC 0x9988ffeeu
1303 #define CONTROL_CONNECTION_MAGIC 0x8abc765du
1304 #define LISTENER_CONNECTION_MAGIC 0x1a1ac741u
1305 
1306 struct buf_t;
1307 
1326 typedef struct connection_t {
1327  uint32_t magic;
1330  uint8_t state;
1331  unsigned int type:5;
1332  unsigned int purpose:5;
1334  /* The next fields are all one-bit booleans. Some are only applicable to
1335  * connection subtypes, but we hold them here anyway, to save space.
1336  */
1337  unsigned int read_blocked_on_bw:1;
1339  unsigned int write_blocked_on_bw:1;
1342  unsigned int hold_open_until_flushed:1;
1345  unsigned int inbuf_reached_eof:1;
1349  unsigned int in_flushed_some:1;
1353 
1354  /* For linked connections:
1355  */
1356  unsigned int linked:1;
1361  unsigned int writing_to_linked_conn:1;
1364  unsigned int active_on_link:1;
1367  unsigned int linked_conn_is_closed:1;
1368 
1370  unsigned int proxy_state:4;
1371 
1374  tor_socket_t s;
1377  struct event *read_event;
1378  struct event *write_event;
1379  struct buf_t *inbuf;
1380  struct buf_t *outbuf;
1397  uint16_t port;
1400  uint16_t marked_for_close;
1406  char *address;
1414 
1417 
1420  uint32_t n_read_conn_bw;
1421 
1425 } connection_t;
1426 
1428 typedef struct listener_connection_t {
1429  connection_t base_;
1430 
1433  struct evdns_server_port *dns_server_port;
1434 
1435  entry_port_cfg_t entry_cfg;
1436 
1438 
1440 #define OR_AUTH_CHALLENGE_LEN 32
1441 
1452 #define OR_CERT_TYPE_TLS_LINK 1
1453 
1455 #define OR_CERT_TYPE_ID_1024 2
1456 
1459 #define OR_CERT_TYPE_AUTH_1024 3
1460 /* DOCDOC */
1461 #define OR_CERT_TYPE_RSA_ED_CROSSCERT 7
1462 
1470 #define AUTHTYPE_RSA_SHA256_TLSSECRET 1
1471 
1478 #define AUTHTYPE_RSA_SHA256_RFC5705 2
1479 
1481 #define AUTHTYPE_ED25519_SHA256_RFC5705 3
1482 /*
1483  * NOTE: authchallenge_type_is_better() relies on these AUTHTYPE codes
1484  * being sorted in order of preference. If we someday add one with
1485  * a higher numerical value that we don't like as much, we should revise
1486  * authchallenge_type_is_better().
1487  */
1488 
1493 #define V3_AUTH_FIXED_PART_LEN (8+(32*6))
1494 
1496 #define V3_AUTH_BODY_LEN (V3_AUTH_FIXED_PART_LEN + 8 + 16)
1497 
1500 typedef struct or_handshake_certs_t {
1505  tor_x509_cert_t *auth_cert;
1508  tor_x509_cert_t *link_cert;
1511  tor_x509_cert_t *id_cert;
1525 
1529 typedef struct or_handshake_state_t {
1534  unsigned int started_here : 1;
1536  unsigned int received_versions : 1;
1538  unsigned int received_auth_challenge : 1;
1540  unsigned int received_certs_cell : 1;
1542  unsigned int received_authenticate : 1;
1543 
1544  /* True iff we've received valid authentication to some identity. */
1545  unsigned int authenticated : 1;
1546  unsigned int authenticated_rsa : 1;
1547  unsigned int authenticated_ed25519 : 1;
1548 
1549  /* True iff we have sent a netinfo cell */
1550  unsigned int sent_netinfo : 1;
1551 
1557 
1567  unsigned int digest_sent_data : 1;
1568  unsigned int digest_received_data : 1;
1573  uint8_t authenticated_rsa_peer_id[DIGEST_LEN];
1577 
1584  crypto_digest_t *digest_received;
1592 
1594 #define EXT_OR_CONN_ID_LEN DIGEST_LEN /* 20 */
1595 /*
1596  * OR_CONN_HIGHWATER and OR_CONN_LOWWATER moved from connection_or.c so
1597  * channeltls.c can see them too.
1598  */
1599 
1602 #define OR_CONN_HIGHWATER (32*1024)
1603 
1606 #define OR_CONN_LOWWATER (16*1024)
1607 
1610 typedef struct or_connection_t {
1611  connection_t base_;
1612 
1615  char identity_digest[DIGEST_LEN];
1616 
1629 
1630  char *nickname;
1632  tor_tls_t *tls;
1637  /* Channel using this connection */
1638  channel_tls_t *chan;
1639 
1650  unsigned int is_canonical:1;
1651 
1653  unsigned int is_outgoing:1;
1654  unsigned int proxy_type:2;
1655  unsigned int wide_circ_ids:1;
1662  unsigned int tracked_for_dos_mitigation : 1;
1663 
1664  uint16_t link_proto;
1666  uint16_t idle_timeout;
1678  /*
1679  * Count the number of bytes flushed out on this orconn, and the number of
1680  * bytes TLS actually sent - used for overhead estimation for scheduling.
1681  */
1682  uint64_t bytes_xmitted, bytes_xmitted_by_tls;
1683 } or_connection_t;
1684 
1687 typedef struct edge_connection_t {
1688  connection_t base_;
1689 
1705 
1706  /* Hidden service connection identifier for edge connections. Used by the HS
1707  * client-side code to identify client SOCKS connections and by the
1708  * service-side code to match HS circuits with their streams. */
1709  struct hs_ident_edge_conn_t *hs_ident;
1710 
1711  uint32_t address_ttl;
1713  uint32_t begincell_flags;
1720  uint16_t end_reason;
1721 
1723  uint32_t n_read;
1724 
1726  uint32_t n_written;
1727 
1729  unsigned int is_dns_request:1;
1731  unsigned int is_reverse_dns_lookup:1;
1732 
1733  unsigned int edge_has_sent_end:1;
1739  unsigned int edge_blocked_on_circ:1;
1740 
1744  uint64_t dirreq_id;
1746 
1749 typedef struct entry_connection_t {
1750  edge_connection_t edge_;
1751 
1753  /* XXX prop220: we need to make chosen_exit_name able to encode Ed IDs too.
1754  * That's logically part of the UI parts for prop220 though. */
1756 
1760  /* === Isolation related, AP only. === */
1761  entry_port_cfg_t entry_cfg;
1763  unsigned nym_epoch;
1764 
1767  /* Other fields to isolate on already exist. The ClientAddr is addr. The
1768  ClientProtocol is a combination of type and socks_request->
1769  socks_version. SocksAuth is socks_request->username/password.
1770  DestAddr is in socks_request->address. */
1771 
1776 
1781  /* For AP connections only: buffer for data that we previously sent
1782  * optimistically which we are currently re-sending as we retry this
1783  * connection. */
1784  struct buf_t *sending_optimistic_data;
1785 
1788  struct evdns_server_request *dns_server_request;
1789 
1790 #define DEBUGGING_17659
1791 
1792 #ifdef DEBUGGING_17659
1793  uint16_t marked_pending_circ_line;
1794  const char *marked_pending_circ_file;
1795 #endif
1796 
1797 #define NUM_CIRCUITS_LAUNCHED_THRESHOLD 10
1798 
1802  unsigned int num_circuits_launched:4;
1803 
1806  unsigned int want_onehop:1;
1809  unsigned int use_begindir:1;
1810 
1813  unsigned int chosen_exit_optional:1;
1818  unsigned int chosen_exit_retries:3;
1819 
1822  unsigned int is_transparent_ap:1;
1823 
1828  unsigned int may_use_optimistic_data : 1;
1830 
1833 typedef struct dir_connection_t {
1834  connection_t base_;
1835 
1843  unsigned int dirconn_direct:1;
1848 
1854 
1857 
1858  /* Hidden service connection identifier for dir connections: Used by HS
1859  client-side code to fetch HS descriptors, and by the service-side code to
1860  upload descriptors. */
1861  struct hs_ident_dir_conn_t *hs_ident;
1862 
1865  struct circuit_guard_state_t *guard_state;
1866 
1867  char identity_digest[DIGEST_LEN];
1873  uint64_t dirreq_id;
1874 
1875 #ifdef MEASUREMENTS_21206
1876 
1877  uint32_t data_cells_received;
1878 
1880  uint32_t data_cells_sent;
1881 #endif /* defined(MEASUREMENTS_21206) */
1883 
1885 typedef struct control_connection_t {
1886  connection_t base_;
1887 
1888  uint64_t event_mask;
1893  unsigned int have_sent_protocolinfo:1;
1897 
1900 
1906 
1915 
1917 #define TO_CONN(c) (&(((c)->base_)))
1918 
1920 #define ENTRY_TO_EDGE_CONN(c) (&(((c))->edge_))
1921 
1922 #define ENTRY_TO_CONN(c) (TO_CONN(ENTRY_TO_EDGE_CONN(c)))
1923 
1926 static or_connection_t *TO_OR_CONN(connection_t *);
1929 static dir_connection_t *TO_DIR_CONN(connection_t *);
1932 static edge_connection_t *TO_EDGE_CONN(connection_t *);
1935 static entry_connection_t *TO_ENTRY_CONN(connection_t *);
1938 static entry_connection_t *EDGE_TO_ENTRY_CONN(edge_connection_t *);
1941 static control_connection_t *TO_CONTROL_CONN(connection_t *);
1944 static listener_connection_t *TO_LISTENER_CONN(connection_t *);
1945 
1946 static inline or_connection_t *TO_OR_CONN(connection_t *c)
1947 {
1948  tor_assert(c->magic == OR_CONNECTION_MAGIC);
1949  return DOWNCAST(or_connection_t, c);
1950 }
1951 static inline dir_connection_t *TO_DIR_CONN(connection_t *c)
1952 {
1953  tor_assert(c->magic == DIR_CONNECTION_MAGIC);
1954  return DOWNCAST(dir_connection_t, c);
1955 }
1956 static inline edge_connection_t *TO_EDGE_CONN(connection_t *c)
1957 {
1958  tor_assert(c->magic == EDGE_CONNECTION_MAGIC ||
1959  c->magic == ENTRY_CONNECTION_MAGIC);
1960  return DOWNCAST(edge_connection_t, c);
1961 }
1962 static inline entry_connection_t *TO_ENTRY_CONN(connection_t *c)
1963 {
1964  tor_assert(c->magic == ENTRY_CONNECTION_MAGIC);
1965  return (entry_connection_t*) SUBTYPE_P(c, entry_connection_t, edge_.base_);
1966 }
1967 static inline entry_connection_t *EDGE_TO_ENTRY_CONN(edge_connection_t *c)
1968 {
1969  tor_assert(c->base_.magic == ENTRY_CONNECTION_MAGIC);
1970  return (entry_connection_t*) SUBTYPE_P(c, entry_connection_t, edge_);
1971 }
1972 static inline control_connection_t *TO_CONTROL_CONN(connection_t *c)
1973 {
1974  tor_assert(c->magic == CONTROL_CONNECTION_MAGIC);
1975  return DOWNCAST(control_connection_t, c);
1976 }
1977 static inline listener_connection_t *TO_LISTENER_CONN(connection_t *c)
1978 {
1979  tor_assert(c->magic == LISTENER_CONNECTION_MAGIC);
1980  return DOWNCAST(listener_connection_t, c);
1981 }
1982 
1984 typedef enum {
1985  ADDR_POLICY_ACCEPT=1,
1986  ADDR_POLICY_REJECT=2,
1988 #define addr_policy_action_bitfield_t ENUM_BF(addr_policy_action_t)
1989 
1991 typedef struct addr_policy_t {
1992  int refcnt;
1994  addr_policy_action_bitfield_t policy_type:2;
1995  unsigned int is_private:1;
1997  unsigned int is_canonical:1;
2012  uint16_t prt_min;
2013  uint16_t prt_max;
2014 } addr_policy_t;
2015 
2018 typedef struct cached_dir_t {
2019  char *dir;
2021  size_t dir_len;
2023  time_t published;
2026  uint8_t digest_sha3_as_signed[DIGEST256_LEN];
2027  int refcnt;
2028 } cached_dir_t;
2029 
2032 typedef enum {
2042  /* FFFF (We could also mmap the file and grow the mmap as needed, or
2043  * lazy-load the descriptor text by using seek and read. We don't, for
2044  * now.)
2045  */
2048 #define saved_location_bitfield_t ENUM_BF(saved_location_t)
2049 
2052 typedef enum {
2053  DL_SCHED_GENERIC = 0,
2054  DL_SCHED_CONSENSUS = 1,
2055  DL_SCHED_BRIDGE = 2,
2057 #define download_schedule_bitfield_t ENUM_BF(download_schedule_t)
2058 
2064 typedef enum {
2065  DL_WANT_ANY_DIRSERVER = 0,
2066  DL_WANT_AUTHORITY = 1,
2068 #define download_want_authority_bitfield_t \
2069  ENUM_BF(download_want_authority_t)
2070 
2074 typedef enum {
2075  DL_SCHED_INCREMENT_FAILURE = 0,
2076  DL_SCHED_INCREMENT_ATTEMPT = 1,
2078 #define download_schedule_increment_bitfield_t \
2079  ENUM_BF(download_schedule_increment_t)
2080 
2107 typedef struct download_status_t {
2115  download_schedule_bitfield_t schedule : 8;
2119  download_want_authority_bitfield_t want_authority : 1;
2124  download_schedule_increment_bitfield_t increment_on : 1;
2134 
2136 #define IMPOSSIBLE_TO_DOWNLOAD 255
2137 
2141 #define ROUTER_ANNOTATION_BUF_LEN 256
2142 
2144 typedef struct signed_descriptor_t {
2155  char signed_descriptor_digest[DIGEST_LEN];
2157  char identity_digest[DIGEST_LEN];
2161  char extra_info_digest[DIGEST_LEN];
2163  char extra_info_digest256[DIGEST256_LEN];
2170  saved_location_t saved_location;
2180  /* If true, we do not ever try to save this object in the cache. */
2181  unsigned int do_not_cache : 1;
2182  /* If true, this item is meant to represent an extrainfo. */
2183  unsigned int is_extrainfo : 1;
2184  /* If true, we got an extrainfo for this item, and the digest was right,
2185  * but it was incompatible. */
2186  unsigned int extrainfo_is_bogus : 1;
2187  /* If true, we are willing to transmit this item unencrypted. */
2188  unsigned int send_unencrypted : 1;
2190 
2192 typedef int16_t country_t;
2193 
2199  unsigned int protocols_known:1;
2200 
2203  unsigned int supports_extend2_cells:1;
2204 
2209 
2214 
2218  unsigned int supports_ed25519_hs_intro : 1;
2219 
2223  unsigned int supports_v3_hsdir : 1;
2224 
2230 
2232 typedef struct {
2233  signed_descriptor_t cache_info;
2234  char *nickname;
2236  uint32_t addr;
2237  uint16_t or_port;
2238  uint16_t dir_port;
2241  /* XXXXX187 Actually these should probably be part of a list of addresses,
2242  * not just a special case. Use abstractions to access these; don't do it
2243  * directly. */
2245  uint16_t ipv6_orport;
2246 
2254 
2255  char *platform;
2260  /* link info */
2261  uint32_t bandwidthrate;
2263  uint32_t bandwidthburst;
2271  long uptime;
2275  unsigned int is_hibernating:1;
2277  unsigned int caches_extra_info:1;
2279  unsigned int allow_single_hop_exits:1;
2282  unsigned int wants_to_be_hs_dir:1;
2284  unsigned int policy_is_reject_star:1;
2288  unsigned int needs_retest_if_added:1;
2289 
2294 
2297  unsigned int omit_from_vote:1;
2298 
2301 
2305 #define ROUTER_PURPOSE_GENERAL 0
2306 
2309 #define ROUTER_PURPOSE_CONTROLLER 1
2310 
2313 #define ROUTER_PURPOSE_BRIDGE 2
2314 
2316 #define ROUTER_PURPOSE_UNKNOWN 255
2317 
2322  uint8_t purpose;
2323 } routerinfo_t;
2324 
2326 typedef struct extrainfo_t {
2327  signed_descriptor_t cache_info;
2329  uint8_t digest256[DIGEST256_LEN];
2331  char nickname[MAX_NICKNAME_LEN+1];
2334  unsigned int bad_sig : 1;
2340 } extrainfo_t;
2341 
2344 typedef struct routerstatus_t {
2345  time_t published_on;
2346  char nickname[MAX_NICKNAME_LEN+1];
2348  char identity_digest[DIGEST_LEN];
2352  char descriptor_digest[DIGEST256_LEN];
2353  uint32_t addr;
2354  uint16_t or_port;
2355  uint16_t dir_port;
2357  uint16_t ipv6_orport;
2358  unsigned int is_authority:1;
2359  unsigned int is_exit:1;
2360  unsigned int is_stable:1;
2361  unsigned int is_fast:1;
2366  unsigned int is_flagged_running:1;
2367  unsigned int is_named:1;
2368  unsigned int is_unnamed:1;
2370  unsigned int is_valid:1;
2371  unsigned int is_possible_guard:1;
2373  unsigned int is_bad_exit:1;
2375  unsigned int is_hs_dir:1;
2377  unsigned int is_v2_dir:1;
2381  unsigned int has_bandwidth:1;
2382  unsigned int has_exitsummary:1;
2383  unsigned int bw_is_unmeasured:1;
2388 
2389  uint32_t bandwidth_kb;
2393  unsigned int has_guardfraction:1;
2396 
2397  char *exitsummary;
2400  /* ---- The fields below aren't derived from the networkstatus; they
2401  * hold local information only. */
2402 
2405  download_status_t dl_status;
2406 
2407 } routerstatus_t;
2408 
2410 typedef struct short_policy_entry_t {
2411  uint16_t min_port, max_port;
2413 
2415 typedef struct short_policy_t {
2418  unsigned int is_accept : 1;
2420  unsigned int n_entries : 31;
2425  short_policy_entry_t entries[FLEXIBLE_ARRAY_MEMBER];
2426 } short_policy_t;
2427 
2433 typedef struct microdesc_t {
2435  HT_ENTRY(microdesc_t) node;
2436 
2437  /* Cache information */
2438 
2442  time_t last_listed;
2444  saved_location_bitfield_t saved_location : 3;
2446  unsigned int no_save : 1;
2448  unsigned int held_in_map : 1;
2450  unsigned int held_by_nodes;
2451 
2454  off_t off;
2455 
2456  /* The string containing the microdesc. */
2457 
2462  char *body;
2464  size_t bodylen;
2466  char digest[DIGEST256_LEN];
2467 
2468  /* Fields in the microdescriptor. */
2469 
2479  uint16_t ipv6_orport;
2486 
2487 } microdesc_t;
2488 
2504 typedef struct node_t {
2505  /* Indexing information */
2506 
2508  HT_ENTRY(node_t) ht_ent;
2510  HT_ENTRY(node_t) ed_ht_ent;
2513 
2516  char identity[DIGEST_LEN];
2517 
2524 
2525  microdesc_t *md;
2526  routerinfo_t *ri;
2527  routerstatus_t *rs;
2528 
2529  /* local info: copied from routerstatus, then possibly frobbed based
2530  * on experience. Authorities set this stuff directly. Note that
2531  * these reflect knowledge of the primary (IPv4) OR port only. */
2532 
2533  unsigned int is_running:1;
2535  unsigned int is_valid:1;
2537  unsigned int is_fast:1;
2538  unsigned int is_stable:1;
2539  unsigned int is_possible_guard:1;
2540  unsigned int is_exit:1;
2541  unsigned int is_bad_exit:1;
2543  unsigned int is_hs_dir:1;
2546  /* Local info: warning state. */
2547 
2548  unsigned int name_lookup_warned:1;
2553  unsigned int rejects_all:1;
2554 
2555  /* Local info: derived. */
2556 
2559  unsigned int ipv6_preferred:1;
2560 
2562  /* XXXprop186 what is this suppose to mean with multiple OR ports? */
2563  country_t country;
2564 
2565  /* The below items are used only by authdirservers for
2566  * reachability testing. */
2567 
2569  time_t last_reachable; /* IPv4. */
2570  time_t last_reachable6; /* IPv6. */
2571 
2572  /* Hidden service directory index data. This is used by a service or client
2573  * in order to know what's the hs directory index for this node at the time
2574  * the consensus is set. */
2575  struct hsdir_index_t hsdir_index;
2576 } node_t;
2577 
2581 typedef struct vote_microdesc_hash_t {
2588 
2590 typedef struct vote_routerstatus_t {
2595 #define MAX_KNOWN_FLAGS_IN_VOTE 64
2596  uint64_t flags;
2598  char *version;
2600  char *protocols;
2602  unsigned int has_measured_bw:1;
2605  unsigned int has_ed25519_listing:1;
2610  uint32_t measured_bw_kb;
2614  uint8_t ed25519_id[ED25519_PUBKEY_LEN];
2616 
2618 typedef struct document_signature_t {
2620  char identity_digest[DIGEST_LEN];
2622  char signing_key_digest[DIGEST_LEN];
2624  digest_algorithm_t alg;
2626  char *signature;
2629  unsigned int bad_signature : 1;
2631  unsigned int good_signature : 1;
2634 
2638  char identity_digest[DIGEST_LEN];
2639  char *nickname;
2642  char legacy_id_digest[DIGEST_LEN];
2643  char *address;
2644  uint32_t addr;
2645  uint16_t dir_port;
2646  uint16_t or_port;
2647  char *contact;
2648  char vote_digest[DIGEST_LEN];
2650  /* Nothing from here on is signed. */
2654 
2655 typedef struct networkstatus_sr_info_t {
2656  /* Indicate if the dirauth partitipates in the SR protocol with its vote.
2657  * This is tied to the SR flag in the vote. */
2658  unsigned int participate:1;
2659  /* Both vote and consensus: Current and previous SRV. If list is empty,
2660  * this means none were found in either the consensus or vote. */
2661  struct sr_srv_t *previous_srv;
2662  struct sr_srv_t *current_srv;
2663  /* Vote only: List of commitments. */
2664  smartlist_t *commits;
2666 
2668 typedef enum {
2669  NS_TYPE_VOTE,
2670  NS_TYPE_CONSENSUS,
2671  NS_TYPE_OPINION,
2673 
2677 typedef enum {
2678  FLAV_NS = 0,
2679  FLAV_MICRODESC = 1,
2681 
2683 #define N_CONSENSUS_FLAVORS ((int)(FLAV_MICRODESC)+1)
2684 
2687 typedef struct networkstatus_t {
2688  networkstatus_type_t type;
2690  unsigned int has_measured_bws : 1;
2693  time_t published;
2694  time_t valid_after;
2695  time_t fresh_until;
2697  time_t valid_until;
2704 
2707 
2714 
2718  char *server_versions;
2719 
2725  char *recommended_client_protocols;
2726  char *required_relay_protocols;
2727  char *required_client_protocols;
2728 
2732 
2736 
2740 
2745 
2752  uint8_t digest_sha3_as_signed[DIGEST256_LEN];
2753 
2758 
2761  digestmap_t *desc_digest_map;
2762 
2765 } networkstatus_t;
2766 
2770  time_t valid_after;
2771  time_t fresh_until;
2772  time_t valid_until;
2773  strmap_t *digests;
2774  strmap_t *signatures;
2777 
2779 typedef enum store_type_t {
2780  ROUTER_STORE = 0,
2781  EXTRAINFO_STORE = 1
2782 } store_type_t;
2783 
2786 typedef struct desc_store_t {
2790  const char *fname_base;
2792  const char *description;
2793 
2799  size_t journal_len;
2801  size_t store_len;
2805 } desc_store_t;
2806 
2808 typedef struct {
2810  struct digest_ri_map_t *identity_map;
2813  struct digest_sd_map_t *desc_digest_map;
2816  struct digest_ei_map_t *extra_info_map;
2820  struct digest_sd_map_t *desc_by_eid_map;
2832 } routerlist_t;
2833 
2838 typedef struct extend_info_t {
2839  char nickname[MAX_HEX_NICKNAME_LEN+1];
2842  char identity_digest[DIGEST_LEN];
2845  uint16_t port;
2848  curve25519_public_key_t curve25519_onion_key;
2849 } extend_info_t;
2850 
2853 typedef struct authority_cert_t {
2861  char signing_key_digest[DIGEST_LEN];
2863  time_t expires;
2865  uint32_t addr;
2867  uint16_t dir_port;
2869 
2879 typedef enum {
2880  NO_DIRINFO = 0,
2882  V3_DIRINFO = 1 << 2,
2884  BRIDGE_DIRINFO = 1 << 4,
2889 } dirinfo_type_t;
2890 
2891 #define ALL_DIRINFO ((dirinfo_type_t)((1<<7)-1))
2892 
2893 #define CRYPT_PATH_MAGIC 0x70127012u
2894 
2895 struct fast_handshake_state_t;
2896 struct ntor_handshake_state_t;
2897 #define ONION_HANDSHAKE_TYPE_TAP 0x0000
2898 #define ONION_HANDSHAKE_TYPE_FAST 0x0001
2899 #define ONION_HANDSHAKE_TYPE_NTOR 0x0002
2900 #define MAX_ONION_HANDSHAKE_TYPE 0x0002
2901 typedef struct {
2902  uint16_t tag;
2903  union {
2904  struct fast_handshake_state_t *fast;
2905  crypto_dh_t *tap;
2906  struct ntor_handshake_state_t *ntor;
2907  } u;
2909 
2910 typedef struct relay_crypto_t {
2911  /* crypto environments */
2918 
2920  crypto_digest_t *f_digest; /* for integrity checking */
2923 
2924 } relay_crypto_t;
2925 
2928 typedef struct crypt_path_t {
2929  uint32_t magic;
2930 
2934 
2941 
2943  char rend_circ_nonce[DIGEST_LEN];/* KH in tor-spec.txt */
2944 
2947 
2953  uint8_t state;
2954 #define CPATH_STATE_CLOSED 0
2955 #define CPATH_STATE_AWAITING_KEYS 1
2956 #define CPATH_STATE_OPEN 2
2957  struct crypt_path_t *next;
2960  struct crypt_path_t *prev;
2967 } crypt_path_t;
2968 
2973 typedef struct {
2975  unsigned int refcount;
2980 
2981 #define CPATH_KEY_MATERIAL_LEN (20*2+16*2)
2982 
2983 #define DH_KEY_LEN DH_BYTES
2984 
2986 typedef struct {
2992  unsigned int need_uptime : 1;
2994  unsigned int need_capacity : 1;
2996  unsigned int is_internal : 1;
3000  unsigned int onehop_tunnel : 1;
3009  time_t expiry_time;
3011 
3013 #define ORIGIN_CIRCUIT_MAGIC 0x35315243u
3014 
3015 #define OR_CIRCUIT_MAGIC 0x98ABC04Fu
3016 
3019 #define DEAD_CIRCUIT_MAGIC 0xdeadc14c
3020 
3021 struct create_cell_t;
3022 
3026  uint8_t command;
3031  unsigned int waiting_time:22;
3032  unsigned int removed:1;
3033  unsigned int exitward:1;
3035 
3059 typedef struct circuit_t {
3060  uint32_t magic;
3065 
3074 
3080 
3083 
3089 
3092  unsigned int streams_blocked_on_n_chan : 1;
3095  unsigned int streams_blocked_on_p_chan : 1;
3096 
3099  unsigned int p_delete_pending : 1;
3102  unsigned int n_delete_pending : 1;
3103 
3105  unsigned int received_destroy : 1;
3106 
3107  uint8_t state;
3108  uint8_t purpose;
3119 
3121  uint32_t age_tmp;
3122 
3125 
3136  struct timeval timestamp_began;
3137 
3139  struct timeval timestamp_created;
3140 
3159 
3160  uint16_t marked_for_close;
3173 
3175  uint64_t dirreq_id;
3176 
3179 
3184 
3187  hs_token_t *hs_token;
3190  HT_ENTRY(circuit_t) hs_circuitmap_node;
3191 } circuit_t;
3192 
3195 #define MAX_RELAY_EARLY_CELLS_PER_CIRCUIT 8
3196 
3212 typedef enum {
3238 
3244 
3251 } path_state_t;
3252 #define path_state_bitfield_t ENUM_BF(path_state_t)
3253 
3256 typedef struct origin_circuit_t {
3257  circuit_t base_;
3258 
3262 
3266  uint32_t n_read_circ_bw;
3267 
3272 
3277 
3282 
3287 
3292 
3303 
3306 
3310 
3314  struct circuit_guard_state_t *guard_state;
3315 
3319 
3323 
3325  unsigned int is_ancient : 1;
3326 
3329  unsigned int has_opened : 1;
3330 
3336  path_state_bitfield_t path_state : 3;
3337 
3338  /* If this flag is set, we should not consider attaching any more
3339  * connections to this circuit. */
3340  unsigned int unusable_for_new_conns : 1;
3341 
3350 #define PATHBIAS_SHOULDCOUNT_UNDECIDED 0
3351 #define PATHBIAS_SHOULDCOUNT_IGNORED 1
3352 #define PATHBIAS_SHOULDCOUNT_COUNTED 2
3353 
3357 
3361 
3376  unsigned int hs_circ_has_timed_out : 1;
3377 
3380  unsigned int relaxed_timeout : 1;
3381 
3389 
3392  uint8_t relay_early_commands[MAX_RELAY_EARLY_CELLS_PER_CIRCUIT];
3393 
3397 
3401 
3402  /* The intro key replaces the hidden service's public key if purpose is
3403  * S_ESTABLISH_INTRO or S_INTRO, provided that no unversioned rendezvous
3404  * descriptor is used. */
3405  crypto_pk_t *intro_key;
3406 
3408  /* XXXX NM This can get re-used after 2**32 circuits. */
3410 
3416  unsigned int isolation_values_set : 1;
3423 
3428 
3442  uint8_t client_proto_type;
3443  uint8_t client_proto_socksver;
3444  uint16_t dest_port;
3445  tor_addr_t client_addr;
3446  char *dest_address;
3447  int session_group;
3448  unsigned nym_epoch;
3449  size_t socks_username_len;
3450  uint8_t socks_password_len;
3451  /* Note that the next two values are NOT NUL-terminated; see
3452  socks_username_len and socks_password_len for their lengths. */
3453  char *socks_username;
3454  char *socks_password;
3463 
3469 
3471 
3472 struct onion_queue_t;
3473 
3476 typedef struct or_circuit_t {
3477  circuit_t base_;
3478 
3486 
3503 
3507 
3511 
3513  char rend_circ_nonce[DIGEST_LEN];/* KH in tor-spec.txt */
3514 
3518 
3519  /* We have already received an INTRODUCE1 cell on this circuit. */
3520  unsigned int already_received_introduce1 : 1;
3521 
3525 
3529 
3534 } or_circuit_t;
3535 
3536 #if REND_COOKIE_LEN != DIGEST_LEN
3537 #error "The REND_TOKEN_LEN macro assumes REND_COOKIE_LEN == DIGEST_LEN"
3538 #endif
3539 #define REND_TOKEN_LEN DIGEST_LEN
3540 
3542 #define TO_CIRCUIT(x) (&((x)->base_))
3543 
3546 static or_circuit_t *TO_OR_CIRCUIT(circuit_t *);
3547 static const or_circuit_t *CONST_TO_OR_CIRCUIT(const circuit_t *);
3550 static origin_circuit_t *TO_ORIGIN_CIRCUIT(circuit_t *);
3551 static const origin_circuit_t *CONST_TO_ORIGIN_CIRCUIT(const circuit_t *);
3552 
3556 static inline int node_is_good_exit(const node_t *node)
3557 {
3558  return node->is_exit && ! node->is_bad_exit;
3559 }
3560 
3561 static inline or_circuit_t *TO_OR_CIRCUIT(circuit_t *x)
3562 {
3564  return DOWNCAST(or_circuit_t, x);
3565 }
3566 static inline const or_circuit_t *CONST_TO_OR_CIRCUIT(const circuit_t *x)
3567 {
3569  return DOWNCAST(or_circuit_t, x);
3570 }
3571 static inline origin_circuit_t *TO_ORIGIN_CIRCUIT(circuit_t *x)
3572 {
3574  return DOWNCAST(origin_circuit_t, x);
3575 }
3576 static inline const origin_circuit_t *CONST_TO_ORIGIN_CIRCUIT(
3577  const circuit_t *x)
3578 {
3580  return DOWNCAST(origin_circuit_t, x);
3581 }
3582 
3583 /* limits for TCP send and recv buffer size used for constrained sockets */
3584 #define MIN_CONSTRAINED_TCP_BUFFER 2048
3585 #define MAX_CONSTRAINED_TCP_BUFFER 262144 /* 256k */
3586 
3594 #define ISO_DESTPORT (1u<<0)
3595 
3596 #define ISO_DESTADDR (1u<<1)
3597 
3598 #define ISO_SOCKSAUTH (1u<<2)
3599 
3600 #define ISO_CLIENTPROTO (1u<<3)
3601 
3602 #define ISO_CLIENTADDR (1u<<4)
3603 
3604 #define ISO_SESSIONGRP (1u<<5)
3605 
3606 #define ISO_NYM_EPOCH (1u<<6)
3607 
3608 #define ISO_STREAM (1u<<7)
3609 
3612 #define ISO_DEFAULT (ISO_CLIENTADDR|ISO_SOCKSAUTH|ISO_SESSIONGRP|ISO_NYM_EPOCH)
3613 
3615 #define SESSION_GROUP_UNSET -1
3616 
3617 #define SESSION_GROUP_DIRCONN -2
3618 
3619 #define SESSION_GROUP_CONTROL_RESOLVE -3
3620 
3621 #define SESSION_GROUP_FIRST_AUTO -4
3622 
3624 typedef struct port_cfg_t {
3626  int port;
3628  uint8_t type;
3629  unsigned is_unix_addr : 1;
3631  unsigned is_group_writable : 1;
3632  unsigned is_world_writable : 1;
3633  unsigned relax_dirmode_check : 1;
3634 
3635  entry_port_cfg_t entry_cfg;
3636 
3637  server_port_cfg_t server_cfg;
3638 
3639  /* Unix sockets only: */
3641  char unix_addr[FLEXIBLE_ARRAY_MEMBER];
3642 } port_cfg_t;
3643 
3644 typedef struct routerset_t routerset_t;
3645 
3648 #define CFG_AUTO_PORT 0xc4005e
3649 
3652 typedef enum {OUTBOUND_ADDR_EXIT, OUTBOUND_ADDR_OR,
3653  OUTBOUND_ADDR_EXIT_AND_OR,
3654  OUTBOUND_ADDR_MAX} outbound_addr_t;
3655 
3657 typedef struct {
3658  uint32_t magic_;
3659 
3661  enum {
3662  CMD_RUN_TOR=0, CMD_LIST_FINGERPRINT, CMD_HASH_PASSWORD,
3663  CMD_VERIFY_CONFIG, CMD_RUN_UNITTESTS, CMD_DUMP_CONFIG,
3664  CMD_KEYGEN,
3665  CMD_KEY_EXPIRATION,
3666  } command;
3667  char *command_arg;
3696  char *Nickname;
3697  char *Address;
3698  char *PidFile;
3700  routerset_t *ExitNodes;
3703  routerset_t *EntryNodes;
3709  routerset_t *ExcludeNodes;
3713  routerset_t *ExcludeExitNodes;
3719 
3743  tor_addr_t OutboundBindAddresses[OUTBOUND_ADDR_MAX][2];
3747  config_line_t *RecommendedClientVersions;
3748  config_line_t *RecommendedServerVersions;
3749  config_line_t *RecommendedPackages;
3754  char *User;
3765  enum {
3766  TPT_DEFAULT,
3767  TPT_PF_DIVERT,
3768  TPT_IPFW,
3769  TPT_TPROXY,
3770  } TransProxyType_parsed;
3786  /* MaxMemInQueues value as input by the user. We clean this up to be
3787  * MaxMemInQueues. */
3788  uint64_t MaxMemInQueues_raw;
3789  uint64_t MaxMemInQueues;
3793 
3807  unsigned int ORPort_set : 1;
3808  unsigned int SocksPort_set : 1;
3809  unsigned int TransPort_set : 1;
3810  unsigned int NATDPort_set : 1;
3811  unsigned int ControlPort_set : 1;
3812  unsigned int DirPort_set : 1;
3813  unsigned int DNSPort_set : 1;
3814  unsigned int ExtORPort_set : 1;
3815  unsigned int HTTPTunnelPort_set : 1;
3831 
3838 
3850 
3853 
3861 
3873 
3895 
3898 
3901  routerset_t *HSLayer2Nodes;
3902 
3905  routerset_t *HSLayer3Nodes;
3906 
3919  /* Makes hidden service clients and servers non-anonymous on this tor
3920  * instance. Allows the non-anonymous HiddenServiceSingleHopMode. Enables
3921  * non-anonymous behaviour in the hidden service protocol.
3922  * Use rend_service_non_anonymous_mode_enabled() instead of using this option
3923  * directly.
3924  */
3925  int HiddenServiceNonAnonymousMode;
3926 
3949 
3993  int MaxOnionQueueDelay; /*< DOCDOC */
3998  uint64_t BandwidthRate;
4000  uint64_t BandwidthBurst;
4008  uint64_t PerConnBWRate;
4009  uint64_t PerConnBWBurst;
4010  int NumCPUs;
4015  char *ContactInfo;
4022  char *HTTPProxy;
4024  uint16_t HTTPProxyPort;
4027  char *HTTPSProxy;
4029  uint16_t HTTPSProxyPort;
4032  char *Socks4Proxy;
4034  uint16_t Socks4ProxyPort;
4036  char *Socks5Proxy;
4038  uint16_t Socks5ProxyPort;
4046 
4051 
4055 
4059 
4062 
4081  smartlist_t *AuthDirBadExitCCs;
4082  smartlist_t *AuthDirInvalidCCs;
4083  smartlist_t *AuthDirRejectCCs;
4096 
4100 
4103  uint64_t AccountingMax;
4112  enum { ACCT_MAX, ACCT_SUM, ACCT_IN, ACCT_OUT } AccountingRule;
4113 
4118 
4140 
4143  char *SafeLogging;
4145  /* Derived from SafeLogging */
4146  enum {
4147  SAFELOG_SCRUB_ALL, SAFELOG_SCRUB_RELAY, SAFELOG_SCRUB_NONE
4148  } SafeLogging_;
4149 
4150  int Sandbox;
4161  char *AccelName;
4162  char *AccelDir;
4172 
4179 
4188 
4191 
4192  int DirCache;
4231 
4235 
4242 
4245 
4248 
4251 
4254 
4257 
4265 
4268 
4273 
4277 
4296 
4305 
4309 
4312 
4315 
4319 
4323 
4327 
4331 
4335 
4339 
4344 
4349 
4353 
4357 
4361 
4365 
4375 
4385 
4395 
4399 
4403 
4408 
4412 
4417 
4422 
4425 
4428 
4432  int TestingDirAuthVoteExitIsStrict;
4433 
4437  int TestingDirAuthVoteGuardIsStrict;
4438 
4442  int TestingDirAuthVoteHSDirIsStrict;
4443 
4446 
4449 
4454 
4456  char *GeoIPFile;
4457  char *GeoIPv6File;
4458 
4463 
4467 
4468  /* The main parameter for picking circuits within a connection.
4469  *
4470  * If this value is positive, when picking a cell to relay on a connection,
4471  * we always relay from the circuit whose weighted cell count is lowest.
4472  * Cells are weighted exponentially such that if one cell is sent
4473  * 'CircuitPriorityHalflife' seconds before another, it counts for half as
4474  * much.
4475  *
4476  * If this value is zero, we're disabling the cell-EWMA algorithm.
4477  *
4478  * If this value is negative, we're using the default approach
4479  * according to either Tor or a parameter set in the consensus.
4480  */
4481  double CircuitPriorityHalflife;
4482 
4487 
4491 
4496 
4497 #define MAX_MAX_CLIENT_CIRCUITS_PENDING 1024
4498 
4501 
4505 
4509 
4536  double PathBiasNoticeRate;
4537  double PathBiasWarnRate;
4538  double PathBiasExtremeRate;
4539  int PathBiasDropGuards;
4540  int PathBiasScaleThreshold;
4562  double PathBiasNoticeUseRate;
4563  double PathBiasExtremeUseRate;
4564  int PathBiasScaleUseThreshold;
4567  int IPv6Exit;
4571 
4575 
4578 
4585 
4592 
4599 
4603 
4604  enum {
4605  FORCE_PASSPHRASE_AUTO=0,
4606  FORCE_PASSPHRASE_ON,
4607  FORCE_PASSPHRASE_OFF
4608  } keygen_force_passphrase;
4609  int use_keygen_passphrase_fd;
4610  int keygen_passphrase_fd;
4611  int change_key_passphrase;
4612  char *master_key_fname;
4613 
4616 
4621 
4627 
4630 
4634 
4637  /* NOTE: remove this option someday. */
4639 
4642 
4647 
4650  int NoExec;
4651 
4657 
4660 
4664  /* An ordered list of scheduler_types mapped from Schedulers. */
4665  smartlist_t *SchedulerTypes_;
4666 
4669 
4674 
4692 
4700 
4703 } or_options_t;
4704 
4705 #define LOG_PROTOCOL_WARN (get_protocol_warning_severity_level())
4706 
4708 typedef struct {
4709  uint32_t magic_;
4713  time_t next_write;
4714 
4716  time_t LastWritten;
4717 
4720  uint64_t AccountingBytesReadInInterval;
4721  uint64_t AccountingBytesWrittenInInterval;
4722  int AccountingSecondsActive;
4723  int AccountingSecondsToReachSoftLimit;
4724  time_t AccountingSoftLimitHitAt;
4725  uint64_t AccountingBytesAtSoftLimit;
4726  uint64_t AccountingExpectedUsage;
4727 
4730 
4733 
4734  config_line_t *TransportProxies;
4735 
4738 
4748  int BWHistoryReadInterval;
4749  smartlist_t *BWHistoryReadValues;
4750  smartlist_t *BWHistoryReadMaxima;
4751  time_t BWHistoryWriteEnds;
4752  int BWHistoryWriteInterval;
4753  smartlist_t *BWHistoryWriteValues;
4754  smartlist_t *BWHistoryWriteMaxima;
4755  time_t BWHistoryDirReadEnds;
4756  int BWHistoryDirReadInterval;
4757  smartlist_t *BWHistoryDirReadValues;
4758  smartlist_t *BWHistoryDirReadMaxima;
4759  time_t BWHistoryDirWriteEnds;
4760  int BWHistoryDirWriteInterval;
4761  smartlist_t *BWHistoryDirWriteValues;
4762  smartlist_t *BWHistoryDirWriteMaxima;
4763 
4766  int TotalBuildTimes;
4767  int CircuitBuildAbandonedCount;
4768 
4770  char *TorVersion;
4771 
4775 
4778 } or_state_t;
4779 
4780 #define MAX_SOCKS_REPLY_LEN 1024
4781 #define MAX_SOCKS_ADDR_LEN 256
4782 #define SOCKS_NO_AUTH 0x00
4783 #define SOCKS_USER_PASS 0x02
4784 
4786 #define SOCKS_COMMAND_CONNECT 0x01
4787 
4788 #define SOCKS_COMMAND_RESOLVE 0xF0
4789 
4790 #define SOCKS_COMMAND_RESOLVE_PTR 0xF1
4791 
4792 /* || 0 is for -Wparentheses-equality (-Wall?) appeasement under clang */
4793 #define SOCKS_COMMAND_IS_CONNECT(c) (((c)==SOCKS_COMMAND_CONNECT) || 0)
4794 #define SOCKS_COMMAND_IS_RESOLVE(c) ((c)==SOCKS_COMMAND_RESOLVE || \
4795  (c)==SOCKS_COMMAND_RESOLVE_PTR)
4796 
4804  uint8_t socks_version;
4808  uint8_t auth_type;
4810  uint8_t command;
4812  uint8_t listener_type;
4813  size_t replylen;
4814  uint8_t reply[MAX_SOCKS_REPLY_LEN];
4820  char address[MAX_SOCKS_ADDR_LEN];
4822  uint16_t port;
4823  unsigned int has_finished : 1;
4826  unsigned int got_auth : 1;
4830  unsigned int socks_prefer_no_auth : 1;
4831 
4833  size_t usernamelen;
4835  uint8_t passwordlen;
4839  char *username;
4842  char *password;
4843 };
4844 
4845 /********************************* circuitbuild.c **********************/
4846 
4848 #define DEFAULT_ROUTE_LEN 3
4849 
4850 /* Circuit Build Timeout "public" structures. */
4851 
4853 #define BW_WEIGHT_SCALE 10000
4854 #define BW_MIN_WEIGHT_SCALE 1
4855 #define BW_MAX_WEIGHT_SCALE INT32_MAX
4856 
4859 #define CBT_NCIRCUITS_TO_OBSERVE 1000
4860 
4862 #define CBT_BIN_WIDTH ((build_time_t)50)
4863 
4865 #define CBT_DEFAULT_NUM_XM_MODES 3
4866 #define CBT_MIN_NUM_XM_MODES 1
4867 #define CBT_MAX_NUM_XM_MODES 20
4868 
4870 typedef uint32_t build_time_t;
4871 
4876 #define CBT_BUILD_ABANDONED ((build_time_t)(INT32_MAX-1))
4877 #define CBT_BUILD_TIME_MAX ((build_time_t)(INT32_MAX))
4878 
4880 #define CBT_SAVE_STATE_EVERY 10
4881 
4882 /* Circuit build times consensus parameters */
4883 
4888 #define CBT_DEFAULT_CLOSE_QUANTILE 95
4889 #define CBT_MIN_CLOSE_QUANTILE CBT_MIN_QUANTILE_CUTOFF
4890 #define CBT_MAX_CLOSE_QUANTILE CBT_MAX_QUANTILE_CUTOFF
4891 
4896 #define CBT_DEFAULT_RECENT_CIRCUITS 20
4897 #define CBT_MIN_RECENT_CIRCUITS 3
4898 #define CBT_MAX_RECENT_CIRCUITS 1000
4899 
4908 #define CBT_DEFAULT_MAX_RECENT_TIMEOUT_COUNT (CBT_DEFAULT_RECENT_CIRCUITS*9/10)
4909 #define CBT_MIN_MAX_RECENT_TIMEOUT_COUNT 3
4910 #define CBT_MAX_MAX_RECENT_TIMEOUT_COUNT 10000
4911 
4913 #define CBT_DEFAULT_MIN_CIRCUITS_TO_OBSERVE 100
4914 #define CBT_MIN_MIN_CIRCUITS_TO_OBSERVE 1
4915 #define CBT_MAX_MIN_CIRCUITS_TO_OBSERVE 10000
4916 
4918 #define CBT_DEFAULT_QUANTILE_CUTOFF 80
4919 #define CBT_MIN_QUANTILE_CUTOFF 10
4920 #define CBT_MAX_QUANTILE_CUTOFF 99
4922 
4924 #define CBT_DEFAULT_TEST_FREQUENCY 10
4925 #define CBT_MIN_TEST_FREQUENCY 1
4926 #define CBT_MAX_TEST_FREQUENCY INT32_MAX
4927 
4929 #define CBT_DEFAULT_TIMEOUT_MIN_VALUE (1500)
4930 #define CBT_MIN_TIMEOUT_MIN_VALUE 500
4931 #define CBT_MAX_TIMEOUT_MIN_VALUE INT32_MAX
4932 
4934 #define CBT_DEFAULT_TIMEOUT_INITIAL_VALUE (60*1000)
4935 #define CBT_MIN_TIMEOUT_INITIAL_VALUE CBT_MIN_TIMEOUT_MIN_VALUE
4936 #define CBT_MAX_TIMEOUT_INITIAL_VALUE INT32_MAX
4938 
4939 #if CBT_DEFAULT_MAX_RECENT_TIMEOUT_COUNT < CBT_MIN_MAX_RECENT_TIMEOUT_COUNT
4940 #error "RECENT_CIRCUITS is set too low."
4941 #endif
4942 
4944 typedef struct {
4957 
4958 typedef struct circuit_build_times_s circuit_build_times_t;
4959 
4960 /********************************* config.c ***************************/
4961 
4963 typedef enum setopt_err_t {
4964  SETOPT_OK = 0,
4965  SETOPT_ERR_MISC = -1,
4966  SETOPT_ERR_PARSE = -2,
4967  SETOPT_ERR_TRANSITION = -3,
4968  SETOPT_ERR_SETTING = -4,
4969 } setopt_err_t;
4970 
4971 /********************************* connection_edge.c *************************/
4972 
4974 typedef enum {
4989 
4995 #define addressmap_entry_source_bitfield_t ENUM_BF(addressmap_entry_source_t)
4996 
4997 /********************************* control.c ***************************/
4998 
5002  CIRC_EVENT_LAUNCHED = 0,
5003  CIRC_EVENT_BUILT = 1,
5004  CIRC_EVENT_EXTENDED = 2,
5005  CIRC_EVENT_FAILED = 3,
5006  CIRC_EVENT_CLOSED = 4,
5008 
5012  CIRC_MINOR_EVENT_PURPOSE_CHANGED,
5013  CIRC_MINOR_EVENT_CANNIBALIZED,
5015 
5019  STREAM_EVENT_SENT_CONNECT = 0,
5020  STREAM_EVENT_SENT_RESOLVE = 1,
5021  STREAM_EVENT_SUCCEEDED = 2,
5022  STREAM_EVENT_FAILED = 3,
5023  STREAM_EVENT_CLOSED = 4,
5024  STREAM_EVENT_NEW = 5,
5025  STREAM_EVENT_NEW_RESOLVE = 6,
5026  STREAM_EVENT_FAILED_RETRIABLE = 7,
5027  STREAM_EVENT_REMAP = 8
5029 
5033  OR_CONN_EVENT_LAUNCHED = 0,
5034  OR_CONN_EVENT_CONNECTED = 1,
5035  OR_CONN_EVENT_FAILED = 2,
5036  OR_CONN_EVENT_CLOSED = 3,
5037  OR_CONN_EVENT_NEW = 4,
5039 
5042  BUILDTIMEOUT_SET_EVENT_COMPUTED = 0,
5043  BUILDTIMEOUT_SET_EVENT_RESET = 1,
5044  BUILDTIMEOUT_SET_EVENT_SUSPENDED = 2,
5045  BUILDTIMEOUT_SET_EVENT_DISCARD = 3,
5046  BUILDTIMEOUT_SET_EVENT_RESUME = 4
5048 
5055 #define CONN_LOG_PROTECT(conn, stmt) \
5056  STMT_BEGIN \
5057  int _log_conn_is_control; \
5058  tor_assert(conn); \
5059  _log_conn_is_control = (conn->type == CONN_TYPE_CONTROL); \
5060  if (_log_conn_is_control) \
5061  disable_control_logging(); \
5062  STMT_BEGIN stmt; STMT_END; \
5063  if (_log_conn_is_control) \
5064  enable_control_logging(); \
5065  STMT_END
5066 
5069 typedef enum {
5070  BOOTSTRAP_STATUS_UNDEF=-1,
5071  BOOTSTRAP_STATUS_STARTING=0,
5072  BOOTSTRAP_STATUS_CONN_DIR=5,
5073  BOOTSTRAP_STATUS_HANDSHAKE=-2,
5074  BOOTSTRAP_STATUS_HANDSHAKE_DIR=10,
5075  BOOTSTRAP_STATUS_ONEHOP_CREATE=15,
5076  BOOTSTRAP_STATUS_REQUESTING_STATUS=20,
5077  BOOTSTRAP_STATUS_LOADING_STATUS=25,
5078  BOOTSTRAP_STATUS_LOADING_KEYS=40,
5079  BOOTSTRAP_STATUS_REQUESTING_DESCRIPTORS=45,
5080  BOOTSTRAP_STATUS_LOADING_DESCRIPTORS=50,
5081  BOOTSTRAP_STATUS_CONN_OR=80,
5082  BOOTSTRAP_STATUS_HANDSHAKE_OR=85,
5083  BOOTSTRAP_STATUS_CIRCUIT_CREATE=90,
5084  BOOTSTRAP_STATUS_DONE=100
5086 
5087 /********************************* directory.c ***************************/
5088 
5090 typedef struct {
5091  char first[DIGEST_LEN];
5092  char second[DIGEST_LEN];
5093 } fp_pair_t;
5094 
5095 /********************************* dirserv.c ***************************/
5096 
5099 typedef enum {
5111 
5112 #ifdef DIRSERV_PRIVATE
5113 typedef struct measured_bw_line_t {
5114  char node_id[DIGEST_LEN];
5115  char node_hex[MAX_HEX_NICKNAME_LEN+1];
5116  long int bw_kb;
5117 } measured_bw_line_t;
5118 
5119 #endif /* defined(DIRSERV_PRIVATE) */
5120 
5121 /********************************* dirvote.c ************************/
5122 
5124 typedef struct vote_timing_t {
5134 } vote_timing_t;
5135 
5136 /********************************* geoip.c **************************/
5137 
5142 typedef enum {
5150 typedef enum {
5165 #define GEOIP_NS_RESPONSE_NUM 6
5166 
5169 typedef enum {
5170  DIRREQ_DIRECT = 0,
5171  DIRREQ_TUNNELED = 1,
5172 } dirreq_type_t;
5173 
5176 typedef enum {
5194 } dirreq_state_t;
5195 
5196 #define WRITE_STATS_INTERVAL (24*60*60)
5197 
5198 /********************************* microdesc.c *************************/
5199 
5200 typedef struct microdesc_cache_t microdesc_cache_t;
5201 
5202 /********************************* networkstatus.c *********************/
5203 
5206 typedef enum version_status_t {
5217 
5218 /********************************* policies.c ************************/
5219 
5221 typedef enum {
5233 
5234 /********************************* rephist.c ***************************/
5235 
5238 typedef enum {
5239  SIGN_DIR, SIGN_RTR,
5240  VERIFY_DIR, VERIFY_RTR,
5241  ENC_ONIONSKIN, DEC_ONIONSKIN,
5242  TLS_HANDSHAKE_C, TLS_HANDSHAKE_S,
5243  REND_CLIENT, REND_MID, REND_SERVER,
5244 } pk_op_t;
5245 
5246 /********************************* rendcommon.c ***************************/
5247 
5250  char *client_name;
5251  uint8_t descriptor_cookie[REND_DESC_COOKIE_LEN];
5252  crypto_pk_t *client_key;
5254 
5257  char desc_id[DIGEST_LEN];
5258  char *desc_str;
5260 
5264 #define MAX_INTRO_POINT_REACHABILITY_FAILURES 5
5265 
5269 #define INTRO_POINT_MIN_LIFETIME_INTRODUCTIONS 16384
5270 /* Double the minimum value so the interval is [min, min * 2]. */
5271 #define INTRO_POINT_MAX_LIFETIME_INTRODUCTIONS \
5272  (INTRO_POINT_MIN_LIFETIME_INTRODUCTIONS * 2)
5273 
5280 #define INTRO_POINT_LIFETIME_MIN_SECONDS (18*60*60)
5281 
5285 #define INTRO_POINT_LIFETIME_MAX_SECONDS (24*60*60)
5286 
5290 #define MAX_INTRO_POINT_CIRCUIT_RETRIES 3
5291 
5295 typedef struct rend_intro_point_t {
5306  unsigned int timed_out : 1;
5307 
5311  unsigned int unreachable_count : 3;
5312 
5315  unsigned int listed_in_last_desc : 1;
5316 
5321 
5326 
5332 
5337 
5342 
5348  unsigned int circuit_retries;
5349 
5352  unsigned int circuit_established:1;
5354 
5355 #define REND_PROTOCOL_VERSION_BITMASK_WIDTH 16
5356 
5361  int version;
5362  time_t timestamp;
5365  unsigned protocols : REND_PROTOCOL_VERSION_BITMASK_WIDTH;
5377 
5378 /********************************* routerlist.c ***************************/
5379 
5382 typedef struct dir_server_t {
5383  char *description;
5384  char *nickname;
5385  char *address;
5386  /* XX/teor - why do we duplicate the address and port fields here and in
5387  * fake_status? Surely we could just use fake_status (#17867). */
5389  uint32_t addr;
5390  uint16_t dir_port;
5391  uint16_t or_port;
5392  uint16_t ipv6_orport;
5393  double weight;
5394  char digest[DIGEST_LEN];
5395  char v3_identity_digest[DIGEST_LEN];
5398  unsigned int is_running:1;
5399  unsigned int is_authority:1;
5404  unsigned int has_accepted_serverdesc:1;
5405 
5408 
5418 } dir_server_t;
5419 
5420 #define RELAY_REQUIRED_MIN_BANDWIDTH (75*1024)
5421 #define BRIDGE_REQUIRED_MIN_BANDWIDTH (50*1024)
5422 
5423 #define ROUTER_MAX_DECLARED_BANDWIDTH INT32_MAX
5424 
5425 /* Flags for pick_directory_server() and pick_trusteddirserver(). */
5429 #define PDS_ALLOW_SELF (1<<0)
5430 
5433 #define PDS_RETRY_IF_NO_SERVERS (1<<1)
5434 
5439 #define PDS_IGNORE_FASCISTFIREWALL (1<<2)
5440 
5446 #define PDS_NO_EXISTING_SERVERDESC_FETCH (1<<3)
5447 
5452 #define PDS_NO_EXISTING_MICRODESC_FETCH (1<<4)
5453 
5457  NO_WEIGHTING, WEIGHT_FOR_EXIT, WEIGHT_FOR_MID, WEIGHT_FOR_GUARD,
5458  WEIGHT_FOR_DIR
5460 
5463 typedef enum {
5464  CRN_NEED_UPTIME = 1<<0,
5465  CRN_NEED_CAPACITY = 1<<1,
5466  CRN_NEED_GUARD = 1<<2,
5467  /* XXXX not used, apparently. */
5468  CRN_WEIGHT_AS_EXIT = 1<<5,
5469  CRN_NEED_DESC = 1<<6,
5470  /* On clients, only provide nodes that satisfy ClientPreferIPv6OR */
5471  CRN_PREF_ADDR = 1<<7,
5472  /* On clients, only provide nodes that we can connect to directly, based on
5473  * our firewall rules */
5474  CRN_DIRECT_CONN = 1<<8,
5475  /* On clients, only provide nodes with HSRend >= 2 protocol version which
5476  * is required for hidden service version >= 3. */
5477  CRN_RENDEZVOUS_V3 = 1<<9,
5479 
5481 typedef enum was_router_added_t {
5482  /* Router was added successfully. */
5483  ROUTER_ADDED_SUCCESSFULLY = 1,
5484  /* Extrainfo document was rejected because no corresponding router
5485  * descriptor was found OR router descriptor was rejected because
5486  * it was incompatible with its extrainfo document. */
5487  ROUTER_BAD_EI = -1,
5488  /* Router descriptor was rejected because it is already known. */
5489  ROUTER_IS_ALREADY_KNOWN = -2,
5490  /* General purpose router was rejected, because it was not listed
5491  * in consensus. */
5492  ROUTER_NOT_IN_CONSENSUS = -3,
5493  /* Router was neither in directory consensus nor in any of
5494  * networkstatus documents. Caching it to access later.
5495  * (Applies to fetched descriptors only.) */
5496  ROUTER_NOT_IN_CONSENSUS_OR_NETWORKSTATUS = -4,
5497  /* Router was rejected by directory authority. */
5498  ROUTER_AUTHDIR_REJECTS = -5,
5499  /* Bridge descriptor was rejected because such bridge was not one
5500  * of the bridges we have listed in our configuration. */
5501  ROUTER_WAS_NOT_WANTED = -6,
5502  /* Router descriptor was rejected because it was older than
5503  * OLD_ROUTER_DESC_MAX_AGE. */
5504  ROUTER_WAS_TOO_OLD = -7, /* note contrast with 'NOT_NEW' */
5505  /* DOCDOC */
5506  ROUTER_CERTS_EXPIRED = -8
5508 
5509 /********************************* routerparse.c ************************/
5510 
5511 #define MAX_STATUS_TAG_LEN 32
5512 
5517 typedef struct tor_version_t {
5518  int major;
5519  int minor;
5520  int micro;
5523  enum { VER_PRE=0, VER_RC=1, VER_RELEASE=2, } status;
5524  int patchlevel;
5525  char status_tag[MAX_STATUS_TAG_LEN];
5526  int svn_revision;
5527 
5528  int git_tag_len;
5529  char git_tag[DIGEST_LEN];
5530 } tor_version_t;
5531 
5532 #endif /* !defined(TOR_OR_H) */
5533 
streamid_t stream_id
Definition: or.h:1716
int MinMeasuredBWsForAuthToIgnoreAdvertised
Definition: or.h:4322
int KeyDirectoryGroupReadable
Definition: or.h:3689
config_line_t * SocksPort_lines
Definition: or.h:3759
unsigned int is_internal
Definition: or.h:2996
int NoExec
Definition: or.h:4650
unsigned int is_stable
Definition: or.h:2538
Definition: or.h:5231
Definition: or.h:842
int V3AuthUseLegacyKey
Definition: or.h:4308
curve25519_public_key_t * onion_curve25519_pkey
Definition: or.h:2473
config_line_t * AlternateBridgeAuthority
Definition: or.h:4061
ed25519_public_key_t * ed25519_identity_pkey
Definition: or.h:2475
struct rend_service_descriptor_t rend_service_descriptor_t
crypto_pk_t * identity_pkey
Definition: or.h:2248
char * microdesc_hash_line
Definition: or.h:2586
tor_tls_t * tls
Definition: or.h:1632
smartlist_t * TrackHostExits
Definition: or.h:3963
int TruncateLogFile
Definition: or.h:3675
curve25519_public_key_t * onion_curve25519_pkey
Definition: or.h:2250
crypto_cipher_t * b_crypto
Definition: or.h:2917
char * username
Definition: or.h:4839
char * DirPortFrontPage
Definition: or.h:4210
struct addr_policy_t addr_policy_t
char * OwningControllerProcess
Definition: or.h:4137
uint64_t MaxMemInQueues_low_threshold
Definition: or.h:3792
config_line_t * ServerTransportListenAddr
Definition: or.h:3849
uint8_t * ed_rsa_crosscert
Definition: or.h:1521
char * nickname
Definition: or.h:1630
common_digests_t digests
Definition: or.h:2749
uint32_t incoming_cmd_cur_len
Definition: or.h:1910
Definition: or.h:5225
#define MAX_HEX_NICKNAME_LEN
Definition: or.h:127
Definition: or.h:5155
unsigned int is_running
Definition: or.h:5398
desc_store_t desc_store
Definition: or.h:2829
relay_crypto_t crypto
Definition: or.h:2933
uint16_t dir_port
Definition: or.h:2238
char * AccountingRule_option
Definition: or.h:4111
int StrictNodes
Definition: or.h:3706
int vote_seconds
Definition: or.h:2710
int DirAllowPrivateAddresses
Definition: or.h:3751
int ClientBootstrapConsensusMaxInProgressTries
Definition: or.h:4416
Definition: confline.h:23
int ReducedExitPolicy
Definition: or.h:3731
Definition: or.h:3657
config_line_t * HashedControlSessionPassword
Definition: or.h:4117
int TestingLinkKeySlop
Definition: or.h:4596
int tls_error
Definition: or.h:1633
struct dir_server_t dir_server_t
struct evdns_server_port * dns_server_port
Definition: or.h:1433
was_router_added_t
Definition: or.h:5481
int AuthDirTestEd25519LinkKeys
Definition: or.h:4638
smartlist_t * declared_family
Definition: or.h:2272
int SocksTimeout
Definition: or.h:3978
char * body
Definition: or.h:2462
char * requested_resource
Definition: or.h:1842
int ExtORPortCookieAuthFileGroupReadable
Definition: or.h:4126
int DirReqStatistics_option
Definition: or.h:4238
Definition: or.h:3476
struct connection_t connection_t
unsigned int is_possible_guard
Definition: or.h:2539
uint16_t ipv6_orport
Definition: or.h:2357
int ExitPolicyRejectLocalInterfaces
Definition: or.h:3727
dirinfo_type_t type
Definition: or.h:5407
bootstrap_status_t
Definition: or.h:5069
Definition: or.h:2973
unsigned int unreachable_count
Definition: or.h:5311
routerset_t * TestingDirAuthVoteExit
Definition: or.h:4431
uint16_t HTTPSProxyPort
Definition: or.h:4029
store_type_t type
Definition: or.h:2796
int OfflineMasterKey
Definition: or.h:4602
char * contact_info
Definition: or.h:2274
channel_t * n_chan
Definition: or.h:3064
smartlist_t * testing_cell_stats
Definition: or.h:3183
unsigned int is_bad_exit
Definition: or.h:2541
struct node_t node_t
char * protocol_list
Definition: or.h:2257
unsigned int is_valid
Definition: or.h:2535
char * PidFile
Definition: or.h:3698
#define DIGEST_LEN
Definition: crypto_digest.h:22
Definition: or.h:2504
time_t last_listed_as_valid_until
Definition: or.h:2179
time_t addr_current_at
Definition: or.h:5409
smartlist_t * routers
Definition: or.h:2822
routerset_t * ExitNodes
Definition: or.h:3700
struct port_cfg_t port_cfg_t
unsigned int received_certs_cell
Definition: or.h:1540
strmap_t * digests
Definition: or.h:2773
int FascistFirewall
Definition: or.h:3934
char * exitsummary
Definition: or.h:2397
smartlist_t * voters
Definition: or.h:2744
int ClientBootstrapConsensusFallbackDownloadInitialDelay
Definition: or.h:4384
unsigned int timed_out
Definition: or.h:5306
int HiddenServiceStatistics_option
Definition: or.h:4260
Definition: or.h:2786
int marked_for_close_orig_reason
Definition: or.h:3172
unsigned int linked_conn_is_closed
Definition: or.h:1367
uint8_t isolation_flags
Definition: or.h:1249
Definition: or.h:857
unsigned int have_sent_protocolinfo
Definition: or.h:1893
extend_info_t * extend_info
Definition: or.h:2946
uint16_t or_port
Definition: or.h:2354
routerstatus_format_type_t
Definition: or.h:5099
uint8_t type
Definition: or.h:3628
char * HTTPProxy
Definition: or.h:4022
unsigned int digest_sent_data
Definition: or.h:1567
size_t annotations_len
Definition: or.h:2150
tor_x509_cert_t * id_cert
Definition: or.h:1511
uint32_t pathbias_probe_nonce
Definition: or.h:3360
Definition: crypto_digest.h:74
Definition: or.h:2410
unsigned int is_hs_dir
Definition: or.h:2375
int TestingClientDownloadInitialDelay
Definition: or.h:4356
uint16_t dir_port
Definition: or.h:2867
struct protover_summary_flags_t protover_summary_flags_t
uint64_t associated_isolated_stream_global_id
Definition: or.h:3457
time_t expiry_time
Definition: or.h:3009
unsigned int ipv6_preferred
Definition: or.h:2559
routerset_t * ExcludeExitNodesUnion_
Definition: or.h:3718
struct testing_cell_stats_entry_t testing_cell_stats_entry_t
config_line_t * ServerTransportOptions
Definition: or.h:3852
int HiddenServiceSingleHopMode
Definition: or.h:3918
char * GeoIPFile
Definition: or.h:4456
tor_addr_t addr
Definition: or.h:2846
size_t store_len
Definition: or.h:2801
download_want_authority_t
Definition: or.h:2064
ed25519_public_key_t authenticated_ed25519_peer_id
Definition: or.h:1576
char * HTTPProxyAuthenticator
Definition: or.h:4025
Definition: hs_ident.h:93
uint64_t PerConnBWRate
Definition: or.h:4008
config_line_t * Bridges
Definition: or.h:3840
int CircuitBuildTimeout
Definition: or.h:3984
extend_info_t * chosen_exit
Definition: or.h:2990
time_t last_listed
Definition: or.h:2442
char * Socks5ProxyPassword
Definition: or.h:4040
struct tor_cert_st * ed_sign_auth
Definition: or.h:1519
unsigned int received_destroy
Definition: or.h:3105
routerset_t * TestingDirAuthVoteHSDir
Definition: or.h:4441
Definition: or.h:2928
size_t bodylen
Definition: or.h:2464
int ClientPreferIPv6DirPort
Definition: or.h:4295
char * ContactInfo
Definition: or.h:4015
crypto_pk_t * onion_pkey
Definition: or.h:2471
char * CookieAuthFile
Definition: or.h:4121
int ReducedConnectionPadding
Definition: or.h:3866
Definition: or.h:2910
crypto_pk_t * onion_pkey
Definition: or.h:2247
Definition: crypto_ed25519.h:23
int ServerDNSDetectHijacking
Definition: or.h:4203
char * DebugLogFile
Definition: or.h:3680
smartlist_t * net_params
Definition: or.h:2735
int TestingServerDownloadInitialDelay
Definition: or.h:4352
uint32_t n_written_conn_bw
Definition: or.h:1424
unsigned int purpose
Definition: or.h:1332
uint32_t magic
Definition: or.h:3060
struct digest_sd_map_t * desc_by_eid_map
Definition: or.h:2820
smartlist_t * known_flags
Definition: or.h:2731
unsigned int removed
Definition: or.h:3032
uint8_t passwordlen
Definition: or.h:4835
int EnforceDistinctSubnets
Definition: or.h:4225
circid_t circ_id
Definition: or.h:1189
unsigned int has_accepted_serverdesc
Definition: or.h:5404
char * desc_str
Definition: or.h:5258
extend_info_t * n_hop
Definition: or.h:3088
unsigned int has_ed25519_listing
Definition: or.h:2605
char * signature
Definition: or.h:2626
Definition: or.h:5180
Definition: or.h:1177
uint32_t build_time_t
Definition: or.h:4870
int deliver_window
Definition: or.h:3118
Definition: address.h:56
int ServerDNSAllowBrokenConfig
Definition: or.h:4218
time_t LastRotatedOnionKey
Definition: or.h:4777
char * password
Definition: or.h:4842
int TrackHostExitsExpire
Definition: or.h:3964
Definition: or.h:4982
Definition: or.h:4800
pk_op_t
Definition: or.h:5238
char * ControlPortWriteToFile
Definition: or.h:4493
int ClientUseIPv4
Definition: or.h:4280
int package_window
Definition: or.h:1692
config_line_t * ExtORPort_lines
Definition: or.h:3757
int socket_family
Definition: or.h:1391
unsigned int dirconn_direct
Definition: or.h:1843
#define DOWNCAST(to, ptr)
Definition: or.h:121
time_t valid_until
Definition: or.h:2697
unsigned int listed_in_last_desc
Definition: or.h:5315
streamid_t stream_id
Definition: or.h:1240
uint8_t listener_type
Definition: or.h:4812
int failure_count
Definition: or.h:3007
int TestingBridgeBootstrapDownloadInitialDelay
Definition: or.h:4402
tor_addr_t addr
Definition: or.h:3625
int PathBiasUseThreshold
Definition: or.h:4561
struct rend_encoded_v2_service_descriptor_t rend_encoded_v2_service_descriptor_t
int AllowNonRFC953Hostnames
Definition: or.h:4227
Headers for compress.c.
int ExitPortStatistics
Definition: or.h:4244
unsigned int socks_iso_keep_alive
Definition: or.h:1258
int conn_array_index
Definition: or.h:1375
int SSLKeyLifetime
Definition: or.h:4574
Headers for crypto.c.
uint64_t MaxMemInQueues
Definition: or.h:3789
unsigned int refcount
Definition: or.h:2975
Definition: or.h:1237
Definition: or.h:5214
struct authority_cert_t authority_cert_t
char * protocols
Definition: or.h:2600
struct cell_t cell_t
struct edge_connection_t * next_stream
Definition: or.h:1690
struct ns_detached_signatures_t ns_detached_signatures_t
uint8_t state
Definition: or.h:3107
smartlist_t * package_lines
Definition: or.h:2706
unsigned int is_canonical
Definition: or.h:1997
Definition: or.h:2636
struct extend_info_t extend_info_t
uint8_t purpose
Definition: or.h:3108
unsigned int chosen_exit_optional
Definition: or.h:1813
unsigned int supports_v3_hsdir
Definition: or.h:2223
struct digest_ei_map_t * extra_info_map
Definition: or.h:2816
int FetchServerDescriptors
Definition: or.h:3881
struct or_circuit_t or_circuit_t
config_line_t * OutboundBindAddressExit
Definition: or.h:3739
tor_addr_t ipv6_addr
Definition: or.h:5388
uint32_t incoming_cmd_len
Definition: or.h:1908
unsigned int write_blocked_on_bw
Definition: or.h:1339
uint32_t n_written
Definition: or.h:1726
circuit_status_event_t
Definition: or.h:5001
config_line_t * RecommendedVersions
Definition: or.h:3746
setopt_err_t
Definition: or.h:4963
time_t published
Definition: or.h:2023
unsigned int allow_single_hop_exits
Definition: or.h:2279
Definition: or.h:3624
int deliver_window
Definition: or.h:2965
Definition: or.h:5101
char * Socks5ProxyUsername
Definition: or.h:4039
uint64_t RelayBandwidthRate
Definition: or.h:4004
struct tor_version_t tor_version_t
unsigned int is_fast
Definition: or.h:2361
int AuthDirPinKeys
Definition: or.h:4091
int ControlSocketsGroupWritable
Definition: or.h:3780
uint16_t prt_min
Definition: or.h:2012
int DoSRefuseSingleHopClientRendezvous
Definition: or.h:4702
struct signed_descriptor_t signed_descriptor_t
unsigned int streams_blocked_on_n_chan
Definition: or.h:3092
char * dir_compressed
Definition: or.h:2020
config_line_t * ReachableORAddresses
Definition: or.h:3938
dirinfo_type_t PublishServerDescriptor_
Definition: or.h:3878
Definition: token_bucket.h:59
#define MAX_NICKNAME_LEN
Definition: or.h:124
int ExtraInfoStatistics
Definition: or.h:4267
int MaxClientCircuitsPending
Definition: or.h:4500
int accepted_introduce2_count
Definition: or.h:5325
unsigned int is_stable
Definition: or.h:2360
Definition: or.h:1204
unsigned int num_circuits_launched
Definition: or.h:1802
time_t time_to_expire
Definition: or.h:5341
config_line_t * EntryGuards
Definition: or.h:4729
Definition: or.h:2144
char * Socks4Proxy
Definition: or.h:4032
struct circuit_t circuit_t
unsigned int is_named
Definition: or.h:2367
uint32_t n_delivered_read_circ_bw
Definition: or.h:3276
unsigned int is_unnamed
Definition: or.h:2368
int ConnDirectionStatistics
Definition: or.h:4247
Header file for replaycache.c.
time_t next_write
Definition: or.h:4713
crypt_path_t * cpath
Definition: or.h:3302
#define tor_assert(expr)
Definition: util_bug.h:68
Definition: or.h:1287
time_t LastWritten
Definition: or.h:4716
struct crypt_path_t * prev
Definition: or.h:2960
tor_x509_cert_t * link_cert
Definition: or.h:1508
digestmap_t * desc_digest_map
Definition: or.h:2761
int DoSCircuitCreationRate
Definition: or.h:4681
int TestingBridgeDownloadInitialDelay
Definition: or.h:4398
routerstatus_t status
Definition: or.h:2591
unsigned int active_on_link
Definition: or.h:1364
Definition: or.h:5157
int LogMessageDomains
Definition: or.h:3673
struct var_cell_t var_cell_t
smartlist_t * LongLivedPorts
Definition: or.h:3952
crypt_path_t * cpath
Definition: or.h:2978
uint8_t n_download_attempts
Definition: or.h:2112
int package_window
Definition: or.h:2963
unsigned int in_flushed_some
Definition: or.h:1349
uint32_t n_overhead_read_circ_bw
Definition: or.h:3286
unsigned int supports_extend2_cells
Definition: or.h:2203
char * User
Definition: or.h:3754
common_digests_t digests
Definition: or.h:2024
unsigned int isolation_any_streams_attached
Definition: or.h:3422
uint8_t router_purpose
Definition: or.h:1847
int ServerDNSRandomizeCase
Definition: or.h:4205
unsigned int socks_prefer_no_auth
Definition: or.h:4830
struct origin_circuit_t origin_circuit_t
consensus_flavor_t flavor
Definition: or.h:2689
char * Address
Definition: or.h:3697
relay_crypto_t crypto
Definition: or.h:3506
uint16_t prt_max
Definition: or.h:2013
struct circuit_t * on_circuit
Definition: or.h:1696
unsigned int want_onehop
Definition: or.h:1806
uint32_t n_overhead_written_circ_bw
Definition: or.h:3291
double circuit_build_times_quantile_cutoff(void)
Definition: circuitstats.c:264
unsigned int has_bandwidth
Definition: or.h:2381
addressmap_entry_source_t
Definition: or.h:4974
int AuthDirSharedRandomness
Definition: or.h:4626
unsigned int onehop_tunnel
Definition: or.h:3000
char * nickname
Definition: or.h:2234
int CellStatistics
Definition: or.h:4250
size_t dir_compressed_len
Definition: or.h:2022
tor_addr_t Socks5ProxyAddr
Definition: or.h:4037
crypto_pk_t * intro_key
Definition: or.h:5298
int vote_delay
Definition: or.h:5131
int MaxCircuitDirtiness
Definition: or.h:3996
Definition: or.h:5210
crypto_dh_t * rend_dh_handshake_state
Definition: or.h:2940
uint8_t command
Definition: or.h:1187
config_line_t * ExitPolicy
Definition: or.h:3723
unsigned int proxy_state
Definition: or.h:1370
long uptime
Definition: or.h:2271
uint16_t marked_for_close
Definition: or.h:3160
unsigned int got_auth
Definition: or.h:4826
char * VirtualAddrNetworkIPv6
Definition: or.h:4198
int AvoidDiskWrites
Definition: or.h:3862
struct tor_cert_st * own_link_cert
Definition: or.h:1556
unsigned int chosen_exit_retries
Definition: or.h:1818
config_line_t * ExtraLines
Definition: or.h:4774
int PaddingStatistics
Definition: or.h:4253
Definition: container.h:18
config_line_t * NATDPort_lines
Definition: or.h:3771
unsigned int has_exitsummary
Definition: or.h:2382
int signature_len
Definition: or.h:2628
or_handshake_certs_t * certs
Definition: or.h:1590
config_line_t * DirPolicy
Definition: or.h:3733
int SafeSocks
Definition: or.h:4151
int ProtocolWarnings
Definition: or.h:4153
uint32_t bandwidthrate
Definition: or.h:2261
dirinfo_type_t
Definition: or.h:2879
circuit_status_minor_event_t
Definition: or.h:5011
int32_t circuit_build_times_initial_timeout(void)
Definition: circuitstats.c:367
int last_delay_used
Definition: or.h:2131
Header file to define uint32_t and friends.
circuitmux_t * p_mux
Definition: or.h:3497
int KeepalivePeriod
Definition: or.h:3976
Definition: d.py:1
digest_algorithm_t alg
Definition: or.h:2624
smartlist_t * Schedulers
Definition: or.h:4663
Definition: or.h:2687
struct create_cell_t * n_chan_create_cell
Definition: or.h:3124
routerset_t * Tor2webRendezvousPoints
Definition: or.h:3897
unsigned int use_cached_ipv4_answers
Definition: or.h:1278
Definition: or.h:5107
unsigned int policy_is_reject_star
Definition: or.h:2284
char * incoming_cmd
Definition: or.h:1913
double DirAuthorityFallbackRate
Definition: or.h:4054
replaycache_t * accepted_intro_rsa_parts
Definition: or.h:5320
int16_t country_t
Definition: or.h:2192
int UseEntryGuards
Definition: or.h:4171
Definition: or.h:2326
int ServerDNSSearchDomains
Definition: or.h:4200
int DisableNetwork
Definition: or.h:4508
int Sandbox
Definition: or.h:4150
crypto_pk_t * pk
Definition: or.h:5360
stream_status_event_t
Definition: or.h:5018
Definition: shared_random.h:60
Definition: or.h:4979
uint16_t dir_port
Definition: or.h:5390
int TestingV3AuthInitialDistDelay
Definition: or.h:4334
Definition: or.h:3025
int max_introductions
Definition: or.h:5331
unsigned int is_exit
Definition: or.h:2540
Definition: hs_ident.h:42
path_state_t
Definition: or.h:3212
struct or_handshake_state_t or_handshake_state_t
int ExitRelay
Definition: or.h:4584
double KISTSockBufSizeFactor
Definition: or.h:4659
config_line_t * AuthDirReject
Definition: or.h:4070
unsigned int is_exit
Definition: or.h:2359
struct connection_t * linked_conn
Definition: or.h:1413
networkstatus_sr_info_t sr_info
Definition: or.h:2764
const char * description
Definition: or.h:2792
int AuthDirListBadExits
Definition: or.h:4086
uint8_t purpose
Definition: or.h:2322
Definition: or.h:5213
saved_location_t
Definition: or.h:2032
unsigned int bw_is_unmeasured
Definition: or.h:2383
rend_auth_type_t
Definition: or.h:826
Definition: or.h:1197
config_line_t * HashedControlPassword
Definition: or.h:4115
int ShutdownWaitLength
Definition: or.h:4141
struct or_circuit_t * rend_splice
Definition: or.h:3510
config_line_t * ReachableDirAddresses
Definition: or.h:3939
Definition: compress.c:459
ed25519_public_key_t ed25519_id
Definition: or.h:2523
routerset_t * HSLayer3Nodes
Definition: or.h:3905
Definition: or.h:2039
uint8_t maskbits_t
Definition: address.h:51
int nodelist_idx
Definition: or.h:2512
routerset_t * TestingDirAuthVoteGuard
Definition: or.h:4436
int PathBiasCircThreshold
Definition: or.h:4535
cell_direction_t
Definition: or.h:917
int RefuseUnknownExits
Definition: or.h:3948
unsigned int no_save
Definition: or.h:2446
int ClientBootstrapConsensusAuthorityOnlyDownloadInitialDelay
Definition: or.h:4394
Definition: or.h:188
uint32_t n_read_circ_bw
Definition: or.h:3266
struct extrainfo_t extrainfo_t
uint8_t command
Definition: or.h:4810
int marked_for_close_reason
Definition: or.h:3168
size_t journal_len
Definition: or.h:2799
unsigned int good_signature
Definition: or.h:2631
time_t published_on
Definition: or.h:2345
Definition: or.h:5105
streamid_t next_stream_id
Definition: or.h:3400
struct packed_cell_t packed_cell_t
int ExtendAllowPrivateAddresses
Definition: or.h:3753
int NumEntryGuards
Definition: or.h:4173
unsigned int remaining_relay_early_cells
Definition: or.h:3322
unsigned int name_lookup_warned
Definition: or.h:2548
uint16_t port
Definition: or.h:4822
#define MAX_RELAY_EARLY_CELLS_PER_CIRCUIT
Definition: or.h:3195
Definition: or.h:2618
uint64_t ConstrainedSockSize
Definition: or.h:3942
int OwningControllerFD
Definition: or.h:4139
uint32_t processed_cells
Definition: or.h:3528
size_t bytes_dropped
Definition: or.h:2804
onion_handshake_state_t handshake_state
Definition: or.h:2937
int SigningKeyLifetime
Definition: or.h:4587
struct rend_service_authorization_t rend_service_authorization_t
char * contact
Definition: or.h:2647
char * ExtORPortCookieAuthFile
Definition: or.h:4123
unsigned int ed25519_reflects_consensus
Definition: or.h:2609
Definition: or.h:4985
int session_group
Definition: or.h:1250
int port
Definition: or.h:3626
struct tor_cert_st * ed_sign_link
Definition: or.h:1516
struct event * read_event
Definition: or.h:1377
config_line_t * AlternateDirAuthority
Definition: or.h:4058
int ExitPolicyRejectPrivate
Definition: or.h:3724
struct buf_t * pending_optimistic_data
Definition: or.h:1780
smartlist_t * FirewallPorts
Definition: or.h:3935
uint8_t command
Definition: or.h:3026
unsigned int isolation_values_set
Definition: or.h:3416
config_line_t * NodeFamilies
Definition: or.h:4065
Definition: or.h:4976
char * AndroidIdentityTag
Definition: or.h:3678
size_t dir_len
Definition: or.h:2021
uint8_t pathbias_shouldcount
Definition: or.h:3349
Definition: or.h:4988
config_line_t * AddressMap
Definition: or.h:3966
uint8_t num_socks_retries
Definition: or.h:1775
unsigned int edge_blocked_on_circ
Definition: or.h:1739
int TestingAuthKeySlop
Definition: or.h:4598
char * ConsensusParams
Definition: or.h:4318
unsigned int in_connection_handle_write
Definition: or.h:1352
uint8_t isolation_flags_mixed
Definition: or.h:3427
int DoSConnectionEnabled
Definition: or.h:4694
Definition: or.h:2581
config_line_t * HidServRevCounter
Definition: or.h:4737
streamid_t pathbias_probe_id
Definition: or.h:3356
int UseGuardFraction
Definition: or.h:4178
desc_store_t extrainfo_store
Definition: or.h:2831
Definition: or.h:5144
time_t expires
Definition: or.h:2863
int TestingAuthKeyLifetime
Definition: or.h:4591
int global_origin_circuit_list_idx
Definition: or.h:3318
int all_uploads_performed
Definition: or.h:5370
unsigned int read_blocked_on_bw
Definition: or.h:1337
unsigned int is_bad_exit
Definition: or.h:2373
Definition: or.h:3250
ed25519_public_key_t ed_identity
Definition: or.h:2844
uint32_t n_delivered_written_circ_bw
Definition: or.h:3281
int relay_early_cells_sent
Definition: or.h:3396
uint64_t BandwidthRate
Definition: or.h:3998
config_line_t * FallbackDir
Definition: or.h:4048
unsigned int is_outgoing
Definition: or.h:1653
char * address
Definition: or.h:1406
int circuit_idle_timeout
Definition: or.h:3468
int FetchHidServDescriptors
Definition: or.h:3882
int vote_interval
Definition: or.h:5127
char * KeyDirectory_option
Definition: or.h:3686
Definition: or.h:1326
Definition: or.h:2888
int DisablePredictedCircuits
Definition: or.h:4131
int CookieAuthentication
Definition: or.h:4119
struct crypt_path_t * cpath_layer
Definition: or.h:1701
unsigned int has_measured_bws
Definition: or.h:2690
Definition: or.h:5359
struct entry_connection_t entry_connection_t
int ReloadTorrcOnSIGHUP
Definition: or.h:4466
int HeartbeatPeriod
Definition: or.h:4017
protover_summary_flags_t pv
Definition: or.h:2300
smartlist_t * ServerDNSTestAddresses
Definition: or.h:4222
token_bucket_rw_t bucket
Definition: or.h:1675
Definition: or.h:5295
struct buf_t * outbuf
Definition: or.h:1380
char * BridgePassword_AuthDigest_
Definition: or.h:3837
config_line_t * OutboundBindAddress
Definition: or.h:3735
int MinUptimeHidServDirectoryV2
Definition: or.h:3884
cell_queue_t p_chan_cells
Definition: or.h:3490
Definition: or.h:5189
store_type_t
Definition: or.h:2779
routerset_t * HSLayer2Nodes
Definition: or.h:3901
unsigned int supports_ed25519_hs_intro
Definition: or.h:2218
int BridgeRelay
Definition: or.h:3854
Definition: or.h:5193
time_t sent_versions_at
Definition: or.h:1532
uint16_t or_port
Definition: or.h:5391
Definition: or.h:2655
config_line_t * Logs
Definition: or.h:3669
int ConnectionPadding
Definition: or.h:3872
unsigned int circuit_carries_hs_traffic_stats
Definition: or.h:3524
Definition: or.h:5163
struct control_connection_t control_connection_t
int dist_seconds
Definition: or.h:2713
uint64_t AuthDirFastGuarantee
Definition: or.h:4095
tor_addr_t Socks4ProxyAddr
Definition: or.h:4033
tor_socket_t s
Definition: or.h:1374
unsigned int supports_ed25519_link_handshake_any
Definition: or.h:2213
time_t BWHistoryReadEnds
Definition: or.h:4747
unsigned int is_possible_guard
Definition: or.h:2371
#define ORIGIN_CIRCUIT_MAGIC
Definition: or.h:3013
signed_descriptor_t cache_info
Definition: or.h:2855
channel_tls_t * chan
Definition: or.h:1638
Headers for address.h.
uint32_t measured_bw_kb
Definition: or.h:2610
int AuthoritativeDir
Definition: or.h:3819
config_line_t * AuthDirInvalid
Definition: or.h:4072
Definition: microdesc.c:29
Definition: or.h:1214
unsigned int is_hibernating
Definition: or.h:2275
int UpdateBridgesFromAuthority
Definition: or.h:3860
Definition: or.h:2035
int UseDefaultFallbackDirs
Definition: or.h:4050
struct or_connection_t or_connection_t
Definition: or.h:4993
Definition: or.h:4708
unsigned int protocols_known
Definition: or.h:2199
uint32_t inserted_timestamp
Definition: or.h:1208
char * SafeLogging
Definition: or.h:4143
tor_addr_t ipv6_addr
Definition: or.h:2477
int GeoIPExcludeUnknown
Definition: or.h:4462
unsigned int is_hs_dir
Definition: or.h:2543
int n
Definition: or.h:1233
smartlist_t * family
Definition: or.h:2481
uint64_t event_mask
Definition: or.h:1888
unsigned int socks_prefer_no_auth
Definition: or.h:1256
unsigned int n_delete_pending
Definition: or.h:3102
int global_circuitlist_idx
Definition: or.h:3178
Definition: or.h:3220
uint64_t MaxAdvertisedBandwidth
Definition: or.h:4002
struct buf_t * inbuf
Definition: or.h:1379
config_line_t * OutboundBindAddressOR
Definition: or.h:3737
uint32_t global_identifier
Definition: or.h:3409
download_status_t ei_dl_status
Definition: or.h:2168
int RunAsDaemon
Definition: or.h:3933
uint16_t streamid_t
Definition: or.h:1032
unsigned int need_capacity
Definition: or.h:2994
circid_t circ_id
Definition: or.h:1178
int DirReqStatistics
Definition: or.h:4241
int ConnLimit_low_thresh
Definition: or.h:3931
char * SyslogIdentityTag
Definition: or.h:3677
config_line_t * ReachableAddresses
Definition: or.h:3937
protover_summary_flags_t pv
Definition: or.h:2387
time_t next_attempt_at
Definition: or.h:2108
int ConnLimit
Definition: or.h:3927
int TestingClientMaxIntervalWithoutRequest
Definition: or.h:4407
int DisableSignalHandlers
Definition: or.h:4673
uint16_t dir_port
Definition: or.h:2645
int refcnt
Definition: or.h:2027
unsigned int circuit_retries
Definition: or.h:5348
config_line_t * DirPort_lines
Definition: or.h:3783
Definition: compat.h:316
Definition: or.h:2808
saved_location_t saved_location
Definition: or.h:2170
circid_t p_circ_id
Definition: or.h:3488
tor_addr_t ipv6_addr
Definition: or.h:2356
int RendPostPeriod
Definition: or.h:3974
int LogTimeGranularity
Definition: or.h:3671
int ExtendByEd25519ID
Definition: or.h:4633
int FetchDirInfoExtraEarly
Definition: or.h:4190
unsigned int tracked_for_dos_mitigation
Definition: or.h:1662
uint32_t bandwidthcapacity
Definition: or.h:2265
unsigned int streams_blocked_on_p_chan
Definition: or.h:3095
int TestingLinkCertLifetime
Definition: or.h:4589
Definition: compat_time.h:33
char * VirtualAddrNetworkIPv4
Definition: or.h:4196
char rend_circ_nonce[DIGEST_LEN]
Definition: or.h:3513
int VersioningAuthoritativeDir
Definition: or.h:3822
int ClientUseIPv6
Definition: or.h:4285
char * recommended_relay_protocols
Definition: or.h:2724
struct digest_ri_map_t * identity_map
Definition: or.h:2810
uint16_t payload_len
Definition: or.h:1191
uint32_t n_written_circ_bw
Definition: or.h:3271
uint32_t bandwidthburst
Definition: or.h:2263
unsigned int has_guardfraction
Definition: or.h:2393
time_t timestamp_lastempty
Definition: or.h:1673
smartlist_t * WarnPlaintextPorts
Definition: or.h:3961
char * Socks5Proxy
Definition: or.h:4036
struct routerstatus_t routerstatus_t
circ_id_type_t
Definition: or.h:186
int ConnLimit_high_thresh
Definition: or.h:3929
#define DIGEST256_LEN
Definition: crypto_digest.h:25
int Tor2webMode
Definition: or.h:3894
Definition: or.h:3215
Definition: crypto.c:77
off_t off
Definition: or.h:2454
config_line_t * ControlPort_lines
Definition: or.h:3775
char * safecookie_client_hash
Definition: or.h:1905
unsigned int received_versions
Definition: or.h:1536
outbound_addr_t
Definition: or.h:3652
struct rend_data_t rend_data_t
unsigned int prefer_ipv6_virtaddr
Definition: or.h:1283
struct short_policy_t * ipv6_exit_policy
Definition: or.h:2270
int DoSCircuitCreationMinConnections
Definition: or.h:4679
Definition: or.h:5382
Definition: or.h:1221
uint16_t Socks4ProxyPort
Definition: or.h:4034
int LeaveStreamsUnattached
Definition: or.h:4128
int FetchDirInfoEarly
Definition: or.h:4187
struct microdesc_t microdesc_t
rend_data_t * rend_data
Definition: or.h:1856
int TestingV3AuthInitialVoteDelay
Definition: or.h:4330
uint16_t end_reason
Definition: or.h:1720
int nr_streams
Definition: or.h:854
unsigned int is_running
Definition: or.h:2533
Definition: or.h:1230
vote_microdesc_hash_t * microdesc
Definition: or.h:2612
int DirCache
Definition: or.h:4192
int AuthDirHasIPv6Connectivity
Definition: or.h:4090
int NewCircuitPeriod
Definition: or.h:3994
#define CELL_MAX_NETWORK_SIZE
Definition: or.h:1001
struct rend_intro_point_t rend_intro_point_t
time_t timestamp_created
Definition: or.h:1389
int TestingClientConsensusDownloadInitialDelay
Definition: or.h:4364
config_line_t * AuthDirBadExit
Definition: or.h:4068
Definition: or.h:2018
struct desc_store_t desc_store_t
struct vote_microdesc_hash_t vote_microdesc_hash_t
Definition: or.h:4944
config_line_t * Guard
Definition: or.h:4732
smartlist_t * NodeFamilySets
Definition: or.h:4067
smartlist_t * intro_nodes
Definition: or.h:5368
Header file for hs_circuitmap.c.
uint32_t address_ttl
Definition: or.h:1711
Definition: or.h:3237
unsigned int supports_v3_rendezvous_point
Definition: or.h:2228
uint16_t marked_for_close
Definition: or.h:1400
struct circuit_guard_state_t * guard_state
Definition: or.h:1865
unsigned int needs_retest_if_added
Definition: or.h:2288
struct tor_cert_st * ed_id_sign
Definition: or.h:1513
config_line_t * DNSPort_lines
Definition: or.h:3784
struct short_policy_t short_policy_t
char * client_versions
Definition: or.h:2717
#define VAR_CELL_MAX_HEADER_SIZE
Definition: or.h:1004
time_t timestamp
Definition: or.h:5362
int RephistTrackTime
Definition: or.h:4184
smartlist_t * PublishServerDescriptor
Definition: or.h:3876
Definition: or.h:5109
uint32_t n_read
Definition: or.h:1723
struct listener_connection_t listener_connection_t
Definition: or.h:187
tor_addr_t real_addr
Definition: or.h:1640
int AutomapHostsOnResolve
Definition: or.h:3967
unsigned int have_noted_bootstrap_problem
Definition: or.h:1658
time_t cert_expiration_time
Definition: or.h:2253
#define REND_NUMBER_OF_NON_CONSECUTIVE_REPLICAS
Definition: or.h:772
struct rend_authorized_client_t rend_authorized_client_t
uint32_t inserted_timestamp
Definition: or.h:1224
int UsingTestNetworkDefaults_
Definition: or.h:4486
uint16_t idle_timeout
Definition: or.h:1666
char * TransProxyType
Definition: or.h:3762
Definition: or.h:919
int version
Definition: or.h:5361
struct onion_queue_t * onionqueue_entry
Definition: or.h:3481
crypto_pk_t * signing_key
Definition: or.h:2859
Definition: or.h:5207
unsigned int is_authority
Definition: or.h:5399
uint32_t n_read_conn_bw
Definition: or.h:1420
int TestingEstimatedDescriptorPropagationTime
Definition: or.h:4348
Definition: or.h:5124
Definition: or.h:1428
unsigned int edge_has_sent_end
Definition: or.h:1733
Definition: or.h:1529
Definition: onion.c:85
Definition: or.h:3229
char * original_dest_address
Definition: or.h:1766
uint64_t AccountingMax
Definition: or.h:4103
Definition: or.h:1885
int after_firsthop_idx
Definition: or.h:4955
int TestingServerConsensusDownloadInitialDelay
Definition: or.h:4360
uint8_t command
Definition: or.h:1179
int DoSCircuitCreationDefenseType
Definition: or.h:4687
unsigned int bad_signature
Definition: or.h:2629
smartlist_t * hsdirs_fp
Definition: or.h:848
Definition: or.h:3218
char * ext_or_auth_correct_client_hash
Definition: or.h:1624
unsigned int type
Definition: or.h:1331
int DisableAllSwap
Definition: or.h:3720
config_line_t * MyFamily
Definition: or.h:4064
unsigned int is_private
Definition: or.h:1995
char * BridgeDistribution
Definition: or.h:3830
config_line_t * MyFamily_lines
Definition: or.h:4063
int ConstrainedSockets
Definition: or.h:3941
unsigned int bad_sig
Definition: or.h:2334
unsigned int relaxed_timeout
Definition: or.h:3380
struct destroy_cell_queue_t destroy_cell_queue_t
char * platform
Definition: or.h:2255
unsigned int remaining_relay_early_cells
Definition: or.h:3517
uint32_t age_tmp
Definition: or.h:3121
int TestingAuthDirTimeToLearnReachability
Definition: or.h:4343
int NumCPUs
Definition: or.h:4010
int n_intervals_valid
Definition: or.h:5129
char * TorVersion
Definition: or.h:4770
unsigned int omit_from_vote
Definition: or.h:2297
buildtimeout_set_event_t
Definition: or.h:5041
Definition: or.h:5152
int CacheDirectoryGroupReadable
Definition: or.h:3694
unsigned int circuit_established
Definition: or.h:5352
Definition: channel.h:326
int DisableOOSCheck
Definition: or.h:4629
uint64_t global_identifier
Definition: or.h:1416
Definition: or.h:2107
char * chosen_exit_name
Definition: or.h:1755
char * Nickname
Definition: or.h:3696
Definition: or.h:1185
char * address
Definition: or.h:2643
int ControlPortFileGroupReadable
Definition: or.h:4495
Definition: or.h:1500
struct vote_routerstatus_t vote_routerstatus_t
#define REND_SERVICE_ID_LEN_BASE32
Definition: or.h:755
unsigned int is_accept
Definition: or.h:2418
rend_data_t * rend_data
Definition: or.h:1704
unsigned int caches_extra_info
Definition: or.h:2277
edge_connection_t * n_streams
Definition: or.h:3499
unsigned int hs_circ_has_timed_out
Definition: or.h:3376
uint64_t PerConnBWBurst
Definition: or.h:4009
Definition: or.h:1247
download_schedule_t
Definition: or.h:2052
config_line_t * RendConfigLines
Definition: or.h:4011
Definition: onion_fast.h:18
config_line_t * SocksPolicy
Definition: or.h:3732
int ServerDNSAllowNonRFC953Hostnames
Definition: or.h:4230
struct document_signature_t document_signature_t
char * CacheDirectory_option
Definition: or.h:3691
smartlist_t * supported_methods
Definition: or.h:2703
channel_t * p_chan
Definition: or.h:3492
int package_window
Definition: or.h:3113
Definition: crypto_curve25519.h:24
char * AccelName
Definition: or.h:4161
#define CELL_PAYLOAD_SIZE
Definition: or.h:998
int routerlist_index
Definition: or.h:2176
int TestingDirConnectionMaxStall
Definition: or.h:4411
time_t published_on
Definition: or.h:2159
time_t timestamp_last_read_allowed
Definition: or.h:1384
Definition: torcert.h:23
uint32_t magic
Definition: or.h:1327
uint8_t socks_version
Definition: or.h:4804
int V3AuthVoteDelay
Definition: or.h:4300
config_line_t * BuildtimeHistogram
Definition: or.h:4765
Definition: or.h:3059
routerset_t * EntryNodes
Definition: or.h:3703
uint16_t link_proto
Definition: or.h:1664
const char * marked_for_close_file
Definition: or.h:1404
bandwidth_weight_rule_t
Definition: or.h:5456
Definition: workqueue.c:93
config_line_t * HTTPTunnelPort_lines
Definition: or.h:3774
size_t ed_rsa_crosscert_len
Definition: or.h:1523
size_t signed_descriptor_len
Definition: or.h:2152
int BridgeAuthoritativeDir
Definition: or.h:3825
tor_mmap_t * mmap
Definition: or.h:2794
int TestingV3AuthInitialVotingInterval
Definition: or.h:4326
crypto_pk_t * onion_key
Definition: or.h:2847
crypt_path_t * pending_final_cpath
Definition: or.h:3002
const char * fname_base
Definition: or.h:2790
addr_policy_result_t
Definition: or.h:5221
uint32_t guardfraction_percentage
Definition: or.h:2395
struct dir_connection_t dir_connection_t
smartlist_t * successful_uploads
Definition: or.h:5375
uint64_t dirreq_id
Definition: or.h:3175
time_t last_dir_503_at
Definition: or.h:2403
size_t outbuf_flushlen
Definition: or.h:1382
crypto_cipher_t * f_crypto
Definition: or.h:2914
int DisableDebuggerAttachment
Definition: or.h:4214
uint16_t port
Definition: or.h:1397
smartlist_t * old_routers
Definition: or.h:2825
char * signed_descriptor_body
Definition: or.h:2148
Definition: or.h:5208
int DoSCircuitCreationEnabled
Definition: or.h:4676
int UseEntryGuards_option
Definition: or.h:4166
smartlist_t * routerstatus_list
Definition: or.h:2757
Definition: or.h:1833
config_line_t * DirAuthorities
Definition: or.h:4045
#define OR_CIRCUIT_MAGIC
Definition: or.h:3015
int IncludeUsed
Definition: or.h:4641
uint64_t dirreq_id
Definition: or.h:1873
struct authority_cert_t * cert
Definition: or.h:2746
cpath_build_state_t * build_state
Definition: or.h:3296
struct download_status_t download_status_t
Definition: or.h:2415
Definition: or.h:1749
short_policy_t * ipv6_exit_policy
Definition: or.h:2485
unsigned int held_by_nodes
Definition: or.h:2450
int MaxConsensusAgeForDiffs
Definition: or.h:4646
unsigned int cache_ipv4_answers
Definition: or.h:1271
uint8_t last_backoff_position
Definition: or.h:2127
maskbits_t maskbits
Definition: or.h:2000
int ClientRejectInternalAddresses
Definition: or.h:4276
edge_connection_t * resolving_streams
Definition: or.h:3502
int DoSCircuitCreationDefenseTimePeriod
Definition: or.h:4691
uint16_t length
Definition: or.h:1242
rend_data_t * rend_data
Definition: or.h:3305
consensus_flavor_t
Definition: or.h:2677
uint16_t ipv6_orport
Definition: or.h:5392
char * AccountingStart
Definition: or.h:4101
int DataDirectoryGroupReadable
Definition: or.h:3684
strmap_t * signatures
Definition: or.h:2774
int LearnCircuitBuildTimeout
Definition: or.h:3980
Definition: or.h:5215
int nonlive_timeouts
Definition: or.h:4948
struct short_policy_entry_t short_policy_entry_t
uint16_t or_port
Definition: or.h:2646
uint32_t circid_t
Definition: or.h:1030
uint64_t RelayBandwidthBurst
Definition: or.h:4006
Definition: or.h:2196
int TestingEnableCellStatsEvent
Definition: or.h:4448
unsigned int supports_ed25519_link_handshake_compat
Definition: or.h:2208
smartlist_t * exit_policy
Definition: or.h:2266
Definition: crypto_rsa.c:41
dirreq_type_t
Definition: or.h:5169
Definition: or.h:1991
uint16_t dir_port
Definition: or.h:2355
country_t country
Definition: or.h:2563
uint8_t auth_type
Definition: or.h:4808
unsigned int proxy_type
Definition: or.h:1654
uint32_t bandwidth_kb
Definition: or.h:2389
int refcnt
Definition: or.h:1992
circuitmux_t * n_mux
Definition: or.h:3079
char * DataDirectory_option
Definition: or.h:3681
uint32_t addr
Definition: or.h:5389
config_line_t * ControlSocket
Definition: or.h:3777
int V3AuthNIntervalsValid
Definition: or.h:4304
Definition: or.h:2046
uint64_t BandwidthBurst
Definition: or.h:4000
unsigned int inbuf_reached_eof
Definition: or.h:1345
int TestSocks
Definition: or.h:4155
struct edge_connection_t edge_connection_t
int KISTSchedRunInterval
Definition: or.h:4656
Definition: or.h:1610
time_t valid_after
Definition: or.h:2694
routerset_t * ExcludeExitNodes
Definition: or.h:3713
Headers for tortls.c.
uint8_t n_download_failures
Definition: or.h:2110
struct event * write_event
Definition: or.h:1378
smartlist_t * weight_params
Definition: or.h:2739
unsigned int hold_open_until_flushed
Definition: or.h:1342
Definition: or.h:2884
edge_connection_t * p_streams
Definition: or.h:3261
crypt_path_reference_t * service_pending_final_cpath_ref
Definition: or.h:3005
unsigned int held_in_map
Definition: or.h:2448
struct cell_queue_t cell_queue_t
Definition: or.h:2882
char * AccelDir
Definition: or.h:4162
crypto_pk_t * identity_key
Definition: or.h:2857
tor_addr_t HTTPSProxyAddr
Definition: or.h:4028
Definition: or.h:5090
int dist_delay
Definition: or.h:5133
struct circuit_guard_state_t * guard_state
Definition: or.h:3314
char * GuardfractionFile
Definition: or.h:4314
short_policy_t * exit_policy
Definition: or.h:2483
tor_addr_t ipv6_addr
Definition: or.h:2244
int TestingV3AuthVotingStartOffset
Definition: or.h:4338
unsigned int started_here
Definition: or.h:1534
time_t timestamp_dirty
Definition: or.h:3158
int consensus_method
Definition: or.h:2701
tor_compress_state_t * compress_state
Definition: or.h:1853
unsigned int use_begindir
Definition: or.h:1809
router_crn_flags_t
Definition: or.h:5463
int started_here
Definition: or.h:1502
uint16_t recognized
Definition: or.h:1239
int BridgeRecordUsageByCountry
Definition: or.h:4453
struct crypt_path_t crypt_path_t
char * CacheDirectory
Definition: or.h:3693
int ClientBootstrapConsensusAuthorityDownloadInitialDelay
Definition: or.h:4374
char * HTTPSProxyAuthenticator
Definition: or.h:4030
int UnixSocksGroupWritable
Definition: or.h:3781
Definition: circuitmux.c:105
char * BridgePassword
Definition: or.h:3834
int UseBridges
Definition: or.h:3839
uint16_t or_port
Definition: or.h:2237
geoip_ns_response_t
Definition: or.h:5150
unsigned protocols
Definition: or.h:5365
unsigned int may_use_optimistic_data
Definition: or.h:1828
char * version
Definition: or.h:2598
Definition: or.h:900
unsigned int p_delete_pending
Definition: or.h:3099
char * V3BandwidthsFile
Definition: or.h:4311
unsigned int reading_from_linked_conn
Definition: or.h:1359
struct tor_cert_st * signing_key_cert
Definition: or.h:2165
int GuardLifetime
Definition: or.h:4577
unsigned nym_epoch
Definition: or.h:1763
int PublishHidServDescriptors
Definition: or.h:3880
struct ext_or_cmd_t ext_or_cmd_t
circid_t n_circ_id
Definition: or.h:3073
unsigned int received_auth_challenge
Definition: or.h:1538
int ClientOnly
Definition: or.h:3864
size_t usernamelen
Definition: or.h:4833
int NumDirectoryGuards
Definition: or.h:4180
unsigned int is_dns_request
Definition: or.h:1729
struct evdns_server_request * dns_server_request
Definition: or.h:1788
unsigned int has_finished
Definition: or.h:4823
int DoSConnectionMaxConcurrentCount
Definition: or.h:4696
Definition: or.h:2986
struct vote_timing_t vote_timing_t
unsigned int linked
Definition: or.h:1356
smartlist_t * sigs
Definition: or.h:2652
config_line_t * ServerTransportPlugin
Definition: or.h:3845
config_line_t * TransPort_lines
Definition: or.h:3761
struct networkstatus_voter_info_t networkstatus_voter_info_t
unsigned int is_owning_control_connection
Definition: or.h:1896
int deliver_window
Definition: or.h:1694
crypto_digest_t * f_digest
Definition: or.h:2920
Definition: or.h:5223
Definition: or.h:2769
tor_addr_t addr
Definition: or.h:1393
uint32_t addr
Definition: or.h:2236
routerstatus_t fake_status
Definition: or.h:5412
hs_token_t * hs_token
Definition: or.h:3187
char * ext_or_conn_id
Definition: or.h:1618
#define SUBTYPE_P(p, subtype, basemember)
Definition: util.h:154
int num_recent_circs
Definition: or.h:4953
int V3AuthVotingInterval
Definition: or.h:4298
time_t fresh_until
Definition: or.h:2695
char * ServerDNSResolvConfFile
Definition: or.h:4207
smartlist_t * FilesOpenedByIncludes
Definition: or.h:4668
char * DataDirectory
Definition: or.h:3683
char * KeyDirectory
Definition: or.h:3688
struct crypt_path_t * next
Definition: or.h:2957
config_line_t * ORPort_lines
Definition: or.h:3755
Definition: aes.c:156
struct workqueue_entry_s * workqueue_entry
Definition: or.h:3485
time_t AccountingIntervalStart
Definition: or.h:4719
struct digest_sd_map_t * desc_digest_map
Definition: or.h:2813
unsigned int writing_to_linked_conn
Definition: or.h:1361
int NumPrimaryGuards
Definition: or.h:4182
uint16_t len
Definition: or.h:1199
struct or_handshake_certs_t or_handshake_certs_t
Definition: or.h:5517
int TestingEnableConnBwEvent
Definition: or.h:4445
int HiddenServiceStatistics
Definition: or.h:4264
uint64_t dirreq_id
Definition: or.h:1744
int IPv6Exit
Definition: or.h:4567
int CircuitStreamTimeout
Definition: or.h:3989
Definition: onion.h:58
uint64_t total_cell_waiting_time
Definition: or.h:3533
int AssumeReachable
Definition: or.h:3818
struct cached_dir_t cached_dir_t
crypto_digest_t * b_digest
Definition: or.h:2922
int ClientPreferIPv6ORPort
Definition: or.h:4290
char * dir
Definition: or.h:2019
uint64_t AuthDirGuardBWGuarantee
Definition: or.h:4099
#define REND_COOKIE_LEN
Definition: or.h:823
uint32_t addr
Definition: or.h:2353
int DoSConnectionDefenseType
Definition: or.h:4699
struct destroy_cell_t destroy_cell_t
Headers for log.c.
struct vote_microdesc_hash_t * next
Definition: or.h:2583
unsigned int is_transparent_ap
Definition: or.h:1822
unsigned int is_reverse_dns_lookup
Definition: or.h:1731
off_t saved_offset
Definition: or.h:2173
#define REND_SERVICE_ADDRESS_LEN
Definition: or.h:758
time_t time_published
Definition: or.h:5336
smartlist_t * spool
Definition: or.h:1851
int DownloadExtraInfo
Definition: or.h:4234
extend_info_t * extend_info
Definition: or.h:5296
char * ext_or_transport
Definition: or.h:1628
unsigned int is_authority
Definition: or.h:2358
int UseMicrodescriptors
Definition: or.h:4490
Definition: or.h:2344
char * command_arg
Definition: or.h:3667
Definition: or.h:3243
int V3AuthoritativeDir
Definition: or.h:3820
geoip_client_action_t
Definition: or.h:5142
int HardwareAccel
Definition: or.h:4157
uint16_t ipv6_orport
Definition: or.h:2479
unsigned int exitward
Definition: or.h:3033
networkstatus_type_t type
Definition: or.h:2688
unsigned int is_valid
Definition: or.h:2370
Definition: or.h:2433
char * address
Definition: or.h:5385
cell_queue_t n_chan_cells
Definition: or.h:3082
size_t replylen
Definition: or.h:4813
struct hs_ident_circuit_t * hs_ident
Definition: or.h:3309
Definition: channel.h:41
Definition: or.h:5249
Definition: or.h:2838
unsigned int wants_to_be_hs_dir
Definition: or.h:2282
smartlist_t * ephemeral_onion_services
Definition: or.h:1899
int CountPrivateBandwidth
Definition: or.h:4221
tor_addr_t HTTPProxyAddr
Definition: or.h:4023
int AuthDirMaxServersPerAddr
Definition: or.h:4088
int8_t * timeouts_after_firsthop
Definition: or.h:4951
char * HTTPSProxy
Definition: or.h:4027
uint64_t TestingMinExitFlagThreshold
Definition: or.h:4424
unsigned int rejects_all
Definition: or.h:2553
Definition: or.h:5146
socks_request_t * socks_request
Definition: or.h:1757
Definition: hs_ident.h:109
#define REND_DESC_COOKIE_LEN
Definition: or.h:790
or_handshake_state_t * handshake_state
Definition: or.h:1670
Definition: or.h:1687
Definition: or.h:5186
Definition: or.h:833
Definition: or.h:5161
time_t published
Definition: or.h:2693
tor_addr_t addr
Definition: or.h:2011
uint16_t port
Definition: or.h:2845
Definition: or.h:2853
or_conn_status_event_t
Definition: or.h:5032
int ClientDNSRejectInternalAddresses
Definition: or.h:4272
crypto_digest_t * digest_sent
Definition: or.h:1583
uint16_t Socks5ProxyPort
Definition: or.h:4038
download_schedule_increment_t
Definition: or.h:2074
int ConnLimit_
Definition: or.h:3928
const char * marked_for_close_file
Definition: or.h:3163
Definition: or.h:5159
Definition: or.h:5228
unsigned int is_ancient
Definition: or.h:3325
unsigned is_unix_addr
Definition: or.h:3629
uint64_t flags
Definition: or.h:2596
smartlist_t * prepend_policy
Definition: or.h:3462
tor_x509_cert_t * auth_cert
Definition: or.h:1505
uint64_t MaxUnparseableDescSizeToLog
Definition: or.h:4620
char * pending_sig
Definition: or.h:2337
uint8_t command
Definition: or.h:1238
unsigned int hs_service_side_rend_circ_has_been_relaunched
Definition: or.h:3388
int AllDirActionsPrivate
Definition: or.h:3888
int TestingTorNetwork
Definition: or.h:4421
unsigned int received_authenticate
Definition: or.h:1542
time_t timestamp_last_write_allowed
Definition: or.h:1386
Definition: or.h:5103
double PathsNeededToBuildCircuits
Definition: or.h:4570
uint32_t addr
Definition: or.h:2644
uint8_t state
Definition: or.h:1330
unsigned int n_entries
Definition: or.h:2420
dirreq_state_t
Definition: or.h:5176
Definition: or.h:3256
version_status_t
Definition: or.h:5206
int EntryStatistics
Definition: or.h:4256
Definition: or.h:191
Definition: or.h:5209
int DoSCircuitCreationBurst
Definition: or.h:4684
addr_policy_action_t
Definition: or.h:1984
Definition: or.h:2590
smartlist_t * RejectPlaintextPorts
Definition: or.h:3957
unsigned int has_measured_bw
Definition: or.h:2602
uint16_t HTTPProxyPort
Definition: or.h:4024
int CircuitsAvailableTimeout
Definition: or.h:3987
unsigned int is_flagged_running
Definition: or.h:2366
unsigned int need_uptime
Definition: or.h:2992
uint32_t addr
Definition: or.h:2865
int MainloopStats
Definition: or.h:4019
rend_auth_type_t auth_type
Definition: or.h:873
int TokenBucketRefillInterval
Definition: or.h:4160
Definition: or.h:918
int desired_path_len
Definition: or.h:2988
uint8_t state
Definition: or.h:2953
size_t pending_sig_len
Definition: or.h:2339
networkstatus_type_t
Definition: or.h:2668
time_t last_reachable
Definition: or.h:2569
struct networkstatus_t networkstatus_t
config_line_t * ClientTransportPlugin
Definition: or.h:3842
unsigned int supports_tunnelled_dir_requests
Definition: or.h:2293
smartlist_t * AutomapHostsSuffixes
Definition: or.h:3973
Definition: or.h:2901
int CookieAuthFileGroupReadable
Definition: or.h:4125
int FetchUselessDescriptors
Definition: or.h:3887
Definition: crypto_digest.c:171
unsigned int has_opened
Definition: or.h:3329
Definition: or.h:2232
time_t network_last_live
Definition: or.h:4946
Definition: or.h:2886
int n
Definition: or.h:1217
int V3AuthDistDelay
Definition: or.h:4302
unsigned int is_canonical
Definition: or.h:1650
char * nickname
Definition: or.h:2639
routerset_t * ExcludeNodes
Definition: or.h:3709
unsigned int waiting_time
Definition: or.h:3031
int OptimisticData
Definition: or.h:4504
int TestingSigningKeySlop
Definition: or.h:4594
config_line_t * HidServAuth
Definition: or.h:4013
int KeepBindCapabilities
Definition: or.h:4615
uint64_t TestingMinFastFlagThreshold
Definition: or.h:4427