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, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 23 /* 24 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 25 * Use is subject to license terms. 26 */ 27 28 #ifndef _NIS_LOCAL_H 29 #define _NIS_LOCAL_H 30 31 #pragma ident "%Z%%M% %I% %E% SMI" 32 33 #include "../../rpc/rpc_mt.h" 34 #include <rpc/rpc.h> 35 #include <rpcsvc/nis.h> 36 37 #ifdef __cplusplus 38 extern "C" { 39 #endif 40 41 /* 42 * Manifest constants for the NIS+ client library. 43 */ 44 45 #ifdef DEBUG 46 #define ASSERT(cond) \ 47 { \ 48 if (!(cond)) { \ 49 (void) printf("ASSERT ERROR:(%s),file %s,line %d\n", \ 50 /* */#cond, __FILE__, __LINE__); \ 51 abort(); \ 52 } \ 53 } 54 #else 55 #define ASSERT(cond) /* no op */ 56 #endif /* DEBUG */ 57 58 #define MAX_LINKS 16 59 #define NIS_MAXSRCHLEN 2048 60 #define NIS_MAXPATHDEPTH 128 61 #define NIS_MAXPATHLEN 8192 62 #ifndef NIS_MAXREPLICAS 63 #define NIS_MAXREPLICAS 128 64 #endif 65 typedef uchar_t h_mask[NIS_MAXREPLICAS+1]; 66 67 /* clock definitions */ 68 #define MAXCLOCKS 16 69 #define CLOCK_SERVER 0 70 #define CLOCK_DB 1 71 #define CLOCK_CLIENT 2 72 #define CLOCK_CACHE 3 73 #define CLOCK_CACHE_SEARCH 4 74 #define CLOCK_CACHE_FINDDIR 5 75 #define CLOCK_SCRATCH 6 76 77 #ifndef TRUE 78 #define TRUE 1 79 #define FALSE 0 80 #endif 81 82 struct nis_tick_data { 83 uint32_t aticks, 84 dticks, 85 zticks, 86 cticks; 87 }; 88 89 #define UPD_TICKS(t, r) {t.aticks += r->aticks; \ 90 t.dticks += r->dticks; \ 91 t.zticks += r->zticks; \ 92 t.cticks += r->cticks; } 93 #define CLR_TICKS(t) {t.aticks = 0; \ 94 t.dticks = 0; \ 95 t.zticks = 0; \ 96 t.cticks = 0; } 97 #define RET_TICKS(t, r) {r->aticks = t.aticks; \ 98 r->dticks = t.dticks; \ 99 r->zticks = t.zticks; \ 100 r->cticks = t.cticks; } 101 102 /* 103 * Either srv or name must be set. If srv is set, then we bind 104 * to that server, otherwise we bind to name and parent_first 105 * determines whether we should bind to the name itself or to 106 * the parent. 107 */ 108 typedef struct { 109 nis_server *srv; 110 int nsrv; 111 char *name; 112 char *server_name; 113 int parent_first; 114 uint_t flags; 115 struct timeval timeout; 116 nis_error niserror; 117 uint32_t aticks; 118 119 /* private: used internally */ 120 int state; 121 nis_bound_directory *binding; 122 int base; 123 int end; 124 int count; /* end - base + 1 */ 125 int start; /* base <= start < end */ 126 int cur; 127 int bound_to; 128 int refresh_count; 129 } nis_call_state; 130 131 /* 132 * Manifest timeouts 133 */ 134 #define NIS_PING_TIMEOUT 5 /* timeout of ping operations */ 135 #define NIS_DUMP_TIMEOUT 120 /* timeout for dump/dumplog operations */ 136 #define NIS_FINDDIR_TIMEOUT 15 /* timeout for finddirectory operations */ 137 #define NIS_TAG_TIMEOUT 30 /* timeout for statistics operations */ 138 #define NIS_GEN_TIMEOUT 15 /* timeout for general NIS+ operations */ 139 #define NIS_READ_TIMEOUT 5 /* timeout for read NIS+ operations */ 140 #define NIS_HARDSLEEP 5 /* interval to sleep during HARD_LOOKUP */ 141 #define NIS_CBACK_TIMEOUT 180 /* timeout for callback */ 142 143 /* 144 * use for the cached client handles 145 */ 146 #define SRV_IS_FREE 0 147 #define SRV_TO_BE_FREED 1 148 #define SRV_IN_USE 2 149 #define SRV_INVALID 3 150 #define SRV_AUTH_INVALID 4 151 152 #define BAD_SERVER 1 153 #define GOOD_SERVER 0 154 155 #define NIS_SEND_SIZE 2048 156 #define NIS_RECV_SIZE 2048 157 #define NIS_TCP_TIMEOUT 3600 158 #define NIS_UDP_TIMEOUT 120 159 160 /* 161 * Internal functions 162 */ 163 extern nis_result *__nis_core_lookup(ib_request *, uint_t, int, void *, 164 int (*)(nis_name, nis_object *, void *)); 165 extern CLIENT *__nis_get_server(nis_call_state *); 166 extern void __nis_release_server(nis_call_state *, CLIENT *, 167 enum clnt_stat); 168 extern void __nis_bad_auth_server(CLIENT *); 169 170 extern void abort(void); 171 extern void nis_sort_directory_servers(directory_obj *); 172 173 extern nis_error nis_bind_dir(char *, int, nis_bound_directory **, uint_t); 174 extern CLIENT *nis_client_handle(nis_bound_directory *, int, uint_t); 175 extern nis_server *__nis_server_dup(nis_server *, nis_server *); 176 extern void *__inet_get_local_interfaces(void); 177 extern void __inet_free_local_interfaces(void *); 178 extern int __inet_address_is_local(void *, struct in_addr); 179 extern int __inet_address_count(void *); 180 extern int __inet_uaddr_is_local(void *, struct netconfig *, char *); 181 extern char *__inet_get_uaddr(void *, struct netconfig *, int); 182 extern char *__inet_get_networka(void *, int); 183 extern int __inet_address_is_local_af(void *, sa_family_t, void *); 184 extern int __nis_server_is_local(endpoint *, void *); 185 extern endpoint *__get_bound_endpoint(nis_bound_directory *, int); 186 extern endpoint *__endpoint_dup(endpoint *, endpoint *); 187 extern void __endpoint_free(endpoint *); 188 extern void nis_print_binding(nis_bound_directory *); 189 extern char *__nis_get_server_address(struct netconfig *, endpoint *); 190 extern nis_error __nis_path(char *, char *, int *, char ***); 191 extern void __nis_path_free(char **, int); 192 extern int32_t __nis_librand(void); 193 extern int __nis_host_is_server(nis_server *, int); 194 extern int __nis_parse_path(char *, nis_name *, int); 195 extern nis_name * __nis_getnames(nis_name, nis_error *); 196 extern void __nis_print_result(nis_result *); 197 extern void __nis_print_rpc_result(enum clnt_stat); 198 extern void __nis_print_call(CLIENT *, int); 199 extern void __nis_print_fdreq(fd_args *); 200 extern void __nis_print_req(ib_request *); 201 extern void __nis_print_nsreq(ns_request *); 202 extern void __nis_init_call_state(nis_call_state *); 203 extern void __nis_reset_call_state(nis_call_state *); 204 extern nis_error nis_bind_server(nis_server *, int, nis_bound_directory **); 205 extern nis_error nis_call(nis_call_state *, rpcproc_t, 206 xdrproc_t, char *, xdrproc_t, char *); 207 extern nis_name __nis_nextsep_of(char *); 208 extern int __rpc_timeval_to_msec(struct timeval *); 209 extern AUTH *authdes_pk_seccreate(const char *, netobj *, uint_t, 210 const char *, const des_block *, nis_server *); 211 extern void __nis_netconfig2ep(struct netconfig *, endpoint *); 212 extern bool_t __nis_netconfig_matches_ep(struct netconfig *, endpoint *); 213 extern nis_server *__nis_init_dump_callback(CLIENT *, int (*)(), void *); 214 extern int __nis_run_dump_callback(netobj *, rpcproc_t, 215 struct timeval *, CLIENT *); 216 217 /* 218 * Internal variables 219 */ 220 extern mutex_t __nis_callback_lock; 221 222 #ifdef __cplusplus 223 } 224 #endif 225 226 #endif /* _NIS_LOCAL_H */ 227