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