Merge git://github.com/the-tcpdump-group/tcpdump

This commit is contained in:
Guy Harris 2014-08-14 17:21:09 -07:00
commit 2456fb746c

View File

@ -40,7 +40,8 @@
static const char tstr[] = "[|cdp]";
#define CDP_HEADER_LEN 4
#define CDP_HEADER_LEN 4
#define CDP_HEADER_OFFSET 2
static const struct tok cdp_tlv_values[] = {
{ 0x01, "Device-ID"},
@ -99,14 +100,14 @@ cdp_print(netdissect_options *ndo,
ND_TCHECK2(*tptr, CDP_HEADER_LEN);
ND_PRINT((ndo, "CDPv%u, ttl: %us", *tptr, *(tptr + 1)));
if (ndo->ndo_vflag)
ND_PRINT((ndo, ", checksum: %u (unverified), length %u", EXTRACT_16BITS(tptr), length));
ND_PRINT((ndo, ", checksum: 0x%04x (unverified), length %u", EXTRACT_16BITS(tptr+CDP_HEADER_OFFSET), length));
tptr += CDP_HEADER_LEN;
while (tptr < (pptr+length)) {
ND_TCHECK2(*tptr, 4); /* read out Type and Length */
ND_TCHECK2(*tptr, CDP_HEADER_LEN); /* read out Type and Length */
type = EXTRACT_16BITS(tptr);
len = EXTRACT_16BITS(tptr+2); /* object length includes the 4 bytes header length */
if (len < 4) {
len = EXTRACT_16BITS(tptr+CDP_HEADER_OFFSET); /* object length includes the 4 bytes header length */
if (len < CDP_HEADER_LEN) {
if (ndo->ndo_vflag)
ND_PRINT((ndo, "\n\t%s (0x%02x), length: %u byte%s (too short)",
tok2str(cdp_tlv_values,"unknown field type", type),
@ -119,8 +120,8 @@ cdp_print(netdissect_options *ndo,
len));
break;
}
tptr += 4;
len -= 4;
tptr += CDP_HEADER_LEN;
len -= CDP_HEADER_LEN;
ND_TCHECK2(*tptr, len);
@ -176,15 +177,15 @@ cdp_print(netdissect_options *ndo,
break;
case 0x08: /* Protocol Hello Option - not documented */
break;
case 0x09: /* VTP Mgmt Domain - not documented */
case 0x09: /* VTP Mgmt Domain - CDPv2 */
ND_PRINT((ndo, "'"));
fn_printn(ndo, tptr, len, NULL);
ND_PRINT((ndo, "'"));
break;
case 0x0a: /* Native VLAN ID - not documented */
case 0x0a: /* Native VLAN ID - CDPv2 */
ND_PRINT((ndo, "%d", EXTRACT_16BITS(tptr)));
break;
case 0x0b: /* Duplex - not documented */
case 0x0b: /* Duplex - CDPv2 */
ND_PRINT((ndo, "%s", *(tptr) ? "full": "half"));
break;