2 * netsniff-ng - the packet sniffing beast
3 * Copyright 2012 Markus Amend <markus@netsniff-ng.org>, Deutsche Flugsicherung GmbH
4 * Subject to the GPL, version 2.
6 * IPv6 Fragmentation Header described in RFC2460
11 #include <netinet/in.h> /* for ntohs() */
15 #include "dissector_eth.h"
20 uint8_t h_fragm_next_header
;
21 uint8_t h_fragm_reserved
;
22 uint16_t h_fragm_off_res_M
;
23 uint32_t h_fragm_identification
;
26 static void fragm(struct pkt_buff
*pkt
)
29 struct fragmhdr
*fragm_ops
;
31 fragm_ops
= (struct fragmhdr
*) pkt_pull(pkt
, sizeof(*fragm_ops
));
32 if (fragm_ops
== NULL
)
35 off_res_M
= ntohs(fragm_ops
->h_fragm_off_res_M
);
37 tprintf("\t [ Fragment ");
38 tprintf("NextHdr (%u), ", fragm_ops
->h_fragm_next_header
);
39 tprintf("Reserved (%u), ", fragm_ops
->h_fragm_reserved
);
40 tprintf("Offset (%u), ", off_res_M
>> 3);
41 tprintf("Res (%u), ", (off_res_M
>> 1) & 0x3);
42 tprintf("M flag (%u), ", off_res_M
& 0x1);
43 tprintf("Identification (%u)",
44 ntohl(fragm_ops
->h_fragm_identification
));
47 pkt_set_proto(pkt
, ð_lay3
, fragm_ops
->h_fragm_next_header
);
50 static void fragm_less(struct pkt_buff
*pkt
)
53 struct fragmhdr
*fragm_ops
;
55 fragm_ops
= (struct fragmhdr
*) pkt_pull(pkt
, sizeof(*fragm_ops
));
56 if (fragm_ops
== NULL
)
59 off_res_M
= ntohs(fragm_ops
->h_fragm_off_res_M
);
61 tprintf(" FragmOffs %u", off_res_M
>> 3);
63 pkt_set_proto(pkt
, ð_lay3
, fragm_ops
->h_fragm_next_header
);
66 struct protocol ipv6_fragm_ops
= {
69 .print_less
= fragm_less
,