Tor 0.4.9.0-alpha-dev
Macros | Functions
policy_parse.c File Reference

Code to parse address policies. More...

#include "core/or/or.h"
#include "core/or/policies.h"
#include "feature/dirparse/parsecommon.h"
#include "feature/dirparse/policy_parse.h"
#include "feature/dirparse/routerparse.h"
#include "feature/dirparse/unparseable.h"
#include "lib/memarea/memarea.h"
#include "core/or/addr_policy_st.h"

Go to the source code of this file.

Functions

static addr_policy_trouter_parse_addr_policy_private (directory_token_t *tok)
 
addr_policy_trouter_parse_addr_policy_item_from_string (const char *s, int assume_action, int *malformed_list)
 
addr_policy_trouter_parse_addr_policy (directory_token_t *tok, unsigned fmt_flags)
 

Detailed Description

Code to parse address policies.

Definition in file policy_parse.c.

Macro Definition Documentation

◆ ROUTERDESC_TOKEN_TABLE_PRIVATE

#define ROUTERDESC_TOKEN_TABLE_PRIVATE

Definition at line 12 of file policy_parse.c.

Function Documentation

◆ router_parse_addr_policy()

addr_policy_t * router_parse_addr_policy ( directory_token_t tok,
unsigned  fmt_flags 
)

Given a K_ACCEPT[6] or K_REJECT[6] token and a router, create and return a new exit_policy_t corresponding to the token. If TAPMP_EXTENDED_STAR is set in fmt_flags, K_ACCEPT6 and K_REJECT6 tokens followed by * expand to IPv6-only policies, otherwise they expand to IPv4 and IPv6 policies

Definition at line 136 of file policy_parse.c.

Referenced by router_add_exit_policy().

◆ router_parse_addr_policy_item_from_string()

addr_policy_t * router_parse_addr_policy_item_from_string ( const char *  s,
int  assume_action,
int *  malformed_list 
)

Parse the addr policy in the string s and return it. If assume_action is nonnegative, then insert its action (ADDR_POLICY_ACCEPT or ADDR_POLICY_REJECT) for items that specify no action.

Returns NULL on policy errors.

Set *malformed_list to true if the entire policy list should be discarded. Otherwise, set it to false, and only this item should be ignored on error - the rest of the policy list can continue to be processed and used.

The addr_policy_t returned by this function can have its address set to AF_UNSPEC for '*'. Use policy_expand_unspec() to turn this into a pair of AF_INET and AF_INET6 items.

Definition at line 44 of file policy_parse.c.

◆ router_parse_addr_policy_private()

static addr_policy_t * router_parse_addr_policy_private ( directory_token_t tok)
static

Parse an exit policy line of the format "accept[6]/reject[6] private:...". This didn't exist until Tor 0.1.1.15, so nobody should generate it in router descriptors until earlier versions are obsolete.

accept/reject and accept6/reject6 private all produce rules for both IPv4 and IPv6 addresses.

Definition at line 189 of file policy_parse.c.