1 /* $KAME: rtsold.h,v 1.19 2003/04/16 09:48:15 itojun Exp $ */
4 * SPDX-License-Identifier: BSD-3-Clause
6 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of the project nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 TAILQ_ENTRY(script_msg) sm_next;
42 TAILQ_HEAD(script_msg_head_t, script_msg);
45 TAILQ_ENTRY(ra_opt) rao_next;
48 struct timespec rao_expire;
53 TAILQ_HEAD(rainfo_head, ra_opt);
56 TAILQ_ENTRY(rainfo) rai_next;
58 struct ifinfo *rai_ifinfo;
59 struct sockaddr_in6 rai_saddr;
60 TAILQ_HEAD(, ra_opt) rai_ra_opt;
64 TAILQ_ENTRY(ifinfo) ifi_next; /* pointer to the next interface */
66 struct sockaddr_dl *sdl; /* link-layer address */
67 char ifname[IFNAMSIZ]; /* interface name */
68 u_int32_t linkid; /* link ID of this interface */
69 int active; /* interface status */
70 int probeinterval; /* interval of probe timer (if necessary) */
71 int probetimer; /* rest of probe timer */
72 int mediareqok; /* whether the IF supports SIOCGIFMEDIA */
73 int otherconfig; /* need a separate protocol for the "other"
78 struct timespec timer;
79 struct timespec expire;
80 int errors; /* # of errors we've got - detect wedge */
81 #define IFI_DNSOPT_STATE_NOINFO 0
82 #define IFI_DNSOPT_STATE_RECEIVED 1
83 int ifi_rdnss; /* RDNSS option state */
84 int ifi_dnssl; /* DNSSL option state */
86 int racnt; /* total # of valid RAs it have got */
87 TAILQ_HEAD(, rainfo) ifi_rainfo;
93 /* per interface status */
98 #define IFS_TENTATIVE 4
101 extern TAILQ_HEAD(ifinfo_head_t, ifinfo) ifinfo_head;
103 #define DNSINFO_ORIGIN_LABEL "slaac"
105 * RFC 3542 API deprecates IPV6_PKTINFO in favor of
108 #ifndef IPV6_RECVPKTINFO
110 #define IPV6_RECVPKTINFO IPV6_PKTINFO
114 * RFC 3542 API deprecates IPV6_HOPLIMIT in favor of
117 #ifndef IPV6_RECVHOPLIMIT
119 #define IPV6_RECVHOPLIMIT IPV6_HOPLIMIT
123 #ifndef IN6ADDR_LINKLOCAL_ALLROUTERS_INIT
124 #define IN6ADDR_LINKLOCAL_ALLROUTERS_INIT \
125 {{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
126 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }}}
129 #define TS_CMP(tsp, usp, cmp) \
130 (((tsp)->tv_sec == (usp)->tv_sec) ? \
131 ((tsp)->tv_nsec cmp (usp)->tv_nsec) : \
132 ((tsp)->tv_sec cmp (usp)->tv_sec))
133 #define TS_ADD(tsp, usp, vsp) \
135 (vsp)->tv_sec = (tsp)->tv_sec + (usp)->tv_sec; \
136 (vsp)->tv_nsec = (tsp)->tv_nsec + (usp)->tv_nsec; \
137 if ((vsp)->tv_nsec >= 1000000000L) { \
139 (vsp)->tv_nsec -= 1000000000L; \
142 #define TS_SUB(tsp, usp, vsp) \
144 (vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec; \
145 (vsp)->tv_nsec = (tsp)->tv_nsec - (usp)->tv_nsec; \
146 if ((vsp)->tv_nsec < 0) { \
148 (vsp)->tv_nsec += 1000000000L; \
153 extern struct timespec tm_max;
158 extern const char *otherconf_script;
159 extern const char *resolvconf_script;
160 extern int ifconfig(char *);
161 extern void iflist_init(void);
162 struct ifinfo *find_ifinfo(int);
163 struct rainfo *find_rainfo(struct ifinfo *, struct sockaddr_in6 *);
164 void rtsol_timer_update(struct ifinfo *);
165 extern void warnmsg(int, const char *, const char *, ...)
166 __attribute__((__format__(__printf__, 3, 4)));
167 extern char **autoifprobe(void);
168 extern int ra_opt_handler(struct ifinfo *);
171 extern int ifinit(void);
172 extern int interface_up(char *);
173 extern int interface_status(struct ifinfo *);
174 extern int lladdropt_length(struct sockaddr_dl *);
175 extern void lladdropt_fill(struct sockaddr_dl *, struct nd_opt_hdr *);
176 extern struct sockaddr_dl *if_nametosdl(char *);
177 extern int getinet6sysctl(int);
178 extern int setinet6sysctl(int, int);
182 extern int sockopen(void);
183 extern void sendpacket(struct ifinfo *);
184 extern void rtsol_input(int);
187 extern int probe_init(void);
188 extern void defrouter_probe(struct ifinfo *);
191 extern void rtsold_dump_file(const char *);
192 extern const char *sec2str(const struct timespec *);
195 extern int rtsock_open(void);
196 extern int rtsock_input(int);