1 /* $OpenLDAP$ */
2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
3  *
4  * Copyright 1998-2021 The OpenLDAP Foundation.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted only as authorized by the OpenLDAP
9  * Public License.
10  *
11  * A copy of this license is available in the file LICENSE in the
12  * top-level directory of the distribution or, alternatively, at
13  * <http://www.OpenLDAP.org/license.html>.
14  */
15 /* ACKNOWLEDGEMENTS:
16  * This program was originally developed by Kurt D. Zeilenga for inclusion
17  * in OpenLDAP Software.
18  */
19 
20 /*
21  * LDAPv3 Cancel Operation Request
22  */
23 
24 #include "portable.h"
25 
26 #include <stdio.h>
27 #include <ac/stdlib.h>
28 
29 #include <ac/socket.h>
30 #include <ac/string.h>
31 #include <ac/time.h>
32 
33 #include "ldap-int.h"
34 #include "ldap_log.h"
35 
36 int
ldap_cancel(LDAP * ld,int cancelid,LDAPControl ** sctrls,LDAPControl ** cctrls,int * msgidp)37 ldap_cancel(
38 	LDAP		*ld,
39 	int		cancelid,
40 	LDAPControl	**sctrls,
41 	LDAPControl	**cctrls,
42 	int		*msgidp )
43 {
44 	BerElement *cancelidber = NULL;
45 	struct berval cancelidvalp = { 0, NULL };
46 	int rc;
47 
48 	cancelidber = ber_alloc_t( LBER_USE_DER );
49 	ber_printf( cancelidber, "{i}", cancelid );
50 	ber_flatten2( cancelidber, &cancelidvalp, 0 );
51 	rc = ldap_extended_operation( ld, LDAP_EXOP_CANCEL,
52 		&cancelidvalp, sctrls, cctrls, msgidp );
53 	ber_free( cancelidber, 1 );
54 	return rc;
55 }
56 
57 int
ldap_cancel_s(LDAP * ld,int cancelid,LDAPControl ** sctrls,LDAPControl ** cctrls)58 ldap_cancel_s(
59 	LDAP		*ld,
60 	int		cancelid,
61 	LDAPControl	**sctrls,
62 	LDAPControl	**cctrls )
63 {
64 	BerElement *cancelidber = NULL;
65 	struct berval cancelidvalp = { 0, NULL };
66 	int rc;
67 
68 	cancelidber = ber_alloc_t( LBER_USE_DER );
69 	ber_printf( cancelidber, "{i}", cancelid );
70 	ber_flatten2( cancelidber, &cancelidvalp, 0 );
71 	rc = ldap_extended_operation_s( ld, LDAP_EXOP_CANCEL,
72 		&cancelidvalp, sctrls, cctrls, NULL, NULL );
73 	ber_free( cancelidber, 1 );
74 	return rc;
75 }
76 
77