1 /* 2 * Copyright 1995-2002 Sun Microsystems, Inc. All rights reserved. 3 * Use is subject to license terms. 4 */ 5 6 #pragma ident "%Z%%M% %I% %E% SMI" 7 8 /* 9 * Copyright (c) 1995 Regents of the University of Michigan. 10 * All rights reserved. 11 * 12 * ldap-int.h - defines & prototypes internal to the LDAP library 13 */ 14 15 #include <stdlib.h> /* rri */ 16 #include <pthread.h> /* rri */ 17 #include <netinet/in.h> 18 19 #define LDAP_URL_PREFIX "ldap://" 20 #define LDAP_URL_PREFIX_LEN 7 21 #define LDAP_URL_URLCOLON "URL:" 22 #define LDAP_URL_URLCOLON_LEN 4 23 24 #ifdef LDAP_REFERRALS 25 #define LDAP_REF_STR "Referral:\n" 26 #define LDAP_REF_STR_LEN 10 27 #define LDAP_LDAP_REF_STR LDAP_URL_PREFIX 28 #define LDAP_LDAP_REF_STR_LEN LDAP_URL_PREFIX_LEN 29 #ifdef LDAP_DNS 30 #define LDAP_DX_REF_STR "dx://" 31 #define LDAP_DX_REF_STR_LEN 5 32 #endif /* LDAP_DNS */ 33 #endif /* LDAP_REFERRALS */ 34 35 36 /* 37 * in cache.c 38 */ 39 #ifdef NEEDPROTOS 40 void add_request_to_cache( LDAP *ld, unsigned int msgtype, 41 BerElement *request ); 42 void add_result_to_cache( LDAP *ld, LDAPMessage *result ); 43 int check_cache( LDAP *ld, unsigned int msgtype, BerElement *request ); 44 #else /* NEEDPROTOS */ 45 void add_request_to_cache(); 46 void add_result_to_cache(); 47 int check_cache(); 48 #endif /* NEEDPROTOS */ 49 50 51 #ifdef KERBEROS 52 /* 53 * in kerberos.c 54 */ 55 #ifdef NEEDPROTOS 56 char *get_kerberosv4_credentials( LDAP *ld, char *who, char *service, 57 int *len ); 58 #else /* NEEDPROTOS */ 59 char *get_kerberosv4_credentials(); 60 #endif /* NEEDPROTOS */ 61 62 #endif /* KERBEROS */ 63 64 /* 65 * in notif.c 66 */ 67 int ldap_insert_notif(LDAP *ld, LDAPMessage *notif); 68 int ldap_add_notif(LDAP *ld, LDAPMessage *notif); 69 70 71 /* 72 * in open.c 73 */ 74 int ldap_thr_index(); /* rri */ 75 #ifdef NEEDPROTOS 76 int open_default_ldap_connection(LDAP *ld); 77 int open_ldap_connection( LDAP *ld, Sockbuf *sb, char *host, int defport, 78 char **krbinstancep, int async ); 79 #else /* NEEDPROTOS */ 80 int open_default_ldap_connection(); 81 int open_ldap_connection(); 82 #endif /* NEEDPROTOS */ 83 84 /* 85 * in options.c 86 */ 87 88 int ldap_get_option (LDAP *ld, int option, void *outvalue); 89 90 /* 91 * in os-ip.c 92 */ 93 void close_ldap_connection( Sockbuf *sb ); /* rri */ 94 #ifdef NEEDPROTOS 95 int connect_to_host(Sockbuf *sb, char *host, in_addr_t address, int port, 96 int async, int bindTimeout); 97 void close_connection( Sockbuf *sb ); 98 #else /* NEEDPROTOS */ 99 int connect_to_host(); 100 void close_connection(); 101 #endif /* NEEDPROTOS */ 102 103 #ifdef KERBEROS 104 #ifdef NEEDPROTOS 105 char *host_connected_to( Sockbuf *sb ); 106 #else /* NEEDPROTOS */ 107 char *host_connected_to(); 108 #endif /* NEEDPROTOS */ 109 #endif /* KERBEROS */ 110 111 #ifdef LDAP_REFERRALS 112 #ifdef NEEDPROTOS 113 int do_ldap_select( LDAP *ld, struct timeval *timeout ); 114 void *new_select_info( void ); 115 void free_select_info( void *sip ); 116 void mark_select_write( LDAP *ld, Sockbuf *sb ); 117 void mark_select_read( LDAP *ld, Sockbuf *sb ); 118 void mark_select_clear( LDAP *ld, Sockbuf *sb ); 119 long is_read_ready( LDAP *ld, Sockbuf *sb ); 120 long is_write_ready( LDAP *ld, Sockbuf *sb ); 121 #else /* NEEDPROTOS */ 122 int do_ldap_select(); 123 void *new_select_info(); 124 void free_select_info(); 125 void mark_select_write(); 126 void mark_select_read(); 127 void mark_select_clear(); 128 long is_read_ready(); 129 long is_write_ready(); 130 #endif /* NEEDPROTOS */ 131 #endif /* LDAP_REFERRALS */ 132 133 /* 134 * in regex.c (rri) 135 */ 136 int re_exec( char *lp ); 137 138 /* 139 * in request.c 140 */ 141 #ifdef NEEDPROTOS 142 int send_initial_request( LDAP *ld, unsigned int msgtype, 143 char *dn, BerElement *ber ); 144 BerElement *alloc_ber_with_options( LDAP *ld ); 145 void set_ber_options( LDAP *ld, BerElement *ber ); 146 #else /* NEEDPROTOS */ 147 int send_initial_request(); 148 BerElement *alloc_ber_with_options(); 149 void set_ber_options(); 150 #endif /* NEEDPROTOS */ 151 152 #if defined( LDAP_REFERRALS ) || defined( LDAP_DNS ) 153 #ifdef NEEDPROTOS 154 int send_server_request( LDAP *ld, BerElement *ber, int msgid, 155 LDAPRequest *parentreq, LDAPServer *srvlist, LDAPConn *lc, 156 int bind ); 157 LDAPConn *new_connection( LDAP *ld, LDAPServer **srvlistp, int use_ldsb, 158 int connect, int bind ); 159 LDAPRequest *find_request_by_msgid( LDAP *ld, int msgid ); 160 void free_request( LDAP *ld, LDAPRequest *lr ); 161 void free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind ); 162 void dump_connection( LDAP *ld, LDAPConn *lconns, int all ); 163 void dump_requests_and_responses( LDAP *ld ); 164 #else /* NEEDPROTOS */ 165 int send_server_request(); 166 LDAPConn *new_connection(); 167 LDAPRequest *find_request_by_msgid(); 168 void free_request(); 169 void free_connection(); 170 void dump_connection(); 171 void dump_requests_and_responses(); 172 #endif /* NEEDPROTOS */ 173 #endif /* LDAP_REFERRALS || LDAP_DNS */ 174 175 #ifdef LDAP_REFERRALS 176 #ifdef NEEDPROTOS 177 int chase_referrals( LDAP *ld, LDAPRequest *lr, char **refs, int *count, int samerequest ); 178 char ** ldap_errormsg2referrals(char *errmsg); 179 char *ldap_referral2error_msg(char ** refs); 180 int append_referral( LDAP *ld, char **referralsp, char *s ); 181 #else /* NEEDPROTOS */ 182 int chase_referrals(); 183 char ** ldap_errormsg2referrals(); 184 char *ldap_referral2error_msg(); 185 int append_referral(); 186 #endif /* NEEDPROTOS */ 187 #endif /* LDAP_REFERRALS */ 188 189 void nsldapi_connection_lost_nolock( LDAP *ld, Sockbuf *sb ); 190 191 /* 192 * in search.c 193 */ 194 #ifdef NEEDPROTOS 195 BerElement *ldap_build_search_req( LDAP *ld, char *base, int scope, 196 char *filter, char **attrs, int attrsonly, LDAPControl ** serverctrls, 197 struct timeval *timeoutp, int sizelimit ); 198 #else /* NEEDPROTOS */ 199 BerElement *ldap_build_search_req(); 200 #endif /* NEEDPROTOS */ 201 202 static int put_extensible_filter( BerElement *ber, char *type, char *val ); 203 204 /* 205 * in unbind.c 206 */ 207 #ifdef NEEDPROTOS 208 int ldap_ld_free( LDAP *ld, int close ); 209 int send_unbind( LDAP *ld, Sockbuf *sb ); 210 #else /* NEEDPROTOS */ 211 int ldap_ld_free(); 212 int send_unbind(); 213 #endif /* NEEDPROTOS */ 214 215 216 #ifdef LDAP_DNS 217 /* 218 * in getdxbyname.c 219 */ 220 #ifdef NEEDPROTOS 221 char **getdxbyname( char *domain ); 222 #else /* NEEDPROTOS */ 223 char **getdxbyname(); 224 #endif /* NEEDPROTOS */ 225 #endif /* LDAP_DNS */ 226 227 /* 228 * abandon.c 229 */ 230 #ifdef NEEDPROTOS 231 BerElement * ldap_build_abandon_req( LDAP *ld, int msgid, LDAPControl ** serverctrls); 232 #else 233 BerElement * ldap_build_abandon_req(); 234 #endif 235 236 /* add.c */ 237 #ifdef NEEDPROTOS 238 BerElement * ldap_build_add_req(LDAP *ld, char *dn, LDAPMod **attrs, LDAPControl ** serverctrls); 239 #else 240 BerElement * ldap_build_add_req(); 241 #endif 242 243 /* 244 * compare.c 245 */ 246 #ifdef NEEDPROTOS 247 BerElement * ldap_build_compare_req(LDAP *ld, char *dn, char *attr, struct berval *bvalue, LDAPControl **serverctrls); 248 #else 249 BerElement * ldap_build_compare_req(); 250 #endif 251 252 /* 253 * delete.c 254 */ 255 #ifdef NEEDPROTOS 256 BerElement * ldap_build_delete_req(LDAP *ld, char *dn, LDAPControl **serverctrls); 257 #else 258 BerElement * ldap_build_delete_req(); 259 #endif 260 261 /* 262 * extop.c 263 */ 264 #ifdef NEEDPROTOS 265 BerElement * ldap_build_extended_operation_req(LDAP *ld, char *exoid, struct berval *exdata, LDAPControl ** serverctrls); 266 #else 267 BerElement * ldap_build_extended_operation_req(); 268 #endif 269 270 /* 271 * modify.c 272 */ 273 #ifdef NEEDPROTOS 274 BerElement * ldap_build_modify_req(LDAP *ld, char *dn, LDAPMod ** mods, LDAPControl **serverctrls); 275 #else 276 BerElement * ldap_build_modify_req(); 277 #endif 278 279 /* 280 * rename.c 281 */ 282 #ifdef NEEDPROTOS 283 BerElement * ldap_build_rename_req ( LDAP *ld, char *dn, char *newrdn, char *newparent, int deleteoldrdn, LDAPControl **serverctrls); 284 #else 285 BerElement * ldap_build_rename_req (); 286 #endif 287 288 /* 289 * saslbind.c 290 */ 291 #ifdef NEEDPROTOS 292 BerElement * ldap_build_sasl_bind_req( LDAP *ld, char *dn, char *mechanism, struct berval *creds, LDAPControl ** serverctrls); 293 #else 294 BerElement * ldap_build_sasl_bind_req(); 295 #endif 296 /* 297 * sbind.c 298 */ 299 #ifdef NEEDPROTOS 300 BerElement * ldap_build_simple_bind_req(LDAP *ld, char *dn, char *passwd, LDAPControl **serverctrls); 301 #else 302 BerElement * ldap_build_simple_bind_req(); 303 #endif 304 305 /* 306 * utils.c 307 */ 308 309 #ifdef NEEDPROTOS 310 void free_strarray(char **sap); 311 #else 312 void free_strarray(); 313 #endif 314 315 /* 316 * Controls.c 317 */ 318 #ifdef NEEDPROTOS 319 LDAPControl * ldap_control_dup(LDAPControl *ctrl); 320 LDAPControl ** ldap_controls_dup(LDAPControl ** ctrls); 321 int ldap_controls_code (BerElement *ber, LDAPControl **ctrls); 322 LDAPControl ** ldap_controls_decode(BerElement *ber, int *errcode); 323 int ldap_build_control(char *oid, BerElement *ber, int freeber, 324 char iscritical, LDAPControl **ctrlp); 325 #else 326 LDAPControl * ldap_control_dup(); 327 LDAPControl ** ldap_controls_dup(); 328 int ldap_controls_code (); 329 LDAPControl ** ldap_controls_decode(); 330 int ldap_build_control(); 331 #endif 332 333 /* 334 * ber/io.c 335 */ 336 #ifdef NEEDPROTOS 337 int ber_flush(Sockbuf *sb, BerElement *ber, int freeit); 338 unsigned int ber_get_next(Sockbuf *sb, unsigned int *len, BerElement *ber); 339 #else 340 int ber_flush(); 341 unsigned int ber_get_next(); 342 #endif 343 344