diff options
Diffstat (limited to 'conf')
-rw-r--r-- | conf/conf.h | 1 | ||||
-rw-r--r-- | conf/confbase.Y | 23 |
2 files changed, 19 insertions, 5 deletions
diff --git a/conf/conf.h b/conf/conf.h index 5abca7da..dbc747d6 100644 --- a/conf/conf.h +++ b/conf/conf.h @@ -86,6 +86,7 @@ struct symbol { #define SYM_FUNCTION 3 #define SYM_FILTER 4 #define SYM_TABLE 5 +#define SYM_IPA 6 #define SYM_VARIABLE 0x100 /* 0x100-0x1ff are variable types */ diff --git a/conf/confbase.Y b/conf/confbase.Y index 4626d440..588f5826 100644 --- a/conf/confbase.Y +++ b/conf/confbase.Y @@ -53,6 +53,7 @@ CF_DECLS %type <i> expr bool pxlen %type <time> datetime +%type <a> ipa %type <px> prefix prefix_or_ipa %nonassoc '=' '<' '>' '~' '.' GEQ LEQ NEQ @@ -96,6 +97,10 @@ definition: cf_define_symbol($2, SYM_NUMBER, NULL); $2->aux = $4; } + | DEFINE SYM '=' IPA ';' { + cf_define_symbol($2, SYM_IPA, cfg_alloc(sizeof(ip_addr))); + *(ip_addr *)$2->def = $4; + } ; /* Switches */ @@ -109,10 +114,18 @@ bool: | /* 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: - IPA pxlen { + ipa pxlen { if (!ip_is_prefix($1, $2)) cf_error("Invalid prefix"); $$.addr = $1; $$.len = $2; } @@ -120,15 +133,15 @@ prefix: prefix_or_ipa: prefix - | IPA { $$.addr = $1; $$.len = BITS_PER_IP_ADDRESS; } + | ipa { $$.addr = $1; $$.len = BITS_PER_IP_ADDRESS; } ; pxlen: - '/' NUM { + '/' expr { if ($2 < 0 || $2 > BITS_PER_IP_ADDRESS) cf_error("Invalid prefix length %d", $2); $$ = $2; } - | ':' IPA { + | ':' ipa { $$ = ipa_mklen($2); if ($$ < 0) cf_error("Invalid netmask %I", $2); } |