protover: Fix old tor hardcoded version check
[tor.git] / src / or / routerparse.h
blob9a3fadca1f3856aedc32362ed83f0acf6947973e
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-2016, The Tor Project, Inc. */
5 /* See LICENSE for licensing information */
7 /**
8 * \file routerparse.h
9 * \brief Header file for routerparse.c.
10 **/
12 #ifndef TOR_ROUTERPARSE_H
13 #define TOR_ROUTERPARSE_H
15 int router_get_router_hash(const char *s, size_t s_len, char *digest);
16 int router_get_dir_hash(const char *s, char *digest);
17 int router_get_networkstatus_v3_hashes(const char *s,
18 common_digests_t *digests);
19 int router_get_extrainfo_hash(const char *s, size_t s_len, char *digest);
20 #define DIROBJ_MAX_SIG_LEN 256
21 char *router_get_dirobj_signature(const char *digest,
22 size_t digest_len,
23 const crypto_pk_t *private_key);
24 int router_append_dirobj_signature(char *buf, size_t buf_len,
25 const char *digest,
26 size_t digest_len,
27 crypto_pk_t *private_key);
28 int router_parse_list_from_string(const char **s, const char *eos,
29 smartlist_t *dest,
30 saved_location_t saved_location,
31 int is_extrainfo,
32 int allow_annotations,
33 const char *prepend_annotations,
34 smartlist_t *invalid_digests_out);
36 routerinfo_t *router_parse_entry_from_string(const char *s, const char *end,
37 int cache_copy,
38 int allow_annotations,
39 const char *prepend_annotations,
40 int *can_dl_again_out);
41 extrainfo_t *extrainfo_parse_entry_from_string(const char *s, const char *end,
42 int cache_copy, struct digest_ri_map_t *routermap,
43 int *can_dl_again_out);
44 MOCK_DECL(addr_policy_t *, router_parse_addr_policy_item_from_string,
45 (const char *s, int assume_action, int *malformed_list));
46 version_status_t tor_version_is_obsolete(const char *myversion,
47 const char *versionlist);
48 int tor_version_as_new_as(const char *platform, const char *cutoff);
49 int tor_version_parse(const char *s, tor_version_t *out);
50 int tor_version_compare(tor_version_t *a, tor_version_t *b);
51 int tor_version_same_series(tor_version_t *a, tor_version_t *b);
52 void sort_version_list(smartlist_t *lst, int remove_duplicates);
53 void assert_addr_policy_ok(smartlist_t *t);
54 void dump_distinct_digest_count(int severity);
56 int compare_vote_routerstatus_entries(const void **_a, const void **_b);
57 int networkstatus_verify_bw_weights(networkstatus_t *ns, int);
58 networkstatus_t *networkstatus_parse_vote_from_string(const char *s,
59 const char **eos_out,
60 networkstatus_type_t ns_type);
61 ns_detached_signatures_t *networkstatus_parse_detached_signatures(
62 const char *s, const char *eos);
64 smartlist_t *microdescs_parse_from_string(const char *s, const char *eos,
65 int allow_annotations,
66 saved_location_t where,
67 smartlist_t *invalid_digests_out);
69 authority_cert_t *authority_cert_parse_from_string(const char *s,
70 const char **end_of_string);
71 int rend_parse_v2_service_descriptor(rend_service_descriptor_t **parsed_out,
72 char *desc_id_out,
73 char **intro_points_encrypted_out,
74 size_t *intro_points_encrypted_size_out,
75 size_t *encoded_size_out,
76 const char **next_out, const char *desc,
77 int as_hsdir);
78 int rend_decrypt_introduction_points(char **ipos_decrypted,
79 size_t *ipos_decrypted_size,
80 const char *descriptor_cookie,
81 const char *ipos_encrypted,
82 size_t ipos_encrypted_size);
83 int rend_parse_introduction_points(rend_service_descriptor_t *parsed,
84 const char *intro_points_encoded,
85 size_t intro_points_encoded_size);
86 int rend_parse_client_keys(strmap_t *parsed_clients, const char *str);
88 void routerparse_init(void);
89 void routerparse_free_all(void);
91 #ifdef ROUTERPARSE_PRIVATE
93 * One entry in the list of dumped descriptors; filename dumped to, length,
94 * SHA-256 and timestamp.
97 typedef struct {
98 char *filename;
99 size_t len;
100 uint8_t digest_sha256[DIGEST256_LEN];
101 time_t when;
102 } dumped_desc_t;
104 EXTERN(uint64_t, len_descs_dumped)
105 EXTERN(smartlist_t *, descs_dumped)
106 STATIC int routerstatus_parse_guardfraction(const char *guardfraction_str,
107 networkstatus_t *vote,
108 vote_routerstatus_t *vote_rs,
109 routerstatus_t *rs);
110 MOCK_DECL(STATIC dumped_desc_t *, dump_desc_populate_one_file,
111 (const char *dirname, const char *f));
112 STATIC void dump_desc_populate_fifo_from_directory(const char *dirname);
113 STATIC void dump_desc(const char *desc, const char *type);
114 STATIC void dump_desc_fifo_cleanup(void);
115 struct memarea_t;
116 STATIC routerstatus_t *routerstatus_parse_entry_from_string(
117 struct memarea_t *area,
118 const char **s, smartlist_t *tokens,
119 networkstatus_t *vote,
120 vote_routerstatus_t *vote_rs,
121 int consensus_method,
122 consensus_flavor_t flav);
123 #endif
125 #define ED_DESC_SIGNATURE_PREFIX "Tor router descriptor signature v1"
127 #endif