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 2006 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 PATH_NDPD_CONF "/etc/inet/ndpd.conf" 73 #define PATH_PID "/var/run/in.ndpd.pid" 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_DAD 0x2000 /* Duplciate Address Detection */ 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