mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-06-16 17:55:15 +00:00
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5081 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
191 lines
5.3 KiB
Java
191 lines
5.3 KiB
Java
/*
|
|
* Copyright (C) 2005 Alfresco, Inc.
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation; either version 2
|
|
* of the License, or (at your option) any later version.
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
*/
|
|
package org.alfresco.filesys.smb.server;
|
|
|
|
import org.alfresco.filesys.smb.PacketType;
|
|
import org.alfresco.filesys.smb.TransactBuffer;
|
|
import org.alfresco.filesys.util.DataBuffer;
|
|
import org.alfresco.filesys.util.DataPacker;
|
|
|
|
/**
|
|
* Transact Buffer Class
|
|
* <p>
|
|
* Contains the parameters and data for a transaction, transaction2 or NT transaction request.
|
|
*/
|
|
class SrvTransactBuffer extends TransactBuffer
|
|
{
|
|
|
|
/**
|
|
* Class constructor
|
|
*
|
|
* @param slen int
|
|
* @param plen int
|
|
* @param dlen int
|
|
*/
|
|
public SrvTransactBuffer(int slen, int plen, int dlen)
|
|
{
|
|
super(slen, plen, dlen);
|
|
}
|
|
|
|
/**
|
|
* Class constructor
|
|
* <p>
|
|
* Construct a TransactBuffer using the maximum size settings from the specified transaction
|
|
* buffer
|
|
*
|
|
* @param tbuf SrvTransactBuffer
|
|
*/
|
|
public SrvTransactBuffer(SrvTransactBuffer tbuf)
|
|
{
|
|
super(tbuf.getReturnSetupLimit(), tbuf.getReturnParameterLimit(), tbuf.getReturnDataLimit());
|
|
|
|
// Save the return limits for this transaction buffer
|
|
|
|
setReturnLimits(tbuf.getReturnSetupLimit(), tbuf.getReturnParameterLimit(), tbuf.getReturnDataLimit());
|
|
|
|
// Set the transaction reply type
|
|
|
|
setType(tbuf.isType());
|
|
|
|
// Copy the tree id
|
|
|
|
setTreeId(tbuf.getTreeId());
|
|
}
|
|
|
|
/**
|
|
* Class constructor
|
|
*
|
|
* @param ntpkt NTTransPacket
|
|
*/
|
|
public SrvTransactBuffer(NTTransPacket ntpkt)
|
|
{
|
|
|
|
// Call the base constructor so that it does not allocate any buffers
|
|
|
|
super(0, 0, 0);
|
|
|
|
// Set the tree id
|
|
|
|
setTreeId(ntpkt.getTreeId());
|
|
|
|
// Set the setup block and size
|
|
|
|
int slen = ntpkt.getSetupCount() * 2;
|
|
if (slen > 0)
|
|
m_setupBuf = new DataBuffer(ntpkt.getBuffer(), ntpkt.getSetupOffset(), slen);
|
|
|
|
// Set the parameter block and size
|
|
|
|
int plen = ntpkt.getTotalParameterCount();
|
|
if (plen > 0)
|
|
m_paramBuf = new DataBuffer(ntpkt.getBuffer(), ntpkt.getParameterBlockOffset(), plen);
|
|
|
|
// Set the data block and size
|
|
|
|
int dlen = ntpkt.getDataBlockCount();
|
|
if (dlen > 0)
|
|
m_dataBuf = new DataBuffer(ntpkt.getBuffer(), ntpkt.getDataBlockOffset(), dlen);
|
|
|
|
// Set the transaction type and sub-function
|
|
|
|
setType(ntpkt.getCommand());
|
|
setFunction(ntpkt.getNTFunction());
|
|
|
|
// Set the maximum parameter and data block lengths to be returned
|
|
|
|
setReturnParameterLimit(ntpkt.getMaximumParameterReturn());
|
|
setReturnDataLimit(ntpkt.getMaximumDataReturn());
|
|
|
|
// Set the Unicode flag
|
|
|
|
setUnicode(ntpkt.isUnicode());
|
|
|
|
// Indicate that this is a not a multi-packet transaction
|
|
|
|
m_multi = false;
|
|
}
|
|
|
|
/**
|
|
* Class constructor
|
|
*
|
|
* @param tpkt SMBSrvTransPacket
|
|
*/
|
|
public SrvTransactBuffer(SMBSrvTransPacket tpkt)
|
|
{
|
|
|
|
// Call the base constructor so that it does not allocate any buffers
|
|
|
|
super(0, 0, 0);
|
|
|
|
// Set the tree id
|
|
|
|
setTreeId(tpkt.getTreeId());
|
|
|
|
// Set the setup block and size
|
|
|
|
int slen = tpkt.getSetupCount() * 2;
|
|
if (slen > 0)
|
|
m_setupBuf = new DataBuffer(tpkt.getBuffer(), tpkt.getSetupOffset(), slen);
|
|
|
|
// Set the parameter block and size
|
|
|
|
int plen = tpkt.getTotalParameterCount();
|
|
if (plen > 0)
|
|
m_paramBuf = new DataBuffer(tpkt.getBuffer(), tpkt.getRxParameterBlock(), plen);
|
|
|
|
// Set the data block and size
|
|
|
|
int dlen = tpkt.getRxDataBlockLength();
|
|
if (dlen > 0)
|
|
m_dataBuf = new DataBuffer(tpkt.getBuffer(), tpkt.getRxDataBlock(), dlen);
|
|
|
|
// Set the transaction type and sub-function
|
|
|
|
setType(tpkt.getCommand());
|
|
|
|
if (tpkt.getSetupCount() > 0)
|
|
setFunction(tpkt.getSetupParameter(0));
|
|
|
|
// Set the Unicode flag
|
|
|
|
setUnicode(tpkt.isUnicode());
|
|
|
|
// Get the transaction name, if used
|
|
|
|
if (isType() == PacketType.Transaction)
|
|
{
|
|
|
|
// Unpack the transaction name string
|
|
|
|
int pos = tpkt.getByteOffset();
|
|
byte[] buf = tpkt.getBuffer();
|
|
|
|
if (isUnicode())
|
|
pos = DataPacker.wordAlign(pos);
|
|
|
|
setName(DataPacker.getString(buf, pos, 64, isUnicode()));
|
|
}
|
|
else
|
|
setName("");
|
|
|
|
// Indicate that this is a not a multi-packet transaction
|
|
|
|
m_multi = false;
|
|
}
|
|
}
|