rtadvd.h revision 1.1 1 /*
2 * Copyright (C) 1998 WIDE Project.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the project nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30 #define ALLNODES "ff02::1"
31 #define ALLROUTERS "ff02::2"
32 #define ANY "::"
33 #define RTSOLLEN 8
34
35 /* protocol constants and default values */
36 #define DEF_MAXRTRADVINTERVAL 600
37 #define DEF_ADVLINKMTU 0
38 #define DEF_ADVREACHABLETIME 0
39 #define DEF_ADVRETRANSTIMER 0
40 #define DEF_ADVCURHOPLIMIT 64
41 #define DEF_ADVVALIDLIFETIME 2592000
42 #define DEF_ADVPREFERREDLIFETIME 604800
43
44 #define MAXROUTERLIFETIME 9000
45 #define MIN_MAXINTERVAL 4
46 #define MAX_MAXINTERVAL 1800
47 #define MIN_MININTERVAL 3
48 #define MAXREACHABLETIME 3600000
49
50 #define MAX_INITIAL_RTR_ADVERT_INTERVAL 16
51 #define MAX_INITIAL_RTR_ADVERTISEMENTS 3
52 #define MAX_FINAL_RTR_ADVERTISEMENTS 3
53 #define MIN_DELAY_BETWEEN_RAS 3
54 #define MAX_RA_DELAY_TIME 500000 /* usec */
55
56 struct prefix {
57 struct prefix *next; /* forward link */
58 struct prefix *prev; /* previous link */
59
60 u_int32_t validlifetime; /* AdvValidLifetime */
61 u_int32_t preflifetime; /* AdvPreferredLifetime */
62 u_int onlinkflg; /* bool: AdvOnLinkFlag */
63 u_int autoconfflg; /* bool: AdvAutonomousFlag */
64 int prefixlen;
65 struct in6_addr prefix;
66 };
67
68 struct rainfo {
69 /* pointer for list */
70 struct rainfo *next;
71
72 /* timer related parameters */
73 struct rtadvd_timer *timer;
74 int initcounter; /* counter for the first few advertisements */
75 struct timeval lastsent; /* timestamp when the lates RA was sent */
76 int waiting; /* number of RS waiting for RA */
77
78 /* interface information */
79 int ifindex;
80 int advlinkopt; /* bool: whether include link-layer addr opt */
81 struct sockaddr_dl *sdl;
82 char ifname[16];
83 int phymtu; /* mtu of the physical interface */
84
85 /* Router configuration variables */
86 u_short lifetime; /* AdvDefaultLifetime */
87 u_int maxinterval; /* MaxRtrAdvInterval */
88 u_int mininterval; /* MinRtrAdvInterval */
89 int managedflg; /* AdvManagedFlag */
90 int otherflg; /* AdvOtherConfigFlag */
91 u_int32_t linkmtu; /* AdvLinkMTU */
92 u_int32_t reachabletime; /* AdvReachableTime */
93 u_int32_t retranstimer; /* AdvRetransTimer */
94 u_int hoplimit; /* AdvCurHopLimit */
95 struct prefix prefix; /* AdvPrefixList(link head) */
96 int pfxs; /* number of prefixes */
97
98 /* actual RA packet data and its length */
99 size_t ra_datalen;
100 u_char *ra_data;
101 };
102
103 void ra_timeout __P((void *));
104 void ra_timer_update __P((void *, struct timeval *));
105