Merge branch 'maint-0.4.8' into release-0.4.8
[tor.git] / src / feature / dirauth / process_descs.h
bloba509eb1fbe403f4bdce45855c1879ccc0708bbf9
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 process_descs.h
9 * \brief Header file for process_descs.c.
10 **/
12 #ifndef TOR_RECV_UPLOADS_H
13 #define TOR_RECV_UPLOADS_H
15 // for was_router_added_t.
16 #include "feature/nodelist/routerlist.h"
18 #include "lib/crypt_ops/crypto_ed25519.h"
20 struct authdir_config_t;
22 /** Target of status_by_digest map. */
23 typedef uint32_t rtr_flags_t;
25 int add_rsa_fingerprint_to_dir(const char *fp, struct authdir_config_t *list,
26 rtr_flags_t add_status);
28 int add_ed25519_to_dir(const ed25519_public_key_t *edkey,
29 struct authdir_config_t *list,
30 rtr_flags_t add_status);
32 /** List of nickname-\>identity fingerprint mappings for all the routers
33 * that we name. Used to prevent router impersonation. */
34 typedef struct authdir_config_t {
35 strmap_t *fp_by_name; /**< Map from lc nickname to fingerprint. */
36 digestmap_t *status_by_digest; /**< Map from digest to router_status_t. */
37 digest256map_t *status_by_digest256; /**< Map from digest256 to
38 * router_status_t. */
39 } authdir_config_t;
41 #if defined(PROCESS_DESCS_PRIVATE) || defined(TOR_UNIT_TESTS)
43 /* 1 Historically used to indicate Named */
44 #define RTR_INVALID 2 /**< Believed invalid. */
45 #define RTR_REJECT 4 /**< We will not publish this router. */
46 /* 8 Historically used to avoid using this as a dir. */
47 #define RTR_BADEXIT 16 /**< We'll tell clients not to use this as an exit. */
48 /** We'll vote to only use this router as a midpoint. */
49 #define RTR_MIDDLEONLY 32
51 #endif /* defined(PROCESS_DESCS_PRIVATE) || defined(TOR_UNIT_TESTS) */
53 #ifdef TOR_UNIT_TESTS
55 void authdir_init_fingerprint_list(void);
57 authdir_config_t *authdir_return_fingerprint_list(void);
59 #endif /* defined(TOR_UNIT_TESTS) */
61 void dirserv_free_fingerprint_list(void);
63 #ifdef HAVE_MODULE_DIRAUTH
64 int dirserv_load_fingerprint_file(void);
65 enum was_router_added_t dirserv_add_multiple_descriptors(
66 const char *desc, size_t desclen,
67 uint8_t purpose,
68 const char *source,
69 const char **msg);
70 enum was_router_added_t dirserv_add_descriptor(routerinfo_t *ri,
71 const char **msg,
72 const char *source);
74 int dirserv_would_reject_router(const routerstatus_t *rs,
75 const vote_routerstatus_t *vrs);
76 int authdir_wants_to_reject_router(routerinfo_t *ri, const char **msg,
77 int complain,
78 int *valid_out);
79 int dirserv_add_own_fingerprint(crypto_pk_t *pk,
80 const ed25519_public_key_t *edkey);
81 uint32_t dirserv_router_get_status(const routerinfo_t *router,
82 const char **msg,
83 int severity);
84 void dirserv_set_node_flags_from_authoritative_status(node_t *node,
85 uint32_t authstatus);
86 #else /* !defined(HAVE_MODULE_DIRAUTH) */
87 static inline int
88 dirserv_load_fingerprint_file(void)
90 return 0;
92 static inline enum was_router_added_t
93 dirserv_add_multiple_descriptors(const char *desc, size_t desclen,
94 uint8_t purpose,
95 const char *source,
96 const char **msg)
98 (void)desc;
99 (void)desclen;
100 (void)purpose;
101 (void)source;
102 *msg = "No directory authority support";
103 return (enum was_router_added_t)0;
105 static inline enum was_router_added_t
106 dirserv_add_descriptor(routerinfo_t *ri,
107 const char **msg,
108 const char *source)
110 (void)ri;
111 (void)source;
112 *msg = "No directory authority support";
113 return (enum was_router_added_t)0;
115 static inline int
116 dirserv_would_reject_router(const routerstatus_t *rs,
117 const vote_routerstatus_t *vrs)
119 (void)rs;
120 (void)vrs;
121 return 0;
123 static inline int
124 authdir_wants_to_reject_router(routerinfo_t *ri, const char **msg,
125 int complain,
126 int *valid_out)
128 (void)ri;
129 (void)complain;
130 *msg = "No directory authority support";
131 *valid_out = 0;
132 return 0;
134 static inline int
135 dirserv_add_own_fingerprint(crypto_pk_t *pk, const ed25519_public_key_t *edkey)
137 (void)pk;
138 (void)edkey;
139 return 0;
141 static inline uint32_t
142 dirserv_router_get_status(const routerinfo_t *router,
143 const char **msg,
144 int severity)
146 (void)router;
147 (void)severity;
148 if (msg)
149 *msg = "No directory authority support";
150 return 0;
152 static inline void
153 dirserv_set_node_flags_from_authoritative_status(node_t *node,
154 uint32_t authstatus)
156 (void)node;
157 (void)authstatus;
159 #endif /* defined(HAVE_MODULE_DIRAUTH) */
161 #ifdef TOR_UNIT_TESTS
162 STATIC int dirserv_router_has_valid_address(routerinfo_t *ri);
163 STATIC bool dirserv_rejects_tor_version(const char *platform,
164 const char **msg);
165 #endif /* defined(TOR_UNIT_TESTS) */
167 #endif /* !defined(TOR_RECV_UPLOADS_H) */