]> git.saurik.com Git - apple/xnu.git/blob - bsd/netinet6/mip6.h
xnu-201.tar.gz
[apple/xnu.git] / bsd / netinet6 / mip6.h
1 /* $KAME: mip6.h,v 1.8 2000/03/18 03:05:39 itojun Exp $ */
2
3 /*
4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the project nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 */
31
32 #ifndef _NETINET6_MIP6_H_
33 #define _NETINET6_MIP6_H_
34
35 #include <netinet6/nd6.h>
36 #include <netinet/icmp6.h>
37
38 struct ifnet;
39
40 /*
41 * Definition For Mobile Internet Protocol Version 6.
42 * Draft draft-ietf-mobileip-ipv6-09.txt
43 */
44
45 /* Definition of MIPv6 states for the Event-State machine */
46 #define MIP6_STATE_UNDEF 0x01
47 #define MIP6_STATE_HOME 0x02
48 #define MIP6_STATE_DEREG 0x03
49 #define MIP6_STATE_NOTREG 0x04
50 #define MIP6_STATE_REG 0x05
51 #define MIP6_STATE_REREG 0x06
52 #define MIP6_STATE_REGNEWCOA 0x07
53
54
55 /* Definition of states used by the move detection algorithm used by MIPv6. */
56 #define MIP6_MD_BOOT 0x01
57 #define MIP6_MD_UNDEFINED 0x02
58 #define MIP6_MD_HOME 0x03
59 #define MIP6_MD_FOREIGN 0x04
60
61
62 /* Definition of Home Address route states used by the move detection
63 algorithm used by MIPv6. */
64 #define MIP6_ROUTE_NET 0x01
65 #define MIP6_ROUTE_HOST 0x02
66
67
68 /* Type of node calling mip6_tunnel */
69 #define MIP6_NODE_MN 0x01
70 #define MIP6_NODE_HA 0x02
71
72
73 /* Movement Detection default values */
74 #define MIP6_MAX_LOST_ADVINTS 3
75
76
77 /* Scope for hook activation */
78 #define MIP6_GENERIC_HOOKS 0x01
79 #define MIP6_SPECIFIC_HOOKS 0x02
80 #define MIP6_CONFIG_HOOKS 0x03
81
82
83 /* Definition of states for tunnels set up by the Home Agent and the MN. */
84 #define MIP6_TUNNEL_ADD 0
85 #define MIP6_TUNNEL_MOVE 1
86 #define MIP6_TUNNEL_DEL 2
87
88
89 /* Definition of length for different destination options */
90 #define IP6OPT_BULEN 8 /* Length of BU option */
91 #define IP6OPT_BALEN 11 /* Length of BA option */
92 #define IP6OPT_BRLEN 0 /* Length of BR option */
93 #define IP6OPT_HALEN 16 /* Length of HA option */
94 #define IP6OPT_UIDLEN 2 /* Length of Unique Identifier sub-option */
95 #define IP6OPT_HALISTLEN 16 /* Length of HA List sub-ption */
96 #define IP6OPT_COALEN 16 /* Length of Alternate COA sub-option */
97
98
99 /* Definition of minimum length of MIPv6 destination options.
100 Length includes option Type and Length. */
101 #define IP6OPT_BAMINLEN (IP6OPT_MINLEN + IP6OPT_BALEN)
102 #define IP6OPT_BRMINLEN (IP6OPT_MINLEN + IP6OPT_BRLEN)
103 #define IP6OPT_BUMINLEN (IP6OPT_MINLEN + IP6OPT_BULEN)
104 #define IP6OPT_HAMINLEN (IP6OPT_MINLEN + IP6OPT_HALEN)
105
106
107 /* Definition of sub-options used by the Destination Options */
108 #define IP6SUBOPT_UNIQUEID 0x02 /* Unique Identifier (BU, BR) */
109 #define IP6SUBOPT_HALIST 0x03 /* Home Agents List (BA) */
110 #define IP6SUBOPT_ALTCOA 0x04 /* Alternate COA (BU) */
111
112
113 /* Definition of MIPv6 Binding Update option flags */
114 #define MIP6_BU_AFLAG 0x80 /* BU Acknowledgement flag present */
115 #define MIP6_BU_HFLAG 0x40 /* BU Home Registration flag present */
116 #define MIP6_BU_RFLAG 0x20 /* BU MN is Router flag present */
117
118
119 /* Definition of flags used for indication of options present in a
120 destination header (mip6_indata->optflag) */
121 #define MIP6_DSTOPT_BU 0x80 /* BU Option present */
122 #define MIP6_DSTOPT_BA 0x40 /* BA Option present */
123 #define MIP6_DSTOPT_BR 0x20 /* BR Option present */
124 #define MIP6_DSTOPT_HA 0x10 /* HA Option present */
125 #define MIP6_DSTOPT_UID 0x08 /* Sub-option Unique Id present */
126 #define MIP6_DSTOPT_COA 0x04 /* Sub-option Alternate COA present */
127 #define MIP6_DSTOPT_HAL 0x02 /* Sub-option HAs List present */
128
129
130 #if 0
131 /* Definition of flags for Home Agent */
132 #define ND_RA_FLAG_HA 0x20 /* RA indicates that router works as HA */
133 #define ND_OPT_PI_FLAG_RADDR 0x20 /* Prefix Information option incl. global
134 IP address */
135 #endif
136
137
138 /* Definition of timers for signals */
139 #define MIP6_BU_LIFETIME 600 /* Lifetime for BU (s) */
140 #define MIP6_BU_LIFETIME_DEFRTR 60 /* Lifetime for BU sent to previous def
141 router (s) */
142 #define MIP6_BU_LIFETIME_DHAAD 16 /* Lifetime for BU when Dynamic Home
143 Agent Address Discovery (s) */
144 #define MIP6_MAX_FAST_UPDATES 5 /* Max number of fast updates (BUs)
145 being sent */
146 #define MIP6_MAX_UPDATE_RATE 1 /* Rate limiting for sending successive
147 fast BUs (sec) */
148 #define MIP6_SLOW_UPDATE_RATE 10 /* Rate limiting for sending successive
149 slow BUs (sec) */
150 #define MIP6_MAX_BINDACK_TIMEOUT 256 /* Max time to wait for a BA */
151 #define MIP6_MAX_ADVERT_REXMIT 3 /* Max retransmission of NA when retur-
152 ning to home link */
153 #define MIP6_OUTQ_LIFETIME 20 /* Max number of 0.1s units that an entry
154 is stored in the output queue */
155 #define MIP6_OUTQ_INTERVAL 5 /* Interval in units of 0.1s that the out
156 queue is searched */
157
158
159 /* Definition of Binding Acknowledgement status field */
160 #define MIP6_BA_STATUS_ACCEPT 0 /* Binding Update accepted */
161 #define MIP6_BA_STATUS_UNSPEC 128 /* Reason unspecified */
162 #define MIP6_BA_STATUS_PROHIBIT 130 /* Administratively prohibited */
163 #define MIP6_BA_STATUS_RESOURCE 131 /* Insufficient resources */
164 #define MIP6_BA_STATUS_HOMEREGNOSUP 132 /* Home registration not supported */
165 #define MIP6_BA_STATUS_SUBNET 133 /* Not home subnet */
166 #define MIP6_BA_STATUS_DHAAD 135 /* Dynamic home agent address
167 discovery response */
168 #define MIP6_BA_STATUS_IFLEN 136 /* Incorrect interface id length */
169 #define MIP6_BA_STATUS_NOTHA 137 /* Not home agent for this MN */
170
171
172 /* Macro for modulo 2^^16 comparison */
173 #define MIP6_LEQ(a,b) ((int16_t)((a)-(b)) <= 0)
174
175
176 /* Macros started with MIP6_ADDR is Mobile IPv6 local */
177 #define MIP6_ADDR_ANYCAST_HA 0x7e
178
179 #if BYTE_ORDER == BIG_ENDIAN
180 #define MIP6_ADDR_INT32_ULL 0xfe800000 /* Unicast Link Local */
181 #define MIP6_ADDR_INT32_USL 0xfec00000 /* Unicast Site Local */
182 #define MIP6_ADDR_INT32_AHA1 0xfffffffe /* Anycast Home Agent bit 97-128 */
183 #define MIP6_ADDR_INT32_AHA2 0xfdffffff /* Anycast Home Agent bit 65-96 */
184 #elif BYTE_ORDER == LITTLE_ENDIAN
185 #define MIP6_ADDR_INT32_ULL 0x000080fe
186 #define MIP6_ADDR_INT32_USL 0x0000c0fe
187 #define MIP6_ADDR_INT32_AHA1 0xfeffffff
188 #define MIP6_ADDR_INT32_AHA2 0xfffffffd
189 #endif
190
191
192 /* Definition of some useful macros to handle IP6 addresses */
193 extern struct in6_addr in6addr_linklocal;
194 extern struct in6_addr in6addr_sitelocal;
195 extern struct in6_addr in6addr_aha_64; /* 64 bits identifier */
196 extern struct in6_addr in6addr_aha_nn; /* 121-nn bits identifier */
197
198
199 /* Definition of states for flag in queue for outgoing packets. */
200 enum send_state {NOT_SENT, SENT};
201
202
203 /* Definition of event-state machine type. */
204 enum esm_type {PERMANENT, TEMPORARY};
205
206
207 /* Configuration parameters needed for MIPv6. Controlled by the user */
208 struct mip6_static_addr {
209 LIST_ENTRY(mip6_static_addr) addr_entry; /* Next IPv6 address list */
210 struct ifnet *ifp; /* Interface */
211 u_int8_t prefix_len; /* Prefix length for address */
212 struct in6_addr ip6_addr; /* Address to be used at foreign network */
213 };
214
215
216 /*
217 * fna_list List of pre-assigned care-of addresses to be used at
218 * foreign networks that the MN might visit
219 * bu_lifetime Used by the MN when sending a BU to the CN if it wants
220 * to use a smaller value than received in the home
221 * registration acknowledgement
222 * br_update Indicates when the CN sends a BR to the MN. The value
223 * should be given as percentage of the bu_lifetime
224 * ha_pref Preference for the Home Agent
225 * hr_lifetime Default life time for home registration (only sent to the
226 * Home Agent)
227 * fwd_sl_unicast Enable forwarding of site local unicast dest addresses
228 * fwd_sl_multicast Enable forwarding of site local multicast dest addresses
229 * enable_prom_mode Enable link layer promiscus mode (used by move detection)
230 * enable_bu_to_cn Enable BU being sent to the CN (Route optimization on/off)
231 * enable_rev_tunnel Enable tunneling of packets from MN to CN via Home Agent
232 * enable_br Enable sending BR to the MN
233 * autoconfig Only enable MIP6 if the mip6 deamon is running
234 * eager_md Enable eager Movement Detection
235 * enable_outq Enable reading from the MIP6 output queue for piggy
236 * backing (Not configurable, handled internally)
237 */
238 struct mip6_config {
239 LIST_HEAD(fna_list, mip6_static_addr) fna_list;
240 u_int32_t bu_lifetime;
241 u_int8_t br_update;
242 int16_t ha_pref;
243 u_int32_t hr_lifetime;
244 u_int8_t fwd_sl_unicast;
245 u_int8_t fwd_sl_multicast;
246 u_int8_t enable_prom_mode;
247 u_int8_t enable_bu_to_cn;
248 u_int8_t enable_rev_tunnel;
249 u_int8_t enable_br;
250 u_int8_t autoconfig;
251 u_int8_t eager_md;
252 u_int8_t enable_outq;
253 };
254
255
256 /* Generic option format */
257 struct mip6_bu_data {
258 u_int8_t prefix_len; /* Prefix length for a Home Address */
259 u_int8_t ack; /* Acknowledgement flag */
260 };
261
262
263 /* Generic option format */
264 struct mip6_opt {
265 u_int8_t type; /* Option type */
266 u_int8_t len; /* Option length (octets) excl. type and length */
267 } __attribute__ ((packed));
268
269
270 /* List of prefixes extracted from Router Advertisments being sent by
271 the Home Agent. */
272 struct mip6_prefix {
273 struct mip6_prefix *next; /* Ptr to next entry in the list */
274 struct ifnet *ifp; /* Outgoing interface */
275 struct in6_addr prefix; /* Announced prefix (on-link) */
276 u_int8_t prefix_len; /* Prefix length for IP address */
277 u_int32_t valid_time; /* Remaining (s) until prefix expires */
278 } __attribute__ ((packed));
279
280
281 /* Binding Update destination option format */
282 struct mip6_opt_bu {
283 u_int8_t type; /* Option type */
284 u_int8_t len; /* Option length excluding Type and length */
285 u_int8_t flags; /* Flags (A, H and R) */
286 u_int8_t prefix_len; /* Prefix length for IP address */
287 u_int16_t seqno; /* Sequence number */
288 u_int32_t lifetime; /* Seconds remaining until the binding expires */
289 } __attribute__ ((packed));
290
291
292 /* Binding Acknowledgement destination option format */
293 struct mip6_opt_ba {
294 u_int8_t type; /* Option type */
295 u_int8_t len; /* Option length (octets) excl. type and length */
296 u_int8_t status; /* Result of the BU */
297 u_int16_t seqno; /* Sequence number */
298 u_int32_t lifetime; /* Granted lifetime (s) for the BU in the BC */
299 u_int32_t refresh; /* Interval for MN to send BU to refresh BC */
300 } __attribute__ ((packed));
301
302
303 /* Binding Request destination option format */
304 struct mip6_opt_br {
305 u_int8_t type; /* Option type */
306 u_int8_t len; /* Option length (octets) excl. type and length */
307 } __attribute__ ((packed));
308
309
310 /* Home Address option format */
311 struct mip6_opt_ha {
312 u_int8_t type; /* Option type */
313 u_int8_t len; /* Option length excl. type and length */
314 struct in6_addr home_addr; /* Home Addr of the MN sending the packet */
315 } __attribute__ ((packed));
316
317
318 /* Unique Identifier sub-option format */
319 struct mip6_subopt_id {
320 u_int8_t type; /* Sub-option type */
321 u_int8_t len; /* Sub-option length (octets) excl. type and length */
322 u_int16_t id; /* Unique identifier */
323 } __attribute__ ((packed));
324
325
326 /* Home Agents list sub-option format */
327 struct mip6_subopt_hal {
328 u_int8_t type; /* Sub-option type */
329 u_int8_t len; /* Sub-option length excl. type and length */
330 struct in6_addr halist[1]; /* List of HA's on the home link */
331 } __attribute__ ((packed));
332
333
334 /* Alternate Care-of Address sub-option format */
335 struct mip6_subopt_coa {
336 u_int8_t type; /* Sub-option type */
337 u_int8_t len; /* Length (octets) excl. type and len fields */
338 struct in6_addr coa; /* Alternate COA */
339 } __attribute__ ((packed));
340
341
342 /* Buffer for storing a consequtive sequence of sub-options */
343 struct mip6_subbuf {
344 u_int16_t len; /* # of used bytes in buffer */
345 char buffer[512];
346 };
347
348
349 /* The event-state machine must be maintained for each Home Address. */
350 struct mip6_dad {
351 struct mip6_subopt_hal *hal; /* Home Agents list */
352 int index; /* Next entry in list to try */
353 };
354
355 struct mip6_hafn {
356 time_t time; /* Absolute expire time */
357 int16_t pref; /* Preference for this HA */
358 u_int8_t prefix_len; /* Prefix_len for HA Address */
359 struct in6_addr addr; /* FN Home Agent global unicast address */
360 };
361
362 struct mip6_esm {
363 struct mip6_esm *next; /* Ptr to next entry in the list */
364 struct ifnet *ifp; /* I/f where home address is applied */
365 const struct encaptab *ep; /* Encapsulation attach (MN -> HA) */
366 int state; /* State for the home address */
367 enum esm_type type; /* Type of event-state machine */
368 struct in6_addr home_addr; /* Home address */
369 u_int8_t prefix_len; /* Prefix_len for Home Address */
370 u_int16_t lifetime; /* if type=PERMANENT 0xFFFF, else x */
371 struct in6_addr ha_hn; /* Home agent address (home network) */
372 struct in6_addr coa; /* Current primary care-of address */
373 struct mip6_hafn *ha_fn; /* Home agent address (foreign network) */
374 struct mip6_dad *dad; /* For Dynamic HA Address Discovery */
375 };
376
377
378 /* Binding Cache parameters. Bindings for other IPv6 nodes. */
379 /* Maintained by each node. */
380 struct bc_info {
381 u_int32_t br_interval; /* % of mip6_lifetime, max 60s, min 2s */
382 u_int8_t no_of_sent_br; /* Number of sent BR to a Mobile Node */
383 u_int8_t max_advert; /* ? */
384 u_int8_t ra_tunneled; /* RA being tunneled to MN */
385 u_int8_t ra_interval; /* Interval for sending RA */
386 };
387
388 struct mip6_bc {
389 struct mip6_bc *next; /* Ptr to next entry in the list */
390 struct in6_addr home_addr; /* Home Address of the MN for which this is
391 the BC entry */
392 struct in6_addr coa; /* COA for MN indicated by the HA field */
393 u_int32_t lifetime; /* Remaining lifetime for this BC entry */
394 u_int8_t hr_flag; /* Flag for home registration entry (T/F) */
395 u_int8_t rtr_flag; /* MN is a router (T/F) */
396 u_int8_t prefix_len; /* Prefix length in last received BU */
397 u_int16_t seqno; /* Maximum value of the sequence number */
398 struct bc_info info; /* Usage info for cache replacement policy */
399 time_t lasttime; /* The time at which a BR was last sent */
400 const struct encaptab *ep; /* Encapsulation attach (HA -> MN) */
401 };
402
403
404
405 /* Binding Update List parameters. Information for each BU sent by this MN */
406 /* Each MN maintains this list. */
407 struct mip6_retrans {
408 struct mip6_opt_bu *bu_opt; /* BU option in case of retransmission */
409 struct mip6_subbuf *bu_subopt; /* BU sub-option in case of retrans. */
410 u_int8_t ba_timeout; /* Exponential back-off starting at 1 */
411 u_int8_t time_left; /* Time left until next retransmission */
412 };
413
414 struct mip6_bul {
415 struct mip6_bul *next; /* Ptr to next entry in the list */
416 struct in6_addr dst_addr; /* Destination address for sent BU */
417 struct in6_addr bind_addr; /* Home Address or previous COA */
418 struct in6_addr coa; /* Care-of address sent in the BU */
419 u_int32_t lifetime; /* Remaining binding lifetime */
420 u_int32_t refreshtime; /* Refresh time for the BU */
421 u_int16_t seqno; /* Last value for sent seq number */
422 time_t lasttime; /* Time at which a BU was last sent */
423 u_int32_t no_of_sent_bu; /* Number of sent BU to a MN */
424 struct mip6_retrans *state; /* Status for BU being acknowledged */
425 u_int8_t bu_flag; /* Flag for sending future BU (T/F) */
426 u_int8_t hr_flag; /* Flag for home reg (True / False) */
427 u_int8_t update_rate; /* Seconds between consequtive BUs */
428 };
429
430
431 /* Home Agent List parameters. Information about each other HA on the link
432 that this node is serving as a HA. One HA list for each link it is
433 serving. */
434 /* Each HA maintains this list. */
435 struct mip6_addr_list {
436 struct mip6_addr_list *next; /* Ptr to next entry in the list */
437 struct in6_addr ip6_addr; /* IPv6 address */
438 u_int8_t prefix_len;
439 };
440
441 struct mip6_ha_list {
442 struct mip6_ha_list *next; /* Ptr to next entry in the list */
443 struct in6_addr ll_addr; /* Link-local IP-addr of a node on
444 the home link */
445 u_int16_t lifetime; /* Remaining lifetime of this HA
446 list entry */
447 int16_t pref; /* Preference for this HA */
448 struct mip6_addr_list *addr_list; /* List of global IP addresses for
449 this HA */
450 };
451
452 struct mip6_link_list {
453 struct mip6_link_list *next; /* Ptr to next entry in the list */
454 struct mip6_ha_list *ha_list; /* List of Home Agents for the link */
455 struct ifnet *ifp; /* Interface */
456 char ifname[IFNAMSIZ+1]; /* Link identifier */
457 };
458
459
460 /* Neighbor Advertisement information stored for retransmission when the
461 Mobile Node is returning to its Home Network or the Home Agent is
462 requested to act as a proxy for the Mobile Node when it is moving to a
463 Foreign Network. */
464 struct mip6_na
465 {
466 struct mip6_na *next; /* Ptr to next entry in the list */
467 struct ifnet *ifp; /* Interface for sending the NA */
468 struct in6_addr home_addr; /* Home address of the mobile node */
469 struct in6_addr dst_addr; /* Destination address */
470 struct in6_addr target_addr; /* Target address */
471 u_int8_t prefix_len; /* Prefix length for home address */
472 u_long flags; /* Flags for the NA message */
473 int use_link_opt; /* Include Target link layer address
474 option or not
475 (0 = Do not include, 1 = Include) */
476 int no; /* Remaining no of times to send the NA */
477 };
478
479
480 /* Definition of global variable used by Mobile IPv6. All variables are
481 stored in node byte order. */
482 struct mip6_indata {
483 u_int8_t flag; /* How to handle tunneled packets */
484 u_int8_t optflag; /* Dest options and sub-options flag */
485 struct in6_addr ip6_src; /* Orig src addr from IPv6 header */
486 struct in6_addr ip6_dst; /* Orig dst addr from IPv6 header */
487 struct mip6_opt_bu *bu_opt; /* BU option present */
488 struct mip6_opt_ba *ba_opt; /* BA option present */
489 struct mip6_opt_br *br_opt; /* BR option present */
490 struct mip6_opt_ha *ha_opt; /* HA option present */
491 struct mip6_subopt_id *uid; /* Sub-option Unique ID present */
492 struct mip6_subopt_coa *coa; /* Sub-option alt coa present */
493 struct mip6_subopt_hal *hal; /* Sub-option HAs List present */
494 };
495
496
497 /* Queue of outgoing packets that are waiting to be sent. */
498 struct mip6_output {
499 struct mip6_output *next; /* Ptr to next option in chain */
500 void *opt; /* BU, BA or BR dest option to be sent */
501 struct mip6_subbuf *subopt; /* Sub-option to be sent (if present) */
502 struct in6_addr ip6_dst; /* Destination address for IPv6 packet */
503 struct in6_addr ip6_src; /* Source address for IPv6 packet */
504 enum send_state flag; /* Has packet been sent or not? */
505 u_int32_t lifetime; /* Time remaining for entry in output queue
506 (units of 0.1s) */
507 };
508
509 #ifdef KERNEL
510
511 /*
512 * Macro MIP6_FREEINDATA free memory allocated for the global variable
513 * mip6_inp and its members. Set the variable to point at NULL when
514 * the memory has been freed.
515 */
516 #define MIP6_FREEINDATA \
517 do { \
518 if (mip6_inp != NULL) { \
519 if (mip6_inp->bu_opt != NULL) \
520 _FREE(mip6_inp->bu_opt, M_TEMP); \
521 if (mip6_inp->ba_opt != NULL) \
522 _FREE(mip6_inp->ba_opt, M_TEMP); \
523 if (mip6_inp->br_opt != NULL) \
524 _FREE(mip6_inp->br_opt, M_TEMP); \
525 if (mip6_inp->ha_opt != NULL) \
526 _FREE(mip6_inp->ha_opt, M_TEMP); \
527 if (mip6_inp->uid != NULL) \
528 _FREE(mip6_inp->uid, M_TEMP); \
529 if (mip6_inp->coa != NULL) \
530 _FREE(mip6_inp->coa, M_TEMP); \
531 if (mip6_inp->hal != NULL) \
532 _FREE(mip6_inp->hal, M_TEMP); \
533 _FREE(mip6_inp, M_TEMP); \
534 mip6_inp = NULL; \
535 } \
536 } while (0)
537
538 #define MIP6_IS_MN_ACTIVE ((mip6_module & MIP6_MN_MODULE) == MIP6_MN_MODULE)
539 #define MIP6_IS_HA_ACTIVE ((mip6_module & MIP6_HA_MODULE) == MIP6_HA_MODULE)
540
541
542 /* External Declaration of Global variables. */
543 extern struct mip6_indata *mip6_inp; /* Input data rec in one packet */
544 extern struct mip6_output *mip6_outq; /* Ptr to output queue */
545 extern struct mip6_esm *mip6_esmq; /* Ptr to list of Home Addresses */
546 extern struct mip6_bc *mip6_bcq; /* First entry in the BC list */
547 extern struct mip6_prefix *mip6_pq; /* First entry in prefix list */
548 extern struct mip6_config mip6_config; /* Config parameters for MIP6 */
549 extern struct mip6_bul *mip6_bulq;
550 extern struct mip6_link_list *mip6_llq;
551 extern struct nd_prefix *mip6_home_prefix;
552 extern struct nd_prefix *mip6_primary_prefix;
553
554 extern u_int8_t mip6_module; /* Info about loaded modules (MN/HA) */
555 extern int mip6_md_state; /* Movement Detection state */
556 extern int mip6_route_state; /* Home Address route state */
557 extern int mip6_max_lost_advints; /* No. lost Adv before start of NUD */
558 extern int mip6_nd6_delay;
559 extern int mip6_nd6_umaxtries;
560
561
562 /* External declaration of function prototypes (mip6_io.c) */
563 extern int mip6_new_packet
564 __P((struct mbuf *));
565 extern int mip6_store_dstopt_pre
566 __P((struct mbuf *, u_int8_t *, u_int8_t, u_int8_t));
567 extern int mip6_store_dstopt
568 __P((struct mbuf *, u_int8_t *, u_int8_t));
569 extern int mip6_store_dstsubopt
570 __P((struct mbuf *, u_int8_t *, u_int8_t, int, int));
571 extern int mip6_output
572 __P((struct mbuf *, struct ip6_pktopts **));
573 extern int mip6_add_rh
574 __P((struct ip6_pktopts **, struct mip6_bc *));
575 extern void mip6_align
576 __P((struct ip6_dest *, int *));
577 extern void mip6_dest_offset
578 __P((struct ip6_dest *, int *));
579 extern int mip6_add_ha
580 __P((struct ip6_dest **, int *, struct in6_addr *, struct in6_addr *));
581 extern int mip6_add_bu
582 __P((struct ip6_dest **, int *, struct mip6_opt_bu *,
583 struct mip6_subbuf *));
584 extern int mip6_add_ba
585 __P((struct ip6_dest **, int *, struct mip6_opt_ba *,
586 struct mip6_subbuf *));
587 extern int mip6_add_br
588 __P((struct ip6_dest **, int *, struct mip6_opt_br *,
589 struct mip6_subbuf *));
590 extern int mip6_store_subopt
591 __P((struct mip6_subbuf **, caddr_t));
592
593
594 /* External declaration of function prototypes (mip6.c) */
595 extern void mip6_init
596 __P((void));
597 extern void mip6_exit
598 __P((void));
599 extern int mip6_rec_ctrl_sig
600 __P((struct mbuf *, int));
601 extern int mip6_icmp6_input
602 __P((struct mbuf *, int));
603 extern int mip6_rec_bu
604 __P((struct mbuf *, int));
605 extern void mip6_ha2srcaddr
606 __P((struct mbuf *));
607 extern int mip6_send_ba
608 __P((struct in6_addr *, struct in6_addr *, struct in6_addr *,
609 struct mip6_subbuf *, u_int8_t, u_int16_t, u_int32_t));
610 extern void mip6_send_na
611 __P((struct mip6_na *));
612 extern struct mbuf *mip6_create_ip6hdr
613 __P((struct in6_addr *, struct in6_addr *, u_int8_t));
614 extern struct ip6_rthdr *mip6_create_rh
615 __P((struct in6_addr *, u_int8_t));
616 extern struct mip6_opt_ba *mip6_create_ba
617 __P((u_int8_t, u_int16_t, u_int32_t));
618 extern struct ip6_dest *mip6_create_dh
619 __P((void *, struct mip6_subbuf *, u_int8_t));
620 extern int mip6_opt_offset
621 __P((struct mbuf *, int, int));
622 extern int mip6_addr_on_link
623 __P((struct in6_addr *, int));
624 extern u_int32_t mip6_min_lifetime
625 __P((struct in6_addr *, int));
626 extern void mip6_build_in6addr
627 __P((struct in6_addr *, struct in6_addr *, const struct in6_addr *,
628 int));
629 extern void mip6_build_ha_anycast
630 __P((struct in6_addr *, const struct in6_addr *, int));
631 extern int mip6_add_ifaddr
632 __P((struct in6_addr *addr, struct ifnet *ifp, int plen, int flags));
633 extern int mip6_tunnel_output
634 __P((struct mbuf **, struct mip6_bc *));
635 extern int mip6_tunnel_input
636 __P((struct mbuf **, int *, int));
637 extern int mip6_tunnel
638 __P((struct in6_addr *, struct in6_addr *, int, int, void *));
639 extern int mip6_proxy
640 __P((struct in6_addr*, struct in6_addr*, int));
641 extern struct mip6_bc *mip6_bc_find
642 __P((struct in6_addr *));
643 extern struct mip6_bc *mip6_bc_create
644 __P((struct in6_addr *, struct in6_addr *, u_int32_t, u_int8_t,
645 u_int8_t, u_int8_t, u_int16_t));
646 extern void mip6_bc_update
647 __P((struct mip6_bc *, struct in6_addr *, u_int32_t, u_int8_t,
648 u_int8_t, u_int8_t, u_int16_t, struct bc_info, time_t));
649 extern int mip6_bc_delete
650 __P((struct mip6_bc *, struct mip6_bc **));
651 extern struct mip6_na *mip6_na_create
652 __P((struct in6_addr *, struct in6_addr *, struct in6_addr *,
653 u_int8_t, u_long, int));
654 extern struct mip6_na *mip6_na_delete
655 __P((struct mip6_na *));
656 extern struct mip6_prefix *mip6_prefix_find
657 __P((struct in6_addr *, u_int8_t));
658 extern struct mip6_prefix *mip6_prefix_create
659 __P((struct ifnet *, struct in6_addr *, u_int8_t, u_int32_t));
660 extern struct mip6_prefix *mip6_prefix_delete
661 __P((struct mip6_prefix *));
662 extern void mip6_timer_na
663 __P((void *));
664 extern void mip6_timer_bc
665 __P((void *));
666 extern void mip6_timer_prefix
667 __P((void *));
668
669 #if !defined(__bsdi__) && !(defined(__FreeBSD__) && __FreeBSD__ < 3)
670 extern int mip6_ioctl __P((struct socket *, u_long, caddr_t, struct ifnet *,
671 struct proc *));
672 #else
673 extern int mip6_ioctl __P((struct socket *, u_long, caddr_t, struct ifnet *));
674 #endif
675
676 #if MIP6_DEBUG
677 void mip6_debug __P((char *, ...));
678 #endif
679
680 extern void mip6_enable_debug
681 __P((int));
682 extern int mip6_write_config_data
683 __P((u_long, caddr_t));
684 extern int mip6_clear_config_data
685 __P((u_long, caddr_t));
686 extern int mip6_enable_func
687 __P((u_long, caddr_t));
688
689
690 /* External declaration of function prototypes (mip6_md.c) */
691 extern void mip6_md_init
692 __P((void));
693 extern void mip6_select_defrtr
694 __P((void));
695 extern void mip6_prelist_update
696 __P((struct nd_prefix *, struct nd_defrouter *));
697 extern void mip6_eager_md
698 __P((int enable));
699 extern void mip6_expired_defrouter
700 __P((struct nd_defrouter *dr));
701 extern void mip6_probe_defrouter
702 __P((struct nd_defrouter *dr));
703 extern void mip6_probe_pfxrtrs
704 __P((void));
705 extern void mip6_store_advint
706 __P((struct nd_opt_advint *, struct nd_defrouter *));
707 extern int mip6_delete_ifaddr
708 __P((struct in6_addr *addr, struct ifnet *ifp));
709 extern struct nd_prefix *mip6_get_home_prefix
710 __P((void));
711 extern int mip6_get_md_state
712 __P((void));
713 extern void mip6_md_exit
714 __P((void));
715
716
717 /* External declaration of function prototypes (mip6_mn.c) */
718 extern void mip6_mn_init
719 __P((void));
720 extern void mip6_mn_exit
721 __P((void));
722 extern void mip6_new_defrtr
723 __P((int, struct nd_prefix *, struct nd_prefix *,
724 struct nd_defrouter *));
725 extern int mip6_rec_ba
726 __P((struct mbuf *, int));
727 extern int mip6_rec_br
728 __P((struct mbuf *, int));
729 extern int mip6_rec_hal
730 __P((struct in6_addr *, struct in6_addr *, struct mip6_subopt_hal *));
731 extern int mip6_rec_ramn
732 __P((struct mbuf *, int));
733 extern int mip6_route_optimize
734 __P((struct mbuf *));
735 extern int mip6_send_bu
736 __P((struct mip6_bul *, struct mip6_bu_data *, struct mip6_subbuf *));
737 extern void mip6_send_bu2fn
738 __P((struct in6_addr *, struct mip6_hafn *, struct in6_addr *,
739 struct ifnet *, u_int32_t));
740 extern void mip6_update_cns
741 __P((struct in6_addr *, struct in6_addr *, u_int8_t, u_int32_t));
742 extern void mip6_queue_bu
743 __P((struct mip6_bul *, struct in6_addr *, struct in6_addr *,
744 u_int8_t, u_int32_t));
745 extern struct mip6_opt_bu *mip6_create_bu
746 __P((u_int8_t, int, int, u_int16_t, u_int32_t));
747 extern void mip6_stop_bu
748 __P((struct in6_addr *));
749 extern int mip6_ba_error
750 __P((struct in6_addr *, struct in6_addr *, struct in6_addr *,
751 u_int8_t));
752 extern u_int32_t mip6_prefix_lifetime
753 __P((struct in6_addr *));
754 extern struct mip6_retrans * mip6_create_retrans
755 __P((struct mip6_bul *));
756 extern void mip6_clear_retrans
757 __P((struct mip6_bul *));
758 extern struct mip6_bul *mip6_bul_find
759 __P((struct in6_addr *, struct in6_addr *));
760 extern struct mip6_bul *mip6_bul_create
761 __P((struct in6_addr *, struct in6_addr *, struct in6_addr *,
762 u_int32_t, u_int8_t));
763 extern struct mip6_bul *mip6_bul_delete
764 __P((struct mip6_bul *));
765 extern struct mip6_esm *mip6_esm_find
766 __P((struct in6_addr *));
767 extern struct mip6_esm *mip6_esm_create
768 __P((struct ifnet *, struct in6_addr *, struct in6_addr *,
769 struct in6_addr *, u_int8_t, int, enum esm_type, u_int16_t));
770 extern struct mip6_esm *mip6_esm_delete
771 __P((struct mip6_esm *));
772 extern int mip6_outq_create
773 __P((void *, struct mip6_subbuf *, struct in6_addr *,
774 struct in6_addr *, enum send_state));
775 extern struct mip6_output *mip6_outq_delete
776 __P((struct mip6_output *));
777 extern void mip6_outq_flush
778 __P((void));
779 extern void mip6_timer_outqueue
780 __P((void *));
781 extern void mip6_timer_bul
782 __P((void *));
783 extern void mip6_timer_esm
784 __P((void *));
785 extern int mip6_write_config_data_mn
786 __P((u_long, void *));
787 extern int mip6_clear_config_data_mn
788 __P((u_long, caddr_t));
789 extern int mip6_enable_func_mn
790 __P((u_long, caddr_t));
791
792
793 /* External declaration of function prototypes (mip6_ha.c). */
794 extern void mip6_ha_init
795 __P((void));
796 extern void mip6_ha_exit
797 __P((void));
798 extern int mip6_rec_raha
799 __P((struct mbuf *, int));
800 extern int mip6_ra_options
801 __P((struct mip6_ha_list *, caddr_t, int));
802 extern struct mip6_subopt_hal * mip6_hal_dynamic
803 __P((struct in6_addr *));
804 extern struct in6_addr *mip6_global_addr
805 __P((struct in6_addr *));
806 extern void mip6_icmp6_output
807 __P((struct mbuf *));
808 extern void mip6_prefix_examine
809 __P((struct mip6_ha_list *, struct ifnet *, caddr_t, int));
810 extern struct mip6_link_list *mip6_ll_find
811 __P((char *));
812 extern struct mip6_link_list *mip6_ll_create
813 __P((char *, struct ifnet *));
814 extern struct mip6_link_list *mip6_ll_delete
815 __P((struct mip6_link_list *));
816 extern struct mip6_ha_list *mip6_hal_find
817 __P((struct mip6_ha_list *, struct in6_addr *));
818 extern struct mip6_ha_list *mip6_hal_create
819 __P((struct mip6_ha_list **, struct in6_addr *, u_int32_t, int16_t));
820 extern void mip6_hal_sort
821 __P((struct mip6_ha_list **));
822 extern struct mip6_ha_list *mip6_hal_delete
823 __P((struct mip6_ha_list **, struct mip6_ha_list *));
824 extern void mip6_timer_ll
825 __P((void *));
826 extern int mip6_write_config_data_ha
827 __P((u_long, void *));
828 extern int mip6_clear_config_data_ha
829 __P((u_long, void *));
830 extern int mip6_enable_func_ha
831 __P((u_long, caddr_t));
832
833
834 /* External declaration of function prototypes (mip6_hooks.c). */
835 extern void mip6_minus_a_case
836 __P((struct nd_prefix *));
837 extern struct nd_prefix *mip6_find_auto_home_addr
838 __P((void));
839 extern void mip6_enable_hooks
840 __P((int));
841 extern void mip6_disable_hooks
842 __P((int));
843 extern int mip6_attach
844 __P((int));
845 extern int mip6_release
846 __P((void));
847
848
849 #if defined(__FreeBSD__) && __FreeBSD__ >= 3
850 extern struct callout_handle mip6_timer_na_handle;
851 extern struct callout_handle mip6_timer_bc_handle;
852 extern struct callout_handle mip6_timer_outqueue_handle;
853 extern struct callout_handle mip6_timer_bul_handle;
854 extern struct callout_handle mip6_timer_esm_handle;
855 extern struct callout_handle mip6_timer_prefix_handle;
856 extern struct callout_handle mip6_timer_ll_handle;
857 #endif
858
859 #endif /* _KERNEL */
860
861 #endif /* not _NETINET6_MIP6_H_ */