source: examples/tracedump/eth_2048.cc @ d907ff5

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

Import tracedump to libtrace

  • Property mode set to 100644
File size: 1.1 KB
Line 
1#include <netinet/ether.h>
2#include <netinet/in.h>
3#include <stdio.h>
4#include <stdint.h>
5#include <dlfcn.h>
6#include <map>
7#include "tracedump.h"
8#include <sys/socket.h>
9#include <netinet/in.h>
10#include <netinet/ip.h>
11#include <arpa/inet.h>
12
13#define DISPLAY_EXP(x,fmt,exp) \
14        if ((unsigned int)len>=((char*)&ip->x-(char*)ip+sizeof(ip->x))) \
15                printf(fmt,exp); \
16        else \
17                return;
18
19#define DISPLAY(x,fmt) DISPLAY_EXP(x,fmt,ip->x)
20
21#define DISPLAYS(x,fmt) DISPLAY_EXP(x,fmt,htons(ip->x))
22#define DISPLAYIP(x,fmt) DISPLAY_EXP(x,fmt,inet_ntoa(*(struct in_addr*)&ip->x))
23
24extern "C"
25void decode(int link_type,char *packet,int len)
26{
27        struct iphdr *ip = (struct iphdr*)packet;
28        if (len>=1) {
29                printf(" IP: Header Len %i",ip->ihl*4);
30                printf(" Ver %i",ip->version);
31        }
32        DISPLAY(tos," TOS %02x")
33        DISPLAY(tot_len," Total Length %i")
34        printf("\n IP:");
35        DISPLAY(id," Id %i");
36        DISPLAY(frag_off," Fragoff %i");
37        printf("\n IP:");
38        DISPLAY(ttl," TTL %i");
39        DISPLAY(protocol," Proto %i");
40        DISPLAYS(check," Checksum %i\n");
41        DISPLAYIP(saddr," IP: Source %s\n");
42        DISPLAYIP(daddr," IP: Destination %s\n");
43        decode_next(packet+sizeof(*ip),len-sizeof(*ip),"ip",ip->protocol);
44        return;
45}
Note: See TracBrowser for help on using the repository browser.