2 Unix SMB/CIFS implementation.
4 Copyright (C) Stefan Metzmacher 2007
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #ifdef HAVE_ADS_SASL_WRAPPING
24 static int ads_saslwrap_setup(Sockbuf_IO_Desc *sbiod, void *arg)
26 ADS_STRUCT *ads = (ADS_STRUCT *)arg;
28 ads->ldap.sbiod = sbiod;
30 sbiod->sbiod_pvt = ads;
35 static int ads_saslwrap_remove(Sockbuf_IO_Desc *sbiod)
40 static ber_slen_t ads_saslwrap_read(Sockbuf_IO_Desc *sbiod, void *buf, ber_len_t len)
42 return LBER_SBIOD_READ_NEXT(sbiod, buf, len);
45 static ber_slen_t ads_saslwrap_write(Sockbuf_IO_Desc *sbiod, void *buf, ber_len_t len)
47 return LBER_SBIOD_WRITE_NEXT(sbiod, buf, len);
51 static int ads_saslwrap_ctrl(Sockbuf_IO_Desc *sbiod, int opt, void *arg)
53 return LBER_SBIOD_CTRL_NEXT(sbiod, opt, arg);
56 static int ads_saslwrap_close(Sockbuf_IO_Desc *sbiod)
61 static const Sockbuf_IO ads_saslwrap_sockbuf_io = {
62 ads_saslwrap_setup, /* sbi_setup */
63 ads_saslwrap_remove, /* sbi_remove */
64 ads_saslwrap_ctrl, /* sbi_ctrl */
65 ads_saslwrap_read, /* sbi_read */
66 ads_saslwrap_write, /* sbi_write */
67 ads_saslwrap_close /* sbi_close */
70 ADS_STATUS ads_setup_sasl_wrapping(ADS_STRUCT *ads)
74 Sockbuf_IO *io = discard_const_p(Sockbuf_IO, &ads_saslwrap_sockbuf_io);
77 rc = ldap_get_option(ads->ldap.ld, LDAP_OPT_SOCKBUF, &sb);
78 status = ADS_ERROR_LDAP(rc);
79 if (!ADS_ERR_OK(status)) {
83 /* debugging for the layer above SASL */
84 rc = ber_sockbuf_add_io(sb, io, LBER_SBIOD_LEVEL_TRANSPORT,
85 (void *)"ads_sasl_wrapping_above" );
86 status = ADS_ERROR_LDAP(rc);
87 if (!ADS_ERR_OK(status)) {
91 /* setup the real wrapping callbacks */
92 rc = ber_sockbuf_add_io(sb, io, LBER_SBIOD_LEVEL_TRANSPORT, ads);
93 status = ADS_ERROR_LDAP(rc);
94 if (!ADS_ERR_OK(status)) {
98 /* debugging for the layer below SASL */
99 rc = ber_sockbuf_add_io(sb, io, LBER_SBIOD_LEVEL_TRANSPORT,
100 (void *)"ads_sasl_wrapping_below" );
101 status = ADS_ERROR_LDAP(rc);
102 if (!ADS_ERR_OK(status)) {
109 #endif /* HAVE_ADS_SASL_WRAPPING */