smbrdr_read_andx.c revision 8d7e41661dc4633488e93b13363137523ce59977
/*
* 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 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* SMB ReadX functions.
*/
#include <syslog.h>
#include <strings.h>
#include <smbsrv/libsmbrdr.h>
#include <smbsrv/ntstatus.h>
#include <smbrdr.h>
#define SMBRDR_READX_RSP_OVERHEAD \
#define SMBRDR_READX_RSP_DATA_MAXLEN \
static int smbrdr_decode_readx_rsp(smb_msgbuf_t *, char *, unsigned,
/*
* smbrdr_readx
*
* Send SMB_COM_READ_ANDX request.
*/
int
{
struct sdb_netuse *netuse;
int rc, max_return;
return (-1);
if (status != NT_STATUS_SUCCESS) {
return (-1);
}
12, /* Count of parameter words */
0xFF, /* Secondary (X) command; 0xFF = none */
0, /* Reserved (must be 0) */
0, /* Offset to next command WordCount */
0, /* Offset in file to begin read */
max_return, /* Max number of bytes to return */
/* Reserved for obsolescent requests [0 = non-blocking read] */
/*
* High 16 bits of MaxCount if CAP_LARGE_READX;
* else MUST BE ZERO
*/
0,
max_return, /* Reserved for obsolescent requests */
/* Upper 32 bits of offset (only if WordCount is 12) */
0,
0); /* Count of data bytes = 0 */
if (rc < 0) {
return (rc);
}
if (status != NT_STATUS_SUCCESS) {
return (-1);
}
if (status != NT_STATUS_SUCCESS) {
return (-1);
}
if (rc < 0) {
return (-1);
}
}
/*
* smbrdr_decode_readx_rsp
*
* Decode the response from the SMB_COM_READ_ANDX request. The payload
* of the response is appended to the end of SmbTransact response data
* in the RPC receive buffer.
*
* Return -1 on error, 0 upon success.
*/
static int
char *in,
unsigned in_len,
{
int rc;
&rsp->AndXReserved,
&rsp->AndXOffset,
&rsp->DataLength,
&rsp->DataOffset,
if (rc <= 0)
return (-1);
return (-1);
return (0);
}