Skip to content

Commit

Permalink
Support for address family constants
Browse files Browse the repository at this point in the history
We already had them defined on BGP level, but they are more general.
  • Loading branch information
Ondrej Zajicek (work) committed Nov 3, 2019
1 parent 08c4c9a commit 0edf0c8
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions bird-gdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 4 additions & 2 deletions conf/gen_keywords.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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(`
Expand Down
1 change: 1 addition & 0 deletions conf/gen_parser.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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(`
Expand Down
1 change: 1 addition & 0 deletions filter/data.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
7 changes: 7 additions & 0 deletions lib/ip.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions nest/config.Y
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0edf0c8

Please sign in to comment.