4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change
on this file since 4e194bc was
70892e3,
checked in by Sam Jansen <stj2@…>, 18 years ago
|
IP does not occupy as many lines now.
|
-
Property mode set to
100644
|
File size:
1.1 KB
|
Line | |
---|
1 | #include <netinet/ether.h> |
---|
2 | #include <netinet/in.h> |
---|
3 | #include <stdio.h> |
---|
4 | #include <stdint.h> |
---|
5 | #include <dlfcn.h> |
---|
6 | #include <map> |
---|
7 | #include "tracedump.h" |
---|
8 | #include <sys/socket.h> |
---|
9 | #include <netinet/in.h> |
---|
10 | #include <netinet/ip.h> |
---|
11 | #include <arpa/inet.h> |
---|
12 | |
---|
13 | #define DISPLAY_EXP(x,fmt,exp) \ |
---|
14 | if ((unsigned int)len>=((char*)&ip->x-(char*)ip+sizeof(ip->x))) \ |
---|
15 | printf(fmt,exp); \ |
---|
16 | else \ |
---|
17 | return; |
---|
18 | |
---|
19 | #define DISPLAY(x,fmt) DISPLAY_EXP(x,fmt,ip->x) |
---|
20 | |
---|
21 | #define DISPLAYS(x,fmt) DISPLAY_EXP(x,fmt,htons(ip->x)) |
---|
22 | #define DISPLAYIP(x,fmt) DISPLAY_EXP(x,fmt,inet_ntoa(*(struct in_addr*)&ip->x)) |
---|
23 | |
---|
24 | extern "C" |
---|
25 | void decode(int link_type,char *packet,int len) |
---|
26 | { |
---|
27 | struct iphdr *ip = (struct iphdr*)packet; |
---|
28 | if (len>=1) { |
---|
29 | printf(" IP: Header Len %i",ip->ihl*4); |
---|
30 | printf(" Ver %i",ip->version); |
---|
31 | } |
---|
32 | DISPLAY(tos," TOS %02x") |
---|
33 | DISPLAYS(tot_len," Total Length %i") |
---|
34 | printf("\n IP:"); |
---|
35 | DISPLAY(id," Id %i"); |
---|
36 | DISPLAY(frag_off," Fragoff %i"); |
---|
37 | //printf("\n IP:"); |
---|
38 | DISPLAY(ttl," TTL %i"); |
---|
39 | DISPLAY(protocol," Proto %i"); |
---|
40 | DISPLAYS(check," Checksum %i\n"); |
---|
41 | DISPLAYIP(saddr," IP: Source %s "); |
---|
42 | DISPLAYIP(daddr,"Destination %s\n"); |
---|
43 | decode_next(packet+sizeof(*ip),len-sizeof(*ip),"ip",ip->protocol); |
---|
44 | return; |
---|
45 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.