Exemplo n.º 1
0
static int
prldap_getpeername( LDAP *ld, struct sockaddr *addr, char *buffer, int buflen)
{
    PRLDAPIOSocketArg *sa;
    PRFileDesc	*fd;
    PRNetAddr	iaddr;
    int		ret;

    if (NULL != ld) {
        ret = prldap_socket_arg_from_ld( ld, &sa );
        if (ret != LDAP_SUCCESS) {
            return (-1);
        }
        ret = PR_GetPeerName(sa->prsock_prfd, &iaddr);
        if( ret == PR_FAILURE ) {
            return( -1 );
        }
        *addr = *((struct sockaddr *)&iaddr.raw);
        ret = PR_NetAddrToString(&iaddr, buffer, buflen);
        if( ret == PR_FAILURE ) {
            return( -1 );
        }
        return (0);
    }
    return (-1);
}
Exemplo n.º 2
0
/*
 * Function: prldap_set_default_socket_info().
 *
 * Given an LDAP session handle, set socket specific information.
 * If ld is NULL, LDAP_PARAM_ERROR is returned.
 *
 * Returns an LDAP API error code (LDAP_SUCCESS if all goes well, in
 * which case the fields in the structure that soip points to are filled in).
 */
int LDAP_CALL
prldap_set_default_socket_info( LDAP *ld, PRLDAPSocketInfo *soip )
{
    int rc;
    PRLDAPIOSocketArg *prsockp;


    if ( NULL == soip || PRLDAP_SOCKETINFO_SIZE != soip->soinfo_size ) {
        ldap_set_lderrno( ld, LDAP_PARAM_ERROR, NULL, NULL );
        return( LDAP_PARAM_ERROR );
    }

    if ( NULL != ld ) {
        if ( LDAP_SUCCESS !=
                ( rc = prldap_socket_arg_from_ld( ld, &prsockp ))) {
            return( rc );
        }
    } else {
        ldap_set_lderrno( ld, LDAP_PARAM_ERROR, NULL, NULL );
        return( LDAP_PARAM_ERROR );
    }

    prsockp->prsock_prfd = soip->soinfo_prfd;
    prsockp->prsock_appdata = soip->soinfo_appdata;

    return( LDAP_SUCCESS );
}