4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change
on this file since ac7037b was
ac7037b,
checked in by Shane Alcock <salcock@…>, 12 years ago
|
- Added libpacketdump decoders for CHDLC and PPP/HDLC
|
-
Property mode set to
100644
|
File size:
1.1 KB
|
Line | |
---|
1 | /* Decoder for PPP with HDLC frames */ |
---|
2 | |
---|
3 | #include <sys/types.h> |
---|
4 | #include <netinet/in.h> |
---|
5 | #include <stdio.h> |
---|
6 | #include <inttypes.h> |
---|
7 | #include <dlfcn.h> |
---|
8 | #include "libtrace.h" |
---|
9 | #include "libpacketdump.h" |
---|
10 | |
---|
11 | typedef struct libtrace_hdlc_t { |
---|
12 | uint8_t address; /** Always 0xff */ |
---|
13 | uint8_t control; /** Always 0x03 */ |
---|
14 | uint16_t protocol; |
---|
15 | } libtrace_hdlc_t; |
---|
16 | |
---|
17 | |
---|
18 | DLLEXPORT void decode(int link_type UNUSED,const char *packet,unsigned len) |
---|
19 | { |
---|
20 | libtrace_hdlc_t *frame = (libtrace_hdlc_t *)packet; |
---|
21 | |
---|
22 | printf(" PPP:"); |
---|
23 | if (len >= 1) |
---|
24 | printf(" Address: 0x%02x", frame->address); |
---|
25 | else { |
---|
26 | printf("[|Truncated]\n"); |
---|
27 | return; |
---|
28 | } |
---|
29 | |
---|
30 | if (len >= 2) |
---|
31 | printf(" Control: 0x%02x", frame->control); |
---|
32 | else { |
---|
33 | printf("[|Truncated]\n"); |
---|
34 | return; |
---|
35 | } |
---|
36 | |
---|
37 | if (len >= 4) { |
---|
38 | printf(" Protocol: 0x%04x\n", ntohs(frame->protocol)); |
---|
39 | |
---|
40 | /* PPP protocols do not match ethertypes, so we have to |
---|
41 | * convert |
---|
42 | * |
---|
43 | * XXX develop decoders for PPP protocols so this can be |
---|
44 | * done generically |
---|
45 | */ |
---|
46 | if (ntohs(frame->protocol) == 0x0021) { |
---|
47 | decode_next(packet + 4, len - 4, "eth", 0x0800); |
---|
48 | } |
---|
49 | } |
---|
50 | else { |
---|
51 | printf("[|Truncated]\n"); |
---|
52 | return; |
---|
53 | } |
---|
54 | |
---|
55 | |
---|
56 | return; |
---|
57 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.