source: libpacketdump/ip_47.c @ cde85f8

4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change on this file since cde85f8 was c7062df, checked in by Shane Alcock <salcock@…>, 12 years ago
  • Ensure that the decode functions are exported as global symbols for the various libpacketdump shared libraries
  • Property mode set to 100644
File size: 840 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
13DLLEXPORT void decode(int link_type UNUSED,const char *packet,unsigned len)
14{
15        // GRE
16        if (len<2) {
17                printf(" GRE: [Truncated]\n");
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.