本文整理汇总了C#中Microsoft.Protocols.TestTools.StackSdk.FileAccessService.Cifs.CifsServerPerConnection类的典型用法代码示例。如果您正苦于以下问题:C# CifsServerPerConnection类的具体用法?C# CifsServerPerConnection怎么用?C# CifsServerPerConnection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CifsServerPerConnection类属于Microsoft.Protocols.TestTools.StackSdk.FileAccessService.Cifs命名空间,在下文中一共展示了CifsServerPerConnection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CreateTransWriteNmpipeSuccessResponse
public SmbTransWriteNmpipeSuccessResponsePacket CreateTransWriteNmpipeSuccessResponse(
CifsServerPerConnection connection,
SmbTransWriteNmpipeRequestPacket request)
{
SmbTransWriteNmpipeSuccessResponsePacket response = new SmbTransWriteNmpipeSuccessResponsePacket();
response.SmbHeader = CifsMessageUtils.CreateSmbHeader(connection, request);
TRANS_WRITE_NMPIPE_Response_Trans_Parameters transParameters = response.TransParameters;
transParameters.BytesWritten = (ushort)request.TransData.WriteData.Length;
response.TransParameters = transParameters;
response.UpdateCountAndOffset();
return response;
}
开发者ID:LiuXiaotian,项目名称:WindowsProtocolTestSuites,代码行数:15,代码来源:CifsServer.cs
示例2: UpdateRoleContext
/// <summary>
/// Update the context of cifs server
/// </summary>
/// <param name="connection">The connection between client and server.</param>
/// <param name="packet">The sent or received packet in stack transport.</param>
public virtual void UpdateRoleContext(CifsServerPerConnection connection, SmbPacket packet)
{
if (connection == null || packet == null)
{
return;
}
if (packet is SmbReadRawResponsePacket)
{
if (connection.PendingRequestTable.Count != 1)
{
return;
}
SmbPacket request = connection.PendingRequestTable[0] as SmbPacket;
this.UpdateResponseRoleContext(connection, request, packet);
connection.RemovePendingRequest(request.SmbHeader.Mid);
connection.RemoveSequenceNumber(packet);
return;
}
else
{
switch(packet.PacketType)
{
case SmbPacketType.BatchedRequest:
case SmbPacketType.SingleRequest:
if (connection.IsSigningActive)
{
packet.IsSignatureCorrect = CifsMessageUtils.VerifySignature(packet,
connection.SigningSessionKey, connection.ServerNextReceiveSequenceNumber,
connection.SigningChallengeResponse);
}
this.UpdateRequestRoleConext(connection, packet);
break;
case SmbPacketType.BatchedResponse:
case SmbPacketType.SingleResponse:
SmbPacket request = connection.GetPendingRequest(packet.SmbHeader.Mid);
this.UpdateResponseRoleContext(connection, request, packet);
this.RemoveRequestAndSequence(connection, packet);
break;
default:
break;
}
}
}
开发者ID:LiuXiaotian,项目名称:WindowsProtocolTestSuites,代码行数:49,代码来源:CifsServerContext.cs
示例3: UpdateRequestRoleConext
/// <summary>
/// Update the context when received request.
/// </summary>
/// <param name="connection">The connection between client and server.</param>
/// <param name="requestPacket">The received packet in stack transport.</param>
protected virtual void UpdateRequestRoleConext(
CifsServerPerConnection connection,
SmbPacket requestPacket)
{
if (requestPacket == null)
{
return;
}
bool isAndxPacket = requestPacket.SmbHeader.Protocol == CifsMessageUtils.SMB_PROTOCOL_ANDXPACKET;
if (!isAndxPacket)
{
connection.MultiplexId = requestPacket.SmbHeader.Mid;
}
/*If the UID is valid, the server MUST enumerate all connections in the Server.ConnectionTable and MUST
*look up Session in the Server.Connection.SessionTable where UID is equal to Server.Session.UID.
*If a session is found, Server.Session.IdleTime MUST be set to the current time. If no session is found,
*no action regarding idle time is taken.*/
if (requestPacket.SmbHeader.Uid != 0)
{
foreach (CifsServerPerSession session in connection.SessionTable)
{
if (session.SessionId == requestPacket.SmbHeader.Uid)
{
session.IdleTime = DateTime.Now;
break;
}
}
}
switch (requestPacket.SmbHeader.Command)
{
case SmbCommand.SMB_COM_SESSION_SETUP_ANDX:
{
SmbSessionSetupAndxRequestPacket request = requestPacket as SmbSessionSetupAndxRequestPacket;
connection.SessionSetupReceived = true;
connection.ClientCapabilites = request.SmbParameters.Capabilities;
connection.ClientMaxBufferSize = request.SmbParameters.MaxBufferSize;
connection.ClientMaxMpxCount = request.SmbParameters.MaxMpxCount;
connection.IsSigningActive = false;
connection.NativeLanMan = CifsMessageUtils.ToSmbString(request.SmbData.NativeLanMan, 0, false);
connection.NativeOS = CifsMessageUtils.ToSmbString(request.SmbData.NativeOS, 0, false);
}
break;
default:
break;
}
if (!isAndxPacket
&& requestPacket.SmbHeader.Command != SmbCommand.SMB_COM_TRANSACTION_SECONDARY
&& requestPacket.SmbHeader.Command != SmbCommand.SMB_COM_TRANSACTION2_SECONDARY
&& requestPacket.SmbHeader.Command != SmbCommand.SMB_COM_NT_TRANSACT_SECONDARY
&& requestPacket.SmbHeader.Command != SmbCommand.SMB_COM_NT_CANCEL)
{
connection.AddPendingRequest(requestPacket);
}
if (!isAndxPacket)
{
connection.UpdateSequenceNumber(requestPacket);
}
SmbBatchedRequestPacket batchedRequest = requestPacket as SmbBatchedRequestPacket;
if (batchedRequest != null)
{
SmbPacket andxPacket = batchedRequest.AndxPacket;
this.UpdateRequestRoleConext(connection, andxPacket);
}
}
开发者ID:LiuXiaotian,项目名称:WindowsProtocolTestSuites,代码行数:76,代码来源:CifsServerContext.cs
示例4: CreateFindCloseResponse
public SmbFindCloseResponsePacket CreateFindCloseResponse(
CifsServerPerConnection connection,
SmbFindCloseRequestPacket request)
{
SmbFindCloseResponsePacket response = new SmbFindCloseResponsePacket();
response.SmbHeader = CifsMessageUtils.CreateSmbHeader(connection, request);
SMB_COM_FIND_CLOSE_Response_SMB_Parameters smbParameters = response.SmbParameters;
smbParameters.Count = 0x00;
smbParameters.WordCount = (byte)(TypeMarshal.GetBlockMemorySize(smbParameters) / 2);
response.SmbParameters = smbParameters;
SMB_COM_FIND_CLOSE_Response_SMB_Data smbData = response.SmbData;
smbData.BufferFormat = 0x05;
smbData.DataLength = 0x0000;
smbData.ByteCount = 0x0003;
response.SmbData = smbData;
return response;
}
开发者ID:LiuXiaotian,项目名称:WindowsProtocolTestSuites,代码行数:20,代码来源:CifsServer.cs
示例5: CreateFindUniqueResponse
public SmbFindUniqueResponsePacket CreateFindUniqueResponse(
CifsServerPerConnection connection,
SmbFindUniqueRequestPacket request,
SMB_Directory_Information[] directoryInformationData)
{
directoryInformationData = directoryInformationData ?? new SMB_Directory_Information[0];
SmbFindUniqueResponsePacket response = new SmbFindUniqueResponsePacket();
response.SmbHeader = CifsMessageUtils.CreateSmbHeader(connection, request);
SMB_COM_FIND_UNIQUE_Response_SMB_Parameters smbParameters = response.SmbParameters;
smbParameters.Count = (ushort)directoryInformationData.Length;
smbParameters.WordCount = (byte)(TypeMarshal.GetBlockMemorySize(smbParameters) / 2);
response.SmbParameters = smbParameters;
ushort dataLength = 0;
foreach (SMB_Directory_Information info in directoryInformationData)
{
dataLength += (ushort)TypeMarshal.GetBlockMemorySize(info);
}
SMB_COM_FIND_UNIQUE_Response_SMB_Data smbData = response.SmbData;
smbData.BufferFormat = 0x05;
smbData.DirectoryInformationData = directoryInformationData;
smbData.DataLength = dataLength;
smbData.ByteCount = (ushort)(dataLength + 0x03);
response.SmbData = smbData;
return response;
}
开发者ID:LiuXiaotian,项目名称:WindowsProtocolTestSuites,代码行数:28,代码来源:CifsServer.cs
示例6: CreateDefaultTrans2Response
/// <summary>
/// Create default Trans2 response
/// </summary>
/// <param name="connection">the connection on which the response will be sent.</param>
/// <param name="request">the corresponding request</param>
/// <returns>the default response to the request.</returns>
private SmbPacket CreateDefaultTrans2Response(
CifsServerPerConnection connection,
SmbTransaction2RequestPacket request)
{
SmbTrans2Open2RequestPacket open2Request = request as SmbTrans2Open2RequestPacket;
SmbTrans2FindFirst2RequestPacket findFirst2Request = request as SmbTrans2FindFirst2RequestPacket;
SmbTrans2FindNext2RequestPacket findNext2Request = request as SmbTrans2FindNext2RequestPacket;
SmbTrans2QueryFsInformationRequestPacket queryFsRequest = request as SmbTrans2QueryFsInformationRequestPacket;
SmbTrans2SetFsInformationRequestPacket setFsInfoRequest = request as SmbTrans2SetFsInformationRequestPacket;
SmbTrans2QueryPathInformationRequestPacket queryPathRequest = request as SmbTrans2QueryPathInformationRequestPacket;
SmbTrans2SetPathInformationRequestPacket setPathRequest = request as SmbTrans2SetPathInformationRequestPacket;
SmbTrans2QueryFileInformationRequestPacket queryFileRequest = request as SmbTrans2QueryFileInformationRequestPacket;
SmbTrans2SetFileInformationRequestPacket setFileRequest = request as SmbTrans2SetFileInformationRequestPacket;
SmbTrans2FsctlRequestPacket fsctlRequest = request as SmbTrans2FsctlRequestPacket;
SmbTrans2Ioctl2RequestPacket ioctl2Request = request as SmbTrans2Ioctl2RequestPacket;
SmbTrans2FindNotifyFirstRequestPacket findNotifyFirstRequest = request as SmbTrans2FindNotifyFirstRequestPacket;
SmbTrans2FindNotifyNextRequestPacket findNotifyNextRequest = request as SmbTrans2FindNotifyNextRequestPacket;
SmbTrans2CreateDirectoryRequestPacket createDirRequest = request as SmbTrans2CreateDirectoryRequestPacket;
SmbTrans2SessionSetupRequestPacket sessionSetupRequest = request as SmbTrans2SessionSetupRequestPacket;
SmbTrans2GetDfsReferalRequestPacket getDfsReferalRequest = request as SmbTrans2GetDfsReferalRequestPacket;
SmbTrans2ReportDfsInconsistencyRequestPacket reportDfsRequest = request as SmbTrans2ReportDfsInconsistencyRequestPacket;
SmbPacket response = null;
if (open2Request != null)
{
response = this.CreateTrans2Open2FinalResponse(connection, open2Request, 0x0, FileTypeValue.FileTypeDisk,
SMB_NMPIPE_STATUS.Endpoint, OpenResultsValues.LockStatus);
}
if (findFirst2Request != null)
{
response = this.CreateTrans2FindFirst2FinalResponse(connection, findFirst2Request, 0x0, null);
}
if (findNext2Request != null)
{
response = this.CreateTrans2FindNext2FinalResponse(connection, findNext2Request, 0x0, null);
}
if (queryFsRequest != null)
{
response = this.CreateTrans2QueryFsInformationFinalResponse(connection, queryFsRequest, null);
}
if (setFsInfoRequest != null)
{
response = this.CreateTrans2SetFsInformationFinalResponse(connection, setFsInfoRequest);
}
if (queryPathRequest != null)
{
response = this.CreateTrans2QueryPathInformationFinalResponse(connection, queryPathRequest, null);
}
if (setPathRequest != null)
{
response = this.CreateTrans2SetPathInformationFinalResponse(connection, setPathRequest);
}
if (queryFileRequest != null)
{
response = this.CreateTrans2QueryFileInformationFinalResponse(connection, queryFileRequest, null);
}
if (setFileRequest != null)
{
response = this.CreateTrans2SetFileInformationFinalResponse(connection, setFileRequest);
}
if (fsctlRequest != null)
{
response = this.CreateTrans2FsctlFinalResponse(connection, fsctlRequest);
}
if (ioctl2Request != null)
{
response = this.CreateTrans2Ioctl2FinalResponse(connection, ioctl2Request);
}
if (findNotifyFirstRequest != null)
{
response = this.CreateTrans2FindNotifyFirstFinalResponse(connection, findNotifyFirstRequest);
}
if (findNotifyNextRequest != null)
{
response = this.CreateTrans2FindNotifyNextFinalResponse(connection, findNotifyNextRequest);
}
if (createDirRequest != null)
{
response = this.CreateTrans2CreateDirectoryFinalResponse(connection, createDirRequest);
}
if (sessionSetupRequest != null)
{
response = this.CreateTrans2SessionSetupFinalResponse(connection, sessionSetupRequest);
}
if (getDfsReferalRequest != null)
{
response = this.CreateTrans2GetDfsReferalFinalResponse(connection, getDfsReferalRequest,
new RESP_GET_DFS_REFERRAL());
}
if (reportDfsRequest != null)
{
response = this.CreateTrans2ReportDfsInconsistencyFinalResponse(connection, reportDfsRequest);
}
return response;
}
开发者ID:LiuXiaotian,项目名称:WindowsProtocolTestSuites,代码行数:100,代码来源:CifsServer.cs
示例7: CreateEchoResponse
public SmbEchoResponsePacket CreateEchoResponse(
CifsServerPerConnection connection,
SmbEchoRequestPacket request)
{
SmbEchoResponsePacket response = new SmbEchoResponsePacket();
response.SmbHeader = CifsMessageUtils.CreateSmbHeader(connection, request);
SMB_COM_ECHO_Response_SMB_Parameters smbParameters = response.SmbParameters;
smbParameters.WordCount = 0x01;
//The SMB_Parameters.Words.SequenceNumber field MUST be set to 1.(3.3.5.32)
smbParameters.SequenceNumber = 0x01;
response.SmbParameters = smbParameters;
SMB_COM_ECHO_Response_SMB_Data smbData = response.SmbData;
smbData.ByteCount = request.SmbData.ByteCount;
smbData.Data = request.SmbData.Data;
response.SmbData = smbData;
return response;
}
开发者ID:LiuXiaotian,项目名称:WindowsProtocolTestSuites,代码行数:20,代码来源:CifsServer.cs
示例8: CreateDefaultResponseWithCallBack
public SmbPacket CreateDefaultResponseWithCallBack(
CifsServerPerConnection connection,
SmbPacket request,
CreateDefaultResponseCallBack callBack)
{
if (connection == null || request == null)
{
return null;
}
SmbPacket response = null;
if (callBack != null)
{
response = callBack(connection, request);
}
if (response != null)
{
return response;
}
switch(request.SmbHeader.Command)
{
case SmbCommand.SMB_COM_CREATE_DIRECTORY:
response = this.CreateCreateDirectoryResponse(
connection,
request as SmbCreateDirectoryRequestPacket);
break;
case SmbCommand.SMB_COM_DELETE_DIRECTORY:
response = this.CreateDeleteDirectoryResponse(
connection,
request as SmbDeleteDirectoryRequestPacket);
break;
case SmbCommand.SMB_COM_OPEN:
response = this.CreateOpenResponse(
connection,
request as SmbOpenRequestPacket,
0x0,
0x0);
break;
case SmbCommand.SMB_COM_CREATE:
response = this.CreateCreateResponse(
connection,
request as SmbCreateRequestPacket);
break;
case SmbCommand.SMB_COM_CLOSE:
response = this.CreateCloseResponse(
connection,
request as SmbCloseRequestPacket);
break;
case SmbCommand.SMB_COM_FLUSH:
response = this.CreateFlushResponse(
connection,
request as SmbFlushRequestPacket);
break;
case SmbCommand.SMB_COM_DELETE:
response = this.CreateDeleteResponse(
connection,
request as SmbDeleteRequestPacket);
break;
case SmbCommand.SMB_COM_RENAME:
response = this.CreateRenameResponse(
connection, request as SmbRenameRequestPacket);
break;
case SmbCommand.SMB_COM_QUERY_INFORMATION:
response = this.CreateQueryInformationResponse(
connection,
request as SmbQueryInformationRequestPacket,
SmbFileAttributes.SMB_FILE_ATTRIBUTE_NORMAL,
0x0, 0x0);
break;
case SmbCommand.SMB_COM_SET_INFORMATION:
response = this.CreateSetInformationResponse(
connection, request as SmbSetInformationRequestPacket);
break;
case SmbCommand.SMB_COM_READ:
response = this.CreateReadResponse(
connection,
request as SmbReadRequestPacket, new byte[0]);
break;
case SmbCommand.SMB_COM_WRITE:
response = this.CreateWriteResponse(
connection, request as SmbWriteRequestPacket);
break;
case SmbCommand.SMB_COM_LOCK_byte_RANGE:
response = this.CreateLockByteRangeResponse(
connection, request as SmbLockByteRangeRequestPacket);
break;
case SmbCommand.SMB_COM_UNLOCK_byte_RANGE:
response = this.CreateUnlockByteRangeResponse(
connection, request as SmbUnlockByteRangeRequestPacket);
break;
case SmbCommand.SMB_COM_CREATE_TEMPORARY:
response = this.CreateCreateTemporaryResponse(
connection,
request as SmbCreateTemporaryRequestPacket, "temp");
break;
case SmbCommand.SMB_COM_CREATE_NEW:
response = this.CreateCreateNewResponse(
connection, request as SmbCreateNewRequestPacket);
break;
//.........这里部分代码省略.........
开发者ID:LiuXiaotian,项目名称:WindowsProtocolTestSuites,代码行数:101,代码来源:CifsServer.cs
示例9: CreateWritePrintFileResponse
public SmbWritePrintFileResponsePacket CreateWritePrintFileResponse(
CifsServerPerConnection connection,
SmbWritePrintFileRequestPacket request)
{
SmbWritePrintFileResponsePacket response = new SmbWritePrintFileResponsePacket();
response.SmbHeader = CifsMessageUtils.CreateSmbHeader(connection, request);
return response;
}
开发者ID:LiuXiaotian,项目名称:WindowsProtocolTestSuites,代码行数:9,代码来源:CifsServer.cs
示例10: CreateUnlockByteRangeResponse
public SmbUnlockByteRangeResponsePacket CreateUnlockByteRangeResponse(
CifsServerPerConnection connection,
SmbUnlockByteRangeRequestPacket request)
{
SmbUnlockByteRangeResponsePacket response = new SmbUnlockByteRangeResponsePacket();
response.SmbHeader = CifsMessageUtils.CreateSmbHeader(connection, request);
return response;
}
开发者ID:LiuXiaotian,项目名称:WindowsProtocolTestSuites,代码行数:9,代码来源:CifsServer.cs
示例11: CreateWriteAndxResponse
public SmbWriteAndxResponsePacket CreateWriteAndxResponse(
CifsServerPerConnection connection,
SmbWriteAndxRequestPacket request,
ushort available,
SmbPacket andxPacket)
{
SmbWriteAndxResponsePacket response = new SmbWriteAndxResponsePacket();
response.SmbHeader = CifsMessageUtils.CreateSmbHeader(connection, request);
SMB_COM_WRITE_ANDX_Response_SMB_Parameters smbParameters = response.SmbParameters;
smbParameters.AndXCommand =
andxPacket != null ? andxPacket.SmbHeader.Command : SmbCommand.SMB_COM_NO_ANDX_COMMAND;
smbParameters.AndXOffset = (ushort)(response.HeaderSize + Marshal.SizeOf(response.SmbParameters)
+ Marshal.SizeOf(response.SmbData));
smbParameters.Count = (ushort)request.SmbData.Data.Length;
smbParameters.Available = available;
smbParameters.AndXReserved = 0x00;
smbParameters.WordCount = (byte)(TypeMarshal.GetBlockMemorySize(smbParameters) / 2);
response.SmbParameters = smbParameters;
response.AndxPacket = andxPacket;
response.UpdateHeader();
return response;
}
开发者ID:LiuXiaotian,项目名称:WindowsProtocolTestSuites,代码行数:25,代码来源:CifsServer.cs
示例12: CreateTreeConnectResponse
public SmbTreeConnectResponsePacket CreateTreeConnectResponse(
CifsServerPerConnection connection,
SmbTreeConnectRequestPacket request)
{
SmbTreeConnectResponsePacket response = new SmbTreeConnectResponsePacket();
response.SmbHeader = CifsMessageUtils.CreateSmbHeader(connection, request);
SMB_COM_TREE_CONNECT_Response_SMB_Parameters smbParameters = response.SmbParameters;
smbParameters.MaxBufferSize = (ushort)this.context.MaxBufferSize;
smbParameters.TID = (ushort)connection.GenerateTID();
smbParameters.WordCount = (byte)(TypeMarshal.GetBlockMemorySize(smbParameters) / 2);
response.SmbParameters = smbParameters;
return response;
}
开发者ID:LiuXiaotian,项目名称:WindowsProtocolTestSuites,代码行数:15,代码来源:CifsServer.cs
示例13: CreateDefaultResponse
/// <summary>
/// <para>Create default response based on the request.</para>
/// If the request is a chained andx packet, the corresponding response is also chained.
/// </summary>
/// <param name="connection">the connection on which the response will be sent.</param>
/// <param name="request">the corresponding request</param>
/// <returns>the default response to the request.</returns>
public SmbPacket CreateDefaultResponse(CifsServerPerConnection connection, SmbPacket request)
{
return this.CreateDefaultResponseWithCallBack(connection, request, null);
}
开发者ID:LiuXiaotian,项目名称:WindowsProtocolTestSuites,代码行数:11,代码来源:CifsServer.cs
示例14: CreateTreeConnectAndxResponse
public SmbTreeConnectAndxResponsePacket CreateTreeConnectAndxResponse(
CifsServerPerConnection connection,
SmbTreeConnectAndxRequestPacket request,
OptionalSupport optionalSupport,
string service,
SmbPacket andxPacket)
{
SmbTreeConnectAndxResponsePacket response = new SmbTreeConnectAndxResponsePacket();
SmbHeader smbHeader = CifsMessageUtils.CreateSmbHeader(connection, request);
smbHeader.Tid = connection.GenerateTID();
response.SmbHeader = smbHeader;
bool isUnicode = (response.SmbHeader.Flags2 & SmbFlags2.SMB_FLAGS2_UNICODE) == SmbFlags2.SMB_FLAGS2_UNICODE;
byte[] serviceBytes = CifsMessageUtils.ToSmbStringBytes(service, false);
byte[] fileSystem = CifsMessageUtils.ToSmbStringBytes(CifsMessageUtils.NATIVE_FS, isUnicode);
int padOffset = Marshal.SizeOf(response.SmbParameters) + sizeof(ushort);
SMB_COM_TREE_CONNECT_ANDX_Response_SMB_Data smbData = response.SmbData;
smbData.Pad = new byte[((padOffset + 3) & ~3) - padOffset];
smbData.Service = serviceBytes;
smbData.NativeFileSystem = fileSystem;
smbData.ByteCount = (ushort)(smbData.Pad.Length + smbData.Service.Length
+ smbData.NativeFileSystem.Length);
response.SmbData = smbData;
SMB_COM_TREE_CONNECT_ANDX_Response_SMB_Parameters smbParameters = response.SmbParameters;
smbParameters.AndXCommand =
andxPacket != null ? andxPacket.SmbHeader.Command : SmbCommand.SMB_COM_NO_ANDX_COMMAND;
smbParameters.AndXReserved = 0x00;
smbParameters.AndXOffset = (ushort)(padOffset + response.SmbData.ByteCount);
smbParameters.OptionalSupport = (ushort)optionalSupport;
smbParameters.WordCount = (byte)(TypeMarshal.GetBlockMemorySize(smbParameters) / 2);
response.SmbParameters = smbParameters;
response.AndxPacket = andxPacket;
response.UpdateHeader();
return response;
}
开发者ID:LiuXiaotian,项目名称:WindowsProtocolTestSuites,代码行数:38,代码来源:CifsServer.cs
示例15: SendPacket
/// <summary>
/// Send packet to a specific connected client
/// </summary>
/// <param name="connection">connection to remote client</param>
/// <param name="packet">the smb packet</param>
/// <exception cref="ArgumentNullException">smbPacket</exception>
/// <exception cref="ArgumentNullException">endpoint</exception>
/// <exception cref="InvalidOperationException">
/// The transport is not started. Please invoke Start() first
/// </exception>
public virtual void SendPacket(SmbPacket packet, CifsServerPerConnection connection)
{
if (packet == null)
{
throw new ArgumentNullException("packet");
}
if (connection == null)
{
throw new ArgumentNullException("connection");
}
if (this.isRunning == false)
{
throw new InvalidOperationException(
"The transport is not started. Please invoke Start() first.");
}
if (connection.IsSigningActive
&& (packet as SmbLockingAndxRequestPacket == null)
&& (packet as SmbReadRawResponsePacket == null))
{
packet.Sign(connection.ServerSendSequenceNumbers[packet.SmbHeader.Mid], connection.SigningSessionKey,
connection.SigningChallengeResponse);
}
SmbPacket smbPacket = packet as SmbPacket;
if (smbPacket != null && this.context.IsContextUpdateEnabled
&& (smbPacket as SmbLockingAndxRequestPacket == null))
{
this.context.UpdateRoleContext(connection, smbPacket);
}
// send packet through netbios over Tcp
this.transport.SendPacket(connection.Identity, smbPacket);
}
开发者ID:LiuXiaotian,项目名称:WindowsProtocolTestSuites,代码行数:46,代码来源:CifsServer.cs
示例16: CreateWriteRawFinalResponse
public SmbWriteRawFinalResponsePacket CreateWriteRawFinalResponse(
CifsServerPerConnection connection,
SmbWriteRawRequestPacket request,
ushort count)
{
SmbWriteRawFinalResponsePacket response = new SmbWriteRawFinalResponsePacket();
SmbHeader smbHeader = CifsMessageUtils.CreateSmbHeader(connection, request);
smbHeader.Command = SmbCommand.SMB_COM_WRITE_COMPLETE;
response.SmbHeader = smbHeader;
SMB_COM_WRITE_RAW_FinalResponse_SMB_Parameters smbParameters = response.SmbParameters;
smbParameters.Count = count;
smbParameters.WordCount = (byte)(TypeMarshal.GetBlockMemorySize(smbParameters) / 2);
response.SmbParameters = smbParameters;
return response;
}
开发者ID:LiuXiaotian,项目名称:WindowsProtocolTestSuites,代码行数:17,代码来源:CifsServer.cs
示例17: CreateDefaultNtTransResponse
/// <summary>
/// Create default NtTrans response
/// </summary>
/// <param name="connection">the connection on which the response will be sent.</param>
/// <param name="request">the corresponding request</param>
/// <returns>the default response to the request.</returns>
private SmbPacket CreateDefaultNtTransResponse(
CifsServerPerConnection connection,
SmbNtTransactRequestPacket request)
{
SmbNtTransactCreateRequestPacket ntCreateRequest = request as SmbNtTransactCreateRequestPacket;
SmbNtTransactIoctlRequestPacket ioctlRequest = request as SmbNtTransactIoctlRequestPacket;
SmbNtTransactSetSecurityDescRequestPacket setSecurityDescRequest =
request as SmbNtTransactSetSecurityDescRequestPacket;
SmbNtTransactNotifyChangeRequestPacket notifyChangeRequest =
request as SmbNtTransactNotifyChangeRequestPacket;
SmbNtTransactRenameRequestPacket renameRequest = request as SmbNtTransactRenameRequestPacket;
SmbNtTransactQuerySecurityDescRequestPacket querySecurityDesc =
request as SmbNtTransactQuerySecurityDescRequestPacket;
SmbPacket response = null;
if (ntCreateRequest != null)
{
response = this.CreateNtTransactCreateResponse(
connection,
ntCreateRequest,
0x0,
0x0,
FileTypeValue.FileTypeDisk,
SMB_NMPIPE_STATUS.Endpoint, 0x0);
}
if (ioctlRequest != null)
{
response = this.CreateNtTransactIoctlResponse(connection, ioctlRequest, new byte[0]);
}
if (setSecurityDescRequest != null)
{
response = this.CreateNtTransactSetSecurityDescResponse(connection, setSecurityDescRequest);
}
if (notifyChangeRequest != null)
{
response = this.CreateNtTransactNotifyChangeResponse(connection, notifyChangeRequest, null);
}
if (renameRequest != null)
{
response = this.CreateNtTransactRenameResponse(connection, renameRequest);
}
if (querySecurityDesc != null)
{
response = this.CreateNtTransactQuerySecurityDescResponse(connection, querySecurityDesc, null);
}
return response;
}
开发者ID:LiuXiaotian,项目名称:WindowsProtocolTestSuites,代码行数:57,代码来源:CifsServer.cs
示例18: CreateWriteRawInterimResponse
public SmbWriteRawInterimResponsePacket CreateWriteRawInterimResponse(
CifsServerPerConnection connection,
SmbWriteRawRequestPacket request,
ushort available)
{
SmbWriteRawInterimResponsePacket response = new SmbWriteRawInterimResponsePacket();
response.SmbHeader = CifsMessageUtils.CreateSmbHeader(connection, request);
SMB_COM_WRITE_RAW_InterimResponse_SMB_Parameters smbParameters = response.SmbParameters;
smbParameters.Available = available;
smbParameters.WordCount = (byte)(TypeMarshal.GetBlockMemorySize(smbParameters) / 2);
response.SmbParameters = smbParameters;
return response;
}
开发者ID:LiuXiaotian,项目名称:WindowsProtocolTestSuites,代码行数:15,代码来源:CifsServer.cs
示例19: CreateDefaultTransResponse
/// <summary>
/// Create Trans response
/// </summary>
/// <param name="connection">the connection on which the response will be sent.</param>
/// <param name="request">the corresponding request</param>
/// <returns>the default response to the request.</returns>
private SmbPacket CreateDefaultTransResponse(
CifsServerPerConnection connection,
SmbTransactionRequestPacket request)
{
SmbTransSetNmpipeStateRequestPacket setStateRequest = request as SmbTransSetNmpipeStateRequestPacket;
SmbTransRawReadNmpipeRequestPacket rewReadRequest = request as SmbTransRawReadNmpipeRequestPacket;
SmbTransQueryNmpipeStateRequestPacket queryStateRequest = request as SmbTransQueryNmpipeStateRequestPacket;
SmbTransQueryNmpipeInfoRequestPacket queryInfoRequest = request as SmbTransQueryNmpipeInfoRequestPacket;
SmbTransPeekNmpipeRequestPacket peekStateRequest = request as SmbTransPeekNmpipeRequestPacket;
SmbTransTransactNmpipeRequestPacket transactRequest = request as SmbTransTransactNmpipeRequestPacket;
SmbTransRawWriteNmpipeRequestPacket rawWriteRequest = request as SmbTransRawWriteNmpipeRequestPacket;
SmbTransReadNmpipeRequestPacket readRequest = request as SmbTransReadNmpipeRequestPacket;
SmbTransWriteNmpipeRequestPacket writeRequest = request as SmbTransWriteNmpipeRequestPacket;
SmbTransCallNmpipeRequestPacket callRequest = request as SmbTransCallNmpipeRequestPacket;
SmbTransRapRequestPacket rapRequest = request as SmbTransRapRequestPacket;
SmbPacket response = null;
if (setStateRequest != null)
{
response = this.CreateTransSetNmpipeStateSuccessResponse(connection, setStateRequest);
}
else if (rewReadRequest != null)
{
response = this.CreateTransRawReadNmpipeSuccessResponse(connection, rewReadRequest, new byte[0]);
}
else if (queryStateRequest != null)
{
response = this.CreateTransQueryNmpipeStateSuccessResponse(connection, queryStateRequest,
SMB_NMPIPE_STATUS.Endpoint);
}
else if (queryInfoRequest != null)
{
response = this.CreateTransQueryNmpipeInfoSuccessResponse(connection, queryInfoRequest, 0x0, 0x0, 0x0,
0x0, @"\\Cifs\share");
}
else if (peekStateRequest != null)
{
response = this.CreateTransPeekNmpipeSuccessResponse(connection, peekStateRequest, 0x0, 0x0,
SMB_NMPIPE_STATUS.Endpoint, new byte[0]);
}
else if (transactRequest != null)
{
response = this.CreateTransTransactNmpipeSuccessResponse(connection, transactRequest, new byte[0]);
}
else if (rawWriteRequest != null)
{
response = this.CreateTransRawWriteNmpipeSuccessResponse(connection, rawWriteRequest);
}
else if (readRequest != null)
{
response = this.CreateTransReadNmpipeSuccessResponse(connection, readRequest, new byte[0]);
}
else if (writeRequest != null)
{
response = this.CreateTransWriteNmpipeSuccessResponse(connection, writeRequest);
}
else if (callRequest != null)
{
response = this.CreateTransCallNmpipeSuccessResponse(connection, callRequest, new byte[0]);
}
else if (rapRequest != null)
{
response = new SmbTransRapResponsePacket();
response.SmbHeader = CifsMessageUtils.CreateSmbHeader(connection, request);
}
return response;
}
开发者ID:LiuXiaotian,项目名称:WindowsProtocolTestSuites,代码行数:73,代码来源:CifsServer.cs
示例20: CreateWriteResponse
public SmbWriteResponsePacket CreateWriteResponse(
CifsServerPerConnection connection,
SmbWriteRequestPacket request)
{
SmbWriteResponsePacket response = new SmbWriteResponsePacket();
response.SmbHeader = CifsMessageUtils.CreateSmbHeader(connection, request);
SMB_COM_WRITE_Response_SMB_Parameters smbParameters = response.SmbParameters;
smbParameters.CountOfBytesWritten = request.SmbParameters.CountOfBytesToWrite;
smbParameters.WordCount = (byte)(TypeMarshal.GetBlockMemorySize(smbParameters) / 2);
response.SmbParameters = smbParameters;
return response;
}
|
请发表评论