cpusched: removed blank lines
[netsniff-ng.git] / src / proto_ipv6_dest_opts.h
blob56e29a583c26c0529aadf4181c6c9db29cfac0a6
1 /*
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 Destination Options Header described in RFC2460
7 */
9 #ifndef PROTO_IPV6_DEST_OPTS_H
10 #define PROTO_IPV6_DEST_OPTS_H
12 #include <stdio.h>
13 #include <stdint.h>
14 #include <netinet/in.h> /* for ntohs() */
16 #include "proto_struct.h"
17 #include "dissector_eth.h"
18 #include "built_in.h"
20 struct dest_optshdr {
21 uint8_t h_next_header;
22 uint8_t h_hdr_ext_len;
23 uint8_t h_dest_option_type;
24 } __packed;
26 static inline void dest_opts(uint8_t *packet, size_t len)
28 uint8_t hdr_ext_len;
29 struct dest_optshdr *dest_opts = (struct dest_optshdr *) packet;
31 hdr_ext_len = (dest_opts->h_hdr_ext_len + 1) * 8;
32 if (len < hdr_ext_len || len < sizeof(struct dest_optshdr))
33 return;
35 tprintf("\t [ Destination Options ");
36 tprintf("NextHdr (%u), ", dest_opts->h_next_header);
37 tprintf("HdrExtLen (%u), ", hdr_ext_len);
38 tprintf("Opt (%u), ", dest_opts->h_dest_option_type);
39 tprintf("Appendix 0x");
40 for (uint8_t i = sizeof(struct dest_optshdr); i < hdr_ext_len; i++)
41 tprintf("%02x",(uint8_t) packet[i]);
42 tprintf(" ]\n");
45 static inline void dest_opts_less(uint8_t *packet, size_t len)
47 uint8_t hdr_ext_len;
48 struct dest_optshdr *dest_opts = (struct dest_optshdr *) packet;
50 hdr_ext_len = (dest_opts->h_hdr_ext_len + 1) * 8;
51 if (len < hdr_ext_len || len < sizeof(struct dest_optshdr))
52 return;
54 tprintf(" Destination Options Opt %u", dest_opts->h_dest_option_type);
57 static inline void dest_opts_next(uint8_t *packet, size_t len,
58 struct hash_table **table,
59 unsigned int *key, size_t *off)
61 uint8_t hdr_ext_len;
62 struct dest_optshdr *dest_opts = (struct dest_optshdr *) packet;
64 hdr_ext_len = (dest_opts->h_hdr_ext_len + 1) * 8;
65 if (len < hdr_ext_len || len < sizeof(struct dest_optshdr))
66 return;
68 (*off) = hdr_ext_len;
69 (*key) = dest_opts->h_next_header;
70 (*table) = &eth_lay3;
73 struct protocol ipv6_dest_opts_ops = {
74 .key = 0x3C,
75 .print_full = dest_opts,
76 .print_less = dest_opts_less,
77 .proto_next = dest_opts_next,
80 #endif /* PROTO_IPV6_DEST_OPTS_H */