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