A packet decoder/encoder class.
An instance is used to either decode or encode a single packet.
data is a bytearray to describe a raw datagram to decode. When decoding, a Packet object is iteratable. Iterated values are protocol (ethernet, ipv4, ...) headers and the payload. Protocol headers are instances of subclass of packet_base.PacketBase. The payload is a bytearray. They are iterated in on-wire order.
data should be omitted when encoding a packet.
Register a protocol proto for this packet.
This method is legal only when encoding a packet.
When encoding a packet, register a protocol (ethernet, ipv4, ...) header to add to this packet. Protocol headers should be registered in on-wire order before calling self.serialize.
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. |
Returns the firstly found protocol that matches to the specified protocol.
Returns a list of protocols that matches to the specified protocol.
Encode a packet and store the resulted bytearray in self.data.
This method is legal only when encoding a packet.
Streaming parser base class.
An instance of a subclass of this class is used to extract messages from a raw byte stream.
It's designed to be used for data read from a transport which doesn't preserve message boundaries. A typical example of such a transport is TCP.
Tries to extract messages from a raw byte stream.
The data argument would be python bytes newly read from the input stream.
Returns an ordered list of extracted messages. It can be an empty list.
The rest of data which doesn't produce a complete message is kept internally and will be used when more data is come. I.e. next time this method is called again.
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.
List of the sub-classes:
AdminReset
AdminShutdown
AttrFlagError
AttrLenError
AuthFailure
BGPEvpnEsImportRTExtendedCommunityBGPEvpnEsiLabelExtendedCommunityBGPEvpnMacMobilityExtendedCommunityBGPFlowSpecRedirectCommunityBGPFlowSpecTPIDActionCommunityBGPFlowSpecTrafficActionCommunityBGPFlowSpecTrafficMarkingCommunityBGPFlowSpecTrafficRateCommunityBGPFlowSpecVlanActionCommunityBGPKeepAlive
BGPMessage
BGPNotification
BGPOpen
BGPPathAttributePmsiTunnel
BGPRouteRefresh
BGPUpdate
BadBgpId
BadLen
BadMsg
BadNotification
BadPeerAs
BgpExc
CollisionResolution
ConnRejected
EvpnASBasedEsiEvpnArbitraryEsiEvpnEsiEvpnEthernetAutoDiscoveryNLRIEvpnEthernetSegmentNLRIEvpnInclusiveMulticastEthernetTagNLRIEvpnIpPrefixNLRIEvpnL2BridgeEsiEvpnLACPEsiEvpnMacBasedEsiEvpnMacIPAdvertisementNLRIEvpnNLRIEvpnRouterIDEsiEvpnUnknownEsiEvpnUnknownNLRIFiniteStateMachineError
FlowSpecComponentUnknownFlowSpecDSCPFlowSpecDestPortFlowSpecDestPrefixFlowSpecDestinationMacFlowSpecEtherTypeFlowSpecFragmentFlowSpecIPProtocolFlowSpecIPv4NLRI
FlowSpecIPv6DestPrefixFlowSpecIPv6FlowLabelFlowSpecIPv6FragmentFlowSpecIPv6NLRI
FlowSpecIPv6SrcPrefixFlowSpecIcmpCodeFlowSpecIcmpTypeFlowSpecInnerVLANCoSFlowSpecInnerVLANIDFlowSpecL2VPNNLRI
FlowSpecLLCControlFlowSpecLLCDSAPFlowSpecLLCSSAPFlowSpecNextHeaderFlowSpecPacketLenFlowSpecPortFlowSpecSNAPFlowSpecSourceMacFlowSpecSrcPortFlowSpecSrcPrefixFlowSpecTCPFlagsFlowSpecVLANCoSFlowSpecVLANIDFlowSpecVPNv4NLRI
FlowSpecVPNv6NLRI
HoldTimerExpired
InvalidNetworkField
InvalidNextHop
InvalidOriginError
MalformedAsPath
MalformedAttrList
MalformedOptionalParam
MaxPrefixReached
MissingWellKnown
NotSync
OptAttrError
OtherConfChange
OutOfResource
PeerDeConfig
PmsiTunnelIdUnknownRouteTargetMembershipNLRIRoutingLoop
StreamParser
UnRegWellKnowAttr
UnacceptableHoldTime
UnsupportedOptParam
UnsupportedVersion
cause_cookie_while_shutdowncause_invalid_paramcause_invalid_stream_idcause_missing_paramcause_no_userdatacause_out_of_resourcecause_protocol_violationcause_restart_with_new_addrcause_stale_cookiecause_unrecognized_chunkcause_unrecognized_paramcause_unresolvable_addrcause_user_initiated_abortchunk_abortchunk_cookie_ackchunk_cookie_echochunk_cwrchunk_datachunk_ecn_echochunk_errorchunk_heartbeatchunk_heartbeat_ackchunk_initchunk_init_ackchunk_sackchunk_shutdownchunk_shutdown_ackchunk_shutdown_completeparam_cookie_preserveparam_ecnparam_heartbeatparam_host_addrparam_ipv4param_ipv6param_state_cookieparam_supported_addrparam_unrecognized_paramsctp
InterfaceLinkParamsNextHopBlackholeNextHopIFIndexNextHopIFNameNextHopIPv4NextHopIPv4IFIndexNextHopIPv4IFNameNextHopIPv6NextHopIPv6IFIndexNextHopIPv6IFNameRegisteredNexthopZebraBfdClientRegisterZebraBfdDestinationDeregisterZebraBfdDestinationRegisterZebraBfdDestinationReplyZebraBfdDestinationUpdateZebraHelloZebraIPv4ImportLookupZebraIPv4NexthopAddZebraIPv4NexthopDeleteZebraIPv4NexthopLookupZebraIPv4NexthopLookupMRibZebraIPv4RouteAddZebraIPv4RouteDeleteZebraIPv4RouteIPv6NexthopAddZebraIPv6ImportLookupZebraIPv6NexthopAddZebraIPv6NexthopDeleteZebraIPv6NexthopLookupZebraIPv6RouteAddZebraIPv6RouteDeleteZebraImportCheckUpdateZebraImportRouteRegisterZebraImportRouteUnregisterZebraInterfaceAddZebraInterfaceAddressAddZebraInterfaceAddressDeleteZebraInterfaceBfdDestinationUpdateZebraInterfaceDeleteZebraInterfaceDisableRadvZebraInterfaceDownZebraInterfaceEnableRadvZebraInterfaceLinkParamsZebraInterfaceNbrAddressAddZebraInterfaceNbrAddressDeleteZebraInterfaceUpZebraInterfaceVrfUpdateZebraMessage
ZebraMplsLabelsAddZebraMplsLabelsDeleteZebraNexthopRegisterZebraNexthopUnregisterZebraNexthopUpdateZebraRedistributeAddZebraRedistributeDefaultAddZebraRedistributeDefaultDeleteZebraRedistributeDeleteZebraRedistributeIPv4AddZebraRedistributeIPv4DeleteZebraRedistributeIPv6AddZebraRedistributeIPv6DeleteZebraRouterIDAddZebraRouterIDDeleteZebraRouterIDUpdateZebraUnknownMessageZebraVrfAddZebraVrfDeleteZebraVrfUnregisterzebra
Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.