]> git.cameronkatri.com Git - apple_cmds.git/blob - network_cmds/rtadvd.tproj/rtadvd.h
file_cmds: Fix .PATH
[apple_cmds.git] / network_cmds / rtadvd.tproj / rtadvd.h
1 /* $KAME: rtadvd.h,v 1.26 2003/08/05 12:34:23 itojun Exp $ */
2
3 /*
4 * Copyright (C) 1998 WIDE Project.
5 * Copyright (C) 2011 Hiroki Sato <hrs@FreeBSD.org>
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of the project nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 */
32 #include "rtadvd_logging.h"
33
34 #define ELM_MALLOC(p, error_action) \
35 do { \
36 p = malloc(sizeof(*p)); \
37 if (p == NULL) { \
38 errorlog("<%s> malloc failed: %s", \
39 __func__, strerror(errno)); \
40 error_action; \
41 } \
42 memset(p, 0, sizeof(*p)); \
43 } while(0)
44
45 #define ROUTEINFO 1
46
47 #define ALLNODES "ff02::1"
48 #define ALLROUTERS_LINK "ff02::2"
49 #define ALLROUTERS_SITE "ff05::2"
50 #define ANY "::"
51 #define RTSOLLEN 8
52
53 /* protocol constants and default values */
54 #define DEF_MAXRTRADVINTERVAL 600
55 #define DEF_ADVLINKMTU 0
56 #define DEF_ADVREACHABLETIME 0
57 #define DEF_ADVRETRANSTIMER 0
58 #define DEF_ADVCURHOPLIMIT 64
59 #define DEF_ADVVALIDLIFETIME 2592000
60 #define DEF_ADVPREFERREDLIFETIME 604800
61
62 #define MAXROUTERLIFETIME 9000
63 #define MIN_MAXINTERVAL 4
64 #define MAX_MAXINTERVAL 1800
65 #define MIN_MININTERVAL 3
66 #define MAXREACHABLETIME 3600000
67
68 #define MAX_INITIAL_RTR_ADVERT_INTERVAL 16
69 #define MAX_INITIAL_RTR_ADVERTISEMENTS 3
70 #define MAX_FINAL_RTR_ADVERTISEMENTS 1
71 #define MIN_DELAY_BETWEEN_RAS 3
72 #define MAX_RA_DELAY_TIME 500000 /* usec */
73
74 #define PREFIX_FROM_KERNEL 1
75 #define PREFIX_FROM_CONFIG 2
76 #define PREFIX_FROM_DYNAMIC 3
77
78 struct prefix {
79 struct prefix *next; /* forward link */
80 struct prefix *prev; /* previous link */
81
82 struct rainfo *rainfo; /* back pointer to the interface */
83
84 struct rtadvd_timer *timer; /* expiration timer. used when a prefix
85 * derived from the kernel is deleted.
86 */
87
88 u_int32_t validlifetime; /* AdvValidLifetime */
89 long vltimeexpire; /* expiration of vltime; decrement case only */
90 u_int32_t preflifetime; /* AdvPreferredLifetime */
91 long pltimeexpire; /* expiration of pltime; decrement case only */
92 u_int onlinkflg; /* bool: AdvOnLinkFlag */
93 u_int autoconfflg; /* bool: AdvAutonomousFlag */
94 int prefixlen;
95 int origin; /* from kernel or config */
96 struct in6_addr prefix;
97 };
98
99 #ifdef ROUTEINFO
100 struct rtinfo {
101 struct rtinfo *prev; /* previous link */
102 struct rtinfo *next; /* forward link */
103
104 u_int32_t ltime; /* route lifetime */
105 u_int rtpref; /* route preference */
106 int prefixlen;
107 struct in6_addr prefix;
108 };
109 #endif
110
111 struct soliciter {
112 struct soliciter *next;
113 struct sockaddr_in6 addr;
114 };
115
116 struct rdnss {
117 struct rdnss *next; /* forward link */
118 struct rdnss *prev; /* previous link */
119
120 struct in6_addr addr;
121 };
122
123 struct dnssl {
124 struct dnssl *next;
125 struct dnssl *prev;
126
127 char domain[1];
128 };
129
130 struct rainfo {
131 /* pointer for list */
132 struct rainfo *next;
133
134 /* timer related parameters */
135 struct rtadvd_timer *timer;
136 int initcounter; /* counter for the first few advertisements */
137 struct timeval lastsent; /* timestamp when the latest RA was sent */
138 int waiting; /* number of RS waiting for RA */
139
140 /* interface information */
141 int ifindex;
142 int advlinkopt; /* bool: whether include link-layer addr opt */
143 struct sockaddr_dl *sdl;
144 char ifname[16];
145 int phymtu; /* mtu of the physical interface */
146
147 /* Router configuration variables */
148 u_short lifetime; /* AdvDefaultLifetime */
149 u_int maxinterval; /* MaxRtrAdvInterval */
150 u_int mininterval; /* MinRtrAdvInterval */
151 int managedflg; /* AdvManagedFlag */
152 int otherflg; /* AdvOtherConfigFlag */
153
154 int rtpref; /* router preference */
155 u_int32_t linkmtu; /* AdvLinkMTU */
156 u_int32_t reachabletime; /* AdvReachableTime */
157 u_int32_t retranstimer; /* AdvRetransTimer */
158 u_int hoplimit; /* AdvCurHopLimit */
159 struct prefix prefix; /* AdvPrefixList(link head) */
160 int pfxs; /* number of prefixes */
161 long clockskew; /* used for consisitency check of lifetimes */
162
163 #ifdef ROUTEINFO
164 struct rtinfo route; /* route information option (link head) */
165 int routes; /* number of route information options */
166 #endif
167
168 /* Recursive DNS Servers RFC5006 */
169 struct rdnss rdnss_list;
170 int rdnss_length;
171 u_int32_t rdnss_lifetime;
172
173 /* DNS Search List RFC6106 */
174 struct dnssl dnssl_list;
175 int dnssl_length;
176 u_int32_t dnssl_lifetime;
177 u_int32_t dnssl_option_length;
178
179 /* Captive Portal RFC 7710 */
180 char * capport;
181 u_int32_t capport_length;
182 u_int32_t capport_option_length;
183
184 /* actual RA packet data and its length */
185 size_t ra_datalen;
186 u_char *ra_data;
187
188 /* statistics */
189 u_quad_t raoutput; /* number of RAs sent */
190 u_quad_t rainput; /* number of RAs received */
191 u_quad_t rainconsistent; /* number of RAs inconsistent with ours */
192 u_quad_t rsinput; /* number of RSs received */
193
194 /* info about soliciter */
195 struct soliciter *soliciter; /* recent solication source */
196 };
197
198 struct rtadvd_timer *ra_timeout(void *);
199 void ra_timer_update(void *, struct timeval *);
200
201 int prefix_match(struct in6_addr *, int, struct in6_addr *, int);
202 struct rainfo *if_indextorainfo(int);
203 struct prefix *find_prefix(struct rainfo *, struct in6_addr *, int);
204
205 extern struct in6_addr in6a_site_allrouters;