10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 52428Smh138676 * Common Development and Distribution License (the "License"). 62428Smh138676 * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*12016SGirish.Moodalbail@Sun.COM * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #ifndef _NDPD_DEFS_H 270Sstevel@tonic-gate #define _NDPD_DEFS_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate #include <stdio.h> 300Sstevel@tonic-gate #include <stdlib.h> 310Sstevel@tonic-gate #include <strings.h> 320Sstevel@tonic-gate #include <errno.h> 330Sstevel@tonic-gate #include <sys/types.h> 340Sstevel@tonic-gate #include <fcntl.h> 350Sstevel@tonic-gate #include <signal.h> 360Sstevel@tonic-gate #include <poll.h> 370Sstevel@tonic-gate #include <unistd.h> 380Sstevel@tonic-gate #include <time.h> 390Sstevel@tonic-gate #include <stdarg.h> 400Sstevel@tonic-gate #include <syslog.h> 410Sstevel@tonic-gate 420Sstevel@tonic-gate #include <sys/param.h> 430Sstevel@tonic-gate #include <sys/socket.h> 440Sstevel@tonic-gate #include <arpa/inet.h> 450Sstevel@tonic-gate #include <netdb.h> 460Sstevel@tonic-gate 470Sstevel@tonic-gate #include <sys/ioctl.h> 480Sstevel@tonic-gate #include <sys/sockio.h> 490Sstevel@tonic-gate #include <net/if.h> 500Sstevel@tonic-gate #include <sys/stropts.h> 510Sstevel@tonic-gate 520Sstevel@tonic-gate #include <string.h> 530Sstevel@tonic-gate #include <ctype.h> 540Sstevel@tonic-gate 550Sstevel@tonic-gate #include <netinet/in_systm.h> 560Sstevel@tonic-gate #include <netinet/in.h> 570Sstevel@tonic-gate #include <netinet/ip.h> 580Sstevel@tonic-gate #include <netinet/ip_icmp.h> 590Sstevel@tonic-gate #include <netinet/if_ether.h> 600Sstevel@tonic-gate #include <netinet/ip6.h> 610Sstevel@tonic-gate #include <netinet/icmp6.h> 620Sstevel@tonic-gate #include <net/route.h> 63*12016SGirish.Moodalbail@Sun.COM #include <libipadm.h> 64*12016SGirish.Moodalbail@Sun.COM #include <ipadm_ndpd.h> 650Sstevel@tonic-gate 662428Smh138676 #include "tables.h" 672428Smh138676 680Sstevel@tonic-gate #ifdef __cplusplus 690Sstevel@tonic-gate extern "C" { 700Sstevel@tonic-gate #endif 710Sstevel@tonic-gate 722493Sdd193516 #define CURHOP_UNSPECIFIED 0 730Sstevel@tonic-gate #define PATH_NDPD_CONF "/etc/inet/ndpd.conf" 740Sstevel@tonic-gate #define PATH_PID "/var/run/in.ndpd.pid" 750Sstevel@tonic-gate 760Sstevel@tonic-gate extern int debug, no_loopback; 770Sstevel@tonic-gate 780Sstevel@tonic-gate extern struct in6_addr all_nodes_mcast; 790Sstevel@tonic-gate extern struct in6_addr all_routers_mcast; 800Sstevel@tonic-gate 810Sstevel@tonic-gate extern int rtsock; 820Sstevel@tonic-gate extern struct rt_msghdr *rt_msg; 830Sstevel@tonic-gate extern struct sockaddr_in6 *rta_gateway; 840Sstevel@tonic-gate extern struct sockaddr_dl *rta_ifp; 850Sstevel@tonic-gate 860Sstevel@tonic-gate /* Debug flags */ 870Sstevel@tonic-gate #define D_ALL 0xffff 880Sstevel@tonic-gate #define D_DEFAULTS 0x0001 /* Default values in config file */ 890Sstevel@tonic-gate #define D_CONFIG 0x0002 /* Config file */ 900Sstevel@tonic-gate #define D_PHYINT 0x0004 /* phyint table */ 910Sstevel@tonic-gate #define D_PREFIX 0x0008 /* prefix table */ 920Sstevel@tonic-gate #define D_ROUTER 0x0010 /* router table */ 930Sstevel@tonic-gate #define D_STATE 0x0020 /* RS/RA state machine */ 940Sstevel@tonic-gate #define D_IFSCAN 0x0040 /* Scan of kernel interfaces */ 950Sstevel@tonic-gate #define D_TIMER 0x0080 /* Timer mechanism */ 960Sstevel@tonic-gate #define D_PARSE 0x0100 /* config file parser */ 970Sstevel@tonic-gate #define D_PKTIN 0x0200 /* Received packet */ 980Sstevel@tonic-gate #define D_PKTBAD 0x0400 /* Malformed packet */ 990Sstevel@tonic-gate #define D_PKTOUT 0x0800 /* Sent packet */ 1000Sstevel@tonic-gate #define D_TMP 0x1000 /* RFC3041 mechanism */ 1013431Scarlsonj #define D_DHCP 0x2000 /* RFC3315 DHCPv6 (stateful addrs) */ 1020Sstevel@tonic-gate 1030Sstevel@tonic-gate #define IF_SEPARATOR ':' 1040Sstevel@tonic-gate #define IPV6_MAX_HOPS 255 1050Sstevel@tonic-gate #define IPV6_MIN_MTU (1024+256) 1060Sstevel@tonic-gate #define IPV6_ABITS 128 1070Sstevel@tonic-gate #define TMP_TOKEN_BITS 64 1080Sstevel@tonic-gate #define TMP_TOKEN_BYTES (TMP_TOKEN_BITS / 8) 1090Sstevel@tonic-gate #define MAX_DAD_FAILURES 5 1100Sstevel@tonic-gate 1110Sstevel@tonic-gate /* Return a random number from a an range inclusive of the endpoints */ 1120Sstevel@tonic-gate #define GET_RANDOM(LOW, HIGH) (random() % ((HIGH) - (LOW) + 1) + (LOW)) 1130Sstevel@tonic-gate 1140Sstevel@tonic-gate #define TIMER_INFINITY 0xFFFFFFFFU /* Never time out */ 1150Sstevel@tonic-gate #define PREFIX_INFINITY 0XFFFFFFFFU /* A "forever" prefix lifetime */ 1160Sstevel@tonic-gate 1170Sstevel@tonic-gate /* 1180Sstevel@tonic-gate * Used by 2 hour rule for stateless addrconf 1190Sstevel@tonic-gate */ 1200Sstevel@tonic-gate #define MIN_VALID_LIFETIME (2*60*60) /* In seconds */ 1210Sstevel@tonic-gate 1220Sstevel@tonic-gate /* 1230Sstevel@tonic-gate * Control how often pi_ReachableTime gets re-randomized 1240Sstevel@tonic-gate */ 1250Sstevel@tonic-gate #define MIN_REACH_RANDOM_INTERVAL (60*1000) /* 1 minute in ms */ 1260Sstevel@tonic-gate #define MAX_REACH_RANDOM_INTERVAL (60*60*1000) /* 1 hour in ms */ 1270Sstevel@tonic-gate 1280Sstevel@tonic-gate /* 1290Sstevel@tonic-gate * Parsing constants 1300Sstevel@tonic-gate */ 1310Sstevel@tonic-gate #define MAXLINELEN 4096 1320Sstevel@tonic-gate #define MAXARGSPERLINE 128 1330Sstevel@tonic-gate 1340Sstevel@tonic-gate void timer_schedule(uint_t delay); 1352428Smh138676 extern void logmsg(int level, const char *fmt, ...); 1362428Smh138676 extern void logperror(const char *str); 1372428Smh138676 extern void logperror_pi(const struct phyint *pi, const char *str); 1382428Smh138676 extern void logperror_pr(const struct prefix *pr, const char *str); 1390Sstevel@tonic-gate extern int parse_config(char *config_file, boolean_t file_required); 1400Sstevel@tonic-gate 1410Sstevel@tonic-gate extern int poll_add(int fd); 1420Sstevel@tonic-gate extern int poll_remove(int fd); 1430Sstevel@tonic-gate 1440Sstevel@tonic-gate extern char *fmt_lla(char *llabuf, int bufsize, uchar_t *lla, int llalen); 1450Sstevel@tonic-gate 1460Sstevel@tonic-gate extern int do_dad(char *ifname, struct sockaddr_in6 *testaddr); 1470Sstevel@tonic-gate 1480Sstevel@tonic-gate #ifdef __cplusplus 1490Sstevel@tonic-gate } 1500Sstevel@tonic-gate #endif 1510Sstevel@tonic-gate 1520Sstevel@tonic-gate #endif /* _NDPD_DEFS_H */ 153