1119026Sume/* $KAME: rtsold.h,v 1.19 2003/04/16 09:48:15 itojun Exp $ */ 266776Skris 355163Sshin/* 455163Sshin * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 555163Sshin * All rights reserved. 662632Skris * 755163Sshin * Redistribution and use in source and binary forms, with or without 855163Sshin * modification, are permitted provided that the following conditions 955163Sshin * are met: 1055163Sshin * 1. Redistributions of source code must retain the above copyright 1155163Sshin * notice, this list of conditions and the following disclaimer. 1255163Sshin * 2. Redistributions in binary form must reproduce the above copyright 1355163Sshin * notice, this list of conditions and the following disclaimer in the 1455163Sshin * documentation and/or other materials provided with the distribution. 1555163Sshin * 3. Neither the name of the project nor the names of its contributors 1655163Sshin * may be used to endorse or promote products derived from this software 1755163Sshin * without specific prior written permission. 1862632Skris * 1955163Sshin * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 2055163Sshin * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2155163Sshin * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2255163Sshin * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 2355163Sshin * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2455163Sshin * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2555163Sshin * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2655163Sshin * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2755163Sshin * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2855163Sshin * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2955163Sshin * SUCH DAMAGE. 3055163Sshin * 3155163Sshin * $FreeBSD: releng/10.2/usr.sbin/rtsold/rtsold.h 254462 2013-08-17 19:23:35Z hrs $ 3255163Sshin */ 3355163Sshin 34222732Shrsstruct script_msg { 35222732Shrs TAILQ_ENTRY(script_msg) sm_next; 36222732Shrs 37222732Shrs char *sm_msg; 38222732Shrs}; 39222732Shrs 40225520ShrsTAILQ_HEAD(script_msg_head_t, script_msg); 41225520Shrs 42222732Shrsstruct ra_opt { 43222732Shrs TAILQ_ENTRY(ra_opt) rao_next; 44222732Shrs 45222732Shrs u_int8_t rao_type; 46253970Shrs struct timespec rao_expire; 47222732Shrs size_t rao_len; 48222732Shrs void *rao_msg; 49222732Shrs}; 50222732Shrs 51222861ShrsTAILQ_HEAD(rainfo_head, ra_opt); 52222861Shrs 53222861Shrsstruct rainfo { 54222861Shrs TAILQ_ENTRY(rainfo) rai_next; 55222861Shrs 56222861Shrs struct ifinfo *rai_ifinfo; 57222861Shrs struct sockaddr_in6 rai_saddr; 58222861Shrs TAILQ_HEAD(, ra_opt) rai_ra_opt; 59222861Shrs}; 60222861Shrs 6155163Sshinstruct ifinfo { 62222732Shrs TAILQ_ENTRY(ifinfo) ifi_next; /* pointer to the next interface */ 6355163Sshin 6455163Sshin struct sockaddr_dl *sdl; /* link-layer address */ 65225520Shrs char ifname[IFNAMSIZ]; /* interface name */ 66119026Sume u_int32_t linkid; /* link ID of this interface */ 6755163Sshin int active; /* interface status */ 68118664Sume int probeinterval; /* interval of probe timer (if necessary) */ 6955163Sshin int probetimer; /* rest of probe timer */ 7055163Sshin int mediareqok; /* wheter the IF supports SIOCGIFMEDIA */ 71118661Sume int otherconfig; /* need a separate protocol for the "other" 72118661Sume * configuration */ 7355163Sshin int state; 7455163Sshin int probes; 7555163Sshin int dadcount; 76253970Shrs struct timespec timer; 77253970Shrs struct timespec expire; 7862632Skris int errors; /* # of errors we've got - detect wedge */ 79222861Shrs#define IFI_DNSOPT_STATE_NOINFO 0 80222861Shrs#define IFI_DNSOPT_STATE_RECEIVED 1 81222861Shrs int ifi_rdnss; /* RDNSS option state */ 82222861Shrs int ifi_dnssl; /* DNSSL option state */ 8355163Sshin 8455163Sshin int racnt; /* total # of valid RAs it have got */ 85222861Shrs TAILQ_HEAD(, rainfo) ifi_rainfo; 8655163Sshin 8755163Sshin size_t rs_datalen; 8855163Sshin u_char *rs_data; 8955163Sshin}; 9055163Sshin 9155163Sshin/* per interface status */ 9262632Skris#define IFS_IDLE 0 9362632Skris#define IFS_DELAY 1 9462632Skris#define IFS_PROBE 2 9562632Skris#define IFS_DOWN 3 9662632Skris#define IFS_TENTATIVE 4 9755163Sshin 98222732Shrs/* Interface list */ 99222732Shrsextern TAILQ_HEAD(ifinfo_head_t, ifinfo) ifinfo_head; 100222732Shrs 101225520Shrs#define DNSINFO_ORIGIN_LABEL "slaac" 102222732Shrs/* 103222732Shrs * RFC 3542 API deprecates IPV6_PKTINFO in favor of 104222732Shrs * IPV6_RECVPKTINFO 105222732Shrs */ 106222732Shrs#ifndef IPV6_RECVPKTINFO 107222732Shrs#ifdef IPV6_PKTINFO 108222732Shrs#define IPV6_RECVPKTINFO IPV6_PKTINFO 109222732Shrs#endif 110222732Shrs#endif 111222732Shrs/* 112222732Shrs * RFC 3542 API deprecates IPV6_HOPLIMIT in favor of 113222732Shrs * IPV6_RECVHOPLIMIT 114222732Shrs */ 115222732Shrs#ifndef IPV6_RECVHOPLIMIT 116222732Shrs#ifdef IPV6_HOPLIMIT 117222732Shrs#define IPV6_RECVHOPLIMIT IPV6_HOPLIMIT 118222732Shrs#endif 119222732Shrs#endif 120222732Shrs 121222732Shrs#ifndef IN6ADDR_LINKLOCAL_ALLROUTERS_INIT 122222732Shrs#define IN6ADDR_LINKLOCAL_ALLROUTERS_INIT \ 123222732Shrs {{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 124222732Shrs 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }}} 125222732Shrs#endif 126222732Shrs 127253970Shrs#define TS_CMP(tsp, usp, cmp) \ 128253970Shrs (((tsp)->tv_sec == (usp)->tv_sec) ? \ 129253970Shrs ((tsp)->tv_nsec cmp (usp)->tv_nsec) : \ 130253970Shrs ((tsp)->tv_sec cmp (usp)->tv_sec)) 131253970Shrs#define TS_ADD(tsp, usp, vsp) \ 132253970Shrs do { \ 133253970Shrs (vsp)->tv_sec = (tsp)->tv_sec + (usp)->tv_sec; \ 134253970Shrs (vsp)->tv_nsec = (tsp)->tv_nsec + (usp)->tv_nsec; \ 135253970Shrs if ((vsp)->tv_nsec >= 1000000000L) { \ 136253970Shrs (vsp)->tv_sec++; \ 137253970Shrs (vsp)->tv_nsec -= 1000000000L; \ 138253970Shrs } \ 139253970Shrs } while (0) 140253970Shrs#define TS_SUB(tsp, usp, vsp) \ 141253970Shrs do { \ 142253970Shrs (vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec; \ 143253970Shrs (vsp)->tv_nsec = (tsp)->tv_nsec - (usp)->tv_nsec; \ 144253970Shrs if ((vsp)->tv_nsec < 0) { \ 145253970Shrs (vsp)->tv_sec--; \ 146253970Shrs (vsp)->tv_nsec += 1000000000L; \ 147253970Shrs } \ 148253970Shrs } while (0) 149253970Shrs 15055163Sshin/* rtsold.c */ 151253970Shrsextern struct timespec tm_max; 15255163Sshinextern int dflag; 153119026Sumeextern int aflag; 154197141Shrsextern int Fflag; 155225520Shrsextern int uflag; 156222732Shrsextern const char *otherconf_script; 157222732Shrsextern const char *resolvconf_script; 158173412Skevloextern int ifconfig(char *); 159173412Skevloextern void iflist_init(void); 160173412Skevlostruct ifinfo *find_ifinfo(int); 161222861Shrsstruct rainfo *find_rainfo(struct ifinfo *, struct sockaddr_in6 *); 162173412Skevlovoid rtsol_timer_update(struct ifinfo *); 163173412Skevloextern void warnmsg(int, const char *, const char *, ...) 16466776Skris __attribute__((__format__(__printf__, 3, 4))); 165173412Skevloextern char **autoifprobe(void); 166222732Shrsextern int ra_opt_handler(struct ifinfo *); 16755163Sshin 16855163Sshin/* if.c */ 169173412Skevloextern int ifinit(void); 170173412Skevloextern int interface_up(char *); 171173412Skevloextern int interface_status(struct ifinfo *); 172173412Skevloextern int lladdropt_length(struct sockaddr_dl *); 173173412Skevloextern void lladdropt_fill(struct sockaddr_dl *, struct nd_opt_hdr *); 174173412Skevloextern struct sockaddr_dl *if_nametosdl(char *); 175173412Skevloextern int getinet6sysctl(int); 176173412Skevloextern int setinet6sysctl(int, int); 17755163Sshin 17855163Sshin/* rtsol.c */ 179254462Shrsextern int rssock; 180173412Skevloextern int sockopen(void); 181173412Skevloextern void sendpacket(struct ifinfo *); 182173412Skevloextern void rtsol_input(int); 18355163Sshin 18455163Sshin/* probe.c */ 185173412Skevloextern int probe_init(void); 186173412Skevloextern void defrouter_probe(struct ifinfo *); 18755163Sshin 18855163Sshin/* dump.c */ 189204407Suqsextern void rtsold_dump_file(const char *); 190253970Shrsextern const char *sec2str(const struct timespec *); 19178064Sume 19278064Sume/* rtsock.c */ 193173412Skevloextern int rtsock_open(void); 194173412Skevloextern int rtsock_input(int); 195