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