12 #define ROUTERDESC_TOKEN_TABLE_PRIVATE
67 if ((*s ==
'*' || *s ==
'[' || TOR_ISDIGIT(*s)) && assume_action >= 0) {
69 assume_action == ADDR_POLICY_ACCEPT?
"accept":
"reject", s)<0) {
79 eos = cp + strlen(cp);
82 if (tok->
tp == ERR_) {
83 log_warn(
LD_DIR,
"Error reading address policy: %s", tok->
error);
86 if (tok->
tp != K_ACCEPT && tok->
tp != K_ACCEPT6 &&
87 tok->
tp != K_REJECT && tok->
tp != K_REJECT6) {
88 log_warn(
LD_DIR,
"Expected 'accept' or 'reject'.");
104 if ((tok->
tp == K_ACCEPT6 || tok->
tp == K_REJECT6) &&
108 log_warn(
LD_DIR,
"IPv4 address '%s' with accept6/reject6 field type in "
109 "exit policy. Ignoring, but continuing to parse rules. (Use "
110 "accept/reject with IPv4 addresses.)",
124 DUMP_AREA(area,
"policy item");
142 tok->
tp == K_ACCEPT || tok->
tp == K_ACCEPT6);
151 memset(&newe, 0,
sizeof(newe));
153 if (tok->
tp == K_REJECT || tok->
tp == K_REJECT6)
160 if ((fmt_flags & TAPMP_EXTENDED_STAR)
161 && (tok->
tp == K_ACCEPT6 || tok->
tp == K_REJECT6)) {
162 fmt_flags |= TAPMP_STAR_IPV6_ONLY;
167 log_warn(
LD_DIR,
"Couldn't parse line %s. Dropping",
escaped(arg));
192 uint16_t port_min, port_max;
199 arg += strlen(
"private");
201 if (!arg || *arg !=
':')
207 memset(&result, 0,
sizeof(result));
208 if (tok->
tp == K_REJECT || tok->
tp == K_REJECT6)
216 if (tok->
tp == K_ACCEPT6 || tok->
tp == K_REJECT6) {
218 "'%s' expands into rules which apply to all private IPv4 and "
219 "IPv6 addresses. (Use accept/reject private:* for IPv4 and "
220 "IPv6.)", tok->
n_args == 1 ? tok->
args[0] :
"");
Address policy structures.
int tor_addr_parse_mask_ports(const char *s, unsigned flags, tor_addr_t *addr_out, maskbits_t *maskbits_out, uint16_t *port_min_out, uint16_t *port_max_out)
int parse_port_range(const char *port, uint16_t *port_min_out, uint16_t *port_max_out)
static sa_family_t tor_addr_family(const tor_addr_t *a)
const char * escaped(const char *s)
memarea_t * memarea_new(void)
#define memarea_drop_all(area)
Master header file for Tor-specific functionality.
void token_clear(directory_token_t *tok)
directory_token_t * get_next_token(memarea_t *area, const char **s, const char *eos, const token_rule_t *table)
Header file for parsecommon.c.
addr_policy_t * addr_policy_get_canonical_entry(addr_policy_t *e)
Header file for policies.c.
addr_policy_t * router_parse_addr_policy(directory_token_t *tok, unsigned fmt_flags)
static addr_policy_t * router_parse_addr_policy_private(directory_token_t *tok)
addr_policy_t * router_parse_addr_policy_item_from_string(const char *s, int assume_action, int *malformed_list)
Header file for policy_parse.c.
int tor_snprintf(char *str, size_t size, const char *format,...)
const token_rule_t routerdesc_token_table[]
Header file for routerparse.c.
addr_policy_action_bitfield_t policy_type
#define MOCK_IMPL(rv, funcname, arglist)
Header file for unparseable.c.
void tor_strlower(char *s)
int strcmpstart(const char *s1, const char *s2)
const char * eat_whitespace(const char *s)