From owner-freebsd-security Tue Jan 25 21: 5:52 2000 Delivered-To: freebsd-security@freebsd.org Received: from public.bta.net.cn (public.bta.net.cn [202.96.0.97]) by hub.freebsd.org (Postfix) with ESMTP id 7939215089 for ; Tue, 25 Jan 2000 21:04:25 -0800 (PST) (envelope-from robinson@netrinsics.com) Received: from netrinsics.com (gj-06-112.bta.net.cn [202.106.6.112]) by public.bta.net.cn (8.9.3/8.9.3) with ESMTP id NAA06951 for ; Wed, 26 Jan 2000 13:04:09 +0800 (CST) Received: (from robinson@localhost) by netrinsics.com (8.9.3/8.9.3) id NAA49214; Wed, 26 Jan 2000 13:04:42 +0800 (+0800) (envelope-from robinson) Date: Wed, 26 Jan 2000 13:04:42 +0800 (+0800) From: Michael Robinson Message-Id: <200001260504.NAA49214@netrinsics.com> To: archie@whistle.com, sh@eclipse.net.uk Subject: Re: tcpdump Cc: freebsd-security@freebsd.org, robinson@netrinsics.com In-Reply-To: <200001252153.NAA66515@bubba.whistle.com> Sender: owner-freebsd-security@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org Archie Cobbs 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