diff --git a/SMBLibrary/SMBLibrary.csproj b/SMBLibrary/SMBLibrary.csproj index 1aa19e5..dae5507 100644 --- a/SMBLibrary/SMBLibrary.csproj +++ b/SMBLibrary/SMBLibrary.csproj @@ -103,6 +103,7 @@ + diff --git a/SMBLibrary/Server/ConnectionState/ConnectionState.cs b/SMBLibrary/Server/ConnectionState/ConnectionState.cs new file mode 100644 index 0000000..2b791f8 --- /dev/null +++ b/SMBLibrary/Server/ConnectionState/ConnectionState.cs @@ -0,0 +1,31 @@ +/* Copyright (C) 2014-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 System.Net.Sockets; +using SMBLibrary.NetBios; +using Utilities; + +namespace SMBLibrary.Server +{ + public class ConnectionState + { + public Socket ClientSocket; + public NBTConnectionReceiveBuffer ReceiveBuffer; + + public ConnectionState() + { + ReceiveBuffer = new NBTConnectionReceiveBuffer(); + } + + public ConnectionState(ConnectionState state) + { + ClientSocket = state.ClientSocket; + ReceiveBuffer = state.ReceiveBuffer; + } + } +} diff --git a/SMBLibrary/Server/ConnectionState/SMB1ConnectionState.cs b/SMBLibrary/Server/ConnectionState/SMB1ConnectionState.cs index 2087afe..8e08da3 100644 --- a/SMBLibrary/Server/ConnectionState/SMB1ConnectionState.cs +++ b/SMBLibrary/Server/ConnectionState/SMB1ConnectionState.cs @@ -7,17 +7,12 @@ using System; using System.Collections.Generic; using System.IO; -using System.Net.Sockets; -using SMBLibrary.NetBios; using Utilities; namespace SMBLibrary.Server { - public class SMB1ConnectionState + public class SMB1ConnectionState : ConnectionState { - public Socket ClientSocket = null; - public NBTConnectionReceiveBuffer ReceiveBuffer = new NBTConnectionReceiveBuffer(); - public int MaxBufferSize; public bool LargeRead; public bool LargeWrite; @@ -35,13 +30,17 @@ namespace SMBLibrary.Server private ushort m_nextFID = 1; // Key is FID private Dictionary m_namedPipeResponse = new Dictionary(); - + // Key is PID public Dictionary ProcessStateList = new Dictionary(); public const int MaxSearches = 2048; // Windows servers initialize Server.MaxSearches to 2048. public Dictionary> OpenSearches = new Dictionary>(); private ushort m_nextSearchHandle = 1; + public SMB1ConnectionState(ConnectionState state) : base(state) + { + } + /// /// An open UID MUST be unique within an SMB connection. /// The value of 0xFFFE SHOULD NOT be used as a valid UID. All other possible values for a UID, excluding zero (0x0000), are valid. diff --git a/SMBLibrary/Server/SMBServer.cs b/SMBLibrary/Server/SMBServer.cs index 24cb4b8..25a1372 100644 --- a/SMBLibrary/Server/SMBServer.cs +++ b/SMBLibrary/Server/SMBServer.cs @@ -92,7 +92,7 @@ namespace SMBLibrary.Server return; } - SMB1ConnectionState state = new SMB1ConnectionState(); + SMB1ConnectionState state = new SMB1ConnectionState(new ConnectionState()); // Disable the Nagle Algorithm for this tcp socket: clientSocket.NoDelay = true; state.ClientSocket = clientSocket;