diff options
Diffstat (limited to 'zebra')
-rw-r--r-- | zebra/afi_string.go | 17 | ||||
-rw-r--r-- | zebra/api_type_string.go | 7 | ||||
-rw-r--r-- | zebra/ptm_enable_string.go | 16 | ||||
-rw-r--r-- | zebra/ptm_status_string.go | 16 | ||||
-rw-r--r-- | zebra/route_type_string.go | 4 | ||||
-rw-r--r-- | zebra/zapi.go | 216 |
6 files changed, 246 insertions, 30 deletions
diff --git a/zebra/afi_string.go b/zebra/afi_string.go new file mode 100644 index 00000000..6c07a09d --- /dev/null +++ b/zebra/afi_string.go @@ -0,0 +1,17 @@ +// Code generated by "stringer -type=AFI"; DO NOT EDIT. + +package zebra + +import "fmt" + +const _AFI_name = "AFI_IPAFI_IP6AFI_ETHERAFI_MAX" + +var _AFI_index = [...]uint8{0, 6, 13, 22, 29} + +func (i AFI) String() string { + i -= 1 + if i >= AFI(len(_AFI_index)-1) { + return fmt.Sprintf("AFI(%d)", i+1) + } + return _AFI_name[_AFI_index[i]:_AFI_index[i+1]] +} diff --git a/zebra/api_type_string.go b/zebra/api_type_string.go index 26b35764..e97059b1 100644 --- a/zebra/api_type_string.go +++ b/zebra/api_type_string.go @@ -4,14 +4,13 @@ package zebra import "fmt" -const _API_TYPE_name = "INTERFACE_ADDINTERFACE_DELETEINTERFACE_ADDRESS_ADDINTERFACE_ADDRESS_DELETEINTERFACE_UPINTERFACE_DOWNIPV4_ROUTE_ADDIPV4_ROUTE_DELETEIPV6_ROUTE_ADDIPV6_ROUTE_DELETEREDISTRIBUTE_ADDREDISTRIBUTE_DELETEREDISTRIBUTE_DEFAULT_ADDREDISTRIBUTE_DEFAULT_DELETEIPV4_NEXTHOP_LOOKUPIPV6_NEXTHOP_LOOKUPIPV4_IMPORT_LOOKUPIPV6_IMPORT_LOOKUPINTERFACE_RENAMEROUTER_ID_ADDROUTER_ID_DELETEROUTER_ID_UPDATEHELLOIPV4_NEXTHOP_LOOKUP_MRIBVRF_UNREGISTERINTERFACE_LINK_PARAMSNEXTHOP_REGISTERNEXTHOP_UNREGISTERNEXTHOP_UPDATEMESSAGE_MAX" +const _API_TYPE_name = "FRR_INTERFACE_ADDINTERFACE_ADDINTERFACE_DELETEINTERFACE_ADDRESS_ADDINTERFACE_ADDRESS_DELETEINTERFACE_UPINTERFACE_DOWNIPV4_ROUTE_ADDIPV4_ROUTE_DELETEIPV6_ROUTE_ADDIPV6_ROUTE_DELETEREDISTRIBUTE_ADDREDISTRIBUTE_DELETEREDISTRIBUTE_DEFAULT_ADDREDISTRIBUTE_DEFAULT_DELETEIPV4_NEXTHOP_LOOKUPIPV6_NEXTHOP_LOOKUPIPV4_IMPORT_LOOKUPIPV6_IMPORT_LOOKUPINTERFACE_RENAMEROUTER_ID_ADDROUTER_ID_DELETEROUTER_ID_UPDATEHELLOIPV4_NEXTHOP_LOOKUP_MRIBVRF_UNREGISTERINTERFACE_LINK_PARAMSNEXTHOP_REGISTERNEXTHOP_UNREGISTERNEXTHOP_UPDATEMESSAGE_MAXFRR_BFD_DEST_REPLAYFRR_REDISTRIBUTE_IPV4_ADDFRR_REDISTRIBUTE_IPV4_DELFRR_REDISTRIBUTE_IPV6_ADDFRR_REDISTRIBUTE_IPV6_DELFRR_VRF_UNREGISTERFRR_VRF_ADDFRR_VRF_DELETEFRR_INTERFACE_VRF_UPDATEFRR_BFD_CLIENT_REGISTERFRR_INTERFACE_ENABLE_RADVFRR_INTERFACE_DISABLE_RADVFRR_IPV4_NEXTHOP_LOOKUP_MRIBFRR_INTERFACE_LINK_PARAMSFRR_MPLS_LABELS_ADDFRR_MPLS_LABELS_DELETEFRR_IPV4_NEXTHOP_ADDFRR_IPV4_NEXTHOP_DELETEFRR_IPV6_NEXTHOP_ADDFRR_IPV6_NEXTHOP_DELETEFRR_IPMR_ROUTE_STATSFRR_LABEL_MANAGER_CONNECTFRR_GET_LABEL_CHUNKFRR_RELEASE_LABEL_CHUNKFRR_PW_ADDFRR_PW_DELETEFRR_PW_SETFRR_PW_UNSETFRR_PW_STATUS_UPDATE" -var _API_TYPE_index = [...]uint16{0, 13, 29, 50, 74, 86, 100, 114, 131, 145, 162, 178, 197, 221, 248, 267, 286, 304, 322, 338, 351, 367, 383, 388, 412, 426, 447, 463, 481, 495, 506} +var _API_TYPE_index = [...]uint16{0, 17, 30, 46, 67, 91, 103, 117, 131, 148, 162, 179, 195, 214, 238, 265, 284, 303, 321, 339, 355, 368, 384, 400, 405, 429, 443, 464, 480, 498, 512, 523, 542, 567, 592, 617, 642, 660, 671, 685, 709, 732, 757, 783, 811, 836, 855, 877, 897, 920, 940, 963, 983, 1008, 1027, 1050, 1060, 1073, 1083, 1095, 1115} func (i API_TYPE) String() string { - i -= 1 if i >= API_TYPE(len(_API_TYPE_index)-1) { - return fmt.Sprintf("API_TYPE(%d)", i+1) + return fmt.Sprintf("API_TYPE(%d)", i) } return _API_TYPE_name[_API_TYPE_index[i]:_API_TYPE_index[i+1]] } diff --git a/zebra/ptm_enable_string.go b/zebra/ptm_enable_string.go new file mode 100644 index 00000000..d750542e --- /dev/null +++ b/zebra/ptm_enable_string.go @@ -0,0 +1,16 @@ +// Code generated by "stringer -type=PTM_ENABLE"; DO NOT EDIT. + +package zebra + +import "fmt" + +const _PTM_ENABLE_name = "PTM_ENABLE_OFFPTM_ENABLE_ONPTM_ENABLE_UNSPEC" + +var _PTM_ENABLE_index = [...]uint8{0, 14, 27, 44} + +func (i PTM_ENABLE) String() string { + if i >= PTM_ENABLE(len(_PTM_ENABLE_index)-1) { + return fmt.Sprintf("PTM_ENABLE(%d)", i) + } + return _PTM_ENABLE_name[_PTM_ENABLE_index[i]:_PTM_ENABLE_index[i+1]] +} diff --git a/zebra/ptm_status_string.go b/zebra/ptm_status_string.go new file mode 100644 index 00000000..464233b7 --- /dev/null +++ b/zebra/ptm_status_string.go @@ -0,0 +1,16 @@ +// Code generated by "stringer -type=PTM_STATUS"; DO NOT EDIT. + +package zebra + +import "fmt" + +const _PTM_STATUS_name = "PTM_STATUS_DOWNPTM_STATUS_UPPTM_STATUS_UNKNOWN" + +var _PTM_STATUS_index = [...]uint8{0, 15, 28, 46} + +func (i PTM_STATUS) String() string { + if i >= PTM_STATUS(len(_PTM_STATUS_index)-1) { + return fmt.Sprintf("PTM_STATUS(%d)", i) + } + return _PTM_STATUS_name[_PTM_STATUS_index[i]:_PTM_STATUS_index[i+1]] +} diff --git a/zebra/route_type_string.go b/zebra/route_type_string.go index aea80ae3..e2ad6c97 100644 --- a/zebra/route_type_string.go +++ b/zebra/route_type_string.go @@ -4,9 +4,9 @@ package zebra import "fmt" -const _ROUTE_TYPE_name = "ROUTE_SYSTEMROUTE_KERNELROUTE_CONNECTROUTE_STATICROUTE_RIPROUTE_RIPNGROUTE_OSPFROUTE_OSPF6ROUTE_ISISROUTE_BGPROUTE_PIMROUTE_HSLSROUTE_OLSRROUTE_BABELROUTE_MAX" +const _ROUTE_TYPE_name = "ROUTE_SYSTEMROUTE_KERNELROUTE_CONNECTROUTE_STATICROUTE_RIPROUTE_RIPNGROUTE_OSPFROUTE_OSPF6ROUTE_ISISROUTE_BGPROUTE_PIMROUTE_HSLSROUTE_OLSRROUTE_BABELROUTE_MAXFRR_ROUTE_VNCFRR_ROUTE_VNC_DIRECTFRR_ROUTE_VNC_DIRECT_RHFRR_ROUTE_BGP_DIRECTFRR_ROUTE_BGP_DIRECT_EXTFRR_ROUTE_ALLFRR_ROUTE_MAX" -var _ROUTE_TYPE_index = [...]uint8{0, 12, 24, 37, 49, 58, 69, 79, 90, 100, 109, 118, 128, 138, 149, 158} +var _ROUTE_TYPE_index = [...]uint16{0, 12, 24, 37, 49, 58, 69, 79, 90, 100, 109, 118, 128, 138, 149, 158, 171, 191, 214, 234, 258, 271, 284} func (i ROUTE_TYPE) String() string { if i >= ROUTE_TYPE(len(_ROUTE_TYPE_index)-1) { diff --git a/zebra/zapi.go b/zebra/zapi.go index 361b36ec..0beb3ccc 100644 --- a/zebra/zapi.go +++ b/zebra/zapi.go @@ -27,8 +27,9 @@ import ( ) const ( - HEADER_MARKER = 255 - INTERFACE_NAMSIZ = 20 + HEADER_MARKER = 255 + FRR_HEADER_MARKER = 254 + INTERFACE_NAMSIZ = 20 ) // Internal Interface Status. @@ -38,6 +39,7 @@ const ( INTERFACE_ACTIVE INTERFACE_STATUS = 0x01 INTERFACE_SUB INTERFACE_STATUS = 0x02 INTERFACE_LINKDETECTION INTERFACE_STATUS = 0x04 + INTERFACE_VRF_LOOPBACK INTERFACE_STATUS = 0x08 ) // Interface Link Layer Types. @@ -119,6 +121,9 @@ func (t INTERFACE_STATUS) String() string { if t&INTERFACE_LINKDETECTION > 0 { ss = append(ss, "LINKDETECTION") } + if t&INTERFACE_VRF_LOOPBACK > 0 { + ss = append(ss, "VRF_LOOPBACK") + } return strings.Join(ss, "|") } @@ -145,6 +150,17 @@ func (t INTERFACE_ADDRESS_FLAG) String() string { return strings.Join(ss, "|") } +// Address Family Identifier. +//go:generate stringer -type=AFI +type AFI uint8 + +const ( + AFI_IP AFI = 1 + AFI_IP6 AFI = 2 + AFI_ETHER AFI = 3 + AFI_MAX AFI = 4 +) + // Subsequent Address Family Identifier. //go:generate stringer -type=SAFI type SAFI uint8 @@ -162,6 +178,7 @@ const ( //go:generate stringer -type=API_TYPE type API_TYPE uint16 +// For Quagga. const ( _ API_TYPE = iota INTERFACE_ADD @@ -196,10 +213,75 @@ const ( MESSAGE_MAX ) +// For FRRouting. +const ( + FRR_INTERFACE_ADD API_TYPE = iota + FRR_INTERFACE_DELETE + FRR_INTERFACE_ADDRESS_ADD + FRR_INTERFACE_ADDRESS_DELETE + FRR_INTERFACE_UP + FRR_INTERFACE_DOWN + FRR_IPV4_ROUTE_ADD + FRR_IPV4_ROUTE_DELETE + FRR_IPV6_ROUTE_ADD + FRR_IPV6_ROUTE_DELETE + FRR_REDISTRIBUTE_ADD + FRR_REDISTRIBUTE_DELETE + FRR_REDISTRIBUTE_DEFAULT_ADD + FRR_REDISTRIBUTE_DEFAULT_DELETE + FRR_ROUTER_ID_ADD + FRR_ROUTER_ID_DELETE + FRR_ROUTER_ID_UPDATE + FRR_HELLO + FRR_NEXTHOP_REGISTER + FRR_NEXTHOP_UNREGISTER + FRR_NEXTHOP_UPDATE + FRR_INTERFACE_NBR_ADDRESS_ADD + FRR_INTERFACE_NBR_ADDRESS_DELETE + FRR_INTERFACE_BFD_DEST_UPDATE + FRR_IMPORT_ROUTE_REGISTER + FRR_IMPORT_ROUTE_UNREGISTER + FRR_IMPORT_CHECK_UPDATE + FRR_IPV4_ROUTE_IPV6_NEXTHOP_ADD + FRR_BFD_DEST_REGISTER + FRR_BFD_DEST_DEREGISTER + FRR_BFD_DEST_UPDATE + FRR_BFD_DEST_REPLAY + FRR_REDISTRIBUTE_IPV4_ADD + FRR_REDISTRIBUTE_IPV4_DEL + FRR_REDISTRIBUTE_IPV6_ADD + FRR_REDISTRIBUTE_IPV6_DEL + FRR_VRF_UNREGISTER + FRR_VRF_ADD + FRR_VRF_DELETE + FRR_INTERFACE_VRF_UPDATE + FRR_BFD_CLIENT_REGISTER + FRR_INTERFACE_ENABLE_RADV + FRR_INTERFACE_DISABLE_RADV + FRR_IPV4_NEXTHOP_LOOKUP_MRIB + FRR_INTERFACE_LINK_PARAMS + FRR_MPLS_LABELS_ADD + FRR_MPLS_LABELS_DELETE + FRR_IPV4_NEXTHOP_ADD + FRR_IPV4_NEXTHOP_DELETE + FRR_IPV6_NEXTHOP_ADD + FRR_IPV6_NEXTHOP_DELETE + FRR_IPMR_ROUTE_STATS + FRR_LABEL_MANAGER_CONNECT + FRR_GET_LABEL_CHUNK + FRR_RELEASE_LABEL_CHUNK + FRR_PW_ADD + FRR_PW_DELETE + FRR_PW_SET + FRR_PW_UNSET + FRR_PW_STATUS_UPDATE +) + // Route Types. //go:generate stringer -type=ROUTE_TYPE type ROUTE_TYPE uint8 +// For Quagga. const ( ROUTE_SYSTEM ROUTE_TYPE = iota ROUTE_KERNEL @@ -218,21 +300,55 @@ const ( ROUTE_MAX ) +// For FRRouting. +const ( + FRR_ROUTE_SYSTEM ROUTE_TYPE = iota + FRR_ROUTE_KERNEL + FRR_ROUTE_CONNECT + FRR_ROUTE_STATIC + FRR_ROUTE_RIP + FRR_ROUTE_RIPNG + FRR_ROUTE_OSPF + FRR_ROUTE_OSPF6 + FRR_ROUTE_ISIS + FRR_ROUTE_BGP + FRR_ROUTE_PIM + FRR_ROUTE_HSLS + FRR_ROUTE_OLSR + FRR_ROUTE_TABLE + FRR_ROUTE_LDP + FRR_ROUTE_VNC + FRR_ROUTE_VNC_DIRECT + FRR_ROUTE_VNC_DIRECT_RH + FRR_ROUTE_BGP_DIRECT + FRR_ROUTE_BGP_DIRECT_EXT + FRR_ROUTE_ALL + FRR_ROUTE_MAX +) + var routeTypeValueMap = map[string]ROUTE_TYPE{ - "system": ROUTE_SYSTEM, - "kernel": ROUTE_KERNEL, - "connect": ROUTE_CONNECT, - "static": ROUTE_STATIC, - "rip": ROUTE_RIP, - "ripng": ROUTE_RIPNG, - "ospf": ROUTE_OSPF, - "ospf3": ROUTE_OSPF6, - "isis": ROUTE_ISIS, - "bgp": ROUTE_BGP, - "pim": ROUTE_PIM, - "hsls": ROUTE_HSLS, - "olsr": ROUTE_OLSR, - "babel": ROUTE_BABEL, + "system": ROUTE_SYSTEM, + "kernel": ROUTE_KERNEL, + "connect": ROUTE_CONNECT, + "static": ROUTE_STATIC, + "rip": ROUTE_RIP, + "ripng": ROUTE_RIPNG, + "ospf": ROUTE_OSPF, + "ospf3": ROUTE_OSPF6, + "isis": ROUTE_ISIS, + "bgp": ROUTE_BGP, + "pim": ROUTE_PIM, + "hsls": ROUTE_HSLS, + "olsr": ROUTE_OLSR, + "babel": ROUTE_BABEL, + "table": FRR_ROUTE_TABLE, + "ldp": FRR_ROUTE_LDP, + "vnc": FRR_ROUTE_VNC, + "vnc-direct": FRR_ROUTE_VNC_DIRECT, + "vnc-direct-rh": FRR_ROUTE_VNC_DIRECT_RH, + "bgp-direct": FRR_ROUTE_BGP_DIRECT, + "bgp-direct-ext": FRR_ROUTE_BGP_DIRECT_EXT, + "all": FRR_ROUTE_ALL, } func RouteTypeFromString(typ string) (ROUTE_TYPE, error) { @@ -246,6 +362,7 @@ func RouteTypeFromString(typ string) (ROUTE_TYPE, error) { // API Message Flags. type MESSAGE_FLAG uint8 +// For Quagga. const ( MESSAGE_NEXTHOP MESSAGE_FLAG = 0x01 MESSAGE_IFINDEX MESSAGE_FLAG = 0x02 @@ -278,18 +395,31 @@ func (t MESSAGE_FLAG) String() string { return strings.Join(ss, "|") } +// For FRRouting. +const ( + FRR_MESSAGE_NEXTHOP MESSAGE_FLAG = 0x01 + FRR_MESSAGE_IFINDEX MESSAGE_FLAG = 0x02 + FRR_MESSAGE_DISTANCE MESSAGE_FLAG = 0x04 + FRR_MESSAGE_METRIC MESSAGE_FLAG = 0x08 + FRR_MESSAGE_TAG MESSAGE_FLAG = 0x10 + FRR_MESSAGE_MTU MESSAGE_FLAG = 0x20 + FRR_MESSAGE_SRCPFX MESSAGE_FLAG = 0x40 +) + // Message Flags type FLAG uint64 const ( - FLAG_INTERNAL FLAG = 0x01 - FLAG_SELFROUTE FLAG = 0x02 - FLAG_BLACKHOLE FLAG = 0x04 - FLAG_IBGP FLAG = 0x08 - FLAG_SELECTED FLAG = 0x10 - FLAG_CHANGED FLAG = 0x20 - FLAG_STATIC FLAG = 0x40 - FLAG_REJECT FLAG = 0x80 + FLAG_INTERNAL FLAG = 0x01 + FLAG_SELFROUTE FLAG = 0x02 + FLAG_BLACKHOLE FLAG = 0x04 + FLAG_IBGP FLAG = 0x08 + FLAG_SELECTED FLAG = 0x10 + FLAG_CHANGED FLAG = 0x20 + FLAG_STATIC FLAG = 0x40 + FLAG_REJECT FLAG = 0x80 + FLAG_SCOPE_LINK FLAG = 0x100 + FLAG_FIB_OVERRIDE FLAG = 0x200 ) func (t FLAG) String() string { @@ -318,6 +448,12 @@ func (t FLAG) String() string { if t&FLAG_REJECT > 0 { ss = append(ss, "FLAG_REJECT") } + if t&FLAG_SCOPE_LINK > 0 { + ss = append(ss, "FLAG_SCOPE_LINK") + } + if t&FLAG_FIB_OVERRIDE > 0 { + ss = append(ss, "FLAG_FIB_OVERRIDE") + } return strings.Join(ss, "|") } @@ -325,6 +461,7 @@ func (t FLAG) String() string { //go:generate stringer -type=NEXTHOP_FLAG type NEXTHOP_FLAG uint8 +// For Quagga. const ( _ NEXTHOP_FLAG = iota NEXTHOP_IFINDEX @@ -338,6 +475,37 @@ const ( NEXTHOP_BLACKHOLE ) +// For FRRouting. +const ( + _ NEXTHOP_FLAG = iota + FRR_NEXTHOP_IFINDEX + FRR_NEXTHOP_IPV4 + FRR_NEXTHOP_IPV4_IFINDEX + FRR_NEXTHOP_IPV6 + FRR_NEXTHOP_IPV6_IFINDEX + FRR_NEXTHOP_BLACKHOLE +) + +// Interface PTM Enable Configuration. +//go:generate stringer -type=PTM_ENABLE +type PTM_ENABLE uint8 + +const ( + PTM_ENABLE_OFF PTM_ENABLE = 0 + PTM_ENABLE_ON PTM_ENABLE = 1 + PTM_ENABLE_UNSPEC PTM_ENABLE = 2 +) + +// PTM Status. +//go:generate stringer -type=PTM_STATUS +type PTM_STATUS uint8 + +const ( + PTM_STATUS_DOWN PTM_STATUS = 0 + PTM_STATUS_UP PTM_STATUS = 1 + PTM_STATUS_UNKNOWN PTM_STATUS = 2 +) + type Client struct { outgoing chan *Message incoming chan *Message |