* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.217.2.3 2003-11-19 01:28:18 guy Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.217.2.4 2003-12-29 22:42:21 hannes Exp $ (LBL)
*/
#ifndef tcpdump_interface_h
#include <pcap.h>
extern int print_unknown_data(const u_char *, const char *,int);
-extern void ascii_print_with_offset(const u_char *, u_int, u_int);
-extern void ascii_print(const u_char *, u_int);
-extern void hex_print_with_offset(const u_char *, u_int, u_int);
+extern void ascii_print_with_offset(const u_char *, const u_char *, u_int, u_int);
+extern void ascii_print(const u_char *, const u_char *, u_int);
+extern void hex_print_with_offset(const u_char *, const u_char *, u_int, u_int);
extern void telnet_print(const u_char *, u_int);
-extern void hex_print(const u_char *, u_int);
+extern void hex_print(const u_char *, const u_char *, u_int);
extern int ether_encap_print(u_short, const u_char *, u_int, u_int, u_short *);
extern int llc_print(const u_char *, u_int, u_int, const u_char *,
const u_char *, u_short *);
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ascii.c,v 1.10.2.2 2003-11-16 08:51:11 guy Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ascii.c,v 1.10.2.3 2003-12-29 22:42:20 hannes Exp $";
#endif
#include <tcpdump-stdinc.h>
#include <stdio.h>
(HEXDUMP_HEXSTUFF_PER_SHORT * HEXDUMP_SHORTS_PER_LINE)
void
-ascii_print_with_offset(register const u_char *cp, register u_int length,
+ascii_print_with_offset(register const u_char *ident, register const u_char *cp, register u_int length,
register u_int oset)
{
register u_int i;
if (Aflag) {
(void)printf("%s", asciistuff);
} else {
- (void)printf("\n0x%04x\t%-*s\t%s",
- oset, HEXDUMP_HEXSTUFF_PER_LINE,
+ (void)printf("%s0x%04x: %-*s %s",
+ ident, oset, HEXDUMP_HEXSTUFF_PER_LINE,
hexstuff, asciistuff);
}
i = 0; hsp = hexstuff; asp = asciistuff;
if (i > 0) {
*hsp = *asp = '\0';
if (Aflag) {
- (void)printf("\n%s", asciistuff);
+ (void)printf("%s%s", ident, asciistuff);
} else {
- (void)printf("\n0x%04x\t%-*s\t%s",
- oset, HEXDUMP_HEXSTUFF_PER_LINE,
+ (void)printf("%s0x%04x: %-*s %s",
+ ident, oset, HEXDUMP_HEXSTUFF_PER_LINE,
hexstuff, asciistuff);
}
}
}
void
-ascii_print(register const u_char *cp, register u_int length)
+ascii_print(register const u_char *ident, register const u_char *cp, register u_int length)
{
- ascii_print_with_offset(cp, length, 0);
+ ascii_print_with_offset(ident, cp, length, 0);
}
/*
* telnet_print() wants this. It is essentially default_print_unaligned()
*/
void
-hex_print_with_offset(register const u_char *cp, register u_int length,
+hex_print_with_offset(register const u_char *ident, register const u_char *cp, register u_int length,
register u_int oset)
{
register u_int i, s;
i = 0;
while (--nshorts >= 0) {
if ((i++ % 8) == 0) {
- (void)printf("\n0x%04x\t", oset);
+ (void)printf("%s0x%04x: ", ident, oset);
oset += HEXDUMP_BYTES_PER_LINE;
}
s = *cp++;
}
if (length & 1) {
if ((i % 8) == 0)
- (void)printf("\n0x%04x\t", oset);
+ (void)printf("%s0x%04x: ", ident, oset);
(void)printf(" %02x", *cp);
}
}
* just for completeness
*/
void
-hex_print(register const u_char *cp, register u_int length)
+hex_print(register const u_char *ident, register const u_char *cp, register u_int length)
{
- hex_print_with_offset(cp, length, 0);
+ hex_print_with_offset(ident, cp, length, 0);
}
#ifdef MAIN
exit(0);
}
#endif /* MAIN */
+
+
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-cdp.c,v 1.19.2.2 2003-11-16 08:51:14 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-cdp.c,v 1.19.2.3 2003-12-29 22:42:22 hannes Exp $";
#endif
#ifdef HAVE_CONFIG_H
if (!TTEST2(*tptr, CDP_HEADER_LEN))
goto trunc;
- printf("CDP v%u, ttl: %us", *tptr, *(tptr+1));
+ printf("CDPv%u, ttl: %us", *tptr, *(tptr+1));
if (vflag)
- printf(", checksum: %u (unverified)", EXTRACT_16BITS(tptr));
+ printf(", checksum: %u (unverified), length %u", EXTRACT_16BITS(tptr), length);
tptr += CDP_HEADER_LEN;
while (tptr < (pptr+length)) {
break;
tptr = tptr+len;
}
+ if (vflag < 1)
+ printf(", length %u",caplen);
+
return;
trunc:
printf("[|cdp]");
*/
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.82.2.2 2003-11-16 08:51:20 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.82.2.3 2003-12-29 22:42:21 hannes Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
if (ntohs(ep->ether_type) <= ETHERMTU)
(void)printf(", 802.3");
else
- (void)printf(", ethertype %s",
- tok2str(ethertype_values,"0x%04x", ntohs(ep->ether_type)));
+ (void)printf(", ethertype %s (0x%04x)",
+ tok2str(ethertype_values,"Unknown", ntohs(ep->ether_type)),
+ ntohs(ep->ether_type));
+ } else {
+ if (ntohs(ep->ether_type) <= ETHERMTU)
+ (void)printf(", 802.3");
+ else
+ (void)printf(", %s", tok2str(ethertype_values,"Unknown Ethertype (0x%04x)", ntohs(ep->ether_type)));
}
(void)printf(", length %u: ", length);
if (!xflag && !qflag)
default_print(p, caplen);
- }
+ }
}
/*
return (1);
case ETHERTYPE_LOOPBACK:
- return (1);
+ return (0);
case ETHERTYPE_MPLS:
case ETHERTYPE_MPLS_MULTI:
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-telnet.c,v 1.21.2.2 2003-11-16 08:51:48 guy Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-telnet.c,v 1.21.2.3 2003-12-29 22:42:23 hannes Exp $";
#endif
#include <tcpdump-stdinc.h>
if (Xflag && 2 < vflag) {
if (first)
printf("\nTelnet:");
- hex_print_with_offset(sp, l, sp - osp);
+ hex_print_with_offset("\n", sp, l, sp - osp);
if (l > 8)
printf("\n\t\t\t\t");
else
"@(#) Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000\n\
The Regents of the University of California. All rights reserved.\n";
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.216.2.5 2003-12-18 01:22:57 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.216.2.6 2003-12-29 22:42:22 hannes Exp $ (LBL)";
#endif
/*
/*
* Include the link-layer header.
*/
- default_print_unaligned(sp, h->caplen);
+ default_print(sp, h->caplen);
} else {
/*
* Don't include the link-layer header - and if
* print nothing.
*/
if (h->caplen > hdrlen)
- default_print_unaligned(sp + hdrlen,
+ default_print(sp + hdrlen,
h->caplen - hdrlen);
}
}
info(0);
}
-/* Like default_print() but data need not be aligned */
-void
-default_print_unaligned(register const u_char *cp, register u_int length)
-{
- register u_int i, s;
- register int nshorts;
-
- if (Xflag) {
- ascii_print(cp, length);
- return;
- }
- nshorts = (u_int) length / sizeof(u_short);
- i = 0;
- while (--nshorts >= 0) {
- if ((i++ % 8) == 0)
- (void)printf("\n\t\t\t");
- s = *cp++;
- (void)printf(" %02x%02x", s, *cp++);
- }
- if (length & 1) {
- if ((i % 8) == 0)
- (void)printf("\n\t\t\t");
- (void)printf(" %02x", *cp);
- }
-}
-
#ifdef WIN32
/*
* XXX - there should really be libpcap calls to get the version
void
default_print(register const u_char *bp, register u_int length)
{
- default_print_unaligned(bp, length);
+ ascii_print("\n\t", bp, length); /* pass on lf and identation string */
}
#ifdef SIGINFO
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/util.c,v 1.87.2.2 2003-11-16 08:51:58 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/util.c,v 1.87.2.3 2003-12-29 22:42:23 hannes Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
*/
int
-print_unknown_data(const u_char *cp,const char *lf,int len)
+print_unknown_data(const u_char *cp,const char *ident,int len)
{
- int i;
-
- if (len ==0)
- return(0);
-
- printf("%s0x0000: ",lf);
- for(i=0;i<len;i++) {
- if (!TTEST2(*(cp+i), 1)) {
- printf("%spacket exceeded snapshot",lf);
- return(0);
- }
- printf("%02x",*(cp+i));
- if (i%2)
- printf(" ");
- if (i/16!=(i+1)/16) {
- if (i<(len-1))
- printf("%s0x%04x: ",lf,i+1);
- }
- }
+ hex_print(ident,cp,len);
return(1); /* everything is ok */
}