#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-cdp.c,v 1.24 2004-03-24 05:59:16 guy Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-cdp.c,v 1.25 2004-10-07 14:53:11 hannes Exp $";
#endif
#ifdef HAVE_CONFIG_H
#include "interface.h"
#include "addrtoname.h"
#include "extract.h" /* must come after interface.h */
+#include "nlpid.h"
#define CDP_HEADER_LEN 4
tok2str(cdp_tlv_values,"unknown field type", type),
type,
len,
- len>1 ? "s" : ""); /* plural */
+ PLURAL_SUFFIX(len)); /* plural */
switch (type) {
case 0x01: /* Device-ID */
if (!vflag)
- printf(", Device-ID '%.*s'", len, tptr);
- else
- printf("'%.*s'", len, tptr);
+ printf(", Device-ID ");
+ printf("'");
+ fn_printn(tptr, len, NULL);
+ printf("'");
break;
case 0x02: /* Address */
if (cdp_print_addr(tptr, len) < 0)
goto trunc;
break;
case 0x03: /* Port-ID */
- printf("'%.*s'", len, tptr);
+ printf("'");
+ fn_printn(tptr, len, NULL);
+ printf("'");
break;
case 0x04: /* Capabilities */
printf("(0x%08x): %s",
}
break;
case 0x06: /* Platform */
- printf("'%.*s'", len, tptr);
+ printf("'");
+ fn_printn(tptr, len, NULL);
+ printf("'");
break;
case 0x07: /* Prefixes */
if (cdp_print_prefixes(tptr, len) < 0)
case 0x08: /* Protocol Hello Option - not documented */
break;
case 0x09: /* VTP Mgmt Domain - not documented */
- printf("'%.*s'", len,tptr);
+ printf("'");
+ fn_printn(tptr, len, NULL);
+ printf("'");
break;
case 0x0a: /* Native VLAN ID - not documented */
printf("%d",EXTRACT_16BITS(tptr));
printf("0x%02x", *(tptr));
break;
case 0x14: /* System Name - not documented */
- printf("'%.*s'", len, tptr);
+ printf("'");
+ fn_printn(tptr, len, NULL);
+ printf("'");
break;
case 0x16: /* System Object ID - not documented */
if (cdp_print_addr(tptr, len) < 0)
goto trunc;
break;
case 0x17: /* Physical Location - not documented */
- printf("0x%02x/%.*s", *(tptr), len - 1, tptr + 1 );
+ printf("0x%02x", *(tptr));
+ if (len > 1) {
+ printf("/");
+ fn_printn(tptr + 1, len - 1, NULL);
+ }
break;
default:
print_unknown_data(tptr,"\n\t ",len);
goto trunc;
al = EXTRACT_16BITS(&p[pl]); /* address length */
- if (pt == PT_NLPID && pl == 1 && *p == 0xcc && al == 4) {
+ if (pt == PT_NLPID && pl == 1 && *p == NLPID_IP && al == 4) {
/*
* IPv4: protocol type = NLPID, protocol length = 1
* (1-byte NLPID), protocol = 0xcc (NLPID for IPv4),