da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw/*
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * CDDL HEADER START
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The contents of this file are subject to the terms of the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Common Development and Distribution License (the "License").
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * You may not use this file except in compliance with the License.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * or http://www.opensolaris.org/os/licensing.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * See the License for the specific language governing permissions
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * and limitations under the License.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * When distributing Covered Code, include this CDDL HEADER in each
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * If applicable, add the following below this CDDL HEADER, with the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * fields enclosed by brackets "[]" replaced with your own identifying
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * information: Portions Copyright [yyyy] [name of copyright owner]
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * CDDL HEADER END
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
148c5f43199ca0b43fc8e3b643aab11cd66ea327Alan Wright
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw/*
c586600796766c83eb9485c446886fd9ed2359a9Keyur Desai * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
68b2bbf26c7040fea4281dcb58b81e7627e46f34Gordon Ross * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown#include <smbsrv/smb_kproto.h>
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#include <smbsrv/smb_fsops.h>
3db3f65c6274eb042354801a308c8e9bc4994553amw#include <smbsrv/smb_share.h>
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown#include <smbsrv/string.h>
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#include <smbsrv/nmpipes.h>
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#include <smbsrv/mailslot.h>
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross#include <smbsrv/winioctl.h>
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw/*
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * count of bytes in server response packet
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * except parameters and data. Note that setup
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * word count is zero.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#define RESP_HEADER_LEN 24
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw/*
b1352070d318187b41b088da3533692976f3f225Alan Wright * We started by using common functions for transaction/transaction2
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * and transaction_secondary/transaction2_secondary because they
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * are respectively so similar. However, it turned out to be a bad
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * idea because of quirky differences. Be sure if you modify one
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * of these four functions to check and see if the modification should
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * be applied to its peer.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United Statesstatic int smb_trans_ready(smb_xa_t *);
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United Statesstatic smb_sdrc_t smb_trans_dispatch(smb_request_t *, smb_xa_t *);
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United Statesstatic smb_sdrc_t smb_trans2_dispatch(smb_request_t *, smb_xa_t *);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
7b59d02d2a384be9a08087b14defadd214b3c1ddjbsmb_sdrc_t
faa1795a28a5c712eed6d0a3f84d98c368a316c6jbsmb_pre_transaction(smb_request_t *sr)
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb{
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb DTRACE_SMB_1(op__Transaction__start, smb_request_t *, sr);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_SUCCESS);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb}
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb
faa1795a28a5c712eed6d0a3f84d98c368a316c6jbvoid
faa1795a28a5c712eed6d0a3f84d98c368a316c6jbsmb_post_transaction(smb_request_t *sr)
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb{
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb DTRACE_SMB_1(op__Transaction__done, smb_request_t *, sr);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb}
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb
faa1795a28a5c712eed6d0a3f84d98c368a316c6jbsmb_sdrc_t
faa1795a28a5c712eed6d0a3f84d98c368a316c6jbsmb_com_transaction(smb_request_t *sr)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw{
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw int rc;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw unsigned char msrcnt, suwcnt;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw uint16_t tpscnt, tdscnt, mprcnt, mdrcnt, flags;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw uint16_t pscnt, psoff, dscnt, dsoff;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw uint32_t timeo;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw struct smb_xa *xa;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw char *stn;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw int ready;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross if (!STYPE_ISIPC(sr->tid_tree->t_res_type)) {
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross smbsr_error(sr, 0, ERRDOS, ERRnoaccess);
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross return (SDRC_ERROR);
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross }
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw rc = smbsr_decode_vwv(sr, SMB_TRANSHDR_ED_FMT,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw &tpscnt, &tdscnt, &mprcnt, &mdrcnt, &msrcnt, &flags,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw &timeo, &pscnt, &psoff, &dscnt, &dsoff, &suwcnt);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
7b59d02d2a384be9a08087b14defadd214b3c1ddjb if (rc != 0)
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa = smb_xa_create(sr->session, sr, tpscnt, tdscnt, mprcnt, mdrcnt,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw msrcnt, suwcnt);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (xa == NULL) {
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as smbsr_error(sr, 0, ERRSRV, ERRnoroom);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /* Should be some alignment stuff here in SMB? */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (sr->smb_flg2 & SMB_FLAGS2_UNICODE) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw rc = smbsr_decode_data(sr, "%.U", sr, &stn);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw } else {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw rc = smbsr_decode_data(sr, "%s", sr, &stn);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (rc != 0) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw smb_xa_rele(sr->session, xa);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States xa->xa_pipe_name = smb_mem_strdup(stn);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa->smb_flags = flags;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa->smb_timeout = timeo;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa->req_disp_param = pscnt;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa->req_disp_data = dscnt;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross if (smb_mbc_copy(&xa->req_setup_mb, &sr->smb_vwv,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw sr->smb_vwv.chain_offset, suwcnt * 2)) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw smb_xa_rele(sr->session, xa);
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as smbsr_error(sr, 0, ERRDOS, ERRbadformat);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross if (smb_mbc_copy(&xa->req_param_mb, &sr->command, psoff, pscnt)) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw smb_xa_rele(sr->session, xa);
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as smbsr_error(sr, 0, ERRDOS, ERRbadformat);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross if (smb_mbc_copy(&xa->req_data_mb, &sr->command, dsoff, dscnt)) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw smb_xa_rele(sr->session, xa);
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as smbsr_error(sr, 0, ERRDOS, ERRbadformat);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw ready = smb_trans_ready(xa);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (smb_xa_open(xa)) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw smb_xa_rele(sr->session, xa);
ccc71be50bb49efb4e31004c77fb3e065e9c0596Gordon Ross smbsr_error(sr, 0, ERRSRV, ERRsrverror);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw sr->r_xa = xa;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (!ready) {
7b59d02d2a384be9a08087b14defadd214b3c1ddjb rc = smbsr_encode_empty_result(sr);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (!smb_xa_complete(xa)) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw smb_xa_close(xa);
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as smbsr_error(sr, 0, ERRDOS, ERRbadformat);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return (smb_trans_dispatch(sr, xa));
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw}
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
7b59d02d2a384be9a08087b14defadd214b3c1ddjbsmb_sdrc_t
faa1795a28a5c712eed6d0a3f84d98c368a316c6jbsmb_pre_transaction_secondary(smb_request_t *sr)
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb{
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb DTRACE_SMB_1(op__TransactionSecondary__start, smb_request_t *, sr);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_SUCCESS);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb}
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb
faa1795a28a5c712eed6d0a3f84d98c368a316c6jbvoid
faa1795a28a5c712eed6d0a3f84d98c368a316c6jbsmb_post_transaction_secondary(smb_request_t *sr)
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb{
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb DTRACE_SMB_1(op__TransactionSecondary__done, smb_request_t *, sr);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb}
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb
faa1795a28a5c712eed6d0a3f84d98c368a316c6jbsmb_sdrc_t
faa1795a28a5c712eed6d0a3f84d98c368a316c6jbsmb_com_transaction_secondary(smb_request_t *sr)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw{
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw uint16_t tpscnt, tdscnt, pscnt, psdisp;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw uint16_t dscnt, dsoff, dsdisp, psoff;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw smb_xa_t *xa;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw int rc;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if ((xa = smbsr_lookup_xa(sr)) == 0) {
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as smbsr_error(sr, 0, ERRSRV, ERRsrverror);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (sr->session->signing.flags & SMB_SIGNING_ENABLED) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (smb_sign_check_secondary(sr, xa->reply_seqnum) != 0) {
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as smbsr_error(sr, NT_STATUS_ACCESS_DENIED,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw ERRDOS, ERRnoaccess);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (xa->smb_com != SMB_COM_TRANSACTION) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return (SDRC_DROP_VC);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw rc = smbsr_decode_vwv(sr, SMB_TRANSSHDR_ED_FMT, &tpscnt, &tdscnt,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw &pscnt, &psoff, &psdisp, &dscnt, &dsoff, &dsdisp);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
7b59d02d2a384be9a08087b14defadd214b3c1ddjb if (rc != 0)
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw mutex_enter(&xa->xa_mutex);
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross if (xa->smb_tpscnt > tpscnt)
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross xa->smb_tpscnt = tpscnt;
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross if (xa->smb_tdscnt > tdscnt)
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross xa->smb_tdscnt = tdscnt;
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross xa->req_disp_param = psdisp + pscnt;
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross xa->req_disp_data = dsdisp + dscnt;
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross /*
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * The words psdisp, dsdisp, tell us what displacement
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * into the entire trans parameter and data buffers
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * where we should put the params & data that are
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * delivered by this request. [MS-CIFS] says all the
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * parameters and data SHOULD be sent sequentially, so
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * so we can normally reassemble by simply appending.
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * However, the components MAY come out of order, so
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * check and set the current offset. This is rare,
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * and we might like to know when this happens, so
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * fire some static dtrace probes when it does.
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross */
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross if (xa->req_param_mb.chain_offset != psdisp) {
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross DTRACE_PROBE2(trans_param_disp,
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross smb_xa_t *, xa, uint16_t, psdisp);
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross xa->req_param_mb.chain_offset = psdisp;
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross }
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross if (xa->req_data_mb.chain_offset != dsdisp) {
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross DTRACE_PROBE2(trans_data_disp,
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross smb_xa_t *, xa, uint16_t, dsdisp);
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross xa->req_data_mb.chain_offset = dsdisp;
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross if (smb_mbc_copy(&xa->req_param_mb, &sr->command, psoff, pscnt)) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw mutex_exit(&xa->xa_mutex);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw smb_xa_close(xa);
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as smbsr_error(sr, 0, ERRDOS, ERRbadformat);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross if (smb_mbc_copy(&xa->req_data_mb, &sr->command, dsoff, dscnt)) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw mutex_exit(&xa->xa_mutex);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw smb_xa_close(xa);
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as smbsr_error(sr, 0, ERRDOS, ERRbadformat);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw mutex_exit(&xa->xa_mutex);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (!smb_trans_ready(xa))
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return (SDRC_NO_REPLY);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (!smb_xa_complete(xa))
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return (SDRC_NO_REPLY);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return (smb_trans_dispatch(sr, xa));
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw}
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
7b59d02d2a384be9a08087b14defadd214b3c1ddjbsmb_sdrc_t
faa1795a28a5c712eed6d0a3f84d98c368a316c6jbsmb_pre_ioctl(smb_request_t *sr)
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb{
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb DTRACE_SMB_1(op__Ioctl__start, smb_request_t *, sr);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_SUCCESS);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb}
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb
faa1795a28a5c712eed6d0a3f84d98c368a316c6jbvoid
faa1795a28a5c712eed6d0a3f84d98c368a316c6jbsmb_post_ioctl(smb_request_t *sr)
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb{
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb DTRACE_SMB_1(op__Ioctl__done, smb_request_t *, sr);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb}
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb
faa1795a28a5c712eed6d0a3f84d98c368a316c6jbsmb_sdrc_t
faa1795a28a5c712eed6d0a3f84d98c368a316c6jbsmb_com_ioctl(smb_request_t *sr)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw{
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw uint16_t fid, category, function, tpscnt, tdscnt, mprcnt;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw uint16_t mdrcnt, pscnt, pdoff, dscnt, dsoff;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw uint32_t timeout;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw int rc;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw rc = smbsr_decode_vwv(sr, "wwwwwwwl2.wwww", &fid, &category, &function,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw &tpscnt, &tdscnt, &mprcnt, &mdrcnt, &timeout, &pscnt,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw &pdoff, &dscnt, &dsoff);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
7b59d02d2a384be9a08087b14defadd214b3c1ddjb if (rc != 0)
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_NOT_IMPLEMENTED);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw}
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
faa1795a28a5c712eed6d0a3f84d98c368a316c6jbsmb_sdrc_t
faa1795a28a5c712eed6d0a3f84d98c368a316c6jbsmb_pre_transaction2(smb_request_t *sr)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw{
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb DTRACE_SMB_1(op__Transaction2__start, smb_request_t *, sr);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_SUCCESS);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb}
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb
faa1795a28a5c712eed6d0a3f84d98c368a316c6jbvoid
faa1795a28a5c712eed6d0a3f84d98c368a316c6jbsmb_post_transaction2(smb_request_t *sr)
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb{
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb DTRACE_SMB_1(op__Transaction2__done, smb_request_t *, sr);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw}
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
7b59d02d2a384be9a08087b14defadd214b3c1ddjbsmb_sdrc_t
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwsmb_com_transaction2(struct smb_request *sr)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw{
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw unsigned char msrcnt, suwcnt;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw uint16_t tpscnt, tdscnt, mprcnt, mdrcnt, flags;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw uint16_t pscnt, psoff, dscnt, dsoff;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw uint32_t timeo;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw smb_xa_t *xa;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw int ready;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw int rc;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw rc = smbsr_decode_vwv(sr, SMB_TRANSHDR_ED_FMT, &tpscnt, &tdscnt,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw &mprcnt, &mdrcnt, &msrcnt, &flags, &timeo, &pscnt, &psoff, &dscnt,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw &dsoff, &suwcnt);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
7b59d02d2a384be9a08087b14defadd214b3c1ddjb if (rc != 0)
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa = smb_xa_create(sr->session, sr, tpscnt, tdscnt, mprcnt, mdrcnt,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw msrcnt, suwcnt);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (xa == 0) {
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as smbsr_error(sr, 0, ERRSRV, ERRnoroom);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa->smb_flags = flags;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa->smb_timeout = timeo;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa->req_disp_param = pscnt;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa->req_disp_data = dscnt;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross if (smb_mbc_copy(&xa->req_setup_mb, &sr->smb_vwv,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw sr->smb_vwv.chain_offset, suwcnt*2)) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw smb_xa_rele(sr->session, xa);
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as smbsr_error(sr, 0, ERRDOS, ERRbadformat);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross if (smb_mbc_copy(&xa->req_param_mb, &sr->command, psoff, pscnt)) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw smb_xa_rele(sr->session, xa);
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as smbsr_error(sr, 0, ERRDOS, ERRbadformat);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross if (smb_mbc_copy(&xa->req_data_mb, &sr->command, dsoff, dscnt)) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw smb_xa_rele(sr->session, xa);
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as smbsr_error(sr, 0, ERRDOS, ERRbadformat);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw ready = smb_trans_ready(xa);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (smb_xa_open(xa)) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw smb_xa_rele(sr->session, xa);
ccc71be50bb49efb4e31004c77fb3e065e9c0596Gordon Ross smbsr_error(sr, 0, ERRSRV, ERRsrverror);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw sr->r_xa = xa;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (!ready) {
7b59d02d2a384be9a08087b14defadd214b3c1ddjb rc = smbsr_encode_empty_result(sr);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (!smb_xa_complete(xa)) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw smb_xa_close(xa);
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as smbsr_error(sr, 0, ERRDOS, ERRbadformat);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return (smb_trans2_dispatch(sr, xa));
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw}
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
7b59d02d2a384be9a08087b14defadd214b3c1ddjbsmb_sdrc_t
faa1795a28a5c712eed6d0a3f84d98c368a316c6jbsmb_pre_transaction2_secondary(smb_request_t *sr)
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb{
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb DTRACE_SMB_1(op__Transaction2Secondary__start, smb_request_t *, sr);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_SUCCESS);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb}
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb
faa1795a28a5c712eed6d0a3f84d98c368a316c6jbvoid
faa1795a28a5c712eed6d0a3f84d98c368a316c6jbsmb_post_transaction2_secondary(smb_request_t *sr)
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb{
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb DTRACE_SMB_1(op__Transaction2Secondary__done, smb_request_t *, sr);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb}
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb
faa1795a28a5c712eed6d0a3f84d98c368a316c6jbsmb_sdrc_t
faa1795a28a5c712eed6d0a3f84d98c368a316c6jbsmb_com_transaction2_secondary(smb_request_t *sr)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw{
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw uint16_t tpscnt, tdscnt, fid;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw uint16_t pscnt, psoff, psdisp, dscnt, dsoff, dsdisp;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw smb_xa_t *xa;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw int rc;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if ((xa = smbsr_lookup_xa(sr)) == 0) {
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as smbsr_error(sr, 0, ERRSRV, ERRsrverror);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (sr->session->signing.flags & SMB_SIGNING_ENABLED) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (smb_sign_check_secondary(sr, xa->reply_seqnum) != 0) {
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as smbsr_error(sr, NT_STATUS_ACCESS_DENIED,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw ERRDOS, ERRnoaccess);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (xa->smb_com != SMB_COM_TRANSACTION2) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return (SDRC_DROP_VC);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw rc = smbsr_decode_vwv(sr, SMB_TRANS2SHDR_ED_FMT, &tpscnt, &tdscnt,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw &pscnt, &psoff, &psdisp, &dscnt, &dsoff, &dsdisp, &fid);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
7b59d02d2a384be9a08087b14defadd214b3c1ddjb if (rc != 0)
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw mutex_enter(&xa->xa_mutex);
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross if (xa->smb_tpscnt > tpscnt)
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross xa->smb_tpscnt = tpscnt;
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross if (xa->smb_tdscnt > tdscnt)
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross xa->smb_tdscnt = tdscnt;
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross if (fid != 0xFFFF)
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross xa->xa_smb_fid = fid;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa->req_disp_param = psdisp + pscnt;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa->req_disp_data = dsdisp + dscnt;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross /*
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * See comment in smb_com_transaction_secondary
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross */
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross if (xa->req_param_mb.chain_offset != psdisp) {
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross DTRACE_PROBE2(trans_param_disp,
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross smb_xa_t *, xa, uint16_t, psdisp);
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross xa->req_param_mb.chain_offset = psdisp;
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross }
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross if (xa->req_data_mb.chain_offset != dsdisp) {
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross DTRACE_PROBE2(trans_data_disp,
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross smb_xa_t *, xa, uint16_t, dsdisp);
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross xa->req_data_mb.chain_offset = dsdisp;
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross }
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross if (smb_mbc_copy(&xa->req_param_mb, &sr->command, psoff, pscnt)) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw mutex_exit(&xa->xa_mutex);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw smb_xa_close(xa);
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as smbsr_error(sr, 0, ERRDOS, ERRbadformat);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross if (smb_mbc_copy(&xa->req_data_mb, &sr->command, dsoff, dscnt)) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw mutex_exit(&xa->xa_mutex);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw smb_xa_close(xa);
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as smbsr_error(sr, 0, ERRDOS, ERRbadformat);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw mutex_exit(&xa->xa_mutex);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (!smb_trans_ready(xa))
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return (SDRC_NO_REPLY);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (!smb_xa_complete(xa))
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return (SDRC_NO_REPLY);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return (smb_trans2_dispatch(sr, xa));
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw}
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
7b59d02d2a384be9a08087b14defadd214b3c1ddjbstatic smb_sdrc_t
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwsmb_nt_trans_dispatch(struct smb_request *sr, struct smb_xa *xa)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw{
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw int rc;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw int total_bytes, n_setup, n_param, n_data;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw int param_off, param_pad, data_off, data_pad;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw switch (xa->smb_func) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw case NT_TRANSACT_CREATE:
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb if ((rc = smb_pre_nt_transact_create(sr, xa)) == 0)
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb rc = smb_nt_transact_create(sr, xa);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb smb_post_nt_transact_create(sr, xa);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw break;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw case NT_TRANSACT_NOTIFY_CHANGE:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw rc = smb_nt_transact_notify_change(sr, xa);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw break;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw case NT_TRANSACT_QUERY_SECURITY_DESC:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw rc = smb_nt_transact_query_security_info(sr, xa);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw break;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw case NT_TRANSACT_SET_SECURITY_DESC:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw rc = smb_nt_transact_set_security_info(sr, xa);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw break;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw case NT_TRANSACT_IOCTL:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw rc = smb_nt_transact_ioctl(sr, xa);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw break;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw case NT_TRANSACT_QUERY_QUOTA:
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States rc = smb_nt_transact_query_quota(sr, xa);
b1352070d318187b41b088da3533692976f3f225Alan Wright break;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw case NT_TRANSACT_SET_QUOTA:
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States rc = smb_nt_transact_set_quota(sr, xa);
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States break;
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown case NT_TRANSACT_RENAME:
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown rc = smb_nt_transact_rename(sr, xa);
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown break;
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw default:
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as smbsr_error(sr, 0, ERRSRV, ERRsmbcmd);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw switch (rc) {
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb case SDRC_SUCCESS:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw break;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw case SDRC_DROP_VC:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw case SDRC_NO_REPLY:
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb case SDRC_ERROR:
59229f98006fc8ee5e568078d81b6ce572071e0bjose borrego case SDRC_SR_KEPT:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return (rc);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb case SDRC_NOT_IMPLEMENTED:
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as smbsr_error(sr, 0, ERRSRV, ERRsmbcmd);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw default:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw break;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw n_setup = MBC_LENGTH(&xa->rep_setup_mb);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw n_param = MBC_LENGTH(&xa->rep_param_mb);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw n_data = MBC_LENGTH(&xa->rep_data_mb);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (xa->smb_msrcnt < n_setup ||
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa->smb_mprcnt < n_param ||
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa->smb_mdrcnt < n_data) {
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as smbsr_error(sr, 0, ERRSRV, ERRsmbcmd);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /* neato, blast it over there */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw n_setup = (n_setup + 1) / 2; /* Conver to setup words */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw param_pad = 1; /* must be one */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw param_off = param_pad + 32 + 37 + (n_setup << 1) + 2;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw data_pad = (4 - ((param_off + n_param) & 3)) % 4; /* Pad to 4 byte */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw data_off = param_off + n_param + data_pad; /* Param off from hdr */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw total_bytes = param_pad + n_param + data_pad + n_data;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
7b59d02d2a384be9a08087b14defadd214b3c1ddjb rc = smbsr_encode_result(sr, 18+n_setup, total_bytes,
3db3f65c6274eb042354801a308c8e9bc4994553amw "b3.llllllllbCw#.C#.C",
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw 18 + n_setup, /* wct */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw n_param, /* Total Parameter Bytes */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw n_data, /* Total Data Bytes */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw n_param, /* Total Parameter Bytes this buffer */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw param_off, /* Param offset from header start */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw 0, /* Param displacement */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw n_data, /* Total Data Bytes this buffer */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw data_off, /* Data offset from header start */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw 0, /* Data displacement */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw n_setup, /* suwcnt */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw &xa->rep_setup_mb, /* setup[] */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw total_bytes, /* Total data bytes */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw param_pad,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw &xa->rep_param_mb,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw data_pad,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw &xa->rep_data_mb);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw}
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
faa1795a28a5c712eed6d0a3f84d98c368a316c6jbsmb_sdrc_t
faa1795a28a5c712eed6d0a3f84d98c368a316c6jbsmb_pre_nt_transact(smb_request_t *sr)
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb{
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb DTRACE_SMB_1(op__NtTransact__start, smb_request_t *, sr);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_SUCCESS);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw}
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
faa1795a28a5c712eed6d0a3f84d98c368a316c6jbvoid
faa1795a28a5c712eed6d0a3f84d98c368a316c6jbsmb_post_nt_transact(smb_request_t *sr)
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb{
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb DTRACE_SMB_1(op__NtTransact__done, smb_request_t *, sr);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb}
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
7b59d02d2a384be9a08087b14defadd214b3c1ddjbsmb_sdrc_t
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwsmb_com_nt_transact(struct smb_request *sr)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw{
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw uint16_t Function;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw unsigned char MaxSetupCount, SetupCount;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw uint32_t TotalParameterCount, TotalDataCount;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw uint32_t MaxParameterCount, MaxDataCount, pscnt;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw uint32_t psoff, dscnt, dsoff;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw smb_xa_t *xa;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw int ready;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw int rc;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw rc = smbsr_decode_vwv(sr, SMB_NT_TRANSHDR_ED_FMT, &MaxSetupCount,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw &TotalParameterCount, &TotalDataCount, &MaxParameterCount,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw &MaxDataCount, &pscnt, &psoff, &dscnt,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw &dsoff, &SetupCount, &Function);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
7b59d02d2a384be9a08087b14defadd214b3c1ddjb if (rc != 0)
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa = smb_xa_create(sr->session, sr, TotalParameterCount, TotalDataCount,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw MaxParameterCount, MaxDataCount, MaxSetupCount, SetupCount);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (xa == 0) {
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as smbsr_error(sr, 0, ERRSRV, ERRnoroom);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa->smb_flags = 0;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa->smb_timeout = 0;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa->smb_func = Function;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa->req_disp_param = pscnt;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa->req_disp_data = dscnt;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross if (smb_mbc_copy(&xa->req_setup_mb, &sr->smb_vwv,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw sr->smb_vwv.chain_offset, SetupCount * 2)) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw smb_xa_rele(sr->session, xa);
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as smbsr_error(sr, 0, ERRDOS, ERRbadformat);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross if (smb_mbc_copy(&xa->req_param_mb, &sr->command, psoff, pscnt)) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw smb_xa_rele(sr->session, xa);
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as smbsr_error(sr, 0, ERRDOS, ERRbadformat);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross if (smb_mbc_copy(&xa->req_data_mb, &sr->command, dsoff, dscnt)) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw smb_xa_rele(sr->session, xa);
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as smbsr_error(sr, 0, ERRDOS, ERRbadformat);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw ready = smb_trans_ready(xa);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (smb_xa_open(xa)) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw smb_xa_rele(sr->session, xa);
ccc71be50bb49efb4e31004c77fb3e065e9c0596Gordon Ross smbsr_error(sr, 0, ERRSRV, ERRsrverror);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw sr->r_xa = xa;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (!ready) {
7b59d02d2a384be9a08087b14defadd214b3c1ddjb rc = smbsr_encode_empty_result(sr);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (!smb_xa_complete(xa)) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw smb_xa_close(xa);
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as smbsr_error(sr, 0, ERRDOS, ERRbadformat);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return (smb_nt_trans_dispatch(sr, xa));
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw}
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
faa1795a28a5c712eed6d0a3f84d98c368a316c6jbsmb_sdrc_t
faa1795a28a5c712eed6d0a3f84d98c368a316c6jbsmb_pre_nt_transact_secondary(smb_request_t *sr)
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb{
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb DTRACE_SMB_1(op__NtTransactSecondary__start, smb_request_t *, sr);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_SUCCESS);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb}
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb
faa1795a28a5c712eed6d0a3f84d98c368a316c6jbvoid
faa1795a28a5c712eed6d0a3f84d98c368a316c6jbsmb_post_nt_transact_secondary(smb_request_t *sr)
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb{
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb DTRACE_SMB_1(op__NtTransactSecondary__done, smb_request_t *, sr);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb}
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
7b59d02d2a384be9a08087b14defadd214b3c1ddjbsmb_sdrc_t
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwsmb_com_nt_transact_secondary(struct smb_request *sr)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw{
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw uint16_t tpscnt, tdscnt, fid;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw uint16_t pscnt, psoff, psdisp, dscnt, dsoff, dsdisp;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw smb_xa_t *xa;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw int rc;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if ((xa = smbsr_lookup_xa(sr)) == 0) {
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as smbsr_error(sr, 0, ERRSRV, ERRsrverror);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (sr->session->signing.flags & SMB_SIGNING_ENABLED) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (smb_sign_check_secondary(sr, xa->reply_seqnum) != 0) {
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as smbsr_error(sr, NT_STATUS_ACCESS_DENIED,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw ERRDOS, ERRnoaccess);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (xa->smb_com != SMB_COM_TRANSACTION2) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return (SDRC_DROP_VC);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw rc = smbsr_decode_vwv(sr, SMB_TRANS2SHDR_ED_FMT, &tpscnt, &tdscnt,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw &pscnt, &psoff, &psdisp, &dscnt, &dsoff, &dsdisp, &fid);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
7b59d02d2a384be9a08087b14defadd214b3c1ddjb if (rc != 0)
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw mutex_enter(&xa->xa_mutex);
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross if (xa->smb_tpscnt > tpscnt)
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross xa->smb_tpscnt = tpscnt;
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross if (xa->smb_tdscnt > tdscnt)
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross xa->smb_tdscnt = tdscnt;
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross if (fid != 0xFFFF)
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross xa->xa_smb_fid = fid;
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross xa->req_disp_param = psdisp + pscnt;
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross xa->req_disp_data = dsdisp + dscnt;
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross /*
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * See comment in smb_com_transaction_secondary
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross */
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross if (xa->req_param_mb.chain_offset != psdisp) {
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross DTRACE_PROBE2(trans_param_disp,
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross smb_xa_t *, xa, uint16_t, psdisp);
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross xa->req_param_mb.chain_offset = psdisp;
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross }
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross if (xa->req_data_mb.chain_offset != dsdisp) {
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross DTRACE_PROBE2(trans_data_disp,
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross smb_xa_t *, xa, uint16_t, dsdisp);
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross xa->req_data_mb.chain_offset = dsdisp;
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross if (smb_mbc_copy(&xa->req_param_mb, &sr->command, psoff, pscnt)) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw mutex_exit(&xa->xa_mutex);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw smb_xa_close(xa);
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as smbsr_error(sr, 0, ERRDOS, ERRbadformat);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross if (smb_mbc_copy(&xa->req_data_mb, &sr->command, dsoff, dscnt)) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw mutex_exit(&xa->xa_mutex);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw smb_xa_close(xa);
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as smbsr_error(sr, 0, ERRDOS, ERRbadformat);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw mutex_exit(&xa->xa_mutex);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (!smb_trans_ready(xa))
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return (SDRC_NO_REPLY);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (!smb_xa_complete(xa))
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return (SDRC_NO_REPLY);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return (smb_nt_trans_dispatch(sr, xa));
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw}
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
7b59d02d2a384be9a08087b14defadd214b3c1ddjbstatic int
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United Statessmb_trans_ready(smb_xa_t *xa)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw{
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw int rc;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw mutex_enter(&xa->xa_mutex);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw rc = xa->req_disp_data >= xa->smb_tdscnt &&
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa->req_disp_param >= xa->smb_tpscnt;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw mutex_exit(&xa->xa_mutex);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return (rc);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw}
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
3ad684d66b78e06edd37e2c4fd3b3949f095194bjbstatic void
3ad684d66b78e06edd37e2c4fd3b3949f095194bjbsmb_encode_SHARE_INFO_1(struct mbuf_chain *output, struct mbuf_chain *text,
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb char *oem_name, uint16_t type, char *comment)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw{
3db3f65c6274eb042354801a308c8e9bc4994553amw (void) smb_mbc_encodef(output, "13c.wl", oem_name,
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb type, MBC_LENGTH(text));
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
3db3f65c6274eb042354801a308c8e9bc4994553amw (void) smb_mbc_encodef(text, "s", comment ? comment : "");
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw}
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
3ad684d66b78e06edd37e2c4fd3b3949f095194bjbstatic void
3ad684d66b78e06edd37e2c4fd3b3949f095194bjbsmb_encode_SHARE_INFO_2(struct mbuf_chain *output, struct mbuf_chain *text,
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb smb_request_t *sr, char *oem_name, uint16_t type,
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb char *comment, uint16_t access, char *path, char *password)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw{
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb unsigned char pword[9];
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw bzero(pword, sizeof (pword));
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw (void) strncpy((char *)pword, password, sizeof (pword));
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb smb_encode_SHARE_INFO_1(output, text, oem_name, type, comment);
3db3f65c6274eb042354801a308c8e9bc4994553amw (void) smb_mbc_encodef(output, "wwwl9c.",
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw access,
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb sr->sr_cfg->skc_maxconnections,
8622ec4569457733001d4982ef7f5b44427069beGordon Ross smb_server_get_session_count(sr->sr_server),
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw MBC_LENGTH(text),
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb pword);
3db3f65c6274eb042354801a308c8e9bc4994553amw (void) smb_mbc_encodef(text, "s", path);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw}
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwint
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwsmb_trans_net_share_enum(struct smb_request *sr, struct smb_xa *xa)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw{
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross uint16_t pid_hi, pid_lo;
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /*
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Number of data bytes that will
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * be sent in the current response
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw uint16_t data_scnt;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /*
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Total number of data bytes that
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * are sent till now. This is only
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * used for calculating current data
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * displacement
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw uint16_t tot_data_scnt;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /*
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Number of parameter bytes should
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * be sent for the current response.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * It is 8 for the 1st response and
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * 0 for others
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw uint16_t param_scnt;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /* number of setup and parameter bytes */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw uint16_t n_setup, n_param;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /* data and parameter displacement */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw uint16_t data_disp, param_disp;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /* parameter and data offset and pad */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw int param_off, param_pad, data_off, data_pad;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /*
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * total bytes of parameters and data
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * in the packet, plus the pad bytes.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw int tot_packet_bytes;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb boolean_t first_resp;
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb char fmt[16];
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw struct mbuf_chain reply;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb uint16_t level;
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb uint16_t pkt_bufsize;
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb smb_enumshare_info_t esi;
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb char *sent_buf;
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb ASSERT(sr->uid_user);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
3db3f65c6274eb042354801a308c8e9bc4994553amw if (smb_mbc_decodef(&xa->req_param_mb, "ww", &level,
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb &esi.es_bufsize) != 0)
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_NOT_IMPLEMENTED);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (level != 1) {
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb /*
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb * Only level 1 is valid for NetShareEnum
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb * None of the error codes in the spec are meaningful
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb * here. This error code is returned by Windows.
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb */
3db3f65c6274eb042354801a308c8e9bc4994553amw (void) smb_mbc_encodef(&xa->rep_param_mb, "wwww",
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb ERROR_INVALID_LEVEL, 0, 0, 0);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_SUCCESS);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
148c5f43199ca0b43fc8e3b643aab11cd66ea327Alan Wright esi.es_buf = smb_srm_zalloc(sr, esi.es_bufsize);
c586600796766c83eb9485c446886fd9ed2359a9Keyur Desai esi.es_posix_uid = crgetuid(sr->uid_user->u_cred);
8622ec4569457733001d4982ef7f5b44427069beGordon Ross smb_kshare_enum(sr->sr_server, &esi);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb /* client buffer size is not big enough to hold any shares */
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb if (esi.es_nsent == 0) {
3db3f65c6274eb042354801a308c8e9bc4994553amw (void) smb_mbc_encodef(&xa->rep_param_mb, "wwww",
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb ERROR_MORE_DATA, 0, esi.es_nsent, esi.es_ntotal);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_SUCCESS);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross /*
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * Initialize the reply mbuf chain. Note that we re-initialize
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * this on each pass through the loop below.
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross */
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross MBC_SETUP(&reply, smb_maxbufsize);
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /*
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The rep_setup_mb is already initialized in smb_trans_dispatch().
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Calling MBC_INIT() will initialized the structure and so the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * pointer to the mbuf chains will be lost. Therefore, we need
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * to free the resources before calling MBC_INIT() again.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb n_setup = 0; /* Setup count for NetShareEnum SMB is 0 */
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross MBC_FLUSH(&xa->rep_setup_mb);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb n_param = 8;
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb pkt_bufsize = sr->session->smb_msg_size -
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb (SMB_HEADER_ED_LEN + RESP_HEADER_LEN + n_param);
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw tot_data_scnt = 0;
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb sent_buf = esi.es_buf;
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb first_resp = B_TRUE;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb while (tot_data_scnt < esi.es_datasize) {
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb data_scnt = esi.es_datasize - tot_data_scnt;
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb if (data_scnt > pkt_bufsize)
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb data_scnt = pkt_bufsize;
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross MBC_FLUSH(&xa->rep_data_mb);
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb (void) sprintf(fmt, "%dc", data_scnt);
3db3f65c6274eb042354801a308c8e9bc4994553amw (void) smb_mbc_encodef(&xa->rep_data_mb, fmt, sent_buf);
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb sent_buf += data_scnt;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw tot_data_scnt += data_scnt;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /* Only the 1st response packet contains parameters */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw param_scnt = (first_resp) ? n_param : 0;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw param_pad = 1; /* always one */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw param_off = SMB_HEADER_ED_LEN + RESP_HEADER_LEN;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw param_disp = (first_resp) ? 0 : n_param;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross MBC_FLUSH(&xa->rep_param_mb);
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (first_resp) {
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb first_resp = B_FALSE;
3db3f65c6274eb042354801a308c8e9bc4994553amw (void) smb_mbc_encodef(&xa->rep_param_mb, "wwww",
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb (esi.es_ntotal > esi.es_nsent)
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb ? ERROR_MORE_DATA : 0,
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb 0, esi.es_nsent, esi.es_ntotal);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw data_pad = (param_off + n_param) & 1; /* Pad to short */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /* data off from hdr start */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw data_off = param_off + param_scnt + data_pad;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw data_disp = tot_data_scnt - data_scnt;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw tot_packet_bytes = param_pad + param_scnt + data_pad +
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw data_scnt;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross pid_hi = sr->smb_pid >> 16;
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross pid_lo = (uint16_t)sr->smb_pid;
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross MBC_FLUSH(&reply);
3db3f65c6274eb042354801a308c8e9bc4994553amw (void) smb_mbc_encodef(&reply, SMB_HEADER_ED_FMT,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw sr->first_smb_com,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw sr->smb_rcls,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw sr->smb_reh,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw sr->smb_err,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw sr->smb_flg | SMB_FLAGS_REPLY,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw sr->smb_flg2,
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross pid_hi,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw sr->smb_sig,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw sr->smb_tid,
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross pid_lo,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw sr->smb_uid,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw sr->smb_mid);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
3db3f65c6274eb042354801a308c8e9bc4994553amw (void) smb_mbc_encodef(&reply,
3db3f65c6274eb042354801a308c8e9bc4994553amw "bww2.wwwwwwb.Cw#.C#.C",
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw 10 + n_setup, /* wct */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw n_param, /* Total Parameter Bytes */
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb esi.es_datasize, /* Total Data Bytes */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw param_scnt, /* Total Parameter Bytes this buffer */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw param_off, /* Param offset from header start */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw param_disp, /* Param displacement */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw data_scnt, /* Total Data Bytes this buffer */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw data_off, /* Data offset from header start */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw data_disp, /* Data displacement */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw n_setup, /* suwcnt */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw &xa->rep_setup_mb, /* setup[] */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw tot_packet_bytes, /* Total data bytes */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw param_pad,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw &xa->rep_param_mb,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw data_pad,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw &xa->rep_data_mb);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (sr->session->signing.flags & SMB_SIGNING_ENABLED)
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States smb_sign_reply(sr, &reply);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw (void) smb_session_send(sr->session, 0, &reply);
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross m_freem(reply.chain);
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return (SDRC_NO_REPLY);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw}
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwint
3ad684d66b78e06edd37e2c4fd3b3949f095194bjbsmb_trans_net_share_getinfo(smb_request_t *sr, struct smb_xa *xa)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw{
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb uint16_t level, max_bytes, access;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw struct mbuf_chain str_mb;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw char *share;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw char *password;
148c5f43199ca0b43fc8e3b643aab11cd66ea327Alan Wright smb_kshare_t *si;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
3db3f65c6274eb042354801a308c8e9bc4994553amw if (smb_mbc_decodef(&xa->req_param_mb, "%sww", sr,
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb &share, &level, &max_bytes) != 0)
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_NOT_IMPLEMENTED);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
8622ec4569457733001d4982ef7f5b44427069beGordon Ross si = smb_kshare_lookup(sr->sr_server, share);
148c5f43199ca0b43fc8e3b643aab11cd66ea327Alan Wright if ((si == NULL) || (si->shr_oemname == NULL)) {
3db3f65c6274eb042354801a308c8e9bc4994553amw (void) smb_mbc_encodef(&xa->rep_param_mb, "www",
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw NERR_NetNameNotFound, 0, 0);
148c5f43199ca0b43fc8e3b643aab11cd66ea327Alan Wright if (si)
8622ec4569457733001d4982ef7f5b44427069beGordon Ross smb_kshare_release(sr->sr_server, si);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_SUCCESS);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb access = SHARE_ACCESS_ALL;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw password = "";
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw MBC_INIT(&str_mb, max_bytes);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw switch (level) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw case 0 :
148c5f43199ca0b43fc8e3b643aab11cd66ea327Alan Wright (void) smb_mbc_encodef(&xa->rep_data_mb, "13c",
148c5f43199ca0b43fc8e3b643aab11cd66ea327Alan Wright si->shr_oemname);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw break;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw case 1 :
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb smb_encode_SHARE_INFO_1(&xa->rep_data_mb, &str_mb,
148c5f43199ca0b43fc8e3b643aab11cd66ea327Alan Wright si->shr_oemname, si->shr_type, si->shr_cmnt);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw break;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw case 2 :
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb smb_encode_SHARE_INFO_2(&xa->rep_data_mb, &str_mb, sr,
148c5f43199ca0b43fc8e3b643aab11cd66ea327Alan Wright si->shr_oemname, si->shr_type, si->shr_cmnt, access,
148c5f43199ca0b43fc8e3b643aab11cd66ea327Alan Wright si->shr_path, password);
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb break;
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw default:
8622ec4569457733001d4982ef7f5b44427069beGordon Ross smb_kshare_release(sr->sr_server, si);
3db3f65c6274eb042354801a308c8e9bc4994553amw (void) smb_mbc_encodef(&xa->rep_param_mb, "www",
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb ERROR_INVALID_LEVEL, 0, 0);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw m_freem(str_mb.chain);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_NOT_IMPLEMENTED);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
8622ec4569457733001d4982ef7f5b44427069beGordon Ross smb_kshare_release(sr->sr_server, si);
3db3f65c6274eb042354801a308c8e9bc4994553amw (void) smb_mbc_encodef(&xa->rep_param_mb, "www", NERR_Success,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw -MBC_LENGTH(&xa->rep_data_mb),
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw MBC_LENGTH(&xa->rep_data_mb) + MBC_LENGTH(&str_mb));
3db3f65c6274eb042354801a308c8e9bc4994553amw (void) smb_mbc_encodef(&xa->rep_data_mb, "C", &str_mb);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw m_freem(str_mb.chain);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_SUCCESS);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw}
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwint
3ad684d66b78e06edd37e2c4fd3b3949f095194bjbsmb_trans_net_workstation_getinfo(struct smb_request *sr, struct smb_xa *xa)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw{
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb uint16_t level, max_bytes;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw struct mbuf_chain str_mb;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw char *domain;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw char *hostname;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
3db3f65c6274eb042354801a308c8e9bc4994553amw if ((smb_mbc_decodef(&xa->req_param_mb, "ww",
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb &level, &max_bytes) != 0) ||
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw (level != 10)) {
3db3f65c6274eb042354801a308c8e9bc4994553amw (void) smb_mbc_encodef(&xa->rep_param_mb, "wwww",
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw NERR_BadTransactConfig, 0, 0, 0);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_SUCCESS);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States domain = sr->sr_cfg->skc_nbdomain;
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb hostname = sr->sr_cfg->skc_hostname;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw MBC_INIT(&str_mb, max_bytes);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
3db3f65c6274eb042354801a308c8e9bc4994553amw (void) smb_mbc_encodef(&str_mb, "."); /* Prevent NULL pointers */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
3db3f65c6274eb042354801a308c8e9bc4994553amw (void) smb_mbc_encodef(&xa->rep_data_mb, "l", MBC_LENGTH(&str_mb));
3db3f65c6274eb042354801a308c8e9bc4994553amw (void) smb_mbc_encodef(&str_mb, "s", hostname);
3db3f65c6274eb042354801a308c8e9bc4994553amw (void) smb_mbc_encodef(&xa->rep_data_mb, "l", MBC_LENGTH(&str_mb));
3db3f65c6274eb042354801a308c8e9bc4994553amw (void) smb_mbc_encodef(&str_mb, "s", "nobody");
3db3f65c6274eb042354801a308c8e9bc4994553amw (void) smb_mbc_encodef(&xa->rep_data_mb, "l", MBC_LENGTH(&str_mb));
3db3f65c6274eb042354801a308c8e9bc4994553amw (void) smb_mbc_encodef(&str_mb, "s", domain);
3db3f65c6274eb042354801a308c8e9bc4994553amw (void) smb_mbc_encodef(&xa->rep_data_mb, "bbl",
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh (uint8_t)sr->sr_cfg->skc_version.sv_major,
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh (uint8_t)sr->sr_cfg->skc_version.sv_minor,
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States MBC_LENGTH(&str_mb));
3db3f65c6274eb042354801a308c8e9bc4994553amw (void) smb_mbc_encodef(&str_mb, "s", domain);
3db3f65c6274eb042354801a308c8e9bc4994553amw (void) smb_mbc_encodef(&xa->rep_data_mb, "l", MBC_LENGTH(&str_mb));
3db3f65c6274eb042354801a308c8e9bc4994553amw (void) smb_mbc_encodef(&str_mb, "s", domain);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
3db3f65c6274eb042354801a308c8e9bc4994553amw (void) smb_mbc_encodef(&xa->rep_param_mb, "www", 0,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw -MBC_LENGTH(&xa->rep_data_mb),
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw MBC_LENGTH(&xa->rep_data_mb) + MBC_LENGTH(&str_mb));
3db3f65c6274eb042354801a308c8e9bc4994553amw (void) smb_mbc_encodef(&xa->rep_data_mb, "C", &str_mb);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw m_freem(str_mb.chain);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_SUCCESS);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw}
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwint
3ad684d66b78e06edd37e2c4fd3b3949f095194bjbsmb_trans_net_user_getinfo(struct smb_request *sr, struct smb_xa *xa)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw{
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb uint16_t level, max_bytes;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw unsigned char *user;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw int rc;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
3db3f65c6274eb042354801a308c8e9bc4994553amw rc = smb_mbc_decodef(&xa->req_param_mb, "%sww", sr,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw &user,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw &level,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw &max_bytes);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (rc != 0)
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_NOT_IMPLEMENTED);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
3db3f65c6274eb042354801a308c8e9bc4994553amw (void) smb_mbc_encodef(&xa->rep_param_mb, "www",
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw NERR_UserNotFound, 0, 0);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_SUCCESS);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw}
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
7b59d02d2a384be9a08087b14defadd214b3c1ddjbsmb_sdrc_t
3ad684d66b78e06edd37e2c4fd3b3949f095194bjbsmb_trans_net_server_getinfo(struct smb_request *sr, struct smb_xa *xa)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw{
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb uint16_t level, buf_size;
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb uint16_t avail_data, max_data;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw char server_name[16];
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw struct mbuf_chain str_mb;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
3db3f65c6274eb042354801a308c8e9bc4994553amw if (smb_mbc_decodef(&xa->req_param_mb, "ww", &level, &buf_size) != 0)
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb max_data = MBC_MAXBYTES(&xa->rep_data_mb);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw MBC_INIT(&str_mb, buf_size);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw bzero(server_name, sizeof (server_name));
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb (void) strncpy(server_name, sr->sr_cfg->skc_hostname,
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb sizeof (server_name));
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb /* valid levels are 0 and 1 */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw switch (level) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw case 0:
3db3f65c6274eb042354801a308c8e9bc4994553amw (void) smb_mbc_encodef(&xa->rep_data_mb, "16c", server_name);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw break;
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw case 1:
3db3f65c6274eb042354801a308c8e9bc4994553amw (void) smb_mbc_encodef(&str_mb, "s",
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb sr->sr_cfg->skc_system_comment);
3db3f65c6274eb042354801a308c8e9bc4994553amw (void) smb_mbc_encodef(&xa->rep_data_mb, "16cbbll", server_name,
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh (uint8_t)sr->sr_cfg->skc_version.sv_major,
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh (uint8_t)sr->sr_cfg->skc_version.sv_minor,
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb MY_SERVER_TYPE, max_data - MBC_LENGTH(&str_mb));
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw break;
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw default:
3db3f65c6274eb042354801a308c8e9bc4994553amw (void) smb_mbc_encodef(&xa->rep_param_mb, "www",
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb ERROR_INVALID_LEVEL, 0, 0);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw m_freem(str_mb.chain);
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb return (SDRC_SUCCESS);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb avail_data = MBC_LENGTH(&xa->rep_data_mb) + MBC_LENGTH(&str_mb);
3db3f65c6274eb042354801a308c8e9bc4994553amw (void) smb_mbc_encodef(&xa->rep_param_mb, "www",
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb NERR_Success, max_data - avail_data, avail_data);
3db3f65c6274eb042354801a308c8e9bc4994553amw (void) smb_mbc_encodef(&xa->rep_data_mb, "C", &str_mb);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw m_freem(str_mb.chain);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_SUCCESS);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw}
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw/*
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * 6.4 The NetServerEnum2 RAP Service
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The NetServerEnum2 RAP service lists all computers of the specified type
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * or types that are visible in the specified domains. It may also
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * enumerate domains.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The following definition uses the notation and terminology defined in
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * the CIFS Remote Administration Protocol specification, which is required
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * in order to make it well-defined. The definition is:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * uint16_t NetServerEnum2 (
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * uint16_t sLevel,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * RCVBUF pbBuffer,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * RCVBUFLEN cbBuffer,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * ENTCOUNT pcEntriesRead,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * uint16_t *pcTotalAvail,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * uint32_t fServerType,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * char *pszDomain,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * );
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * where:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * sLevel specifies the level of detail (0 or 1) requested.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * pbBuffer points to the buffer to receive the returned data. If the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * function is successful, the buffer contains a sequence of
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * server_info_x structures, where x is 0 or 1, depending on the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * level of detail requested.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * cbBuffer specifies the size, in bytes, of the buffer pointed to by
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * the pbBuffer parameter.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * pcEntriesRead points to a 16 bit variable that receives a count of
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * the number of servers enumerated in the buffer. This count is
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * valid only if NetServerEnum2 returns the NERR_Success or
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * ERROR_MORE_DATA values.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * pcTotal Avail points to a 16 bit variable that receives a count of
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * the total number of available entries. This count is valid only if
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * NetServerEnum2 returns the NERR_Success or ERROR_MORE_DATA values.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * fServerType specifies the type or types of computers to enumerate.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Computers that match at least one of the specified types are
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * returned in the buffer. Possible values are defined in the request
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * parameters section.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * pszDomain points to a null-terminated string that contains the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * name of the workgroup in which to enumerate computers of the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * specified type or types. If the pszDomain parameter is a null
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * string or a null pointer, servers are enumerated for the current
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * domain of the computer.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * 6.4.1 Transaction Request Parameters section
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The Transaction request parameters section in this instance contains:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * . The 16 bit function number for NetServerEnum2 which is 104.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * . The parameter descriptor string which is "WrLehDz".
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * . The data descriptor string for the (returned) data which is "B16" for
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * level detail 0 or "B16BBDz" for level detail 1.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * . The actual parameters as described by the parameter descriptor
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * string.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The parameters are:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * . A 16 bit integer with a value of 0 or 1 (corresponding to the "W" in
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * the parameter descriptor string. This represents the level of detail
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * the server is expected to return
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * . A 16 bit integer that contains the size of the receive buffer.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * . A 32 bit integer that represents the type of servers the function
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * should enumerate. The possible values may be any of the following or
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * a combination of the following:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * SV_TYPE_WORKSTATION 0x00000001 All workstations
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * SV_TYPE_SERVER 0x00000002 All servers
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * SV_TYPE_SQLSERVER 0x00000004 Any server running with SQL
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * server
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * SV_TYPE_DOMAIN_CTRL 0x00000008 Primary domain controller
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * SV_TYPE_DOMAIN_BAKCTRL 0x00000010 Backup domain controller
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * SV_TYPE_TIME_SOURCE 0x00000020 Server running the timesource
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * service
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * SV_TYPE_AFP 0x00000040 Apple File Protocol servers
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * SV_TYPE_NOVELL 0x00000080 Novell servers
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * SV_TYPE_DOMAIN_MEMBER 0x00000100 Domain Member
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * SV_TYPE_PRINTQ_SERVER 0x00000200 Server sharing print queue
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * SV_TYPE_DIALIN_SERVER 0x00000400 Server running dialin service.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * SV_TYPE_XENIX_SERVER 0x00000800 Xenix server
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * SV_TYPE_NT 0x00001000 NT server
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * SV_TYPE_WFW 0x00002000 Server running Windows for
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Workgroups
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * SV_TYPE_SERVER_NT 0x00008000 Windows NT non DC server
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * SV_TYPE_POTENTIAL_BROWSER 0x00010000 Server that can run the browser
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * service
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * SV_TYPE_BACKUP_BROWSER 0x00020000 Backup browser server
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * SV_TYPE_MASTER_BROWSER 0x00040000 Master browser server
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * SV_TYPE_DOMAIN_MASTER 0x00080000 Domain Master Browser server
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * SV_TYPE_LOCAL_LIST_ONLY 0x40000000 Enumerate only entries marked
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * "local"
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * SV_TYPE_DOMAIN_ENUM 0x80000000 Enumerate Domains. The pszDomain
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * parameter must be NULL.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * . A null terminated ASCII string representing the pszDomain parameter
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * described above
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * 6.4.2 Transaction Request Data section
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * There is no data or auxiliary data to send as part of the request.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * 6.4.3 Transaction Response Parameters section
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The transaction response parameters section consists of:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * . A 16 bit word indicating the return status. The possible values are:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Code Value Description
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * NERR_Success 0 No errors encountered
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * ERROR_MORE_DATA 234 Additional data is available
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * NERR_ServerNotStarted 2114 The RAP service on the remote computer
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * is not running
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * NERR_BadTransactConfig 2141 The server is not configured for
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * transactions, IPC$ is not shared
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * . A 16 bit "converter" word.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * . A 16 bit number representing the number of entries returned.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * . A 16 bit number representing the total number of available entries.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * If the supplied buffer is large enough, this will equal the number of
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * entries returned.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * 6.4.4 Transaction Response Data section
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The return data section consists of a number of SERVER_INFO_1 structures.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The number of such structures present is determined by the third entry
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * (described above) in the return parameters section.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * At level detail 0, the Transaction response data section contains a
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * number of SERVER_INFO_0 data structure. The number of such structures is
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * equal to the 16 bit number returned by the server in the third parameter
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * in the Transaction response parameter section. The SERVER_INFO_0 data
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * structure is defined as:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * struct SERVER_INFO_0 {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * char sv0_name[16];
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * };
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * where:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * sv0_name is a null-terminated string that specifies the name of a
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * computer or domain .
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * At level detail 1, the Transaction response data section contains a
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * number of SERVER_INFO_1 data structure. The number of such structures is
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * equal to the 16 bit number returned by the server in the third parameter
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * in the Transaction response parameter section. The SERVER_INFO_1 data
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * structure is defined as:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * struct SERVER_INFO_1 {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * char sv1_name[16];
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * char sv1_version_major;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * char sv1_version_minor;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * uint32_t sv1_type;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * char *sv1_comment_or_master_browser;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * };
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * sv1_name contains a null-terminated string that specifies the name
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * of a computer, or a domain name if SV_TYPE_DOMAIN_ENUM is set in
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * sv1_type.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * sv1_version_major whatever was specified in the HostAnnouncement
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * or DomainAnnouncement frame with which the entry was registered.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * sv1_version_minor whatever was specified in the HostAnnouncement
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * or DomainAnnouncement frame with which the entry was registered.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * sv1_type specifies the type of software the computer is running.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The member can be one or a combination of the values defined above
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * in the Transaction request parameters section for fServerType.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * sv1_comment_or_master_browser points to a null-terminated string. If
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * the sv1_type indicates that the entry is for a domain, this
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * specifies the name of server running the domain master browser;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * otherwise, it specifies a comment describing the server. The comment
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * can be a null string or the pointer may be a null pointer.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * In case there are multiple SERVER_INFO_1 data structures to
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * return, the server may put all these fixed length structures in
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * the return buffer, leave some space and then put all the variable
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * length data (the actual value of the sv1_comment strings) at the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * end of the buffer.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * There is no auxiliary data to receive.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwint
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwsmb_trans_net_server_enum2(struct smb_request *sr, struct smb_xa *xa)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw{
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw uint16_t opcode, level, max_bytes;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw uint32_t server_type;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw unsigned char *domain;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw struct mbuf_chain str_mb;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw char *hostname, *s;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw smb_kmod_cfg_t *si;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
3db3f65c6274eb042354801a308c8e9bc4994553amw if (smb_mbc_decodef(&xa->req_param_mb,
3db3f65c6274eb042354801a308c8e9bc4994553amw "%wsswwls", sr, &opcode, &s, &s,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw &level, &max_bytes, &server_type, &domain) != 0)
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_NOT_IMPLEMENTED);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb si = sr->sr_cfg;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown if (smb_strcasecmp(si->skc_nbdomain, (char *)domain, 0) != 0) {
3db3f65c6274eb042354801a308c8e9bc4994553amw (void) smb_mbc_encodef(&xa->rep_param_mb, "wwww", 0, 0, 0, 0);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_SUCCESS);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if ((server_type & MY_SERVER_TYPE) == 0) {
3db3f65c6274eb042354801a308c8e9bc4994553amw (void) smb_mbc_encodef(&xa->rep_param_mb, "wwww", 0, 0, 0, 0);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_SUCCESS);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw MBC_INIT(&str_mb, max_bytes);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw hostname = si->skc_hostname;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
3db3f65c6274eb042354801a308c8e9bc4994553amw (void) smb_mbc_encodef(&xa->rep_data_mb, "16c", hostname);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (level == 1) {
3db3f65c6274eb042354801a308c8e9bc4994553amw (void) smb_mbc_encodef(&xa->rep_data_mb, "bbll",
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh (uint8_t)sr->sr_cfg->skc_version.sv_major,
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh (uint8_t)sr->sr_cfg->skc_version.sv_minor,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw MY_SERVER_TYPE, MBC_LENGTH(&str_mb));
3db3f65c6274eb042354801a308c8e9bc4994553amw (void) smb_mbc_encodef(&str_mb, "s", si->skc_system_comment);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
3db3f65c6274eb042354801a308c8e9bc4994553amw (void) smb_mbc_encodef(&xa->rep_param_mb, "wwww", 0,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw -MBC_LENGTH(&xa->rep_data_mb), 1, 1);
3db3f65c6274eb042354801a308c8e9bc4994553amw (void) smb_mbc_encodef(&xa->rep_data_mb, "m", str_mb.chain);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_SUCCESS);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw}
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brownstatic boolean_t
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brownis_supported_mailslot(const char *mailslot)
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown{
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown static char *mailslots[] = {
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown PIPE_LANMAN,
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown MAILSLOT_LANMAN,
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown MAILSLOT_BROWSE,
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown MAILSLOT_MSBROWSE
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown };
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown int i;
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown for (i = 0; i < sizeof (mailslots)/sizeof (mailslots[0]); ++i)
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown if (smb_strcasecmp(mailslot, mailslots[i], 0) == 0)
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown return (B_TRUE);
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown return (B_FALSE);
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown}
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw/*
68b2bbf26c7040fea4281dcb58b81e7627e46f34Gordon Ross * smb_trans_nmpipe
68b2bbf26c7040fea4281dcb58b81e7627e46f34Gordon Ross *
68b2bbf26c7040fea4281dcb58b81e7627e46f34Gordon Ross * This is used for RPC bind and request transactions.
68b2bbf26c7040fea4281dcb58b81e7627e46f34Gordon Ross *
68b2bbf26c7040fea4281dcb58b81e7627e46f34Gordon Ross * If the data available from the pipe is larger than the maximum
68b2bbf26c7040fea4281dcb58b81e7627e46f34Gordon Ross * data size requested by the client, return as much as requested.
68b2bbf26c7040fea4281dcb58b81e7627e46f34Gordon Ross * The residual data remains in the pipe until the client comes back
68b2bbf26c7040fea4281dcb58b81e7627e46f34Gordon Ross * with a read request or closes the pipe.
68b2bbf26c7040fea4281dcb58b81e7627e46f34Gordon Ross *
68b2bbf26c7040fea4281dcb58b81e7627e46f34Gordon Ross * When we read less than what's available, we MUST return the
68b2bbf26c7040fea4281dcb58b81e7627e46f34Gordon Ross * status NT_STATUS_BUFFER_OVERFLOW (or ERRDOS/ERROR_MORE_DATA)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
68b2bbf26c7040fea4281dcb58b81e7627e46f34Gordon Rossstatic smb_sdrc_t
68b2bbf26c7040fea4281dcb58b81e7627e46f34Gordon Rosssmb_trans_nmpipe(smb_request_t *sr, smb_xa_t *xa)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw{
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross smb_fsctl_t fsctl;
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross uint32_t status;
68b2bbf26c7040fea4281dcb58b81e7627e46f34Gordon Ross
68b2bbf26c7040fea4281dcb58b81e7627e46f34Gordon Ross smbsr_lookup_file(sr);
68b2bbf26c7040fea4281dcb58b81e7627e46f34Gordon Ross if (sr->fid_ofile == NULL) {
68b2bbf26c7040fea4281dcb58b81e7627e46f34Gordon Ross smbsr_error(sr, NT_STATUS_INVALID_HANDLE,
68b2bbf26c7040fea4281dcb58b81e7627e46f34Gordon Ross ERRDOS, ERRbadfid);
68b2bbf26c7040fea4281dcb58b81e7627e46f34Gordon Ross return (SDRC_ERROR);
68b2bbf26c7040fea4281dcb58b81e7627e46f34Gordon Ross }
68b2bbf26c7040fea4281dcb58b81e7627e46f34Gordon Ross
bce01b59de50fe66a0267f4aa23e1d6e60d973d9Gordon Ross /*
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross * A little confusing perhaps, but the fsctl "input" is what we
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross * write to the pipe (from the transaction "send" data), and the
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross * fsctl "output" is what we read from the pipe (and becomes the
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross * transaction receive data).
bce01b59de50fe66a0267f4aa23e1d6e60d973d9Gordon Ross */
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross fsctl.CtlCode = FSCTL_PIPE_TRANSCEIVE;
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross fsctl.InputCount = xa->smb_tdscnt; /* write count */
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross fsctl.OutputCount = 0; /* minimum to read from the pipe */
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross fsctl.MaxOutputResp = xa->smb_mdrcnt; /* max to read */
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross fsctl.in_mbc = &xa->req_data_mb; /* write from here */
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross fsctl.out_mbc = &xa->rep_data_mb; /* read into here */
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross status = smb_opipe_fsctl(sr, &fsctl);
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross if (status) {
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross smbsr_status(sr, status, 0, 0);
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross if (NT_SC_SEVERITY(status) == NT_STATUS_SEVERITY_ERROR)
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross return (SDRC_ERROR);
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross /* Warnings like NT_STATUS_BUFFER_OVERFLOW are OK */
bce01b59de50fe66a0267f4aa23e1d6e60d973d9Gordon Ross }
bce01b59de50fe66a0267f4aa23e1d6e60d973d9Gordon Ross
68b2bbf26c7040fea4281dcb58b81e7627e46f34Gordon Ross return (SDRC_SUCCESS);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw}
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
7b59d02d2a384be9a08087b14defadd214b3c1ddjbstatic smb_sdrc_t
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United Statessmb_trans_dispatch(smb_request_t *sr, smb_xa_t *xa)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw{
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw int rc, pos;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw int total_bytes, n_setup, n_param, n_data;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw int param_off, param_pad, data_off, data_pad;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw uint16_t opcode;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw uint16_t devstate;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw char *req_fmt;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw char *rep_fmt;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross if (xa->smb_suwcnt > 0) {
3db3f65c6274eb042354801a308c8e9bc4994553amw rc = smb_mbc_decodef(&xa->req_setup_mb, "ww", &opcode,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw &sr->smb_fid);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (rc != 0)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw goto trans_err_not_supported;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw switch (opcode) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw case TRANS_SET_NMPIPE_STATE:
3db3f65c6274eb042354801a308c8e9bc4994553amw if ((rc = smb_mbc_decodef(&xa->req_param_mb, "w",
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw &devstate)) != 0)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw goto trans_err_not_supported;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb rc = SDRC_SUCCESS;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw break;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw case TRANS_TRANSACT_NMPIPE:
68b2bbf26c7040fea4281dcb58b81e7627e46f34Gordon Ross rc = smb_trans_nmpipe(sr, xa);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw break;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw case TRANS_WAIT_NMPIPE:
68b2bbf26c7040fea4281dcb58b81e7627e46f34Gordon Ross delay(SEC_TO_TICK(1));
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb rc = SDRC_SUCCESS;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw break;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw default:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw goto trans_err_not_supported;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw } else {
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown if (!is_supported_mailslot(xa->xa_pipe_name))
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw goto trans_err_not_supported;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
3db3f65c6274eb042354801a308c8e9bc4994553amw if ((rc = smb_mbc_decodef(&xa->req_param_mb, "%wss", sr,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw &opcode, &req_fmt, &rep_fmt)) != 0)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw goto trans_err_not_supported;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw switch (opcode) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw case API_WshareEnum:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw rc = smb_trans_net_share_enum(sr, xa);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw break;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw case API_WshareGetInfo:
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb rc = smb_trans_net_share_getinfo(sr, xa);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw break;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw case API_WserverGetInfo:
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb rc = smb_trans_net_server_getinfo(sr, xa);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw break;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw case API_WUserGetInfo:
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb rc = smb_trans_net_user_getinfo(sr, xa);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw break;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw case API_WWkstaGetInfo:
3ad684d66b78e06edd37e2c4fd3b3949f095194bjb rc = smb_trans_net_workstation_getinfo(sr, xa);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw break;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw case API_NetServerEnum2:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw rc = smb_trans_net_server_enum2(sr, xa);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw break;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw default:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw goto trans_err_not_supported;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw switch (rc) {
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb case SDRC_SUCCESS:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw break;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw case SDRC_DROP_VC:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw case SDRC_NO_REPLY:
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb case SDRC_ERROR:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return (rc);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb case SDRC_NOT_IMPLEMENTED:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw goto trans_err_not_supported;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw default:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw break;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw n_setup = MBC_LENGTH(&xa->rep_setup_mb);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw n_param = MBC_LENGTH(&xa->rep_param_mb);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw n_data = MBC_LENGTH(&xa->rep_data_mb);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (xa->smb_msrcnt < n_setup ||
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa->smb_mprcnt < n_param ||
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa->smb_mdrcnt < n_data) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw goto trans_err_too_small;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /* neato, blast it over there */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw n_setup = (n_setup + 1) / 2; /* Convert to setup words */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw param_pad = 1; /* always one */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw param_off = param_pad + 32 + 21 + (n_setup << 1) + 2;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw data_pad = (param_off + n_param) & 1; /* Pad to short */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /* Param off from hdr start */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw data_off = param_off + n_param + data_pad;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw total_bytes = param_pad + n_param + data_pad + n_data;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
7b59d02d2a384be9a08087b14defadd214b3c1ddjb rc = smbsr_encode_result(sr, 10+n_setup, total_bytes,
3db3f65c6274eb042354801a308c8e9bc4994553amw "bww2.wwwwwwb.Cw#.C#.C",
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw 10 + n_setup, /* wct */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw n_param, /* Total Parameter Bytes */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw n_data, /* Total Data Bytes */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw n_param, /* Total Parameter Bytes this buffer */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw param_off, /* Param offset from header start */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw 0, /* Param displacement */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw n_data, /* Total Data Bytes this buffer */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw data_off, /* Data offset from header start */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw 0, /* Data displacement */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw n_setup, /* suwcnt */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw &xa->rep_setup_mb, /* setup[] */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw total_bytes, /* Total data bytes */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw param_pad,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw &xa->rep_param_mb,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw data_pad,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw &xa->rep_data_mb);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwtrans_err_too_small:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw rc = NERR_BufTooSmall;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw goto trans_err;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwtrans_err_not_supported:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw rc = ERROR_NOT_SUPPORTED;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw goto trans_err;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwtrans_err:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw pos = MBC_LENGTH(&sr->reply) + 23;
3db3f65c6274eb042354801a308c8e9bc4994553amw rc = smbsr_encode_result(sr, 10, 4, "bww2.wwwwwwb.www",
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw 10, /* wct */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw 4, 0, /* tpscnt tdscnt */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw 4, pos, 0, /* pscnt psoff psdisp */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw 0, 0, 0, /* dscnt dsoff dsdisp */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw 0, /* suwcnt */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw 4, /* bcc */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw rc,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw 0); /* converter word? */
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw}
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
7b59d02d2a384be9a08087b14defadd214b3c1ddjbstatic smb_sdrc_t
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United Statessmb_trans2_dispatch(smb_request_t *sr, smb_xa_t *xa)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw{
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw int rc, pos;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw int total_bytes, n_setup, n_param, n_data;
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross int param_off, param_pad, data_off;
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross uint16_t data_pad;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw uint16_t opcode;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw uint16_t nt_unknown_secret = 0x0100;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw char *fmt;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross n_data = xa->smb_mdrcnt;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
3db3f65c6274eb042354801a308c8e9bc4994553amw if (smb_mbc_decodef(&xa->req_setup_mb, "w", &opcode) != 0)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw goto trans_err_not_supported;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /*
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Save this for /proc to read later.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa->smb_func = opcode;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /* for now, only respond to the */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw switch (opcode) {
2c2961f8403049d948b9f3e6c35d6488b6b7e1aajose borrego case TRANS2_OPEN2:
2c2961f8403049d948b9f3e6c35d6488b6b7e1aajose borrego rc = smb_com_trans2_open2(sr, xa);
2c2961f8403049d948b9f3e6c35d6488b6b7e1aajose borrego break;
2c2961f8403049d948b9f3e6c35d6488b6b7e1aajose borrego
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw case TRANS2_CREATE_DIRECTORY:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw rc = smb_com_trans2_create_directory(sr, xa);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw break;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw case TRANS2_FIND_FIRST2:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /*
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Should have enough room to send the response
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * data back to client.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (n_data == 0) {
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as smbsr_error(sr, NT_STATUS_INFO_LENGTH_MISMATCH,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw ERRDOS, ERROR_BAD_LENGTH);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw rc = smb_com_trans2_find_first2(sr, xa);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw break;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw case TRANS2_FIND_NEXT2:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /*
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Should have enough room to send the response
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * data back to client.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (n_data == 0) {
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as smbsr_error(sr, NT_STATUS_INFO_LENGTH_MISMATCH,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw ERRDOS, ERROR_BAD_LENGTH);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw rc = smb_com_trans2_find_next2(sr, xa);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw break;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw case TRANS2_QUERY_FS_INFORMATION:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /*
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Should have enough room to send the response
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * data back to client.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (n_data == 0) {
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as smbsr_error(sr, NT_STATUS_INFO_LENGTH_MISMATCH,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw ERRDOS, ERROR_BAD_LENGTH);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw rc = smb_com_trans2_query_fs_information(sr, xa);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw break;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States case TRANS2_SET_FS_INFORMATION:
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States rc = smb_com_trans2_set_fs_information(sr, xa);
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States break;
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw case TRANS2_QUERY_PATH_INFORMATION:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /*
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Should have enough room to send the response
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * data back to client.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (n_data == 0) {
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as smbsr_error(sr, NT_STATUS_INFO_LENGTH_MISMATCH,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw ERRDOS, ERROR_BAD_LENGTH);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw rc = smb_com_trans2_query_path_information(sr, xa);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw break;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw case TRANS2_QUERY_FILE_INFORMATION:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /*
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Should have enough room to send the response
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * data back to client.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (n_data == 0) {
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as smbsr_error(sr, NT_STATUS_INFO_LENGTH_MISMATCH,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw ERRDOS, ERROR_BAD_LENGTH);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw rc = smb_com_trans2_query_file_information(sr, xa);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw break;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw case TRANS2_SET_PATH_INFORMATION:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw rc = smb_com_trans2_set_path_information(sr, xa);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw break;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw case TRANS2_SET_FILE_INFORMATION:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw rc = smb_com_trans2_set_file_information(sr, xa);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw break;
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States case TRANS2_GET_DFS_REFERRAL:
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States rc = smb_com_trans2_get_dfs_referral(sr, xa);
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States break;
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw default:
2c2961f8403049d948b9f3e6c35d6488b6b7e1aajose borrego (void) smb_mbc_encodef(&xa->rep_param_mb, "w", 0);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw goto trans_err_not_supported;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw switch (rc) {
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb case SDRC_SUCCESS:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw break;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw case SDRC_DROP_VC:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw case SDRC_NO_REPLY:
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb case SDRC_ERROR:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return (rc);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb case SDRC_NOT_IMPLEMENTED:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw goto trans_err_not_supported;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw default:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw break;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw n_setup = MBC_LENGTH(&xa->rep_setup_mb);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw n_param = MBC_LENGTH(&xa->rep_param_mb);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw n_data = MBC_LENGTH(&xa->rep_data_mb);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (xa->smb_msrcnt < n_setup ||
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa->smb_mprcnt < n_param ||
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa->smb_mdrcnt < n_data) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw goto trans_err_too_small;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /* neato, blast it over there */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw n_setup = (n_setup + 1) / 2; /* Conver to setup words */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw param_pad = 1; /* must be one */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw param_off = param_pad + 32 + 21 + (n_setup << 1) + 2;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /*
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Including the nt_unknown_secret value persuades netmon to
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * display the correct data format for QueryPathInfo and
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * QueryFileInfo.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (opcode == TRANS2_QUERY_FILE_INFORMATION ||
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw opcode == TRANS2_QUERY_PATH_INFORMATION) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw data_pad = sizeof (uint16_t);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw data_off = param_off + n_param + data_pad;
3db3f65c6274eb042354801a308c8e9bc4994553amw fmt = "bww2.wwwwwwb.Cw#.CwC";
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw nt_unknown_secret = 0x0100;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw else
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw data_pad = (param_off + n_param) & 1; /* Pad to short */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /* Param off from hdr start */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw data_off = param_off + n_param + data_pad;
3db3f65c6274eb042354801a308c8e9bc4994553amw fmt = "bww2.wwwwwwb.Cw#.C#.C";
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw nt_unknown_secret = data_pad;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw total_bytes = param_pad + n_param + data_pad + n_data;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
7b59d02d2a384be9a08087b14defadd214b3c1ddjb rc = smbsr_encode_result(sr, 10+n_setup, total_bytes,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw fmt,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw 10 + n_setup, /* wct */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw n_param, /* Total Parameter Bytes */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw n_data /* + data_pad */, /* Total Data Bytes */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw n_param, /* Total Parameter Bytes this buffer */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw param_off, /* Param offset from header start */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw 0, /* Param displacement */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw n_data /* + data_pad */, /* Total Data Bytes this buffer */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw data_off, /* Data offset from header start */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw 0, /* Data displacement */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw n_setup, /* suwcnt */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw &xa->rep_setup_mb, /* setup[] */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw total_bytes, /* Total data bytes */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw param_pad,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw &xa->rep_param_mb,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw nt_unknown_secret,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw &xa->rep_data_mb);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwtrans_err_too_small:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw rc = NERR_BufTooSmall;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw goto trans_err;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwtrans_err_not_supported:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw rc = ERROR_NOT_SUPPORTED;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw goto trans_err;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwtrans_err:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw pos = MBC_LENGTH(&sr->reply) + 23;
3db3f65c6274eb042354801a308c8e9bc4994553amw rc = smbsr_encode_result(sr, 10, 4, "bww2.wwwwwwb.www",
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw 10, /* wct */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw 4, 0, /* tpscnt tdscnt */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw 4, pos, 0, /* pscnt psoff psdisp */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw 0, 0, 0, /* dscnt dsoff dsdisp */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw 0, /* suwcnt */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw 4, /* bcc */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw rc,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw 0); /* converter word? */
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw}
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
7f3ef643e446c82e27a9386991b140b128baf22cGordon Rossstatic uint32_t smb_xa_max_setup_count = 200;
7f3ef643e446c82e27a9386991b140b128baf22cGordon Rossstatic uint32_t smb_xa_max_param_count = 32 * 1024;
7f3ef643e446c82e27a9386991b140b128baf22cGordon Rossstatic uint32_t smb_xa_max_data_count = 64 * 1024;
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwsmb_xa_t *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwsmb_xa_create(
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw smb_session_t *session,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw smb_request_t *sr,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw uint32_t total_parameter_count,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw uint32_t total_data_count,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw uint32_t max_parameter_count,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw uint32_t max_data_count,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw uint32_t max_setup_count,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw uint32_t setup_word_count)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw{
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw smb_xa_t *xa, *nxa;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw smb_llist_t *xlist;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross /*
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * Sanity check what the client says it will send.
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * Caller handles NULL return as ERRnoroom.
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross */
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross if (setup_word_count > smb_xa_max_setup_count)
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross return (NULL);
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross if (total_parameter_count > smb_xa_max_param_count)
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross return (NULL);
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross if (total_data_count > smb_xa_max_data_count)
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross return (NULL);
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross /*
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * Limit what the client asks us to allocate for
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * returned setup, params, data.
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross */
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross if (max_setup_count > smb_xa_max_setup_count)
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross max_setup_count = smb_xa_max_setup_count;
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross if (max_parameter_count > smb_xa_max_param_count)
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross max_parameter_count = smb_xa_max_param_count;
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross if (max_data_count > smb_xa_max_data_count)
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross max_data_count = smb_xa_max_data_count;
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown xa = kmem_zalloc(sizeof (smb_xa_t), KM_SLEEP);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa->xa_refcnt = 1;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa->smb_com = sr->smb_com;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa->smb_flg = sr->smb_flg;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa->smb_flg2 = sr->smb_flg2;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa->smb_tid = sr->smb_tid;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa->smb_pid = sr->smb_pid;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa->smb_uid = sr->smb_uid;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa->xa_smb_mid = sr->smb_mid;
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross xa->xa_smb_fid = 0xFFFF;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa->reply_seqnum = sr->reply_seqnum;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa->smb_tpscnt = total_parameter_count;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa->smb_tdscnt = total_data_count;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa->smb_mprcnt = max_parameter_count;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa->smb_mdrcnt = max_data_count;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa->smb_msrcnt = max_setup_count;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa->smb_suwcnt = setup_word_count;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa->xa_session = session;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa->xa_magic = SMB_XA_MAGIC;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross /* request parts */
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross xa->req_setup_mb.max_bytes = setup_word_count * 2;
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross xa->req_param_mb.max_bytes = total_parameter_count;
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross xa->req_data_mb.max_bytes = total_data_count;
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross /* reply parts */
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross xa->rep_setup_mb.max_bytes = max_setup_count * 2;
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross xa->rep_param_mb.max_bytes = max_parameter_count;
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross xa->rep_data_mb.max_bytes = max_data_count;
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /*
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The new xa structure is checked against the current list to see
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * if it exists already.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xlist = &session->s_xa_list;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw smb_llist_enter(xlist, RW_WRITER);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw nxa = smb_llist_head(xlist);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw while (nxa) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw ASSERT(nxa->xa_magic == SMB_XA_MAGIC);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (nxa->xa_smb_mid == xa->xa_smb_mid &&
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw nxa->smb_pid == xa->smb_pid &&
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw !SMB_XA_CLOSED(nxa) &&
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw !(nxa->xa_flags & SMB_XA_FLAG_COMPLETE)) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw smb_llist_exit(xlist);
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown kmem_free(xa, sizeof (smb_xa_t));
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return (NULL);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw nxa = smb_llist_next(xlist, nxa);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw smb_llist_insert_tail(xlist, xa);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw smb_llist_exit(xlist);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return (xa);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw}
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwvoid
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwsmb_xa_delete(smb_xa_t *xa)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw{
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw ASSERT(xa->xa_refcnt == 0);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw ASSERT(SMB_XA_CLOSED(xa));
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown if (xa->xa_pipe_name)
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States smb_mem_free(xa->xa_pipe_name);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross /* request parts */
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross if (xa->req_setup_mb.chain != NULL)
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross m_freem(xa->req_setup_mb.chain);
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross if (xa->req_param_mb.chain != NULL)
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross m_freem(xa->req_param_mb.chain);
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross if (xa->req_data_mb.chain != NULL)
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross m_freem(xa->req_data_mb.chain);
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross /* reply parts */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (xa->rep_setup_mb.chain != NULL)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw m_freem(xa->rep_setup_mb.chain);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (xa->rep_param_mb.chain != NULL)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw m_freem(xa->rep_param_mb.chain);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (xa->rep_data_mb.chain != NULL)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw m_freem(xa->rep_data_mb.chain);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa->xa_magic = (uint32_t)~SMB_XA_MAGIC;
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown kmem_free(xa, sizeof (smb_xa_t));
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw}
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwsmb_xa_t *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwsmb_xa_hold(smb_xa_t *xa)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw{
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw mutex_enter(&xa->xa_mutex);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa->xa_refcnt++;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw ASSERT(xa->xa_refcnt);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw mutex_exit(&xa->xa_mutex);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return (xa);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw}
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwvoid
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwsmb_xa_rele(smb_session_t *session, smb_xa_t *xa)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw{
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw mutex_enter(&xa->xa_mutex);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw ASSERT(xa->xa_refcnt);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa->xa_refcnt--;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (SMB_XA_CLOSED(xa) && (xa->xa_refcnt == 0)) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw mutex_exit(&xa->xa_mutex);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw smb_llist_enter(&session->s_xa_list, RW_WRITER);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw smb_llist_remove(&session->s_xa_list, xa);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw smb_llist_exit(&session->s_xa_list);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw smb_xa_delete(xa);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw mutex_exit(&xa->xa_mutex);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw}
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwint
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwsmb_xa_open(smb_xa_t *xa)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw{
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw int rc;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw mutex_enter(&xa->xa_mutex);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw ASSERT((xa->xa_flags & SMB_XA_FLAG_OPEN) == 0);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if ((xa->xa_flags & SMB_XA_FLAG_CLOSE) == 0) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa->xa_flags |= SMB_XA_FLAG_OPEN;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw rc = 0;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw } else {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw rc = ERROR_INVALID_HANDLE;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw mutex_exit(&xa->xa_mutex);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return (rc);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw}
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwvoid
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwsmb_xa_close(smb_xa_t *xa)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw{
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw mutex_enter(&xa->xa_mutex);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa->xa_flags |= SMB_XA_FLAG_CLOSE;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa->xa_flags &= ~SMB_XA_FLAG_OPEN;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (xa->xa_refcnt == 0) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw mutex_exit(&xa->xa_mutex);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw smb_llist_enter(&xa->xa_session->s_xa_list, RW_WRITER);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw smb_llist_remove(&xa->xa_session->s_xa_list, xa);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw smb_llist_exit(&xa->xa_session->s_xa_list);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw smb_xa_delete(xa);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw mutex_exit(&xa->xa_mutex);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw}
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwint
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwsmb_xa_complete(smb_xa_t *xa)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw{
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw int rc;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw mutex_enter(&xa->xa_mutex);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (xa->xa_flags & (SMB_XA_FLAG_COMPLETE | SMB_XA_FLAG_CLOSE)) {
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross rc = 0; /* error ("not complete") */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw } else {
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross rc = 1; /* Yes, "complete" */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa->xa_flags |= SMB_XA_FLAG_COMPLETE;
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross /*
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * During trans & trans-secondary processing,
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * we copied the request data into these.
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * Now we want to parse them, so we need to
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross * move the "finger" back to the beginning.
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross */
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross xa->req_setup_mb.chain_offset = 0;
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross xa->req_param_mb.chain_offset = 0;
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross xa->req_data_mb.chain_offset = 0;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw mutex_exit(&xa->xa_mutex);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return (rc);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw}
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwsmb_xa_t *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwsmb_xa_find(
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw smb_session_t *session,
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross uint32_t pid,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw uint16_t mid)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw{
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw smb_xa_t *xa;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw smb_llist_t *xlist;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xlist = &session->s_xa_list;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw smb_llist_enter(xlist, RW_READER);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa = smb_llist_head(xlist);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw while (xa) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw mutex_enter(&xa->xa_mutex);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (xa->xa_smb_mid == mid &&
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa->smb_pid == pid &&
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw !SMB_XA_CLOSED(xa) &&
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw !(xa->xa_flags & SMB_XA_FLAG_COMPLETE)) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa->xa_refcnt++;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw ASSERT(xa->xa_refcnt);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw mutex_exit(&xa->xa_mutex);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw break;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw mutex_exit(&xa->xa_mutex);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xa = smb_llist_next(xlist, xa);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw smb_llist_exit(xlist);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return (xa);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw}