Home | History | Annotate | Line # | Download | only in rtadvd
rtadvd.h revision 1.14.2.1
      1  1.14.2.1  pgoyette /*	$NetBSD: rtadvd.h,v 1.14.2.1 2017/03/20 06:58:09 pgoyette Exp $	*/
      2      1.10    rpaulo /*	$KAME: rtadvd.h,v 1.30 2005/10/17 14:40:02 suz Exp $	*/
      3       1.2    itojun 
      4       1.1    itojun /*
      5       1.1    itojun  * Copyright (C) 1998 WIDE Project.
      6       1.1    itojun  * All rights reserved.
      7       1.1    itojun  *
      8       1.1    itojun  * Redistribution and use in source and binary forms, with or without
      9       1.1    itojun  * modification, are permitted provided that the following conditions
     10       1.1    itojun  * are met:
     11       1.1    itojun  * 1. Redistributions of source code must retain the above copyright
     12       1.1    itojun  *    notice, this list of conditions and the following disclaimer.
     13       1.1    itojun  * 2. Redistributions in binary form must reproduce the above copyright
     14       1.1    itojun  *    notice, this list of conditions and the following disclaimer in the
     15       1.1    itojun  *    documentation and/or other materials provided with the distribution.
     16       1.1    itojun  * 3. Neither the name of the project nor the names of its contributors
     17       1.1    itojun  *    may be used to endorse or promote products derived from this software
     18       1.1    itojun  *    without specific prior written permission.
     19       1.1    itojun  *
     20       1.1    itojun  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
     21       1.1    itojun  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     22       1.1    itojun  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     23       1.1    itojun  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
     24       1.1    itojun  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     25       1.1    itojun  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     26       1.1    itojun  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     27       1.1    itojun  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     28       1.1    itojun  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     29       1.1    itojun  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     30       1.1    itojun  * SUCH DAMAGE.
     31       1.1    itojun  */
     32       1.1    itojun 
     33      1.13       roy #define RTADVD_USER	"_rtadvd"
     34      1.13       roy 
     35       1.1    itojun #define ALLNODES "ff02::1"
     36       1.6    itojun #define ALLROUTERS_LINK "ff02::2"
     37       1.6    itojun #define ALLROUTERS_SITE "ff05::2"
     38      1.11       roy 
     39      1.11       roy #define IN6ADDR_SITELOCAL_ALLROUTERS_INIT \
     40      1.11       roy 	{{{ 0xff, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
     41      1.11       roy  	    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }}}
     42      1.11       roy 
     43      1.11       roy //extern struct sockaddr_in6 sin6_linklocal_allnodes;
     44      1.11       roy //extern struct sockaddr_in6 sin6_linklocal_allrouters;
     45      1.11       roy extern struct sockaddr_in6 sin6_sitelocal_allrouters;
     46       1.1    itojun 
     47       1.1    itojun /* protocol constants and default values */
     48       1.1    itojun #define DEF_MAXRTRADVINTERVAL 600
     49       1.1    itojun #define DEF_ADVLINKMTU 0
     50       1.1    itojun #define DEF_ADVREACHABLETIME 0
     51       1.1    itojun #define DEF_ADVRETRANSTIMER 0
     52       1.1    itojun #define DEF_ADVCURHOPLIMIT 64
     53       1.1    itojun #define DEF_ADVVALIDLIFETIME 2592000
     54       1.1    itojun #define DEF_ADVPREFERREDLIFETIME 604800
     55  1.14.2.1  pgoyette #define DEF_ADVROUTERLIFETIME 1800
     56       1.1    itojun 
     57       1.1    itojun #define MAXROUTERLIFETIME 9000
     58      1.10    rpaulo #define MIN_MAXINTERVAL 4
     59       1.1    itojun #define MAX_MAXINTERVAL 1800
     60      1.10    rpaulo #define MIN_MININTERVAL 3
     61       1.1    itojun #define MAXREACHABLETIME 3600000
     62       1.1    itojun 
     63       1.1    itojun #define MAX_INITIAL_RTR_ADVERT_INTERVAL  16
     64       1.1    itojun #define MAX_INITIAL_RTR_ADVERTISEMENTS    3
     65       1.1    itojun #define MAX_FINAL_RTR_ADVERTISEMENTS      3
     66       1.1    itojun #define MIN_DELAY_BETWEEN_RAS             3
     67      1.14       roy #define MAX_RA_DELAY_TIME                500000000 /* nsec */
     68       1.1    itojun 
     69       1.4    itojun #define PREFIX_FROM_KERNEL 1
     70       1.4    itojun #define PREFIX_FROM_CONFIG 2
     71       1.4    itojun #define PREFIX_FROM_DYNAMIC 3
     72       1.4    itojun 
     73       1.1    itojun struct prefix {
     74      1.11       roy 	TAILQ_ENTRY(prefix) next;
     75       1.1    itojun 
     76      1.10    rpaulo 	struct rainfo *rainfo;	/* back pointer to the interface */
     77      1.10    rpaulo 
     78      1.10    rpaulo 	struct rtadvd_timer *timer; /* expiration timer.  used when a prefix
     79      1.10    rpaulo 				     * derived from the kernel is deleted.
     80      1.10    rpaulo 				     */
     81      1.10    rpaulo 
     82      1.11       roy 	uint32_t validlifetime; /* AdvValidLifetime */
     83       1.6    itojun 	long	vltimeexpire;	/* expiration of vltime; decrement case only */
     84      1.11       roy 	uint32_t preflifetime;	/* AdvPreferredLifetime */
     85       1.6    itojun 	long	pltimeexpire;	/* expiration of pltime; decrement case only */
     86      1.11       roy 	uint16_t onlinkflg;	/* bool: AdvOnLinkFlag */
     87      1.11       roy 	uint16_t autoconfflg;	/* bool: AdvAutonomousFlag */
     88       1.4    itojun 	int prefixlen;
     89      1.10    rpaulo 	int origin;		/* from kernel or config */
     90       1.1    itojun 	struct in6_addr prefix;
     91       1.1    itojun };
     92       1.1    itojun 
     93      1.10    rpaulo struct rtinfo {
     94      1.11       roy 	TAILQ_ENTRY(rtinfo) next;
     95      1.10    rpaulo 
     96      1.11       roy 	uint32_t ltime;	/* route lifetime */
     97      1.11       roy 	uint16_t rtpref;		/* route preference */
     98      1.10    rpaulo 	int prefixlen;
     99      1.10    rpaulo 	struct in6_addr prefix;
    100      1.10    rpaulo };
    101      1.11       roy 
    102      1.11       roy struct rdnss_addr {
    103      1.11       roy 	TAILQ_ENTRY(rdnss_addr) next;
    104      1.11       roy 
    105      1.11       roy 	struct in6_addr addr;
    106      1.11       roy };
    107      1.11       roy 
    108      1.11       roy struct rdnss {
    109      1.11       roy 	TAILQ_ENTRY(rdnss) next;
    110      1.11       roy 
    111      1.11       roy 	TAILQ_HEAD(, rdnss_addr) list;
    112      1.11       roy 	uint32_t lifetime;
    113      1.11       roy };
    114      1.11       roy 
    115      1.11       roy struct dnssl_domain {
    116      1.11       roy 	TAILQ_ENTRY(dnssl_domain) next;
    117      1.11       roy 
    118      1.11       roy 	int len;
    119      1.11       roy 	char domain[256];
    120      1.11       roy };
    121      1.11       roy 
    122      1.11       roy struct dnssl {
    123      1.11       roy 	TAILQ_ENTRY(dnssl) next;
    124      1.11       roy 
    125      1.11       roy 	TAILQ_HEAD(, dnssl_domain) list;
    126      1.11       roy 	uint32_t lifetime;
    127      1.11       roy };
    128       1.9    itojun 
    129       1.5    itojun struct soliciter {
    130      1.11       roy 	TAILQ_ENTRY(soliciter) next;
    131      1.11       roy 
    132       1.5    itojun 	struct sockaddr_in6 addr;
    133       1.5    itojun };
    134       1.5    itojun 
    135       1.1    itojun struct	rainfo {
    136      1.11       roy 	TAILQ_ENTRY(rainfo) next;
    137       1.1    itojun 
    138       1.1    itojun 	/* timer related parameters */
    139       1.1    itojun 	struct rtadvd_timer *timer;
    140       1.1    itojun 	int initcounter; /* counter for the first few advertisements */
    141      1.14       roy 	struct timespec lastsent; /* timestamp when the latest RA was sent */
    142       1.1    itojun 	int waiting;		/* number of RS waiting for RA */
    143      1.12       roy 	struct rainfo *leaving;		/* the config which is leaving */
    144      1.12       roy 	struct rainfo *leaving_for;	/* the new config to activate */
    145      1.12       roy 	int leaving_adv;		/* number of RA left to send */
    146       1.1    itojun 
    147       1.1    itojun 	/* interface information */
    148      1.11       roy 	uint16_t	ifindex;
    149      1.12       roy 	int		ifflags;
    150       1.1    itojun 	int	advlinkopt;	/* bool: whether include link-layer addr opt */
    151       1.1    itojun 	struct sockaddr_dl *sdl;
    152       1.1    itojun 	char	ifname[16];
    153      1.11       roy 	uint32_t	phymtu;		/* mtu of the physical interface */
    154       1.1    itojun 
    155       1.1    itojun 	/* Router configuration variables */
    156      1.11       roy 	uint16_t	lifetime;	/* AdvDefaultLifetime */
    157      1.11       roy 	uint16_t	maxinterval;	/* MaxRtrAdvInterval */
    158      1.11       roy 	uint16_t	mininterval;	/* MinRtrAdvInterval */
    159       1.1    itojun 	int 	managedflg;	/* AdvManagedFlag */
    160       1.1    itojun 	int	otherflg;	/* AdvOtherConfigFlag */
    161      1.10    rpaulo 
    162       1.9    itojun 	int	rtpref;		/* router preference */
    163      1.11       roy 	uint32_t linkmtu;	/* AdvLinkMTU */
    164      1.11       roy 	uint32_t reachabletime; /* AdvReachableTime */
    165      1.11       roy 	uint32_t retranstimer;	/* AdvRetransTimer */
    166      1.11       roy 	uint16_t	hoplimit;	/* AdvCurHopLimit */
    167      1.11       roy 	TAILQ_HEAD(, prefix) prefix;	/* AdvPrefixList(link head) */
    168      1.11       roy 	int	pfxs;
    169      1.11       roy 	uint16_t	clockskew;/* used for consisitency check of lifetimes */
    170      1.11       roy 
    171      1.11       roy 	TAILQ_HEAD(, rtinfo) route;
    172      1.11       roy 	TAILQ_HEAD(, rdnss) rdnss;	/* RDNSS list */
    173      1.11       roy 	TAILQ_HEAD(, dnssl) dnssl;	/* DNS Search List */
    174       1.3    itojun 
    175       1.1    itojun 	/* actual RA packet data and its length */
    176       1.1    itojun 	size_t ra_datalen;
    177      1.11       roy 	char *ra_data;
    178       1.4    itojun 
    179       1.4    itojun 	/* statistics */
    180      1.11       roy 	uint64_t raoutput;	/* number of RAs sent */
    181      1.11       roy 	uint64_t rainput;	/* number of RAs received */
    182      1.11       roy 	uint64_t rainconsistent; /* number of RAs inconsistent with ours */
    183      1.11       roy 	uint64_t rsinput;	/* number of RSs received */
    184       1.5    itojun 
    185       1.5    itojun 	/* info about soliciter */
    186      1.11       roy 	TAILQ_HEAD(, soliciter) soliciter;	/* recent solication source */
    187       1.1    itojun };
    188       1.1    itojun 
    189      1.11       roy extern TAILQ_HEAD(ralist_head_t, rainfo) ralist;
    190       1.3    itojun 
    191      1.11       roy struct rtadvd_timer *ra_timeout(void *);
    192      1.14       roy void ra_timer_update(void *, struct timespec *);
    193      1.12       roy void ra_timer_set_short_delay(struct rainfo *);
    194       1.6    itojun 
    195      1.11       roy int prefix_match(struct in6_addr *, int, struct in6_addr *, int);
    196      1.11       roy struct rainfo *if_indextorainfo(unsigned int);
    197      1.11       roy struct prefix *find_prefix(struct rainfo *, struct in6_addr *, int);
    198