/* Copyright (C) 2017 Tal Aloni . All rights reserved. * * You can redistribute this program and/or modify it under the terms of * the GNU Lesser Public License as published by the Free Software Foundation, * either version 3 of the License, or (at your option) any later version. */ using System; using System.Collections.Generic; using Utilities; namespace SMBLibrary.SMB2 { /// /// SMB2 TREE_CONNECT Response /// public class TreeConnectResponse : SMB2Command { public const int DeclaredSize = 16; public ushort StructureSize; public ShareType ShareType; public byte Reserved; public ShareFlags ShareFlags; public ShareCapabilities Capabilities; public AccessMask MaximalAccess; public TreeConnectResponse() : base(SMB2CommandName.TreeConnect) { Header.IsResponse = true; StructureSize = DeclaredSize; } public TreeConnectResponse(byte[] buffer, int offset) : base(buffer, offset) { StructureSize = LittleEndianConverter.ToUInt16(buffer, offset + SMB2Header.Length + 0); ShareType = (ShareType)ByteReader.ReadByte(buffer, offset + SMB2Header.Length + 2); Reserved = ByteReader.ReadByte(buffer, offset + SMB2Header.Length + 3); ShareFlags = (ShareFlags)LittleEndianConverter.ToUInt32(buffer, offset + SMB2Header.Length + 4); Capabilities = (ShareCapabilities)LittleEndianConverter.ToUInt32(buffer, offset + SMB2Header.Length + 8); MaximalAccess = new AccessMask(buffer, offset + SMB2Header.Length + 12); } public override void WriteCommandBytes(byte[] buffer, int offset) { LittleEndianWriter.WriteUInt16(buffer, offset + 0, StructureSize); ByteWriter.WriteByte(buffer, offset + 2, (byte)ShareType); ByteWriter.WriteByte(buffer, offset + 3, Reserved); LittleEndianWriter.WriteUInt32(buffer, offset + 4, (uint)ShareFlags); LittleEndianWriter.WriteUInt32(buffer, offset + 8, (uint)Capabilities); MaximalAccess.WriteBytes(buffer, offset + 12); } public override int CommandLength { get { return DeclaredSize; } } } }