Initial import from FreeBSD RELENG_4:
[dragonfly.git] / sys / netinet6 / in6_prefix.h
1 /*      $FreeBSD: src/sys/netinet6/in6_prefix.h,v 1.1.2.2 2001/07/03 11:01:52 ume Exp $ */
2 /*      $KAME: in6_prefix.h,v 1.10 2001/02/08 16:30:30 itojun Exp $     */
3
4 /*
5  * Copyright (C) 1995, 1996, 1997, 1998 and 1999 WIDE Project.
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
33 #include <sys/callout.h>
34
35 struct rr_prefix {
36         struct ifprefix rp_ifpr;
37         LIST_ENTRY(rr_prefix) rp_entry;
38         LIST_HEAD(rp_addrhead, rp_addr) rp_addrhead;
39         struct sockaddr_in6 rp_prefix;  /* prefix */
40         u_int32_t rp_vltime;    /* advertised valid lifetime */
41         u_int32_t rp_pltime;    /* advertised preferred lifetime */
42         time_t rp_expire;       /* expiration time of the prefix */
43         time_t rp_preferred;    /* preferred time of the prefix */
44         struct in6_prflags rp_flags;
45         u_char  rp_origin; /* from where this prefix info is obtained */
46         struct  rp_stateflags {
47                 /* if some prefix should be added to this prefix */
48                 u_char addmark : 1;
49                 u_char delmark : 1; /* if this prefix will be deleted */
50         } rp_stateflags;
51 };
52
53 #define rp_type         rp_ifpr.ifpr_type
54 #define rp_ifp          rp_ifpr.ifpr_ifp
55 #define rp_plen         rp_ifpr.ifpr_plen
56
57 #define rp_raf          rp_flags.prf_ra
58 #define rp_raf_onlink           rp_flags.prf_ra.onlink
59 #define rp_raf_auto             rp_flags.prf_ra.autonomous
60
61 #define rp_statef_addmark       rp_stateflags.addmark
62 #define rp_statef_delmark       rp_stateflags.delmark
63
64 #define rp_rrf          rp_flags.prf_rr
65 #define rp_rrf_decrvalid        rp_flags.prf_rr.decrvalid
66 #define rp_rrf_decrprefd        rp_flags.prf_rr.decrprefd
67
68 struct rp_addr {
69         LIST_ENTRY(rp_addr)     ra_entry;
70         struct in6_addr         ra_ifid;
71         struct in6_ifaddr       *ra_addr;
72         struct ra_flags {
73                 u_char anycast : 1;
74         } ra_flags;
75 };
76
77 #define ifpr2rp(ifpr)   ((struct rr_prefix *)(ifpr))
78 #define rp2ifpr(rp)     ((struct ifprefix *)(rp))
79
80 #define RP_IN6(rp)      (&(rp)->rp_prefix.sin6_addr)
81
82 #define RR_INFINITE_LIFETIME            0xffffffff
83
84
85 LIST_HEAD(rr_prhead, rr_prefix);
86
87 extern struct rr_prhead rr_prefix;
88
89 void in6_rr_timer __P((void *));
90 extern struct callout in6_rr_timer_ch;
91 int delete_each_prefix  __P((struct rr_prefix *rpp, u_char origin));