xref: /titanic_50/usr/src/cmd/cmd-inet/usr.lib/in.ndpd/defs.h (revision 176dc7289d4a747748f02c0dd61a72b7423deeb6)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5b0f490f4Smh138676  * Common Development and Distribution License (the "License").
6b0f490f4Smh138676  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*6e91bba0SGirish Moodalbail  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef	_NDPD_DEFS_H
277c478bd9Sstevel@tonic-gate #define	_NDPD_DEFS_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #include <stdio.h>
307c478bd9Sstevel@tonic-gate #include <stdlib.h>
317c478bd9Sstevel@tonic-gate #include <strings.h>
327c478bd9Sstevel@tonic-gate #include <errno.h>
337c478bd9Sstevel@tonic-gate #include <sys/types.h>
347c478bd9Sstevel@tonic-gate #include <fcntl.h>
357c478bd9Sstevel@tonic-gate #include <signal.h>
367c478bd9Sstevel@tonic-gate #include <poll.h>
377c478bd9Sstevel@tonic-gate #include <unistd.h>
387c478bd9Sstevel@tonic-gate #include <time.h>
397c478bd9Sstevel@tonic-gate #include <stdarg.h>
407c478bd9Sstevel@tonic-gate #include <syslog.h>
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate #include <sys/param.h>
437c478bd9Sstevel@tonic-gate #include <sys/socket.h>
447c478bd9Sstevel@tonic-gate #include <arpa/inet.h>
457c478bd9Sstevel@tonic-gate #include <netdb.h>
467c478bd9Sstevel@tonic-gate 
477c478bd9Sstevel@tonic-gate #include <sys/ioctl.h>
487c478bd9Sstevel@tonic-gate #include <sys/sockio.h>
497c478bd9Sstevel@tonic-gate #include <net/if.h>
507c478bd9Sstevel@tonic-gate #include <sys/stropts.h>
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate #include <string.h>
537c478bd9Sstevel@tonic-gate #include <ctype.h>
547c478bd9Sstevel@tonic-gate 
557c478bd9Sstevel@tonic-gate #include <netinet/in_systm.h>
567c478bd9Sstevel@tonic-gate #include <netinet/in.h>
577c478bd9Sstevel@tonic-gate #include <netinet/ip.h>
587c478bd9Sstevel@tonic-gate #include <netinet/ip_icmp.h>
597c478bd9Sstevel@tonic-gate #include <netinet/if_ether.h>
607c478bd9Sstevel@tonic-gate #include <netinet/ip6.h>
617c478bd9Sstevel@tonic-gate #include <netinet/icmp6.h>
627c478bd9Sstevel@tonic-gate #include <net/route.h>
63*6e91bba0SGirish Moodalbail #include <libipadm.h>
64*6e91bba0SGirish Moodalbail #include <ipadm_ndpd.h>
657c478bd9Sstevel@tonic-gate 
66b0f490f4Smh138676 #include "tables.h"
67b0f490f4Smh138676 
687c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
697c478bd9Sstevel@tonic-gate extern "C" {
707c478bd9Sstevel@tonic-gate #endif
717c478bd9Sstevel@tonic-gate 
720a12cda4Sdd193516 #define	CURHOP_UNSPECIFIED 0
737c478bd9Sstevel@tonic-gate #define	PATH_NDPD_CONF	"/etc/inet/ndpd.conf"
747c478bd9Sstevel@tonic-gate 
757c478bd9Sstevel@tonic-gate extern int debug, no_loopback;
767c478bd9Sstevel@tonic-gate 
777c478bd9Sstevel@tonic-gate extern struct in6_addr all_nodes_mcast;
787c478bd9Sstevel@tonic-gate extern struct in6_addr all_routers_mcast;
797c478bd9Sstevel@tonic-gate 
807c478bd9Sstevel@tonic-gate extern int			rtsock;
817c478bd9Sstevel@tonic-gate extern struct	rt_msghdr	*rt_msg;
827c478bd9Sstevel@tonic-gate extern struct	sockaddr_in6	*rta_gateway;
837c478bd9Sstevel@tonic-gate extern struct	sockaddr_dl	*rta_ifp;
847c478bd9Sstevel@tonic-gate 
857c478bd9Sstevel@tonic-gate /* Debug flags */
867c478bd9Sstevel@tonic-gate #define	D_ALL		0xffff
877c478bd9Sstevel@tonic-gate #define	D_DEFAULTS	0x0001		/* Default values in config file */
887c478bd9Sstevel@tonic-gate #define	D_CONFIG	0x0002		/* Config file */
897c478bd9Sstevel@tonic-gate #define	D_PHYINT	0x0004		/* phyint table */
907c478bd9Sstevel@tonic-gate #define	D_PREFIX	0x0008		/* prefix table */
917c478bd9Sstevel@tonic-gate #define	D_ROUTER	0x0010		/* router table */
927c478bd9Sstevel@tonic-gate #define	D_STATE		0x0020		/* RS/RA state machine */
937c478bd9Sstevel@tonic-gate #define	D_IFSCAN	0x0040		/* Scan of kernel interfaces */
947c478bd9Sstevel@tonic-gate #define	D_TIMER		0x0080		/* Timer mechanism */
957c478bd9Sstevel@tonic-gate #define	D_PARSE		0x0100		/* config file parser */
967c478bd9Sstevel@tonic-gate #define	D_PKTIN		0x0200		/* Received packet */
977c478bd9Sstevel@tonic-gate #define	D_PKTBAD	0x0400		/* Malformed packet */
987c478bd9Sstevel@tonic-gate #define	D_PKTOUT	0x0800		/* Sent packet */
997c478bd9Sstevel@tonic-gate #define	D_TMP		0x1000		/* RFC3041 mechanism */
100d04ccbb3Scarlsonj #define	D_DHCP		0x2000		/* RFC3315 DHCPv6 (stateful addrs) */
1017c478bd9Sstevel@tonic-gate 
1027c478bd9Sstevel@tonic-gate #define	IF_SEPARATOR		':'
1037c478bd9Sstevel@tonic-gate #define	IPV6_MAX_HOPS		255
1047c478bd9Sstevel@tonic-gate #define	IPV6_MIN_MTU		(1024+256)
1057c478bd9Sstevel@tonic-gate #define	IPV6_ABITS		128
1067c478bd9Sstevel@tonic-gate #define	TMP_TOKEN_BITS		64
1077c478bd9Sstevel@tonic-gate #define	TMP_TOKEN_BYTES		(TMP_TOKEN_BITS / 8)
1087c478bd9Sstevel@tonic-gate #define	MAX_DAD_FAILURES	5
1097c478bd9Sstevel@tonic-gate 
1107c478bd9Sstevel@tonic-gate /* Return a random number from a an range inclusive of the endpoints */
1117c478bd9Sstevel@tonic-gate #define	GET_RANDOM(LOW, HIGH) (random() % ((HIGH) - (LOW) + 1) + (LOW))
1127c478bd9Sstevel@tonic-gate 
1137c478bd9Sstevel@tonic-gate #define	TIMER_INFINITY	0xFFFFFFFFU	/* Never time out */
1147c478bd9Sstevel@tonic-gate #define	PREFIX_INFINITY 0XFFFFFFFFU	/* A "forever" prefix lifetime */
1157c478bd9Sstevel@tonic-gate 
1167c478bd9Sstevel@tonic-gate /*
1177c478bd9Sstevel@tonic-gate  * Used by 2 hour rule for stateless addrconf
1187c478bd9Sstevel@tonic-gate  */
1197c478bd9Sstevel@tonic-gate #define	MIN_VALID_LIFETIME	(2*60*60)		/* In seconds */
1207c478bd9Sstevel@tonic-gate 
1217c478bd9Sstevel@tonic-gate /*
1227c478bd9Sstevel@tonic-gate  * Control how often pi_ReachableTime gets re-randomized
1237c478bd9Sstevel@tonic-gate  */
1247c478bd9Sstevel@tonic-gate #define	MIN_REACH_RANDOM_INTERVAL	(60*1000)	/* 1 minute in ms */
1257c478bd9Sstevel@tonic-gate #define	MAX_REACH_RANDOM_INTERVAL	(60*60*1000)	/* 1 hour in ms */
1267c478bd9Sstevel@tonic-gate 
1277c478bd9Sstevel@tonic-gate /*
1287c478bd9Sstevel@tonic-gate  * Parsing constants
1297c478bd9Sstevel@tonic-gate  */
1307c478bd9Sstevel@tonic-gate #define	MAXLINELEN	4096
1317c478bd9Sstevel@tonic-gate #define	MAXARGSPERLINE	128
1327c478bd9Sstevel@tonic-gate 
1337c478bd9Sstevel@tonic-gate void		timer_schedule(uint_t delay);
134b0f490f4Smh138676 extern void	logmsg(int level, const char *fmt, ...);
135b0f490f4Smh138676 extern void	logperror(const char *str);
136b0f490f4Smh138676 extern void	logperror_pi(const struct phyint *pi, const char *str);
137b0f490f4Smh138676 extern void	logperror_pr(const struct prefix *pr, const char *str);
1387c478bd9Sstevel@tonic-gate extern int	parse_config(char *config_file, boolean_t file_required);
1397c478bd9Sstevel@tonic-gate 
1407c478bd9Sstevel@tonic-gate extern int	poll_add(int fd);
1417c478bd9Sstevel@tonic-gate extern int	poll_remove(int fd);
1427c478bd9Sstevel@tonic-gate 
1437c478bd9Sstevel@tonic-gate extern char	*fmt_lla(char *llabuf, int bufsize, uchar_t *lla, int llalen);
1447c478bd9Sstevel@tonic-gate 
1457c478bd9Sstevel@tonic-gate extern int	do_dad(char *ifname, struct sockaddr_in6 *testaddr);
1467c478bd9Sstevel@tonic-gate 
1477c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1487c478bd9Sstevel@tonic-gate }
1497c478bd9Sstevel@tonic-gate #endif
1507c478bd9Sstevel@tonic-gate 
1517c478bd9Sstevel@tonic-gate #endif	/* _NDPD_DEFS_H */
152