Tor  0.4.7.0-alpha-dev
process_descs.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-2021, The Tor Project, Inc. */
5 /* See LICENSE for licensing information */
6 
7 /**
8  * \file process_descs.h
9  * \brief Header file for process_descs.c.
10  **/
11 
12 #ifndef TOR_RECV_UPLOADS_H
13 #define TOR_RECV_UPLOADS_H
14 
15 // for was_router_added_t.
17 
19 
20 struct authdir_config_t;
21 
22 /** Target of status_by_digest map. */
23 typedef uint32_t rtr_flags_t;
24 
25 int add_rsa_fingerprint_to_dir(const char *fp, struct authdir_config_t *list,
26  rtr_flags_t add_status);
27 
29  struct authdir_config_t *list,
30  rtr_flags_t add_status);
31 
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. */
40 
41 #if defined(PROCESS_DESCS_PRIVATE) || defined(TOR_UNIT_TESTS)
42 
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 /* 32 Historically used to indicade Unnamed */
49 
50 #endif /* defined(PROCESS_DESCS_PRIVATE) || defined(TOR_UNIT_TESTS) */
51 
52 #ifdef TOR_UNIT_TESTS
53 
54 void authdir_init_fingerprint_list(void);
55 
56 authdir_config_t *authdir_return_fingerprint_list(void);
57 
58 #endif /* defined(TOR_UNIT_TESTS) */
59 
61 
62 #ifdef HAVE_MODULE_DIRAUTH
65  const char *desc, size_t desclen,
66  uint8_t purpose,
67  const char *source,
68  const char **msg);
70  const char **msg,
71  const char *source);
72 
74  const vote_routerstatus_t *vrs);
75 int authdir_wants_to_reject_router(routerinfo_t *ri, const char **msg,
76  int complain,
77  int *valid_out);
79  const ed25519_public_key_t *edkey);
80 uint32_t dirserv_router_get_status(const routerinfo_t *router,
81  const char **msg,
82  int severity);
84  uint32_t authstatus);
85 #else /* !defined(HAVE_MODULE_DIRAUTH) */
86 static inline int
88 {
89  return 0;
90 }
91 static inline enum was_router_added_t
92 dirserv_add_multiple_descriptors(const char *desc, size_t desclen,
93  uint8_t purpose,
94  const char *source,
95  const char **msg)
96 {
97  (void)desc;
98  (void)desclen;
99  (void)purpose;
100  (void)source;
101  *msg = "No directory authority support";
102  return (enum was_router_added_t)0;
103 }
104 static inline enum was_router_added_t
106  const char **msg,
107  const char *source)
108 {
109  (void)ri;
110  (void)source;
111  *msg = "No directory authority support";
112  return (enum was_router_added_t)0;
113 }
114 static inline int
116  const vote_routerstatus_t *vrs)
117 {
118  (void)rs;
119  (void)vrs;
120  return 0;
121 }
122 static inline int
123 authdir_wants_to_reject_router(routerinfo_t *ri, const char **msg,
124  int complain,
125  int *valid_out)
126 {
127  (void)ri;
128  (void)complain;
129  *msg = "No directory authority support";
130  *valid_out = 0;
131  return 0;
132 }
133 static inline int
135 {
136  (void)pk;
137  (void)edkey;
138  return 0;
139 }
140 static inline uint32_t
142  const char **msg,
143  int severity)
144 {
145  (void)router;
146  (void)severity;
147  if (msg)
148  *msg = "No directory authority support";
149  return 0;
150 }
151 static inline void
153  uint32_t authstatus)
154 {
155  (void)node;
156  (void)authstatus;
157 }
158 #endif /* defined(HAVE_MODULE_DIRAUTH) */
159 
160 #ifdef TOR_UNIT_TESTS
162 STATIC bool dirserv_rejects_tor_version(const char *platform,
163  const char **msg);
164 #endif /* defined(TOR_UNIT_TESTS) */
165 
166 #endif /* !defined(TOR_RECV_UPLOADS_H) */
Header for crypto_ed25519.c.
int dirserv_would_reject_router(const routerstatus_t *rs, const vote_routerstatus_t *vrs)
int dirserv_load_fingerprint_file(void)
STATIC bool dirserv_rejects_tor_version(const char *platform, const char **msg)
was_router_added_t dirserv_add_descriptor(routerinfo_t *ri, const char **msg, const char *source)
void dirserv_set_node_flags_from_authoritative_status(node_t *node, uint32_t authstatus)
int dirserv_add_own_fingerprint(crypto_pk_t *pk, const ed25519_public_key_t *edkey)
was_router_added_t dirserv_add_multiple_descriptors(const char *desc, size_t desclen, uint8_t purpose, const char *source, const char **msg)
uint32_t dirserv_router_get_status(const routerinfo_t *router, const char **msg, int severity)
STATIC int dirserv_router_has_valid_address(routerinfo_t *ri)
int authdir_wants_to_reject_router(routerinfo_t *ri, const char **msg, int complain, int *valid_out)
int add_ed25519_to_dir(const ed25519_public_key_t *edkey, struct authdir_config_t *list, rtr_flags_t add_status)
int add_rsa_fingerprint_to_dir(const char *fp, struct authdir_config_t *list, rtr_flags_t add_status)
void dirserv_free_fingerprint_list(void)
uint32_t rtr_flags_t
Definition: process_descs.h:20
Header file for routerlist.c.
was_router_added_t
Definition: routerlist.h:17
digest256map_t * status_by_digest256
Definition: process_descs.h:37
strmap_t * fp_by_name
Definition: process_descs.h:35
digestmap_t * status_by_digest
Definition: process_descs.h:36
Definition: node_st.h:34
#define STATIC
Definition: testsupport.h:32