1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * Copyright 2001-2003 Sun Microsystems, Inc. All rights reserved. 3*0Sstevel@tonic-gate * Use is subject to license terms. 4*0Sstevel@tonic-gate */ 5*0Sstevel@tonic-gate 6*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 7*0Sstevel@tonic-gate 8*0Sstevel@tonic-gate #ifndef _SOLARISINT_H 9*0Sstevel@tonic-gate #define _SOLARISINT_H 10*0Sstevel@tonic-gate 11*0Sstevel@tonic-gate #ifdef __cplusplus 12*0Sstevel@tonic-gate extern "C" { 13*0Sstevel@tonic-gate #endif 14*0Sstevel@tonic-gate 15*0Sstevel@tonic-gate #include <stdio.h> 16*0Sstevel@tonic-gate #include <ctype.h> 17*0Sstevel@tonic-gate #include <stdarg.h> 18*0Sstevel@tonic-gate #include <stdlib.h> 19*0Sstevel@tonic-gate 20*0Sstevel@tonic-gate #include "ldap.h" 21*0Sstevel@tonic-gate 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * These were moved from lber.h. This should have been ifdef'd with 24*0Sstevel@tonic-gate * _SOLARIS_SDK but since we do not want to expose these in lber.h its 25*0Sstevel@tonic-gate * not possible to ifndef it there. 26*0Sstevel@tonic-gate */ 27*0Sstevel@tonic-gate 28*0Sstevel@tonic-gate /* BerElement set/get options */ 29*0Sstevel@tonic-gate #define LBER_OPT_REMAINING_BYTES 0x01 30*0Sstevel@tonic-gate #define LBER_OPT_TOTAL_BYTES 0x02 31*0Sstevel@tonic-gate #define LBER_OPT_USE_DER 0x04 32*0Sstevel@tonic-gate #define LBER_OPT_TRANSLATE_STRINGS 0x08 33*0Sstevel@tonic-gate #define LBER_OPT_BYTES_TO_WRITE 0x10 34*0Sstevel@tonic-gate #define LBER_OPT_MEMALLOC_FN_PTRS 0x20 35*0Sstevel@tonic-gate #define LBER_OPT_DEBUG_LEVEL 0x40 36*0Sstevel@tonic-gate /* 37*0Sstevel@tonic-gate * LBER_USE_DER is defined for compatibility with the C LDAP API RFC. 38*0Sstevel@tonic-gate * In our implementation, we recognize it (instead of the numerically 39*0Sstevel@tonic-gate * identical LBER_OPT_REMAINING_BYTES) in calls to ber_alloc_t() and 40*0Sstevel@tonic-gate * ber_init_w_nullchar() only. Callers of ber_set_option() or 41*0Sstevel@tonic-gate * ber_get_option() must use LBER_OPT_USE_DER instead. Sorry! 42*0Sstevel@tonic-gate */ 43*0Sstevel@tonic-gate #define LBER_USE_DER 0x01 44*0Sstevel@tonic-gate 45*0Sstevel@tonic-gate /* Sockbuf set/get options */ 46*0Sstevel@tonic-gate #define LBER_SOCKBUF_OPT_TO_FILE 0x001 47*0Sstevel@tonic-gate #define LBER_SOCKBUF_OPT_TO_FILE_ONLY 0x002 48*0Sstevel@tonic-gate #define LBER_SOCKBUF_OPT_MAX_INCOMING_SIZE 0x004 49*0Sstevel@tonic-gate #define LBER_SOCKBUF_OPT_NO_READ_AHEAD 0x008 50*0Sstevel@tonic-gate #define LBER_SOCKBUF_OPT_DESC 0x010 51*0Sstevel@tonic-gate #define LBER_SOCKBUF_OPT_COPYDESC 0x020 52*0Sstevel@tonic-gate #define LBER_SOCKBUF_OPT_READ_FN 0x040 53*0Sstevel@tonic-gate #define LBER_SOCKBUF_OPT_WRITE_FN 0x080 54*0Sstevel@tonic-gate #define LBER_SOCKBUF_OPT_EXT_IO_FNS 0x100 55*0Sstevel@tonic-gate 56*0Sstevel@tonic-gate #ifndef _SOLARIS_SDK 57*0Sstevel@tonic-gate /* 58*0Sstevel@tonic-gate * The following is not used by solaris. Just kept to stay in sync with 59*0Sstevel@tonic-gate * iplanet and also a place holder (0x200) 60*0Sstevel@tonic-gate */ 61*0Sstevel@tonic-gate #define LBER_SOCKBUF_OPT_VALID_TAG 0x200 62*0Sstevel@tonic-gate #endif /* !_SOLARIS_SDK */ 63*0Sstevel@tonic-gate 64*0Sstevel@tonic-gate /* 65*0Sstevel@tonic-gate * Socket buffer structure associated to the LDAP connection 66*0Sstevel@tonic-gate */ 67*0Sstevel@tonic-gate #define LDAP_X_OPT_SOCKBUF (LDAP_OPT_PRIVATE_EXTENSION_BASE + 0x0F02) 68*0Sstevel@tonic-gate /* 0x4000 + 0x0F02 = 0x4F02 = 20226 - API extension */ 69*0Sstevel@tonic-gate 70*0Sstevel@tonic-gate 71*0Sstevel@tonic-gate #define LBER_OPT_ON ((void *) 1) 72*0Sstevel@tonic-gate #define LBER_OPT_OFF ((void *) 0) 73*0Sstevel@tonic-gate 74*0Sstevel@tonic-gate /* Used in various functions */ 75*0Sstevel@tonic-gate #define LBER_FUNC_VALUE -1 76*0Sstevel@tonic-gate 77*0Sstevel@tonic-gate struct lextiof_socket_private; /* Defined by the extended I/O */ 78*0Sstevel@tonic-gate /* callback functions */ 79*0Sstevel@tonic-gate struct lextiof_session_private; /* Defined by the extended I/O */ 80*0Sstevel@tonic-gate /* callback functions */ 81*0Sstevel@tonic-gate 82*0Sstevel@tonic-gate /* This is modeled after the PRIOVec that is passed to the NSPR 83*0Sstevel@tonic-gate writev function! The void* is a char* in that struct */ 84*0Sstevel@tonic-gate typedef struct ldap_x_iovec { 85*0Sstevel@tonic-gate char *ldapiov_base; 86*0Sstevel@tonic-gate int ldapiov_len; 87*0Sstevel@tonic-gate } ldap_x_iovec; 88*0Sstevel@tonic-gate 89*0Sstevel@tonic-gate /* 90*0Sstevel@tonic-gate * libldap read and write I/O function callbacks. The rest of the I/O callback 91*0Sstevel@tonic-gate * types are defined in ldap.h 92*0Sstevel@tonic-gate */ 93*0Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_IOF_READ_CALLBACK)( LBER_SOCKET s, 94*0Sstevel@tonic-gate void *buf, int bufsize ); 95*0Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_IOF_WRITE_CALLBACK)( LBER_SOCKET s, 96*0Sstevel@tonic-gate const void *buf, int len ); 97*0Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_X_EXTIOF_READ_CALLBACK)( int s, 98*0Sstevel@tonic-gate void *buf, int bufsize, struct lextiof_socket_private *arg ); 99*0Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_X_EXTIOF_WRITE_CALLBACK)( int s, 100*0Sstevel@tonic-gate const void *buf, int len, struct lextiof_socket_private *arg ); 101*0Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_X_EXTIOF_WRITEV_CALLBACK)(int s, 102*0Sstevel@tonic-gate const ldap_x_iovec iov[], int iovcnt, struct lextiof_socket_private *socketarg); 103*0Sstevel@tonic-gate 104*0Sstevel@tonic-gate 105*0Sstevel@tonic-gate /* 106*0Sstevel@tonic-gate * Structure for use with LBER_SOCKBUF_OPT_EXT_IO_FNS: 107*0Sstevel@tonic-gate */ 108*0Sstevel@tonic-gate struct lber_x_ext_io_fns { 109*0Sstevel@tonic-gate /* lbextiofn_size should always be set to LBER_X_EXTIO_FNS_SIZE */ 110*0Sstevel@tonic-gate int lbextiofn_size; 111*0Sstevel@tonic-gate LDAP_X_EXTIOF_READ_CALLBACK *lbextiofn_read; 112*0Sstevel@tonic-gate LDAP_X_EXTIOF_WRITE_CALLBACK *lbextiofn_write; 113*0Sstevel@tonic-gate struct lextiof_socket_private *lbextiofn_socket_arg; 114*0Sstevel@tonic-gate LDAP_X_EXTIOF_WRITEV_CALLBACK *lbextiofn_writev; 115*0Sstevel@tonic-gate }; 116*0Sstevel@tonic-gate #define LBER_X_EXTIO_FNS_SIZE sizeof(struct lber_x_ext_io_fns) 117*0Sstevel@tonic-gate 118*0Sstevel@tonic-gate /* 119*0Sstevel@tonic-gate * liblber memory allocation callback functions. These are global to all 120*0Sstevel@tonic-gate * Sockbufs and BerElements. Install your own functions by using a call 121*0Sstevel@tonic-gate * like this: ber_set_option( NULL, LBER_OPT_MEMALLOC_FN_PTRS, &memalloc_fns ); 122*0Sstevel@tonic-gate */ 123*0Sstevel@tonic-gate typedef void * (LDAP_C LDAP_CALLBACK LDAP_MALLOC_CALLBACK)( size_t size ); 124*0Sstevel@tonic-gate typedef void * (LDAP_C LDAP_CALLBACK LDAP_CALLOC_CALLBACK)( size_t nelem, 125*0Sstevel@tonic-gate size_t elsize ); 126*0Sstevel@tonic-gate typedef void * (LDAP_C LDAP_CALLBACK LDAP_REALLOC_CALLBACK)( void *ptr, 127*0Sstevel@tonic-gate size_t size ); 128*0Sstevel@tonic-gate typedef void (LDAP_C LDAP_CALLBACK LDAP_FREE_CALLBACK)( void *ptr ); 129*0Sstevel@tonic-gate 130*0Sstevel@tonic-gate struct lber_memalloc_fns { 131*0Sstevel@tonic-gate LDAP_MALLOC_CALLBACK *lbermem_malloc; 132*0Sstevel@tonic-gate LDAP_CALLOC_CALLBACK *lbermem_calloc; 133*0Sstevel@tonic-gate LDAP_REALLOC_CALLBACK *lbermem_realloc; 134*0Sstevel@tonic-gate LDAP_FREE_CALLBACK *lbermem_free; 135*0Sstevel@tonic-gate }; 136*0Sstevel@tonic-gate 137*0Sstevel@tonic-gate /* 138*0Sstevel@tonic-gate * Functions marked as Project Private in PSARC case and moved 139*0Sstevel@tonic-gate * from lber.h 140*0Sstevel@tonic-gate */ 141*0Sstevel@tonic-gate typedef struct sockbuf Sockbuf; 142*0Sstevel@tonic-gate 143*0Sstevel@tonic-gate LDAP_API(void) LDAP_CALL ber_special_free(void* buf, BerElement *ber); 144*0Sstevel@tonic-gate LDAP_API(void*) LDAP_CALL ber_special_alloc(size_t size, BerElement **ppBer); 145*0Sstevel@tonic-gate LDAP_API(ber_uint_t) LDAP_CALL ber_get_next_buffer( void *buffer, 146*0Sstevel@tonic-gate size_t buffer_size, ber_len_t *len, BerElement *ber, 147*0Sstevel@tonic-gate ber_uint_t *Bytes_Scanned ); 148*0Sstevel@tonic-gate LDAP_API(ber_uint_t) LDAP_CALL ber_get_next_buffer_ext( void *buffer, 149*0Sstevel@tonic-gate size_t buffer_size, ber_len_t *len, BerElement *ber, 150*0Sstevel@tonic-gate ber_len_t *Bytes_Scanned, Sockbuf *sb ); 151*0Sstevel@tonic-gate LDAP_API(void) LDAP_CALL ber_init_w_nullchar( BerElement *ber, int options ); 152*0Sstevel@tonic-gate LDAP_API(int) LDAP_CALL ber_set_option( BerElement *ber, int option, 153*0Sstevel@tonic-gate void *value ); 154*0Sstevel@tonic-gate LDAP_API(int) LDAP_CALL ber_get_option( BerElement *ber, int option, 155*0Sstevel@tonic-gate void *value ); 156*0Sstevel@tonic-gate LDAP_API(Sockbuf*) LDAP_CALL ber_sockbuf_alloc( void ); 157*0Sstevel@tonic-gate LDAP_API(void) LDAP_CALL ber_sockbuf_free( Sockbuf* p ); 158*0Sstevel@tonic-gate LDAP_API(int) LDAP_CALL ber_sockbuf_set_option( Sockbuf *sb, int option, 159*0Sstevel@tonic-gate void *value ); 160*0Sstevel@tonic-gate LDAP_API(int) LDAP_CALL ber_sockbuf_get_option( Sockbuf *sb, int option, 161*0Sstevel@tonic-gate void *value ); 162*0Sstevel@tonic-gate LDAP_API(int) LDAP_CALL ber_flush( Sockbuf *sb, BerElement *ber, int freeit ); 163*0Sstevel@tonic-gate LDAP_API(ber_tag_t) LDAP_CALL ber_get_next( Sockbuf *sb, ber_len_t *len, 164*0Sstevel@tonic-gate BerElement *ber ); 165*0Sstevel@tonic-gate 166*0Sstevel@tonic-gate /* 167*0Sstevel@tonic-gate * The following was moved from ldap.h 168*0Sstevel@tonic-gate */ 169*0Sstevel@tonic-gate 170*0Sstevel@tonic-gate /* 171*0Sstevel@tonic-gate * These extended I/O function callbacks echo the BSD socket API but accept 172*0Sstevel@tonic-gate * an extra pointer parameter at the end of their argument list that can 173*0Sstevel@tonic-gate * be used by client applications for their own needs. For some of the calls, 174*0Sstevel@tonic-gate * the pointer is a session argument of type struct lextiof_session_private * 175*0Sstevel@tonic-gate * that is associated with the LDAP session handle (LDAP *). For others, the 176*0Sstevel@tonic-gate * pointer is a socket specific struct lextiof_socket_private * argument that 177*0Sstevel@tonic-gate * is associated with a particular socket (a TCP connection). 178*0Sstevel@tonic-gate * 179*0Sstevel@tonic-gate * The lextiof_session_private and lextiof_socket_private structures are not 180*0Sstevel@tonic-gate * defined by the LDAP C API; users of this extended I/O interface should 181*0Sstevel@tonic-gate * define these themselves. 182*0Sstevel@tonic-gate * 183*0Sstevel@tonic-gate * The combination of the integer socket number (i.e., lpoll_fd, which is 184*0Sstevel@tonic-gate * the value returned by the CONNECT callback) and the application specific 185*0Sstevel@tonic-gate * socket argument (i.e., lpoll_socketarg, which is the value set in *sockargpp 186*0Sstevel@tonic-gate * by the CONNECT callback) must be unique. 187*0Sstevel@tonic-gate * 188*0Sstevel@tonic-gate * The types for the extended READ and WRITE callbacks are actually in lber.h. 189*0Sstevel@tonic-gate * 190*0Sstevel@tonic-gate * The CONNECT callback gets passed both the session argument (sessionarg) 191*0Sstevel@tonic-gate * and a pointer to a socket argument (socketargp) so it has the 192*0Sstevel@tonic-gate * opportunity to set the socket-specific argument. The CONNECT callback 193*0Sstevel@tonic-gate * also takes a timeout parameter whose value can be set by calling 194*0Sstevel@tonic-gate * ldap_set_option( ld, LDAP_X_OPT_..., &val ). The units used for the 195*0Sstevel@tonic-gate * timeout parameter are milliseconds. 196*0Sstevel@tonic-gate * 197*0Sstevel@tonic-gate * A POLL interface is provided instead of a select() one. The timeout is 198*0Sstevel@tonic-gate * in milliseconds. 199*0Sstevel@tonic-gate 200*0Sstevel@tonic-gate * A NEWHANDLE callback function is also provided. It is called right 201*0Sstevel@tonic-gate * after the LDAP session handle is created, e.g., during ldap_init(). 202*0Sstevel@tonic-gate * If the NEWHANDLE callback returns anything other than LDAP_SUCCESS, 203*0Sstevel@tonic-gate * the session handle allocation fails. 204*0Sstevel@tonic-gate * 205*0Sstevel@tonic-gate * A DISPOSEHANDLE callback function is also provided. It is called right 206*0Sstevel@tonic-gate * before the LDAP session handle and its contents are destroyed, e.g., 207*0Sstevel@tonic-gate * during ldap_unbind(). 208*0Sstevel@tonic-gate */ 209*0Sstevel@tonic-gate 210*0Sstevel@tonic-gate /* LDAP poll()-like descriptor: 211*0Sstevel@tonic-gate */ 212*0Sstevel@tonic-gate typedef struct ldap_x_pollfd { /* used by LDAP_X_EXTIOF_POLL_CALLBACK */ 213*0Sstevel@tonic-gate int lpoll_fd; /* integer file descriptor / socket */ 214*0Sstevel@tonic-gate struct lextiof_socket_private 215*0Sstevel@tonic-gate *lpoll_socketarg; 216*0Sstevel@tonic-gate /* pointer socket and for use by */ 217*0Sstevel@tonic-gate /* application */ 218*0Sstevel@tonic-gate short lpoll_events; /* requested event */ 219*0Sstevel@tonic-gate short lpoll_revents; /* returned event */ 220*0Sstevel@tonic-gate } LDAP_X_PollFD; 221*0Sstevel@tonic-gate 222*0Sstevel@tonic-gate /* Event flags for lpoll_events and lpoll_revents: 223*0Sstevel@tonic-gate */ 224*0Sstevel@tonic-gate #define LDAP_X_POLLIN 0x01 /* regular data ready for reading */ 225*0Sstevel@tonic-gate #define LDAP_X_POLLPRI 0x02 /* high priority data available */ 226*0Sstevel@tonic-gate #define LDAP_X_POLLOUT 0x04 /* ready for writing */ 227*0Sstevel@tonic-gate #define LDAP_X_POLLERR 0x08 /* error occurred -- only in lpoll_revents */ 228*0Sstevel@tonic-gate #define LDAP_X_POLLHUP 0x10 /* connection closed -- only in lpoll_revents */ 229*0Sstevel@tonic-gate #define LDAP_X_POLLNVAL 0x20 /* invalid lpoll_fd -- only in lpoll_revents */ 230*0Sstevel@tonic-gate 231*0Sstevel@tonic-gate /* Options passed to LDAP_X_EXTIOF_CONNECT_CALLBACK to modify socket behavior: 232*0Sstevel@tonic-gate */ 233*0Sstevel@tonic-gate #define LDAP_X_EXTIOF_OPT_NONBLOCKING 0x01 /* turn on non-blocking mode */ 234*0Sstevel@tonic-gate #define LDAP_X_EXTIOF_OPT_SECURE 0x02 /* turn on 'secure' mode */ 235*0Sstevel@tonic-gate 236*0Sstevel@tonic-gate /* extended I/O callback function prototypes: 237*0Sstevel@tonic-gate */ 238*0Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_X_EXTIOF_CONNECT_CALLBACK )( 239*0Sstevel@tonic-gate const char *hostlist, int port, /* host byte order */ 240*0Sstevel@tonic-gate int timeout /* milliseconds */, 241*0Sstevel@tonic-gate unsigned long options, /* bitmapped options */ 242*0Sstevel@tonic-gate struct lextiof_session_private *sessionarg, 243*0Sstevel@tonic-gate struct lextiof_socket_private **socketargp 244*0Sstevel@tonic-gate #ifdef _SOLARIS_SDK 245*0Sstevel@tonic-gate , void **datapriv ); 246*0Sstevel@tonic-gate #else 247*0Sstevel@tonic-gate ); 248*0Sstevel@tonic-gate #endif 249*0Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_X_EXTIOF_CLOSE_CALLBACK )( 250*0Sstevel@tonic-gate int s, struct lextiof_socket_private *socketarg ); 251*0Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_X_EXTIOF_POLL_CALLBACK)( 252*0Sstevel@tonic-gate LDAP_X_PollFD fds[], int nfds, int timeout /* milliseconds */, 253*0Sstevel@tonic-gate struct lextiof_session_private *sessionarg ); 254*0Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_X_EXTIOF_NEWHANDLE_CALLBACK)( 255*0Sstevel@tonic-gate LDAP *ld, struct lextiof_session_private *sessionarg ); 256*0Sstevel@tonic-gate typedef void (LDAP_C LDAP_CALLBACK LDAP_X_EXTIOF_DISPOSEHANDLE_CALLBACK)( 257*0Sstevel@tonic-gate LDAP *ld, struct lextiof_session_private *sessionarg ); 258*0Sstevel@tonic-gate 259*0Sstevel@tonic-gate 260*0Sstevel@tonic-gate /* Structure to hold extended I/O function pointers: 261*0Sstevel@tonic-gate */ 262*0Sstevel@tonic-gate struct ldap_x_ext_io_fns { 263*0Sstevel@tonic-gate /* lextiof_size should always be set to LDAP_X_EXTIO_FNS_SIZE */ 264*0Sstevel@tonic-gate int lextiof_size; 265*0Sstevel@tonic-gate LDAP_X_EXTIOF_CONNECT_CALLBACK *lextiof_connect; 266*0Sstevel@tonic-gate LDAP_X_EXTIOF_CLOSE_CALLBACK *lextiof_close; 267*0Sstevel@tonic-gate LDAP_X_EXTIOF_READ_CALLBACK *lextiof_read; 268*0Sstevel@tonic-gate LDAP_X_EXTIOF_WRITE_CALLBACK *lextiof_write; 269*0Sstevel@tonic-gate LDAP_X_EXTIOF_POLL_CALLBACK *lextiof_poll; 270*0Sstevel@tonic-gate LDAP_X_EXTIOF_NEWHANDLE_CALLBACK *lextiof_newhandle; 271*0Sstevel@tonic-gate LDAP_X_EXTIOF_DISPOSEHANDLE_CALLBACK *lextiof_disposehandle; 272*0Sstevel@tonic-gate void *lextiof_session_arg; 273*0Sstevel@tonic-gate LDAP_X_EXTIOF_WRITEV_CALLBACK *lextiof_writev; 274*0Sstevel@tonic-gate }; 275*0Sstevel@tonic-gate #define LDAP_X_EXTIO_FNS_SIZE sizeof(struct ldap_x_ext_io_fns) 276*0Sstevel@tonic-gate 277*0Sstevel@tonic-gate 278*0Sstevel@tonic-gate /* 279*0Sstevel@tonic-gate * Utility functions for parsing space-separated host lists (useful for 280*0Sstevel@tonic-gate * implementing an extended I/O CONNECT callback function). 281*0Sstevel@tonic-gate */ 282*0Sstevel@tonic-gate struct ldap_x_hostlist_status; 283*0Sstevel@tonic-gate LDAP_API(int) LDAP_CALL ldap_x_hostlist_first( const char *hostlist, 284*0Sstevel@tonic-gate int defport, char **hostp, int *portp /* host byte order */, 285*0Sstevel@tonic-gate struct ldap_x_hostlist_status **statusp ); 286*0Sstevel@tonic-gate LDAP_API(int) LDAP_CALL ldap_x_hostlist_next( char **hostp, 287*0Sstevel@tonic-gate int *portp /* host byte order */, struct ldap_x_hostlist_status *status ); 288*0Sstevel@tonic-gate LDAP_API(void) LDAP_CALL ldap_x_hostlist_statusfree( 289*0Sstevel@tonic-gate struct ldap_x_hostlist_status *status ); 290*0Sstevel@tonic-gate 291*0Sstevel@tonic-gate 292*0Sstevel@tonic-gate /* 293*0Sstevel@tonic-gate * I/O callback functions (note that types for the read and write callbacks 294*0Sstevel@tonic-gate * are actually in lber.h): 295*0Sstevel@tonic-gate */ 296*0Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_IOF_SELECT_CALLBACK)( int nfds, 297*0Sstevel@tonic-gate fd_set *readfds, fd_set *writefds, fd_set *errorfds, 298*0Sstevel@tonic-gate struct timeval *timeout ); 299*0Sstevel@tonic-gate typedef LBER_SOCKET (LDAP_C LDAP_CALLBACK LDAP_IOF_SOCKET_CALLBACK)( 300*0Sstevel@tonic-gate int domain, int type, int protocol ); 301*0Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_IOF_IOCTL_CALLBACK)( LBER_SOCKET s, 302*0Sstevel@tonic-gate int option, ... ); 303*0Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_IOF_CONNECT_CALLBACK )( 304*0Sstevel@tonic-gate LBER_SOCKET s, struct sockaddr *name, int namelen ); 305*0Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_IOF_CLOSE_CALLBACK )( 306*0Sstevel@tonic-gate LBER_SOCKET s ); 307*0Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_IOF_SSL_ENABLE_CALLBACK )( 308*0Sstevel@tonic-gate LBER_SOCKET s ); 309*0Sstevel@tonic-gate 310*0Sstevel@tonic-gate 311*0Sstevel@tonic-gate /* 312*0Sstevel@tonic-gate * Structure to hold I/O function pointers: 313*0Sstevel@tonic-gate */ 314*0Sstevel@tonic-gate struct ldap_io_fns { 315*0Sstevel@tonic-gate LDAP_IOF_READ_CALLBACK *liof_read; 316*0Sstevel@tonic-gate LDAP_IOF_WRITE_CALLBACK *liof_write; 317*0Sstevel@tonic-gate LDAP_IOF_SELECT_CALLBACK *liof_select; 318*0Sstevel@tonic-gate LDAP_IOF_SOCKET_CALLBACK *liof_socket; 319*0Sstevel@tonic-gate LDAP_IOF_IOCTL_CALLBACK *liof_ioctl; 320*0Sstevel@tonic-gate LDAP_IOF_CONNECT_CALLBACK *liof_connect; 321*0Sstevel@tonic-gate LDAP_IOF_CLOSE_CALLBACK *liof_close; 322*0Sstevel@tonic-gate LDAP_IOF_SSL_ENABLE_CALLBACK *liof_ssl_enable; 323*0Sstevel@tonic-gate }; 324*0Sstevel@tonic-gate 325*0Sstevel@tonic-gate /********* the functions in the following section are experimental ***********/ 326*0Sstevel@tonic-gate 327*0Sstevel@tonic-gate #define LDAP_OPT_PREFERRED_LANGUAGE 0x14 /* 20 - API extension */ 328*0Sstevel@tonic-gate 329*0Sstevel@tonic-gate /* 330*0Sstevel@tonic-gate * SSL option (an API extension): 331*0Sstevel@tonic-gate */ 332*0Sstevel@tonic-gate #define LDAP_OPT_SSL 0x0A /* 10 - API extension */ 333*0Sstevel@tonic-gate 334*0Sstevel@tonic-gate /* 335*0Sstevel@tonic-gate * Referral hop limit (an API extension): 336*0Sstevel@tonic-gate */ 337*0Sstevel@tonic-gate #define LDAP_OPT_REFERRAL_HOP_LIMIT 0x10 /* 16 - API extension */ 338*0Sstevel@tonic-gate 339*0Sstevel@tonic-gate /* 340*0Sstevel@tonic-gate * DNS resolver callbacks (an API extension --LDAP_API_FEATURE_X_DNS_FUNCTIONS). 341*0Sstevel@tonic-gate * Note that gethostbyaddr() is not currently used. 342*0Sstevel@tonic-gate */ 343*0Sstevel@tonic-gate #define LDAP_OPT_DNS_FN_PTRS 0x60 /* 96 - API extension */ 344*0Sstevel@tonic-gate 345*0Sstevel@tonic-gate typedef struct LDAPHostEnt { 346*0Sstevel@tonic-gate char *ldaphe_name; /* official name of host */ 347*0Sstevel@tonic-gate char **ldaphe_aliases; /* alias list */ 348*0Sstevel@tonic-gate int ldaphe_addrtype; /* host address type */ 349*0Sstevel@tonic-gate int ldaphe_length; /* length of address */ 350*0Sstevel@tonic-gate char **ldaphe_addr_list; /* list of addresses from name server */ 351*0Sstevel@tonic-gate } LDAPHostEnt; 352*0Sstevel@tonic-gate 353*0Sstevel@tonic-gate typedef LDAPHostEnt * (LDAP_C LDAP_CALLBACK LDAP_DNSFN_GETHOSTBYNAME)( 354*0Sstevel@tonic-gate const char *name, LDAPHostEnt *result, char *buffer, 355*0Sstevel@tonic-gate int buflen, int *statusp, void *extradata); 356*0Sstevel@tonic-gate typedef LDAPHostEnt * (LDAP_C LDAP_CALLBACK LDAP_DNSFN_GETHOSTBYADDR)( 357*0Sstevel@tonic-gate const char *addr, int length, int type, LDAPHostEnt *result, 358*0Sstevel@tonic-gate char *buffer, int buflen, int *statusp, void *extradata); 359*0Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_DNSFN_GETPEERNAME)( 360*0Sstevel@tonic-gate LDAP *ld, struct sockaddr *netaddr, char *buffer, int buflen); 361*0Sstevel@tonic-gate 362*0Sstevel@tonic-gate struct ldap_dns_fns { 363*0Sstevel@tonic-gate void *lddnsfn_extradata; 364*0Sstevel@tonic-gate int lddnsfn_bufsize; 365*0Sstevel@tonic-gate LDAP_DNSFN_GETHOSTBYNAME *lddnsfn_gethostbyname; 366*0Sstevel@tonic-gate LDAP_DNSFN_GETHOSTBYADDR *lddnsfn_gethostbyaddr; 367*0Sstevel@tonic-gate LDAP_DNSFN_GETPEERNAME *lddnsfn_getpeername; 368*0Sstevel@tonic-gate }; 369*0Sstevel@tonic-gate 370*0Sstevel@tonic-gate /* 371*0Sstevel@tonic-gate * Generalized cache callback interface: 372*0Sstevel@tonic-gate */ 373*0Sstevel@tonic-gate #define LDAP_OPT_CACHE_FN_PTRS 0x0D /* 13 - API extension */ 374*0Sstevel@tonic-gate #define LDAP_OPT_CACHE_STRATEGY 0x0E /* 14 - API extension */ 375*0Sstevel@tonic-gate #define LDAP_OPT_CACHE_ENABLE 0x0F /* 15 - API extension */ 376*0Sstevel@tonic-gate 377*0Sstevel@tonic-gate /* cache strategies */ 378*0Sstevel@tonic-gate #define LDAP_CACHE_CHECK 0 379*0Sstevel@tonic-gate #define LDAP_CACHE_POPULATE 1 380*0Sstevel@tonic-gate #define LDAP_CACHE_LOCALDB 2 381*0Sstevel@tonic-gate 382*0Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_CF_BIND_CALLBACK)(LDAP *ld, int msgid, 383*0Sstevel@tonic-gate ber_tag_t tag, const char *dn, const struct berval *creds, 384*0Sstevel@tonic-gate int method); 385*0Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_CF_UNBIND_CALLBACK)(LDAP *ld, 386*0Sstevel@tonic-gate int unused0, unsigned long unused1); 387*0Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_CF_SEARCH_CALLBACK)(LDAP *ld, 388*0Sstevel@tonic-gate int msgid, ber_tag_t tag, const char *base, int scope, 389*0Sstevel@tonic-gate const char LDAP_CALLBACK *filter, char **attrs, int attrsonly); 390*0Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_CF_COMPARE_CALLBACK)(LDAP *ld, 391*0Sstevel@tonic-gate int msgid, ber_tag_t tag, const char *dn, const char *attr, 392*0Sstevel@tonic-gate const struct berval *value); 393*0Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_CF_ADD_CALLBACK)(LDAP *ld, 394*0Sstevel@tonic-gate int msgid, ber_tag_t tag, const char *dn, LDAPMod **attrs); 395*0Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_CF_DELETE_CALLBACK)(LDAP *ld, 396*0Sstevel@tonic-gate int msgid, ber_tag_t tag, const char *dn); 397*0Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_CF_MODIFY_CALLBACK)(LDAP *ld, 398*0Sstevel@tonic-gate int msgid, ber_tag_t tag, const char *dn, LDAPMod **mods); 399*0Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_CF_MODRDN_CALLBACK)(LDAP *ld, 400*0Sstevel@tonic-gate int msgid, ber_tag_t tag, const char *dn, const char *newrdn, 401*0Sstevel@tonic-gate int deleteoldrdn); 402*0Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_CF_RESULT_CALLBACK)(LDAP *ld, 403*0Sstevel@tonic-gate int msgid, int all, struct timeval *timeout, LDAPMessage **result); 404*0Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_CF_FLUSH_CALLBACK)(LDAP *ld, 405*0Sstevel@tonic-gate const char *dn, const char *filter); 406*0Sstevel@tonic-gate 407*0Sstevel@tonic-gate struct ldap_cache_fns { 408*0Sstevel@tonic-gate void *lcf_private; 409*0Sstevel@tonic-gate LDAP_CF_BIND_CALLBACK *lcf_bind; 410*0Sstevel@tonic-gate LDAP_CF_UNBIND_CALLBACK *lcf_unbind; 411*0Sstevel@tonic-gate LDAP_CF_SEARCH_CALLBACK *lcf_search; 412*0Sstevel@tonic-gate LDAP_CF_COMPARE_CALLBACK *lcf_compare; 413*0Sstevel@tonic-gate LDAP_CF_ADD_CALLBACK *lcf_add; 414*0Sstevel@tonic-gate LDAP_CF_DELETE_CALLBACK *lcf_delete; 415*0Sstevel@tonic-gate LDAP_CF_MODIFY_CALLBACK *lcf_modify; 416*0Sstevel@tonic-gate LDAP_CF_MODRDN_CALLBACK *lcf_modrdn; 417*0Sstevel@tonic-gate LDAP_CF_RESULT_CALLBACK *lcf_result; 418*0Sstevel@tonic-gate LDAP_CF_FLUSH_CALLBACK *lcf_flush; 419*0Sstevel@tonic-gate }; 420*0Sstevel@tonic-gate 421*0Sstevel@tonic-gate int LDAP_CALL ldap_cache_flush(LDAP *ld, const char *dn, 422*0Sstevel@tonic-gate const char *filter); 423*0Sstevel@tonic-gate 424*0Sstevel@tonic-gate /* 425*0Sstevel@tonic-gate * Memory allocation callback functions (an API extension -- 426*0Sstevel@tonic-gate * LDAP_API_FEATURE_X_MEMALLOC_FUNCTIONS). These are global and can 427*0Sstevel@tonic-gate * not be set on a per-LDAP session handle basis. Install your own 428*0Sstevel@tonic-gate * functions by making a call like this: 429*0Sstevel@tonic-gate * ldap_set_option( NULL, LDAP_OPT_MEMALLOC_FN_PTRS, &memalloc_fns ); 430*0Sstevel@tonic-gate * 431*0Sstevel@tonic-gate * look in lber.h for the function typedefs themselves. 432*0Sstevel@tonic-gate */ 433*0Sstevel@tonic-gate #define LDAP_OPT_MEMALLOC_FN_PTRS 0x61 /* 97 - API extension */ 434*0Sstevel@tonic-gate 435*0Sstevel@tonic-gate struct ldap_memalloc_fns { 436*0Sstevel@tonic-gate LDAP_MALLOC_CALLBACK *ldapmem_malloc; 437*0Sstevel@tonic-gate LDAP_CALLOC_CALLBACK *ldapmem_calloc; 438*0Sstevel@tonic-gate LDAP_REALLOC_CALLBACK *ldapmem_realloc; 439*0Sstevel@tonic-gate LDAP_FREE_CALLBACK *ldapmem_free; 440*0Sstevel@tonic-gate }; 441*0Sstevel@tonic-gate 442*0Sstevel@tonic-gate 443*0Sstevel@tonic-gate /* 444*0Sstevel@tonic-gate * Memory allocation functions (an API extension) 445*0Sstevel@tonic-gate */ 446*0Sstevel@tonic-gate void *ldap_x_malloc( size_t size ); 447*0Sstevel@tonic-gate void *ldap_x_calloc( size_t nelem, size_t elsize ); 448*0Sstevel@tonic-gate void *ldap_x_realloc( void *ptr, size_t size ); 449*0Sstevel@tonic-gate void ldap_x_free( void *ptr ); 450*0Sstevel@tonic-gate 451*0Sstevel@tonic-gate /* 452*0Sstevel@tonic-gate * Extra thread callback functions (an API extension -- 453*0Sstevel@tonic-gate * LDAP_API_FEATURE_X_EXTHREAD_FUNCTIONS) 454*0Sstevel@tonic-gate */ 455*0Sstevel@tonic-gate #define LDAP_OPT_EXTRA_THREAD_FN_PTRS 0x65 /* 101 - API extension */ 456*0Sstevel@tonic-gate 457*0Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_MUTEX_TRYLOCK_CALLBACK)( void *m ); 458*0Sstevel@tonic-gate typedef void *(LDAP_C LDAP_CALLBACK LDAP_TF_SEMA_ALLOC_CALLBACK)( void ); 459*0Sstevel@tonic-gate typedef void (LDAP_C LDAP_CALLBACK LDAP_TF_SEMA_FREE_CALLBACK)( void *s ); 460*0Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_SEMA_WAIT_CALLBACK)( void *s ); 461*0Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_SEMA_POST_CALLBACK)( void *s ); 462*0Sstevel@tonic-gate typedef void *(LDAP_C LDAP_CALLBACK LDAP_TF_THREADID_CALLBACK)(void); 463*0Sstevel@tonic-gate 464*0Sstevel@tonic-gate struct ldap_extra_thread_fns { 465*0Sstevel@tonic-gate LDAP_TF_MUTEX_TRYLOCK_CALLBACK *ltf_mutex_trylock; 466*0Sstevel@tonic-gate LDAP_TF_SEMA_ALLOC_CALLBACK *ltf_sema_alloc; 467*0Sstevel@tonic-gate LDAP_TF_SEMA_FREE_CALLBACK *ltf_sema_free; 468*0Sstevel@tonic-gate LDAP_TF_SEMA_WAIT_CALLBACK *ltf_sema_wait; 469*0Sstevel@tonic-gate LDAP_TF_SEMA_POST_CALLBACK *ltf_sema_post; 470*0Sstevel@tonic-gate LDAP_TF_THREADID_CALLBACK *ltf_threadid_fn; 471*0Sstevel@tonic-gate }; 472*0Sstevel@tonic-gate 473*0Sstevel@tonic-gate 474*0Sstevel@tonic-gate /* 475*0Sstevel@tonic-gate * Debugging level (an API extension) 476*0Sstevel@tonic-gate */ 477*0Sstevel@tonic-gate #define LDAP_OPT_DEBUG_LEVEL 0x6E /* 110 - API extension */ 478*0Sstevel@tonic-gate /* On UNIX, there's only one copy of ldap_debug */ 479*0Sstevel@tonic-gate /* On NT, each dll keeps its own module_ldap_debug, which */ 480*0Sstevel@tonic-gate /* points to the process' ldap_debug and needs initializing after load */ 481*0Sstevel@tonic-gate #ifdef _WIN32 482*0Sstevel@tonic-gate extern int *module_ldap_debug; 483*0Sstevel@tonic-gate typedef void (*set_debug_level_fn_t)(int*); 484*0Sstevel@tonic-gate #endif 485*0Sstevel@tonic-gate 486*0Sstevel@tonic-gate /************************ end of experimental section ************************/ 487*0Sstevel@tonic-gate 488*0Sstevel@tonic-gate 489*0Sstevel@tonic-gate LDAP_API(int) LDAP_CALL ldap_keysort_entries( LDAP *ld, LDAPMessage **chain, 490*0Sstevel@tonic-gate void *arg, LDAP_KEYGEN_CALLBACK *gen, LDAP_KEYCMP_CALLBACK *cmp, 491*0Sstevel@tonic-gate LDAP_KEYFREE_CALLBACK *fre ); 492*0Sstevel@tonic-gate 493*0Sstevel@tonic-gate /* 494*0Sstevel@tonic-gate * utility routines 495*0Sstevel@tonic-gate */ 496*0Sstevel@tonic-gate LDAP_API(int) LDAP_CALL ldap_charray_add( char ***a, char *s ); 497*0Sstevel@tonic-gate LDAP_API(int) LDAP_CALL ldap_charray_merge( char ***a, char **s ); 498*0Sstevel@tonic-gate LDAP_API(void) LDAP_CALL ldap_charray_free( char **array ); 499*0Sstevel@tonic-gate LDAP_API(int) LDAP_CALL ldap_charray_inlist( char **a, char *s ); 500*0Sstevel@tonic-gate LDAP_API(char **) LDAP_CALL ldap_charray_dup( char **a ); 501*0Sstevel@tonic-gate LDAP_API(char **) LDAP_CALL ldap_str2charray( char *str, char *brkstr ); 502*0Sstevel@tonic-gate LDAP_API(int) LDAP_CALL ldap_charray_position( char **a, char *s ); 503*0Sstevel@tonic-gate 504*0Sstevel@tonic-gate /* 505*0Sstevel@tonic-gate * UTF-8 routines (should these move into libnls?) 506*0Sstevel@tonic-gate */ 507*0Sstevel@tonic-gate /* number of bytes in character */ 508*0Sstevel@tonic-gate LDAP_API(int) LDAP_CALL ldap_utf8len( const char* ); 509*0Sstevel@tonic-gate /* find next character */ 510*0Sstevel@tonic-gate LDAP_API(char*) LDAP_CALL ldap_utf8next( char* ); 511*0Sstevel@tonic-gate /* find previous character */ 512*0Sstevel@tonic-gate LDAP_API(char*) LDAP_CALL ldap_utf8prev( char* ); 513*0Sstevel@tonic-gate /* copy one character */ 514*0Sstevel@tonic-gate LDAP_API(int) LDAP_CALL ldap_utf8copy( char* dst, const char* src ); 515*0Sstevel@tonic-gate /* total number of characters */ 516*0Sstevel@tonic-gate LDAP_API(size_t) LDAP_CALL ldap_utf8characters( const char* ); 517*0Sstevel@tonic-gate /* get one UCS-4 character, and move *src to the next character */ 518*0Sstevel@tonic-gate LDAP_API(unsigned long) LDAP_CALL ldap_utf8getcc( const char** src ); 519*0Sstevel@tonic-gate /* UTF-8 aware strtok_r() */ 520*0Sstevel@tonic-gate LDAP_API(char*) LDAP_CALL ldap_utf8strtok_r( char* src, const char* brk, char** next); 521*0Sstevel@tonic-gate 522*0Sstevel@tonic-gate /* like isalnum(*s) in the C locale */ 523*0Sstevel@tonic-gate LDAP_API(int) LDAP_CALL ldap_utf8isalnum( char* s ); 524*0Sstevel@tonic-gate /* like isalpha(*s) in the C locale */ 525*0Sstevel@tonic-gate LDAP_API(int) LDAP_CALL ldap_utf8isalpha( char* s ); 526*0Sstevel@tonic-gate /* like isdigit(*s) in the C locale */ 527*0Sstevel@tonic-gate LDAP_API(int) LDAP_CALL ldap_utf8isdigit( char* s ); 528*0Sstevel@tonic-gate /* like isxdigit(*s) in the C locale */ 529*0Sstevel@tonic-gate LDAP_API(int) LDAP_CALL ldap_utf8isxdigit(char* s ); 530*0Sstevel@tonic-gate /* like isspace(*s) in the C locale */ 531*0Sstevel@tonic-gate LDAP_API(int) LDAP_CALL ldap_utf8isspace( char* s ); 532*0Sstevel@tonic-gate 533*0Sstevel@tonic-gate #define LDAP_UTF8LEN(s) ((0x80 & *(unsigned char*)(s)) ? ldap_utf8len (s) : 1) 534*0Sstevel@tonic-gate #define LDAP_UTF8NEXT(s) ((0x80 & *(unsigned char*)(s)) ? ldap_utf8next(s) : (s)+1) 535*0Sstevel@tonic-gate #define LDAP_UTF8INC(s) ((0x80 & *(unsigned char*)(s)) ? s=ldap_utf8next(s) : ++s) 536*0Sstevel@tonic-gate 537*0Sstevel@tonic-gate #define LDAP_UTF8PREV(s) ldap_utf8prev(s) 538*0Sstevel@tonic-gate #define LDAP_UTF8DEC(s) (s=ldap_utf8prev(s)) 539*0Sstevel@tonic-gate 540*0Sstevel@tonic-gate #define LDAP_UTF8COPY(d,s) ((0x80 & *(unsigned char*)(s)) ? ldap_utf8copy(d,s) : ((*(d) = *(s)), 1)) 541*0Sstevel@tonic-gate #define LDAP_UTF8GETCC(s) ((0x80 & *(unsigned char*)(s)) ? ldap_utf8getcc (&s) : *s++) 542*0Sstevel@tonic-gate #define LDAP_UTF8GETC(s) ((0x80 & *(unsigned char*)(s)) ? ldap_utf8getcc ((const char**)&s) : *s++) 543*0Sstevel@tonic-gate 544*0Sstevel@tonic-gate #ifdef __cplusplus 545*0Sstevel@tonic-gate } 546*0Sstevel@tonic-gate #endif 547*0Sstevel@tonic-gate #endif /* _SOLARISINT_H */ 548*0Sstevel@tonic-gate 549