]> The Tcpdump Group git mirrors - tcpdump/commit
CDP: Modernize packet parsing style.
authorDenis Ovsienko <[email protected]>
Tue, 8 Dec 2020 23:50:23 +0000 (23:50 +0000)
committerDenis Ovsienko <[email protected]>
Tue, 8 Dec 2020 23:50:23 +0000 (23:50 +0000)
commit4350892475ad3a3405745fb3a71084eb45e4dc3a
treebad05e733bb399d4e4e1b2fd09668ac6cfcfefb3
parente44c0f19ba704f31bac7c4c0f466f81592b0a091
CDP: Modernize packet parsing style.

Enable ND_LONGJMP_FROM_TCHECK. Remove many redundant ND_TCHECK*()
instances. Report invalid packets as invalid with a reason, not
truncated. Test whether the invalid packet is entirely in the buffer.

Remove redundant and add plenty of new length checks. Reduce scope for
some variables. Consistently decrement length when advancing the current
pointer. Resort to ND_TCHECK_LEN() only when there are no better ways to
test the packet buffer space.

Do not pass caplen to cdp_print() and remove an improvised snapshot end
guard. Move TLV type-specific code from cdp_print() into standalone
small functions and upgrade a TLV name lookup table into a more
developed TLV registry table along the lines of what was done for
OpenFlow.

In cdp_print_addr() instead of comparing pointers test the address
counter only and trust the loop to do the length checks.

Replace cdp_get_number() with GET_*() macros.

Rewrite the code to make it easier to follow and make indentation more
consistent while at it.

Remove a stray CDP case block from print-chdlc.c.
netdissect.h
print-cdp.c
print-chdlc.c
print-llc.c