4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change
on this file since eade363 was
eade363,
checked in by Perry Lorier <perry@…>, 11 years ago
|
Tidy up thousands of little warnings
|
-
Property mode set to
100644
|
File size:
1.7 KB
|
Line | |
---|
1 | #include <stdio.h> |
---|
2 | #include "libpacketdump.h" |
---|
3 | |
---|
4 | #define LE(lhs,n) \ |
---|
5 | do { \ |
---|
6 | uint64_t num=0; \ |
---|
7 | int size=0; \ |
---|
8 | if ((offset+n)>len*8) return; \ |
---|
9 | if (n>16) { \ |
---|
10 | num=htonl(*(uint32_t*)(packet+offset/8));\ |
---|
11 | size = 32;\ |
---|
12 | } else if (n>8) { \ |
---|
13 | num=htons(*(uint16_t*)(packet+offset/8));\ |
---|
14 | size = 16; \ |
---|
15 | } else { \ |
---|
16 | num=*(uint8_t*)(packet+offset/8); \ |
---|
17 | size = 8; \ |
---|
18 | } \ |
---|
19 | num=num>>(size - (n + (offset % 8))); \ |
---|
20 | offset+=n; \ |
---|
21 | lhs=num&((1<<(n))-1); \ |
---|
22 | } while(0) |
---|
23 | |
---|
24 | void decode(int link_type UNUSED,const char *packet,unsigned len) |
---|
25 | { |
---|
26 | unsigned int offset=0; |
---|
27 | int value; |
---|
28 | uint16_t ethertype; |
---|
29 | |
---|
30 | LE(value, 3); printf(" VLAN: User Priority: %d\n", value); |
---|
31 | LE(value, 1); printf(" VLAN: Format Indicator: %d\n", value); |
---|
32 | LE(value, 12); printf(" VLAN: ID: %d\n", value); |
---|
33 | LE(value, 16); printf(" VLAN: EtherType: 0x%04x\n", (uint16_t)value); |
---|
34 | ethertype = (uint16_t) value; |
---|
35 | |
---|
36 | decode_next(packet + 4, len - 4, "eth", ethertype); |
---|
37 | |
---|
38 | return; |
---|
39 | } |
---|
40 | |
---|
Note: See
TracBrowser
for help on using the repository browser.