4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change
on this file since 3a3aa23 was
258c1fb,
checked in by Perry Lorier <perry@…>, 18 years ago
|
Fixes to TCP
Fixes to ASN1 parsing
|
-
Property mode set to
100644
|
File size:
1.5 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 <string> |
---|
8 | #include <ctype.h> |
---|
9 | #include "tracedump.h" |
---|
10 | |
---|
11 | #ifndef DIRNAME |
---|
12 | #define DIRNAME "./" |
---|
13 | #endif |
---|
14 | |
---|
15 | typedef void (*decode_t)(uint16_t type,char *packet,int len); |
---|
16 | |
---|
17 | static std::map<std::string,std::map<uint16_t,decode_t> > decoders; |
---|
18 | |
---|
19 | #define WIDTH 16 |
---|
20 | |
---|
21 | static void generic_decode(uint16_t type,char *packet, int len) { |
---|
22 | int i; |
---|
23 | printf(" Unknown Protocol: %i",type); |
---|
24 | for(i=0;i<len; /* Nothing */ ) { |
---|
25 | int j; |
---|
26 | printf("\n "); |
---|
27 | for(j=0;j<WIDTH;j++) { |
---|
28 | if (i+j<len) |
---|
29 | printf(" %02x",(unsigned char)packet[i+j]); |
---|
30 | else |
---|
31 | printf(" "); |
---|
32 | } |
---|
33 | printf(" "); |
---|
34 | for(j=0;j<WIDTH;j++) { |
---|
35 | if (i+j<len) |
---|
36 | if (isprint((unsigned char)packet[i+j])) |
---|
37 | printf("%c",(unsigned char)packet[i+j]); |
---|
38 | else |
---|
39 | printf("."); |
---|
40 | else |
---|
41 | printf(" "); |
---|
42 | } |
---|
43 | if (i+WIDTH>len) |
---|
44 | break; |
---|
45 | else |
---|
46 | i+=WIDTH; |
---|
47 | } |
---|
48 | printf("\n"); |
---|
49 | } |
---|
50 | |
---|
51 | void decode_next(char *packet,int len,char *proto_name,int type) |
---|
52 | { |
---|
53 | std::string sname(proto_name); |
---|
54 | if (decoders[sname].find(type)==decoders[sname].end()) { |
---|
55 | void *hdl; |
---|
56 | char name[1024]; |
---|
57 | snprintf(name,sizeof(name),DIRNAME "%s_%i.so",sname.c_str(),type); |
---|
58 | hdl = dlopen(name,RTLD_LAZY); |
---|
59 | if (!hdl) |
---|
60 | decoders[sname][type]=generic_decode; |
---|
61 | else { |
---|
62 | void *s=dlsym(hdl,"decode"); |
---|
63 | if (!s) { |
---|
64 | decoders[sname][type]=generic_decode; |
---|
65 | } |
---|
66 | else |
---|
67 | decoders[sname][type]=(decode_t)s; |
---|
68 | } |
---|
69 | } |
---|
70 | decoders[sname][type](type,packet,len); |
---|
71 | } |
---|
72 | |
---|
Note: See
TracBrowser
for help on using the repository browser.