Mailinglist Archive: opensuse (4053 mails)

< Previous Next >
compiling this to add functions to Tcpdump
  • From: Raul Gutierrez Segales <oxford@xxxxxxxxxxxxxxxx>
  • Date: Thu, 9 Aug 2001 12:43:05 -0400 (PYT)
  • Message-id: <Pine.LNX.4.31.0108091239570.28005-300000@xxxxxxxxxxxxxxxxxxxxxxxxx>

I found this to files written in c to add to tcpdump so the -d switch
works. I alread have tcpdump installed from the cds. Should I uninstall it
and then install the tarball + the c code that I got?

Thanks,
Raúl


__________________________
Raul Gutierrez Segales
ICQ: 33158891
*** <B>tcpdump</B>-3.3/print-tcp.c Wed Dec 11 07:26:08 1996

--- <B>tcpdump</B>-3.3.local/print-tcp.c Fri Mar 14 10:28:38 1997

*************** tcp_print(register const u_char *bp, reg

*** 104,109 ****

--- 104,111 ----

register char ch;

u_short sport, dport, win, urp;

u_int32_t seq, ack;

+ char *dataptr;

+ int datalen;



tp = (struct tcphdr *)bp;

ip = (struct ip *)bp2;

*************** tcp_print(register const u_char *bp, reg

*** 127,132 ****

--- 129,149 ----



if (qflag) {

(void)printf(&quot;tcp %d&quot;, length - tp-&gt;th_off * 4);

+ dataptr=(char *) tp + tp-&gt;th_off * 4;

+ datalen=length-(tp-&gt;th_off * 4);

+ if (datalen&gt;0) {

+ char buf[300];

+ int x;

+ x=datalen;

+ if (x&gt;299) { x=299; }

+ strncpy(buf,dataptr,x);

+ buf[x]=0;

+ while (--x&gt;0) {

+ if ((buf[x]==13) || (buf[x]==10)) buf[x]='_';

+ if ((buf[x]&gt;128) || (buf[x]&lt;27)) buf[x]=0;

+ }

+ printf(&quot; {%s} &quot;,buf);

+ }

return;

}

if ((flags = tp-&gt;th_flags) &amp; (TH_SYN|TH_FIN|TH_RST|TH_PUSH)) {



----END PATCH FILE----





*** tcpdump.c.orig Wed Nov 26 15:49:43 1997

--- tcpdump.c Wed Nov 26 16:49:29 1997

***************

*** 62,67 ****

--- 62,68 ----

int xflag; /* print packet in hex */

int Oflag = 1; /* run filter code optimizer */

int Sflag; /* print raw TCP sequence numbers */

+ int Dflag; /* print packet contents as char */

int packettype;



int dflag; /* print filter code */

***************

*** 145,151 ****

error("%s", ebuf);



opterr = 0;

! while ((op = getopt(argc, argv, "c:defF:i:lnNOpqr:s:StT:vw:xY")) != EOF

)

switch (op) {

case 'c':

cnt = atoi(optarg);

--- 146,152 ----

error("%s", ebuf);



opterr = 0;

! while ((op = getopt(argc, argv, "c:defF:i:lnNOpqr:s:StT:vw:xDY")) != EO

F)

switch (op) {

case 'c':

cnt = atoi(optarg);

***************

*** 254,259 ****

--- 255,268 ----

++xflag;

break;



+ case 'D':

+ {

+ /* print data as char. sets -x as well */

+ if (!xflag) ++xflag;

+ ++Dflag;

+ }

+ break;

+

default:

usage();

/* NOTREACHED */

***************

*** 387,392 ****

--- 396,418 ----

}



void

+ default_D_print(register const u_char *cp, register u_int length)

+ {

+ register u_int i;

+

+ if ( Dflag == 1)

+ i = 0;

+ else

+ i = (length > 40) ? 40 : 0;

+

+ putchar('\n');

+

+ for ( ; i < length; i+=2) {

+ putchar(cp[i]); putchar(cp[i + 1]);

+ }

+ }

+

+ void

default_print(register const u_char *bp, register u_int length)

{

register const u_short *sp;

***************

*** 397,414 ****

default_print_unaligned(bp, length);

return;

}

sp = (u_short *)bp;

nshorts = (u_int) length / sizeof(u_short);

i = 0;

while (--nshorts >= 0) {

if ((i++ % 8) == 0)

(void)printf("\n\t\t\t");

! (void)printf(" %04x", ntohs(*sp++));

}

if (length & 1) {

if ((i % 8) == 0)

(void)printf("\n\t\t\t");

! (void)printf(" %02x", *(u_char *)sp);

}

}



--- 423,447 ----

default_print_unaligned(bp, length);

return;

}

+

+ if (Dflag) {

+ default_D_print(bp, length);

+ return;

+ }

+

sp = (u_short *)bp;

+

nshorts = (u_int) length / sizeof(u_short);

i = 0;

while (--nshorts >= 0) {

if ((i++ % 8) == 0)

(void)printf("\n\t\t\t");

! (void)printf(" %04x", ntohs(*sp++));

}

if (length & 1) {

if ((i % 8) == 0)

(void)printf("\n\t\t\t");

! (void)printf(" %02x", *(u_char *)sp);

}

}



***************

*** 419,425 ****



(void)fprintf(stderr, "Version %s\n", version);

(void)fprintf(stderr,

! "Usage: tcpdump [-deflnNOpqStvx] [-c count] [ -F file ]\n");

(void)fprintf(stderr,

"\t\t[ -i interface ] [ -r file ] [ -s snaplen ]\n");

(void)fprintf(stderr,

--- 452,458 ----



(void)fprintf(stderr, "Version %s\n", version);

(void)fprintf(stderr,

! "Usage: tcpdump [-deflnNOpqStvxD] [-c count] [ -F file ]\n");

(void)fprintf(stderr,

"\t\t[ -i interface ] [ -r file ] [ -s snaplen ]\n");

(void)fprintf(stderr,





< Previous Next >
This Thread
  • No further messages