Use net_addr pointer for net_addr_roaX

net_addr_roa6 is bigger than net_addr

Thanks to Ondrej Zajicek for notice
This commit is contained in:
Pavel Tvrdík 2016-01-21 10:24:50 +01:00
parent 259052199b
commit a4caa1c0a3

View file

@ -78,8 +78,8 @@ CF_DECLS
%type <i32> expr_us %type <i32> expr_us
%type <time> datetime %type <time> datetime
%type <a> ipa %type <a> ipa
%type <net> net_ip4_ net_ip6_ net_ip6 net_ip_ net_ip net_or_ipa net_roa4_ net_roa6_ net_roa_ net__ %type <net> net_ip4_ net_ip6_ net_ip6 net_ip_ net_ip net_or_ipa
%type <net_ptr> net_ net_any %type <net_ptr> net_ net_any net_roa4_ net_roa6_ net_roa_
%type <t> text opttext %type <t> text opttext
@ -198,14 +198,16 @@ net_ip6_: IP6 '/' NUM
net_roa4_: net_ip4_ MAX NUM AS NUM net_roa4_: net_ip4_ MAX NUM AS NUM
{ {
net_fill_roa4(&($$), ((net_addr_ip4 *)&$1)->prefix, $1.pxlen, $3, $5); $$ = cfg_alloc(sizeof(net_addr_roa4));
net_fill_roa4($$, ((net_addr_ip4 *)&$1)->prefix, $1.pxlen, $3, $5);
if ($3 < 0 || $3 > IP4_MAX_PREFIX_LENGTH) if ($3 < 0 || $3 > IP4_MAX_PREFIX_LENGTH)
cf_error("Invalid max prefix length %d", $3); cf_error("Invalid max prefix length %d", $3);
}; };
net_roa6_: net_ip6_ MAX NUM AS NUM net_roa6_: net_ip6_ MAX NUM AS NUM
{ {
net_fill_roa6(&($$), ((net_addr_ip6 *)&$1)->prefix, $1.pxlen, $3, $5); $$ = cfg_alloc(sizeof(net_addr_roa6));
net_fill_roa6($$, ((net_addr_ip6 *)&$1)->prefix, $1.pxlen, $3, $5);
if ($3 < 0 || $3 > IP6_MAX_PREFIX_LENGTH) if ($3 < 0 || $3 > IP6_MAX_PREFIX_LENGTH)
cf_error("Invalid max prefix length %d", $3); cf_error("Invalid max prefix length %d", $3);
}; };
@ -213,9 +215,10 @@ net_roa6_: net_ip6_ MAX NUM AS NUM
net_ip_: net_ip4_ | net_ip6_ ; net_ip_: net_ip4_ | net_ip6_ ;
net_roa_: net_roa4_ | net_roa6_ ; net_roa_: net_roa4_ | net_roa6_ ;
net__: net_ip_ | net_roa_; net_:
net_ip_ { $$ = cfg_alloc($1.length); net_copy($$, &($1)); }
net_: net__ { $$ = cfg_alloc($1.length); net_copy($$, &($1)); } ; | net_roa_
;
/* Networks - regular */ /* Networks - regular */