4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change
on this file since 505c421 was
d907ff5,
checked in by Perry Lorier <perry@…>, 18 years ago
|
Import tracedump to libtrace
|
-
Property mode set to
100644
|
File size:
1.1 KB
|
Line | |
---|
1 | #include <stdio.h> |
---|
2 | #include <stdint.h> |
---|
3 | #include <dlfcn.h> |
---|
4 | #include <map> |
---|
5 | #include "tracedump.h" |
---|
6 | #include <netinet/udp.h> |
---|
7 | #include <netinet/in.h> |
---|
8 | |
---|
9 | #define STRUCT udp |
---|
10 | |
---|
11 | #define SAFE(x) \ |
---|
12 | ((unsigned int)len>=((char*)&STRUCT->x-(char*)STRUCT+sizeof(STRUCT->x))) |
---|
13 | #define DISPLAY_EXP(x,fmt,exp) \ |
---|
14 | if (SAFE(x)) \ |
---|
15 | printf(fmt,exp); \ |
---|
16 | else \ |
---|
17 | return; |
---|
18 | |
---|
19 | #define DISPLAY(x,fmt) DISPLAY_EXP(x,fmt,STRUCT->x) |
---|
20 | |
---|
21 | #define DISPLAYS(x,fmt) DISPLAY_EXP(x,fmt,htons(STRUCT->x)) |
---|
22 | #define DISPLAYL(x,fmt) DISPLAY_EXP(x,fmt,htonl(STRUCT->x)) |
---|
23 | #define DISPLAYIP(x,fmt) DISPLAY_EXP(x,fmt,inet_ntoa(*(struct in_addr*)&STRUCT->x)) |
---|
24 | |
---|
25 | |
---|
26 | extern "C" |
---|
27 | void decode(int link_type,char *packet,int len) |
---|
28 | { |
---|
29 | struct udphdr *udp = (struct udphdr*)packet; |
---|
30 | printf(" UDP:"); |
---|
31 | DISPLAYS(source," Source %i") |
---|
32 | DISPLAYS(dest," Dest %i") |
---|
33 | printf("\n UDP:"); |
---|
34 | DISPLAYS(len," Len %u"); |
---|
35 | DISPLAYS(check," Checksum %u"); |
---|
36 | printf("\n"); |
---|
37 | if (htons(udp->source) < htons(udp->dest)) |
---|
38 | decode_next(packet+sizeof(*udp),len-sizeof(*udp),"udp",htons(udp->source)); |
---|
39 | else |
---|
40 | decode_next(packet+sizeof(*udp),len-sizeof(*udp),"udp",htons(udp->dest)); |
---|
41 | return; |
---|
42 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.