source: libpacketdump/eth_34525.c @ 740661f

4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change on this file since 740661f was 2ec8434, checked in by Shane Alcock <salcock@…>, 11 years ago
  • Removed multi-line comment
  • Property mode set to 100644
File size: 1.0 KB
Line 
1#include <sys/types.h>
2#include <sys/socket.h>
3#include <netinet/in.h>
4#include <stdio.h>
5#include "libpacketdump.h"
6#ifndef WIN32
7        #include <netinet/in_systm.h>
8#endif
9#include <arpa/inet.h>
10#include <netdb.h>
11
12DLLEXPORT void decode(int link_type UNUSED,const char *packet,unsigned len)
13{
14        libtrace_ip6_t *ip = (libtrace_ip6_t*)packet;
15       
16        uint32_t tmp = ntohl(*(uint32_t*)ip);
17
18        printf(" IPv6: Version %u\n", (tmp >> 28) & 0x000000f);
19        printf(" IPv6: Class %u\n", (tmp >> 20) & 0x000000ff);
20        printf(" IPv6: Flow Label %u\n", tmp & 0x000fffff);
21        printf(" IPv6: Payload Length %u\n", ntohs(ip->plen));
22        printf(" IPv6: Next Header %u\n", ip->nxt);
23        printf(" IPv6: Hop Limit %u\n", ip->hlim);
24
25
26        char ipstr[INET6_ADDRSTRLEN];                             
27        inet_ntop(AF_INET6, &(ip->ip_src), ipstr, INET6_ADDRSTRLEN);
28
29        printf(" IPv6: Source IP %s\n", ipstr);
30        inet_ntop(AF_INET6, &(ip->ip_dst), ipstr, INET6_ADDRSTRLEN);
31        printf(" IPv6: Destination IP %s\n", ipstr);
32
33        decode_next(packet+sizeof(libtrace_ip6_t),len-sizeof(libtrace_ip6_t),"ip",ip->nxt);
34        return;
35}
Note: See TracBrowser for help on using the repository browser.