8ebb4bde424741506d8706a514f036be9a70733d
[oftp] / libs / watt32 / netinet6 / in6_pref.h
1 /*!\file netinet6/in6_pref.h
2  *
3  */
4
5 /*      $FreeBSD: src/sys/netinet6/in6_prefix.h,v 1.5 2001/06/11 12:39:05 ume Exp $     */
6 /*      $KAME: in6_prefix.h,v 1.10 2001/02/08 16:30:30 itojun Exp $     */
7
8 /*
9  * Copyright (C) 1995, 1996, 1997, 1998 and 1999 WIDE Project.
10  * All rights reserved.
11  *
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions
14  * are met:
15  * 1. Redistributions of source code must retain the above copyright
16  *    notice, this list of conditions and the following disclaimer.
17  * 2. Redistributions in binary form must reproduce the above copyright
18  *    notice, this list of conditions and the following disclaimer in the
19  *    documentation and/or other materials provided with the distribution.
20  * 3. Neither the name of the project nor the names of its contributors
21  *    may be used to endorse or promote products derived from this software
22  *    without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
25  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
28  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34  * SUCH DAMAGE.
35  */
36
37 #include <sys/callout.h>
38
39 struct rr_prefix {
40         struct ifprefix rp_ifpr;
41         LIST_ENTRY(rr_prefix) rp_entry;
42         LIST_HEAD(rp_addrhead, rp_addr) rp_addrhead;
43         struct sockaddr_in6 rp_prefix;  /* prefix */
44         u_int32_t rp_vltime;    /* advertised valid lifetime */
45         u_int32_t rp_pltime;    /* advertised preferred lifetime */
46         time_t rp_expire;       /* expiration time of the prefix */
47         time_t rp_preferred;    /* preferred time of the prefix */
48         struct in6_prflags rp_flags;
49         u_char  rp_origin; /* from where this prefix info is obtained */
50         struct  rp_stateflags {
51                 /* if some prefix should be added to this prefix */
52                 u_char addmark : 1;
53                 u_char delmark : 1; /* if this prefix will be deleted */
54         } rp_stateflags;
55 };
56
57 #define rp_type         rp_ifpr.ifpr_type
58 #define rp_ifp          rp_ifpr.ifpr_ifp
59 #define rp_plen         rp_ifpr.ifpr_plen
60
61 #define rp_raf          rp_flags.prf_ra
62 #define rp_raf_onlink           rp_flags.prf_ra.onlink
63 #define rp_raf_auto             rp_flags.prf_ra.autonomous
64
65 #define rp_statef_addmark       rp_stateflags.addmark
66 #define rp_statef_delmark       rp_stateflags.delmark
67
68 #define rp_rrf          rp_flags.prf_rr
69 #define rp_rrf_decrvalid        rp_flags.prf_rr.decrvalid
70 #define rp_rrf_decrprefd        rp_flags.prf_rr.decrprefd
71
72 struct rp_addr {
73         LIST_ENTRY(rp_addr)     ra_entry;
74         struct in6_addr         ra_ifid;
75         struct in6_ifaddr       *ra_addr;
76         struct ra_flags {
77                 u_char anycast : 1;
78         } ra_flags;
79 };
80
81 #define ifpr2rp(ifpr)   ((struct rr_prefix *)(ifpr))
82 #define rp2ifpr(rp)     ((struct ifprefix *)(rp))
83
84 #define RP_IN6(rp)      (&(rp)->rp_prefix.sin6_addr)
85
86 #define RR_INFINITE_LIFETIME            0xffffffff
87
88
89 LIST_HEAD(rr_prhead, rr_prefix);
90
91 extern struct rr_prhead rr_prefix;
92
93 void in6_rr_timer __P((void *));
94 extern struct callout in6_rr_timer_ch;
95 int delete_each_prefix  __P((struct rr_prefix *rpp, u_char origin));