odhcp6c: remove len check in option parsing handle
[project/odhcp6c.git] / src / ra.h
1 /**
2 * Copyright (C) 2012-2014 Steven Barth <steven@midlink.org>
3 * Copyright (C) 2018 Hans Dedecker <dedeckeh@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License v2 as published by
7 * the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 */
15 #pragma once
16
17 #define ALL_IPV6_NODES {{{0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
18 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}}}
19
20 #define ALL_IPV6_ROUTERS {{{0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
21 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02}}}
22
23 struct icmpv6_opt {
24 uint8_t type;
25 uint8_t len;
26 uint8_t data[6];
27 };
28
29 struct icmpv6_opt_route_info {
30 uint8_t type;
31 uint8_t len;
32 uint8_t prefix_len;
33 uint8_t flags;
34 uint32_t lifetime;
35 uint8_t prefix[];
36 };
37
38 #define ND_OPT_ROUTE_INFORMATION 24
39
40
41 #define icmpv6_for_each_option(opt, start, end)\
42 for (opt = (struct icmpv6_opt*)(start);\
43 (void*)(opt + 1) <= (void*)(end) && opt->len > 0 &&\
44 (void*)(opt + opt->len) <= (void*)(end); opt += opt->len)
45
46
47 int ra_init(const char *ifname, const struct in6_addr *ifid,
48 unsigned int options, unsigned int holdoff_interval);
49 bool ra_link_up(void);
50 bool ra_process(void);