]> git.decadent.org.uk Git - odhcp6c.git/blob - src/ra.h
Fix parsing of Router Advertisement messsages
[odhcp6c.git] / src / ra.h
1 /**
2  * Copyright (C) 2012-2013 Steven Barth <steven@midlink.org>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License v2 as published by
6  * the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  * GNU General Public License for more details.
12  *
13  */
14 #pragma once
15
16 #define ALL_IPV6_NODES {{{0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
17                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}}}
18
19 #define ALL_IPV6_ROUTERS {{{0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
20                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02}}}
21
22 struct icmpv6_opt {
23         uint8_t type;
24         uint8_t len;
25 };
26
27 struct nd_opt_recursive_dns {
28         uint8_t type;
29         uint8_t len;
30         uint8_t pad;
31         uint8_t pad2;
32         uint32_t lifetime;
33         struct in6_addr servers[1];
34 };
35
36 #define ND_OPT_ROUTE_INFORMATION 24
37 struct nd_opt_route_info {
38         uint8_t nd_opt_ri_type;
39         uint8_t nd_opt_ri_len;
40         uint8_t nd_opt_ri_prefix_len;
41         uint8_t nd_opt_ri_prf;
42         uint32_t nd_opt_ri_route_lifetime;
43         uint8_t nd_opt_ri_prefix[1];
44 };
45
46 #define icmpv6_for_each_option(opt, start, end)\
47         for (opt = (struct icmpv6_opt*)(start);\
48         ((void *)opt < (void *)end) && \
49         (void *)((uint8_t *)opt + (opt->len << 3)) <= (void *)(end); \
50         opt = (struct icmpv6_opt *)((uint8_t *)opt + (opt->len << 3)))
51
52
53 int ra_init(const char *ifname, const struct in6_addr *ifid);
54 bool ra_link_up(void);
55 bool ra_process(void);