source: libpacketdump/ip_47.c @ e8d0993

4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change on this file since e8d0993 was 9b06a91, checked in by Perry Lorier <perry@…>, 14 years ago

Add a GRE decoder

  • Property mode set to 100644
File size: 815 bytes
Line 
1#include <sys/types.h>
2#include <netinet/in.h>
3#include <stdio.h>
4#include "libpacketdump.h"
5
6typedef struct gre_t {
7        uint16_t flags;
8        uint16_t ethertype;
9        uint16_t checksum;
10        uint16_t reserved1;
11} gre_t;
12
13void decode(int link_type,char *packet,unsigned len)
14{
15        // GRE
16        if (len<2) {
17                printf(" GRE: [Truncated]");
18                return;
19        }
20        printf(" GRE: %s\n",
21                ntohs(((gre_t*)packet)->flags) & 0x8000 
22                        ? "Checksum present"
23                        : "Checksum absent");
24        printf(" GRE: Version: %d\n", ntohs(((gre_t*)packet)->flags) & 0x0007);
25        printf(" GRE: Protocol: %04x\n", ntohs(((gre_t*)packet)->ethertype));
26
27        if (ntohs(((gre_t*)packet)->flags) & 0x8000) {
28                decode_next(packet+4,len-4,"link",
29                                ntohs(((gre_t*)packet)->ethertype));
30        }
31        else {
32                decode_next(packet+8,len-8,"link",
33                                ntohs(((gre_t*)packet)->ethertype));
34        }
35        return;
36}
Note: See TracBrowser for help on using the repository browser.