Przeglądaj źródła

Minor code refactoring

Tal Aloni 5 lat temu
rodzic
commit
20b2a5fb6e

+ 10 - 10
SMBLibrary/Client/SMB1Client.cs

@@ -478,16 +478,7 @@ namespace SMBLibrary.Client
 
         private void ProcessPacket(SessionPacket packet, ConnectionState state)
         {
-            if (packet is SessionKeepAlivePacket && m_transport == SMBTransportType.NetBiosOverTCP)
-            {
-                // [RFC 1001] NetBIOS session keep alives do not require a response from the NetBIOS peer
-            }
-            else if ((packet is PositiveSessionResponsePacket || packet is NegativeSessionResponsePacket) && m_transport == SMBTransportType.NetBiosOverTCP)
-            {
-                m_sessionResponsePacket = packet;
-                m_sessionResponseEventHandle.Set();
-            }
-            else if (packet is SessionMessagePacket)
+            if (packet is SessionMessagePacket)
             {
                 SMB1Message message;
                 try
@@ -515,6 +506,15 @@ namespace SMBLibrary.Client
                     }
                 }
             }
+            else if ((packet is PositiveSessionResponsePacket || packet is NegativeSessionResponsePacket) && m_transport == SMBTransportType.NetBiosOverTCP)
+            {
+                m_sessionResponsePacket = packet;
+                m_sessionResponseEventHandle.Set();
+            }
+            else if (packet is SessionKeepAlivePacket && m_transport == SMBTransportType.NetBiosOverTCP)
+            {
+                // [RFC 1001] NetBIOS session keep alives do not require a response from the NetBIOS peer
+            }
         }
 
         internal SMB1Message WaitForMessage(CommandName commandName)

+ 10 - 10
SMBLibrary/Client/SMB2Client.cs

@@ -373,16 +373,7 @@ namespace SMBLibrary.Client
 
         private void ProcessPacket(SessionPacket packet, ConnectionState state)
         {
-            if (packet is SessionKeepAlivePacket && m_transport == SMBTransportType.NetBiosOverTCP)
-            {
-                // [RFC 1001] NetBIOS session keep alives do not require a response from the NetBIOS peer
-            }
-            else if ((packet is PositiveSessionResponsePacket || packet is NegativeSessionResponsePacket) && m_transport == SMBTransportType.NetBiosOverTCP)
-            {
-                m_sessionResponsePacket = packet;
-                m_sessionResponseEventHandle.Set();
-            }
-            else if (packet is SessionMessagePacket)
+            if (packet is SessionMessagePacket)
             {
                 SMB2Command command;
                 try
@@ -410,6 +401,15 @@ namespace SMBLibrary.Client
                     }
                 }
             }
+            else if ((packet is PositiveSessionResponsePacket || packet is NegativeSessionResponsePacket) && m_transport == SMBTransportType.NetBiosOverTCP)
+            {
+                m_sessionResponsePacket = packet;
+                m_sessionResponseEventHandle.Set();
+            }
+            else if (packet is SessionKeepAlivePacket && m_transport == SMBTransportType.NetBiosOverTCP)
+            {
+                // [RFC 1001] NetBIOS session keep alives do not require a response from the NetBIOS peer
+            }
         }
 
         internal SMB2Command WaitForCommand(SMB2CommandName commandName)

+ 10 - 10
SMBLibrary/Server/SMBServer.cs

@@ -285,16 +285,7 @@ namespace SMBLibrary.Server
 
         private void ProcessPacket(SessionPacket packet, ref ConnectionState state)
         {
-            if (packet is SessionRequestPacket && m_transport == SMBTransportType.NetBiosOverTCP)
-            {
-                PositiveSessionResponsePacket response = new PositiveSessionResponsePacket();
-                state.SendQueue.Enqueue(response);
-            }
-            else if (packet is SessionKeepAlivePacket && m_transport == SMBTransportType.NetBiosOverTCP)
-            {
-                // [RFC 1001] NetBIOS session keep alives do not require a response from the NetBIOS peer
-            }
-            else if (packet is SessionMessagePacket)
+            if (packet is SessionMessagePacket)
             {
                 // Note: To be compatible with SMB2 specifications, we must accept SMB_COM_NEGOTIATE.
                 // We will disconnect the connection if m_enableSMB1 == false and the client does not support SMB2.
@@ -380,6 +371,15 @@ namespace SMBLibrary.Server
                     state.ClientSocket.Close();
                 }
             }
+            else if (packet is SessionRequestPacket && m_transport == SMBTransportType.NetBiosOverTCP)
+            {
+                PositiveSessionResponsePacket response = new PositiveSessionResponsePacket();
+                state.SendQueue.Enqueue(response);
+            }
+            else if (packet is SessionKeepAlivePacket && m_transport == SMBTransportType.NetBiosOverTCP)
+            {
+                // [RFC 1001] NetBIOS session keep alives do not require a response from the NetBIOS peer
+            }
             else
             {
                 state.LogToServer(Severity.Warning, "Invalid NetBIOS packet");