Tor
0.4.7.0-alpha-dev
|
Code to parse and validate microdescriptors. More...
#include "core/or/or.h"
#include "app/config/config.h"
#include "core/or/policies.h"
#include "feature/dirparse/microdesc_parse.h"
#include "feature/dirparse/parsecommon.h"
#include "feature/dirparse/routerparse.h"
#include "feature/nodelist/microdesc.h"
#include "feature/nodelist/nickname.h"
#include "feature/nodelist/nodefamily.h"
#include "feature/relay/router.h"
#include "lib/crypt_ops/crypto_curve25519.h"
#include "lib/crypt_ops/crypto_ed25519.h"
#include "lib/crypt_ops/crypto_format.h"
#include "lib/memarea/memarea.h"
#include "feature/nodelist/microdesc_st.h"
Go to the source code of this file.
Macros | |
#define | CHECK_LENGTH() |
#define | NEXT_LINE() |
Functions | |
static const char * | find_start_of_next_microdesc (const char *s, const char *eos) |
static int | policy_is_reject_star_or_null (struct short_policy_t *policy) |
static const char * | saved_location_to_string (saved_location_t where) |
static int | microdesc_extract_body (microdesc_t *md, const char *start, const char *s, const char *start_of_next_microdesc, saved_location_t where) |
static int | microdesc_parse_fields (microdesc_t *md, memarea_t *area, const char *s, const char *start_of_next_microdesc, int allow_annotations, saved_location_t where) |
smartlist_t * | microdescs_parse_from_string (const char *s, const char *eos, int allow_annotations, saved_location_t where, smartlist_t *invalid_digests_out) |
Variables | |
static token_rule_t | microdesc_token_table [] |
Code to parse and validate microdescriptors.
Definition in file microdesc_parse.c.
#define CHECK_LENGTH | ( | ) |
#define NEXT_LINE | ( | ) |
|
static |
Assuming that s starts with a microdesc, return the start of the NEXT one. Return NULL on "not found."
Definition at line 48 of file microdesc_parse.c.
Referenced by microdescs_parse_from_string().
|
static |
Given a microdescriptor stored in where which starts at s, which ends at start_of_next_microdescriptor, and which is located within a larger document beginning at start: Fill in the body, bodylen, bodylen, saved_location, off, and digest fields of md as appropriate.
The body field will be an alias within s if saved_location is SAVED_IN_CACHE, and will be copied into body and nul-terminated otherwise.
Definition at line 140 of file microdesc_parse.c.
|
static |
Parse a microdescriptor which begins at s and ends at start_of_next_microdesc. Store its fields into md. Use where for generating log information. If allow_annotations is true, then one or more annotations may precede the microdescriptor body proper. Use area for memory management, clearing it when done.
On success, return 0; otherwise return -1.
Definition at line 177 of file microdesc_parse.c.
smartlist_t* microdescs_parse_from_string | ( | const char * | s, |
const char * | eos, | ||
int | allow_annotations, | ||
saved_location_t | where, | ||
smartlist_t * | invalid_digests_out | ||
) |
Parse as many microdescriptors as are found from the string starting at s and ending at eos. If allow_annotations is set, read any annotations we recognize and ignore ones we don't.
If saved_location isn't SAVED_IN_CACHE, make a local copy of each descriptor in the body field of each microdesc_t.
Return all newly parsed microdescriptors in a newly allocated smartlist_t. If invalid_disgests_out is provided, add a SHA256 microdesc digest to it for every microdesc that we found to be badly formed. (This may cause duplicates)
Definition at line 293 of file microdesc_parse.c.
Referenced by microdescs_add_to_cache().
|
static |
Return a human-readable description of a given saved_location_t. Never returns NULL.
Definition at line 108 of file microdesc_parse.c.
|
static |
List of tokens recognized in microdescriptors
Definition at line 32 of file microdesc_parse.c.