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