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