smbrdr_transact.c revision da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* SMB transaction functions to support MLRPC.
*/
#include <syslog.h>
#include <strings.h>
#include <smbsrv/libsmbrdr.h>
#include <smbsrv/ntstatus.h>
#include <smbrdr.h>
/*
* The pipe filename, length (including the null terminator)
* and the buffer size for the transaction. Moving to unicode
* revealed that the length should not include the null.
*/
#define TX_FILENAME "\\PIPE\\"
#define TX_FILENAME_ASCII_LEN 6
#define TX_FILENAME_WCHAR_LEN 14
static int prep_smb_transact(smb_msgbuf_t *, unsigned short, char *,
unsigned short, unsigned short, unsigned);
static int decode_smb_transact(smb_msgbuf_t *, char *, unsigned,
/*
* smbrdr_rpc_transact
*
* Send a SMB_COM_TRANSACTION request.
*/
int
{
struct sdb_session *session;
struct sdb_netuse *netuse;
int rc;
unsigned short rcv_dcnt;
int cur_inlen;
int first_rsp;
return (-1);
if (status != NT_STATUS_SUCCESS) {
return (-1);
}
if (rc < 0) {
"smbrdr_rpc_transact: prep_smb_transact failed");
return (rc);
}
if (status != NT_STATUS_SUCCESS) {
return (-1);
}
rcv_dcnt = 0;
first_rsp = 1;
do {
rc = -1;
break;
}
"SmbTransact: transact decode failure!");
rc = -1;
break;
}
first_rsp = 0;
}
/*
* prep_smb_transact
*
* Prepare the SMB_COM_TRANSACTION request.
*/
static int
{
int data_off;
int rc;
unsigned short bcc;
/*
* The byte count seems to include the pad
* byte to word align the filename and two
* spurious pad bytes between the filename
* and the transaction data.
*/
data_off += 3;
/* this is where data starts */
"(wct)b"
"(tpscnt)w (tdscnt)w (mprcnt)w (mdrcnt)w (msrcnt)b"
"(rsvd). (flags)w (timeo)l (rsvd1)2."
"(pscnt)w (psoff)w (dscnt)w (dsoff)w (suwcnt)b"
"(rsvd2). (pipop)w (fid)w (bcc)w (fname)u",
16, /* smb_wct */
0, /* total parm bytes */
out_len, /* total data bytes */
0, /* max parm bytes to ret */
in_max, /* max data bytes to ret */
0, /* max setup words to ret */
0, /* transact flags */
0, /* transact timeout */
0, /* parameter bytes */
data_off, /* parameter offset */
out_len, /* data bytes */
data_off, /* data offset */
2, /* total setup words */
0x0026, /* OP=TransactNmPipe */
fid, /* FID */
bcc, /* byte count */
TX_FILENAME); /* file name */
/*
* Transaction data - padded.
*/
return (rc);
}
/*
* decode_smb_transact
*
* Decode the response from the SMB_COM_TRANSACTION request.
*/
static int
{
int rc;
return (-1);
}
"(tpscnt)w (tdscnt)w (rsvd)2."
"(pscnt)w (psoff)w (psdisp)w (dscnt)w (dsoff)w"
"(dsdisp)w (suwcnt)b (rsvd). (bcc)w",
if (rc <= 0)
return (-1);
return (-1);
return (0);
}