tor  0.4.2.0-alpha-dev
Macros | Functions
routerparse.h File Reference

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_trouter_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_textrainfo_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)
 

Detailed Description

Header file for routerparse.c.

Definition in file routerparse.h.

Function Documentation

◆ extrainfo_parse_entry_from_string()

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 961 of file routerparse.c.

◆ find_single_ipv6_orport()

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 336 of file routerparse.c.

References SMARTLIST_FOREACH_BEGIN, tor_addr_copy(), tor_addr_parse_mask_ports(), and tor_assert().

◆ router_get_extrainfo_hash()

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 186 of file routerparse.c.

References router_get_hash_impl().

◆ router_get_router_hash()

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 176 of file routerparse.c.

References router_get_hash_impl().

◆ router_parse_entry_from_string()

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 390 of file routerparse.c.

References memarea_new(), routerdesc_token_table, tokenize_string(), and tor_assert().

Referenced by router_load_single_router(), and routerlist_reparse_old().

◆ router_parse_list_from_string()

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 245 of file routerparse.c.

References DIGEST_LEN, find_start_of_next_router_or_extrainfo(), and tor_assert().

Referenced by router_load_extrainfo_from_string(), and router_load_routers_from_string().

◆ routerparse_free_all()

void routerparse_free_all ( void  )

Clean up all data structures used by routerparse.c at exit

Definition at line 1242 of file routerparse.c.

References dump_desc_fifo_cleanup().

◆ routerparse_init()

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 1228 of file routerparse.c.

References dump_desc_init(), and sandbox_is_active().