msantos / pkt

Erlang network protocol library
http://blog.listincomprehension.com/search/label/epcap
BSD 3-Clause "New" or "Revised" License
150 stars 44 forks source link

Handle unknown LLDP PDUs gracefully #52

Closed vasu-dasari closed 5 years ago

vasu-dasari commented 5 years ago

When an unknown TLV is received, whose type does not match any of the ones that are currently handled, even though the PDU is good, pkt_lldp crashes as such a packet is not handled. Wireshark shows that packet as unknown TLV. Doing the same here.

shun159 commented 5 years ago

Hi @vasu-dasari !

If you don't mind, could you give me the LLDP packet? Please let me check how it works, just in case.

vasu-dasari commented 5 years ago

Hi @shun159

Here is the packet stream that can cause the problem. I wish there is a way of attaching pcap file :(

0000   01 80 c2 00 00 0e ca e1 f8 79 9b 82 88 cc 02 07
0010   04 72 71 fe 9b 8e 4d 04 03 02 00 02 06 02 00 78
0020   fe 0c 00 26 e1 00 00 00 72 71 fe 9b 8e 4d 18 08
0030   06 8f 10 aa 74 d7 9a 16 e6 01 01 fe 0c 00 26 e1
0040   01 00 00 00 00 15 10 f9 f4 00 00
shun159 commented 5 years ago

Thanks @vasu-dasari!

I confirmed that how this PR works, looks very good :smile: Could you add some test code?

vasu-dasari commented 5 years ago

@shun159 Added unit test to test new functionality.

shun159 commented 5 years ago

@vasu-dasari LGTM, thank you!