Date: Wed, 26 Jan 2000 13:04:42 +0800 (+0800) From: Michael Robinson <robinson@netrinsics.com> To: archie@whistle.com, sh@eclipse.net.uk Cc: freebsd-security@freebsd.org, robinson@netrinsics.com Subject: Re: tcpdump Message-ID: <200001260504.NAA49214@netrinsics.com> In-Reply-To: <200001252153.NAA66515@bubba.whistle.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Archie Cobbs <archie@whistle.com> writes:
>So.. how do you get tcpdump to spit forth ascii?
This works for me:
------------------------------------
u_char template[]=
"\n\t \0";
u_char hex[] = "0123456789ABCDEF";
/*
* By default, print the packet out in hex.
*
* (BTW, please don't send us patches to print the packet out in ascii)
*/
void
default_print(register const u_char *bp, register u_int length)
{
u_char buffer[62], c;
u_int i=0, o, p;
while (i < length) {
o = i % 16;
if (o == 0) {
if (i > 0)
fputs(buffer, stdout);
bcopy(template, buffer, 62);
}
c = bp[i++];
p = 2 + o*2 + (o/2);
buffer[p++] = hex[(c & 0xF0)>>4];
buffer[p++] = hex[c & 0x0F];
if (c >= ' ' && c <= '~') {
buffer[o+45] = c;
} else {
buffer[o+45] = '.';
}
}
if (i % 16) {
fputs(buffer, stdout);
}
}
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-security" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200001260504.NAA49214>
