tor  0.4.2.0-alpha-dev
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-2019, 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 #include "lib/cc/torint.h"
17 
18 #ifdef HAVE_SIGNAL_H
19 #include <signal.h>
20 #endif
21 #ifdef HAVE_TIME_H
22 #include <time.h>
23 #endif
24 
25 #include "lib/arch/bytes.h"
26 #include "lib/cc/compat_compiler.h"
27 #include "lib/cc/torint.h"
28 #include "lib/container/map.h"
29 #include "lib/buf/buffers.h"
33 #include "lib/ctime/di_ops.h"
34 #include "lib/defs/dh_sizes.h"
35 #include "lib/encoding/binascii.h"
36 #include "lib/encoding/cstring.h"
37 #include "lib/encoding/time_fmt.h"
38 #include "lib/err/torerr.h"
39 #include "lib/fs/dir.h"
40 #include "lib/fs/files.h"
41 #include "lib/fs/mmap.h"
42 #include "lib/fs/path.h"
43 #include "lib/fs/userdb.h"
44 #include "lib/geoip/country.h"
45 #include "lib/intmath/addsub.h"
46 #include "lib/intmath/bits.h"
47 #include "lib/intmath/cmp.h"
48 #include "lib/intmath/logic.h"
49 #include "lib/intmath/muldiv.h"
50 #include "lib/log/escape.h"
51 #include "lib/log/ratelim.h"
52 #include "lib/log/util_bug.h"
53 #include "lib/malloc/malloc.h"
54 #include "lib/net/address.h"
55 #include "lib/net/inaddr.h"
56 #include "lib/net/socket.h"
59 #include "lib/string/parse_int.h"
60 #include "lib/string/printf.h"
61 #include "lib/string/scanf.h"
62 #include "lib/string/util_string.h"
64 #include "lib/thread/threads.h"
65 #include "lib/time/compat_time.h"
67 #include "lib/wallclock/timeval.h"
68 
69 #include "ht.h"
70 
71 // These, more than other includes, are for keeping the other struct
72 // definitions working. We should remove them when we minimize our includes.
73 #include "core/or/entry_port_cfg_st.h"
74 
77 
78 /* These signals are defined to help handle_control_signal work.
79  */
80 #ifndef SIGHUP
81 #define SIGHUP 1
82 #endif
83 #ifndef SIGINT
84 #define SIGINT 2
85 #endif
86 #ifndef SIGUSR1
87 #define SIGUSR1 10
88 #endif
89 #ifndef SIGUSR2
90 #define SIGUSR2 12
91 #endif
92 #ifndef SIGTERM
93 #define SIGTERM 15
94 #endif
95 /* Controller signals start at a high number so we don't
96  * conflict with system-defined signals. */
97 #define SIGNEWNYM 129
98 #define SIGCLEARDNSCACHE 130
99 #define SIGHEARTBEAT 131
100 #define SIGACTIVE 132
101 #define SIGDORMANT 133
102 
103 #if (SIZEOF_CELL_T != 0)
104 /* On Irix, stdlib.h defines a cell_t type, so we need to make sure
105  * that our stuff always calls cell_t something different. */
106 #define cell_t tor_cell_t
107 #endif
108 
110 #define DOWNCAST(to, ptr) ((to*)SUBTYPE_P(ptr, to, base_))
111 
113 #define MAX_NICKNAME_LEN 19
114 
116 #define MAX_HEX_NICKNAME_LEN (HEX_DIGEST_LEN+1)
117 
119 #define MAX_VERBOSE_NICKNAME_LEN (1+HEX_DIGEST_LEN+1+MAX_NICKNAME_LEN)
120 
123 #define MAX_HEADERS_SIZE 50000
124 
128 #define MAX_DESCRIPTOR_UPLOAD_SIZE 20000
129 
131 #define MAX_EXTRAINFO_UPLOAD_SIZE 50000
132 
134 #define MIN_ONION_KEY_LIFETIME_DAYS (1)
135 
137 #define MAX_ONION_KEY_LIFETIME_DAYS (90)
138 
140 #define DEFAULT_ONION_KEY_LIFETIME_DAYS (28)
141 
145 #define MIN_ONION_KEY_GRACE_PERIOD_DAYS (1)
146 
148 #define DEFAULT_ONION_KEY_GRACE_PERIOD_DAYS (7)
149 
152 #define ONION_KEY_CONSENSUS_CHECK_INTERVAL (60*60)
153 
155 #define MAX_SSL_KEY_LIFETIME_INTERNAL (2*60*60)
156 
159 #define ROUTER_MAX_AGE (60*60*48)
160 
162 #define ROUTER_MAX_AGE_TO_PUBLISH (60*60*24)
163 
164 #define OLD_ROUTER_DESC_MAX_AGE (60*60*24*5)
165 
166 /* Proxy client types */
167 #define PROXY_NONE 0
168 #define PROXY_CONNECT 1
169 #define PROXY_SOCKS4 2
170 #define PROXY_SOCKS5 3
171 /* !!!! If there is ever a PROXY_* type over 3, we must grow the proxy_type
172  * field in or_connection_t */
173 
174 /* Pluggable transport proxy type. Don't use this in or_connection_t,
175  * instead use the actual underlying proxy type (see above). */
176 #define PROXY_PLUGGABLE 4
177 
180 #define MIN_CIRCUITS_HANDLING_STREAM 2
181 
182 /* These RELAY_COMMAND constants define values for relay cell commands, and
183 * must match those defined in tor-spec.txt. */
184 #define RELAY_COMMAND_BEGIN 1
185 #define RELAY_COMMAND_DATA 2
186 #define RELAY_COMMAND_END 3
187 #define RELAY_COMMAND_CONNECTED 4
188 #define RELAY_COMMAND_SENDME 5
189 #define RELAY_COMMAND_EXTEND 6
190 #define RELAY_COMMAND_EXTENDED 7
191 #define RELAY_COMMAND_TRUNCATE 8
192 #define RELAY_COMMAND_TRUNCATED 9
193 #define RELAY_COMMAND_DROP 10
194 #define RELAY_COMMAND_RESOLVE 11
195 #define RELAY_COMMAND_RESOLVED 12
196 #define RELAY_COMMAND_BEGIN_DIR 13
197 #define RELAY_COMMAND_EXTEND2 14
198 #define RELAY_COMMAND_EXTENDED2 15
199 
200 #define RELAY_COMMAND_ESTABLISH_INTRO 32
201 #define RELAY_COMMAND_ESTABLISH_RENDEZVOUS 33
202 #define RELAY_COMMAND_INTRODUCE1 34
203 #define RELAY_COMMAND_INTRODUCE2 35
204 #define RELAY_COMMAND_RENDEZVOUS1 36
205 #define RELAY_COMMAND_RENDEZVOUS2 37
206 #define RELAY_COMMAND_INTRO_ESTABLISHED 38
207 #define RELAY_COMMAND_RENDEZVOUS_ESTABLISHED 39
208 #define RELAY_COMMAND_INTRODUCE_ACK 40
209 
210 #define RELAY_COMMAND_PADDING_NEGOTIATE 41
211 #define RELAY_COMMAND_PADDING_NEGOTIATED 42
212 
213 /* Reasons why an OR connection is closed. */
214 #define END_OR_CONN_REASON_DONE 1
215 #define END_OR_CONN_REASON_REFUSED 2 /* connection refused */
216 #define END_OR_CONN_REASON_OR_IDENTITY 3
217 #define END_OR_CONN_REASON_CONNRESET 4 /* connection reset by peer */
218 #define END_OR_CONN_REASON_TIMEOUT 5
219 #define END_OR_CONN_REASON_NO_ROUTE 6 /* no route to host/net */
220 #define END_OR_CONN_REASON_IO_ERROR 7 /* read/write error */
221 #define END_OR_CONN_REASON_RESOURCE_LIMIT 8 /* sockets, buffers, etc */
222 #define END_OR_CONN_REASON_PT_MISSING 9 /* PT failed or not available */
223 #define END_OR_CONN_REASON_MISC 10
224 
225 /* Reasons why we (or a remote OR) might close a stream. See tor-spec.txt for
226  * documentation of these. The values must match. */
227 #define END_STREAM_REASON_MISC 1
228 #define END_STREAM_REASON_RESOLVEFAILED 2
229 #define END_STREAM_REASON_CONNECTREFUSED 3
230 #define END_STREAM_REASON_EXITPOLICY 4
231 #define END_STREAM_REASON_DESTROY 5
232 #define END_STREAM_REASON_DONE 6
233 #define END_STREAM_REASON_TIMEOUT 7
234 #define END_STREAM_REASON_NOROUTE 8
235 #define END_STREAM_REASON_HIBERNATING 9
236 #define END_STREAM_REASON_INTERNAL 10
237 #define END_STREAM_REASON_RESOURCELIMIT 11
238 #define END_STREAM_REASON_CONNRESET 12
239 #define END_STREAM_REASON_TORPROTOCOL 13
240 #define END_STREAM_REASON_NOTDIRECTORY 14
241 #define END_STREAM_REASON_ENTRYPOLICY 15
242 
243 /* These high-numbered end reasons are not part of the official spec,
244  * and are not intended to be put in relay end cells. They are here
245  * to be more informative when sending back socks replies to the
246  * application. */
247 /* XXXX 256 is no longer used; feel free to reuse it. */
249 /* XXXX the ways we use this one don't make a lot of sense. */
250 #define END_STREAM_REASON_CANT_ATTACH 257
251 
253 #define END_STREAM_REASON_NET_UNREACHABLE 258
254 
256 #define END_STREAM_REASON_SOCKSPROTOCOL 259
257 
259 #define END_STREAM_REASON_CANT_FETCH_ORIG_DEST 260
260 
262 #define END_STREAM_REASON_INVALID_NATD_DEST 261
263 
265 #define END_STREAM_REASON_PRIVATE_ADDR 262
266 
269 #define END_STREAM_REASON_HTTPPROTOCOL 263
270 
272 #define END_STREAM_REASON_MASK 511
273 
276 #define END_STREAM_REASON_FLAG_REMOTE 512
277 
279 #define END_STREAM_REASON_FLAG_ALREADY_SENT_CLOSED 1024
280 
283 #define END_STREAM_REASON_FLAG_ALREADY_SOCKS_REPLIED 2048
284 
285 /* 'type' values to use in RESOLVED cells. Specified in tor-spec.txt. */
286 #define RESOLVED_TYPE_HOSTNAME 0
287 #define RESOLVED_TYPE_IPV4 4
288 #define RESOLVED_TYPE_IPV6 6
289 #define RESOLVED_TYPE_ERROR_TRANSIENT 0xF0
290 #define RESOLVED_TYPE_ERROR 0xF1
291 
292 /* Negative reasons are internal: we never send them in a DESTROY or TRUNCATE
293  * call; they only go to the controller for tracking */
294 
295 /* Closing introduction point that were opened in parallel. */
296 #define END_CIRC_REASON_IP_NOW_REDUNDANT -4
297 
300 #define END_CIRC_REASON_MEASUREMENT_EXPIRED -3
301 
303 #define END_CIRC_REASON_NOPATH -2
304 
305 #define END_CIRC_AT_ORIGIN -1
306 
307 /* Reasons why we (or a remote OR) might close a circuit. See tor-spec.txt
308  * section 5.4 for documentation of these. */
309 #define END_CIRC_REASON_MIN_ 0
310 #define END_CIRC_REASON_NONE 0
311 #define END_CIRC_REASON_TORPROTOCOL 1
312 #define END_CIRC_REASON_INTERNAL 2
313 #define END_CIRC_REASON_REQUESTED 3
314 #define END_CIRC_REASON_HIBERNATING 4
315 #define END_CIRC_REASON_RESOURCELIMIT 5
316 #define END_CIRC_REASON_CONNECTFAILED 6
317 #define END_CIRC_REASON_OR_IDENTITY 7
318 #define END_CIRC_REASON_CHANNEL_CLOSED 8
319 #define END_CIRC_REASON_FINISHED 9
320 #define END_CIRC_REASON_TIMEOUT 10
321 #define END_CIRC_REASON_DESTROYED 11
322 #define END_CIRC_REASON_NOSUCHSERVICE 12
323 #define END_CIRC_REASON_MAX_ 12
324 
328 #define END_CIRC_REASON_FLAG_REMOTE 512
329 
331 #define REND_SERVICE_ID_LEN_BASE32 16
332 
334 #define REND_SERVICE_ADDRESS_LEN (16+1+5)
335 
337 #define REND_SERVICE_ID_LEN 10
338 
340 #define REND_TIME_PERIOD_V2_DESC_VALIDITY (24*60*60)
341 
344 #define REND_TIME_PERIOD_OVERLAPPING_V2_DESCS (60*60)
345 
348 #define REND_NUMBER_OF_NON_CONSECUTIVE_REPLICAS 2
349 
351 #define REND_NUMBER_OF_CONSECUTIVE_REPLICAS 3
352 
354 #define REND_DESC_ID_V2_LEN_BASE32 BASE32_DIGEST_LEN
355 
358 #define REND_SECRET_ID_PART_LEN_BASE32 BASE32_DIGEST_LEN
359 
362 #define REND_INTRO_POINT_ID_LEN_BASE32 BASE32_DIGEST_LEN
363 
366 #define REND_DESC_COOKIE_LEN 16
367 
370 #define REND_DESC_COOKIE_LEN_BASE64 22
371 
374 #define REND_BASIC_AUTH_CLIENT_ID_LEN 4
375 
379 #define REND_BASIC_AUTH_CLIENT_MULTIPLE 16
380 
383 #define REND_BASIC_AUTH_CLIENT_ENTRY_LEN (REND_BASIC_AUTH_CLIENT_ID_LEN \
384  + CIPHER_KEY_LEN)
385 
387 #define REND_DESC_MAX_SIZE (20 * 1024)
388 
391 #define REND_LEGAL_CLIENTNAME_CHARACTERS \
392  "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+-_"
393 
395 #define REND_CLIENTNAME_MAX_LEN 16
396 
399 #define REND_COOKIE_LEN DIGEST_LEN
400 
402 typedef enum rend_auth_type_t {
403  REND_NO_AUTH = 0,
404  REND_BASIC_AUTH = 1,
405  REND_STEALTH_AUTH = 2,
407 
410  uint8_t descriptor_cookie[REND_DESC_COOKIE_LEN];
411  char onion_address[REND_SERVICE_ADDRESS_LEN+1];
412  rend_auth_type_t auth_type;
414 
418 typedef struct rend_data_t {
419  /* Hidden service protocol version of this base object. */
420  uint32_t version;
421 
425 
428 
431 } rend_data_t;
432 
433 typedef struct rend_data_v2_t {
434  /* Rendezvous base data. */
435  rend_data_t base_;
436 
439 
444 
447 
450 
455 
459 
460 /* From a base rend_data_t object <b>d</d>, return the v2 object. */
461 static inline
462 rend_data_v2_t *TO_REND_DATA_V2(const rend_data_t *d)
463 {
464  tor_assert(d);
465  tor_assert(d->version == 2);
466  return DOWNCAST(rend_data_v2_t, d);
467 }
468 
469 /* Stub because we can't include hs_ident.h. */
470 struct hs_ident_edge_conn_t;
471 struct hs_ident_dir_conn_t;
472 struct hs_ident_circuit_t;
473 
474 typedef struct hsdir_index_t hsdir_index_t;
475 
479 #define REND_REPLAY_TIME_INTERVAL (5 * 60)
480 
482 typedef enum {
486 
494 typedef enum {
495  CIRCUIT_N_CHAN = 0,
496  CIRCUIT_P_CHAN = 1
498 
501 #define CIRCWINDOW_START 1000
502 #define CIRCWINDOW_START_MIN 100
503 #define CIRCWINDOW_START_MAX 1000
504 
505 #define CIRCWINDOW_INCREMENT 100
506 
508 #define STREAMWINDOW_START 500
509 #define STREAMWINDOW_START_MAX 500
510 
511 #define STREAMWINDOW_INCREMENT 50
512 
520 #define ORCIRC_MAX_MIDDLE_CELLS (CIRCWINDOW_START_MAX*2)
521 
524 #define ORCIRC_MAX_MIDDLE_KILL_THRESH (1.1f)
525 
526 /* Cell commands. These values are defined in tor-spec.txt. */
527 #define CELL_PADDING 0
528 #define CELL_CREATE 1
529 #define CELL_CREATED 2
530 #define CELL_RELAY 3
531 #define CELL_DESTROY 4
532 #define CELL_CREATE_FAST 5
533 #define CELL_CREATED_FAST 6
534 #define CELL_VERSIONS 7
535 #define CELL_NETINFO 8
536 #define CELL_RELAY_EARLY 9
537 #define CELL_CREATE2 10
538 #define CELL_CREATED2 11
539 #define CELL_PADDING_NEGOTIATE 12
540 
541 #define CELL_VPADDING 128
542 #define CELL_CERTS 129
543 #define CELL_AUTH_CHALLENGE 130
544 #define CELL_AUTHENTICATE 131
545 #define CELL_AUTHORIZE 132
546 #define CELL_COMMAND_MAX_ 132
547 
549 #define TIMEOUT_UNTIL_UNREACHABILITY_COMPLAINT (20*60)
550 
552 #define LEGAL_NICKNAME_CHARACTERS \
553  "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
554 
557 #define DEFAULT_CLIENT_NICKNAME "client"
558 
560 #define UNNAMED_ROUTER_NICKNAME "Unnamed"
561 
563 #define SOCKS4_NETWORK_LEN 8
564 
565 /*
566  * Relay payload:
567  * Relay command [1 byte]
568  * Recognized [2 bytes]
569  * Stream ID [2 bytes]
570  * Partial SHA-1 [4 bytes]
571  * Length [2 bytes]
572  * Relay payload [498 bytes]
573  */
574 
576 #define CELL_PAYLOAD_SIZE 509
577 
579 #define CELL_MAX_NETWORK_SIZE 514
580 
582 #define VAR_CELL_MAX_HEADER_SIZE 7
583 
584 static int get_cell_network_size(int wide_circ_ids);
585 static inline int get_cell_network_size(int wide_circ_ids)
586 {
587  return wide_circ_ids ? CELL_MAX_NETWORK_SIZE : CELL_MAX_NETWORK_SIZE - 2;
588 }
589 static int get_var_cell_header_size(int wide_circ_ids);
590 static inline int get_var_cell_header_size(int wide_circ_ids)
591 {
592  return wide_circ_ids ? VAR_CELL_MAX_HEADER_SIZE :
594 }
595 static int get_circ_id_size(int wide_circ_ids);
596 static inline int get_circ_id_size(int wide_circ_ids)
597 {
598  return wide_circ_ids ? 4 : 2;
599 }
600 
603 #define RELAY_HEADER_SIZE (1+2+2+4+2)
604 
605 #define RELAY_PAYLOAD_SIZE (CELL_PAYLOAD_SIZE-RELAY_HEADER_SIZE)
606 
608 typedef uint32_t circid_t;
610 typedef uint16_t streamid_t;
611 
612 /* channel_t typedef; struct channel_s is in channel.h */
613 
614 typedef struct channel_s channel_t;
615 
616 /* channel_listener_t typedef; struct channel_listener_s is in channel.h */
617 
619 
620 /* TLS channel stuff */
621 
622 typedef struct channel_tls_s channel_tls_t;
623 
624 /* circuitmux_t typedef; struct circuitmux_s is in circuitmux.h */
625 
626 typedef struct circuitmux_s circuitmux_t;
627 
628 typedef struct cell_t cell_t;
629 typedef struct var_cell_t var_cell_t;
630 typedef struct packed_cell_t packed_cell_t;
631 typedef struct cell_queue_t cell_queue_t;
632 typedef struct destroy_cell_t destroy_cell_t;
634 typedef struct ext_or_cmd_t ext_or_cmd_t;
635 
637 typedef struct {
638  uint8_t command;
639  uint16_t recognized;
641  char integrity[4];
642  uint16_t length;
644 
645 typedef struct socks_request_t socks_request_t;
646 typedef struct entry_port_cfg_t entry_port_cfg_t;
647 typedef struct server_port_cfg_t server_port_cfg_t;
648 
650 #define OR_AUTH_CHALLENGE_LEN 32
651 
662 #define OR_CERT_TYPE_TLS_LINK 1
663 
665 #define OR_CERT_TYPE_ID_1024 2
666 
669 #define OR_CERT_TYPE_AUTH_1024 3
670 /* DOCDOC */
671 #define OR_CERT_TYPE_RSA_ED_CROSSCERT 7
672 
680 #define AUTHTYPE_RSA_SHA256_TLSSECRET 1
681 
688 #define AUTHTYPE_RSA_SHA256_RFC5705 2
689 
691 #define AUTHTYPE_ED25519_SHA256_RFC5705 3
692 /*
693  * NOTE: authchallenge_type_is_better() relies on these AUTHTYPE codes
694  * being sorted in order of preference. If we someday add one with
695  * a higher numerical value that we don't like as much, we should revise
696  * authchallenge_type_is_better().
697  */
698 
703 #define V3_AUTH_FIXED_PART_LEN (8+(32*6))
704 
706 #define V3_AUTH_BODY_LEN (V3_AUTH_FIXED_PART_LEN + 8 + 16)
707 
710 
712 #define EXT_OR_CONN_ID_LEN DIGEST_LEN /* 20 */
713 /*
714  * OR_CONN_HIGHWATER and OR_CONN_LOWWATER moved from connection_or.c so
715  * channeltls.c can see them too.
716  */
717 
720 #define OR_CONN_HIGHWATER (32*1024)
721 
724 #define OR_CONN_LOWWATER (16*1024)
725 
726 typedef struct connection_t connection_t;
728 typedef struct dir_connection_t dir_connection_t;
729 typedef struct edge_connection_t edge_connection_t;
732 typedef struct or_connection_t or_connection_t;
733 
735 #define TO_CONN(c) (&(((c)->base_)))
736 
738 #define ENTRY_TO_CONN(c) (TO_CONN(ENTRY_TO_EDGE_CONN(c)))
739 
740 typedef struct addr_policy_t addr_policy_t;
741 
742 typedef struct cached_dir_t cached_dir_t;
743 
746 typedef enum {
756  /* FFFF (We could also mmap the file and grow the mmap as needed, or
757  * lazy-load the descriptor text by using seek and read. We don't, for
758  * now.)
759  */
762 #define saved_location_bitfield_t ENUM_BF(saved_location_t)
763 
766 typedef enum {
767  DL_SCHED_GENERIC = 0,
768  DL_SCHED_CONSENSUS = 1,
769  DL_SCHED_BRIDGE = 2,
771 #define download_schedule_bitfield_t ENUM_BF(download_schedule_t)
772 
778 typedef enum {
779  DL_WANT_ANY_DIRSERVER = 0,
780  DL_WANT_AUTHORITY = 1,
782 #define download_want_authority_bitfield_t \
783  ENUM_BF(download_want_authority_t)
784 
788 typedef enum {
789  DL_SCHED_INCREMENT_FAILURE = 0,
790  DL_SCHED_INCREMENT_ATTEMPT = 1,
792 #define download_schedule_increment_bitfield_t \
793  ENUM_BF(download_schedule_increment_t)
794 
795 typedef struct download_status_t download_status_t;
796 
798 #define IMPOSSIBLE_TO_DOWNLOAD 255
799 
803 #define ROUTER_ANNOTATION_BUF_LEN 256
804 
806 
809 typedef struct protover_summary_flags_t {
812  unsigned int protocols_known:1;
813 
816  unsigned int supports_extend2_cells:1;
817 
822 
827 
831  unsigned int supports_ed25519_hs_intro : 1;
832 
836  unsigned int supports_v3_hsdir : 1;
837 
842 
845  unsigned int supports_padding : 1;
847 
848 typedef struct routerinfo_t routerinfo_t;
849 typedef struct extrainfo_t extrainfo_t;
850 typedef struct routerstatus_t routerstatus_t;
851 
852 typedef struct microdesc_t microdesc_t;
853 typedef struct node_t node_t;
859 
863 typedef enum {
864  FLAV_NS = 0,
865  FLAV_MICRODESC = 1,
867 
869 #define N_CONSENSUS_FLAVORS ((int)(FLAV_MICRODESC)+1)
870 
871 typedef struct networkstatus_t networkstatus_t;
873 typedef struct desc_store_t desc_store_t;
874 typedef struct routerlist_t routerlist_t;
875 typedef struct extend_info_t extend_info_t;
876 typedef struct authority_cert_t authority_cert_t;
877 
887 typedef enum {
888  NO_DIRINFO = 0,
890  V3_DIRINFO = 1 << 2,
892  BRIDGE_DIRINFO = 1 << 4,
898 
899 #define ALL_DIRINFO ((dirinfo_type_t)((1<<7)-1))
900 
901 #define ONION_HANDSHAKE_TYPE_TAP 0x0000
902 #define ONION_HANDSHAKE_TYPE_FAST 0x0001
903 #define ONION_HANDSHAKE_TYPE_NTOR 0x0002
904 #define MAX_ONION_HANDSHAKE_TYPE 0x0002
905 
907 typedef struct relay_crypto_t relay_crypto_t;
908 typedef struct crypt_path_t crypt_path_t;
910 
911 #define CPATH_KEY_MATERIAL_LEN (20*2+16*2)
912 
914 
915 struct create_cell_t;
916 
920  uint8_t command;
925  unsigned int waiting_time:22;
926  unsigned int removed:1;
927  unsigned int exitward:1;
929 
930 typedef struct circuit_t circuit_t;
931 typedef struct origin_circuit_t origin_circuit_t;
932 typedef struct or_circuit_t or_circuit_t;
933 
936 #define MAX_RELAY_EARLY_CELLS_PER_CIRCUIT 8
937 
938 typedef enum path_state_t path_state_t;
939 #define path_state_bitfield_t ENUM_BF(path_state_t)
940 
941 #if REND_COOKIE_LEN != DIGEST_LEN
942 #error "The REND_TOKEN_LEN macro assumes REND_COOKIE_LEN == DIGEST_LEN"
943 #endif
944 #define REND_TOKEN_LEN DIGEST_LEN
945 
947 #define TO_CIRCUIT(x) (&((x)->base_))
948 
956 #define ISO_DESTPORT (1u<<0)
957 
958 #define ISO_DESTADDR (1u<<1)
959 
960 #define ISO_SOCKSAUTH (1u<<2)
961 
962 #define ISO_CLIENTPROTO (1u<<3)
963 
964 #define ISO_CLIENTADDR (1u<<4)
965 
966 #define ISO_SESSIONGRP (1u<<5)
967 
968 #define ISO_NYM_EPOCH (1u<<6)
969 
970 #define ISO_STREAM (1u<<7)
971 
974 #define ISO_DEFAULT (ISO_CLIENTADDR|ISO_SOCKSAUTH|ISO_SESSIONGRP|ISO_NYM_EPOCH)
975 
977 #define SESSION_GROUP_UNSET -1
978 
979 #define SESSION_GROUP_DIRCONN -2
980 
981 #define SESSION_GROUP_CONTROL_RESOLVE -3
982 
983 #define SESSION_GROUP_FIRST_AUTO -4
984 
985 typedef struct port_cfg_t port_cfg_t;
986 typedef struct routerset_t routerset_t;
987 
990 #define CFG_AUTO_PORT 0xc4005e
991 
992 typedef struct or_options_t or_options_t;
993 
994 #define LOG_PROTOCOL_WARN (get_protocol_warning_severity_level())
995 
996 typedef struct or_state_t or_state_t;
997 
998 #define MAX_SOCKS_ADDR_LEN 256
999 
1000 /********************************* circuitbuild.c **********************/
1001 
1003 #define DEFAULT_ROUTE_LEN 3
1004 
1005 /* Circuit Build Timeout "public" structures. */
1006 
1008 #define BW_WEIGHT_SCALE 10000
1009 #define BW_MIN_WEIGHT_SCALE 1
1010 #define BW_MAX_WEIGHT_SCALE INT32_MAX
1011 
1012 typedef struct circuit_build_times_s circuit_build_times_t;
1013 
1014 /********************************* config.c ***************************/
1015 
1016 /********************************* connection_edge.c *************************/
1017 
1019 typedef enum {
1034 
1040 #define addressmap_entry_source_bitfield_t ENUM_BF(addressmap_entry_source_t)
1041 
1042 #define WRITE_STATS_INTERVAL (24*60*60)
1043 
1044 /********************************* dirvote.c ************************/
1045 
1046 typedef struct vote_timing_t vote_timing_t;
1047 
1048 /********************************* microdesc.c *************************/
1049 
1050 typedef struct microdesc_cache_t microdesc_cache_t;
1051 
1052 /********************************* rendcommon.c ***************************/
1053 
1057 
1061 #define MAX_INTRO_POINT_REACHABILITY_FAILURES 5
1062 
1066 #define INTRO_POINT_MIN_LIFETIME_INTRODUCTIONS 16384
1067 /* Double the minimum value so the interval is [min, min * 2]. */
1068 #define INTRO_POINT_MAX_LIFETIME_INTRODUCTIONS \
1069  (INTRO_POINT_MIN_LIFETIME_INTRODUCTIONS * 2)
1070 
1077 #define INTRO_POINT_LIFETIME_MIN_SECONDS (18*60*60)
1078 
1082 #define INTRO_POINT_LIFETIME_MAX_SECONDS (24*60*60)
1083 
1087 #define MAX_INTRO_POINT_CIRCUIT_RETRIES 3
1088 
1089 typedef struct rend_intro_point_t rend_intro_point_t;
1091 
1092 /********************************* routerlist.c ***************************/
1093 
1094 typedef struct dir_server_t dir_server_t;
1095 
1096 #define RELAY_REQUIRED_MIN_BANDWIDTH (75*1024)
1097 #define BRIDGE_REQUIRED_MIN_BANDWIDTH (50*1024)
1098 
1099 #define ROUTER_MAX_DECLARED_BANDWIDTH INT32_MAX
1100 
1101 typedef struct tor_version_t tor_version_t;
1102 
1103 #endif /* !defined(TOR_OR_H) */
char descriptor_id[REND_NUMBER_OF_NON_CONSECUTIVE_REPLICAS][DIGEST_LEN]
Definition: or.h:443
Definition: node_st.h:28
Header for printf.c.
Header for smartlist.c.
Headers for di_ops.c.
Header for cstring.c.
struct protover_summary_flags_t protover_summary_flags_t
struct testing_cell_stats_entry_t testing_cell_stats_entry_t
download_want_authority_t
Definition: or.h:778
unsigned int removed
Definition: or.h:926
Summarize similar messages that would otherwise flood the logs.
Definitions for timing-related constants.
Headers for crypto_cipher.c.
Definition: cell_st.h:12
Macro definitions for MIN, MAX, and CLAMP.
#define DOWNCAST(to, ptr)
Definition: or.h:110
Functions and types for monotonic times.
char descriptor_cookie[REND_DESC_COOKIE_LEN]
Definition: or.h:446
int nr_streams
Definition: or.h:430
Headers for crypto_rsa.c.
uint8_t command
Definition: or.h:920
smartlist_t * hsdirs_fp
Definition: or.h:424
Header for mmap.c.
addressmap_entry_source_t
Definition: or.h:1019
unsigned int supports_v3_hsdir
Definition: or.h:836
Header for time_fmt.c.
Header for util_string.c.
Header for inaddr.c.
unsigned int supports_ed25519_hs_intro
Definition: or.h:831
uint16_t recognized
Definition: or.h:639
dirinfo_type_t
Definition: or.h:887
Integer definitions used throughout Tor.
Headers for util_malloc.c.
Definition: or.h:919
saved_location_t
Definition: or.h:746
rend_auth_type_t
Definition: or.h:402
cell_direction_t
Definition: or.h:482
Header for threads.c.
streamid_t stream_id
Definition: or.h:640
unsigned int protocols_known
Definition: or.h:812
struct rend_service_authorization_t rend_service_authorization_t
char rend_pk_digest[DIGEST_LEN]
Definition: or.h:457
Declarations for timeval-related macros that some platforms are missing.
tor_assert(buffer)
#define DIGEST_LEN
Definition: digest_sizes.h:20
Utility macros to handle different features and behavior in different compilers.
Headers for address.h.
Definitions for sizes of Diffie-Hellman groups elements in Z_p.
uint16_t streamid_t
Definition: or.h:610
Header for binascii.c.
unsigned int supports_ed25519_link_handshake_compat
Definition: or.h:821
Header for approx_time.c.
struct rend_data_t rend_data_t
Header for scanf.c.
#define CELL_MAX_NETWORK_SIZE
Definition: or.h:579
unsigned int supports_extend2_cells
Definition: or.h:816
#define VAR_CELL_MAX_HEADER_SIZE
Definition: or.h:582
#define REND_NUMBER_OF_NON_CONSECUTIVE_REPLICAS
Definition: or.h:348
unsigned int waiting_time
Definition: or.h:925
Header for path.c.
uint16_t length
Definition: or.h:642
uint8_t command
Definition: or.h:638
Header for muldiv.c.
#define REND_SERVICE_ID_LEN_BASE32
Definition: or.h:331
Macros for comparing the boolean value of integers.
download_schedule_t
Definition: or.h:766
rend_auth_type_t auth_type
Definition: or.h:449
char rend_cookie[REND_COOKIE_LEN]
Definition: or.h:427
char desc_id_fetch[DIGEST_LEN]
Definition: or.h:454
Locale-independent character-type inspection (header)
Inline functions for reading and writing multibyte values from the middle of strings,...
consensus_flavor_t
Definition: or.h:863
uint32_t circid_t
Definition: or.h:608
Header for bits.c.
Headers for map.c.
Header for addsub.c.
Macros to implement mocking and selective exposure for the test code.
Header for compat_string.c.
Definition: or.h:890
Header for escape.c.
Wrappers for reading and writing data to files on disk.
Headers for torerr.c.
Header file for buffers.c.
unsigned int exitward
Definition: or.h:927
char onion_address[REND_SERVICE_ID_LEN_BASE32+1]
Definition: or.h:438
#define REND_COOKIE_LEN
Definition: or.h:399
#define REND_SERVICE_ADDRESS_LEN
Definition: or.h:334
Header for socket.c.
circuit_channel_direction_t
Definition: or.h:494
unsigned int supports_ed25519_link_handshake_any
Definition: or.h:826
Header for userdb.c.
Macros to manage assertions, fatal and non-fatal.
unsigned int supports_padding
Definition: or.h:845
Header for parse_int.c.
#define REND_DESC_COOKIE_LEN
Definition: or.h:366
download_schedule_increment_t
Definition: or.h:788
unsigned int supports_v3_rendezvous_point
Definition: or.h:841
Header for dir.c.