/[LeafOK_CVS]/pvpgn-1.7.4/scripts/reform.awk
ViewVC logotype

Contents of /pvpgn-1.7.4/scripts/reform.awk

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (show annotations) (vendor branch)
Tue Jun 6 03:41:37 2006 UTC (19 years, 9 months ago) by sysadm
Branch: GNU, MAIN
CVS Tags: arelease, HEAD
Changes since 1.1: +0 -0 lines
no message

1 #!/usr/bin/awk -f
2
3 # This file converts tcpdump output into a hexdump with
4 # ASCII strings on the right. It replaces packet headers
5 # with "*"s to reduce visual noise.
6 #
7 # Use it like:
8 # tcpdump -s 2000 -x [<filter options>] | reform.awk
9 # To save a dump:
10 # tcpdump -s 2000 -w dumpfile
11 # To replay it:
12 # tcpdump -x -s 2000 -r dumpfile | reform.awk
13
14
15 function hexvalue(nybble) {
16 if (nybble=="0") { return 0; }
17 if (nybble=="1") { return 1; }
18 if (nybble=="2") { return 2; }
19 if (nybble=="3") { return 3; }
20 if (nybble=="4") { return 4; }
21 if (nybble=="5") { return 5; }
22 if (nybble=="6") { return 6; }
23 if (nybble=="7") { return 7; }
24 if (nybble=="8") { return 8; }
25 if (nybble=="9") { return 9; }
26 if (nybble=="a") { return 10; }
27 if (nybble=="b") { return 11; }
28 if (nybble=="c") { return 12; }
29 if (nybble=="d") { return 13; }
30 if (nybble=="e") { return 14; }
31 if (nybble=="f") { return 15; }
32 }
33
34
35 # ab67 483d cac9 08ca 3efb 35f8 9406 36e8
36 {
37 if (substr($0,1,1)=="\t") {
38 printf(" ");
39 str = "";
40 for (i=1; i<=NF; i++) {
41 nybble1 = substr($(i),1,1);
42 nybble2 = substr($(i),2,1);
43 byte1 = 16*hexvalue(nybble1)+hexvalue(nybble2);
44 if (headerleft) {
45 headerleft--;
46 printf("** ");
47 str = str " ";
48 } else {
49 printf("%02X ",byte1);
50 if (byte1<32 || byte1>126) {
51 str = str ".";
52 } else {
53 str = str sprintf("%c",0+byte1);
54 }
55 }
56
57 nybble3 = substr($(i),3,1);
58 nybble4 = substr($(i),4,1);
59 if (nybble3=="" && nybble4=="") {
60 printf(" ");
61 } else {
62 byte2 = 16*hexvalue(nybble3)+hexvalue(nybble4);
63 if (headerleft) {
64 headerleft--;
65 printf("** ");
66 str = str " ";
67 } else {
68 printf("%02X ",byte2);
69 if (byte2<32 || byte2>126) {
70 str = str ".";
71 } else {
72 str = str sprintf("%c",0+byte2);
73 }
74 }
75 }
76 if (i==4) {
77 printf(" ");
78 }
79 }
80 for (; i<=8; i++) {
81 if (i==4) {
82 printf(" ");
83 }
84 printf(" ");
85 }
86 printf(" %s\n",str);
87 } else {
88 printf("%s\n",$0);
89 headerleft = 40;
90 }
91 }
92

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1