Tor
0.4.7.0-alpha-dev
|
Header file for routerparse.c. More...
Go to the source code of this file.
Macros | |
#define | ED_DESC_SIGNATURE_PREFIX "Tor router descriptor signature v1" |
Functions | |
int | router_get_router_hash (const char *s, size_t s_len, char *digest) |
int | router_get_extrainfo_hash (const char *s, size_t s_len, char *digest) |
int | router_parse_list_from_string (const char **s, const char *eos, smartlist_t *dest, saved_location_t saved_location, int is_extrainfo, int allow_annotations, const char *prepend_annotations, smartlist_t *invalid_digests_out) |
routerinfo_t * | router_parse_entry_from_string (const char *s, const char *end, int cache_copy, int allow_annotations, const char *prepend_annotations, int *can_dl_again_out) |
extrainfo_t * | extrainfo_parse_entry_from_string (const char *s, const char *end, int cache_copy, struct digest_ri_map_t *routermap, int *can_dl_again_out) |
int | find_single_ipv6_orport (const smartlist_t *list, tor_addr_t *addr_out, uint16_t *port_out) |
void | routerparse_init (void) |
void | routerparse_free_all (void) |
Header file for routerparse.c.
Definition in file routerparse.h.
extrainfo_t* extrainfo_parse_entry_from_string | ( | const char * | s, |
const char * | end, | ||
int | cache_copy, | ||
struct digest_ri_map_t * | routermap, | ||
int * | can_dl_again_out | ||
) |
Parse a single extrainfo entry from the string s, ending at end. (If end is NULL, parse up to the end of s.) If cache_copy is true, make a copy of the extra-info document in the cache_info fields of the result. If routermap is provided, use it as a map from router identity to routerinfo_t when looking up signing keys.
If can_dl_again_out is provided, set *can_dl_again_out to 1 if it's okay to try to download an extrainfo with this same digest again, and 0 if it isn't. (It might not be okay to download it again if part of the part covered by the digest is invalid.)
Definition at line 973 of file routerparse.c.
int find_single_ipv6_orport | ( | const smartlist_t * | list, |
tor_addr_t * | addr_out, | ||
uint16_t * | port_out | ||
) |
Try to find an IPv6 OR port in list of directory_token_t's with at least one argument (use GE(1) in setup). If found, store address and port number to addr_out and port_out. Return number of OR ports found.
Definition at line 340 of file routerparse.c.
int router_get_extrainfo_hash | ( | const char * | s, |
size_t | s_len, | ||
char * | digest | ||
) |
Set digest to the SHA-1 digest of the hash of the s_len-byte extrainfo string at s. Return 0 on success, -1 on failure.
Definition at line 190 of file routerparse.c.
int router_get_router_hash | ( | const char * | s, |
size_t | s_len, | ||
char * | digest | ||
) |
Set digest to the SHA-1 digest of the hash of the first router in s. Return 0 on success, -1 on failure.
Definition at line 180 of file routerparse.c.
routerinfo_t* router_parse_entry_from_string | ( | const char * | s, |
const char * | end, | ||
int | cache_copy, | ||
int | allow_annotations, | ||
const char * | prepend_annotations, | ||
int * | can_dl_again_out | ||
) |
Helper function: reads a single router entry from *s ... *end. Mallocs a new router and returns it if all goes well, else returns NULL. If cache_copy is true, duplicate the contents of s through end into the signed_descriptor_body of the resulting routerinfo_t.
If end is NULL, s must be properly NUL-terminated.
If allow_annotations, it's okay to encounter annotations in s before the router; if it's false, reject the router if it's annotated. If prepend_annotations is set, it should contain some annotations: append them to the front of the router before parsing it, and keep them around when caching the router.
Only one of allow_annotations and prepend_annotations may be set.
If can_dl_again_out is provided, set *can_dl_again_out to 1 if it's okay to try to download a descriptor with this same digest again, and 0 if it isn't. (It might not be okay to download it again if part of the part covered by the digest is invalid.)
Definition at line 394 of file routerparse.c.
Referenced by router_load_single_router(), and routerlist_reparse_old().
int router_parse_list_from_string | ( | const char ** | s, |
const char * | eos, | ||
smartlist_t * | dest, | ||
saved_location_t | saved_location, | ||
int | want_extrainfo, | ||
int | allow_annotations, | ||
const char * | prepend_annotations, | ||
smartlist_t * | invalid_digests_out | ||
) |
Given a string *s containing a concatenated sequence of router descriptors (or extra-info documents if want_extrainfo is set), parses them and stores the result in dest. All routers are marked running and valid. Advances *s to a point immediately following the last router entry. Ignore any trailing router entries that are not complete.
If saved_location isn't SAVED_IN_CACHE, make a local copy of each descriptor in the signed_descriptor_body field of each routerinfo_t. If it isn't SAVED_NOWHERE, remember the offset of each descriptor.
Returns 0 on success and -1 on failure. Adds a digest to invalid_digests_out for every entry that was unparseable or invalid. (This may cause duplicate entries.)
Definition at line 249 of file routerparse.c.
Referenced by router_load_extrainfo_from_string(), and router_load_routers_from_string().
void routerparse_free_all | ( | void | ) |
Clean up all data structures used by routerparse.c at exit
Definition at line 1260 of file routerparse.c.
void routerparse_init | ( | void | ) |
Called on startup; right now we just handle scanning the unparseable descriptor dumps, but hang anything else we might need to do in the future here as well.
Definition at line 1246 of file routerparse.c.