|
Lines 46-51
Link Here
|
| 46 |
#include <stdlib.h> |
46 |
#include <stdlib.h> |
| 47 |
#include <string.h> |
47 |
#include <string.h> |
| 48 |
#include <unistd.h> |
48 |
#include <unistd.h> |
|
|
49 |
#include <ctype.h> |
| 49 |
|
50 |
|
| 50 |
#include "interface.h" |
51 |
#include "interface.h" |
| 51 |
#include "addrtoname.h" |
52 |
#include "addrtoname.h" |
|
Lines 66-71
Link Here
|
| 66 |
int tflag = 1; /* print packet arrival time */ |
67 |
int tflag = 1; /* print packet arrival time */ |
| 67 |
int vflag; /* verbose */ |
68 |
int vflag; /* verbose */ |
| 68 |
int xflag; /* print packet in hex */ |
69 |
int xflag; /* print packet in hex */ |
|
|
70 |
int zflag; /* print packet in ascii */ |
| 69 |
|
71 |
|
| 70 |
int packettype; |
72 |
int packettype; |
| 71 |
|
73 |
|
|
Lines 149-155
Link Here
|
| 149 |
|
151 |
|
| 150 |
opterr = 0; |
152 |
opterr = 0; |
| 151 |
while ( |
153 |
while ( |
| 152 |
(op = getopt(argc, argv, "ac:defF:i:lnNOpqr:s:StT:vw:xY")) != EOF) |
154 |
(op = getopt(argc, argv, "ac:defF:i:lnNOpqr:s:StT:vw:xYz")) != EOF) |
| 153 |
switch (op) { |
155 |
switch (op) { |
| 154 |
|
156 |
|
| 155 |
case 'a': |
157 |
case 'a': |
|
Lines 263-268
Link Here
|
| 263 |
++xflag; |
265 |
++xflag; |
| 264 |
break; |
266 |
break; |
| 265 |
|
267 |
|
|
|
268 |
case 'z': |
| 269 |
++zflag; |
| 270 |
break; |
| 271 |
|
| 266 |
default: |
272 |
default: |
| 267 |
usage(); |
273 |
usage(); |
| 268 |
/* NOTREACHED */ |
274 |
/* NOTREACHED */ |
|
Lines 408-413
Link Here
|
| 408 |
* |
414 |
* |
| 409 |
* (BTW, please don't send us patches to print the packet out in ascii) |
415 |
* (BTW, please don't send us patches to print the packet out in ascii) |
| 410 |
*/ |
416 |
*/ |
|
|
417 |
/* |
| 418 |
* The developers of tcpdump are fascist bastards. |
| 419 |
* (And fuckwits, too. (void)printf("foo")? Bunch of arse. |
| 420 |
* They should be writing if (printf("foo") < 0) |
| 421 |
* { perror("stdout"); exit(EXIT_FAILURE); } |
| 422 |
*/ |
| 411 |
void |
423 |
void |
| 412 |
default_print(register const u_char *bp, register u_int length) |
424 |
default_print(register const u_char *bp, register u_int length) |
| 413 |
{ |
425 |
{ |
|
Lines 432-437
Link Here
|
| 432 |
(void)printf("\n\t\t\t"); |
444 |
(void)printf("\n\t\t\t"); |
| 433 |
(void)printf(" %02x", *(u_char *)sp); |
445 |
(void)printf(" %02x", *(u_char *)sp); |
| 434 |
} |
446 |
} |
|
|
447 |
} |
| 448 |
|
| 449 |
/* |
| 450 |
* print the packet out in ascii |
| 451 |
*/ |
| 452 |
void |
| 453 |
ascii_print(register const u_char *bp, register int length) |
| 454 |
{ |
| 455 |
register u_int i, j; |
| 456 |
|
| 457 |
for (i = 0; i < length; i += 16, bp += 16) { |
| 458 |
fputs("\n ", stdout); |
| 459 |
for (j = 0; j < 16; j++) { |
| 460 |
if (i + j < length) |
| 461 |
printf(" %02X", bp[j]); |
| 462 |
else |
| 463 |
printf(" "); |
| 464 |
if (j % 4 == 3) |
| 465 |
fputs(" ", stdout); |
| 466 |
} |
| 467 |
fputs(" ", stdout); |
| 468 |
for (j = 0; j < 16; j++) { |
| 469 |
if (i + j < length) |
| 470 |
putchar(isprint(bp[j]) ? bp[j] : '.'); |
| 471 |
if (j % 4 == 3) |
| 472 |
putchar(' '); |
| 473 |
} |
| 474 |
} |
| 475 |
putchar('\n'); |
| 435 |
} |
476 |
} |
| 436 |
|
477 |
|
| 437 |
__dead void |
478 |
__dead void |