File: ip_44.c

package info (click to toggle)
libtrace3 3.0.14-1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 11,492 kB
  • sloc: ansic: 21,584; sh: 10,236; cpp: 1,765; makefile: 454; yacc: 96; lex: 50
file content (37 lines) | stat: -rw-r--r-- 864 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <sys/types.h>
#include <netinet/in.h>
#include <stdio.h>
#include "libpacketdump.h"
#include "libtrace.h"

DLLEXPORT void decode(int link_type UNUSED, const char *packet, unsigned len)
{
	libtrace_ip6_frag_t *frag = (libtrace_ip6_frag_t *)packet;
	uint16_t offset;

	// IPv6 Fragment Header
	if (len == 0) {
		printf(" IPv6 Frag: [Truncated]\n");
		return;
	}

	

	printf(" IPv6 Frag: Next Header: %u\n", frag->nxt);
	
	offset = ntohs(frag->frag_off);
	printf(" IPv6 Frag: Offset: %u", offset & 0xFFF8);
	if ((offset & 0x1)) printf(" MORE_FRAG");
	
	printf("\n"); 
	printf(" IPv6 Frag: Identification: %u\n", ntohl(frag->ident));

	/* Only dump the next header if this is the first fragment */
	if ((offset & 0xFFF8) != 0)
		return;

	decode_next(packet + sizeof(libtrace_ip6_frag_t), 
			len - sizeof(libtrace_ip6_frag_t), "ip", frag->nxt);
	return;	

}