scapy.contrib.lldp
LLDP - Link Layer Discovery Protocol
- author
Thomas Tannhaeuser, hecke@naberius.de
- description
This module provides Scapy layers for the LLDP protocol.
- normative references:
IEEE 802.1AB 2016 - LLDP protocol, topology and MIB description
- TODO
- organization specific TLV e.g. ProfiNet(see LLDPDUGenericOrganisationSpecific for a starting point)
Ignore everything after EndofLLDPDUTLV
- NOTES
you can find the layer configuration options at the end of this file
default configuration enforces standard conform:
- frame structure(ChassisIDTLV/PortIDTLV/TimeToLiveTLV/…)
multiplicity of TLVs (if given by the standard)
min sizes of strings used by the TLVs
conf.contribs[‘LLDP’].strict_mode_disable() -> disable strict mode
- class scapy.contrib.lldp.LLDPConfiguration[source]
Bases:
object
basic configuration for LLDP layer
- class scapy.contrib.lldp.LLDPDU(*args: Any, **kargs: Any)[source]
Bases:
scapy.packet.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
- 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', range(9, 126): 'reserved - future standardization', 127: 'organisation specific TLV'}
- aliastypes
- class scapy.contrib.lldp.LLDPDUChassisID(*args: Any, **kargs: Any)[source]
Bases:
scapy.contrib.lldp.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', range(8, 255): 'reserved'}
- 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
1
_length
BitFieldLenField
(9 bits)None
subtype
0
family
ByteField
(Cond)0
id
MultipleTypeField
(MACField, IPField, StrLenField)b''
- class scapy.contrib.lldp.LLDPDUEndOfLLDPDU(*args: Any, **kargs: Any)[source]
Bases:
scapy.contrib.lldp.LLDPDU
ieee 802.1ab-2016 - sec. 8.5.1 / p. 26
- 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 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. LLDPDUEndOfLLDPDU
LLDPDUEndOfLLDPDU fields _type
0
_length
BitField
(9 bits)0
- class scapy.contrib.lldp.LLDPDUGenericOrganisationSpecific(*args: Any, **kargs: Any)[source]
Bases:
scapy.contrib.lldp.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
127
_length
BitFieldLenField
(9 bits)None
org_code
0
subtype
0
data
b''
- class scapy.contrib.lldp.LLDPDUManagementAddress(*args: Any, **kargs: Any)[source]
Bases:
scapy.contrib.lldp.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
- 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'}
- 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
8
_length
BitFieldLenField
(9 bits)None
_management_address_string_length
BitFieldLenField
(8 bits)None
management_address_subtype
0
management_address
b''
interface_numbering_subtype
1
interface_number
BitField
(32 bits)0
_oid_string_length
BitFieldLenField
(8 bits)None
object_id
b''
- class scapy.contrib.lldp.LLDPDUPortDescription(*args: Any, **kargs: Any)[source]
Bases:
scapy.contrib.lldp.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
4
_length
BitFieldLenField
(9 bits)None
description
b''
- class scapy.contrib.lldp.LLDPDUPortID(*args: Any, **kargs: Any)[source]
Bases:
scapy.contrib.lldp.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', range(8, 255): 'reserved'}
- 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
2
_length
BitFieldLenField
(9 bits)None
subtype
0
family
ByteField
(Cond)0
id
MultipleTypeField
(MACField, IPField, StrLenField)b''
- class scapy.contrib.lldp.LLDPDUSystemCapabilities(*args: Any, **kargs: Any)[source]
Bases:
scapy.contrib.lldp.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
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(*args: Any, **kargs: Any)[source]
Bases:
scapy.contrib.lldp.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
6
_length
BitFieldLenField
(9 bits)None
description
b''
- class scapy.contrib.lldp.LLDPDUSystemName(*args: Any, **kargs: Any)[source]
Bases:
scapy.contrib.lldp.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
5
_length
BitFieldLenField
(9 bits)None
system_name
b''
- class scapy.contrib.lldp.LLDPDUTimeToLive(*args: Any, **kargs: Any)[source]
Bases:
scapy.contrib.lldp.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
3
_length
BitField
(9 bits)2
ttl
20
- exception scapy.contrib.lldp.LLDPInvalidFrameStructure[source]
Bases:
scapy.error.Scapy_Exception
basic frame structure not standard conform (missing TLV, invalid order or multiplicity)
- exception scapy.contrib.lldp.LLDPInvalidLengthField[source]
Bases:
scapy.error.Scapy_Exception
invalid value of length field
- exception scapy.contrib.lldp.LLDPInvalidTLVCount[source]
Bases:
scapy.error.Scapy_Exception
invalid number of entries for a specific TLV type
- exception scapy.contrib.lldp.LLDPMissingLowerLayer[source]
Bases:
scapy.error.Scapy_Exception
first layer below first LLDPDU must be Ethernet or Dot1q