xref: /freebsd/usr.sbin/rtadvd/rtadvd.h (revision b601c69bdbe8755d26570261d7fd4c02ee4eff74)
1 /*	$KAME: rtadvd.h,v 1.8 2000/05/16 13:34:14 itojun Exp $	*/
2 
3 /*
4  * Copyright (C) 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  * $FreeBSD$
32  */
33 
34 #define ALLNODES "ff02::1"
35 #define ALLROUTERS "ff02::2"
36 #define ANY "::"
37 #define RTSOLLEN 8
38 
39 /* protocol constants and default values */
40 #define DEF_MAXRTRADVINTERVAL 600
41 #define DEF_ADVLINKMTU 0
42 #define DEF_ADVREACHABLETIME 0
43 #define DEF_ADVRETRANSTIMER 0
44 #define DEF_ADVCURHOPLIMIT 64
45 #define DEF_ADVVALIDLIFETIME 2592000
46 #define DEF_ADVPREFERREDLIFETIME 604800
47 
48 /*XXX int-to-double comparison for INTERVAL items */
49 #ifndef MIP6
50 #define mobileip6 0
51 #endif
52 
53 #define MAXROUTERLIFETIME 9000
54 #define MIN_MAXINTERVAL (mobileip6 ? 1.5 : 4.0)
55 #define MAX_MAXINTERVAL 1800
56 #define MIN_MININTERVAL	(mobileip6 ? 0.5 : 3)
57 #define MAXREACHABLETIME 3600000
58 
59 #ifndef MIP6
60 #undef miobileip6
61 #endif
62 
63 #define MAX_INITIAL_RTR_ADVERT_INTERVAL  16
64 #define MAX_INITIAL_RTR_ADVERTISEMENTS    3
65 #define MAX_FINAL_RTR_ADVERTISEMENTS      3
66 #define MIN_DELAY_BETWEEN_RAS             3
67 #define MAX_RA_DELAY_TIME                 500000 /* usec */
68 
69 #define PREFIX_FROM_KERNEL 1
70 #define PREFIX_FROM_CONFIG 2
71 #define PREFIX_FROM_DYNAMIC 3
72 
73 struct prefix {
74 	struct prefix *next;	/* forward link */
75 	struct prefix *prev;	/* previous link */
76 
77 	u_int32_t validlifetime; /* AdvValidLifetime */
78 	u_int32_t preflifetime;	/* AdvPreferredLifetime */
79 	u_int onlinkflg;	/* bool: AdvOnLinkFlag */
80 	u_int autoconfflg;	/* bool: AdvAutonomousFlag */
81 #ifdef MIP6
82 	u_int routeraddr;	/* bool: RouterAddress */
83 #endif
84 	int prefixlen;
85 	int origin;		/* from kernel or cofig */
86 	struct in6_addr prefix;
87 };
88 
89 struct soliciter {
90 	struct soliciter *next;
91 	struct sockaddr_in6 addr;
92 };
93 
94 struct	rainfo {
95 	/* pointer for list */
96 	struct	rainfo *next;
97 
98 	/* timer related parameters */
99 	struct rtadvd_timer *timer;
100 	int initcounter; /* counter for the first few advertisements */
101 	struct timeval lastsent; /* timestamp when the latest RA was sent */
102 	int waiting;		/* number of RS waiting for RA */
103 
104 	/* interface information */
105 	int	ifindex;
106 	int	advlinkopt;	/* bool: whether include link-layer addr opt */
107 	struct sockaddr_dl *sdl;
108 	char	ifname[16];
109 	int	phymtu;		/* mtu of the physical interface */
110 
111 	/* Router configuration variables */
112 	u_short lifetime;	/* AdvDefaultLifetime */
113 	u_int	maxinterval;	/* MaxRtrAdvInterval */
114 	u_int	mininterval;	/* MinRtrAdvInterval */
115 	int 	managedflg;	/* AdvManagedFlag */
116 	int	otherflg;	/* AdvOtherConfigFlag */
117 #ifdef MIP6
118 	int	haflg;		/* HAFlag */
119 #endif
120 	u_int32_t linkmtu;	/* AdvLinkMTU */
121 	u_int32_t reachabletime; /* AdvReachableTime */
122 	u_int32_t retranstimer;	/* AdvRetransTimer */
123 	u_int	hoplimit;	/* AdvCurHopLimit */
124 	struct prefix prefix;	/* AdvPrefixList(link head) */
125 	int	pfxs;		/* number of prefixes */
126 
127 #ifdef MIP6
128 	u_short	hapref;		/* Home Agent Preference */
129 	u_short	hatime;		/* Home Agent Lifetime */
130 #endif
131 
132 	/* actual RA packet data and its length */
133 	size_t ra_datalen;
134 	u_char *ra_data;
135 
136 	/* statistics */
137 	u_quad_t raoutput;	/* number of RAs sent */
138 	u_quad_t rainput;	/* number of RAs received */
139 	u_quad_t rainconsistent; /* number of RAs inconsistent with ours */
140 	u_quad_t rsinput;	/* number of RSs received */
141 
142 	/* info about soliciter */
143 	struct soliciter *soliciter;	/* recent solication source */
144 };
145 
146 void ra_timeout __P((void *));
147 void ra_timer_update __P((void *, struct timeval *));
148 
149 #ifdef MIP6
150 extern int mobileip6;
151 #endif
152