]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/stctrl.c
ITS#6254
[openldap] / libraries / libldap / stctrl.c
index 84284e11dbd8f1994cb0a8ad91ddbaa5592add8b..4ba0c2197a0effa469f499b23e03f3812b28098d 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2007 The OpenLDAP Foundation.
+ * Copyright 1998-2009 The OpenLDAP Foundation.
  * Portions Copyright 2007 Pierangelo Masarati.
  * All rights reserved.
  *
@@ -60,6 +60,7 @@ param_error:;
        }
 
        assert( LDAP_VALID( ld ) );
+       ld->ld_errno = LDAP_SUCCESS;
 
        /* check sizes according to I.D. */
        if ( sessionSourceIp == NULL ) {
@@ -128,7 +129,7 @@ done:;
  * NOTE: this API is bad; it could be much more efficient...
  */
 int
-ldap_create_session_tracking(
+ldap_create_session_tracking_control(
        LDAP            *ld,
        char            *sessionSourceIp,
        char            *sessionSourceName,
@@ -137,7 +138,6 @@ ldap_create_session_tracking(
        LDAPControl     **ctrlp )
 {
        struct berval   value;
-       BerElement      *ber;
 
        if ( ctrlp == NULL ) {
                ld->ld_errno = LDAP_PARAM_ERROR;
@@ -148,21 +148,11 @@ ldap_create_session_tracking(
                sessionSourceIp, sessionSourceName, formatOID,
                sessionTrackingIdentifier, &value );
        if ( ld->ld_errno == LDAP_SUCCESS ) {
-               ber = ldap_alloc_ber_with_options( ld );
-               if ( ber == NULL ) {
-                       ld->ld_errno = LDAP_NO_MEMORY;
-                       return LDAP_NO_MEMORY;
-               }
-
-               ld->ld_errno = ldap_create_control( LDAP_CONTROL_X_SESSION_TRACKING,
-                       ber, 0, ctrlp );
-               if ( ld->ld_errno == LDAP_SUCCESS ) {
-                       (*ctrlp)->ldctl_value = value;
-
-               } else {
+               ld->ld_errno = ldap_control_create( LDAP_CONTROL_X_SESSION_TRACKING,
+                       0, &value, 0, ctrlp );
+               if ( ld->ld_errno != LDAP_SUCCESS ) {
                        LDAP_FREE( value.bv_val );
                }
-               ber_free( ber, 1 );
        }
 
        return ld->ld_errno;
@@ -198,14 +188,10 @@ ldap_parse_session_tracking_control(
                return LDAP_PARAM_ERROR;
        }
 
-       ip->bv_val = NULL;
-       ip->bv_len = 0;
-       name->bv_val = NULL;
-       name->bv_len = 0;
-       oid->bv_val = NULL;
-       oid->bv_len = 0;
-       id->bv_val = NULL;
-       id->bv_len = 0;
+       BER_BVZERO( ip );
+       BER_BVZERO( name );
+       BER_BVZERO( oid );
+       BER_BVZERO( id );
 
        ber = ber_init( &ctrl->ldctl_value );