Cleanup of configuration.
o Use `expr' instead of `NUM' and `ipa' instead of `IPA', so that defined symbols work everywhere. o `define' now accepts both numbers and IP addresses. o Renamed `ipa' in filters to `fipa'. Pavel, please update filters to accept define'd symbols as well.
This commit is contained in:
parent
3b1c523d79
commit
e3f2d5fce3
7 changed files with 39 additions and 26 deletions
1
TODO
1
TODO
|
@ -38,7 +38,6 @@ Globals
|
||||||
- check incoming packets and log errors!!
|
- check incoming packets and log errors!!
|
||||||
- check log calls for trailing newlines and log levels followed by comma
|
- check log calls for trailing newlines and log levels followed by comma
|
||||||
- check if all protocols set proper packet priorities and TTL's.
|
- check if all protocols set proper packet priorities and TTL's.
|
||||||
- replace all NUM, IPA and expr tokens by constant filter expressions
|
|
||||||
- try compiling with -Wunused
|
- try compiling with -Wunused
|
||||||
- does everybody test return value of sk_open?
|
- does everybody test return value of sk_open?
|
||||||
- doc: references to RFC's we did follow
|
- doc: references to RFC's we did follow
|
||||||
|
|
|
@ -86,6 +86,7 @@ struct symbol {
|
||||||
#define SYM_FUNCTION 3
|
#define SYM_FUNCTION 3
|
||||||
#define SYM_FILTER 4
|
#define SYM_FILTER 4
|
||||||
#define SYM_TABLE 5
|
#define SYM_TABLE 5
|
||||||
|
#define SYM_IPA 6
|
||||||
|
|
||||||
#define SYM_VARIABLE 0x100 /* 0x100-0x1ff are variable types */
|
#define SYM_VARIABLE 0x100 /* 0x100-0x1ff are variable types */
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,7 @@ CF_DECLS
|
||||||
|
|
||||||
%type <i> expr bool pxlen
|
%type <i> expr bool pxlen
|
||||||
%type <time> datetime
|
%type <time> datetime
|
||||||
|
%type <a> ipa
|
||||||
%type <px> prefix prefix_or_ipa
|
%type <px> prefix prefix_or_ipa
|
||||||
|
|
||||||
%nonassoc '=' '<' '>' '~' '.' GEQ LEQ NEQ
|
%nonassoc '=' '<' '>' '~' '.' GEQ LEQ NEQ
|
||||||
|
@ -96,6 +97,10 @@ definition:
|
||||||
cf_define_symbol($2, SYM_NUMBER, NULL);
|
cf_define_symbol($2, SYM_NUMBER, NULL);
|
||||||
$2->aux = $4;
|
$2->aux = $4;
|
||||||
}
|
}
|
||||||
|
| DEFINE SYM '=' IPA ';' {
|
||||||
|
cf_define_symbol($2, SYM_IPA, cfg_alloc(sizeof(ip_addr)));
|
||||||
|
*(ip_addr *)$2->def = $4;
|
||||||
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
/* Switches */
|
/* Switches */
|
||||||
|
@ -109,10 +114,18 @@ bool:
|
||||||
| /* Silence means agreement */ { $$ = 1; }
|
| /* Silence means agreement */ { $$ = 1; }
|
||||||
;
|
;
|
||||||
|
|
||||||
/* Prefixes and netmasks */
|
/* Addresses, prefixes and netmasks */
|
||||||
|
|
||||||
|
ipa:
|
||||||
|
IPA
|
||||||
|
| SYM {
|
||||||
|
if ($1->class != SYM_IPA) cf_error("IP address expected");
|
||||||
|
$$ = *(ip_addr *)$1->def;
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
prefix:
|
prefix:
|
||||||
IPA pxlen {
|
ipa pxlen {
|
||||||
if (!ip_is_prefix($1, $2)) cf_error("Invalid prefix");
|
if (!ip_is_prefix($1, $2)) cf_error("Invalid prefix");
|
||||||
$$.addr = $1; $$.len = $2;
|
$$.addr = $1; $$.len = $2;
|
||||||
}
|
}
|
||||||
|
@ -120,15 +133,15 @@ prefix:
|
||||||
|
|
||||||
prefix_or_ipa:
|
prefix_or_ipa:
|
||||||
prefix
|
prefix
|
||||||
| IPA { $$.addr = $1; $$.len = BITS_PER_IP_ADDRESS; }
|
| ipa { $$.addr = $1; $$.len = BITS_PER_IP_ADDRESS; }
|
||||||
;
|
;
|
||||||
|
|
||||||
pxlen:
|
pxlen:
|
||||||
'/' NUM {
|
'/' expr {
|
||||||
if ($2 < 0 || $2 > BITS_PER_IP_ADDRESS) cf_error("Invalid prefix length %d", $2);
|
if ($2 < 0 || $2 > BITS_PER_IP_ADDRESS) cf_error("Invalid prefix length %d", $2);
|
||||||
$$ = $2;
|
$$ = $2;
|
||||||
}
|
}
|
||||||
| ':' IPA {
|
| ':' ipa {
|
||||||
$$ = ipa_mklen($2);
|
$$ = ipa_mklen($2);
|
||||||
if ($$ < 0) cf_error("Invalid netmask %I", $2);
|
if ($$ < 0) cf_error("Invalid netmask %I", $2);
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ CF_KEYWORDS(FUNCTION, PRINT, PRINTN, UNSET, RETURN,
|
||||||
%type <f> filter filter_body where_filter
|
%type <f> filter filter_body where_filter
|
||||||
%type <i> type break_command pair
|
%type <i> type break_command pair
|
||||||
%type <e> set_item set_items switch_body
|
%type <e> set_item set_items switch_body
|
||||||
%type <v> set_atom fprefix fprefix_s ipa
|
%type <v> set_atom fprefix fprefix_s fipa
|
||||||
%type <s> decls declsn one_decl function_params
|
%type <s> decls declsn one_decl function_params
|
||||||
%type <h> bgp_path
|
%type <h> bgp_path
|
||||||
%type <i> bgp_one
|
%type <i> bgp_one
|
||||||
|
@ -224,14 +224,14 @@ fprefix:
|
||||||
| fprefix_s '{' NUM ',' NUM '}' { $$ = $1; $$.val.px.len |= LEN_RANGE | ($3 << 16) | ($5 << 8); }
|
| fprefix_s '{' NUM ',' NUM '}' { $$ = $1; $$.val.px.len |= LEN_RANGE | ($3 << 16) | ($5 << 8); }
|
||||||
;
|
;
|
||||||
|
|
||||||
ipa:
|
fipa:
|
||||||
IPA { $$.type = T_IP; $$.val.px.ip = $1; }
|
IPA { $$.type = T_IP; $$.val.px.ip = $1; }
|
||||||
;
|
;
|
||||||
|
|
||||||
set_atom:
|
set_atom:
|
||||||
NUM { $$.type = T_INT; $$.val.i = $1; }
|
NUM { $$.type = T_INT; $$.val.i = $1; }
|
||||||
| pair { $$.type = T_PAIR; $$.val.i = $1; }
|
| pair { $$.type = T_PAIR; $$.val.i = $1; }
|
||||||
| ipa { $$ = $1; }
|
| fipa { $$ = $1; }
|
||||||
| fprefix { $$ = $1; }
|
| fprefix { $$ = $1; }
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -291,7 +291,7 @@ constant:
|
||||||
| FALSE { $$ = f_new_inst(); $$->code = 'c'; $$->aux = T_BOOL; $$->a2.i = 0; }
|
| FALSE { $$ = f_new_inst(); $$->code = 'c'; $$->aux = T_BOOL; $$->a2.i = 0; }
|
||||||
| TEXT { $$ = f_new_inst(); $$->code = 'c'; $$->aux = T_STRING; $$->a2.p = $1; }
|
| TEXT { $$ = f_new_inst(); $$->code = 'c'; $$->aux = T_STRING; $$->a2.p = $1; }
|
||||||
| pair { $$ = f_new_inst(); $$->code = 'c'; $$->aux = T_PAIR; $$->a2.i = $1; }
|
| pair { $$ = f_new_inst(); $$->code = 'c'; $$->aux = T_PAIR; $$->a2.i = $1; }
|
||||||
| ipa { NEW_F_VAL; $$ = f_new_inst(); $$->code = 'C'; $$->a1.p = val; *val = $1; }
|
| fipa { NEW_F_VAL; $$ = f_new_inst(); $$->code = 'C'; $$->a1.p = val; *val = $1; }
|
||||||
| fprefix_s {NEW_F_VAL; $$ = f_new_inst(); $$->code = 'C'; $$->a1.p = val; *val = $1; }
|
| fprefix_s {NEW_F_VAL; $$ = f_new_inst(); $$->code = 'C'; $$->a1.p = val; *val = $1; }
|
||||||
| '[' set_items ']' { DBG( "We've got a set here..." ); $$ = f_new_inst(); $$->code = 'c'; $$->aux = T_SET; $$->a2.p = build_tree($2); DBG( "ook\n" ); }
|
| '[' set_items ']' { DBG( "We've got a set here..." ); $$ = f_new_inst(); $$->code = 'c'; $$->aux = T_SET; $$->a2.p = build_tree($2); DBG( "ook\n" ); }
|
||||||
| ENUM { $$ = f_new_inst(); $$->code = 'c'; $$->aux = $1 >> 16; $$->a2.i = $1 & 0xffff; }
|
| ENUM { $$ = f_new_inst(); $$->code = 'c'; $$->aux = $1 >> 16; $$->a2.i = $1 & 0xffff; }
|
||||||
|
|
|
@ -205,7 +205,7 @@ password_items:
|
||||||
| FROM datetime password_items { last_password_item->from = $2; }
|
| FROM datetime password_items { last_password_item->from = $2; }
|
||||||
| TO datetime password_items { last_password_item->to = $2; }
|
| TO datetime password_items { last_password_item->to = $2; }
|
||||||
| PASSIVE datetime password_items { last_password_item->passive = $2; }
|
| PASSIVE datetime password_items { last_password_item->passive = $2; }
|
||||||
| ID NUM password_items { last_password_item->id = $2; }
|
| ID expr password_items { last_password_item->id = $2; }
|
||||||
;
|
;
|
||||||
|
|
||||||
password_list:
|
password_list:
|
||||||
|
|
|
@ -44,28 +44,28 @@ bgp_proto_start: proto_start BGP {
|
||||||
bgp_proto:
|
bgp_proto:
|
||||||
bgp_proto_start proto_name '{'
|
bgp_proto_start proto_name '{'
|
||||||
| bgp_proto proto_item ';'
|
| bgp_proto proto_item ';'
|
||||||
| bgp_proto LOCAL AS NUM ';' {
|
| bgp_proto LOCAL AS expr ';' {
|
||||||
if ($4 < 0 || $4 > 65535) cf_error("AS number out of range");
|
if ($4 < 0 || $4 > 65535) cf_error("AS number out of range");
|
||||||
BGP_CFG->local_as = $4;
|
BGP_CFG->local_as = $4;
|
||||||
}
|
}
|
||||||
| bgp_proto NEIGHBOR IPA AS NUM ';' {
|
| bgp_proto NEIGHBOR ipa AS expr ';' {
|
||||||
if ($5 < 0 || $5 > 65535) cf_error("AS number out of range");
|
if ($5 < 0 || $5 > 65535) cf_error("AS number out of range");
|
||||||
BGP_CFG->remote_ip = $3;
|
BGP_CFG->remote_ip = $3;
|
||||||
BGP_CFG->remote_as = $5;
|
BGP_CFG->remote_as = $5;
|
||||||
}
|
}
|
||||||
| bgp_proto HOLD TIME NUM ';' { BGP_CFG->hold_time = $4; }
|
| bgp_proto HOLD TIME expr ';' { BGP_CFG->hold_time = $4; }
|
||||||
| bgp_proto STARTUP HOLD TIME NUM ';' { BGP_CFG->initial_hold_time = $5; }
|
| bgp_proto STARTUP HOLD TIME expr ';' { BGP_CFG->initial_hold_time = $5; }
|
||||||
| bgp_proto CONNECT RETRY TIME NUM ';' { BGP_CFG->connect_retry_time = $5; }
|
| bgp_proto CONNECT RETRY TIME expr ';' { BGP_CFG->connect_retry_time = $5; }
|
||||||
| bgp_proto KEEPALIVE TIME NUM ';' { BGP_CFG->keepalive_time = $4; }
|
| bgp_proto KEEPALIVE TIME expr ';' { BGP_CFG->keepalive_time = $4; }
|
||||||
| bgp_proto MULTIHOP NUM VIA IPA ';' { BGP_CFG->multihop = $3; BGP_CFG->multihop_via = $5; }
|
| bgp_proto MULTIHOP expr VIA ipa ';' { BGP_CFG->multihop = $3; BGP_CFG->multihop_via = $5; }
|
||||||
| bgp_proto NEXT HOP SELF ';' { BGP_CFG->next_hop_self = 1; }
|
| bgp_proto NEXT HOP SELF ';' { BGP_CFG->next_hop_self = 1; }
|
||||||
| bgp_proto PATH METRIC NUM ';' { BGP_CFG->compare_path_lengths = $4; }
|
| bgp_proto PATH METRIC expr ';' { BGP_CFG->compare_path_lengths = $4; }
|
||||||
| bgp_proto DEFAULT BGP_MED NUM ';' { BGP_CFG->default_med = $4; }
|
| bgp_proto DEFAULT BGP_MED expr ';' { BGP_CFG->default_med = $4; }
|
||||||
| bgp_proto DEFAULT BGP_LOCAL_PREF NUM ';' { BGP_CFG->default_local_pref = $4; }
|
| bgp_proto DEFAULT BGP_LOCAL_PREF expr ';' { BGP_CFG->default_local_pref = $4; }
|
||||||
| bgp_proto SOURCE ADDRESS IPA ';' { BGP_CFG->source_addr = $4; }
|
| bgp_proto SOURCE ADDRESS ipa ';' { BGP_CFG->source_addr = $4; }
|
||||||
| bgp_proto START DELAY TIME NUM ';' { BGP_CFG->start_delay_time = $5; }
|
| bgp_proto START DELAY TIME expr ';' { BGP_CFG->start_delay_time = $5; }
|
||||||
| bgp_proto ERROR FORGET TIME NUM ';' { BGP_CFG->error_amnesia_time = $5; }
|
| bgp_proto ERROR FORGET TIME expr ';' { BGP_CFG->error_amnesia_time = $5; }
|
||||||
| bgp_proto ERROR WAIT TIME NUM ',' NUM ';' { BGP_CFG->error_delay_time_min = $5; BGP_CFG->error_delay_time_max = $7; }
|
| bgp_proto ERROR WAIT TIME expr ',' expr ';' { BGP_CFG->error_delay_time_min = $5; BGP_CFG->error_delay_time_max = $7; }
|
||||||
| bgp_proto DISABLE AFTER ERROR ';' { BGP_CFG->disable_after_error = 1; }
|
| bgp_proto DISABLE AFTER ERROR ';' { BGP_CFG->disable_after_error = 1; }
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ stat_route0: ROUTE prefix {
|
||||||
;
|
;
|
||||||
|
|
||||||
stat_route:
|
stat_route:
|
||||||
stat_route0 VIA IPA {
|
stat_route0 VIA ipa {
|
||||||
this_srt->dest = RTD_ROUTER;
|
this_srt->dest = RTD_ROUTER;
|
||||||
this_srt->via = $3;
|
this_srt->via = $3;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue