/// <summary> /// Deep copy constructor. /// </summary> public Connection(Connection connection) { if (connection != null) { this.GlobalIndex = connection.GlobalIndex; this.ConnectionId = connection.ConnectionId; this.sessionTable = new Collection<Session>(); foreach (Session session in connection.sessionTable) { this.sessionTable.Add(new Session(session)); } this.CommandSequenceWindow = new Collection<MessageIdStatus>(); foreach (MessageIdStatus messageIdStatus in connection.CommandSequenceWindow) { this.CommandSequenceWindow.Add(new MessageIdStatus(messageIdStatus)); } this.RequestList = new Dictionary<ulong, StackPacket>(); foreach (KeyValuePair<ulong, StackPacket> request in connection.RequestList) { this.RequestList.Add(request.Key, request.Value.Clone()); } this.ClientCapabilities = connection.ClientCapabilities; this.NegotiateReceived = connection.NegotiateReceived; } else { this.GlobalIndex = 0; this.ConnectionId = 0; this.sessionTable = new Collection<Session>(); this.CommandSequenceWindow = new Collection<MessageIdStatus>(); this.RequestList = new Dictionary<ulong, StackPacket>(); this.ClientCapabilities = 0; this.NegotiateReceived = false; } }
/// <summary> /// this function will be invoked every time a packet is sent or received. all logics about /// Client' states will be implemented here. /// response packet update the context, do regular transaction. /// </summary> /// <param name="connection">the connection object.</param> /// <param name="packet">the sent or received packet in stack transport.</param> protected virtual void ResponsePacketUpdateRoleContextRegular(Connection connection, SmbPacket packet) { int connectionId = connection.ConnectionId; #region RemoveOutstandingRequest if (packet.SmbHeader.Status != 0 ||!(packet is SmbTransactionInterimResponsePacket || packet is SmbTransaction2InterimResponsePacket || packet is SmbNtTransactInterimResponsePacket || packet is SmbWriteRawInterimResponsePacket)) { this.RemoveOutstandingRequest(connectionId, (ulong)packet.SmbHeader.Mid); } #endregion #region RemoveSequenceNumber this.RemoveSequenceNumber(connectionId, packet); #endregion }