python_lldp - python LLDP Packet sniffer.

python_lldp – python LLDP Packet sniffer.

python_lldp is a python LLDP Packet sniffer.
With Function; eth_protocol, eth_payload = unpack_ethernet_frame(packet):
#[0] at the end of the unpack is because of the tuple returnvalue
#!H unpacks as an unsigned short, which has a size of two bytes, which is what we need because the TLV “header” is 9 and 7 bits long (2bytes)
#The right bitshift by 9 bits shifts away the length part of the TLV, leaving us with the TLV Type
#The bitmask gives us the length of the real payload by masking the first 7 bits with a 0000000111111111 mask (0x01ff in hex)
#tlv_TotalPayload is the 3rd-Nth byte of the TLV Frame
#tlv_TotalPayload: we need to add +2 bytes because the address space changes when we cut off the header ( see page 24)
#if tlvtype is 4 then datafield must start at 0 because of the payload structure for Port Descriptions (see IEEE PDF)

Download :  | Clone Url
Source :