Zebra¶
Zebra protocol parser/serializer
Zebra Protocol is used to communicate with the zebra daemon.
-
class
os_ken.lib.packet.zebra.
InterfaceLinkParams
(lp_status, te_metric, max_bw, max_reserved_bw, unreserved_bw, admin_group, remote_as, remote_ip, average_delay, min_delay, max_delay, delay_var, pkt_loss, residual_bw, average_bw, utilized_bw)¶ Interface Link Parameters class for if_link_params structure.
-
class
os_ken.lib.packet.zebra.
NextHopBlackhole
(ifindex=None, ifname=None, addr=None, type_=None)¶ Nexthop class for ZEBRA_NEXTHOP_BLACKHOLE type.
-
class
os_ken.lib.packet.zebra.
NextHopIFIndex
(ifindex=None, ifname=None, addr=None, type_=None)¶ Nexthop class for ZEBRA_NEXTHOP_IFINDEX type.
-
class
os_ken.lib.packet.zebra.
NextHopIFName
(ifindex=None, ifname=None, addr=None, type_=None)¶ Nexthop class for ZEBRA_NEXTHOP_IFNAME type.
-
class
os_ken.lib.packet.zebra.
NextHopIPv4
(ifindex=None, ifname=None, addr=None, type_=None)¶ Nexthop class for ZEBRA_NEXTHOP_IPV4 type.
-
class
os_ken.lib.packet.zebra.
NextHopIPv4IFIndex
(ifindex=None, ifname=None, addr=None, type_=None)¶ Nexthop class for ZEBRA_NEXTHOP_IPV4_IFINDEX type.
-
class
os_ken.lib.packet.zebra.
NextHopIPv4IFName
(ifindex=None, ifname=None, addr=None, type_=None)¶ Nexthop class for ZEBRA_NEXTHOP_IPV4_IFNAME type.
-
class
os_ken.lib.packet.zebra.
NextHopIPv6
(ifindex=None, ifname=None, addr=None, type_=None)¶ Nexthop class for ZEBRA_NEXTHOP_IPV6 type.
-
class
os_ken.lib.packet.zebra.
NextHopIPv6IFIndex
(ifindex=None, ifname=None, addr=None, type_=None)¶ Nexthop class for ZEBRA_NEXTHOP_IPV6_IFINDEX type.
-
class
os_ken.lib.packet.zebra.
NextHopIPv6IFName
(ifindex=None, ifname=None, addr=None, type_=None)¶ Nexthop class for ZEBRA_NEXTHOP_IPV6_IFNAME type.
-
class
os_ken.lib.packet.zebra.
RegisteredNexthop
(connected, family, prefix)¶ Unit of ZEBRA_NEXTHOP_REGISTER message body.
-
class
os_ken.lib.packet.zebra.
ZebraBfdClientRegister
(pid)¶ Message body class for FRR_ZEBRA_BFD_CLIENT_REGISTER.
-
class
os_ken.lib.packet.zebra.
ZebraBfdDestinationDeregister
(pid, dst_family, dst_prefix, multi_hop, src_family, src_prefix, multi_hop_count=None, ifname=None)¶ Message body class for FRR_ZEBRA_BFD_DEST_DEREGISTER.
-
class
os_ken.lib.packet.zebra.
ZebraBfdDestinationRegister
(pid, dst_family, dst_prefix, min_rx_timer, min_tx_timer, detect_mult, multi_hop, src_family, src_prefix, multi_hop_count=None, ifname=None)¶ Message body class for FRR_ZEBRA_BFD_DEST_REGISTER.
-
class
os_ken.lib.packet.zebra.
ZebraBfdDestinationReply
¶ Message body class for FRR_ZEBRA_BFD_DEST_REPLAY.
-
class
os_ken.lib.packet.zebra.
ZebraBfdDestinationUpdate
(pid, dst_family, dst_prefix, min_rx_timer, min_tx_timer, detect_mult, multi_hop, src_family, src_prefix, multi_hop_count=None, ifname=None)¶ Message body class for FRR_ZEBRA_BFD_DEST_UPDATE.
-
class
os_ken.lib.packet.zebra.
ZebraHello
(route_type, instance=None)¶ Message body class for ZEBRA_HELLO.
-
class
os_ken.lib.packet.zebra.
ZebraIPv4ImportLookup
(prefix, metric=None, nexthops=None, from_zebra=False)¶ Message body class for ZEBRA_IPV4_IMPORT_LOOKUP.
-
class
os_ken.lib.packet.zebra.
ZebraIPv4NexthopAdd
(route_type, flags, message, safi=None, prefix=None, src_prefix=None, nexthops=None, ifindexes=None, distance=None, metric=None, mtu=None, tag=None, instance=None, from_zebra=False)¶ Message body class for FRR_ZEBRA_IPV4_NEXTHOP_ADD.
-
class
os_ken.lib.packet.zebra.
ZebraIPv4NexthopDelete
(route_type, flags, message, safi=None, prefix=None, src_prefix=None, nexthops=None, ifindexes=None, distance=None, metric=None, mtu=None, tag=None, instance=None, from_zebra=False)¶ Message body class for FRR_ZEBRA_IPV4_NEXTHOP_DELETE.
-
class
os_ken.lib.packet.zebra.
ZebraIPv4NexthopLookup
(addr, metric=None, nexthops=None)¶ Message body class for ZEBRA_IPV4_NEXTHOP_LOOKUP.
-
class
os_ken.lib.packet.zebra.
ZebraIPv4NexthopLookupMRib
(addr, distance=None, metric=None, nexthops=None)¶ Message body class for ZEBRA_IPV4_NEXTHOP_LOOKUP_MRIB.
-
class
os_ken.lib.packet.zebra.
ZebraIPv4RouteAdd
(route_type, flags, message, safi=None, prefix=None, src_prefix=None, nexthops=None, ifindexes=None, distance=None, metric=None, mtu=None, tag=None, instance=None, from_zebra=False)¶ Message body class for ZEBRA_IPV4_ROUTE_ADD.
-
class
os_ken.lib.packet.zebra.
ZebraIPv4RouteDelete
(route_type, flags, message, safi=None, prefix=None, src_prefix=None, nexthops=None, ifindexes=None, distance=None, metric=None, mtu=None, tag=None, instance=None, from_zebra=False)¶ Message body class for ZEBRA_IPV4_ROUTE_DELETE.
-
class
os_ken.lib.packet.zebra.
ZebraIPv4RouteIPv6NexthopAdd
(route_type, flags, message, safi=None, prefix=None, src_prefix=None, nexthops=None, ifindexes=None, distance=None, metric=None, mtu=None, tag=None, instance=None, from_zebra=False)¶ Message body class for FRR_ZEBRA_IPV4_ROUTE_IPV6_NEXTHOP_ADD.
-
class
os_ken.lib.packet.zebra.
ZebraIPv6ImportLookup
(prefix, metric=None, nexthops=None, from_zebra=False)¶ Message body class for ZEBRA_IPV6_IMPORT_LOOKUP.
-
class
os_ken.lib.packet.zebra.
ZebraIPv6NexthopAdd
(route_type, flags, message, safi=None, prefix=None, src_prefix=None, nexthops=None, ifindexes=None, distance=None, metric=None, mtu=None, tag=None, instance=None, from_zebra=False)¶ Message body class for FRR_ZEBRA_IPV6_NEXTHOP_ADD.
-
class
os_ken.lib.packet.zebra.
ZebraIPv6NexthopDelete
(route_type, flags, message, safi=None, prefix=None, src_prefix=None, nexthops=None, ifindexes=None, distance=None, metric=None, mtu=None, tag=None, instance=None, from_zebra=False)¶ Message body class for FRR_ZEBRA_IPV6_NEXTHOP_DELETE.
-
class
os_ken.lib.packet.zebra.
ZebraIPv6NexthopLookup
(addr, metric=None, nexthops=None)¶ Message body class for ZEBRA_IPV6_NEXTHOP_LOOKUP.
-
class
os_ken.lib.packet.zebra.
ZebraIPv6RouteAdd
(route_type, flags, message, safi=None, prefix=None, src_prefix=None, nexthops=None, ifindexes=None, distance=None, metric=None, mtu=None, tag=None, instance=None, from_zebra=False)¶ Message body class for ZEBRA_IPV6_ROUTE_ADD.
-
class
os_ken.lib.packet.zebra.
ZebraIPv6RouteDelete
(route_type, flags, message, safi=None, prefix=None, src_prefix=None, nexthops=None, ifindexes=None, distance=None, metric=None, mtu=None, tag=None, instance=None, from_zebra=False)¶ Message body class for ZEBRA_IPV6_ROUTE_DELETE.
-
class
os_ken.lib.packet.zebra.
ZebraImportCheckUpdate
(family, prefix, distance=None, metric=None, nexthops=None)¶ Message body class for FRR_ZEBRA_IMPORT_CHECK_UPDATE.
-
class
os_ken.lib.packet.zebra.
ZebraImportRouteRegister
(nexthops)¶ Message body class for FRR_ZEBRA_IMPORT_ROUTE_REGISTER.
-
class
os_ken.lib.packet.zebra.
ZebraImportRouteUnregister
(nexthops)¶ Message body class for FRR_ZEBRA_IMPORT_ROUTE_UNREGISTER.
-
class
os_ken.lib.packet.zebra.
ZebraInterfaceAdd
(ifname=None, ifindex=None, status=None, if_flags=None, ptm_enable=None, ptm_status=None, metric=None, speed=None, ifmtu=None, ifmtu6=None, bandwidth=None, ll_type=None, hw_addr_len=0, hw_addr=None, link_params=None)¶ Message body class for ZEBRA_INTERFACE_ADD.
-
class
os_ken.lib.packet.zebra.
ZebraInterfaceAddressAdd
(ifindex, ifc_flags, family, prefix, dest)¶ Message body class for ZEBRA_INTERFACE_ADDRESS_ADD.
-
class
os_ken.lib.packet.zebra.
ZebraInterfaceAddressDelete
(ifindex, ifc_flags, family, prefix, dest)¶ Message body class for ZEBRA_INTERFACE_ADDRESS_DELETE.
-
class
os_ken.lib.packet.zebra.
ZebraInterfaceBfdDestinationUpdate
(ifindex, dst_family, dst_prefix, status, src_family, src_prefix)¶ Message body class for FRR_ZEBRA_INTERFACE_BFD_DEST_UPDATE.
-
class
os_ken.lib.packet.zebra.
ZebraInterfaceDelete
(ifname=None, ifindex=None, status=None, if_flags=None, ptm_enable=None, ptm_status=None, metric=None, speed=None, ifmtu=None, ifmtu6=None, bandwidth=None, ll_type=None, hw_addr_len=0, hw_addr=None, link_params=None)¶ Message body class for ZEBRA_INTERFACE_DELETE.
-
class
os_ken.lib.packet.zebra.
ZebraInterfaceDisableRadv
(ifindex, interval)¶ Message body class for FRR_ZEBRA_INTERFACE_DISABLE_RADV.
-
class
os_ken.lib.packet.zebra.
ZebraInterfaceDown
(ifname=None, ifindex=None, status=None, if_flags=None, ptm_enable=None, ptm_status=None, metric=None, speed=None, ifmtu=None, ifmtu6=None, bandwidth=None, ll_type=None, hw_addr_len=0, hw_addr=None, link_params=None)¶ Message body class for ZEBRA_INTERFACE_DOWN.
-
class
os_ken.lib.packet.zebra.
ZebraInterfaceEnableRadv
(ifindex, interval)¶ Message body class for FRR_ZEBRA_INTERFACE_ENABLE_RADV.
-
class
os_ken.lib.packet.zebra.
ZebraInterfaceLinkParams
(ifindex, link_params)¶ Message body class for ZEBRA_INTERFACE_LINK_PARAMS.
-
class
os_ken.lib.packet.zebra.
ZebraInterfaceNbrAddressAdd
(ifindex, family, prefix)¶ Message body class for FRR_ZEBRA_INTERFACE_NBR_ADDRESS_ADD.
-
class
os_ken.lib.packet.zebra.
ZebraInterfaceNbrAddressDelete
(ifindex, family, prefix)¶ Message body class for FRR_ZEBRA_INTERFACE_NBR_ADDRESS_DELETE.
-
class
os_ken.lib.packet.zebra.
ZebraInterfaceUp
(ifname=None, ifindex=None, status=None, if_flags=None, ptm_enable=None, ptm_status=None, metric=None, speed=None, ifmtu=None, ifmtu6=None, bandwidth=None, ll_type=None, hw_addr_len=0, hw_addr=None, link_params=None)¶ Message body class for ZEBRA_INTERFACE_UP.
-
class
os_ken.lib.packet.zebra.
ZebraInterfaceVrfUpdate
(ifindex, vrf_id)¶ Message body class for FRR_ZEBRA_INTERFACE_VRF_UPDATE.
-
class
os_ken.lib.packet.zebra.
ZebraMessage
(length=None, version=3, vrf_id=0, command=None, body=None)¶ Zebra protocol parser/serializer class.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute
Description
length
Total packet length including this header. The minimum length is 3 bytes for version 0 messages, 6 bytes for version 1/2 messages and 8 bytes for version 3 messages.
version
Version number of the Zebra protocol message. To instantiate messages with other than the default version,
version
must be specified.vrf_id
VRF ID for the route contained in message. Not present in version 0/1/2 messages in the on-wire structure, and always 0 for theses version.
command
Zebra Protocol command, which denotes message type.
body
Messages body. An instance of subclass of
_ZebraMessageBody
named like "Zebra + <message name>" (e.g.,ZebraHello
). OrNone
if message does not contain any body.Note
To instantiate Zebra messages,
command
can be omitted when the validbody
is specified.>>> from os_ken.lib.packet import zebra >>> zebra.ZebraMessage(body=zebra.ZebraHello()) ZebraMessage(body=ZebraHello(route_type=14),command=23, length=None,version=3,vrf_id=0)
On the other hand, if
body
is omitted,command
must be specified.>>> zebra.ZebraMessage(command=zebra.ZEBRA_INTERFACE_ADD) ZebraMessage(body=None,command=1,length=None,version=3,vrf_id=0)
-
classmethod
parser
(buf)¶ Decode a protocol header.
This method is used only when decoding a packet.
Decode a protocol header at offset 0 in bytearray buf. Returns the following three objects.
An object to describe the decoded header.
A packet_base.PacketBase subclass appropriate for the rest of the packet. None when the rest of the packet should be considered as raw payload.
The rest of packet.
-
serialize
(_payload=None, _prev=None)¶ Encode a protocol header.
This method is used only when encoding a packet.
Encode a protocol header. Returns a bytearray which contains the header.
payload is the rest of the packet which will immediately follow this header.
prev is a packet_base.PacketBase subclass for the outer protocol header. prev is None if the current header is the outer-most. For example, prev is ipv4 or ipv6 for tcp.serialize.
-
classmethod
-
class
os_ken.lib.packet.zebra.
ZebraMplsLabelsAdd
(route_type, family, prefix, gate_addr, ifindex=None, distance=None, in_label=None, out_label=None)¶ Message body class for FRR_ZEBRA_MPLS_LABELS_ADD.
-
class
os_ken.lib.packet.zebra.
ZebraMplsLabelsDelete
(route_type, family, prefix, gate_addr, ifindex=None, distance=None, in_label=None, out_label=None)¶ Message body class for FRR_ZEBRA_MPLS_LABELS_DELETE.
-
class
os_ken.lib.packet.zebra.
ZebraNexthopRegister
(nexthops)¶ Message body class for ZEBRA_NEXTHOP_REGISTER.
-
class
os_ken.lib.packet.zebra.
ZebraNexthopUnregister
(nexthops)¶ Message body class for ZEBRA_NEXTHOP_UNREGISTER.
-
class
os_ken.lib.packet.zebra.
ZebraNexthopUpdate
(family, prefix, distance=None, metric=None, nexthops=None)¶ Message body class for ZEBRA_NEXTHOP_UPDATE.
-
class
os_ken.lib.packet.zebra.
ZebraRedistributeAdd
(route_type, afi=None, instance=None)¶ Message body class for ZEBRA_REDISTRIBUTE_ADD.
-
class
os_ken.lib.packet.zebra.
ZebraRedistributeDefaultAdd
(route_type, afi=None, instance=None)¶ Message body class for ZEBRA_REDISTRIBUTE_DEFAULT_ADD.
-
class
os_ken.lib.packet.zebra.
ZebraRedistributeDefaultDelete
(route_type, afi=None, instance=None)¶ Message body class for ZEBRA_REDISTRIBUTE_DEFAULT_DELETE.
-
class
os_ken.lib.packet.zebra.
ZebraRedistributeDelete
(route_type, afi=None, instance=None)¶ Message body class for ZEBRA_REDISTRIBUTE_DELETE.
-
class
os_ken.lib.packet.zebra.
ZebraRedistributeIPv4Add
(route_type, flags, message, safi=None, prefix=None, src_prefix=None, nexthops=None, ifindexes=None, distance=None, metric=None, mtu=None, tag=None, instance=None, from_zebra=False)¶ Message body class for FRR_ZEBRA_IPV4_ROUTE_ADD.
-
class
os_ken.lib.packet.zebra.
ZebraRedistributeIPv4Delete
(route_type, flags, message, safi=None, prefix=None, src_prefix=None, nexthops=None, ifindexes=None, distance=None, metric=None, mtu=None, tag=None, instance=None, from_zebra=False)¶ Message body class for FRR_ZEBRA_IPV4_ROUTE_DELETE.
-
class
os_ken.lib.packet.zebra.
ZebraRedistributeIPv6Add
(route_type, flags, message, safi=None, prefix=None, src_prefix=None, nexthops=None, ifindexes=None, distance=None, metric=None, mtu=None, tag=None, instance=None, from_zebra=False)¶ Message body class for FRR_ZEBRA_REDISTRIBUTE_IPV6_ADD.
-
class
os_ken.lib.packet.zebra.
ZebraRedistributeIPv6Delete
(route_type, flags, message, safi=None, prefix=None, src_prefix=None, nexthops=None, ifindexes=None, distance=None, metric=None, mtu=None, tag=None, instance=None, from_zebra=False)¶ Message body class for FRR_ZEBRA_REDISTRIBUTE_IPV6_DEL.
-
class
os_ken.lib.packet.zebra.
ZebraRouterIDAdd
¶ Message body class for ZEBRA_ROUTER_ID_ADD.
-
class
os_ken.lib.packet.zebra.
ZebraRouterIDDelete
¶ Message body class for ZEBRA_ROUTER_ID_DELETE.
-
class
os_ken.lib.packet.zebra.
ZebraRouterIDUpdate
(family, prefix)¶ Message body class for ZEBRA_ROUTER_ID_UPDATE.
-
class
os_ken.lib.packet.zebra.
ZebraUnknownMessage
(buf)¶ Message body class for Unknown command.
-
class
os_ken.lib.packet.zebra.
ZebraVrfAdd
(vrf_name)¶ Message body class for FRR_ZEBRA_VRF_ADD.
-
class
os_ken.lib.packet.zebra.
ZebraVrfDelete
(vrf_name)¶ Message body class for FRR_ZEBRA_VRF_DELETE.
-
class
os_ken.lib.packet.zebra.
ZebraVrfUnregister
¶ Message body class for ZEBRA_VRF_UNREGISTER.
-
os_ken.lib.packet.zebra.
zebra
¶ alias of
os_ken.lib.packet.zebra.ZebraMessage