rtadvd.h revision 118664
1/* $FreeBSD: head/usr.sbin/rtadvd/rtadvd.h 118664 2003-08-08 16:56:01Z ume $ */ 2/* $KAME: rtadvd.h,v 1.16 2001/04/10 15:08:31 suz 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/*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 73struct prefix { 74 struct prefix *next; /* forward link */ 75 struct prefix *prev; /* previous link */ 76 77 struct rainfo *rainfo; /* back pointer to the interface */ 78 79 struct rtadvd_timer *timer; /* expiration timer. used when a prefix 80 * derived from the kernel is deleted. 81 */ 82 83 u_int32_t validlifetime; /* AdvValidLifetime */ 84 long vltimeexpire; /* expiration of vltime; decrement case only */ 85 u_int32_t preflifetime; /* AdvPreferredLifetime */ 86 long pltimeexpire; /* expiration of pltime; decrement case only */ 87 u_int onlinkflg; /* bool: AdvOnLinkFlag */ 88 u_int autoconfflg; /* bool: AdvAutonomousFlag */ 89#ifdef MIP6 90 u_int routeraddr; /* bool: RouterAddress */ 91#endif 92 int prefixlen; 93 int origin; /* from kernel or config */ 94 struct in6_addr prefix; 95}; 96 97struct rtinfo { 98 struct rtinfo *prev; /* previous link */ 99 struct rtinfo *next; /* forward link */ 100 101 u_int32_t ltime; /* route lifetime */ 102 u_int rtpref; /* route preference */ 103 int prefixlen; 104 struct in6_addr prefix; 105}; 106 107struct soliciter { 108 struct soliciter *next; 109 struct sockaddr_in6 addr; 110}; 111 112struct rainfo { 113 /* pointer for list */ 114 struct rainfo *next; 115 116 /* timer related parameters */ 117 struct rtadvd_timer *timer; 118 int initcounter; /* counter for the first few advertisements */ 119 struct timeval lastsent; /* timestamp when the latest RA was sent */ 120 int waiting; /* number of RS waiting for RA */ 121 122 /* interface information */ 123 int ifindex; 124 int advlinkopt; /* bool: whether include link-layer addr opt */ 125 struct sockaddr_dl *sdl; 126 char ifname[16]; 127 int phymtu; /* mtu of the physical interface */ 128 129 /* Router configuration variables */ 130 u_short lifetime; /* AdvDefaultLifetime */ 131 u_int maxinterval; /* MaxRtrAdvInterval */ 132 u_int mininterval; /* MinRtrAdvInterval */ 133 int managedflg; /* AdvManagedFlag */ 134 int otherflg; /* AdvOtherConfigFlag */ 135#ifdef MIP6 136 int haflg; /* HAFlag */ 137#endif 138 139 int rtpref; /* router preference */ 140 u_int32_t linkmtu; /* AdvLinkMTU */ 141 u_int32_t reachabletime; /* AdvReachableTime */ 142 u_int32_t retranstimer; /* AdvRetransTimer */ 143 u_int hoplimit; /* AdvCurHopLimit */ 144 struct prefix prefix; /* AdvPrefixList(link head) */ 145 int pfxs; /* number of prefixes */ 146 long clockskew; /* used for consisitency check of lifetimes */ 147 148#ifdef MIP6 149 u_short hapref; /* Home Agent Preference */ 150 u_short hatime; /* Home Agent Lifetime */ 151#endif 152 struct rtinfo route; /* route information option (link head) */ 153 int routes; /* number of route information options */ 154 155 /* actual RA packet data and its length */ 156 size_t ra_datalen; 157 u_char *ra_data; 158 159 /* statistics */ 160 u_quad_t raoutput; /* number of RAs sent */ 161 u_quad_t rainput; /* number of RAs received */ 162 u_quad_t rainconsistent; /* number of RAs inconsistent with ours */ 163 u_quad_t rsinput; /* number of RSs received */ 164 165 /* info about soliciter */ 166 struct soliciter *soliciter; /* recent solication source */ 167}; 168 169struct rtadvd_timer *ra_timeout __P((void *)); 170void ra_timer_update __P((void *, struct timeval *)); 171 172int prefix_match __P((struct in6_addr *, int, struct in6_addr *, int)); 173struct rainfo *if_indextorainfo __P((int)); 174struct prefix *find_prefix __P((struct rainfo *, struct in6_addr *, int)); 175 176extern struct in6_addr in6a_site_allrouters; 177#ifdef MIP6 178extern int mobileip6; 179#endif 180