diff options
author | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2019-11-03 20:26:54 +0100 |
---|---|---|
committer | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2019-11-03 22:25:44 +0100 |
commit | 0edf0c8cd919a8b3fbf5bc036f27ea0b4ed0b91a (patch) | |
tree | 07ae1b48e392992e58ad0f1a230ea180739a29b3 | |
parent | 08c4c9a30b7ed61be39ddc71aebd69a0fea6a55a (diff) |
Support for address family constants
We already had them defined on BGP level, but they are more general.
-rw-r--r-- | bird-gdb.py | 1 | ||||
-rw-r--r-- | conf/gen_keywords.m4 | 6 | ||||
-rw-r--r-- | conf/gen_parser.m4 | 1 | ||||
-rw-r--r-- | filter/data.h | 1 | ||||
-rw-r--r-- | lib/ip.h | 7 | ||||
-rw-r--r-- | nest/config.Y | 1 |
6 files changed, 15 insertions, 2 deletions
diff --git a/bird-gdb.py b/bird-gdb.py index a85ef8c6..3cf65a9c 100644 --- a/bird-gdb.py +++ b/bird-gdb.py @@ -30,6 +30,7 @@ class BIRDFValPrinter(BIRDPrinter): "T_ENUM_ROA": "i", "T_ENUM_NETTYPE": "i", "T_ENUM_RA_PREFERENCE": "i", + "T_ENUM_AF": "i", "T_IP": "ip", "T_NET": "net", "T_STRING": "s", diff --git a/conf/gen_keywords.m4 b/conf/gen_keywords.m4 index cf3fb58e..0c1dc545 100644 --- a/conf/gen_keywords.m4 +++ b/conf/gen_keywords.m4 @@ -34,9 +34,11 @@ m4_define(CF_CLI, `CF_KEYWORDS(m4_translit($1, [[ ]], [[,]])) ') # Enums are translated to C initializers: use CF_ENUM(typename, prefix, values) -m4_define(CF_enum, `m4_divert(1){ "CF_enum_prefix[[]]$1", -((CF_enum_type<<16) | CF_enum_prefix[[]]$1), NULL }, +# For different prefix: CF_ENUM_PX(typename, external prefix, C prefix, values) +m4_define(CF_enum, `m4_divert(1){ "CF_enum_prefix_ext[[]]$1", -((CF_enum_type<<16) | CF_enum_prefix_int[[]]$1), NULL }, m4_divert(-1)') -m4_define(CF_ENUM, `m4_define([[CF_enum_type]],$1)m4_define([[CF_enum_prefix]],$2)CF_iterate([[CF_enum]], [[m4_shift(m4_shift($@))]])DNL') +m4_define(CF_ENUM, `m4_define([[CF_enum_type]],$1)m4_define([[CF_enum_prefix_ext]],$2)m4_define([[CF_enum_prefix_int]],$2)CF_iterate([[CF_enum]], [[m4_shift(m4_shift($@))]])DNL') +m4_define(CF_ENUM_PX, `m4_define([[CF_enum_type]],$1)m4_define([[CF_enum_prefix_ext]],$2)m4_define([[CF_enum_prefix_int]],$3)CF_iterate([[CF_enum]], [[m4_shift(m4_shift(m4_shift($@)))]])DNL') # After all configuration templates end, we generate the m4_m4wrap(` diff --git a/conf/gen_parser.m4 b/conf/gen_parser.m4 index af43d96f..5b378a93 100644 --- a/conf/gen_parser.m4 +++ b/conf/gen_parser.m4 @@ -44,6 +44,7 @@ m4_define(CF_CLI_HELP, `') # ENUM declarations are ignored m4_define(CF_ENUM, `') +m4_define(CF_ENUM_PX, `') # After all configuration templates end, we finally generate the grammar file. m4_m4wrap(` diff --git a/filter/data.h b/filter/data.h index 083595f4..db6b6e12 100644 --- a/filter/data.h +++ b/filter/data.h @@ -38,6 +38,7 @@ enum f_type { T_ENUM_ROA = 0x35, T_ENUM_NETTYPE = 0x36, T_ENUM_RA_PREFERENCE = 0x37, + T_ENUM_AF = 0x38, /* new enums go here */ T_ENUM_EMPTY = 0x3f, /* Special hack for atomic_aggr */ @@ -48,6 +48,13 @@ #define UDP_HEADER_LENGTH 8 +/* IANA Address Family Numbers */ +/* https://www.iana.org/assignments/address-family-numbers/address-family-numbers.xhtml */ +/* Would use AF_ prefix, but that collides with POSIX address family numbers */ +#define AFI_IPV4 1 +#define AFI_IPV6 2 + + #ifdef DEBUGGING typedef struct ip4_addr { diff --git a/nest/config.Y b/nest/config.Y index 1bc203dd..8fe060c5 100644 --- a/nest/config.Y +++ b/nest/config.Y @@ -85,6 +85,7 @@ CF_ENUM(T_ENUM_RTS, RTS_, DUMMY, STATIC, INHERIT, DEVICE, STATIC_DEVICE, REDIREC CF_ENUM(T_ENUM_SCOPE, SCOPE_, HOST, LINK, SITE, ORGANIZATION, UNIVERSE, UNDEFINED) CF_ENUM(T_ENUM_RTD, RTD_, UNICAST, BLACKHOLE, UNREACHABLE, PROHIBIT) CF_ENUM(T_ENUM_ROA, ROA_, UNKNOWN, VALID, INVALID) +CF_ENUM_PX(T_ENUM_AF, AF_, AFI_, IPV4, IPV6) %type <i32> idval %type <f> imexport |