tor  0.4.0.0-alpha-dev
Macros | Functions | Variables
microdesc_parse.c File Reference
#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)
 
smartlist_tmicrodescs_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 []
 

Detailed Description

Code to parse and validate microdescriptors.

Definition in file microdesc_parse.c.

Macro Definition Documentation

◆ CHECK_LENGTH

#define CHECK_LENGTH ( )
Value:
STMT_BEGIN \
if (eos - s < 32) \
return NULL; \
STMT_END

◆ NEXT_LINE

#define NEXT_LINE ( )
Value:
STMT_BEGIN \
s = memchr(s, '\n', eos-s); \
if (!s || eos - s <= 1) \
return NULL; \
s++; \
STMT_END

Function Documentation

◆ find_start_of_next_microdesc()

static const char* find_start_of_next_microdesc ( const char *  s,
const char *  eos 
)
static

Assuming that s starts with a microdesc, return the start of the NEXT one. Return NULL on "not found."

Definition at line 46 of file microdesc_parse.c.

References eat_whitespace_eos().

◆ microdescs_parse_from_string()

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 107 of file microdesc_parse.c.

Referenced by microdescs_add_to_cache().

Variable Documentation

◆ microdesc_token_table

token_rule_t microdesc_token_table[]
static
Initial value:
= {
T1_START("onion-key", K_ONION_KEY, NO_ARGS, NEED_KEY_1024),
T01("ntor-onion-key", K_ONION_KEY_NTOR, GE(1), NO_OBJ ),
T0N("id", K_ID, GE(2), NO_OBJ ),
T0N("a", K_A, GE(1), NO_OBJ ),
T01("family", K_FAMILY, CONCAT_ARGS, NO_OBJ ),
T01("p", K_P, CONCAT_ARGS, NO_OBJ ),
T01("p6", K_P6, CONCAT_ARGS, NO_OBJ ),
A01("@last-listed", A_LAST_LISTED, CONCAT_ARGS, NO_OBJ ),
}
#define END_OF_TABLE
Definition: parsecommon.h:244
#define T0N(s, t, a, o)
Definition: parsecommon.h:248
#define A01(s, t, a, o)
Definition: parsecommon.h:260
#define T1_START(s, t, a, o)
Definition: parsecommon.h:252
#define NO_ARGS
Definition: parsecommon.h:265
#define GE(n)
Definition: parsecommon.h:269
#define CONCAT_ARGS
Definition: parsecommon.h:267
#define T01(s, t, a, o)
Definition: parsecommon.h:258

List of tokens recognized in microdescriptors

Definition at line 31 of file microdesc_parse.c.