4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change
on this file since 11a7f9c was
11a7f9c,
checked in by Perry Lorier <perry@…>, 14 years ago
|
Constification
|
-
Property mode set to
100644
|
File size:
1.0 KB
|
Line | |
---|
1 | #include <stdio.h> |
---|
2 | #include "libpacketdump.h" |
---|
3 | |
---|
4 | #define LE(lhs,n) \ |
---|
5 | do { \ |
---|
6 | uint64_t num=0; \ |
---|
7 | if ((offset+n)>len*8) return; \ |
---|
8 | if (n>16) \ |
---|
9 | num=htonl(*(uint32_t*)(packet+offset/8));\ |
---|
10 | else if (n>8) \ |
---|
11 | num=htons(*(uint16_t*)(packet+offset/8));\ |
---|
12 | else \ |
---|
13 | num=*(uint8_t*)(packet+offset/8); \ |
---|
14 | num=num>>(32-n); \ |
---|
15 | offset+=n; \ |
---|
16 | lhs=num&((1<<(n+1))-1); \ |
---|
17 | } while(0) |
---|
18 | |
---|
19 | void decode(int link_type,const char *packet,unsigned len) |
---|
20 | { |
---|
21 | int offset=0; |
---|
22 | int value; |
---|
23 | LE(value,20); printf(" MPLS: Label: %d\n",offset); |
---|
24 | LE(value,3); printf(" MPLS: Class of service: %d\n",offset); |
---|
25 | LE(value,1); printf(" MPLS: Stack: %s\n",offset?"Last" :"More"); |
---|
26 | LE(value,8); printf(" MPLS: TTL: %d\n",offset); |
---|
27 | /* MPLS doesn't say what it's encapsulating, so we make an educated |
---|
28 | * guess and pray. |
---|
29 | */ |
---|
30 | if ((*(packet+32)&0xF0) == 0x40) |
---|
31 | decode_next(packet+offset/8,len-4,"eth",0x0800); |
---|
32 | else if ((*(packet+32)&0xF0) == 0x60) |
---|
33 | decode_next(packet+offset/8,len-4,"eth",0x86DD); |
---|
34 | else |
---|
35 | decode_next(packet+offset/8,len-4,"link",1); |
---|
36 | |
---|
37 | return; |
---|
38 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.