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 _NS_CACHE_DOOR_H 27 #define _NS_CACHE_DOOR_H 28 29 #pragma ident "%Z%%M% %I% %E% SMI" 30 31 /* 32 * Definitions for client side of doors-based ldap caching 33 */ 34 35 #ifdef __cplusplus 36 extern "C" { 37 #endif 38 39 #include <netdb.h> 40 #include <netinet/in.h> 41 #include <arpa/inet.h> 42 #include <sys/socket.h> 43 #include <grp.h> 44 #include <pwd.h> 45 46 47 /* 48 * statistics & control structure 49 */ 50 51 typedef struct ldap_stat { 52 int ldap_numbercalls; /* number of times called */ 53 int ldap_ttl; /* time to live for positive entries */ 54 } ldap_stat_t; 55 56 57 /* 58 * Structure used to transfer arrays of strings. 59 * Buffer format: 60 * count 61 * array of offsets from start of buffer 62 * array of characters of strings 63 * charp = buf + ldap_offsets[n]; 64 */ 65 66 typedef struct ldap_strlist { 67 int ldap_count; /* number of strings */ 68 int ldap_offsets[1]; /* array of offsets */ 69 } ldap_strlist_t; 70 71 /* 72 * structure returned by server for all calls 73 */ 74 75 #define BUFFERSIZE 8192 76 #define OFFSET 36 77 78 typedef struct { 79 int ldap_bufferbytesused; 80 int ldap_return_code; 81 int ldap_errno; 82 83 union { 84 char config[BUFFERSIZE - OFFSET]; /* V1 Config */ 85 ldap_stat_t stats; 86 char buff[4]; 87 char ber[4]; /* BER/DER encoded packet */ 88 ldap_strlist_t strlist; 89 } ldap_u; 90 91 } ldap_return_t; 92 93 /* 94 * calls look like this 95 */ 96 97 typedef struct { 98 int ldap_callnumber; 99 union { 100 uid_t uid; 101 gid_t gid; 102 char domainname[sizeof (int)]; /* size is indeterminate */ 103 struct { 104 int a_type; 105 int a_length; 106 char a_data[sizeof (int)]; 107 } addr; 108 char servername[sizeof (int)]; /* Format: server:port */ 109 ldap_strlist_t strlist; 110 } ldap_u; 111 } ldap_call_t; 112 /* 113 * how the client views the call process 114 */ 115 116 typedef union { 117 ldap_call_t ldap_call; 118 ldap_return_t ldap_ret; 119 char ldap_buff[sizeof (int)]; 120 } ldap_data_t; 121 122 /* Version 1 Cache Manager calls */ 123 /* Cache manager ping */ 124 #define NULLCALL 0 125 /* NativeLDAP I Get Config */ 126 #define GETLDAPCONFIG 1 127 #define GETLDAPCONFIGV1 1 128 129 /* 130 * administrative calls 131 */ 132 133 #define KILLSERVER 7 134 #define GETADMIN 8 135 #define SETADMIN 9 136 137 /* 138 * debug levels 139 */ 140 141 #define DBG_OFF 0 142 #define DBG_CANT_FIND 1 143 #define DBG_NETLOOKUPS 2 144 #define DBG_SERVER_LIST_REFRESH 3 /* debug server list refresh */ 145 #define DBG_PROFILE_REFRESH 4 /* debug profile TTL/refresh */ 146 #define DBG_ALL 6 147 148 /* Version 2 Cache Manager calls */ 149 /* NativeLDAP II Get Server and RootDSE Info */ 150 #define GETLDAPSERVER 21 151 /* NativeLDAP II Get cached data */ 152 #define GETCACHE 22 153 /* NativeLDAP II Set cached data */ 154 #define SETCACHE 23 155 /* NativeLDAP II get cache data statistics */ 156 #define GETCACHESTAT 24 157 158 /* 159 * GETLDAPSERVER request flags 160 */ 161 162 #define NS_CACHE_NEW "0" 163 #define NS_CACHE_NORESP "1" 164 #define NS_CACHE_NEXT "2" 165 #define NS_CACHE_WRITE "3" 166 #define NS_CACHE_ADDR_HOSTNAME "H" 167 #define NS_CACHE_ADDR_IP "I" 168 169 /* 170 * GETCACHE/SETCACHE data flags 171 */ 172 #define NS_CACHE_DN2DOMAIN "DM" 173 174 /* 175 * Max size name we allow to be passed to avoid 176 * buffer overflow problems 177 */ 178 #define LDAPMAXNAMELEN 255 179 180 /* 181 * defines for client-server interaction 182 */ 183 184 #define LDAP_CACHE_DOOR_VERSION 1 185 #define LDAP_CACHE_DOOR "/var/run/ldap_cache_door" 186 #define LDAP_CACHE_DOOR_COOKIE ((void*)(0xdeadbeef^LDAP_CACHE_DOOR_VERSION)) 187 #define UPDATE_DOOR_COOKIE ((void*)(0xdeadcafe) 188 189 #define SUCCESS 0 190 #define NOTFOUND -1 191 #define CREDERROR -2 192 #define SERVERERROR -3 193 #define NOSERVER -4 194 195 int 196 __ns_ldap_trydoorcall(ldap_data_t **dptr, int *ndata, int *adata); 197 198 #ifdef __cplusplus 199 } 200 #endif 201 202 203 #endif /* _NS_CACHE_DOOR_H */ 204