1 /* $FreeBSD$ */ 2 /* $KAME: rtadvd.h,v 1.26 2003/08/05 12:34:23 itojun Exp $ */ 3 4 /* 5 * Copyright (C) 1998 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 #define ALLNODES "ff02::1" 34 #define ALLROUTERS_LINK "ff02::2" 35 #define ALLROUTERS_SITE "ff05::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 #define MAXROUTERLIFETIME 9000 49 #define MIN_MAXINTERVAL 4 50 #define MAX_MAXINTERVAL 1800 51 #define MIN_MININTERVAL 3 52 #define MAXREACHABLETIME 3600000 53 54 #define MAX_INITIAL_RTR_ADVERT_INTERVAL 16 55 #define MAX_INITIAL_RTR_ADVERTISEMENTS 3 56 #define MAX_FINAL_RTR_ADVERTISEMENTS 3 57 #define MIN_DELAY_BETWEEN_RAS 3 58 #define MAX_RA_DELAY_TIME 500000 /* usec */ 59 60 #define PREFIX_FROM_KERNEL 1 61 #define PREFIX_FROM_CONFIG 2 62 #define PREFIX_FROM_DYNAMIC 3 63 64 struct prefix { 65 struct prefix *next; /* forward link */ 66 struct prefix *prev; /* previous link */ 67 68 struct rainfo *rainfo; /* back pointer to the interface */ 69 70 struct rtadvd_timer *timer; /* expiration timer. used when a prefix 71 * derived from the kernel is deleted. 72 */ 73 74 u_int32_t validlifetime; /* AdvValidLifetime */ 75 long vltimeexpire; /* expiration of vltime; decrement case only */ 76 u_int32_t preflifetime; /* AdvPreferredLifetime */ 77 long pltimeexpire; /* expiration of pltime; decrement case only */ 78 u_int onlinkflg; /* bool: AdvOnLinkFlag */ 79 u_int autoconfflg; /* bool: AdvAutonomousFlag */ 80 int prefixlen; 81 int origin; /* from kernel or config */ 82 struct in6_addr prefix; 83 }; 84 85 #ifdef ROUTEINFO 86 struct rtinfo { 87 struct rtinfo *prev; /* previous link */ 88 struct rtinfo *next; /* forward link */ 89 90 u_int32_t ltime; /* route lifetime */ 91 u_int rtpref; /* route preference */ 92 int prefixlen; 93 struct in6_addr prefix; 94 }; 95 #endif 96 97 struct soliciter { 98 struct soliciter *next; 99 struct sockaddr_in6 addr; 100 }; 101 102 struct rainfo { 103 /* pointer for list */ 104 struct rainfo *next; 105 106 /* timer related parameters */ 107 struct rtadvd_timer *timer; 108 int initcounter; /* counter for the first few advertisements */ 109 struct timeval lastsent; /* timestamp when the latest RA was sent */ 110 int waiting; /* number of RS waiting for RA */ 111 112 /* interface information */ 113 int ifindex; 114 int advlinkopt; /* bool: whether include link-layer addr opt */ 115 struct sockaddr_dl *sdl; 116 char ifname[16]; 117 int phymtu; /* mtu of the physical interface */ 118 119 /* Router configuration variables */ 120 u_short lifetime; /* AdvDefaultLifetime */ 121 u_int maxinterval; /* MaxRtrAdvInterval */ 122 u_int mininterval; /* MinRtrAdvInterval */ 123 int managedflg; /* AdvManagedFlag */ 124 int otherflg; /* AdvOtherConfigFlag */ 125 126 int rtpref; /* router preference */ 127 u_int32_t linkmtu; /* AdvLinkMTU */ 128 u_int32_t reachabletime; /* AdvReachableTime */ 129 u_int32_t retranstimer; /* AdvRetransTimer */ 130 u_int hoplimit; /* AdvCurHopLimit */ 131 struct prefix prefix; /* AdvPrefixList(link head) */ 132 int pfxs; /* number of prefixes */ 133 long clockskew; /* used for consisitency check of lifetimes */ 134 135 #ifdef ROUTEINFO 136 struct rtinfo route; /* route information option (link head) */ 137 int routes; /* number of route information options */ 138 #endif 139 140 /* actual RA packet data and its length */ 141 size_t ra_datalen; 142 u_char *ra_data; 143 144 /* statistics */ 145 u_quad_t raoutput; /* number of RAs sent */ 146 u_quad_t rainput; /* number of RAs received */ 147 u_quad_t rainconsistent; /* number of RAs inconsistent with ours */ 148 u_quad_t rsinput; /* number of RSs received */ 149 150 /* info about soliciter */ 151 struct soliciter *soliciter; /* recent solication source */ 152 }; 153 154 struct rtadvd_timer *ra_timeout(void *); 155 void ra_timer_update(void *, struct timeval *); 156 157 int prefix_match(struct in6_addr *, int, struct in6_addr *, int); 158 struct rainfo *if_indextorainfo(int); 159 struct prefix *find_prefix(struct rainfo *, struct in6_addr *, int); 160 161 extern struct in6_addr in6a_site_allrouters; 162