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 34*db82af41SHiroki Sato struct script_msg { 35*db82af41SHiroki Sato TAILQ_ENTRY(script_msg) sm_next; 36*db82af41SHiroki Sato 37*db82af41SHiroki Sato char *sm_msg; 38*db82af41SHiroki Sato }; 39*db82af41SHiroki Sato 40*db82af41SHiroki Sato struct ra_opt { 41*db82af41SHiroki Sato TAILQ_ENTRY(ra_opt) rao_next; 42*db82af41SHiroki Sato 43*db82af41SHiroki Sato u_int8_t rao_type; 44*db82af41SHiroki Sato struct timeval rao_expire; 45*db82af41SHiroki Sato size_t rao_len; 46*db82af41SHiroki Sato void *rao_msg; 47*db82af41SHiroki Sato }; 48*db82af41SHiroki Sato 497d56d374SYoshinobu Inoue struct ifinfo { 50*db82af41SHiroki Sato TAILQ_ENTRY(ifinfo) ifi_next; /* pointer to the next interface */ 517d56d374SYoshinobu Inoue 527d56d374SYoshinobu Inoue struct sockaddr_dl *sdl; /* link-layer address */ 53259df286SKris Kennaway char ifname[IF_NAMESIZE]; /* interface name */ 549a364ca3SHajimu UMEMOTO u_int32_t linkid; /* link ID of this interface */ 557d56d374SYoshinobu Inoue int active; /* interface status */ 567d56d374SYoshinobu Inoue int probeinterval; /* interval of probe timer (if necessary) */ 577d56d374SYoshinobu Inoue int probetimer; /* rest of probe timer */ 587d56d374SYoshinobu Inoue int mediareqok; /* wheter the IF supports SIOCGIFMEDIA */ 5986b032afSHajimu UMEMOTO int otherconfig; /* need a separate protocol for the "other" 6086b032afSHajimu UMEMOTO * configuration */ 617d56d374SYoshinobu Inoue int state; 627d56d374SYoshinobu Inoue int probes; 637d56d374SYoshinobu Inoue int dadcount; 647d56d374SYoshinobu Inoue struct timeval timer; 657d56d374SYoshinobu Inoue struct timeval expire; 66259df286SKris Kennaway int errors; /* # of errors we've got - detect wedge */ 677d56d374SYoshinobu Inoue 687d56d374SYoshinobu Inoue int racnt; /* total # of valid RAs it have got */ 697d56d374SYoshinobu Inoue 707d56d374SYoshinobu Inoue size_t rs_datalen; 717d56d374SYoshinobu Inoue u_char *rs_data; 72*db82af41SHiroki Sato 73*db82af41SHiroki Sato TAILQ_HEAD(, ra_opt) ifi_ra_opt; 747d56d374SYoshinobu Inoue }; 757d56d374SYoshinobu Inoue 767d56d374SYoshinobu Inoue /* per interface status */ 777d56d374SYoshinobu Inoue #define IFS_IDLE 0 787d56d374SYoshinobu Inoue #define IFS_DELAY 1 797d56d374SYoshinobu Inoue #define IFS_PROBE 2 807d56d374SYoshinobu Inoue #define IFS_DOWN 3 817d56d374SYoshinobu Inoue #define IFS_TENTATIVE 4 827d56d374SYoshinobu Inoue 83*db82af41SHiroki Sato /* Interface list */ 84*db82af41SHiroki Sato extern TAILQ_HEAD(ifinfo_head_t, ifinfo) ifinfo_head; 85*db82af41SHiroki Sato 86*db82af41SHiroki Sato /* 87*db82af41SHiroki Sato * RFC 3542 API deprecates IPV6_PKTINFO in favor of 88*db82af41SHiroki Sato * IPV6_RECVPKTINFO 89*db82af41SHiroki Sato */ 90*db82af41SHiroki Sato #ifndef IPV6_RECVPKTINFO 91*db82af41SHiroki Sato #ifdef IPV6_PKTINFO 92*db82af41SHiroki Sato #define IPV6_RECVPKTINFO IPV6_PKTINFO 93*db82af41SHiroki Sato #endif 94*db82af41SHiroki Sato #endif 95*db82af41SHiroki Sato /* 96*db82af41SHiroki Sato * RFC 3542 API deprecates IPV6_HOPLIMIT in favor of 97*db82af41SHiroki Sato * IPV6_RECVHOPLIMIT 98*db82af41SHiroki Sato */ 99*db82af41SHiroki Sato #ifndef IPV6_RECVHOPLIMIT 100*db82af41SHiroki Sato #ifdef IPV6_HOPLIMIT 101*db82af41SHiroki Sato #define IPV6_RECVHOPLIMIT IPV6_HOPLIMIT 102*db82af41SHiroki Sato #endif 103*db82af41SHiroki Sato #endif 104*db82af41SHiroki Sato 105*db82af41SHiroki Sato #ifndef IN6ADDR_LINKLOCAL_ALLROUTERS_INIT 106*db82af41SHiroki Sato #define IN6ADDR_LINKLOCAL_ALLROUTERS_INIT \ 107*db82af41SHiroki Sato {{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 108*db82af41SHiroki Sato 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }}} 109*db82af41SHiroki Sato #endif 110*db82af41SHiroki Sato 1117d56d374SYoshinobu Inoue /* rtsold.c */ 1127d56d374SYoshinobu Inoue extern struct timeval tm_max; 1137d56d374SYoshinobu Inoue extern int dflag; 1149a364ca3SHajimu UMEMOTO extern int aflag; 115eb87e699SHiroki Sato extern int Fflag; 116*db82af41SHiroki Sato extern const char *otherconf_script; 117*db82af41SHiroki Sato extern const char *resolvconf_script; 118784bddbcSKevin Lo extern int ifconfig(char *); 119784bddbcSKevin Lo extern void iflist_init(void); 120784bddbcSKevin Lo struct ifinfo *find_ifinfo(int); 121784bddbcSKevin Lo void rtsol_timer_update(struct ifinfo *); 122784bddbcSKevin Lo extern void warnmsg(int, const char *, const char *, ...) 123804c83d4SKris Kennaway __attribute__((__format__(__printf__, 3, 4))); 124784bddbcSKevin Lo extern char **autoifprobe(void); 125*db82af41SHiroki Sato extern int ra_opt_handler(struct ifinfo *); 1267d56d374SYoshinobu Inoue 1277d56d374SYoshinobu Inoue /* if.c */ 128784bddbcSKevin Lo extern int ifinit(void); 129784bddbcSKevin Lo extern int interface_up(char *); 130784bddbcSKevin Lo extern int interface_status(struct ifinfo *); 131784bddbcSKevin Lo extern int lladdropt_length(struct sockaddr_dl *); 132784bddbcSKevin Lo extern void lladdropt_fill(struct sockaddr_dl *, struct nd_opt_hdr *); 133784bddbcSKevin Lo extern struct sockaddr_dl *if_nametosdl(char *); 134784bddbcSKevin Lo extern int getinet6sysctl(int); 135784bddbcSKevin Lo extern int setinet6sysctl(int, int); 1367d56d374SYoshinobu Inoue 1377d56d374SYoshinobu Inoue /* rtsol.c */ 138784bddbcSKevin Lo extern int sockopen(void); 139784bddbcSKevin Lo extern void sendpacket(struct ifinfo *); 140784bddbcSKevin Lo extern void rtsol_input(int); 1417d56d374SYoshinobu Inoue 1427d56d374SYoshinobu Inoue /* probe.c */ 143784bddbcSKevin Lo extern int probe_init(void); 144784bddbcSKevin Lo extern void defrouter_probe(struct ifinfo *); 1457d56d374SYoshinobu Inoue 1467d56d374SYoshinobu Inoue /* dump.c */ 147bd2c49afSUlrich Spörlein extern void rtsold_dump_file(const char *); 14833841545SHajimu UMEMOTO 14933841545SHajimu UMEMOTO /* rtsock.c */ 150784bddbcSKevin Lo extern int rtsock_open(void); 151784bddbcSKevin Lo extern int rtsock_input(int); 152