BGP

RFC 4271 BGP-4

exception os_ken.lib.packet.bgp.AdminReset(data='')
CODE = 6

BGP error code.

SUB_CODE = 4

BGP error sub-code.

exception os_ken.lib.packet.bgp.AdminShutdown(data='')

Error to indicate Administrative shutdown.

RFC says: If a BGP speaker decides to administratively shut down its peering with a neighbor, then the speaker SHOULD send a NOTIFICATION message with the Error Code Cease and the Error Subcode 'Administrative Shutdown'.

CODE = 6

BGP error code.

SUB_CODE = 2

BGP error sub-code.

exception os_ken.lib.packet.bgp.AttrFlagError(data='')

Error to indicate recognized path attributes have incorrect flags.

RFC says: If any recognized attribute has Attribute Flags that conflict with the Attribute Type Code, then the Error Subcode MUST be set to Attribute Flags Error. The Data field MUST contain the erroneous attribute (type, length, and value).

CODE = 3

BGP error code.

SUB_CODE = 4

BGP error sub-code.

exception os_ken.lib.packet.bgp.AttrLenError(data='')
CODE = 3

BGP error code.

SUB_CODE = 5

BGP error sub-code.

exception os_ken.lib.packet.bgp.AuthFailure(data='')
CODE = 2

BGP error code.

SUB_CODE = 5

BGP error sub-code.

class os_ken.lib.packet.bgp.BGPEvpnEsImportRTExtendedCommunity(**kwargs)

ES-Import Route Target Extended Community

class os_ken.lib.packet.bgp.BGPEvpnEsiLabelExtendedCommunity(label=None, mpls_label=None, vni=None, **kwargs)

ESI Label Extended Community

class os_ken.lib.packet.bgp.BGPEvpnMacMobilityExtendedCommunity(**kwargs)

MAC Mobility Extended Community

class os_ken.lib.packet.bgp.BGPFlowSpecRedirectCommunity(**kwargs)

Flow Specification Traffic Filtering Actions for Redirect.

Attribute

Description

as_number

Autonomous System number.

local_administrator

Local Administrator.

class os_ken.lib.packet.bgp.BGPFlowSpecTPIDActionCommunity(**kwargs)

Flow Specification TPID Actions.

Attribute

Description

actions

Bit representation of actions. Supported actions are TI(inner TPID action) and TO(outer TPID action).

tpid_1

TPID used by TI.

tpid_2

TPID used by TO.

class os_ken.lib.packet.bgp.BGPFlowSpecTrafficActionCommunity(**kwargs)

Flow Specification Traffic Filtering Actions for Traffic Action.

Attribute

Description

action

Apply action. The supported action are SAMPLE and TERMINAL.

class os_ken.lib.packet.bgp.BGPFlowSpecTrafficMarkingCommunity(**kwargs)

Flow Specification Traffic Filtering Actions for Traffic Marking.

Attribute

Description

dscp

Differentiated Services Code Point.

class os_ken.lib.packet.bgp.BGPFlowSpecTrafficRateCommunity(**kwargs)

Flow Specification Traffic Filtering Actions for Traffic Rate.

Attribute

Description

as_number

Autonomous System number.

rate_info

rate information.

class os_ken.lib.packet.bgp.BGPFlowSpecVlanActionCommunity(**kwargs)

Flow Specification Vlan Actions.

Attribute

Description

actions_1

Bit representation of actions. Supported actions are POP, PUSH, SWAP, REWRITE_INNER, REWRITE_OUTER.

actions_2

Same as actions_1.

vlan_1

VLAN ID used by actions_1.

cos_1

Class of Service used by actions_1.

vlan_2

VLAN ID used by actions_2.

cos_2

Class of Service used by actions_2.

class os_ken.lib.packet.bgp.BGPKeepAlive(type_=4, len_=None, marker=None)

BGP-4 KEEPALIVE Message encoder/decoder 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

marker

Marker field. Ignored when encoding.

len

Length field. Ignored when encoding.

type

Type field.

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.

class os_ken.lib.packet.bgp.BGPMessage(marker=None, len_=None, type_=None)

Base class for BGP-4 messages.

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

marker

Marker field. Ignored when encoding.

len

Length field. Ignored when encoding.

type

Type field. one of BGP_MSG_* constants.

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.

class os_ken.lib.packet.bgp.BGPNotification(error_code, error_subcode, data=b'', type_=3, len_=None, marker=None)

BGP-4 NOTIFICATION Message encoder/decoder 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

marker

Marker field. Ignored when encoding.

len

Length field. Ignored when encoding.

type

Type field.

error_code

Error code field.

error_subcode

Error subcode field.

data

Data field.

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.

class os_ken.lib.packet.bgp.BGPOpen(my_as, bgp_identifier, type_=1, opt_param_len=0, opt_param=None, version=4, hold_time=0, len_=None, marker=None)

BGP-4 OPEN Message encoder/decoder 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

marker

Marker field. Ignored when encoding.

len

Length field. Ignored when encoding.

type

Type field.

version

Version field.

my_as

My Autonomous System field. 2 octet unsigned integer.

hold_time

Hold Time field. 2 octet unsigned integer.

bgp_identifier

BGP Identifier field. An IPv4 address. For example, '192.0.2.1'

opt_param_len

Optional Parameters Length field. Ignored when encoding.

opt_param

Optional Parameters field. A list of BGPOptParam instances. The default is [].

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.

class os_ken.lib.packet.bgp.BGPPathAttributePmsiTunnel(pmsi_flags, tunnel_type, mpls_label=None, label=None, vni=None, tunnel_id=None, flags=0, type_=None, length=None)

P-Multicast Service Interface Tunnel (PMSI Tunnel) attribute

classmethod from_jsondict(dict_, decode_string=<function b64decode>, **additional_args)

Create an instance from a JSON style dict.

Instantiate this class with parameters specified by the dict.

This method takes the following arguments.

Argument

Descrpition

dict_

A dictionary which describes the parameters. For example, {"Param1": 100, "Param2": 200}

decode_string

(Optional) specify how to decode strings. The default is base64. This argument is used only for attributes which don't have explicit type annotations in _TYPE class attribute.

additional_args

(Optional) Additional kwargs for constructor.

class os_ken.lib.packet.bgp.BGPRouteRefresh(afi, safi, demarcation=0, type_=5, len_=None, marker=None)

BGP-4 ROUTE REFRESH Message (RFC 2918) encoder/decoder 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

marker

Marker field. Ignored when encoding.

len

Length field. Ignored when encoding.

type

Type field.

afi

Address Family Identifier

safi

Subsequent Address Family Identifier

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.

class os_ken.lib.packet.bgp.BGPUpdate(type_=2, withdrawn_routes_len=None, withdrawn_routes=None, total_path_attribute_len=None, path_attributes=None, nlri=None, len_=None, marker=None)

BGP-4 UPDATE Message encoder/decoder 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

marker

Marker field. Ignored when encoding.

len

Length field. Ignored when encoding.

type

Type field.

withdrawn_routes_len

Withdrawn Routes Length field. Ignored when encoding.

withdrawn_routes

Withdrawn Routes field. A list of BGPWithdrawnRoute instances. The default is [].

total_path_attribute_len

Total Path Attribute Length field. Ignored when encoding.

path_attributes

Path Attributes field. A list of BGPPathAttribute instances. The default is [].

nlri

Network Layer Reachability Information field. A list of BGPNLRI instances. The default is [].

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.

exception os_ken.lib.packet.bgp.BadBgpId(data='')

Error to indicate incorrect BGP Identifier.

RFC says: If the BGP Identifier field of the OPEN message is syntactically incorrect, then the Error Subcode MUST be set to Bad BGP Identifier. Syntactic correctness means that the BGP Identifier field represents a valid unicast IP host address.

CODE = 2

BGP error code.

SUB_CODE = 3

BGP error sub-code.

exception os_ken.lib.packet.bgp.BadLen(msg_type_code, message_length)
CODE = 1

BGP error code.

SUB_CODE = 2

BGP error sub-code.

exception os_ken.lib.packet.bgp.BadMsg(msg_type)

Error to indicate un-recognized message type.

RFC says: If the Type field of the message header is not recognized, then the Error Subcode MUST be set to Bad Message Type. The Data field MUST contain the erroneous Type field.

CODE = 1

BGP error code.

SUB_CODE = 3

BGP error sub-code.

exception os_ken.lib.packet.bgp.BadNotification(data='')
SEND_ERROR = False

Flag if set indicates Notification message should be sent to peer.

exception os_ken.lib.packet.bgp.BadPeerAs(data='')

Error to indicate open message has incorrect AS number.

RFC says: If the Autonomous System field of the OPEN message is unacceptable, then the Error Subcode MUST be set to Bad Peer AS. The determination of acceptable Autonomous System numbers is configure peer AS.

CODE = 2

BGP error code.

SUB_CODE = 2

BGP error sub-code.

exception os_ken.lib.packet.bgp.BgpExc(data='')

Base bgp exception.

CODE = 0

BGP error code.

SEND_ERROR = True

Flag if set indicates Notification message should be sent to peer.

SUB_CODE = 0

BGP error sub-code.

exception os_ken.lib.packet.bgp.CollisionResolution(data='')

Error to indicate Connection Collision Resolution.

RFC says: If a BGP speaker decides to send a NOTIFICATION message with the Error Code Cease as a result of the collision resolution procedure (as described in [BGP-4]), then the subcode SHOULD be set to "Connection Collision Resolution".

CODE = 6

BGP error code.

SUB_CODE = 7

BGP error sub-code.

exception os_ken.lib.packet.bgp.ConnRejected(data='')

Error to indicate Connection Rejected.

RFC says: If a BGP speaker decides to disallow a BGP connection (e.g., the peer is not configured locally) after the speaker accepts a transport protocol connection, then the BGP speaker SHOULD send a NOTIFICATION message with the Error Code Cease and the Error Subcode "Connection Rejected".

CODE = 6

BGP error code.

SUB_CODE = 5

BGP error sub-code.

class os_ken.lib.packet.bgp.EvpnASBasedEsi(as_number, local_disc, type_=None)

AS based ESI value

This type indicates an Autonomous System(AS)-based ESI Value that can be auto-generated or configured by the operator.

class os_ken.lib.packet.bgp.EvpnArbitraryEsi(value, type_=None)

Arbitrary 9-octet ESI value

This type indicates an arbitrary 9-octet ESI value, which is managed and configured by the operator.

class os_ken.lib.packet.bgp.EvpnEsi(type_=None)

Ethernet Segment Identifier

The supported ESI Types:

  • EvpnEsi.ARBITRARY indicates EvpnArbitraryEsi.

  • EvpnEsi.LACP indicates EvpnLACPEsi.

  • EvpnEsi.L2_BRIDGE indicates EvpnL2BridgeEsi.

  • EvpnEsi.MAC_BASED indicates EvpnMacBasedEsi.

  • EvpnEsi.ROUTER_ID indicates EvpnRouterIDEsi.

  • EvpnEsi.AS_BASED indicates EvpnASBasedEsi.

class os_ken.lib.packet.bgp.EvpnEthernetAutoDiscoveryNLRI(route_dist, esi, ethernet_tag_id, mpls_label=None, vni=None, label=None, type_=None, length=None)

Ethernet A-D route type specific EVPN NLRI

class os_ken.lib.packet.bgp.EvpnEthernetSegmentNLRI(route_dist, esi, ip_addr, ip_addr_len=None, type_=None, length=None)

Ethernet Segment route type specific EVPN NLRI

class os_ken.lib.packet.bgp.EvpnInclusiveMulticastEthernetTagNLRI(route_dist, ethernet_tag_id, ip_addr, ip_addr_len=None, type_=None, length=None)

Inclusive Multicast Ethernet Tag route type specific EVPN NLRI

class os_ken.lib.packet.bgp.EvpnIpPrefixNLRI(route_dist, ethernet_tag_id, ip_prefix, esi=None, gw_ip_addr=None, mpls_label=None, vni=None, label=None, type_=None, length=None)

IP Prefix advertisement route NLRI

class os_ken.lib.packet.bgp.EvpnL2BridgeEsi(mac_addr, priority, type_=None)

ESI value for Layer 2 Bridge

This type is used in the case of indirectly connected hosts via a bridged LAN between the CEs and the PEs. The ESI Value is auto-generated and determined based on the Layer 2 bridge protocol.

class os_ken.lib.packet.bgp.EvpnLACPEsi(mac_addr, port_key, type_=None)

ESI value for LACP

When IEEE 802.1AX LACP is used between the PEs and CEs, this ESI type indicates an auto-generated ESI value determined from LACP.

class os_ken.lib.packet.bgp.EvpnMacBasedEsi(mac_addr, local_disc, type_=None)

MAC-based ESI Value

This type indicates a MAC-based ESI Value that can be auto-generated or configured by the operator.

class os_ken.lib.packet.bgp.EvpnMacIPAdvertisementNLRI(route_dist, ethernet_tag_id, mac_addr, ip_addr, esi=None, mpls_labels=None, vni=None, labels=None, mac_addr_len=None, ip_addr_len=None, type_=None, length=None)

MAC/IP Advertisement route type specific EVPN NLRI

class os_ken.lib.packet.bgp.EvpnNLRI(type_=None, length=None)

BGP Network Layer Reachability Information (NLRI) for EVPN

class os_ken.lib.packet.bgp.EvpnRouterIDEsi(router_id, local_disc, type_=None)

Router-ID ESI Value

This type indicates a router-ID ESI Value that can be auto-generated or configured by the operator.

class os_ken.lib.packet.bgp.EvpnUnknownEsi(value, type_=None)

ESI value for unknown type

class os_ken.lib.packet.bgp.EvpnUnknownNLRI(value, type_, length=None)

Unknown route type specific EVPN NLRI

exception os_ken.lib.packet.bgp.FiniteStateMachineError(data='')

Error to indicate any Finite State Machine Error.

RFC says: Any error detected by the BGP Finite State Machine (e.g., receipt of an unexpected event) is indicated by sending the NOTIFICATION message with the Error Code Finite State Machine Error.

CODE = 5

BGP error code.

SUB_CODE = 1

BGP error sub-code.

class os_ken.lib.packet.bgp.FlowSpecComponentUnknown(buf, type_=None)

Unknown component type for Flow Specification NLRI component

class os_ken.lib.packet.bgp.FlowSpecDSCP(operator, value, type_=None)

Diffserv Code Point for Flow Specification NLRI component

Set the 6-bit DSCP field at value. [RFC2474]

class os_ken.lib.packet.bgp.FlowSpecDestPort(operator, value, type_=None)

Destination port number for Flow Specification NLRI component

Set the destination port of a TCP or UDP packet at value.

class os_ken.lib.packet.bgp.FlowSpecDestPrefix(length, addr, type_=None)

Destination Prefix for Flow Specification NLRI component

class os_ken.lib.packet.bgp.FlowSpecDestinationMac(length, addr, type_=None)

Destination Mac Address.

Set the Mac Address at value.

class os_ken.lib.packet.bgp.FlowSpecEtherType(operator, value, type_=None)

Ethernet Type field in an Ethernet frame.

Set the 2 byte value of an Ethernet Type field at value.

class os_ken.lib.packet.bgp.FlowSpecFragment(operator, value, type_=None)

Fragment for Flow Specification NLRI component

Set the bitmask for operand format at value. The following values are supported.

Attribute

Description

LF

Last fragment

FF

First fragment

ISF

Is a fragment

DF

Don't fragment

class os_ken.lib.packet.bgp.FlowSpecIPProtocol(operator, value, type_=None)

IP Protocol for Flow Specification NLRI component

Set the IP protocol number at value.

class os_ken.lib.packet.bgp.FlowSpecIPv4NLRI(length=0, rules=None)

Flow Specification NLRI class for IPv4 [RFC 5575]

classmethod from_user(**kwargs)

Utility method for creating a NLRI instance.

This function returns a NLRI instance from human readable format value.

Parameters:

kwargs -- The following arguments are available.

Argument

Value

Operator

Description

dst_prefix

IPv4 Prefix

Nothing

Destination Prefix.

src_prefix

IPv4 Prefix

Nothing

Source Prefix.

ip_proto

Integer

Numeric

IP Protocol.

port

Integer

Numeric

Port number.

dst_port

Integer

Numeric

Destination port number.

src_port

Integer

Numeric

Source port number.

icmp_type

Integer

Numeric

ICMP type.

icmp_code

Integer

Numeric

ICMP code.

tcp_flags

Fixed string

Bitmask

TCP flags. Supported values are CWR, ECN, URGENT, ACK, PUSH, RST, SYN and FIN.

packet_len

Integer

Numeric

Packet length.

dscp

Integer

Numeric

Differentiated Services Code Point.

fragment

Fixed string

Bitmask

Fragment. Supported values are DF (Don't fragment), ISF (Is a fragment), FF (First fragment) and LF (Last fragment)

Example:

>>> msg = bgp.FlowSpecIPv4NLRI.from_user(
...     dst_prefix='10.0.0.0/24',
...     src_prefix='20.0.0.1/24',
...     ip_proto=6,
...     port='80 | 8000',
...     dst_port='>9000 & <9050',
...     src_port='>=8500 & <=9000',
...     icmp_type=0,
...     icmp_code=6,
...     tcp_flags='SYN+ACK & !=URGENT',
...     packet_len=1000,
...     dscp='22 | 24',
...     fragment='LF | ==FF')
>>>

You can specify conditions with the following keywords.

The following keywords can be used when the operator type is Numeric.

Keyword

Description

<

Less than comparison between data and value.

<=

Less than or equal to comparison between data and value.

>

Greater than comparison between data and value.

>=

Greater than or equal to comparison between data and value.

==

Equality between data and value. This operator can be omitted.

The following keywords can be used when the operator type is Bitmask.

Keyword

Description

!=

Not equal operation.

==

Exact match operation if specified. Otherwise partial match operation.

+

Used for the summation of bitmask values. (e.g., SYN+ACK)

You can combine the multiple conditions with the following operators.

Keyword

Description

|

Logical OR operation

&

Logical AND operation

Returns:

A instance of FlowSpecVPNv4NLRI.

class os_ken.lib.packet.bgp.FlowSpecIPv6DestPrefix(length, addr, offset=0, type_=None)

IPv6 destination Prefix for Flow Specification NLRI component

class os_ken.lib.packet.bgp.FlowSpecIPv6FlowLabel(operator, value, type_=None)
class os_ken.lib.packet.bgp.FlowSpecIPv6Fragment(operator, value, type_=None)

Fragment for Flow Specification for IPv6 NLRI component

Attribute

Description

LF

Last fragment

FF

First fragment

ISF

Is a fragment

class os_ken.lib.packet.bgp.FlowSpecIPv6NLRI(length=0, rules=None)

Flow Specification NLRI class for IPv6 [RFC draft-ietf-idr-flow-spec-v6-08]

classmethod from_user(**kwargs)

Utility method for creating a NLRI instance.

This function returns a NLRI instance from human readable format value.

Parameters:

kwargs -- The following arguments are available.

Argument

Value

Operator

Description

dst_prefix

IPv6 Prefix

Nothing

Destination Prefix.

src_prefix

IPv6 Prefix

Nothing

Source Prefix.

next_header

Integer

Numeric

Next Header.

port

Integer

Numeric

Port number.

dst_port

Integer

Numeric

Destination port number.

src_port

Integer

Numeric

Source port number.

icmp_type

Integer

Numeric

ICMP type.

icmp_code

Integer

Numeric

ICMP code.

tcp_flags

Fixed string

Bitmask

TCP flags. Supported values are CWR, ECN, URGENT, ACK, PUSH, RST, SYN and FIN.

packet_len

Integer

Numeric

Packet length.

dscp

Integer

Numeric

Differentiated Services Code Point.

fragment

Fixed string

Bitmask

Fragment. Supported values are ISF (Is a fragment), FF (First fragment) and LF (Last fragment)

flow_label

Intefer

Numeric

Flow Label.

Note

For dst_prefix and src_prefix, you can give "offset" value like this: 2001::2/128/32. At this case, offset is 32. offset can be omitted, then offset is treated as 0.

class os_ken.lib.packet.bgp.FlowSpecIPv6SrcPrefix(length, addr, offset=0, type_=None)

IPv6 source Prefix for Flow Specification NLRI component

class os_ken.lib.packet.bgp.FlowSpecIcmpCode(operator, value, type_=None)

ICMP code Flow Specification NLRI component

Set the code field of an ICMP packet at value.

class os_ken.lib.packet.bgp.FlowSpecIcmpType(operator, value, type_=None)

ICMP type for Flow Specification NLRI component

Set the type field of an ICMP packet at value.

class os_ken.lib.packet.bgp.FlowSpecInnerVLANCoS(operator, value, type_=None)

VLAN CoS Fields in an Inner Ethernet frame.

Set the 3 bit CoS field at value..

class os_ken.lib.packet.bgp.FlowSpecInnerVLANID(operator, value, type_=None)

Inner VLAN ID.

Set VLAN ID at value.

class os_ken.lib.packet.bgp.FlowSpecL2VPNNLRI(length=0, route_dist=None, rules=None)

Flow Specification NLRI class for L2VPN [draft-ietf-idr-flowspec-l2vpn-05]

classmethod from_user(route_dist, **kwargs)

Utility method for creating a L2VPN NLRI instance.

This function returns a L2VPN NLRI instance from human readable format value.

Parameters:

kwargs -- The following arguments are available.

Argument

Value

Operator

Description

ether_type

Integer

Numeric

Ethernet Type.

src_mac

Mac Address

Nothing

Source Mac address.

dst_mac

Mac Address

Nothing

Destination Mac address.

llc_ssap

Integer

Numeric

Source Service Access Point in LLC.

llc_dsap

Integer

Numeric

Destination Service Access Point in LLC.

llc_control

Integer

Numeric

Control field in LLC.

snap

Integer

Numeric

Sub-Network Access Protocol field.

vlan_id

Integer

Numeric

VLAN ID.

vlan_cos

Integer

Numeric

VLAN COS field.

inner_vlan_id

Integer

Numeric

Inner VLAN ID.

inner_vlan_cos

Integer

Numeric

Inner VLAN COS field.

class os_ken.lib.packet.bgp.FlowSpecLLCControl(operator, value, type_=None)

Control field in LLC header in an Ethernet frame.

Set the Contorol field at value.

class os_ken.lib.packet.bgp.FlowSpecLLCDSAP(operator, value, type_=None)

Destination SAP field in LLC header in an Ethernet frame.

Set the 2 byte value of an Destination SAP at value.

class os_ken.lib.packet.bgp.FlowSpecLLCSSAP(operator, value, type_=None)

Source SAP field in LLC header in an Ethernet frame.

Set the 2 byte value of an Source SAP at value.

class os_ken.lib.packet.bgp.FlowSpecNextHeader(operator, value, type_=None)

Next Header value in IPv6 packets

Set the IP protocol number at value

class os_ken.lib.packet.bgp.FlowSpecPacketLen(operator, value, type_=None)

Packet length for Flow Specification NLRI component

Set the total IP packet length at value.

class os_ken.lib.packet.bgp.FlowSpecPort(operator, value, type_=None)

Port number for Flow Specification NLRI component

Set the source or destination TCP/UDP ports at value.

class os_ken.lib.packet.bgp.FlowSpecSNAP(operator, value, type_=None)

Sub-Network Access Protocol field in an Ethernet frame.

Set the 5 byte SNAP field at value.

class os_ken.lib.packet.bgp.FlowSpecSourceMac(length, addr, type_=None)

Source Mac Address.

Set the Mac Address at value.

class os_ken.lib.packet.bgp.FlowSpecSrcPort(operator, value, type_=None)

Source port number for Flow Specification NLRI component

Set the source port of a TCP or UDP packet at value.

class os_ken.lib.packet.bgp.FlowSpecSrcPrefix(length, addr, type_=None)

Source Prefix for Flow Specification NLRI component

class os_ken.lib.packet.bgp.FlowSpecTCPFlags(operator, value, type_=None)

TCP flags for Flow Specification NLRI component

Supported TCP flags are CWR, ECN, URGENT, ACK, PUSH, RST, SYN and FIN.

class os_ken.lib.packet.bgp.FlowSpecVLANCoS(operator, value, type_=None)

VLAN CoS Fields in an Ethernet frame.

Set the 3 bit CoS field at value.

class os_ken.lib.packet.bgp.FlowSpecVLANID(operator, value, type_=None)

VLAN ID.

Set VLAN ID at value.

class os_ken.lib.packet.bgp.FlowSpecVPNv4NLRI(length=0, route_dist=None, rules=None)

Flow Specification NLRI class for VPNv4 [RFC 5575]

classmethod from_user(route_dist, **kwargs)

Utility method for creating a NLRI instance.

This function returns a NLRI instance from human readable format value.

Parameters:

Example:

>>> msg = bgp.FlowSpecIPv4NLRI.from_user(
...     route_dist='65000:1000',
...     dst_prefix='10.0.0.0/24',
...     src_prefix='20.0.0.1/24',
...     ip_proto=6,
...     port='80 | 8000',
...     dst_port='>9000 & <9050',
...     src_port='>=8500 & <=9000',
...     icmp_type=0,
...     icmp_code=6,
...     tcp_flags='SYN+ACK & !=URGENT',
...     packet_len=1000,
...     dscp='22 | 24',
...     fragment='LF | ==FF')
>>>
class os_ken.lib.packet.bgp.FlowSpecVPNv6NLRI(length=0, route_dist=None, rules=None)

Flow Specification NLRI class for VPNv6 [draft-ietf-idr-flow-spec-v6-08]

classmethod from_user(route_dist, **kwargs)

Utility method for creating a NLRI instance.

This function returns a NLRI instance from human readable format value.

Parameters:
exception os_ken.lib.packet.bgp.HoldTimerExpired(data='')

Error to indicate Hold Timer expired.

RFC says: If a system does not receive successive KEEPALIVE, UPDATE, and/or NOTIFICATION messages within the period specified in the Hold Time field of the OPEN message, then the NOTIFICATION message with the Hold Timer Expired Error Code is sent and the BGP connection is closed.

CODE = 4

BGP error code.

SUB_CODE = 1

BGP error sub-code.

exception os_ken.lib.packet.bgp.InvalidNetworkField(data='')
CODE = 3

BGP error code.

SUB_CODE = 10

BGP error sub-code.

exception os_ken.lib.packet.bgp.InvalidNextHop(data='')
CODE = 3

BGP error code.

SUB_CODE = 8

BGP error sub-code.

exception os_ken.lib.packet.bgp.InvalidOriginError(data='')

Error indicates undefined Origin attribute value.

RFC says: If the ORIGIN attribute has an undefined value, then the Error Sub- code MUST be set to Invalid Origin Attribute. The Data field MUST contain the unrecognized attribute (type, length, and value).

CODE = 3

BGP error code.

SUB_CODE = 6

BGP error sub-code.

exception os_ken.lib.packet.bgp.MalformedAsPath(data='')

Error to indicate if AP_PATH attribute is syntactically incorrect.

RFC says: The AS_PATH attribute is checked for syntactic correctness. If the path is syntactically incorrect, then the Error Subcode MUST be set to Malformed AS_PATH.

CODE = 3

BGP error code.

SUB_CODE = 11

BGP error sub-code.

exception os_ken.lib.packet.bgp.MalformedAttrList(data='')

Error to indicate UPDATE message is malformed.

RFC says: Error checking of an UPDATE message begins by examining the path attributes. If the Withdrawn Routes Length or Total Attribute Length is too large (i.e., if Withdrawn Routes Length + Total Attribute Length + 23 exceeds the message Length), then the Error Subcode MUST be set to Malformed Attribute List.

CODE = 3

BGP error code.

SUB_CODE = 1

BGP error sub-code.

exception os_ken.lib.packet.bgp.MalformedOptionalParam(data='')

If recognized optional parameters are malformed.

RFC says: If one of the Optional Parameters in the OPEN message is recognized, but is malformed, then the Error Subcode MUST be set to 0 (Unspecific).

CODE = 2

BGP error code.

SUB_CODE = 0

BGP error sub-code.

exception os_ken.lib.packet.bgp.MaxPrefixReached(data='')
CODE = 6

BGP error code.

SUB_CODE = 1

BGP error sub-code.

exception os_ken.lib.packet.bgp.MissingWellKnown(pattr_type_code)

Error to indicate missing well-known attribute.

RFC says: If any of the well-known mandatory attributes are not present, then the Error Subcode MUST be set to Missing Well-known Attribute. The Data field MUST contain the Attribute Type Code of the missing, well-known attribute.

CODE = 3

BGP error code.

SUB_CODE = 3

BGP error sub-code.

exception os_ken.lib.packet.bgp.NotSync(data='')
CODE = 1

BGP error code.

SUB_CODE = 1

BGP error sub-code.

exception os_ken.lib.packet.bgp.OptAttrError(data='')

Error indicates Optional Attribute is malformed.

RFC says: If an optional attribute is recognized, then the value of this attribute MUST be checked. If an error is detected, the attribute MUST be discarded, and the Error Subcode MUST be set to Optional Attribute Error. The Data field MUST contain the attribute (type, length, and value).

CODE = 3

BGP error code.

SUB_CODE = 9

BGP error sub-code.

exception os_ken.lib.packet.bgp.OtherConfChange(data='')
CODE = 6

BGP error code.

SUB_CODE = 6

BGP error sub-code.

exception os_ken.lib.packet.bgp.OutOfResource(data='')
CODE = 6

BGP error code.

SUB_CODE = 8

BGP error sub-code.

exception os_ken.lib.packet.bgp.PeerDeConfig(data='')
CODE = 6

BGP error code.

SUB_CODE = 3

BGP error sub-code.

class os_ken.lib.packet.bgp.PmsiTunnelIdUnknown(value)

Unknown route type specific _PmsiTunnelId

class os_ken.lib.packet.bgp.RouteTargetMembershipNLRI(origin_as, route_target)

Route Target Membership NLRI.

Route Target membership NLRI is advertised in BGP UPDATE messages using the MP_REACH_NLRI and MP_UNREACH_NLRI attributes.

exception os_ken.lib.packet.bgp.RoutingLoop(data='')
CODE = 3

BGP error code.

SUB_CODE = 7

BGP error sub-code.

class os_ken.lib.packet.bgp.StreamParser

Streaming parser for BGP-4 messages.

This is a subclass of os_ken.lib.packet.stream_parser.StreamParser. Its parse method returns a list of BGPMessage subclass instances.

try_parse(data)

Try to extract a message from the given bytes.

This is an override point for subclasses.

This method tries to extract a message from bytes given by the argument.

Raises TooSmallException if the given data is not enough to extract a complete message but there's still a chance to extract a message if more data is come later.

exception os_ken.lib.packet.bgp.UnRegWellKnowAttr(data='')
CODE = 3

BGP error code.

SUB_CODE = 2

BGP error sub-code.

exception os_ken.lib.packet.bgp.UnacceptableHoldTime(data='')

Error to indicate Unacceptable Hold Time in open message.

RFC says: If the Hold Time field of the OPEN message is unacceptable, then the Error Subcode MUST be set to Unacceptable Hold Time.

CODE = 2

BGP error code.

SUB_CODE = 6

BGP error sub-code.

exception os_ken.lib.packet.bgp.UnsupportedOptParam(data='')

Error to indicate unsupported optional parameters.

RFC says: If one of the Optional Parameters in the OPEN message is not recognized, then the Error Subcode MUST be set to Unsupported Optional Parameters.

CODE = 2

BGP error code.

SUB_CODE = 4

BGP error sub-code.

exception os_ken.lib.packet.bgp.UnsupportedVersion(locally_support_version)

Error to indicate unsupport bgp version number.

RFC says: If the version number in the Version field of the received OPEN message is not supported, then the Error Subcode MUST be set to Unsupported Version Number. The Data field is a 2-octet unsigned integer, which indicates the largest, locally-supported version number less than the version the remote BGP peer bid (as indicated in the received OPEN message), or if the smallest, locally-supported version number is greater than the version the remote BGP peer bid, then the smallest, locally- supported version number.

CODE = 2

BGP error code.

SUB_CODE = 1

BGP error sub-code.