/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Mozilla Communicator client code, released
* March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998-1999 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
/*
* Extended I/O callback functions for libldap that use
* NSPR (Netscape Portable Runtime) I/O.
*
* High level strategy: we use the socket-specific arg to hold our own data
* structure that includes the NSPR file handle (PRFileDesc *), among other
* useful information. We use the default argument to hold an LDAP session
* handle specific data structure.
*/
#include "ldappr-int.h"
#include <string.h>
/*
* Local function prototypes:
*/
struct lextiof_socket_private *socketarg );
struct lextiof_socket_private *socketarg );
struct lextiof_session_private *sessionarg,
struct lextiof_socket_private **socketargp
#ifdef _SOLARIS_SDK
, void **dhost );
#else
);
#endif /* _SOLARIS_SDK */
static int LDAP_CALLBACK prldap_close( int s,
struct lextiof_socket_private *socketarg );
struct lextiof_session_private *sessionarg );
struct lextiof_session_private *sessionarg );
struct lextiof_session_private *sessionarg );
struct lextiof_session_private *sessionarg );
static PRLDAPIOSessionArg *prldap_session_arg_alloc( void );
/*
* Local macros:
*/
/* given a socket-specific arg, return the corresponding PRFileDesc * */
/*
* Static variables.
*/
/*
* Install NSPR I/O functions into ld (if ld is NULL, they are installed
* as the default functions for new LDAP * handles).
*
* Returns 0 if all goes well and -1 if not.
*/
int
{
if ( shared ) {
} else {
}
/*
* If we are dealing with a real ld, we allocate the session specific
* data structure now. If not allocated here, it will be allocated
* inside prldap_newhandle() or prldap_shared_newhandle().
*/
if ( NULL ==
return( -1 );
}
} else {
}
return( -1 );
}
return( 0 );
}
static PRIntervalTime
{
if ( LDAP_X_IO_TIMEOUT_NO_WAIT == ms_timeout ) {
} else if ( LDAP_X_IO_TIMEOUT_NO_TIMEOUT == ms_timeout ) {
} else {
}
/* cap at maximum I/O timeout */
if ( LDAP_X_IO_TIMEOUT_NO_WAIT == ms_maxtimeout ) {
} else if ( LDAP_X_IO_TIMEOUT_NO_TIMEOUT != ms_maxtimeout ) {
if ( LDAP_X_IO_TIMEOUT_NO_TIMEOUT == ms_timeout ||
ms_timeout > ms_maxtimeout ) {
}
}
#ifdef PRLDAP_DEBUG
if ( PR_INTERVAL_NO_WAIT == prit ) {
} else if ( PR_INTERVAL_NO_TIMEOUT == prit ) {
} else {
}
#endif /* PRLDAP_DEBUG */
return( prit );
}
static int LDAP_CALLBACK
struct lextiof_socket_private *socketarg )
{
}
static int LDAP_CALLBACK
struct lextiof_socket_private *socketarg )
{
/*
* Note the 4th parameter (flags) to PR_Send() has been obsoleted and
* must always be 0
*/
}
struct prldap_eventmap_entry {
};
{ PR_POLL_READ, LDAP_X_POLLIN },
{ PR_POLL_EXCEPT, LDAP_X_POLLPRI },
{ PR_POLL_WRITE, LDAP_X_POLLOUT },
{ PR_POLL_ERR, LDAP_X_POLLERR },
{ PR_POLL_HUP, LDAP_X_POLLHUP },
{ PR_POLL_NVAL, LDAP_X_POLLNVAL },
};
#define PRLDAP_EVENTMAP_ENTRIES \
sizeof(prldap_eventmap)/sizeof(struct prldap_eventmap_entry )
static int LDAP_CALLBACK
struct lextiof_session_private *sessionarg )
{
int i, j, rc;
return( -1 );
}
/* allocate or resize NSPR poll descriptor array */
( nfds + PRLDAP_POLL_ARRAY_GROWTH )
* sizeof( PRPollDesc ));
return( -1 );
}
} else {
}
/* populate NSPR poll info. based on LDAP info. */
for ( i = 0; i < nfds; ++i ) {
} else {
}
for ( j = 0; j < PRLDAP_EVENTMAP_ENTRIES; ++j ) {
!= 0 ) {
}
}
}
}
/* call PR_Poll() to do the real work */
/* populate LDAP info. based on NSPR results */
for ( i = 0; i < nfds; ++i ) {
for ( j = 0; j < PRLDAP_EVENTMAP_ENTRIES; ++j ) {
!= 0 ) {
}
}
}
}
return( rc );
}
/*
* Utility function to try one TCP connect()
* Returns 1 if successful and -1 if not. Sets the NSPR fd inside prsockp.
*/
static int
{
/*
* Set up address and open a TCP socket:
*/
return( -1 );
}
PRLDAP_DEFAULT_ADDRESS_FAMILY )) == NULL ) {
return( -1 );
}
/*
* Set nonblocking option if requested:
*/
if ( 0 != ( options & LDAP_X_EXTIOF_OPT_NONBLOCKING )) {
!= PR_SUCCESS ) {
return( -1 );
}
}
#ifdef PRLDAP_DEBUG
{
}
/* IPv4 address mapped into IPv6 address space */
p = buf + 7;
fmtstr = "prldap_try_one_address(): Trying %s:%d...\n";
} else {
p = buf;
fmtstr = "prldap_try_one_address(): Trying [%s]:%d...\n";
}
}
#endif /* PRLDAP_DEBUG */
/*
* Try to open the TCP connection itself:
*/
return( -1 );
}
#ifdef PRLDAP_DEBUG
#endif /* PRLDAP_DEBUG */
/*
* Success. Return a valid file descriptor (1 is always valid)
*/
return( 1 );
}
/*
* XXXmcs: At present, this code ignores the timeout when doing DNS lookups.
*/
static int LDAP_CALLBACK
struct lextiof_socket_private **socketargp
#ifdef _SOLARIS_SDK
, void **dhost )
#else
)
#endif /* _SOLARIS_SDK */
{
#ifdef _SOLARIS_SDK
char *nsldapi_strdup(char *);
#endif /* _SOLARIS_SDK */
if ( 0 != ( options & LDAP_X_EXTIOF_OPT_SECURE )) {
return( -1 );
}
return( -1 );
}
&status );
if ( PRLDAP_DEFAULT_ADDRESS_FAMILY == PR_AF_INET6 &&
}
} else {
}
}
}
#ifdef _SOLARIS_SDK
}
if ( rc >= 0 ) {
}
#endif /* _SOLARIS_SDK */
ldap_memfree( host );
}
if ( rc < 0 ) {
} else {
*socketargp = prsockp;
}
#ifdef _SOLARIS_SDK
#endif /* _SOLARIS_SDK */
return( rc );
}
static int LDAP_CALLBACK
{
int rc;
rc = 0;
rc = -1;
}
return( rc );
}
/*
* LDAP session handle creation callback.
*
* Allocate a session argument if not already done, and then call the
* thread's new handle function.
*/
static int LDAP_CALLBACK
{
if ( NULL == sessionarg ) {
(void *)&iofns ) < 0 ) {
}
if ( NULL ==
return( LDAP_NO_MEMORY );
}
(void *)&iofns ) < 0 ) {
}
}
return( LDAP_SUCCESS );
}
static int LDAP_CALLBACK
{
int rc;
}
return( rc );
}
static void LDAP_CALLBACK
{
}
static void LDAP_CALLBACK
struct lextiof_session_private *sessionarg )
{
}
/*
* Allocate a session argument.
*/
static PRLDAPIOSessionArg *
prldap_session_arg_alloc( void )
{
/* copy global defaults to the new session handle */
}
return( prsessp );
}
static void
{
}
}
}
/*
* Given an LDAP session handle, retrieve a session argument.
* Returns an LDAP error code.
*/
int
{
/* XXXmcs: NULL ld's are not supported */
return( LDAP_PARAM_ERROR );
}
}
return( LDAP_LOCAL_ERROR );
}
return( LDAP_SUCCESS );
}
/*
* Given an LDAP session handle, retrieve a socket argument.
* Returns an LDAP error code.
*/
int
{
/* XXXmcs: NULL ld's are not supported */
return( LDAP_PARAM_ERROR );
}
}
(void *)&extiofns ) < 0 ) {
}
return( LDAP_LOCAL_ERROR );
}
return( LDAP_SUCCESS );
}
/*
* Allocate a socket argument.
*/
static PRLDAPIOSocketArg *
{
/* copy socket defaults from the session */
}
return( prsockp );
}
static void
{
}
}
static void *
{
void *p;
} else {
}
return( p );
}
/* returns an LDAP result code */
int
{
} else {
}
return( rc );
}
/* returns an LDAP result code */
int
{
if ( NULL == io_max_timeoutp ) {
} else {
}
return( rc );
}