Update copyrights to 2021, using "make update-copyright"
[tor.git] / src / feature / nodelist / microdesc_st.h
blobad56b6d6c2b059e27e4cba51ceed40d3e6d2c7f4
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-2021, The Tor Project, Inc. */
5 /* See LICENSE for licensing information */
7 /**
8 * @file microdesc_st.h
9 * @brief Microdescriptor structure
10 **/
12 #ifndef MICRODESC_ST_H
13 #define MICRODESC_ST_H
15 struct curve25519_public_key_t;
16 struct ed25519_public_key_t;
17 struct nodefamily_t;
18 struct short_policy_t;
20 #include "ext/ht.h"
22 /** A microdescriptor is the smallest amount of information needed to build a
23 * circuit through a router. They are generated by the directory authorities,
24 * using information from the uploaded routerinfo documents. They are not
25 * self-signed, but are rather authenticated by having their hash in a signed
26 * networkstatus document. */
27 struct microdesc_t {
28 /** Hashtable node, used to look up the microdesc by its digest. */
29 HT_ENTRY(microdesc_t) node;
31 /* Cache information */
33 /** When was this microdescriptor last listed in a consensus document?
34 * Once a microdesc has been unlisted long enough, we can drop it.
36 time_t last_listed;
37 /** Where is this microdescriptor currently stored? */
38 saved_location_bitfield_t saved_location : 3;
39 /** If true, do not attempt to cache this microdescriptor on disk. */
40 unsigned int no_save : 1;
41 /** If true, this microdesc has an entry in the microdesc_map */
42 unsigned int held_in_map : 1;
43 /** True iff the exit policy for this router rejects everything. */
44 unsigned int policy_is_reject_star : 1;
45 /** Reference count: how many node_ts have a reference to this microdesc? */
46 unsigned int held_by_nodes;
48 /** If saved_location == SAVED_IN_CACHE, this field holds the offset of the
49 * microdescriptor in the cache. */
50 off_t off;
52 /* The string containing the microdesc. */
54 /** A pointer to the encoded body of the microdescriptor. If the
55 * saved_location is SAVED_IN_CACHE, then the body is a pointer into an
56 * mmap'd region. Otherwise, it is a malloc'd string. The string might not
57 * be NUL-terminated; take the length from <b>bodylen</b>. */
58 char *body;
59 /** The length of the microdescriptor in <b>body</b>. */
60 size_t bodylen;
61 /** A SHA256-digest of the microdescriptor. */
62 char digest[DIGEST256_LEN];
64 /* Fields in the microdescriptor. */
66 /**
67 * Public RSA TAP key for onions, ASN.1 encoded. We store this
68 * in its encoded format since storing it as a crypto_pk_t uses
69 * significantly more memory. */
70 char *onion_pkey;
71 /** Length of onion_pkey, in bytes. */
72 size_t onion_pkey_len;
74 /** As routerinfo_t.onion_curve25519_pkey */
75 struct curve25519_public_key_t *onion_curve25519_pkey;
76 /** Ed25519 identity key, if included. */
77 struct ed25519_public_key_t *ed25519_identity_pkey;
78 /** As routerinfo_t.ipv6_addr */
79 tor_addr_t ipv6_addr;
80 /** As routerinfo_t.ipv6_orport */
81 uint16_t ipv6_orport;
82 /** As routerinfo_t.family, with readable members parsed. */
83 struct nodefamily_t *family;
84 /** IPv4 exit policy summary */
85 struct short_policy_t *exit_policy;
86 /** IPv6 exit policy summary */
87 struct short_policy_t *ipv6_exit_policy;
90 #endif /* !defined(MICRODESC_ST_H) */