scapy.contrib.lldp

class scapy.contrib.lldp.LLDPConfiguration[源代码]

基类:object

basic configuration for LLDP layer

strict_mode()[源代码]

get current strict mode state

strict_mode_disable()[源代码]

disable strict mode and dissector debugging

strict_mode_enable()[源代码]

enable strict mode and dissector debugging

class scapy.contrib.lldp.LLDPDU(_pkt, /)[源代码]

基类:Packet

base class for all LLDP data units

DOT1Q_HEADER_LEN = 4
ETHER_FRAME_MIN_LEN = 64
ETHER_FSC_LEN = 4
ETHER_HEADER_LEN = 14
IANA_ADDRESS_FAMILY_NUMBERS = {0: 'other', 1: 'IPv4', 2: 'IPv6', 3: 'NSAP', 4: 'HDLC', 5: 'BBN', 6: '802', 7: 'E.163', 8: 'E.164', 9: 'F.69', 10: 'X.121', 11: 'IPX', 12: 'Appletalk', 13: 'Decnet IV', 14: 'Banyan Vines', 15: 'E.164 with NSAP', 16: 'DNS', 17: 'Distinguished Name', 18: 'AS Number', 19: 'XTP over IPv4', 20: 'XTP over IPv6', 21: 'XTP native mode XTP', 22: 'Fiber Channel World-Wide Port Name', 23: 'Fiber Channel World-Wide Node Name', 24: 'GWID', 25: 'AFI for L2VPN', 26: 'MPLS-TP Section Endpoint ID', 27: 'MPLS-TP LSP Endpoint ID', 28: 'MPLS-TP Pseudowire Endpoint ID', 29: 'MT IP Multi-Topology IPv4', 30: 'MT IP Multi-Topology IPv6'}
LAYER_MULTIPLICITIES = {}
LAYER_STACK = []
TYPES = {0: 'end of LLDPDU', 1: 'chassis id', 2: 'port id', 3: 'time to live', 4: 'port description', 5: 'system name', 6: 'system description', 7: 'system capabilities', 8: 'management address', 127: 'organisation specific TLV'}
aliastypes
dissection_done(pkt)[源代码]
do_build()[源代码]
guess_payload_class(payload)[源代码]
post_build(pkt, pay)[源代码]
post_dissect(s)[源代码]
pre_dissect(s)[源代码]
class scapy.contrib.lldp.LLDPDUChassisID(_pkt, /, *, _type=1, _length=None, subtype=0, family=0, id=None)[源代码]

基类:LLDPDU

ieee 802.1ab-2016 - sec. 8.5.2 / p. 26

LLDP_CHASSIS_ID_TLV_SUBTYPES = {0: 'reserved', 1: 'chassis component', 2: 'interface alias', 3: 'port component', 4: 'MAC address', 5: 'network address', 6: 'interface name', 7: 'locally assigned'}
SUBTYPE_CHASSIS_COMPONENT = 1
SUBTYPE_INTERFACE_ALIAS = 2
SUBTYPE_INTERFACE_NAME = 6
SUBTYPE_LOCALLY_ASSIGNED = 7
SUBTYPE_MAC_ADDRESS = 4
SUBTYPE_NETWORK_ADDRESS = 5
SUBTYPE_PORT_COMPONENT = 3
SUBTYPE_RESERVED = 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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|     TYPE    |      LENGTH     |    SUBTYPE    |     FAMILY    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               ID              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                       Fig. LLDPDUChassisID                       
LLDPDUChassisID fields

_type

BitEnumField

1

_length

BitFieldLenField (9 bits)

None

subtype

ByteEnumField

0

family

ByteEnumField (Cond)

0

id

MultipleTypeField (MACField, IPField, IP6Field, StrLenField)

b''

class scapy.contrib.lldp.LLDPDUEndOfLLDPDU(_pkt, /, *, _type=0, _length=0)[源代码]

基类:LLDPDU

ieee 802.1ab-2016 - sec. 8.5.1 / p. 26

aliastypes
extract_padding(s)[源代码]
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    |      LENGTH     |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                      Fig. LLDPDUEndOfLLDPDU                      
LLDPDUEndOfLLDPDU fields

_type

BitEnumField

0

_length

BitField (9 bits)

0

class scapy.contrib.lldp.LLDPDUGenericOrganisationSpecific(_pkt, /, *, _type=127, _length=None, org_code=0, subtype=0, data=b'')[源代码]

基类:LLDPDU

ORG_UNIQUE_CODES = {3791: 'PROFIBUS International (PNO)', 4623: 'IEEE 802.3', 4795: 'TIA TR-41 Committee . Media Endpoint Discovery', 32962: 'IEEE 802.1', 3191318: 'Hytec Geraetebau GmbH'}
ORG_UNIQUE_CODE_HYTEC = 3191318
ORG_UNIQUE_CODE_IEEE_802_1 = 32962
ORG_UNIQUE_CODE_IEEE_802_3 = 4623
ORG_UNIQUE_CODE_PNO = 3791
ORG_UNIQUE_CODE_TIA_TR_41_MED = 4795
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    |      LENGTH     |            ORG CODE           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                               |    SUBTYPE    |      DATA     |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               |
+-+-+-+-+-+-+-+-+

              Fig. LLDPDUGenericOrganisationSpecific              
LLDPDUGenericOrganisationSpecific fields

_type

BitEnumField

127

_length

BitFieldLenField (9 bits)

None

org_code

ThreeBytesEnumField

0

subtype

ByteField

0

data

XStrLenField

b''

class scapy.contrib.lldp.LLDPDUManagementAddress(_pkt, /, *, _type=8, _length=None, _management_address_string_length=None, management_address_subtype=0, management_address=b'', interface_numbering_subtype=1, interface_number=0, _oid_string_length=None, object_id=b'')[源代码]

基类:LLDPDU

ieee 802.1ab-2016 - sec. 8.5.9 / p. 32

currently only 0x00..0x1e are used by standards, no way to use anything > 0xff as management address subtype is only one octet wide

see https://www.iana.org/assignments/address-family-numbers/address-family-numbers.xhtml # noqa: E501

INTERFACE_NUMBERING_SUBTYPES = {1: 'unknown', 2: 'ifIndex', 3: 'system port number'}
SUBTYPE_INTERFACE_NUMBER_IF_INDEX = 2
SUBTYPE_INTERFACE_NUMBER_SYSTEM_PORT_NUMBER = 3

Note - calculation of _length field:

_length = 1@_management_address_string_length +
          1@management_address_subtype +
          management_address.len +
          1@interface_numbering_subtype +
          4@interface_number +
          1@_oid_string_length +
          object_id.len
SUBTYPE_INTERFACE_NUMBER_UNKNOWN = 1
SUBTYPE_MANAGEMENT_ADDRESS_802 = 6
SUBTYPE_MANAGEMENT_ADDRESS_AFI_FOR_L2VPN = 25
SUBTYPE_MANAGEMENT_ADDRESS_APPLETALK = 12
SUBTYPE_MANAGEMENT_ADDRESS_AS_NUMBER = 18
SUBTYPE_MANAGEMENT_ADDRESS_BANYAN_VINES = 14
SUBTYPE_MANAGEMENT_ADDRESS_BBN = 5
SUBTYPE_MANAGEMENT_ADDRESS_DECNET_IV = 13
SUBTYPE_MANAGEMENT_ADDRESS_DISTINGUISHED_NAME = 17
SUBTYPE_MANAGEMENT_ADDRESS_DNS = 16
SUBTYPE_MANAGEMENT_ADDRESS_E_163 = 7
SUBTYPE_MANAGEMENT_ADDRESS_E_164 = 8
SUBTYPE_MANAGEMENT_ADDRESS_E_164_WITH_NSAP = 15
SUBTYPE_MANAGEMENT_ADDRESS_FIBER_CHANNEL_WORLD_WIDE_NODE_NAME = 23
SUBTYPE_MANAGEMENT_ADDRESS_FIBER_CHANNEL_WORLD_WIDE_PORT_NAME = 22
SUBTYPE_MANAGEMENT_ADDRESS_F_69 = 9
SUBTYPE_MANAGEMENT_ADDRESS_GWID = 24
SUBTYPE_MANAGEMENT_ADDRESS_HDLC = 4
SUBTYPE_MANAGEMENT_ADDRESS_IPV4 = 1
SUBTYPE_MANAGEMENT_ADDRESS_IPV6 = 2
SUBTYPE_MANAGEMENT_ADDRESS_IPX = 11
SUBTYPE_MANAGEMENT_ADDRESS_MPLS_TP_LSP_ENDPOINT_ID = 27
SUBTYPE_MANAGEMENT_ADDRESS_MPLS_TP_PSEUDOWIRE_ENDPOINT_ID = 28
SUBTYPE_MANAGEMENT_ADDRESS_MPLS_TP_SECTION_ENDPOINT_ID = 26
SUBTYPE_MANAGEMENT_ADDRESS_MT_IP_MULTI_TOPOLOGY_IPV4 = 29
SUBTYPE_MANAGEMENT_ADDRESS_MT_IP_MULTI_TOPOLOGY_IPV6 = 30
SUBTYPE_MANAGEMENT_ADDRESS_NSAP = 3
SUBTYPE_MANAGEMENT_ADDRESS_OTHER = 0
SUBTYPE_MANAGEMENT_ADDRESS_XTP_NATIVE_MODE_XTP = 21
SUBTYPE_MANAGEMENT_ADDRESS_XTP_OVER_IPV4 = 19
SUBTYPE_MANAGEMENT_ADDRESS_XTP_OVER_IPV6 = 20
SUBTYPE_MANAGEMENT_ADDRESS_X_121 = 10
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    |      LENGTH     | MANAGEMENT ADD|MANAGEMENT ADDR|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|       MANAGEMENT ADDRESS      |INTERFACE NUMBE|INTERFACE NUMBE|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                               | OID STRING LEN|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|           OBJECT ID           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                   Fig. LLDPDUManagementAddress                   
LLDPDUManagementAddress fields

_type

BitEnumField

8

_length

BitFieldLenField (9 bits)

None

_management_address_string_length

BitFieldLenField (8 bits)

None

management_address_subtype

ByteEnumField

0

management_address

XStrLenField

b''

interface_numbering_subtype

ByteEnumField

1

interface_number

BitField (32 bits)

0

_oid_string_length

BitFieldLenField (8 bits)

None

object_id

XStrLenField

b''

class scapy.contrib.lldp.LLDPDUPortDescription(_pkt, /, *, _type=4, _length=None, description=b'')[源代码]

基类:LLDPDU

ieee 802.1ab-2016 - sec. 8.5.5 / p. 29

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    |      LENGTH     |          DESCRIPTION          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                    Fig. LLDPDUPortDescription                    
LLDPDUPortDescription fields

_type

BitEnumField

4

_length

BitFieldLenField (9 bits)

None

description

StrLenField

b''

class scapy.contrib.lldp.LLDPDUPortID(_pkt, /, *, _type=2, _length=None, subtype=0, family=0, id=None)[源代码]

基类:LLDPDU

ieee 802.1ab-2016 - sec. 8.5.3 / p. 26

LLDP_PORT_ID_TLV_SUBTYPES = {0: 'reserved', 1: 'interface alias', 2: 'port component', 3: 'MAC address', 4: 'network address', 5: 'interface name', 6: 'agent circuit ID', 7: 'locally assigned'}
SUBTYPE_AGENT_CIRCUIT_ID = 6
SUBTYPE_INTERFACE_ALIAS = 1
SUBTYPE_INTERFACE_NAME = 5
SUBTYPE_LOCALLY_ASSIGNED = 7
SUBTYPE_MAC_ADDRESS = 3
SUBTYPE_NETWORK_ADDRESS = 4
SUBTYPE_PORT_COMPONENT = 2
SUBTYPE_RESERVED = 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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|     TYPE    |      LENGTH     |    SUBTYPE    |     FAMILY    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               ID              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                        Fig. LLDPDUPortID                         
LLDPDUPortID fields

_type

BitEnumField

2

_length

BitFieldLenField (9 bits)

None

subtype

ByteEnumField

0

family

ByteEnumField (Cond)

0

id

MultipleTypeField (MACField, IPField, IP6Field, StrLenField)

b''

class scapy.contrib.lldp.LLDPDUSystemCapabilities(_pkt, /, *, _type=7, _length=4, reserved_5_available=0, reserved_4_available=0, reserved_3_available=0, reserved_2_available=0, reserved_1_available=0, two_port_mac_relay_available=0, s_vlan_component_available=0, c_vlan_component_available=0, station_only_available=0, docsis_cable_device_available=0, telephone_available=0, router_available=0, wlan_access_point_available=0, mac_bridge_available=0, repeater_available=0, other_available=0, reserved_5_enabled=0, reserved_4_enabled=0, reserved_3_enabled=0, reserved_2_enabled=0, reserved_1_enabled=0, two_port_mac_relay_enabled=0, s_vlan_component_enabled=0, c_vlan_component_enabled=0, station_only_enabled=0, docsis_cable_device_enabled=0, telephone_enabled=0, router_enabled=0, wlan_access_point_enabled=0, mac_bridge_enabled=0, repeater_enabled=0, other_enabled=0)[源代码]

基类:LLDPDU

ieee 802.1ab-2016 - sec. 8.5.8 / p. 31

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    |      LENGTH     |R|R|R|R|R|T|S|C|S|D|T|R|W|M|R|O|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|R|R|R|R|R|T|S|C|S|D|T|R|W|M|R|O|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                  Fig. LLDPDUSystemCapabilities                   
LLDPDUSystemCapabilities fields

_type

BitEnumField

7

_length

BitFieldLenField (9 bits)

4

reserved_5_available

BitField (1 bit)

0

reserved_4_available

BitField (1 bit)

0

reserved_3_available

BitField (1 bit)

0

reserved_2_available

BitField (1 bit)

0

reserved_1_available

BitField (1 bit)

0

two_port_mac_relay_available

BitField (1 bit)

0

s_vlan_component_available

BitField (1 bit)

0

c_vlan_component_available

BitField (1 bit)

0

station_only_available

BitField (1 bit)

0

docsis_cable_device_available

BitField (1 bit)

0

telephone_available

BitField (1 bit)

0

router_available

BitField (1 bit)

0

wlan_access_point_available

BitField (1 bit)

0

mac_bridge_available

BitField (1 bit)

0

repeater_available

BitField (1 bit)

0

other_available

BitField (1 bit)

0

reserved_5_enabled

BitField (1 bit)

0

reserved_4_enabled

BitField (1 bit)

0

reserved_3_enabled

BitField (1 bit)

0

reserved_2_enabled

BitField (1 bit)

0

reserved_1_enabled

BitField (1 bit)

0

two_port_mac_relay_enabled

BitField (1 bit)

0

s_vlan_component_enabled

BitField (1 bit)

0

c_vlan_component_enabled

BitField (1 bit)

0

station_only_enabled

BitField (1 bit)

0

docsis_cable_device_enabled

BitField (1 bit)

0

telephone_enabled

BitField (1 bit)

0

router_enabled

BitField (1 bit)

0

wlan_access_point_enabled

BitField (1 bit)

0

mac_bridge_enabled

BitField (1 bit)

0

repeater_enabled

BitField (1 bit)

0

other_enabled

BitField (1 bit)

0

class scapy.contrib.lldp.LLDPDUSystemDescription(_pkt, /, *, _type=6, _length=None, description=b'')[源代码]

基类:LLDPDU

ieee 802.1ab-2016 - sec. 8.5.7 / p. 31

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    |      LENGTH     |          DESCRIPTION          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                   Fig. LLDPDUSystemDescription                   
LLDPDUSystemDescription fields

_type

BitEnumField

6

_length

BitFieldLenField (9 bits)

None

description

StrLenField

b''

class scapy.contrib.lldp.LLDPDUSystemName(_pkt, /, *, _type=5, _length=None, system_name=b'')[源代码]

基类:LLDPDU

ieee 802.1ab-2016 - sec. 8.5.6 / p. 30

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    |      LENGTH     |          SYSTEM NAME          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                      Fig. LLDPDUSystemName                       
LLDPDUSystemName fields

_type

BitEnumField

5

_length

BitFieldLenField (9 bits)

None

system_name

StrLenField

b''

class scapy.contrib.lldp.LLDPDUTimeToLive(_pkt, /, *, _type=3, _length=2, ttl=20)[源代码]

基类:LLDPDU

ieee 802.1ab-2016 - sec. 8.5.4 / p. 29

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    |      LENGTH     |              TTL              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                      Fig. LLDPDUTimeToLive                       
LLDPDUTimeToLive fields

_type

BitEnumField

3

_length

BitField (9 bits)

2

ttl

ShortField

20

exception scapy.contrib.lldp.LLDPInvalidFrameStructure[源代码]

基类:Scapy_Exception

basic frame structure not standard conform (missing TLV, invalid order or multiplicity)

exception scapy.contrib.lldp.LLDPInvalidLengthField[源代码]

基类:Scapy_Exception

invalid value of length field

exception scapy.contrib.lldp.LLDPInvalidTLVCount[源代码]

基类:Scapy_Exception

invalid number of entries for a specific TLV type

exception scapy.contrib.lldp.LLDPMissingLowerLayer[源代码]

基类:Scapy_Exception

first layer below first LLDPDU must be Ethernet or Dot1q

class scapy.contrib.lldp.ThreeBytesEnumField(name, default, enum)[源代码]

基类:EnumField, ThreeBytesField