1 /* extended.c - sock backend extended routines */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2000-2017 The OpenLDAP Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
12 * A copy of this license is available in the file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
20 #include <ac/string.h>
23 #include "back-sock.h"
28 sock_back_extended( Operation *op, SlapReply *rs )
31 struct sockinfo *si = (struct sockinfo *) op->o_bd->be_private;
35 Debug( LDAP_DEBUG_ARGS, "==> sock_back_extended(%s)\n",
36 op->ore_reqoid.bv_val, op->o_req_dn.bv_val, 0 );
38 if ( (fp = opensock( si->si_sockpath )) == NULL ) {
39 send_ldap_error( op, rs, LDAP_OTHER,
40 "could not open socket" );
44 /* write out the request to the extended process */
45 fprintf( fp, "EXTENDED\n" );
46 fprintf( fp, "msgid: %ld\n", (long) op->o_msgid );
47 sock_print_conn( fp, op->o_conn, si );
48 sock_print_suffixes( fp, op->o_bd );
49 fprintf( fp, "oid: %s\n", op->ore_reqoid.bv_val );
51 if (op->ore_reqdata) {
53 b64.bv_len = LUTIL_BASE64_ENCODE_LEN( op->ore_reqdata->bv_len ) + 1;
54 b64.bv_val = op->o_tmpalloc( b64.bv_len + 1, op->o_tmpmemctx );
57 (unsigned char *) op->ore_reqdata->bv_val, op->ore_reqdata->bv_len,
58 b64.bv_val, b64.bv_len );
61 assert( strlen(b64.bv_val) == b64.bv_len );
63 fprintf( fp, "value: %s\n", b64.bv_val );
65 op->o_tmpfree( b64.bv_val, op->o_tmpmemctx );
71 /* read in the results and send them along */
72 rc = sock_read_and_send_results( op, rs, fp );