xref: /onnv-gate/usr/src/cmd/cmd-inet/usr.lib/in.ndpd/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 #ifndef	_NDPD_DEFS_H
28*0Sstevel@tonic-gate #define	_NDPD_DEFS_H
29*0Sstevel@tonic-gate 
30*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*0Sstevel@tonic-gate 
32*0Sstevel@tonic-gate #include <stdio.h>
33*0Sstevel@tonic-gate #include <stdlib.h>
34*0Sstevel@tonic-gate #include <strings.h>
35*0Sstevel@tonic-gate #include <errno.h>
36*0Sstevel@tonic-gate #include <sys/types.h>
37*0Sstevel@tonic-gate #include <fcntl.h>
38*0Sstevel@tonic-gate #include <signal.h>
39*0Sstevel@tonic-gate #include <poll.h>
40*0Sstevel@tonic-gate #include <unistd.h>
41*0Sstevel@tonic-gate #include <time.h>
42*0Sstevel@tonic-gate #include <stdarg.h>
43*0Sstevel@tonic-gate #include <syslog.h>
44*0Sstevel@tonic-gate 
45*0Sstevel@tonic-gate #include <sys/param.h>
46*0Sstevel@tonic-gate #include <sys/socket.h>
47*0Sstevel@tonic-gate #include <arpa/inet.h>
48*0Sstevel@tonic-gate #include <netdb.h>
49*0Sstevel@tonic-gate 
50*0Sstevel@tonic-gate #include <sys/ioctl.h>
51*0Sstevel@tonic-gate #include <sys/sockio.h>
52*0Sstevel@tonic-gate #include <net/if.h>
53*0Sstevel@tonic-gate #include <sys/stropts.h>
54*0Sstevel@tonic-gate 
55*0Sstevel@tonic-gate #include <string.h>
56*0Sstevel@tonic-gate #include <ctype.h>
57*0Sstevel@tonic-gate 
58*0Sstevel@tonic-gate #include <netinet/in_systm.h>
59*0Sstevel@tonic-gate #include <netinet/in.h>
60*0Sstevel@tonic-gate #include <netinet/ip.h>
61*0Sstevel@tonic-gate #include <netinet/ip_icmp.h>
62*0Sstevel@tonic-gate #include <netinet/if_ether.h>
63*0Sstevel@tonic-gate #include <netinet/ip6.h>
64*0Sstevel@tonic-gate #include <netinet/icmp6.h>
65*0Sstevel@tonic-gate #include <net/route.h>
66*0Sstevel@tonic-gate 
67*0Sstevel@tonic-gate #ifdef	__cplusplus
68*0Sstevel@tonic-gate extern "C" {
69*0Sstevel@tonic-gate #endif
70*0Sstevel@tonic-gate 
71*0Sstevel@tonic-gate #define	PATH_NDPD_CONF	"/etc/inet/ndpd.conf"
72*0Sstevel@tonic-gate #define	PATH_PID	"/var/run/in.ndpd.pid"
73*0Sstevel@tonic-gate 
74*0Sstevel@tonic-gate extern int debug, no_loopback;
75*0Sstevel@tonic-gate 
76*0Sstevel@tonic-gate extern struct in6_addr all_nodes_mcast;
77*0Sstevel@tonic-gate extern struct in6_addr all_routers_mcast;
78*0Sstevel@tonic-gate 
79*0Sstevel@tonic-gate extern int			rtsock;
80*0Sstevel@tonic-gate extern struct	rt_msghdr	*rt_msg;
81*0Sstevel@tonic-gate extern struct	sockaddr_in6	*rta_gateway;
82*0Sstevel@tonic-gate extern struct	sockaddr_dl	*rta_ifp;
83*0Sstevel@tonic-gate 
84*0Sstevel@tonic-gate /* Debug flags */
85*0Sstevel@tonic-gate #define	D_ALL		0xffff
86*0Sstevel@tonic-gate #define	D_DEFAULTS	0x0001		/* Default values in config file */
87*0Sstevel@tonic-gate #define	D_CONFIG	0x0002		/* Config file */
88*0Sstevel@tonic-gate #define	D_PHYINT	0x0004		/* phyint table */
89*0Sstevel@tonic-gate #define	D_PREFIX	0x0008		/* prefix table */
90*0Sstevel@tonic-gate #define	D_ROUTER	0x0010		/* router table */
91*0Sstevel@tonic-gate #define	D_STATE		0x0020		/* RS/RA state machine */
92*0Sstevel@tonic-gate #define	D_IFSCAN	0x0040		/* Scan of kernel interfaces */
93*0Sstevel@tonic-gate #define	D_TIMER		0x0080		/* Timer mechanism */
94*0Sstevel@tonic-gate #define	D_PARSE		0x0100		/* config file parser */
95*0Sstevel@tonic-gate #define	D_PKTIN		0x0200		/* Received packet */
96*0Sstevel@tonic-gate #define	D_PKTBAD	0x0400		/* Malformed packet */
97*0Sstevel@tonic-gate #define	D_PKTOUT	0x0800		/* Sent packet */
98*0Sstevel@tonic-gate #define	D_TMP		0x1000		/* RFC3041 mechanism */
99*0Sstevel@tonic-gate #define	D_DAD		0x2000		/* Duplciate Address Detection */
100*0Sstevel@tonic-gate 
101*0Sstevel@tonic-gate #define	IF_SEPARATOR		':'
102*0Sstevel@tonic-gate #define	IPV6_MAX_HOPS		255
103*0Sstevel@tonic-gate #define	IPV6_MIN_MTU		(1024+256)
104*0Sstevel@tonic-gate #define	IPV6_ABITS		128
105*0Sstevel@tonic-gate #define	TMP_TOKEN_BITS		64
106*0Sstevel@tonic-gate #define	TMP_TOKEN_BYTES		(TMP_TOKEN_BITS / 8)
107*0Sstevel@tonic-gate #define	MAX_DAD_FAILURES	5
108*0Sstevel@tonic-gate 
109*0Sstevel@tonic-gate /* Return a random number from a an range inclusive of the endpoints */
110*0Sstevel@tonic-gate #define	GET_RANDOM(LOW, HIGH) (random() % ((HIGH) - (LOW) + 1) + (LOW))
111*0Sstevel@tonic-gate 
112*0Sstevel@tonic-gate #define	TIMER_INFINITY	0xFFFFFFFFU	/* Never time out */
113*0Sstevel@tonic-gate #define	PREFIX_INFINITY 0XFFFFFFFFU	/* A "forever" prefix lifetime */
114*0Sstevel@tonic-gate 
115*0Sstevel@tonic-gate /*
116*0Sstevel@tonic-gate  * Used by 2 hour rule for stateless addrconf
117*0Sstevel@tonic-gate  */
118*0Sstevel@tonic-gate #define	MIN_VALID_LIFETIME	(2*60*60)		/* In seconds */
119*0Sstevel@tonic-gate 
120*0Sstevel@tonic-gate /*
121*0Sstevel@tonic-gate  * Control how often pi_ReachableTime gets re-randomized
122*0Sstevel@tonic-gate  */
123*0Sstevel@tonic-gate #define	MIN_REACH_RANDOM_INTERVAL	(60*1000)	/* 1 minute in ms */
124*0Sstevel@tonic-gate #define	MAX_REACH_RANDOM_INTERVAL	(60*60*1000)	/* 1 hour in ms */
125*0Sstevel@tonic-gate 
126*0Sstevel@tonic-gate /*
127*0Sstevel@tonic-gate  * Parsing constants
128*0Sstevel@tonic-gate  */
129*0Sstevel@tonic-gate #define	MAXLINELEN	4096
130*0Sstevel@tonic-gate #define	MAXARGSPERLINE	128
131*0Sstevel@tonic-gate 
132*0Sstevel@tonic-gate void		timer_schedule(uint_t delay);
133*0Sstevel@tonic-gate extern void	logmsg(int level, char *fmt, ...);
134*0Sstevel@tonic-gate extern void	logperror(char *str);
135*0Sstevel@tonic-gate extern int	parse_config(char *config_file, boolean_t file_required);
136*0Sstevel@tonic-gate 
137*0Sstevel@tonic-gate extern int	poll_add(int fd);
138*0Sstevel@tonic-gate extern int	poll_remove(int fd);
139*0Sstevel@tonic-gate 
140*0Sstevel@tonic-gate extern char	*fmt_lla(char *llabuf, int bufsize, uchar_t *lla, int llalen);
141*0Sstevel@tonic-gate 
142*0Sstevel@tonic-gate extern int	do_dad(char *ifname, struct sockaddr_in6 *testaddr);
143*0Sstevel@tonic-gate 
144*0Sstevel@tonic-gate #ifdef	__cplusplus
145*0Sstevel@tonic-gate }
146*0Sstevel@tonic-gate #endif
147*0Sstevel@tonic-gate 
148*0Sstevel@tonic-gate #endif	/* _NDPD_DEFS_H */
149