2 * netsniff-ng - the packet sniffing beast
3 * Copyright 2012 Markus Amend <markus@netsniff-ng.org>
4 * Subject to the GPL, version 2.
6 * IPv6 Fragmentation Header described in RFC2460
9 #ifndef PROTO_IPV6_FRAGM_H
10 #define PROTO_IPV6_FRAGM_H
14 #include <netinet/in.h> /* for ntohs() */
16 #include "proto_struct.h"
17 #include "dissector_eth.h"
21 uint8_t h_fragm_next_header
;
22 uint8_t h_fragm_reserved
;
23 uint16_t h_fragm_off_res_M
;
24 uint32_t h_fragm_identification
;
27 static inline void fragm(uint8_t *packet
, size_t len
)
30 struct fragmhdr
*fragm
= (struct fragmhdr
*) packet
;
32 if (len
< sizeof(struct fragmhdr
))
35 off_res_M
= ntohs(fragm
->h_fragm_off_res_M
);
37 tprintf("\t [ Fragment ");
38 tprintf("NextHdr (%u), ", fragm
->h_fragm_next_header
);
39 tprintf("Reserved (%u), ", fragm
->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) ", ntohl(fragm
->h_fragm_identification
));
47 static inline void fragm_less(uint8_t *packet
, size_t len
)
50 struct fragmhdr
*fragm
= (struct fragmhdr
*) packet
;
52 if (len
< sizeof(struct fragmhdr
))
55 off_res_M
= ntohs(fragm
->h_fragm_off_res_M
);
57 tprintf(" FragmOffs %u", off_res_M
>> 3);
60 static inline void fragm_next(uint8_t *packet
, size_t len
,
61 struct hash_table
**table
,
62 unsigned int *key
, size_t *off
)
64 struct fragmhdr
*fragm
= (struct fragmhdr
*) packet
;
65 if (len
< sizeof(struct fragmhdr
))
67 (*off
) = sizeof(struct fragmhdr
);
68 (*key
) = fragm
->h_fragm_next_header
;
72 struct protocol ipv6_fragm_ops
= {
75 .print_less
= fragm_less
,
76 .proto_next
= fragm_next
,
79 #endif /* PROTO_IPV6_FRAGM_H */