xref: /onnv-gate/usr/src/cmd/cmd-inet/usr.lib/in.ripngd/defs.h (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
24*0Sstevel@tonic-gate  * Use is subject to license terms.
25*0Sstevel@tonic-gate  */
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
28*0Sstevel@tonic-gate /*	  All Rights Reserved  	*/
29*0Sstevel@tonic-gate 
30*0Sstevel@tonic-gate /*
31*0Sstevel@tonic-gate  * Portions of this source code were derived from Berkeley 4.3 BSD
32*0Sstevel@tonic-gate  * under license from the Regents of the University of California.
33*0Sstevel@tonic-gate  */
34*0Sstevel@tonic-gate 
35*0Sstevel@tonic-gate #ifndef	_IN_RIPNGD_DEFS_H
36*0Sstevel@tonic-gate #define	_IN_RIPNGD_DEFS_H
37*0Sstevel@tonic-gate 
38*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
39*0Sstevel@tonic-gate 
40*0Sstevel@tonic-gate #ifdef	__cplusplus
41*0Sstevel@tonic-gate extern "C" {
42*0Sstevel@tonic-gate #endif
43*0Sstevel@tonic-gate 
44*0Sstevel@tonic-gate #include <sys/types.h>
45*0Sstevel@tonic-gate #include <sys/socket.h>
46*0Sstevel@tonic-gate #include <sys/sockio.h>
47*0Sstevel@tonic-gate #include <sys/stream.h>
48*0Sstevel@tonic-gate #include <sys/time.h>
49*0Sstevel@tonic-gate #include <sys/stat.h>
50*0Sstevel@tonic-gate #include <fcntl.h>
51*0Sstevel@tonic-gate 
52*0Sstevel@tonic-gate #include <netinet/in.h>
53*0Sstevel@tonic-gate #include <netinet/ip6.h>
54*0Sstevel@tonic-gate #include <netinet/udp.h>
55*0Sstevel@tonic-gate #include <net/if.h>
56*0Sstevel@tonic-gate #include <net/route.h>
57*0Sstevel@tonic-gate #include <protocols/ripngd.h>
58*0Sstevel@tonic-gate 
59*0Sstevel@tonic-gate #include <stdio.h>
60*0Sstevel@tonic-gate #include <stdlib.h>
61*0Sstevel@tonic-gate #include <syslog.h>
62*0Sstevel@tonic-gate #include <netdb.h>
63*0Sstevel@tonic-gate 
64*0Sstevel@tonic-gate #include <signal.h>
65*0Sstevel@tonic-gate #include <stropts.h>
66*0Sstevel@tonic-gate #include <arpa/inet.h>
67*0Sstevel@tonic-gate 
68*0Sstevel@tonic-gate #include <strings.h>
69*0Sstevel@tonic-gate #include <unistd.h>
70*0Sstevel@tonic-gate #include <errno.h>
71*0Sstevel@tonic-gate #include <malloc.h>
72*0Sstevel@tonic-gate #include <limits.h>
73*0Sstevel@tonic-gate 
74*0Sstevel@tonic-gate #include "table.h"
75*0Sstevel@tonic-gate #include "trace.h"
76*0Sstevel@tonic-gate #include "interface.h"
77*0Sstevel@tonic-gate 
78*0Sstevel@tonic-gate #define	PATH_PID	"/var/run/in.ripngd.pid"
79*0Sstevel@tonic-gate 
80*0Sstevel@tonic-gate /*
81*0Sstevel@tonic-gate  * Timer values (in seconds) used in managing the routing table.
82*0Sstevel@tonic-gate  * Every update forces an entry's timer to be reset.  After
83*0Sstevel@tonic-gate  * EXPIRE_TIME without updates, the entry is marked invalid,
84*0Sstevel@tonic-gate  * but held onto until GARBAGE_TIME so that others may
85*0Sstevel@tonic-gate  * see it "be deleted".
86*0Sstevel@tonic-gate  */
87*0Sstevel@tonic-gate #define	EXPIRE_TIME		180	/* time to mark entry invalid */
88*0Sstevel@tonic-gate #define	GARBAGE_TIME		300	/* time to garbage collect */
89*0Sstevel@tonic-gate #define	MIN_SUPPLY_TIME		15	/* min. time to supply tables */
90*0Sstevel@tonic-gate #define	MAX_SUPPLY_TIME		45	/* max. time to supply tables */
91*0Sstevel@tonic-gate #define	MIN_WAIT_TIME		1	/* min. interval to multicast changes */
92*0Sstevel@tonic-gate #define	MAX_WAIT_TIME		5	/* max. time to delay changes */
93*0Sstevel@tonic-gate 
94*0Sstevel@tonic-gate /*
95*0Sstevel@tonic-gate  * Return a random number from a an range inclusive of the endpoints
96*0Sstevel@tonic-gate  */
97*0Sstevel@tonic-gate #define	GET_RANDOM(LOW, HIGH) (random() % ((HIGH) - (LOW) + 1) + (LOW))
98*0Sstevel@tonic-gate 
99*0Sstevel@tonic-gate /*
100*0Sstevel@tonic-gate  * When we find any interfaces marked down we rescan the
101*0Sstevel@tonic-gate  * kernel every CHECK_INTERVAL seconds to see if they've
102*0Sstevel@tonic-gate  * come up.
103*0Sstevel@tonic-gate  */
104*0Sstevel@tonic-gate #define	CHECK_INTERVAL		60
105*0Sstevel@tonic-gate #define	START_POLL_SIZE		5
106*0Sstevel@tonic-gate 
107*0Sstevel@tonic-gate #define	min(a, b)		((a) > (b) ? (b) : (a))
108*0Sstevel@tonic-gate 
109*0Sstevel@tonic-gate /*
110*0Sstevel@tonic-gate  * The maximum receive buffer size is controlled via Solaris' NDD udp_max_buf
111*0Sstevel@tonic-gate  * tunable.
112*0Sstevel@tonic-gate  */
113*0Sstevel@tonic-gate #define	RCVBUFSIZ		65536
114*0Sstevel@tonic-gate 
115*0Sstevel@tonic-gate #define	TIME_TO_MSECS(tval)	((tval).tv_sec * 1000 + (tval).tv_usec / 1000)
116*0Sstevel@tonic-gate 
117*0Sstevel@tonic-gate #define	HOPCNT_INFINITY		16		/* RFC 2080, section 2.1 */
118*0Sstevel@tonic-gate #define	HOPCNT_NEXTHOP		255		/* RFC 2080, section 2.1.1 */
119*0Sstevel@tonic-gate 
120*0Sstevel@tonic-gate /*
121*0Sstevel@tonic-gate  * XXX Some of these are defined in <inet/ip6.h> under _KERNEL (but should be
122*0Sstevel@tonic-gate  * defined in <netinet/ip6.h> for completeness).
123*0Sstevel@tonic-gate  */
124*0Sstevel@tonic-gate #define	IPV6_MAX_HOPS		255		/* Max IPv6 hops */
125*0Sstevel@tonic-gate #define	IPV6_MAX_PACKET		65535		/* maximum IPv6 packet size */
126*0Sstevel@tonic-gate #define	IPV6_MIN_MTU		1280		/* Minimum IPv6 MTU */
127*0Sstevel@tonic-gate 
128*0Sstevel@tonic-gate extern struct		sockaddr_in6 allrouters;
129*0Sstevel@tonic-gate extern struct		in6_addr allrouters_in6;
130*0Sstevel@tonic-gate extern char		*control;
131*0Sstevel@tonic-gate extern boolean_t	dopoison;
132*0Sstevel@tonic-gate extern struct		interface *ifnet;
133*0Sstevel@tonic-gate extern boolean_t	install;
134*0Sstevel@tonic-gate extern int		iocsoc;
135*0Sstevel@tonic-gate extern struct		timeval lastfullupdate;
136*0Sstevel@tonic-gate extern struct		timeval lastmcast;
137*0Sstevel@tonic-gate extern int		max_poll_ifs;
138*0Sstevel@tonic-gate extern struct		rip6 *msg;
139*0Sstevel@tonic-gate extern boolean_t	needupdate;
140*0Sstevel@tonic-gate extern struct		timeval nextmcast;
141*0Sstevel@tonic-gate extern struct		timeval now;
142*0Sstevel@tonic-gate extern char		*packet;
143*0Sstevel@tonic-gate extern struct		pollfd *poll_ifs;
144*0Sstevel@tonic-gate extern int		poll_ifs_num;
145*0Sstevel@tonic-gate extern int		rip6_port;
146*0Sstevel@tonic-gate extern int		supplyinterval;
147*0Sstevel@tonic-gate extern boolean_t	supplier;
148*0Sstevel@tonic-gate 
149*0Sstevel@tonic-gate extern void		dynamic_update(struct interface *);
150*0Sstevel@tonic-gate extern void		in_data(struct interface *);
151*0Sstevel@tonic-gate extern void		initifs(void);
152*0Sstevel@tonic-gate extern void		sendpacket(struct sockaddr_in6 *, struct interface *,
153*0Sstevel@tonic-gate     int, int);
154*0Sstevel@tonic-gate extern void		setup_rtsock(void);
155*0Sstevel@tonic-gate extern void		solicitall(struct sockaddr_in6 *);
156*0Sstevel@tonic-gate extern void		supply(struct sockaddr_in6 *, struct interface *,
157*0Sstevel@tonic-gate     int, boolean_t);
158*0Sstevel@tonic-gate extern void		supplyall(struct sockaddr_in6 *, int,
159*0Sstevel@tonic-gate     struct interface *, boolean_t);
160*0Sstevel@tonic-gate extern void		term(void);
161*0Sstevel@tonic-gate extern void		timer(void);
162*0Sstevel@tonic-gate extern void		timevaladd(struct timeval *, struct timeval *);
163*0Sstevel@tonic-gate 
164*0Sstevel@tonic-gate #ifdef	__cplusplus
165*0Sstevel@tonic-gate }
166*0Sstevel@tonic-gate #endif
167*0Sstevel@tonic-gate 
168*0Sstevel@tonic-gate #endif	/* _IN_RIPNGD_DEFS_H */
169