rtsold.h revision 222732
1/*	$KAME: rtsold.h,v 1.19 2003/04/16 09:48:15 itojun Exp $	*/
2
3/*
4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 *    notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 *    notice, this list of conditions and the following disclaimer in the
14 *    documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the project nor the names of its contributors
16 *    may be used to endorse or promote products derived from this software
17 *    without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 *
31 * $FreeBSD: head/usr.sbin/rtsold/rtsold.h 222732 2011-06-06 03:06:43Z hrs $
32 */
33
34struct script_msg {
35	TAILQ_ENTRY(script_msg)	sm_next;
36
37	char *sm_msg;
38};
39
40struct ra_opt {
41	TAILQ_ENTRY(ra_opt)	rao_next;
42
43	u_int8_t	rao_type;
44	struct timeval	rao_expire;
45	size_t		rao_len;
46	void		*rao_msg;
47};
48
49struct ifinfo {
50	TAILQ_ENTRY(ifinfo)	ifi_next;	/* pointer to the next interface */
51
52	struct sockaddr_dl *sdl; /* link-layer address */
53	char ifname[IF_NAMESIZE]; /* interface name */
54	u_int32_t linkid;	/* link ID of this interface */
55	int active;		/* interface status */
56	int probeinterval;	/* interval of probe timer (if necessary) */
57	int probetimer;		/* rest of probe timer */
58	int mediareqok;		/* wheter the IF supports SIOCGIFMEDIA */
59	int otherconfig;	/* need a separate protocol for the "other"
60				 * configuration */
61	int state;
62	int probes;
63	int dadcount;
64	struct timeval timer;
65	struct timeval expire;
66	int errors;		/* # of errors we've got - detect wedge */
67
68	int racnt;		/* total # of valid RAs it have got */
69
70	size_t rs_datalen;
71	u_char *rs_data;
72
73	TAILQ_HEAD(, ra_opt)   ifi_ra_opt;
74};
75
76/* per interface status */
77#define IFS_IDLE	0
78#define IFS_DELAY	1
79#define IFS_PROBE	2
80#define IFS_DOWN	3
81#define IFS_TENTATIVE	4
82
83/* Interface list */
84extern TAILQ_HEAD(ifinfo_head_t, ifinfo) ifinfo_head;
85
86/*
87 * RFC 3542 API deprecates IPV6_PKTINFO in favor of
88 * IPV6_RECVPKTINFO
89 */
90#ifndef IPV6_RECVPKTINFO
91#ifdef IPV6_PKTINFO
92#define IPV6_RECVPKTINFO	IPV6_PKTINFO
93#endif
94#endif
95/*
96 * RFC 3542 API deprecates IPV6_HOPLIMIT in favor of
97 * IPV6_RECVHOPLIMIT
98 */
99#ifndef IPV6_RECVHOPLIMIT
100#ifdef IPV6_HOPLIMIT
101#define IPV6_RECVHOPLIMIT	IPV6_HOPLIMIT
102#endif
103#endif
104
105#ifndef IN6ADDR_LINKLOCAL_ALLROUTERS_INIT
106#define IN6ADDR_LINKLOCAL_ALLROUTERS_INIT			\
107	{{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,	\
108	    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }}}
109#endif
110
111/* rtsold.c */
112extern struct timeval tm_max;
113extern int dflag;
114extern int aflag;
115extern int Fflag;
116extern const char *otherconf_script;
117extern const char *resolvconf_script;
118extern int ifconfig(char *);
119extern void iflist_init(void);
120struct ifinfo *find_ifinfo(int);
121void rtsol_timer_update(struct ifinfo *);
122extern void warnmsg(int, const char *, const char *, ...)
123     __attribute__((__format__(__printf__, 3, 4)));
124extern char **autoifprobe(void);
125extern int ra_opt_handler(struct ifinfo *);
126
127/* if.c */
128extern int ifinit(void);
129extern int interface_up(char *);
130extern int interface_status(struct ifinfo *);
131extern int lladdropt_length(struct sockaddr_dl *);
132extern void lladdropt_fill(struct sockaddr_dl *, struct nd_opt_hdr *);
133extern struct sockaddr_dl *if_nametosdl(char *);
134extern int getinet6sysctl(int);
135extern int setinet6sysctl(int, int);
136
137/* rtsol.c */
138extern int sockopen(void);
139extern void sendpacket(struct ifinfo *);
140extern void rtsol_input(int);
141
142/* probe.c */
143extern int probe_init(void);
144extern void defrouter_probe(struct ifinfo *);
145
146/* dump.c */
147extern void rtsold_dump_file(const char *);
148
149/* rtsock.c */
150extern int rtsock_open(void);
151extern int rtsock_input(int);
152