scapy.contrib.bgp

BGP (Border Gateway Protocol).

class scapy.contrib.bgp.ASPathSegmentPacketListField(name: str, default: Optional[List[BasePacket]], pkt_cls: Optional[Union[Callable[[bytes], Packet], Type[Packet]]]  # noqa: E501 = None, count_from: Optional[Callable[[Packet], int]] = None, length_from: Optional[Callable[[Packet], int]] = None, next_cls_cb: Optional[Callable[[Packet, List[BasePacket], Optional[Packet], bytes], Type[Packet]]]  # noqa: E501 = None, max_count: Optional[int] = None)[源代码]

基类:PacketListField

PacketListField handling AS_PATH segments.

getfield(pkt, s)[源代码]
class scapy.contrib.bgp.BGP(_pkt, /)[源代码]

基类:Packet

Every BGP message inherits from this class.

KEEPALIVE_TYPE = 4
NOTIFICATION_TYPE = 3
OPEN_TYPE = 1
ROUTEREFRESH_TYPE = 5
UPDATE_TYPE = 2
aliastypes
classmethod dispatch_hook(_pkt=None, *args, **kargs)[源代码]

Returns the right class for the given data.

guess_payload_class(p)[源代码]
class scapy.contrib.bgp.BGPAuthenticationInformation(_pkt, /, *, authentication_code=0, authentication_data=None)[源代码]

基类:Packet

Provides an implementation of the Authentication Information optional parameter, which is now obsolete. References: RFC 1771, RFC 1654, RFC 4271

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|AUTHENTICATION |      AUTHENTICATION DATA      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                Fig. BGPAuthenticationInformation                 
BGPAuthenticationInformation fields

authentication_code

ByteField

0

authentication_data

StrField

None

class scapy.contrib.bgp.BGPCapFourBytesASN(_pkt, /, *, code=65, length=4, asn=0)[源代码]

基类:BGPCapability

This class provides an implementation of the 4-octet AS number capability. References: RFC 4893

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|      CODE     |     LENGTH    |              ASN              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                     Fig. BGPCapFourBytesASN                      
BGPCapFourBytesASN fields

code

ByteEnumField

65

length

ByteField

4

asn

IntField

0

match_subclass = True
class scapy.contrib.bgp.BGPCapGeneric(_pkt, /, *, code=0, length=None, cap_data=b'')[源代码]

基类:BGPCapability

This class provides an implementation of a generic capability.

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|      CODE     |     LENGTH    |            CAP DATA           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                        Fig. BGPCapGeneric                        
BGPCapGeneric fields

code

ByteEnumField

0

length

FieldLenField

None

cap_data

StrLenField

b''

match_subclass = True
class scapy.contrib.bgp.BGPCapGracefulRestart(_pkt, /, *, code=64, length=None, restart_flags=0, restart_time=0, entries=[])[源代码]

基类:BGPCapability

This class provides an implementation of the Graceful Restart capability. References: RFC 4724

class GRTuple(_pkt, /, *, afi=0, safi=0, flags=0)[源代码]

基类:Packet

Tuple <AFI, SAFI, Flags for address family>

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|              AFI              |      SAFI     |     FLAGS     |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                           Fig. GRTuple                           
GRTuple fields

afi

ShortEnumField

0

safi

ByteEnumField

0

flags

ByteEnumField

0

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|      CODE     |     LENGTH    |RESTART|      RESTART TIME     |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|            ENTRIES            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                    Fig. BGPCapGracefulRestart                    
BGPCapGracefulRestart fields

code

ByteEnumField

64

length

ByteField

None

restart_flags

BitField (4 bits)

0

restart_time

BitField (12 bits)

0

entries

PacketListField

[]

match_subclass = True
class scapy.contrib.bgp.BGPCapMultiprotocol(_pkt, /, *, code=1, length=4, afi=0, reserved=0, safi=0)[源代码]

基类:BGPCapability

This class provides an implementation of the Multiprotocol capability. References: RFC 4760

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|      CODE     |     LENGTH    |              AFI              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|    RESERVED   |      SAFI     |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                     Fig. BGPCapMultiprotocol                     
BGPCapMultiprotocol fields

code

ByteEnumField

1

length

ByteField

4

afi

ShortEnumField

0

reserved

ByteField

0

safi

ByteEnumField

0

match_subclass = True
class scapy.contrib.bgp.BGPCapORF(_pkt, /, *, code=3, length=None, orf=[])[源代码]

基类:BGPCapability

This class provides an implementation of the Outbound Route Filtering capability. References: RFC 5291

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|      CODE     |     LENGTH    |              ORF              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                          Fig. BGPCapORF                          
BGPCapORF fields

code

ByteEnumField

3

length

ByteField

None

orf

BGPCapORFBlockPacketListField

[]

match_subclass = True
class scapy.contrib.bgp.BGPCapORFBlock(_pkt, /, *, afi=0, reserved=0, safi=0, orf_number=None, entries=[])[源代码]

基类:Packet

The "ORFBlock" is made of <AFI, rsvd, SAFI, Number of ORFs, and <ORF Type, Send/Receive> entries.

class ORFTuple(_pkt, /, *, orf_type=0, send_receive=0)[源代码]

基类:Packet

Packet handling <ORF Types, Send/Receive> tuples.

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|    ORF TYPE   |  SEND RECEIVE |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                          Fig. ORFTuple                           
ORFTuple fields

orf_type

ByteEnumField

0

send_receive

ByteEnumField

0

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|              AFI              |    RESERVED   |      SAFI     |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|   ORF NUMBER  |            ENTRIES            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                       Fig. BGPCapORFBlock                        
BGPCapORFBlock fields

afi

ShortEnumField

0

reserved

ByteField

0

safi

ByteEnumField

0

orf_number

FieldLenField

None

entries

PacketListField

[]

post_build(p, pay)[源代码]
class scapy.contrib.bgp.BGPCapORFBlockPacketListField(name: str, default: Optional[List[BasePacket]], pkt_cls: Optional[Union[Callable[[bytes], Packet], Type[Packet]]]  # noqa: E501 = None, count_from: Optional[Callable[[Packet], int]] = None, length_from: Optional[Callable[[Packet], int]] = None, next_cls_cb: Optional[Callable[[Packet, List[BasePacket], Optional[Packet], bytes], Type[Packet]]]  # noqa: E501 = None, max_count: Optional[int] = None)[源代码]

基类:PacketListField

Handles lists of BGPCapORFBlocks.

getfield(pkt, s)[源代码]
class scapy.contrib.bgp.BGPCapability(_pkt, /)[源代码]

基类:Packet

Generic BGP capability.

aliastypes
classmethod dispatch_hook(_pkt=None, *args, **kargs)[源代码]

Returns the right class for the given data.

post_build(p, pay)[源代码]
pre_dissect(s)[源代码]

Check that the payload is long enough (at least 2 bytes).

class scapy.contrib.bgp.BGPConf[源代码]

基类:ConfClass

BGP module configuration.

use_2_bytes_asn = True
class scapy.contrib.bgp.BGPFieldIPv4(name: str, default: Any, fmt: str = 'H')[源代码]

基类:Field

IPv4 Field (CIDR)

addfield(pkt, s, val)[源代码]
getfield(pkt, s)[源代码]
h2i(pkt, h)[源代码]

x.x.x.x/y to "internal" representation.

i2h(pkt, i)[源代码]

"Internal" representation to "human" representation (x.x.x.x/y).

i2len(pkt, i)[源代码]
i2m(pkt, i)[源代码]

"Internal" (IP as bytes, mask as int) to "machine" representation.

i2repr(pkt, i)[源代码]
m2i(pkt, m)[源代码]
mask2iplen(mask)[源代码]

Get the IP field mask length (in bytes).

class scapy.contrib.bgp.BGPFieldIPv6(name: str, default: Any, fmt: str = 'H')[源代码]

基类:Field

IPv6 Field (CIDR)

addfield(pkt, s, val)[源代码]
getfield(pkt, s)[源代码]
h2i(pkt, h)[源代码]

x.x.x.x/y to internal representation.

i2h(pkt, i)[源代码]

"Internal" representation to "human" representation.

i2len(pkt, i)[源代码]
i2m(pkt, i)[源代码]

"Internal" (IP as bytes, mask as int) to "machine" representation.

i2repr(pkt, i)[源代码]
m2i(pkt, m)[源代码]
mask2iplen(mask)[源代码]

Get the IP field mask length (in bytes).

class scapy.contrib.bgp.BGPHeader(_pkt, /, *, marker=340282366920938463463374607431768211455, len=None, type=4)[源代码]

基类:Packet

The header of any BGP message. References: RFC 4271

aliastypes
classmethod dispatch_hook(_pkt=None, *args, **kargs)[源代码]

Returns the right class for the given data.

fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                             MARKER                            |
+                                                               +
|                                                               |
+                                                               +
|                                                               |
+                                                               +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|              LEN              |      TYPE     |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                          Fig. BGPHeader                          
BGPHeader fields

marker

XBitField (128 bits)

340282366920938463463374607431768211455

len

ShortField

None

type

ByteEnumField

4

guess_payload_class(payload)[源代码]
payload_guess

Possible sublayers: BGPKeepAlive, BGPNotification, BGPOpen, BGPRouteRefresh, BGPUpdate

post_build(p, pay)[源代码]
class scapy.contrib.bgp.BGPKeepAlive(_pkt, /, *, marker=340282366920938463463374607431768211455, len=None, type=4)[源代码]

基类:BGP, BGPHeader

KEEPALIVE message.

aliastypes
class scapy.contrib.bgp.BGPNLRIPacketListField(name, default, ip_mode, **kwargs)[源代码]

基类:PacketListField

PacketListField handling NLRI fields.

cls_group
getfield(pkt, s)[源代码]
max_bit_length
no_length
class scapy.contrib.bgp.BGPNLRI_IPv4(_pkt, /, *, prefix=(0, '0.0.0.0'))[源代码]

基类:Packet

Packet handling IPv4 NLRI fields.

aliastypes
default_payload_class(payload)[源代码]
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             PREFIX            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                        Fig. BGPNLRI_IPv4                         
BGPNLRI_IPv4 fields

prefix

BGPFieldIPv4

(0, '0.0.0.0')

class scapy.contrib.bgp.BGPNLRI_IPv4_AP(_pkt, /, *, nlri_path_id=0, prefix=(0, '0.0.0.0'))[源代码]

基类:BGPNLRI_IPv4

Packet handling IPv4 NLRI fields WITH BGP ADDITIONAL PATH

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                          NLRI PATH ID                         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             PREFIX            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                       Fig. BGPNLRI_IPv4_AP                       
BGPNLRI_IPv4_AP fields

nlri_path_id

IntField

0

prefix

BGPFieldIPv4

(0, '0.0.0.0')

class scapy.contrib.bgp.BGPNLRI_IPv6(_pkt, /, *, prefix=(0, '::'))[源代码]

基类:Packet

Packet handling IPv6 NLRI fields.

aliastypes
default_payload_class(payload)[源代码]
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             PREFIX            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                        Fig. BGPNLRI_IPv6                         
BGPNLRI_IPv6 fields

prefix

BGPFieldIPv6

(0, '::')

class scapy.contrib.bgp.BGPNLRI_IPv6_AP(_pkt, /, *, nlri_path_id=0, prefix=(0, '::'))[源代码]

基类:BGPNLRI_IPv6

Packet handling IPv6 NLRI fields WITH BGP ADDITIONAL PATH

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                          NLRI PATH ID                         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             PREFIX            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                       Fig. BGPNLRI_IPv6_AP                       
BGPNLRI_IPv6_AP fields

nlri_path_id

IntField

0

prefix

BGPFieldIPv6

(0, '::')

class scapy.contrib.bgp.BGPNotification(_pkt, /, *, error_code=0, error_subcode=0, data=None)[源代码]

基类:BGP

NOTIFICATION messages end a BGP session. References: RFC 4271

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|   ERROR CODE  | ERROR SUBCODE |              DATA             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                       Fig. BGPNotification                       
BGPNotification fields

error_code

ByteEnumField

0

error_subcode

MultiEnumField (Depends on 0)

0

data

StrField

None

class scapy.contrib.bgp.BGPORF(_pkt, /, *, when_to_refresh=0, orf_type=0, orf_len=None, entries=[])[源代码]

基类:Packet

Provides an implementation of ORFs carried in the RR message. References: RFC 5291

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|WHEN TO REFRESH|    ORF TYPE   |            ORF LEN            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|            ENTRIES            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                           Fig. BGPORF                            
BGPORF fields

when_to_refresh

ByteEnumField

0

orf_type

ByteEnumField

0

orf_len

FieldLenField

None

entries

BGPORFEntryPacketListField

[]

class scapy.contrib.bgp.BGPORFAddressPrefix(_pkt, /, *, action=0, match=0, reserved=0, sequence=0, min_len=0, max_len=0, prefix=b'')[源代码]

基类:BGPORFEntry

Provides an implementation of the Address Prefix ORF (RFC 5292).

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|ACT|M| RESERVED|                    SEQUENCE                   |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               |    MIN LEN    |    MAX LEN    |     PREFIX    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               |
+-+-+-+-+-+-+-+-+

                     Fig. BGPORFAddressPrefix                     
BGPORFAddressPrefix fields

action

BitEnumField

0

match

BitEnumField

0

reserved

BitField (5 bits)

0

sequence

IntField

0

min_len

ByteField

0

max_len

ByteField

0

prefix

_ORFNLRIPacketField

b''

class scapy.contrib.bgp.BGPORFCoveringPrefix(_pkt, /, *, action=0, match=0, reserved=0, sequence=0, min_len=0, max_len=0, rt=0, import_rt=0, route_type=0, host_addr=None)[源代码]

基类:BGPORFEntry

Provides an implementation of the CP-ORF (RFC 7543).

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|ACT|M| RESERVED|                    SEQUENCE                   |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               |    MIN LEN    |    MAX LEN    |       RT      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+               +
|                                                               |
+                                               +-+-+-+-+-+-+-+-+
|                                               |   IMPORT RT   |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+               +
|                                                               |
+                                               +-+-+-+-+-+-+-+-+
|                                               |   ROUTE TYPE  |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|           HOST ADDR           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                    Fig. BGPORFCoveringPrefix                     
BGPORFCoveringPrefix fields

action

BitEnumField

0

match

BitEnumField

0

reserved

BitField (5 bits)

0

sequence

IntField

0

min_len

ByteField

0

max_len

ByteField

0

rt

LongField

0

import_rt

LongField

0

route_type

ByteField

0

host_addr

PacketField

None

class scapy.contrib.bgp.BGPORFEntry(_pkt, /, *, action=0, match=0, reserved=0, value=b'')[源代码]

基类:Packet

Provides an implementation of an ORF entry. References: RFC 5291

afi
aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|ACT|M| RESERVED|             VALUE             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                         Fig. BGPORFEntry                         
BGPORFEntry fields

action

BitEnumField

0

match

BitEnumField

0

reserved

BitField (5 bits)

0

value

StrField

b''

safi
class scapy.contrib.bgp.BGPORFEntryPacketListField(name: str, default: Optional[List[BasePacket]], pkt_cls: Optional[Union[Callable[[bytes], Packet], Type[Packet]]]  # noqa: E501 = None, count_from: Optional[Callable[[Packet], int]] = None, length_from: Optional[Callable[[Packet], int]] = None, next_cls_cb: Optional[Callable[[Packet, List[BasePacket], Optional[Packet], bytes], Type[Packet]]]  # noqa: E501 = None, max_count: Optional[int] = None)[源代码]

基类:PacketListField

PacketListField handling the ORF entries.

getfield(pkt, s)[源代码]
m2i(pkt, m)[源代码]
class scapy.contrib.bgp.BGPOpen(_pkt, /, *, version=4, my_as=0, hold_time=0, bgp_id='0.0.0.0', opt_param_len=None, opt_params=[])[源代码]

基类:BGP

OPEN messages are exchanged in order to open a new BGP session. References: RFC 4271

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|    VERSION    |             MY AS             |   HOLD TIME   |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               |                     BGP ID                    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               | OPT PARAM LEN |           OPT PARAMS          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                           Fig. BGPOpen                           
BGPOpen fields

version

ByteField

4

my_as

ShortField

0

hold_time

ShortField

0

bgp_id

IPField

'0.0.0.0'

opt_param_len

FieldLenField

None

opt_params

BGPOptParamPacketListField

[]

post_build(p, pay)[源代码]
class scapy.contrib.bgp.BGPOptParam(_pkt, /, *, param_type=2, param_length=None, param_value=None, authentication_data=None)[源代码]

基类:Packet

Provides an implementation the OPEN message optional parameters. References: RFC 4271

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|   PARAM TYPE  |  PARAM LENGTH |          PARAM VALUE          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|      AUTHENTICATION DATA      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                         Fig. BGPOptParam                         
BGPOptParam fields

param_type

ByteEnumField

2

param_length

ByteField

None

param_value

PacketField (Cond)

None

authentication_data

PacketField (Cond)

None

post_build(p, pay)[源代码]
class scapy.contrib.bgp.BGPOptParamPacketListField(name: str, default: Optional[List[BasePacket]], pkt_cls: Optional[Union[Callable[[bytes], Packet], Type[Packet]]]  # noqa: E501 = None, count_from: Optional[Callable[[Packet], int]] = None, length_from: Optional[Callable[[Packet], int]] = None, next_cls_cb: Optional[Callable[[Packet, List[BasePacket], Optional[Packet], bytes], Type[Packet]]]  # noqa: E501 = None, max_count: Optional[int] = None)[源代码]

基类:PacketListField

PacketListField handling the optional parameters (OPEN message).

getfield(pkt, s)[源代码]
class scapy.contrib.bgp.BGPPAAS4Aggregator(_pkt, /, *, aggregator_asn=0, speaker_address='0.0.0.0')[源代码]

基类:Packet

Provides an implementation of the AS4_AGGREGATOR attribute "value part". References: RFC 4893

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                         AGGREGATOR ASN                        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                        SPEAKER ADDRESS                        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                     Fig. BGPPAAS4Aggregator                      
BGPPAAS4Aggregator fields

aggregator_asn

IntField

0

speaker_address

IPField

'0.0.0.0'

class scapy.contrib.bgp.BGPPAAS4BytesPath(_pkt, /, *, segments=[])[源代码]

基类:Packet

Packet handling the AS_PATH attribute value (4 bytes ASNs, for new speakers -> ASNs are encoded as IntFields). References: RFC 4893

class ASPathSegment(_pkt, /, *, segment_type=2, segment_length=None, segment_value=[])[源代码]

基类:Packet

Provides an implementation for AS_PATH segments with 4 bytes ASNs.

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  SEGMENT TYPE | SEGMENT LENGTH|         SEGMENT VALUE         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                        Fig. ASPathSegment                        
ASPathSegment fields

segment_type

ByteEnumField

2

segment_length

ByteField

None

segment_value

FieldListField

[]

post_build(p, pay)[源代码]
aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|            SEGMENTS           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                      Fig. BGPPAAS4BytesPath                      
BGPPAAS4BytesPath fields

segments

ASPathSegmentPacketListField

[]

class scapy.contrib.bgp.BGPPAAS4Path(_pkt, /, *, segment_type=2, segment_length=None, segment_value=[])[源代码]

基类:Packet

Provides an implementation of the AS4_PATH attribute "value part". References: RFC 4893

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  SEGMENT TYPE | SEGMENT LENGTH|         SEGMENT VALUE         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                        Fig. BGPPAAS4Path                         
BGPPAAS4Path fields

segment_type

ByteEnumField

2

segment_length

ByteField

None

segment_value

FieldListField

[]

post_build(p, pay)[源代码]
class scapy.contrib.bgp.BGPPAASPath(_pkt, /, *, segments=[])[源代码]

基类:Packet

Packet handling the AS_PATH attribute value (2 bytes ASNs, for old speakers). References: RFC 4271, RFC 5065

class ASPathSegment(_pkt, /, *, segment_type=2, segment_length=None, segment_value=[])[源代码]

基类:Packet

Provides an implementation for AS_PATH segments with 2 bytes ASNs.

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  SEGMENT TYPE | SEGMENT LENGTH|         SEGMENT VALUE         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                        Fig. ASPathSegment                        
ASPathSegment fields

segment_type

ByteEnumField

2

segment_length

ByteField

None

segment_value

FieldListField

[]

post_build(p, pay)[源代码]
AS_TRANS = 23456
aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|            SEGMENTS           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                         Fig. BGPPAASPath                         
BGPPAASPath fields

segments

ASPathSegmentPacketListField

[]

class scapy.contrib.bgp.BGPPAAggregator(_pkt, /, *, aggregator_asn=0, speaker_address='0.0.0.0')[源代码]

基类:Packet

Packet handling the AGGREGATOR attribute value. References: RFC 4271

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|         AGGREGATOR ASN        |        SPEAKER ADDRESS        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                       Fig. BGPPAAggregator                       
BGPPAAggregator fields

aggregator_asn

ShortField

0

speaker_address

IPField

'0.0.0.0'

class scapy.contrib.bgp.BGPPAAtomicAggregate(_pkt, /)[源代码]

基类:Packet

Packet handling the ATOMIC_AGGREGATE attribute value. References: RFC 4271

aliastypes
class scapy.contrib.bgp.BGPPAClusterList(_pkt, /, *, cluster_list=[])[源代码]

基类:Packet

Packet handling the CLUSTER_LIST attribute value. References: RFC 4456

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|          CLUSTER LIST         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                      Fig. BGPPAClusterList                       
BGPPAClusterList fields

cluster_list

FieldListField

[]

class scapy.contrib.bgp.BGPPACommunity(_pkt, /, *, community=0)[源代码]

基类:Packet

Packet handling the COMMUNITIES attribute value. References: RFC 1997

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                           COMMUNITY                           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                       Fig. BGPPACommunity                        
BGPPACommunity fields

community

IntEnumField

0

class scapy.contrib.bgp.BGPPAExtCommFourOctetASSpecific(_pkt, /, *, global_administrator=0, local_administrator=0)[源代码]

基类:Packet

Packet handling the Four-Octet AS Specific Extended Community attribute value. References: RFC 5668

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                      GLOBAL ADMINISTRATOR                     |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|      LOCAL ADMINISTRATOR      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

               Fig. BGPPAExtCommFourOctetASSpecific               
BGPPAExtCommFourOctetASSpecific fields

global_administrator

IntField

0

local_administrator

ShortField

0

class scapy.contrib.bgp.BGPPAExtCommIPv4AddressSpecific(_pkt, /, *, global_administrator=0, local_administrator=0)[源代码]

基类:Packet

Packet handling the IPv4 Address Specific Extended Community attribute value. References: RFC 4360

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                      GLOBAL ADMINISTRATOR                     |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|      LOCAL ADMINISTRATOR      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

               Fig. BGPPAExtCommIPv4AddressSpecific               
BGPPAExtCommIPv4AddressSpecific fields

global_administrator

IntField

0

local_administrator

ShortField

0

class scapy.contrib.bgp.BGPPAExtCommOpaque(_pkt, /, *, value=b'')[源代码]

基类:Packet

Packet handling the Opaque Extended Community attribute value. References: RFC 4360

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                             VALUE                             |
+                               +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                     Fig. BGPPAExtCommOpaque                      
BGPPAExtCommOpaque fields

value

StrFixedLenField

b''

class scapy.contrib.bgp.BGPPAExtCommRedirectAS2Byte(_pkt, /, *, asn=0, value=0)[源代码]

基类:Packet

Packet handling the (FlowSpec) "redirect AS-2byte" extended community (RFC 7674). References: RFC 7674

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|              ASN              |             VALUE             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                 Fig. BGPPAExtCommRedirectAS2Byte                 
BGPPAExtCommRedirectAS2Byte fields

asn

ShortField

0

value

IntField

0

class scapy.contrib.bgp.BGPPAExtCommRedirectAS4Byte(_pkt, /, *, asn=0, value=0)[源代码]

基类:Packet

Packet handling the (FlowSpec) "redirect AS-4byte" extended community. (RFC 7674). References: RFC 7674

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                              ASN                              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             VALUE             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                 Fig. BGPPAExtCommRedirectAS4Byte                 
BGPPAExtCommRedirectAS4Byte fields

asn

IntField

0

value

ShortField

0

class scapy.contrib.bgp.BGPPAExtCommRedirectIPv4(_pkt, /, *, ip_addr=0, value=0)[源代码]

基类:Packet

Packet handling the (FlowSpec) "redirect IPv4" extended community. (RFC 7674). References: RFC 7674

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                            IP ADDR                            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             VALUE             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                  Fig. BGPPAExtCommRedirectIPv4                   
BGPPAExtCommRedirectIPv4 fields

ip_addr

IntField

0

value

ShortField

0

class scapy.contrib.bgp.BGPPAExtCommTrafficAction(_pkt, /, *, reserved=0, sample=0, terminal_action=0)[源代码]

基类:Packet

Packet handling the (FlowSpec) "traffic-action" extended community. References: RFC 5575

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                            RESERVED                           |
+                           +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                           |S|T|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                  Fig. BGPPAExtCommTrafficAction                  
BGPPAExtCommTrafficAction fields

reserved

BitField (46 bits)

0

sample

BitField (1 bit)

0

terminal_action

BitField (1 bit)

0

class scapy.contrib.bgp.BGPPAExtCommTrafficMarking(_pkt, /, *, dscp=48)[源代码]

基类:Packet

Packet handling the (FlowSpec) "traffic-marking" extended community. References: RFC 5575

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                              DSCP                             |
+                               +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                 Fig. BGPPAExtCommTrafficMarking                  
BGPPAExtCommTrafficMarking fields

dscp

BitEnumField

48

class scapy.contrib.bgp.BGPPAExtCommTrafficRate(_pkt, /, *, id=0, rate=0)[源代码]

基类:Packet

Packet handling the (FlowSpec) "traffic-rate" extended community. References: RFC 5575

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               ID              |              RATE             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                   Fig. BGPPAExtCommTrafficRate                   
BGPPAExtCommTrafficRate fields

id

ShortField

0

rate

IEEEFloatField

0

class scapy.contrib.bgp.BGPPAExtCommTwoOctetASSpecific(_pkt, /, *, global_administrator=0, local_administrator=0)[源代码]

基类:Packet

Packet handling the Two-Octet AS Specific Extended Community attribute value. References: RFC 4360

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|      GLOBAL ADMINISTRATOR     |      LOCAL ADMINISTRATOR      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

               Fig. BGPPAExtCommTwoOctetASSpecific                
BGPPAExtCommTwoOctetASSpecific fields

global_administrator

ShortField

0

local_administrator

IntField

0

class scapy.contrib.bgp.BGPPAExtComms(_pkt, /, *, extended_communities=[])[源代码]

基类:Packet

Packet handling the multiple extended communities.

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|      EXTENDED COMMUNITIES     |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                        Fig. BGPPAExtComms                        
BGPPAExtComms fields

extended_communities

_ExtCommsPacketListField

[]

class scapy.contrib.bgp.BGPPAExtCommunity(_pkt, /, *, type_high=0, type_low=None, value=None)[源代码]

基类:Packet

Provides an implementation of the Extended Communities attribute. References: RFC 4360

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|   TYPE HIGH   |    TYPE LOW   |             VALUE             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                      Fig. BGPPAExtCommunity                      
BGPPAExtCommunity fields

type_high

ByteEnumField

0

type_low

_TypeLowField

None

value

_ExtCommValuePacketField

None

post_build(p, pay)[源代码]
class scapy.contrib.bgp.BGPPAIPv6AddressSpecificExtComm(_pkt, /, *, global_administrator='::', local_administrator=0)[源代码]

基类:Packet

Provides an implementation of the IPv6 Address Specific Extended Community attribute. This attribute is not defined using the existing BGP Extended Community attribute (see the RFC 5701 excerpt below). References: RFC 5701

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                      GLOBAL ADMINISTRATOR                     |
+                                                               +
|                                                               |
+                                                               +
|                                                               |
+                                                               +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|      LOCAL ADMINISTRATOR      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

               Fig. BGPPAIPv6AddressSpecificExtComm               
BGPPAIPv6AddressSpecificExtComm fields

global_administrator

IP6Field

'::'

local_administrator

ShortField

0

class scapy.contrib.bgp.BGPPALocalPref(_pkt, /, *, local_pref=0)[源代码]

基类:Packet

Packet handling the LOCAL_PREF attribute value. References: RFC 4271

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                           LOCAL PREF                          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                       Fig. BGPPALocalPref                        
BGPPALocalPref fields

local_pref

IntField

0

class scapy.contrib.bgp.BGPPAMPReachNLRI(_pkt, /, *, afi=0, safi=0, nh_addr_len=0, nh_v4_addr='0.0.0.0', nh_v6_addr='::', nh_v6_global='::', nh_v6_link_local='::', reserved=0, nlri=[])[源代码]

基类:Packet

Packet handling the MP_REACH_NLRI attribute value, for non IPv6 AFI. References: RFC 4760

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|              AFI              |      SAFI     |  NH ADDR LEN  |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                           NH V4 ADDR                          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                           NH V6 ADDR                          |
+                                                               +
|                                                               |
+                                                               +
|                                                               |
+                                                               +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                          NH V6 GLOBAL                         |
+                                                               +
|                                                               |
+                                                               +
|                                                               |
+                                                               +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                        NH V6 LINK LOCAL                       |
+                                                               +
|                                                               |
+                                                               +
|                                                               |
+                                                               +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|    RESERVED   |              NLRI             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                      Fig. BGPPAMPReachNLRI                       
BGPPAMPReachNLRI fields

afi

ShortEnumField

0

safi

ByteEnumField

0

nh_addr_len

ByteField

0

nh_v4_addr

IPField (Cond)

'0.0.0.0'

nh_v6_addr

IP6Field (Cond)

'::'

nh_v6_global

IP6Field (Cond)

'::'

nh_v6_link_local

IP6Field (Cond)

'::'

reserved

ByteField

0

nlri

MPReachNLRIPacketListField

[]

post_build(p, pay)[源代码]
class scapy.contrib.bgp.BGPPAMPUnreachNLRI(_pkt, /, *, afi=0, safi=0, afi_safi_specific=None)[源代码]

基类:Packet

Packet handling the MP_UNREACH_NLRI attribute value, for non IPv6 AFI. References: RFC 4760

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|              AFI              |      SAFI     |AFI SAFI SPECIF|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               |
+-+-+-+-+-+-+-+-+

                     Fig. BGPPAMPUnreachNLRI                      
BGPPAMPUnreachNLRI fields

afi

ShortEnumField

0

safi

ByteEnumField

0

afi_safi_specific

MPUnreachNLRIPacketField

None

post_build(p, pay)[源代码]
class scapy.contrib.bgp.BGPPAMPUnreachNLRI_IPv6(_pkt, /, *, withdrawn_routes=[])[源代码]

基类:Packet

Packet handling the MP_UNREACH_NLRI attribute value, for IPv6 AFI.

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|        WITHDRAWN ROUTES       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                   Fig. BGPPAMPUnreachNLRI_IPv6                   
BGPPAMPUnreachNLRI_IPv6 fields

withdrawn_routes

BGPNLRIPacketListField

[]

class scapy.contrib.bgp.BGPPAMultiExitDisc(_pkt, /, *, med=0)[源代码]

基类:Packet

Packet handling the MULTI_EXIT_DISC attribute value. References: RFC 4271

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                              MED                              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                     Fig. BGPPAMultiExitDisc                      
BGPPAMultiExitDisc fields

med

IntField

0

class scapy.contrib.bgp.BGPPANextHop(_pkt, /, *, next_hop='0.0.0.0')[源代码]

基类:Packet

Packet handling the NEXT_HOP attribute value. References: RFC 4271

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                            NEXT HOP                           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                        Fig. BGPPANextHop                         
BGPPANextHop fields

next_hop

IPField

'0.0.0.0'

class scapy.contrib.bgp.BGPPAOrigin(_pkt, /, *, origin=0)[源代码]

基类:Packet

Packet handling the ORIGIN attribute value. References: RFC 4271

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|     ORIGIN    |
+-+-+-+-+-+-+-+-+

                         Fig. BGPPAOrigin                         
BGPPAOrigin fields

origin

ByteEnumField

0

class scapy.contrib.bgp.BGPPAOriginatorID(_pkt, /, *, originator_id='0.0.0.0')[源代码]

基类:Packet

Packet handling the ORIGINATOR_ID attribute value. References: RFC 4456

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                         ORIGINATOR ID                         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                      Fig. BGPPAOriginatorID                      
BGPPAOriginatorID fields

originator_id

IPField

'0.0.0.0'

class scapy.contrib.bgp.BGPPathAttr(_pkt, /, *, type_flags=<Flag 128 (Optional)>, type_code=0, attr_ext_len=None, attr_len=None, attribute=None)[源代码]

基类:Packet

Provides an implementation of the path attributes. References: RFC 4271

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|   TYPE FLAGS  |   TYPE CODE   |          ATTR EXT LEN         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|    ATTR LEN   |           ATTRIBUTE           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                         Fig. BGPPathAttr                         
BGPPathAttr fields

type_flags

FlagsField

<Flag 128 (Optional)>

type_code

ByteEnumField

0

attr_ext_len

ShortField (Cond)

None

attr_len

ByteField (Cond)

None

attribute

_PathAttrPacketField

None

post_build(p, pay)[源代码]
class scapy.contrib.bgp.BGPPathAttrPacketListField(name: str, default: Optional[List[BasePacket]], pkt_cls: Optional[Union[Callable[[bytes], Packet], Type[Packet]]]  # noqa: E501 = None, count_from: Optional[Callable[[Packet], int]] = None, length_from: Optional[Callable[[Packet], int]] = None, next_cls_cb: Optional[Callable[[Packet, List[BasePacket], Optional[Packet], bytes], Type[Packet]]]  # noqa: E501 = None, max_count: Optional[int] = None)[源代码]

基类:PacketListField

PacketListField handling the path attributes (UPDATE message).

getfield(pkt, s)[源代码]
class scapy.contrib.bgp.BGPRouteRefresh(_pkt, /, *, afi=1, subtype=0, safi=1, orf_data=b'')[源代码]

基类:BGP

Provides an implementation of the ROUTE-REFRESH message. References: RFC 2918, RFC 7313

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|              AFI              |    SUBTYPE    |      SAFI     |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|            ORF DATA           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                       Fig. BGPRouteRefresh                       
BGPRouteRefresh fields

afi

ShortEnumField

1

subtype

ByteEnumField

0

safi

ByteEnumField

1

orf_data

PacketField (Cond)

b''

class scapy.contrib.bgp.BGPUpdate(_pkt, /, *, withdrawn_routes_len=None, withdrawn_routes=[], path_attr_len=None, path_attr=[], nlri=[])[源代码]

基类:BGP

UPDATE messages allow peers to exchange routes. References: RFC 4271

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|      WITHDRAWN ROUTES LEN     |        WITHDRAWN ROUTES       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|         PATH ATTR LEN         |           PATH ATTR           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|              NLRI             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                          Fig. BGPUpdate                          
BGPUpdate fields

withdrawn_routes_len

FieldLenField

None

withdrawn_routes

BGPNLRIPacketListField

[]

path_attr_len

FieldLenField

None

path_attr

BGPPathAttrPacketListField

[]

nlri

BGPNLRIPacketListField

[]

post_build(p, pay)[源代码]
class scapy.contrib.bgp.MPReachNLRIPacketListField(name: str, default: Optional[List[BasePacket]], pkt_cls: Optional[Union[Callable[[bytes], Packet], Type[Packet]]]  # noqa: E501 = None, count_from: Optional[Callable[[Packet], int]] = None, length_from: Optional[Callable[[Packet], int]] = None, next_cls_cb: Optional[Callable[[Packet, List[BasePacket], Optional[Packet], bytes], Type[Packet]]]  # noqa: E501 = None, max_count: Optional[int] = None)[源代码]

基类:PacketListField

PacketListField handling the AFI specific part (except for the length of Next Hop Network Address field, which is not AFI specific) of the MP_REACH_NLRI attribute.

getfield(pkt, s)[源代码]
class scapy.contrib.bgp.MPUnreachNLRIPacketField(name: str, default: Optional[K], pkt_cls: Union[Callable[[bytes], Packet], Type[Packet]]  # noqa: E501)[源代码]

基类:PacketField

PacketField handling the AFI specific part of the MP_UNREACH_NLRI attribute.

m2i(pkt, m)[源代码]
scapy.contrib.bgp.detect_add_path_prefix46(s, max_bit_length)[源代码]

Detect IPv4/IPv6 prefixes conform to BGP Additional Path but NOT conform to standard BGP..

This is an adapted version of wireshark's detect_add_path_prefix46 https://github.com/wireshark/wireshark/blob/ed9e958a2ed506220fdab320738f1f96a3c2ffbb/epan/dissectors/packet-bgp.c#L2905 Kudos to them !

scapy.contrib.bgp.has_extended_length(flags)[源代码]

Used in BGPPathAttr to check if the extended-length flag is set.