Merge pull request #4 from dedeckeh/master
[project/odhcpd.git] / src / router.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
15 #pragma once
16 #include <stdint.h>
17 #include <netinet/in.h>
18 #include <netinet/icmp6.h>
19
20 struct icmpv6_opt {
21         uint8_t type;
22         uint8_t len;
23 };
24
25 struct nd_opt_slla {
26         uint8_t type;
27         uint8_t len;
28         uint8_t addr[6];
29 };
30
31 struct nd_opt_recursive_dns {
32         uint8_t type;
33         uint8_t len;
34         uint8_t pad;
35         uint8_t pad2;
36         uint32_t lifetime;
37 };
38
39 #define icmpv6_for_each_option(opt, start, end)\
40         for (opt = (struct icmpv6_opt*)(start);\
41         (void*)(opt + (opt->len << 3)) <= (void*)(end); opt += (opt->len << 3))
42
43 #define MaxRtrAdvInterval 600
44 #define MinRtrAdvInterval (MaxRtrAdvInterval / 3)
45 #define MaxValidTime 7200
46 #define MaxPreferredTime  (3 * MaxRtrAdvInterval)
47
48 #define ND_RA_FLAG_PROXY        0x4
49 #define ND_RA_PREF_HIGH (1 << 3)
50 #define ND_RA_PREF_LOW          (3 << 3)