19a364ca3SHajimu UMEMOTO /* $KAME: rtsold.h,v 1.19 2003/04/16 09:48:15 itojun Exp $ */ 2804c83d4SKris Kennaway 37d56d374SYoshinobu Inoue /* 47d56d374SYoshinobu Inoue * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 57d56d374SYoshinobu Inoue * All rights reserved. 67d56d374SYoshinobu Inoue * 77d56d374SYoshinobu Inoue * Redistribution and use in source and binary forms, with or without 87d56d374SYoshinobu Inoue * modification, are permitted provided that the following conditions 97d56d374SYoshinobu Inoue * are met: 107d56d374SYoshinobu Inoue * 1. Redistributions of source code must retain the above copyright 117d56d374SYoshinobu Inoue * notice, this list of conditions and the following disclaimer. 127d56d374SYoshinobu Inoue * 2. Redistributions in binary form must reproduce the above copyright 137d56d374SYoshinobu Inoue * notice, this list of conditions and the following disclaimer in the 147d56d374SYoshinobu Inoue * documentation and/or other materials provided with the distribution. 157d56d374SYoshinobu Inoue * 3. Neither the name of the project nor the names of its contributors 167d56d374SYoshinobu Inoue * may be used to endorse or promote products derived from this software 177d56d374SYoshinobu Inoue * without specific prior written permission. 187d56d374SYoshinobu Inoue * 197d56d374SYoshinobu Inoue * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 207d56d374SYoshinobu Inoue * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 217d56d374SYoshinobu Inoue * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 227d56d374SYoshinobu Inoue * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 237d56d374SYoshinobu Inoue * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 247d56d374SYoshinobu Inoue * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 257d56d374SYoshinobu Inoue * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 267d56d374SYoshinobu Inoue * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 277d56d374SYoshinobu Inoue * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 287d56d374SYoshinobu Inoue * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 297d56d374SYoshinobu Inoue * SUCH DAMAGE. 307d56d374SYoshinobu Inoue * 317d56d374SYoshinobu Inoue * $FreeBSD$ 327d56d374SYoshinobu Inoue */ 337d56d374SYoshinobu Inoue 34db82af41SHiroki Sato struct script_msg { 35db82af41SHiroki Sato TAILQ_ENTRY(script_msg) sm_next; 36db82af41SHiroki Sato 37db82af41SHiroki Sato char *sm_msg; 38db82af41SHiroki Sato }; 39db82af41SHiroki Sato 40*489e04d0SHiroki Sato TAILQ_HEAD(script_msg_head_t, script_msg); 41*489e04d0SHiroki Sato 42db82af41SHiroki Sato struct ra_opt { 43db82af41SHiroki Sato TAILQ_ENTRY(ra_opt) rao_next; 44db82af41SHiroki Sato 45db82af41SHiroki Sato u_int8_t rao_type; 46db82af41SHiroki Sato struct timeval rao_expire; 47db82af41SHiroki Sato size_t rao_len; 48db82af41SHiroki Sato void *rao_msg; 49db82af41SHiroki Sato }; 50db82af41SHiroki Sato 5106056832SHiroki Sato TAILQ_HEAD(rainfo_head, ra_opt); 5206056832SHiroki Sato 5306056832SHiroki Sato struct rainfo { 5406056832SHiroki Sato TAILQ_ENTRY(rainfo) rai_next; 5506056832SHiroki Sato 5606056832SHiroki Sato struct ifinfo *rai_ifinfo; 5706056832SHiroki Sato struct sockaddr_in6 rai_saddr; 5806056832SHiroki Sato TAILQ_HEAD(, ra_opt) rai_ra_opt; 5906056832SHiroki Sato }; 6006056832SHiroki Sato 617d56d374SYoshinobu Inoue struct ifinfo { 62db82af41SHiroki Sato TAILQ_ENTRY(ifinfo) ifi_next; /* pointer to the next interface */ 637d56d374SYoshinobu Inoue 647d56d374SYoshinobu Inoue struct sockaddr_dl *sdl; /* link-layer address */ 65*489e04d0SHiroki Sato char ifname[IFNAMSIZ]; /* interface name */ 669a364ca3SHajimu UMEMOTO u_int32_t linkid; /* link ID of this interface */ 677d56d374SYoshinobu Inoue int active; /* interface status */ 687d56d374SYoshinobu Inoue int probeinterval; /* interval of probe timer (if necessary) */ 697d56d374SYoshinobu Inoue int probetimer; /* rest of probe timer */ 707d56d374SYoshinobu Inoue int mediareqok; /* wheter the IF supports SIOCGIFMEDIA */ 7186b032afSHajimu UMEMOTO int otherconfig; /* need a separate protocol for the "other" 7286b032afSHajimu UMEMOTO * configuration */ 737d56d374SYoshinobu Inoue int state; 747d56d374SYoshinobu Inoue int probes; 757d56d374SYoshinobu Inoue int dadcount; 767d56d374SYoshinobu Inoue struct timeval timer; 777d56d374SYoshinobu Inoue struct timeval expire; 78259df286SKris Kennaway int errors; /* # of errors we've got - detect wedge */ 7906056832SHiroki Sato #define IFI_DNSOPT_STATE_NOINFO 0 8006056832SHiroki Sato #define IFI_DNSOPT_STATE_RECEIVED 1 8106056832SHiroki Sato int ifi_rdnss; /* RDNSS option state */ 8206056832SHiroki Sato int ifi_dnssl; /* DNSSL option state */ 837d56d374SYoshinobu Inoue 847d56d374SYoshinobu Inoue int racnt; /* total # of valid RAs it have got */ 8506056832SHiroki Sato TAILQ_HEAD(, rainfo) ifi_rainfo; 867d56d374SYoshinobu Inoue 877d56d374SYoshinobu Inoue size_t rs_datalen; 887d56d374SYoshinobu Inoue u_char *rs_data; 897d56d374SYoshinobu Inoue }; 907d56d374SYoshinobu Inoue 917d56d374SYoshinobu Inoue /* per interface status */ 927d56d374SYoshinobu Inoue #define IFS_IDLE 0 937d56d374SYoshinobu Inoue #define IFS_DELAY 1 947d56d374SYoshinobu Inoue #define IFS_PROBE 2 957d56d374SYoshinobu Inoue #define IFS_DOWN 3 967d56d374SYoshinobu Inoue #define IFS_TENTATIVE 4 977d56d374SYoshinobu Inoue 98db82af41SHiroki Sato /* Interface list */ 99db82af41SHiroki Sato extern TAILQ_HEAD(ifinfo_head_t, ifinfo) ifinfo_head; 100db82af41SHiroki Sato 101*489e04d0SHiroki Sato #define DNSINFO_ORIGIN_LABEL "slaac" 102db82af41SHiroki Sato /* 103db82af41SHiroki Sato * RFC 3542 API deprecates IPV6_PKTINFO in favor of 104db82af41SHiroki Sato * IPV6_RECVPKTINFO 105db82af41SHiroki Sato */ 106db82af41SHiroki Sato #ifndef IPV6_RECVPKTINFO 107db82af41SHiroki Sato #ifdef IPV6_PKTINFO 108db82af41SHiroki Sato #define IPV6_RECVPKTINFO IPV6_PKTINFO 109db82af41SHiroki Sato #endif 110db82af41SHiroki Sato #endif 111db82af41SHiroki Sato /* 112db82af41SHiroki Sato * RFC 3542 API deprecates IPV6_HOPLIMIT in favor of 113db82af41SHiroki Sato * IPV6_RECVHOPLIMIT 114db82af41SHiroki Sato */ 115db82af41SHiroki Sato #ifndef IPV6_RECVHOPLIMIT 116db82af41SHiroki Sato #ifdef IPV6_HOPLIMIT 117db82af41SHiroki Sato #define IPV6_RECVHOPLIMIT IPV6_HOPLIMIT 118db82af41SHiroki Sato #endif 119db82af41SHiroki Sato #endif 120db82af41SHiroki Sato 121db82af41SHiroki Sato #ifndef IN6ADDR_LINKLOCAL_ALLROUTERS_INIT 122db82af41SHiroki Sato #define IN6ADDR_LINKLOCAL_ALLROUTERS_INIT \ 123db82af41SHiroki Sato {{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 124db82af41SHiroki Sato 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }}} 125db82af41SHiroki Sato #endif 126db82af41SHiroki Sato 1277d56d374SYoshinobu Inoue /* rtsold.c */ 1287d56d374SYoshinobu Inoue extern struct timeval tm_max; 1297d56d374SYoshinobu Inoue extern int dflag; 1309a364ca3SHajimu UMEMOTO extern int aflag; 131eb87e699SHiroki Sato extern int Fflag; 132*489e04d0SHiroki Sato extern int uflag; 133db82af41SHiroki Sato extern const char *otherconf_script; 134db82af41SHiroki Sato extern const char *resolvconf_script; 135784bddbcSKevin Lo extern int ifconfig(char *); 136784bddbcSKevin Lo extern void iflist_init(void); 137784bddbcSKevin Lo struct ifinfo *find_ifinfo(int); 13806056832SHiroki Sato struct rainfo *find_rainfo(struct ifinfo *, struct sockaddr_in6 *); 139784bddbcSKevin Lo void rtsol_timer_update(struct ifinfo *); 140784bddbcSKevin Lo extern void warnmsg(int, const char *, const char *, ...) 141804c83d4SKris Kennaway __attribute__((__format__(__printf__, 3, 4))); 142784bddbcSKevin Lo extern char **autoifprobe(void); 143db82af41SHiroki Sato extern int ra_opt_handler(struct ifinfo *); 1447d56d374SYoshinobu Inoue 1457d56d374SYoshinobu Inoue /* if.c */ 146784bddbcSKevin Lo extern int ifinit(void); 147784bddbcSKevin Lo extern int interface_up(char *); 148784bddbcSKevin Lo extern int interface_status(struct ifinfo *); 149784bddbcSKevin Lo extern int lladdropt_length(struct sockaddr_dl *); 150784bddbcSKevin Lo extern void lladdropt_fill(struct sockaddr_dl *, struct nd_opt_hdr *); 151784bddbcSKevin Lo extern struct sockaddr_dl *if_nametosdl(char *); 152784bddbcSKevin Lo extern int getinet6sysctl(int); 153784bddbcSKevin Lo extern int setinet6sysctl(int, int); 1547d56d374SYoshinobu Inoue 1557d56d374SYoshinobu Inoue /* rtsol.c */ 156784bddbcSKevin Lo extern int sockopen(void); 157784bddbcSKevin Lo extern void sendpacket(struct ifinfo *); 158784bddbcSKevin Lo extern void rtsol_input(int); 1597d56d374SYoshinobu Inoue 1607d56d374SYoshinobu Inoue /* probe.c */ 161784bddbcSKevin Lo extern int probe_init(void); 162784bddbcSKevin Lo extern void defrouter_probe(struct ifinfo *); 1637d56d374SYoshinobu Inoue 1647d56d374SYoshinobu Inoue /* dump.c */ 165bd2c49afSUlrich Spörlein extern void rtsold_dump_file(const char *); 16606056832SHiroki Sato extern const char *sec2str(const struct timeval *); 16733841545SHajimu UMEMOTO 16833841545SHajimu UMEMOTO /* rtsock.c */ 169784bddbcSKevin Lo extern int rtsock_open(void); 170784bddbcSKevin Lo extern int rtsock_input(int); 171