xref: /titanic_50/usr/src/cmd/cmd-inet/usr.lib/in.ndpd/defs.h (revision 7c2fbfb345896881c631598ee3852ce9ce33fb07)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_NDPD_DEFS_H
27 #define	_NDPD_DEFS_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #include <stdio.h>
32 #include <stdlib.h>
33 #include <strings.h>
34 #include <errno.h>
35 #include <sys/types.h>
36 #include <fcntl.h>
37 #include <signal.h>
38 #include <poll.h>
39 #include <unistd.h>
40 #include <time.h>
41 #include <stdarg.h>
42 #include <syslog.h>
43 
44 #include <sys/param.h>
45 #include <sys/socket.h>
46 #include <arpa/inet.h>
47 #include <netdb.h>
48 
49 #include <sys/ioctl.h>
50 #include <sys/sockio.h>
51 #include <net/if.h>
52 #include <sys/stropts.h>
53 
54 #include <string.h>
55 #include <ctype.h>
56 
57 #include <netinet/in_systm.h>
58 #include <netinet/in.h>
59 #include <netinet/ip.h>
60 #include <netinet/ip_icmp.h>
61 #include <netinet/if_ether.h>
62 #include <netinet/ip6.h>
63 #include <netinet/icmp6.h>
64 #include <net/route.h>
65 
66 #include "tables.h"
67 
68 #ifdef	__cplusplus
69 extern "C" {
70 #endif
71 
72 #define	CURHOP_UNSPECIFIED 0
73 #define	PATH_NDPD_CONF	"/etc/inet/ndpd.conf"
74 #define	PATH_PID	"/var/run/in.ndpd.pid"
75 
76 extern int debug, no_loopback;
77 
78 extern struct in6_addr all_nodes_mcast;
79 extern struct in6_addr all_routers_mcast;
80 
81 extern int			rtsock;
82 extern struct	rt_msghdr	*rt_msg;
83 extern struct	sockaddr_in6	*rta_gateway;
84 extern struct	sockaddr_dl	*rta_ifp;
85 
86 /* Debug flags */
87 #define	D_ALL		0xffff
88 #define	D_DEFAULTS	0x0001		/* Default values in config file */
89 #define	D_CONFIG	0x0002		/* Config file */
90 #define	D_PHYINT	0x0004		/* phyint table */
91 #define	D_PREFIX	0x0008		/* prefix table */
92 #define	D_ROUTER	0x0010		/* router table */
93 #define	D_STATE		0x0020		/* RS/RA state machine */
94 #define	D_IFSCAN	0x0040		/* Scan of kernel interfaces */
95 #define	D_TIMER		0x0080		/* Timer mechanism */
96 #define	D_PARSE		0x0100		/* config file parser */
97 #define	D_PKTIN		0x0200		/* Received packet */
98 #define	D_PKTBAD	0x0400		/* Malformed packet */
99 #define	D_PKTOUT	0x0800		/* Sent packet */
100 #define	D_TMP		0x1000		/* RFC3041 mechanism */
101 #define	D_DHCP		0x2000		/* RFC3315 DHCPv6 (stateful addrs) */
102 
103 #define	IF_SEPARATOR		':'
104 #define	IPV6_MAX_HOPS		255
105 #define	IPV6_MIN_MTU		(1024+256)
106 #define	IPV6_ABITS		128
107 #define	TMP_TOKEN_BITS		64
108 #define	TMP_TOKEN_BYTES		(TMP_TOKEN_BITS / 8)
109 #define	MAX_DAD_FAILURES	5
110 
111 /* Return a random number from a an range inclusive of the endpoints */
112 #define	GET_RANDOM(LOW, HIGH) (random() % ((HIGH) - (LOW) + 1) + (LOW))
113 
114 #define	TIMER_INFINITY	0xFFFFFFFFU	/* Never time out */
115 #define	PREFIX_INFINITY 0XFFFFFFFFU	/* A "forever" prefix lifetime */
116 
117 /*
118  * Used by 2 hour rule for stateless addrconf
119  */
120 #define	MIN_VALID_LIFETIME	(2*60*60)		/* In seconds */
121 
122 /*
123  * Control how often pi_ReachableTime gets re-randomized
124  */
125 #define	MIN_REACH_RANDOM_INTERVAL	(60*1000)	/* 1 minute in ms */
126 #define	MAX_REACH_RANDOM_INTERVAL	(60*60*1000)	/* 1 hour in ms */
127 
128 /*
129  * Parsing constants
130  */
131 #define	MAXLINELEN	4096
132 #define	MAXARGSPERLINE	128
133 
134 void		timer_schedule(uint_t delay);
135 extern void	logmsg(int level, const char *fmt, ...);
136 extern void	logperror(const char *str);
137 extern void	logperror_pi(const struct phyint *pi, const char *str);
138 extern void	logperror_pr(const struct prefix *pr, const char *str);
139 extern int	parse_config(char *config_file, boolean_t file_required);
140 
141 extern int	poll_add(int fd);
142 extern int	poll_remove(int fd);
143 
144 extern char	*fmt_lla(char *llabuf, int bufsize, uchar_t *lla, int llalen);
145 
146 extern int	do_dad(char *ifname, struct sockaddr_in6 *testaddr);
147 
148 #ifdef	__cplusplus
149 }
150 #endif
151 
152 #endif	/* _NDPD_DEFS_H */
153