Tor  0.4.5.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-2020, The Tor Project, Inc. */
5 /* See LICENSE for licensing information */
6 
7 /**
8  * \file or.h
9  * \brief Master header file for Tor-specific functionality.
10  **/
11 
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/container/map.h"
28 #include "lib/buf/buffers.h"
32 #include "lib/ctime/di_ops.h"
33 #include "lib/defs/dh_sizes.h"
34 #include "lib/encoding/binascii.h"
35 #include "lib/encoding/cstring.h"
36 #include "lib/encoding/time_fmt.h"
37 #include "lib/err/torerr.h"
38 #include "lib/fs/dir.h"
39 #include "lib/fs/files.h"
40 #include "lib/fs/mmap.h"
41 #include "lib/fs/path.h"
42 #include "lib/fs/userdb.h"
43 #include "lib/geoip/country.h"
44 #include "lib/intmath/addsub.h"
45 #include "lib/intmath/bits.h"
46 #include "lib/intmath/cmp.h"
47 #include "lib/intmath/logic.h"
48 #include "lib/intmath/muldiv.h"
49 #include "lib/log/escape.h"
50 #include "lib/log/ratelim.h"
51 #include "lib/log/util_bug.h"
52 #include "lib/malloc/malloc.h"
53 #include "lib/net/address.h"
54 #include "lib/net/inaddr.h"
55 #include "lib/net/socket.h"
58 #include "lib/string/parse_int.h"
59 #include "lib/string/printf.h"
60 #include "lib/string/scanf.h"
61 #include "lib/string/util_string.h"
63 #include "lib/thread/threads.h"
64 #include "lib/time/compat_time.h"
66 #include "lib/wallclock/timeval.h"
67 
68 #include "ht.h"
69 
70 // These, more than other includes, are for keeping the other struct
71 // definitions working. We should remove them when we minimize our includes.
73 
76 
77 /* These signals are defined to help handle_control_signal work.
78  */
79 #ifndef SIGHUP
80 #define SIGHUP 1
81 #endif
82 #ifndef SIGINT
83 #define SIGINT 2
84 #endif
85 #ifndef SIGUSR1
86 #define SIGUSR1 10
87 #endif
88 #ifndef SIGUSR2
89 #define SIGUSR2 12
90 #endif
91 #ifndef SIGTERM
92 #define SIGTERM 15
93 #endif
94 /* Controller signals start at a high number so we don't
95  * conflict with system-defined signals. */
96 #define SIGNEWNYM 129
97 #define SIGCLEARDNSCACHE 130
98 #define SIGHEARTBEAT 131
99 #define SIGACTIVE 132
100 #define SIGDORMANT 133
101 
102 #if (SIZEOF_CELL_T != 0)
103 /* On Irix, stdlib.h defines a cell_t type, so we need to make sure
104  * that our stuff always calls cell_t something different. */
105 #define cell_t tor_cell_t
106 #endif
107 
108 /** Helper macro: Given a pointer to to.base_, of type from*, return &to. */
109 #define DOWNCAST(to, ptr) ((to*)SUBTYPE_P(ptr, to, base_))
110 
111 /** Length of longest allowable configured nickname. */
112 #define MAX_NICKNAME_LEN 19
113 /** Length of a router identity encoded as a hexadecimal digest, plus
114  * possible dollar sign. */
115 #define MAX_HEX_NICKNAME_LEN (HEX_DIGEST_LEN+1)
116 /** Maximum length of verbose router identifier: dollar sign, hex ID digest,
117  * equal sign or tilde, nickname. */
118 #define MAX_VERBOSE_NICKNAME_LEN (1+HEX_DIGEST_LEN+1+MAX_NICKNAME_LEN)
119 
120 /** For HTTP parsing: Maximum number of bytes we'll accept in the headers
121  * of an HTTP request or response. */
122 #define MAX_HEADERS_SIZE 50000
123 
124 /** Maximum size, in bytes, of a single router descriptor uploaded to us
125  * as a directory authority. Caches and clients fetch whatever descriptors
126  * the authorities tell them to fetch, and don't care about size. */
127 #define MAX_DESCRIPTOR_UPLOAD_SIZE 20000
128 
129 /** Maximum size of a single extrainfo document, as above. */
130 #define MAX_EXTRAINFO_UPLOAD_SIZE 50000
131 
132 /** Minimum lifetime for an onion key in days. */
133 #define MIN_ONION_KEY_LIFETIME_DAYS (1)
134 
135 /** Maximum lifetime for an onion key in days. */
136 #define MAX_ONION_KEY_LIFETIME_DAYS (90)
137 
138 /** Default lifetime for an onion key in days. */
139 #define DEFAULT_ONION_KEY_LIFETIME_DAYS (28)
140 
141 /** Minimum grace period for acceptance of an onion key in days.
142  * The maximum value is defined in proposal #274 as being the current network
143  * consensus parameter for "onion-key-rotation-days". */
144 #define MIN_ONION_KEY_GRACE_PERIOD_DAYS (1)
145 
146 /** Default grace period for acceptance of an onion key in days. */
147 #define DEFAULT_ONION_KEY_GRACE_PERIOD_DAYS (7)
148 
149 /** How often we should check the network consensus if it is time to rotate or
150  * expire onion keys. */
151 #define ONION_KEY_CONSENSUS_CHECK_INTERVAL (60*60)
152 
153 /** How often do we rotate TLS contexts? */
154 #define MAX_SSL_KEY_LIFETIME_INTERNAL (2*60*60)
155 
156 /** How old do we allow a router to get before removing it
157  * from the router list? In seconds. */
158 #define ROUTER_MAX_AGE (60*60*48)
159 /** How old can a router get before we (as a server) will no longer
160  * consider it live? In seconds. */
161 #define ROUTER_MAX_AGE_TO_PUBLISH (60*60*24)
162 /** How old do we let a saved descriptor get before force-removing it? */
163 #define OLD_ROUTER_DESC_MAX_AGE (60*60*24*5)
164 
165 /* Proxy client types */
166 #define PROXY_NONE 0
167 #define PROXY_CONNECT 1
168 #define PROXY_SOCKS4 2
169 #define PROXY_SOCKS5 3
170 #define PROXY_HAPROXY 4
171 /* !!!! If there is ever a PROXY_* type over 7, 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 5
177 
178 /** How many circuits do we want simultaneously in-progress to handle
179  * a given stream? */
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_TLS_ERROR 10 /* Problem in TLS protocol */
224 #define END_OR_CONN_REASON_MISC 11
225 
226 /* Reasons why we (or a remote OR) might close a stream. See tor-spec.txt for
227  * documentation of these. The values must match. */
228 #define END_STREAM_REASON_MISC 1
229 #define END_STREAM_REASON_RESOLVEFAILED 2
230 #define END_STREAM_REASON_CONNECTREFUSED 3
231 #define END_STREAM_REASON_EXITPOLICY 4
232 #define END_STREAM_REASON_DESTROY 5
233 #define END_STREAM_REASON_DONE 6
234 #define END_STREAM_REASON_TIMEOUT 7
235 #define END_STREAM_REASON_NOROUTE 8
236 #define END_STREAM_REASON_HIBERNATING 9
237 #define END_STREAM_REASON_INTERNAL 10
238 #define END_STREAM_REASON_RESOURCELIMIT 11
239 #define END_STREAM_REASON_CONNRESET 12
240 #define END_STREAM_REASON_TORPROTOCOL 13
241 #define END_STREAM_REASON_NOTDIRECTORY 14
242 #define END_STREAM_REASON_ENTRYPOLICY 15
243 
244 /* These high-numbered end reasons are not part of the official spec,
245  * and are not intended to be put in relay end cells. They are here
246  * to be more informative when sending back socks replies to the
247  * application. */
248 /* XXXX 256 is no longer used; feel free to reuse it. */
249 /** We were unable to attach the connection to any circuit at all. */
250 /* XXXX the ways we use this one don't make a lot of sense. */
251 #define END_STREAM_REASON_CANT_ATTACH 257
252 /** We can't connect to any directories at all, so we killed our streams
253  * before they can time out. */
254 #define END_STREAM_REASON_NET_UNREACHABLE 258
255 /** This is a SOCKS connection, and the client used (or misused) the SOCKS
256  * protocol in a way we couldn't handle. */
257 #define END_STREAM_REASON_SOCKSPROTOCOL 259
258 /** This is a transparent proxy connection, but we can't extract the original
259  * target address:port. */
260 #define END_STREAM_REASON_CANT_FETCH_ORIG_DEST 260
261 /** This is a connection on the NATD port, and the destination IP:Port was
262  * either ill-formed or out-of-range. */
263 #define END_STREAM_REASON_INVALID_NATD_DEST 261
264 /** The target address is in a private network (like 127.0.0.1 or 10.0.0.1);
265  * you don't want to do that over a randomly chosen exit */
266 #define END_STREAM_REASON_PRIVATE_ADDR 262
267 /** This is an HTTP tunnel connection and the client used or misused HTTP in a
268  * way we can't handle.
269  */
270 #define END_STREAM_REASON_HTTPPROTOCOL 263
271 
272 /** Bitwise-and this value with endreason to mask out all flags. */
273 #define END_STREAM_REASON_MASK 511
274 
275 /** Bitwise-or this with the argument to control_event_stream_status
276  * to indicate that the reason came from an END cell. */
277 #define END_STREAM_REASON_FLAG_REMOTE 512
278 /** Bitwise-or this with the argument to control_event_stream_status
279  * to indicate that we already sent a CLOSED stream event. */
280 #define END_STREAM_REASON_FLAG_ALREADY_SENT_CLOSED 1024
281 /** Bitwise-or this with endreason to indicate that we already sent
282  * a socks reply, and no further reply needs to be sent from
283  * connection_mark_unattached_ap(). */
284 #define END_STREAM_REASON_FLAG_ALREADY_SOCKS_REPLIED 2048
285 
286 /* 'type' values to use in RESOLVED cells. Specified in tor-spec.txt. */
287 #define RESOLVED_TYPE_HOSTNAME 0
288 #define RESOLVED_TYPE_IPV4 4
289 #define RESOLVED_TYPE_IPV6 6
290 #define RESOLVED_TYPE_ERROR_TRANSIENT 0xF0
291 #define RESOLVED_TYPE_ERROR 0xF1
292 
293 /* Negative reasons are internal: we never send them in a DESTROY or TRUNCATE
294  * call; they only go to the controller for tracking */
295 
296 /* Closing introduction point that were opened in parallel. */
297 #define END_CIRC_REASON_IP_NOW_REDUNDANT -4
298 
299 /** Our post-timeout circuit time measurement period expired.
300  * We must give up now */
301 #define END_CIRC_REASON_MEASUREMENT_EXPIRED -3
302 
303 /** We couldn't build a path for this circuit. */
304 #define END_CIRC_REASON_NOPATH -2
305 /** Catch-all "other" reason for closing origin circuits. */
306 #define END_CIRC_AT_ORIGIN -1
307 
308 /* Reasons why we (or a remote OR) might close a circuit. See tor-spec.txt
309  * section 5.4 for documentation of these. */
310 #define END_CIRC_REASON_MIN_ 0
311 #define END_CIRC_REASON_NONE 0
312 #define END_CIRC_REASON_TORPROTOCOL 1
313 #define END_CIRC_REASON_INTERNAL 2
314 #define END_CIRC_REASON_REQUESTED 3
315 #define END_CIRC_REASON_HIBERNATING 4
316 #define END_CIRC_REASON_RESOURCELIMIT 5
317 #define END_CIRC_REASON_CONNECTFAILED 6
318 #define END_CIRC_REASON_OR_IDENTITY 7
319 #define END_CIRC_REASON_CHANNEL_CLOSED 8
320 #define END_CIRC_REASON_FINISHED 9
321 #define END_CIRC_REASON_TIMEOUT 10
322 #define END_CIRC_REASON_DESTROYED 11
323 #define END_CIRC_REASON_NOSUCHSERVICE 12
324 #define END_CIRC_REASON_MAX_ 12
325 
326 /** Bitwise-OR this with the argument to circuit_mark_for_close() or
327  * control_event_circuit_status() to indicate that the reason was
328  * passed through from a destroy or truncate cell. */
329 #define END_CIRC_REASON_FLAG_REMOTE 512
330 
331 /** Length of 'y' portion of 'y.onion' URL. */
332 #define REND_SERVICE_ID_LEN_BASE32 16
333 
334 /** Length of 'y.onion' including '.onion' URL. */
335 #define REND_SERVICE_ADDRESS_LEN (16+1+5)
336 
337 /** Length of a binary-encoded rendezvous service ID. */
338 #define REND_SERVICE_ID_LEN 10
339 
340 /** Time period for which a v2 descriptor will be valid. */
341 #define REND_TIME_PERIOD_V2_DESC_VALIDITY (24*60*60)
342 
343 /** Time period within which two sets of v2 descriptors will be uploaded in
344  * parallel. */
345 #define REND_TIME_PERIOD_OVERLAPPING_V2_DESCS (60*60)
346 
347 /** Number of non-consecutive replicas (i.e. distributed somewhere
348  * in the ring) for a descriptor. */
349 #define REND_NUMBER_OF_NON_CONSECUTIVE_REPLICAS 2
350 
351 /** Number of consecutive replicas for a descriptor. */
352 #define REND_NUMBER_OF_CONSECUTIVE_REPLICAS 3
353 
354 /** Length of v2 descriptor ID (32 base32 chars = 160 bits). */
355 #define REND_DESC_ID_V2_LEN_BASE32 BASE32_DIGEST_LEN
356 
357 /** Length of the base32-encoded secret ID part of versioned hidden service
358  * descriptors. */
359 #define REND_SECRET_ID_PART_LEN_BASE32 BASE32_DIGEST_LEN
360 
361 /** Length of the base32-encoded hash of an introduction point's
362  * identity key. */
363 #define REND_INTRO_POINT_ID_LEN_BASE32 BASE32_DIGEST_LEN
364 
365 /** Length of the descriptor cookie that is used for client authorization
366  * to hidden services. */
367 #define REND_DESC_COOKIE_LEN 16
368 
369 /** Length of the base64-encoded descriptor cookie that is used for
370  * exchanging client authorization between hidden service and client. */
371 #define REND_DESC_COOKIE_LEN_BASE64 22
372 
373 /** Length of client identifier in encrypted introduction points for hidden
374  * service authorization type 'basic'. */
375 #define REND_BASIC_AUTH_CLIENT_ID_LEN 4
376 
377 /** Multiple of the number of clients to which the real number of clients
378  * is padded with fake clients for hidden service authorization type
379  * 'basic'. */
380 #define REND_BASIC_AUTH_CLIENT_MULTIPLE 16
381 
382 /** Length of client entry consisting of client identifier and encrypted
383  * session key for hidden service authorization type 'basic'. */
384 #define REND_BASIC_AUTH_CLIENT_ENTRY_LEN (REND_BASIC_AUTH_CLIENT_ID_LEN \
385  + CIPHER_KEY_LEN)
386 
387 /** Maximum size of v2 hidden service descriptors. */
388 #define REND_DESC_MAX_SIZE (20 * 1024)
389 
390 /** Legal characters for use in authorized client names for a hidden
391  * service. */
392 #define REND_LEGAL_CLIENTNAME_CHARACTERS \
393  "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+-_"
394 
395 /** Maximum length of authorized client names for a hidden service. */
396 #define REND_CLIENTNAME_MAX_LEN 16
397 
398 /** Length of the rendezvous cookie that is used to connect circuits at the
399  * rendezvous point. */
400 #define REND_COOKIE_LEN DIGEST_LEN
401 
402 /** Client authorization type that a hidden service performs. */
403 typedef enum rend_auth_type_t {
404  REND_NO_AUTH = 0,
405  REND_BASIC_AUTH = 1,
406  REND_STEALTH_AUTH = 2,
408 
409 /** Client-side configuration of authorization for a hidden service. */
411  uint8_t descriptor_cookie[REND_DESC_COOKIE_LEN];
412  char onion_address[REND_SERVICE_ADDRESS_LEN+1];
413  rend_auth_type_t auth_type;
415 
416 /** Client- and server-side data that is used for hidden service connection
417  * establishment. Not all fields contain data depending on where this struct
418  * is used. */
419 typedef struct rend_data_t {
420  /* Hidden service protocol version of this base object. */
421  uint32_t version;
422 
423  /** List of HSDir fingerprints on which this request has been sent to. This
424  * contains binary identity digest of the directory of size DIGEST_LEN. */
426 
427  /** Rendezvous cookie used by both, client and service. */
429 
430  /** Number of streams associated with this rendezvous circuit. */
432 } rend_data_t;
433 
434 typedef struct rend_data_v2_t {
435  /* Rendezvous base data. */
436  rend_data_t base_;
437 
438  /** Onion address (without the .onion part) that a client requests. */
440 
441  /** Descriptor ID for each replicas computed from the onion address. If
442  * the onion address is empty, this array MUST be empty. We keep them so
443  * we know when to purge our entry in the last hsdir request table. */
445 
446  /** (Optional) descriptor cookie that is used by a client. */
448 
449  /** Authorization type for accessing a service used by a client. */
451 
452  /** Descriptor ID for a client request. The control port command HSFETCH
453  * uses this. It's set if the descriptor query should only use this
454  * descriptor ID. */
456 
457  /** Hash of the hidden service's PK used by a service. */
460 
461 /* From a base rend_data_t object <b>d</d>, return the v2 object. */
462 static inline
463 rend_data_v2_t *TO_REND_DATA_V2(const rend_data_t *d)
464 {
465  tor_assert(d);
466  tor_assert(d->version == 2);
467  return DOWNCAST(rend_data_v2_t, d);
468 }
469 
470 /* Stub because we can't include hs_ident.h. */
471 struct hs_ident_edge_conn_t;
472 struct hs_ident_dir_conn_t;
473 struct hs_ident_circuit_t;
474 
475 typedef struct hsdir_index_t hsdir_index_t;
476 
477 /** Time interval for tracking replays of DH public keys received in
478  * INTRODUCE2 cells. Used only to avoid launching multiple
479  * simultaneous attempts to connect to the same rendezvous point. */
480 #define REND_REPLAY_TIME_INTERVAL (5 * 60)
481 
482 /** Used to indicate which way a cell is going on a circuit. */
483 typedef enum {
484  CELL_DIRECTION_IN=1, /**< The cell is moving towards the origin. */
485  CELL_DIRECTION_OUT=2, /**< The cell is moving away from the origin. */
487 
488 /**
489  * An enum to allow us to specify which channel in a circuit
490  * we're interested in.
491  *
492  * This is needed because our data structures and other fields
493  * for channel delivery are disassociated from the channel.
494  */
495 typedef enum {
496  CIRCUIT_N_CHAN = 0,
497  CIRCUIT_P_CHAN = 1
499 
500 /** Initial value for both sides of a circuit transmission window when the
501  * circuit is initialized. Measured in cells. */
502 #define CIRCWINDOW_START 1000
503 #define CIRCWINDOW_START_MIN 100
504 #define CIRCWINDOW_START_MAX 1000
505 /** Amount to increment a circuit window when we get a circuit SENDME. */
506 #define CIRCWINDOW_INCREMENT 100
507 /** Initial value on both sides of a stream transmission window when the
508  * stream is initialized. Measured in cells. */
509 #define STREAMWINDOW_START 500
510 #define STREAMWINDOW_START_MAX 500
511 /** Amount to increment a stream window when we get a stream SENDME. */
512 #define STREAMWINDOW_INCREMENT 50
513 
514 /** Maximum number of queued cells on a circuit for which we are the
515  * midpoint before we give up and kill it. This must be >= circwindow
516  * to avoid killing innocent circuits, and >= circwindow*2 to give
517  * leaky-pipe a chance of working someday. The ORCIRC_MAX_MIDDLE_KILL_THRESH
518  * ratio controls the margin of error between emitting a warning and
519  * killing the circuit.
520  */
521 #define ORCIRC_MAX_MIDDLE_CELLS (CIRCWINDOW_START_MAX*2)
522 /** Ratio of hard (circuit kill) to soft (warning) thresholds for the
523  * ORCIRC_MAX_MIDDLE_CELLS tests.
524  */
525 #define ORCIRC_MAX_MIDDLE_KILL_THRESH (1.1f)
526 
527 /* Cell commands. These values are defined in tor-spec.txt. */
528 #define CELL_PADDING 0
529 #define CELL_CREATE 1
530 #define CELL_CREATED 2
531 #define CELL_RELAY 3
532 #define CELL_DESTROY 4
533 #define CELL_CREATE_FAST 5
534 #define CELL_CREATED_FAST 6
535 #define CELL_VERSIONS 7
536 #define CELL_NETINFO 8
537 #define CELL_RELAY_EARLY 9
538 #define CELL_CREATE2 10
539 #define CELL_CREATED2 11
540 #define CELL_PADDING_NEGOTIATE 12
541 
542 #define CELL_VPADDING 128
543 #define CELL_CERTS 129
544 #define CELL_AUTH_CHALLENGE 130
545 #define CELL_AUTHENTICATE 131
546 #define CELL_AUTHORIZE 132
547 #define CELL_COMMAND_MAX_ 132
548 
549 /** How long to test reachability before complaining to the user. */
550 #define TIMEOUT_UNTIL_UNREACHABILITY_COMPLAINT (20*60)
551 
552 /** Legal characters in a nickname. */
553 #define LEGAL_NICKNAME_CHARACTERS \
554  "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
555 
556 /** Name to use in client TLS certificates if no nickname is given. Once
557  * Tor 0.1.2.x is obsolete, we can remove this. */
558 #define DEFAULT_CLIENT_NICKNAME "client"
559 
560 /** Name chosen by routers that don't configure nicknames */
561 #define UNNAMED_ROUTER_NICKNAME "Unnamed"
562 
563 /** Number of bytes in a SOCKS4 header. */
564 #define SOCKS4_NETWORK_LEN 8
565 
566 /*
567  * Relay payload:
568  * Relay command [1 byte]
569  * Recognized [2 bytes]
570  * Stream ID [2 bytes]
571  * Partial SHA-1 [4 bytes]
572  * Length [2 bytes]
573  * Relay payload [498 bytes]
574  */
575 
576 /** Number of bytes in a cell, minus cell header. */
577 #define CELL_PAYLOAD_SIZE 509
578 /** Number of bytes in a cell transmitted over the network, in the longest
579  * form */
580 #define CELL_MAX_NETWORK_SIZE 514
581 
582 /** Maximum length of a header on a variable-length cell. */
583 #define VAR_CELL_MAX_HEADER_SIZE 7
584 
585 static int get_cell_network_size(int wide_circ_ids);
586 static inline int get_cell_network_size(int wide_circ_ids)
587 {
588  return wide_circ_ids ? CELL_MAX_NETWORK_SIZE : CELL_MAX_NETWORK_SIZE - 2;
589 }
590 static int get_var_cell_header_size(int wide_circ_ids);
591 static inline int get_var_cell_header_size(int wide_circ_ids)
592 {
593  return wide_circ_ids ? VAR_CELL_MAX_HEADER_SIZE :
595 }
596 static int get_circ_id_size(int wide_circ_ids);
597 static inline int get_circ_id_size(int wide_circ_ids)
598 {
599  return wide_circ_ids ? 4 : 2;
600 }
601 
602 /** Number of bytes in a relay cell's header (not including general cell
603  * header). */
604 #define RELAY_HEADER_SIZE (1+2+2+4+2)
605 /** Largest number of bytes that can fit in a relay cell payload. */
606 #define RELAY_PAYLOAD_SIZE (CELL_PAYLOAD_SIZE-RELAY_HEADER_SIZE)
607 
608 /** Identifies a circuit on an or_connection */
609 typedef uint32_t circid_t;
610 /** Identifies a stream on a circuit */
611 typedef uint16_t streamid_t;
612 
613 /* channel_t typedef; struct channel_t is in channel.h */
614 
615 typedef struct channel_t channel_t;
616 
617 /* channel_listener_t typedef; struct channel_listener_t is in channel.h */
618 
620 
621 /* TLS channel stuff */
622 
623 typedef struct channel_tls_t channel_tls_t;
624 
625 /* circuitmux_t typedef; struct circuitmux_t is in circuitmux.h */
626 
627 typedef struct circuitmux_t circuitmux_t;
628 
629 typedef struct cell_t cell_t;
630 typedef struct var_cell_t var_cell_t;
631 typedef struct packed_cell_t packed_cell_t;
632 typedef struct cell_queue_t cell_queue_t;
633 typedef struct destroy_cell_t destroy_cell_t;
635 typedef struct ext_or_cmd_t ext_or_cmd_t;
636 
637 /** Beginning of a RELAY cell payload. */
638 typedef struct {
639  uint8_t command; /**< The end-to-end relay command. */
640  uint16_t recognized; /**< Used to tell whether cell is for us. */
641  streamid_t stream_id; /**< Which stream is this cell associated with? */
642  char integrity[4]; /**< Used to tell whether cell is corrupted. */
643  uint16_t length; /**< How long is the payload body? */
645 
646 typedef struct socks_request_t socks_request_t;
647 typedef struct entry_port_cfg_t entry_port_cfg_t;
648 typedef struct server_port_cfg_t server_port_cfg_t;
649 
650 /** Minimum length of the random part of an AUTH_CHALLENGE cell. */
651 #define OR_AUTH_CHALLENGE_LEN 32
652 
653 /**
654  * @name Certificate types for CERTS cells.
655  *
656  * These values are defined by the protocol, and affect how an X509
657  * certificate in a CERTS cell is interpreted and used.
658  *
659  * @{ */
660 /** A certificate that authenticates a TLS link key. The subject key
661  * must match the key used in the TLS handshake; it must be signed by
662  * the identity key. */
663 #define OR_CERT_TYPE_TLS_LINK 1
664 /** A self-signed identity certificate. The subject key must be a
665  * 1024-bit RSA key. */
666 #define OR_CERT_TYPE_ID_1024 2
667 /** A certificate that authenticates a key used in an AUTHENTICATE cell
668  * in the v3 handshake. The subject key must be a 1024-bit RSA key; it
669  * must be signed by the identity key */
670 #define OR_CERT_TYPE_AUTH_1024 3
671 /* DOCDOC */
672 #define OR_CERT_TYPE_RSA_ED_CROSSCERT 7
673 /**@}*/
674 
675 /** The first supported type of AUTHENTICATE cell. It contains
676  * a bunch of structures signed with an RSA1024 key. The signed
677  * structures include a HMAC using negotiated TLS secrets, and a digest
678  * of all cells sent or received before the AUTHENTICATE cell (including
679  * the random server-generated AUTH_CHALLENGE cell).
680  */
681 #define AUTHTYPE_RSA_SHA256_TLSSECRET 1
682 /** As AUTHTYPE_RSA_SHA256_TLSSECRET, but instead of using the
683  * negotiated TLS secrets, uses exported keying material from the TLS
684  * session as described in RFC 5705.
685  *
686  * Not used by today's tors, since everything that supports this
687  * also supports ED25519_SHA256_5705, which is better.
688  **/
689 #define AUTHTYPE_RSA_SHA256_RFC5705 2
690 /** As AUTHTYPE_RSA_SHA256_RFC5705, but uses an Ed25519 identity key to
691  * authenticate. */
692 #define AUTHTYPE_ED25519_SHA256_RFC5705 3
693 /*
694  * NOTE: authchallenge_type_is_better() relies on these AUTHTYPE codes
695  * being sorted in order of preference. If we someday add one with
696  * a higher numerical value that we don't like as much, we should revise
697  * authchallenge_type_is_better().
698  */
699 
700 /** The length of the part of the AUTHENTICATE cell body that the client and
701  * server can generate independently (when using RSA_SHA256_TLSSECRET). It
702  * contains everything except the client's timestamp, the client's randomly
703  * generated nonce, and the signature. */
704 #define V3_AUTH_FIXED_PART_LEN (8+(32*6))
705 /** The length of the part of the AUTHENTICATE cell body that the client
706  * signs. */
707 #define V3_AUTH_BODY_LEN (V3_AUTH_FIXED_PART_LEN + 8 + 16)
708 
711 
712 /** Length of Extended ORPort connection identifier. */
713 #define EXT_OR_CONN_ID_LEN DIGEST_LEN /* 20 */
714 /*
715  * OR_CONN_HIGHWATER and OR_CONN_LOWWATER moved from connection_or.c so
716  * channeltls.c can see them too.
717  */
718 
719 /** When adding cells to an OR connection's outbuf, keep adding until the
720  * outbuf is at least this long, or we run out of cells. */
721 #define OR_CONN_HIGHWATER (32*1024)
722 
723 /** Add cells to an OR connection's outbuf whenever the outbuf's data length
724  * drops below this size. */
725 #define OR_CONN_LOWWATER (16*1024)
726 
727 typedef struct connection_t connection_t;
729 typedef struct dir_connection_t dir_connection_t;
730 typedef struct edge_connection_t edge_connection_t;
733 typedef struct or_connection_t or_connection_t;
734 
735 /** Cast a connection_t subtype pointer to a connection_t **/
736 #define TO_CONN(c) (&(((c)->base_)))
737 
738 /** Cast a entry_connection_t subtype pointer to a connection_t **/
739 #define ENTRY_TO_CONN(c) (TO_CONN(ENTRY_TO_EDGE_CONN(c)))
740 
741 typedef struct addr_policy_t addr_policy_t;
742 
743 typedef struct cached_dir_t cached_dir_t;
744 
745 /** Enum used to remember where a signed_descriptor_t is stored and how to
746  * manage the memory for signed_descriptor_body. */
747 typedef enum {
748  /** The descriptor isn't stored on disk at all: the copy in memory is
749  * canonical; the saved_offset field is meaningless. */
751  /** The descriptor is stored in the cached_routers file: the
752  * signed_descriptor_body is meaningless; the signed_descriptor_len and
753  * saved_offset are used to index into the mmaped cache file. */
755  /** The descriptor is stored in the cached_routers.new file: the
756  * signed_descriptor_body and saved_offset fields are both set. */
757  /* FFFF (We could also mmap the file and grow the mmap as needed, or
758  * lazy-load the descriptor text by using seek and read. We don't, for
759  * now.)
760  */
763 #define saved_location_bitfield_t ENUM_BF(saved_location_t)
764 
765 /** Enumeration: what directory object is being downloaded?
766  * This determines which schedule is selected to perform the download. */
767 typedef enum {
768  DL_SCHED_GENERIC = 0,
769  DL_SCHED_CONSENSUS = 1,
770  DL_SCHED_BRIDGE = 2,
772 #define download_schedule_bitfield_t ENUM_BF(download_schedule_t)
773 
774 /** Enumeration: is the download schedule for downloading from an authority,
775  * or from any available directory mirror?
776  * During bootstrap, "any" means a fallback (or an authority, if there
777  * are no fallbacks).
778  * When we have a valid consensus, "any" means any directory server. */
779 typedef enum {
780  DL_WANT_ANY_DIRSERVER = 0,
781  DL_WANT_AUTHORITY = 1,
783 #define download_want_authority_bitfield_t \
784  ENUM_BF(download_want_authority_t)
785 
786 /** Enumeration: do we want to increment the schedule position each time a
787  * connection is attempted (these attempts can be concurrent), or do we want
788  * to increment the schedule position after a connection fails? */
789 typedef enum {
790  DL_SCHED_INCREMENT_FAILURE = 0,
791  DL_SCHED_INCREMENT_ATTEMPT = 1,
793 #define download_schedule_increment_bitfield_t \
794  ENUM_BF(download_schedule_increment_t)
795 
796 typedef struct download_status_t download_status_t;
797 
798 /** If n_download_failures is this high, the download can never happen. */
799 #define IMPOSSIBLE_TO_DOWNLOAD 255
800 
801 /** The max size we expect router descriptor annotations we create to
802  * be. We'll accept larger ones if we see them on disk, but we won't
803  * create any that are larger than this. */
804 #define ROUTER_ANNOTATION_BUF_LEN 256
805 
807 
808 /** Flags used to summarize the declared protocol versions of a relay,
809  * so we don't need to parse them again and again. */
810 typedef struct protover_summary_flags_t {
811  /** True iff we have a proto line for this router, or a versions line
812  * from which we could infer the protocols. */
813  unsigned int protocols_known:1;
814 
815  /** True iff this router has a version or protocol list that allows it to
816  * accept EXTEND2 cells. This requires Relay=2. */
817  unsigned int supports_extend2_cells:1;
818 
819  /** True iff this router has a version or protocol list that allows it to
820  * accept IPv6 connections. This requires Relay=2 or Relay=3. */
822 
823  /** True iff this router has a version or protocol list that allows it to
824  * initiate IPv6 connections. This requires Relay=3. */
826 
827  /** True iff this router has a version or protocol list that allows it to
828  * consider IPv6 connections canonical. This requires Relay=3. */
830 
831  /** True iff this router has a protocol list that allows it to negotiate
832  * ed25519 identity keys on a link handshake with us. This
833  * requires LinkAuth=3. */
835 
836  /** True iff this router has a protocol list that allows it to negotiate
837  * ed25519 identity keys on a link handshake, at all. This requires some
838  * LinkAuth=X for X >= 3. */
840 
841  /** True iff this router has a protocol list that allows it to be an
842  * introduction point supporting ed25519 authentication key which is part of
843  * the v3 protocol detailed in proposal 224. This requires HSIntro=4. */
844  unsigned int supports_ed25519_hs_intro : 1;
845 
846  /** True iff this router has a protocol list that allows it to support the
847  * ESTABLISH_INTRO DoS cell extension. Requires HSIntro=5. */
849 
850  /** True iff this router has a protocol list that allows it to be an hidden
851  * service directory supporting version 3 as seen in proposal 224. This
852  * requires HSDir=2. */
853  unsigned int supports_v3_hsdir : 1;
854 
855  /** True iff this router has a protocol list that allows it to be an hidden
856  * service rendezvous point supporting version 3 as seen in proposal 224.
857  * This requires HSRend=2. */
859 
860  /** True iff this router has a protocol list that allows clients to
861  * negotiate hs circuit setup padding. Requires Padding=2. */
862  unsigned int supports_hs_setup_padding : 1;
863 
865 
866 typedef struct routerinfo_t routerinfo_t;
867 typedef struct extrainfo_t extrainfo_t;
868 typedef struct routerstatus_t routerstatus_t;
869 
870 typedef struct microdesc_t microdesc_t;
871 typedef struct node_t node_t;
877 
878 /** Enumerates recognized flavors of a consensus networkstatus document. All
879  * flavors of a consensus are generated from the same set of votes, but they
880  * present different types information to different versions of Tor. */
881 typedef enum {
882  FLAV_NS = 0,
883  FLAV_MICRODESC = 1,
885 
886 /** How many different consensus flavors are there? */
887 #define N_CONSENSUS_FLAVORS ((int)(FLAV_MICRODESC)+1)
888 
889 typedef struct networkstatus_t networkstatus_t;
891 typedef struct desc_store_t desc_store_t;
892 typedef struct routerlist_t routerlist_t;
893 typedef struct extend_info_t extend_info_t;
894 typedef struct authority_cert_t authority_cert_t;
895 
896 /** Bitfield enum type listing types of information that directory authorities
897  * can be authoritative about, and that directory caches may or may not cache.
898  *
899  * Note that the granularity here is based on authority granularity and on
900  * cache capabilities. Thus, one particular bit may correspond in practice to
901  * a few types of directory info, so long as every authority that pronounces
902  * officially about one of the types prounounces officially about all of them,
903  * and so long as every cache that caches one of them caches all of them.
904  */
905 typedef enum {
906  NO_DIRINFO = 0,
907  /** Serves/signs v3 directory information: votes, consensuses, certs */
908  V3_DIRINFO = 1 << 2,
909  /** Serves bridge descriptors. */
910  BRIDGE_DIRINFO = 1 << 4,
911  /** Serves extrainfo documents. */
913  /** Serves microdescriptors. */
916 
917 #define ALL_DIRINFO ((dirinfo_type_t)((1<<7)-1))
918 
919 #define ONION_HANDSHAKE_TYPE_TAP 0x0000
920 #define ONION_HANDSHAKE_TYPE_FAST 0x0001
921 #define ONION_HANDSHAKE_TYPE_NTOR 0x0002
922 #define MAX_ONION_HANDSHAKE_TYPE 0x0002
923 
925 typedef struct relay_crypto_t relay_crypto_t;
926 typedef struct crypt_path_t crypt_path_t;
928 
929 #define CPATH_KEY_MATERIAL_LEN (20*2+16*2)
930 
932 
933 struct create_cell_t;
934 
935 /** Entry in the cell stats list of a circuit; used only if CELL_STATS
936  * events are enabled. */
938  uint8_t command; /**< cell command number. */
939  /** Waiting time in centiseconds if this event is for a removed cell,
940  * or 0 if this event is for adding a cell to the queue. 22 bits can
941  * store more than 11 hours, enough to assume that a circuit with this
942  * delay would long have been closed. */
943  unsigned int waiting_time:22;
944  unsigned int removed:1; /**< 0 for added to, 1 for removed from queue. */
945  unsigned int exitward:1; /**< 0 for app-ward, 1 for exit-ward. */
947 
948 typedef struct circuit_t circuit_t;
949 typedef struct origin_circuit_t origin_circuit_t;
950 typedef struct or_circuit_t or_circuit_t;
951 
952 /** Largest number of relay_early cells that we can send on a given
953  * circuit. */
954 #define MAX_RELAY_EARLY_CELLS_PER_CIRCUIT 8
955 
956 typedef enum path_state_t path_state_t;
957 #define path_state_bitfield_t ENUM_BF(path_state_t)
958 
959 #if REND_COOKIE_LEN != DIGEST_LEN
960 #error "The REND_TOKEN_LEN macro assumes REND_COOKIE_LEN == DIGEST_LEN"
961 #endif
962 #define REND_TOKEN_LEN DIGEST_LEN
963 
964 /** Convert a circuit subtype to a circuit_t. */
965 #define TO_CIRCUIT(x) (&((x)->base_))
966 
967 /** @name Isolation flags
968 
969  Ways to isolate client streams
970 
971  @{
972 */
973 /** Isolate based on destination port */
974 #define ISO_DESTPORT (1u<<0)
975 /** Isolate based on destination address */
976 #define ISO_DESTADDR (1u<<1)
977 /** Isolate based on SOCKS authentication */
978 #define ISO_SOCKSAUTH (1u<<2)
979 /** Isolate based on client protocol choice */
980 #define ISO_CLIENTPROTO (1u<<3)
981 /** Isolate based on client address */
982 #define ISO_CLIENTADDR (1u<<4)
983 /** Isolate based on session group (always on). */
984 #define ISO_SESSIONGRP (1u<<5)
985 /** Isolate based on newnym epoch (always on). */
986 #define ISO_NYM_EPOCH (1u<<6)
987 /** Isolate all streams (Internal only). */
988 #define ISO_STREAM (1u<<7)
989 /**@}*/
990 
991 /** Default isolation level for ports. */
992 #define ISO_DEFAULT (ISO_CLIENTADDR|ISO_SOCKSAUTH|ISO_SESSIONGRP|ISO_NYM_EPOCH)
993 
994 /** Indicates that we haven't yet set a session group on a port_cfg_t. */
995 #define SESSION_GROUP_UNSET -1
996 /** Session group reserved for directory connections */
997 #define SESSION_GROUP_DIRCONN -2
998 /** Session group reserved for resolve requests launched by a controller */
999 #define SESSION_GROUP_CONTROL_RESOLVE -3
1000 /** First automatically allocated session group number */
1001 #define SESSION_GROUP_FIRST_AUTO -4
1002 
1003 typedef struct port_cfg_t port_cfg_t;
1004 typedef struct routerset_t routerset_t;
1005 
1006 /** A magic value for the (Socks|OR|...)Port options below, telling Tor
1007  * to pick its own port. */
1008 #define CFG_AUTO_PORT 0xc4005e
1009 
1010 typedef struct or_options_t or_options_t;
1011 
1012 typedef struct or_state_t or_state_t;
1013 
1014 #define MAX_SOCKS_ADDR_LEN 256
1015 
1016 /********************************* circuitbuild.c **********************/
1017 
1018 /** How many hops does a general-purpose circuit have by default? */
1019 #define DEFAULT_ROUTE_LEN 3
1020 
1021 /* Circuit Build Timeout "public" structures. */
1022 
1023 /** Precision multiplier for the Bw weights */
1024 #define BW_WEIGHT_SCALE 10000
1025 #define BW_MIN_WEIGHT_SCALE 1
1026 #define BW_MAX_WEIGHT_SCALE INT32_MAX
1027 
1029 
1030 /********************************* config.c ***************************/
1031 
1032 /********************************* connection_edge.c *************************/
1033 
1034 /** Enumerates possible origins of a client-side address mapping. */
1035 typedef enum {
1036  /** We're remapping this address because the controller told us to. */
1038  /** We're remapping this address because of an AutomapHostsOnResolve
1039  * configuration. */
1041  /** We're remapping this address because our configuration (via torrc, the
1042  * command line, or a SETCONF command) told us to. */
1044  /** We're remapping this address because we have TrackHostExit configured,
1045  * and we want to remember to use the same exit next time. */
1047  /** We're remapping this address because we got a DNS resolution from a
1048  * Tor server that told us what its value was. */
1050 
1051  /** No remapping has occurred. This isn't a possible value for an
1052  * addrmap_entry_t; it's used as a null value when we need to answer "Why
1053  * did this remapping happen." */
1056 #define addressmap_entry_source_bitfield_t ENUM_BF(addressmap_entry_source_t)
1057 
1058 #define WRITE_STATS_INTERVAL (24*60*60)
1059 
1060 /********************************* dirvote.c ************************/
1061 
1062 typedef struct vote_timing_t vote_timing_t;
1063 
1064 /********************************* microdesc.c *************************/
1065 
1066 typedef struct microdesc_cache_t microdesc_cache_t;
1067 
1068 /********************************* rendcommon.c ***************************/
1069 
1073 
1074 /** The maximum number of non-circuit-build-timeout failures a hidden
1075  * service client will tolerate while trying to build a circuit to an
1076  * introduction point. See also rend_intro_point_t.unreachable_count. */
1077 #define MAX_INTRO_POINT_REACHABILITY_FAILURES 5
1078 
1079 /** The minimum and maximum number of distinct INTRODUCE2 cells which a
1080  * hidden service's introduction point will receive before it begins to
1081  * expire. */
1082 #define INTRO_POINT_MIN_LIFETIME_INTRODUCTIONS 16384
1083 /* Double the minimum value so the interval is [min, min * 2]. */
1084 #define INTRO_POINT_MAX_LIFETIME_INTRODUCTIONS \
1085  (INTRO_POINT_MIN_LIFETIME_INTRODUCTIONS * 2)
1086 
1087 /** The minimum number of seconds that an introduction point will last
1088  * before expiring due to old age. (If it receives
1089  * INTRO_POINT_LIFETIME_INTRODUCTIONS INTRODUCE2 cells, it may expire
1090  * sooner.)
1091  *
1092  * XXX Should this be configurable? */
1093 #define INTRO_POINT_LIFETIME_MIN_SECONDS (18*60*60)
1094 /** The maximum number of seconds that an introduction point will last
1095  * before expiring due to old age.
1096  *
1097  * XXX Should this be configurable? */
1098 #define INTRO_POINT_LIFETIME_MAX_SECONDS (24*60*60)
1099 
1100 /** The maximum number of circuit creation retry we do to an intro point
1101  * before giving up. We try to reuse intro point that fails during their
1102  * lifetime so this is a hard limit on the amount of time we do that. */
1103 #define MAX_INTRO_POINT_CIRCUIT_RETRIES 3
1104 
1105 typedef struct rend_intro_point_t rend_intro_point_t;
1107 
1108 /********************************* routerlist.c ***************************/
1109 
1110 typedef struct dir_server_t dir_server_t;
1111 
1112 #define RELAY_REQUIRED_MIN_BANDWIDTH (75*1024)
1113 #define BRIDGE_REQUIRED_MIN_BANDWIDTH (50*1024)
1114 
1115 #define ROUTER_MAX_DECLARED_BANDWIDTH INT32_MAX
1116 
1117 typedef struct tor_version_t tor_version_t;
1118 
1119 #endif /* !defined(TOR_OR_H) */
crypt_path_reference_t
Definition: crypt_path_reference_st.h:19
CELL_MAX_NETWORK_SIZE
#define CELL_MAX_NETWORK_SIZE
Definition: or.h:580
microdesc_t
Definition: microdesc_st.h:27
DOWNCAST
#define DOWNCAST(to, ptr)
Definition: or.h:109
path.h
Header for path.c.
routerinfo_t
Definition: routerinfo_st.h:20
testing_cell_stats_entry_t
Definition: or.h:937
protover_summary_flags_t::supports_accepting_ipv6_extends
unsigned int supports_accepting_ipv6_extends
Definition: or.h:821
ADDRMAPSRC_DNS
@ ADDRMAPSRC_DNS
Definition: or.h:1049
or_state_t
Definition: or_state_st.h:21
inaddr.h
Header for inaddr.c.
protover_summary_flags_t
Definition: or.h:810
addsub.h
Header for addsub.c.
smartlist.h
Header for smartlist.c.
dh_sizes.h
Definitions for sizes of Diffie-Hellman groups elements in Z_p.
extrainfo_t
Definition: extrainfo_st.h:18
rend_data_v2_t::desc_id_fetch
char desc_id_fetch[DIGEST_LEN]
Definition: or.h:455
addressmap_entry_source_t
addressmap_entry_source_t
Definition: or.h:1035
vote_microdesc_hash_t
Definition: vote_microdesc_hash_st.h:18
REND_NUMBER_OF_NON_CONSECUTIVE_REPLICAS
#define REND_NUMBER_OF_NON_CONSECUTIVE_REPLICAS
Definition: or.h:349
cmp.h
Macro definitions for MIN, MAX, and CLAMP.
ADDRMAPSRC_AUTOMAP
@ ADDRMAPSRC_AUTOMAP
Definition: or.h:1040
rend_data_v2_t::auth_type
rend_auth_type_t auth_type
Definition: or.h:450
download_schedule_increment_t
download_schedule_increment_t
Definition: or.h:789
REND_SERVICE_ADDRESS_LEN
#define REND_SERVICE_ADDRESS_LEN
Definition: or.h:335
parse_int.h
Header for parse_int.c.
protover_summary_flags_t::supports_initiating_ipv6_extends
unsigned int supports_initiating_ipv6_extends
Definition: or.h:825
relay_header_t::command
uint8_t command
Definition: or.h:639
tor_assert
#define tor_assert(expr)
Definition: util_bug.h:102
desc_store_t
Definition: desc_store_st.h:23
download_want_authority_t
download_want_authority_t
Definition: or.h:779
compat_string.h
Header for compat_string.c.
protover_summary_flags_t::supports_v3_hsdir
unsigned int supports_v3_hsdir
Definition: or.h:853
create_cell_t
Definition: onion.h:24
rend_auth_type_t
rend_auth_type_t
Definition: or.h:403
threads.h
Header for threads.c.
REND_SERVICE_ID_LEN_BASE32
#define REND_SERVICE_ID_LEN_BASE32
Definition: or.h:332
cell_direction_t
cell_direction_t
Definition: or.h:483
ADDRMAPSRC_TORRC
@ ADDRMAPSRC_TORRC
Definition: or.h:1043
testing_cell_stats_entry_t::command
uint8_t command
Definition: or.h:938
escape.h
Header for escape.c.
destroy_cell_queue_t
Definition: destroy_cell_queue_st.h:27
torint.h
Integer definitions used throughout Tor.
routerstatus_t
Definition: routerstatus_st.h:19
server_port_cfg_t
Definition: server_port_cfg_st.h:15
compat_time.h
Functions and types for monotonic times.
protover_summary_flags_t::supports_ed25519_link_handshake_any
unsigned int supports_ed25519_link_handshake_any
Definition: or.h:839
tor_version_t
Definition: tor_version_st.h:21
ratelim.h
Summarize similar messages that would otherwise flood the logs.
relay_crypto_t
Definition: relay_crypto_st.h:19
rend_service_descriptor_t
Definition: rend_service_descriptor_st.h:19
rend_data_t::nr_streams
int nr_streams
Definition: or.h:431
util_bug.h
Macros to manage assertions, fatal and non-fatal.
or_connection_t
Definition: or_connection_st.h:22
approx_time.h
Header for approx_time.c.
crypt_path_t
Definition: crypt_path_st.h:47
circuit_channel_direction_t
circuit_channel_direction_t
Definition: or.h:495
listener_connection_t
Definition: listener_connection_st.h:18
crypto_rsa.h
Headers for crypto_rsa.c.
protover_summary_flags_t::supports_canonical_ipv6_conns
unsigned int supports_canonical_ipv6_conns
Definition: or.h:829
addr_policy_t
Definition: addr_policy_st.h:26
cell_t
Definition: cell_st.h:17
protover_summary_flags_t::supports_ed25519_hs_intro
unsigned int supports_ed25519_hs_intro
Definition: or.h:844
relay_header_t::stream_id
streamid_t stream_id
Definition: or.h:641
consensus_flavor_t
consensus_flavor_t
Definition: or.h:881
CELL_DIRECTION_OUT
@ CELL_DIRECTION_OUT
Definition: or.h:485
bits.h
Header for bits.c.
DIGEST_LEN
#define DIGEST_LEN
Definition: digest_sizes.h:20
document_signature_t
Definition: document_signature_st.h:16
country.h
Country type for geoip.
packed_cell_t
Definition: cell_queue_st.h:18
address.h
Headers for address.h.
circuit_build_times_t
Definition: circuitstats.h:177
routerlist_t
Definition: routerlist_st.h:18
muldiv.h
Header for muldiv.c.
socks_request_t
Definition: socks_request_st.h:37
MICRODESC_DIRINFO
@ MICRODESC_DIRINFO
Definition: or.h:914
ext_or_cmd_t
Definition: proto_ext_or.h:18
node_t
Definition: node_st.h:34
origin_circuit_t
Definition: origin_circuit_st.h:79
rend_data_v2_t::descriptor_cookie
char descriptor_cookie[REND_DESC_COOKIE_LEN]
Definition: or.h:447
printf.h
Header for printf.c.
protover_summary_flags_t::supports_extend2_cells
unsigned int supports_extend2_cells
Definition: or.h:817
vote_routerstatus_t
Definition: vote_routerstatus_st.h:18
VAR_CELL_MAX_HEADER_SIZE
#define VAR_CELL_MAX_HEADER_SIZE
Definition: or.h:583
ed25519_public_key_t
Definition: crypto_ed25519.h:23
path_state_t
path_state_t
Definition: origin_circuit_st.h:36
REND_COOKIE_LEN
#define REND_COOKIE_LEN
Definition: or.h:400
vote_timing_t
Definition: vote_timing_st.h:16
rend_service_authorization_t
Definition: or.h:410
SAVED_IN_JOURNAL
@ SAVED_IN_JOURNAL
Definition: or.h:761
download_status_t
Definition: download_status_st.h:41
time.h
Definitions for timing-related constants.
port_cfg_t
Definition: port_cfg_st.h:19
networkstatus_sr_info_t
Definition: networkstatus_sr_info_st.h:15
circuit_t
Definition: circuit_st.h:61
hs_ident_dir_conn_t
Definition: hs_ident.h:87
binascii.h
Header for binascii.c.
networkstatus_voter_info_t
Definition: networkstatus_voter_info_st.h:16
cell_queue_t
Definition: cell_queue_st.h:28
scanf.h
Header for scanf.c.
dir_server_t
Definition: dir_server_st.h:21
buffers.h
Header file for buffers.c.
cached_dir_t
Definition: cached_dir_st.h:17
saved_location_t
saved_location_t
Definition: or.h:747
malloc.h
Headers for util_malloc.c.
authority_cert_t
Definition: authority_cert_st.h:19
channel_t
Definition: channel.h:181
timeval.h
Declarations for timeval-related macros that some platforms are missing.
rend_data_t::rend_cookie
char rend_cookie[REND_COOKIE_LEN]
Definition: or.h:428
EXTRAINFO_DIRINFO
@ EXTRAINFO_DIRINFO
Definition: or.h:912
protover_summary_flags_t::supports_establish_intro_dos_extension
unsigned int supports_establish_intro_dos_extension
Definition: or.h:848
map.h
Headers for map.c.
protover_summary_flags_t::protocols_known
unsigned int protocols_known
Definition: or.h:813
connection_t
Definition: connection_st.h:45
download_schedule_t
download_schedule_t
Definition: or.h:767
protover_summary_flags_t::supports_ed25519_link_handshake_compat
unsigned int supports_ed25519_link_handshake_compat
Definition: or.h:834
di_ops.h
Headers for di_ops.c.
relay_header_t::length
uint16_t length
Definition: or.h:643
time_fmt.h
Header for time_fmt.c.
hsdir_index_t
Definition: hsdir_index_st.h:17
rend_intro_point_t
Definition: rend_intro_point_st.h:21
SAVED_IN_CACHE
@ SAVED_IN_CACHE
Definition: or.h:754
mmap.h
Header for mmap.c.
protover_summary_flags_t::supports_v3_rendezvous_point
unsigned int supports_v3_rendezvous_point
Definition: or.h:858
rend_encoded_v2_service_descriptor_t
Definition: rend_encoded_v2_service_descriptor_st.h:16
entry_port_cfg_st.h
Configuration structure for client ports.
curve25519_public_key_t
Definition: crypto_curve25519.h:24
userdb.h
Header for userdb.c.
ADDRMAPSRC_NONE
@ ADDRMAPSRC_NONE
Definition: or.h:1054
crypto_cipher.h
Headers for crypto_cipher.c.
relay_header_t
Definition: or.h:638
ADDRMAPSRC_CONTROLLER
@ ADDRMAPSRC_CONTROLLER
Definition: or.h:1037
V3_DIRINFO
@ V3_DIRINFO
Definition: or.h:908
destroy_cell_t
Definition: destroy_cell_queue_st.h:18
or_handshake_state_t
Definition: or_handshake_state_st.h:18
hs_ident_circuit_t
Definition: hs_ident.h:42
dirinfo_type_t
dirinfo_type_t
Definition: or.h:905
REND_DESC_COOKIE_LEN
#define REND_DESC_COOKIE_LEN
Definition: or.h:367
channel_listener_t
Definition: channel.h:461
rend_data_v2_t::descriptor_id
char descriptor_id[REND_NUMBER_OF_NON_CONSECUTIVE_REPLICAS][DIGEST_LEN]
Definition: or.h:444
testsupport.h
Macros to implement mocking and selective exposure for the test code.
ADDRMAPSRC_TRACKEXIT
@ ADDRMAPSRC_TRACKEXIT
Definition: or.h:1046
logic.h
Macros for comparing the boolean value of integers.
rend_data_v2_t::onion_address
char onion_address[REND_SERVICE_ID_LEN_BASE32+1]
Definition: or.h:439
microdesc_cache_t
Definition: microdesc.c:48
relay_header_t::recognized
uint16_t recognized
Definition: or.h:640
control_connection_t
Definition: control_connection_st.h:19
edge_connection_t
Definition: edge_connection_st.h:21
rend_data_t
Definition: or.h:419
streamid_t
uint16_t streamid_t
Definition: or.h:611
socket.h
Header for socket.c.
bytes.h
Inline functions for reading and writing multibyte values from the middle of strings,...
or_handshake_certs_t
Definition: or_handshake_certs_st.h:19
or_circuit_t
Definition: or_circuit_st.h:21
cpath_build_state_t
Definition: cpath_build_state_st.h:16
protover_summary_flags_t::supports_hs_setup_padding
unsigned int supports_hs_setup_padding
Definition: or.h:862
hs_ident_edge_conn_t
Definition: hs_ident.h:103
BRIDGE_DIRINFO
@ BRIDGE_DIRINFO
Definition: or.h:910
testing_cell_stats_entry_t::exitward
unsigned int exitward
Definition: or.h:945
files.h
Wrappers for reading and writing data to files on disk.
signed_descriptor_t
Definition: signed_descriptor_st.h:18
entry_port_cfg_t
Definition: entry_port_cfg_st.h:18
or_options_t
Definition: or_options_st.h:64
onion_handshake_state_t
Definition: crypt_path_st.h:23
rend_data_v2_t::rend_pk_digest
char rend_pk_digest[DIGEST_LEN]
Definition: or.h:458
dir_connection_t
Definition: dir_connection_st.h:21
ns_detached_signatures_t
Definition: ns_detached_signatures_st.h:17
var_cell_t
Definition: var_cell_st.h:16
entry_connection_t
Definition: entry_connection_st.h:19
rend_data_v2_t
Definition: or.h:434
dir.h
Header for dir.c.
torerr.h
Headers for torerr.c.
networkstatus_t
Definition: networkstatus_st.h:26
rend_data_t::hsdirs_fp
smartlist_t * hsdirs_fp
Definition: or.h:425
SAVED_NOWHERE
@ SAVED_NOWHERE
Definition: or.h:750
smartlist_t
Definition: smartlist_core.h:26
compat_compiler.h
Utility macros to handle different features and behavior in different compilers.
CELL_DIRECTION_IN
@ CELL_DIRECTION_IN
Definition: or.h:484
util_string.h
Header for util_string.c.
testing_cell_stats_entry_t::waiting_time
unsigned int waiting_time
Definition: or.h:943
rend_authorized_client_t
Definition: rend_authorized_client_st.h:16
compat_ctype.h
Locale-independent character-type inspection (header)
cstring.h
Header for cstring.c.
extend_info_t
Definition: extend_info_st.h:27
circid_t
uint32_t circid_t
Definition: or.h:609
testing_cell_stats_entry_t::removed
unsigned int removed
Definition: or.h:944