2 * IPv6 Mobility Header described in RFC6275
3 * programmed by Markus Amend 2012 as a contribution to
4 * netsniff-ng - the packet sniffing beast
5 * Copyright 2012 Markus Amend.
6 * Subject to the GPL, version 2.
9 #ifndef MOBILITY_HEADER_H
10 #define MOBILITY_HEADER_H
14 #include <netinet/in.h> /* for ntohs() */
16 #include "proto_struct.h"
17 #include "dissector_eth.h"
20 uint8_t h_next_header
;
21 uint8_t h_hdr_ext_len
;
25 } __attribute__((packed
));
27 static inline void mobility(uint8_t *packet
, size_t len
)
30 struct mobilityhdr
*mobility
= (struct mobilityhdr
*) packet
;
32 hdr_ext_len
= (mobility
->h_hdr_ext_len
+ 1) * 8;
33 if (len
< hdr_ext_len
|| len
< sizeof(struct mobilityhdr
))
36 tprintf("\t [ Mobility Header ");
37 tprintf("NextHdr (%u), ", mobility
->h_next_header
);
38 tprintf("HdrLen (%u), ", hdr_ext_len
);
39 tprintf("MH (%u), ", mobility
->h_MH_type
);
40 tprintf("Res (0x%x), ", mobility
->h_reserved
);
41 tprintf("Chk (0x%x), ", ntohs(mobility
->h_checksum
));
42 tprintf("Appendix 0x");
43 for (uint8_t i
= sizeof(struct mobilityhdr
); i
< hdr_ext_len
; i
++)
44 tprintf("%02x",(uint8_t) packet
[i
]);
48 static inline void mobility_less(uint8_t *packet
, size_t len
)
51 struct mobilityhdr
*mobility
= (struct mobilityhdr
*) packet
;
53 hdr_ext_len
= (mobility
->h_hdr_ext_len
+ 1) * 8;
54 if (len
< hdr_ext_len
|| len
< sizeof(struct mobilityhdr
))
57 tprintf(" MH Type %u", mobility
->h_MH_type
);
60 static inline void mobility_next(uint8_t *packet
, size_t len
,
61 struct hash_table
**table
,
62 unsigned int *key
, size_t *off
)
65 struct mobilityhdr
*mobility
= (struct mobilityhdr
*) packet
;
67 hdr_ext_len
= (mobility
->h_hdr_ext_len
+ 1) * 8;
68 if (len
< hdr_ext_len
|| len
< sizeof(struct mobilityhdr
))
72 (*key
) = mobility
->h_next_header
;
76 struct protocol ipv6_mobility_hdr_ops
= {
78 .print_full
= mobility
,
79 .print_less
= mobility_less
,
80 .print_pay_ascii
= empty
,
81 .print_pay_hex
= empty
,
82 .print_pay_none
= mobility
,
84 .proto_next
= mobility_next
,
87 #endif /* MOBILITY_HEADER_H */