]> git.sur5r.net Git - openldap/commitdiff
Add ldap_turn(3) and ldap_turn_s(3).
authorKurt Zeilenga <kurt@openldap.org>
Wed, 4 May 2005 20:24:48 +0000 (20:24 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Wed, 4 May 2005 20:24:48 +0000 (20:24 +0000)
include/ldap.h
libraries/libldap/Makefile.in
libraries/libldap/turn.c [new file with mode: 0644]
libraries/libldap_r/Makefile.in

index 849f054b252d13c25d01822a7b11c86884b355dc..c03d8d71ee16b76ef0add1f671578615980b1ae3 100644 (file)
@@ -312,6 +312,8 @@ typedef struct ldapcontrol {
 #define LDAP_EXOP_X_WHO_AM_I   "1.3.6.1.4.1.4203.1.11.3"
 #define LDAP_EXOP_X_CANCEL             "1.3.6.1.1.8"
 
+#define LDAP_EXOP_X_TURN               "1.3.6.1.4.1.4203.666.6.4"
+
 /* LDAP Grouping of Related Operations *//* a work in progress */
 #ifdef LDAP_DEVEL
 #define LDAP_X_GROUPING_BASE           "1.3.6.1.4.1.4203.666.10.3"
@@ -1838,12 +1840,32 @@ ldap_cancel LDAP_P(( LDAP *ld,
        int                             *msgidp ));
 
 LDAP_F( int )
-ldap_cancel_s LDAP_P((
-       LDAP *ld,
+ldap_cancel_s LDAP_P(( LDAP *ld,
        int cancelid,
        LDAPControl **sctrl,
        LDAPControl **cctrl ));
 
+/*
+ * LDAP Turn Extended Operation <draft-zeilenga-ldap-turn-xx.txt>
+ *  in turn.c
+ */
+#define LDAP_API_FEATURE_TURN 1000
+
+LDAP_F( int )
+ldap_turn LDAP_P(( LDAP *ld,
+       int mutual,
+       LDAP_CONST char* identifier,
+       LDAPControl             **sctrls,
+       LDAPControl             **cctrls,
+       int                             *msgidp ));
+
+LDAP_F( int )
+ldap_turn_s LDAP_P(( LDAP *ld,
+       int mutual,
+       LDAP_CONST char* identifier,
+       LDAPControl **sctrl,
+       LDAPControl **cctrl ));
+
 /*
  * LDAP Server Side Sort
  *     in sortctrl.c
index 42e47dab10932face859129860f0aeb60ecdf5a8..47d81ddc076b84bde35d60b0101a40c0f0752c8d 100644 (file)
@@ -26,7 +26,7 @@ SRCS  = bind.c open.c result.c error.c compare.c search.c \
        request.c os-ip.c url.c sortctrl.c vlvctrl.c \
        init.c options.c print.c string.c util-int.c schema.c \
        charray.c tls.c os-local.c dnssrv.c utf-8.c utf-8-conv.c \
-       groupings.c txn.c ppolicy.c
+       turn.c groupings.c txn.c ppolicy.c
 
 OBJS   = bind.lo open.lo result.lo error.lo compare.lo search.lo \
        controls.lo messages.lo references.lo extended.lo cyrus.lo \
@@ -37,7 +37,7 @@ OBJS  = bind.lo open.lo result.lo error.lo compare.lo search.lo \
        request.lo os-ip.lo url.lo sortctrl.lo vlvctrl.lo \
        init.lo options.lo print.lo string.lo util-int.lo schema.lo \
        charray.lo tls.lo os-local.lo dnssrv.lo utf-8.lo utf-8-conv.lo \
-       groupings.lo txn.lo ppolicy.lo
+       turn.lo groupings.lo txn.lo ppolicy.lo
 
 LDAP_INCDIR= ../../include       
 LDAP_LIBDIR= ../../libraries
diff --git a/libraries/libldap/turn.c b/libraries/libldap/turn.c
new file mode 100644 (file)
index 0000000..085a4dc
--- /dev/null
@@ -0,0 +1,88 @@
+/* $OpenLDAP$ */
+/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
+ *
+ * Copyright 2005 The OpenLDAP Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
+ *
+ * A copy of this license is available in the file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * <http://www.OpenLDAP.org/license.html>.
+ */
+/* ACKNOWLEDGEMENTS:
+ * This program was orignally developed by Kurt D. Zeilenga for inclusion in
+ * OpenLDAP Software.
+ */
+
+/*
+ * LDAPv3 Turn Operation Request
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+#include <ac/stdlib.h>
+
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
+
+#include "ldap-int.h"
+#include "ldap_log.h"
+
+int
+ldap_turn(
+       LDAP *ld,
+       int mutual,
+       LDAP_CONST char* identifier,
+       LDAPControl **sctrls,
+       LDAPControl **cctrls,
+       int *msgidp )
+{
+       BerElement *turnvalber = NULL;
+       struct berval *turnvalp = NULL;
+       int rc;
+
+       turnvalber = ber_alloc_t( LBER_USE_DER );
+       if( mutual ) {
+               ber_printf( turnvalber, "{bs}", mutual, identifier );
+       } else {
+               ber_printf( turnvalber, "{s}", identifier );
+       }
+       ber_flatten( turnvalber, &turnvalp );
+
+       rc = ldap_extended_operation( ld, LDAP_EXOP_X_TURN,
+                       turnvalp, sctrls, cctrls, msgidp );
+       ber_free( turnvalber, 1 );
+       return rc;
+}
+
+int
+ldap_turn_s(
+       LDAP *ld,
+       int mutual,
+       LDAP_CONST char* identifier,
+       LDAPControl **sctrls,
+       LDAPControl **cctrls )
+{
+       BerElement *turnvalber = NULL;
+       struct berval *turnvalp = NULL;
+       int rc;
+
+       turnvalber = ber_alloc_t( LBER_USE_DER );
+       if( mutual ) {
+               ber_printf( turnvalber, "{bs}", 0xFF, identifier );
+       } else {
+               ber_printf( turnvalber, "{s}", identifier );
+       }
+       ber_flatten( turnvalber, &turnvalp );
+
+       rc = ldap_extended_operation_s( ld, LDAP_EXOP_X_TURN,
+                       turnvalp, sctrls, cctrls, NULL, NULL );
+       ber_free( turnvalber, 1 );
+       return rc;
+}
+
index 2e63c77fb1897b7ca3e2d2b119b20974e91f7f65..09554ea9adec80640f45557b509dae4b56b295af 100644 (file)
@@ -28,7 +28,7 @@ XXSRCS    = apitest.c test.c \
        request.c os-ip.c url.c sortctrl.c vlvctrl.c \
        init.c options.c print.c string.c util-int.c schema.c \
        charray.c tls.c os-local.c dnssrv.c utf-8.c utf-8-conv.c \
-       groupings.c txn.c ppolicy.c
+       turn.c groupings.c txn.c ppolicy.c
 SRCS   = threads.c rdwr.c tpool.c rq.c \
        thr_posix.c thr_cthreads.c thr_thr.c thr_lwp.c thr_nt.c \
        thr_pth.c thr_stub.c
@@ -44,7 +44,7 @@ OBJS  = threads.lo rdwr.lo tpool.lo  rq.lo \
        request.lo os-ip.lo url.lo sortctrl.lo vlvctrl.lo \
        init.lo options.lo print.lo string.lo util-int.lo schema.lo \
        charray.lo tls.lo os-local.lo dnssrv.lo utf-8.lo utf-8-conv.lo \
-       groupings.lo txn.lo ppolicy.lo
+       turn.lo groupings.lo txn.lo ppolicy.lo
 
 LDAP_INCDIR= ../../include       
 LDAP_LIBDIR= ../../libraries