ConnectionState: Renamed ServerDialect to Dialect

This commit is contained in:
Tal Aloni 2017-03-04 11:26:49 +02:00
parent 054d537c26
commit 3325d1842f
5 changed files with 14 additions and 14 deletions

View file

@ -21,14 +21,14 @@ namespace SMBLibrary.Server
public IPEndPoint ClientEndPoint; public IPEndPoint ClientEndPoint;
public NBTConnectionReceiveBuffer ReceiveBuffer; public NBTConnectionReceiveBuffer ReceiveBuffer;
protected LogDelegate LogToServerHandler; protected LogDelegate LogToServerHandler;
public SMBDialect ServerDialect; public SMBDialect Dialect;
public object AuthenticationContext; public object AuthenticationContext;
public ConnectionState(LogDelegate logToServerHandler) public ConnectionState(LogDelegate logToServerHandler)
{ {
ReceiveBuffer = new NBTConnectionReceiveBuffer(); ReceiveBuffer = new NBTConnectionReceiveBuffer();
LogToServerHandler = logToServerHandler; LogToServerHandler = logToServerHandler;
ServerDialect = SMBDialect.NotSet; Dialect = SMBDialect.NotSet;
} }
public ConnectionState(ConnectionState state) public ConnectionState(ConnectionState state)
@ -37,7 +37,7 @@ namespace SMBLibrary.Server
ClientEndPoint = state.ClientEndPoint; ClientEndPoint = state.ClientEndPoint;
ReceiveBuffer = state.ReceiveBuffer; ReceiveBuffer = state.ReceiveBuffer;
LogToServerHandler = state.LogToServerHandler; LogToServerHandler = state.LogToServerHandler;
ServerDialect = state.ServerDialect; Dialect = state.Dialect;
} }
public void LogToServer(Severity severity, string message) public void LogToServer(Severity severity, string message)

View file

@ -32,7 +32,7 @@ namespace SMBLibrary.Server.SMB2
} }
else if (smb2Dialects.Contains(SMB2002Dialect)) else if (smb2Dialects.Contains(SMB2002Dialect))
{ {
state.ServerDialect = SMBDialect.SMB202; state.Dialect = SMBDialect.SMB202;
response.DialectRevision = SMB2Dialect.SMB202; response.DialectRevision = SMB2Dialect.SMB202;
} }
else else
@ -55,12 +55,12 @@ namespace SMBLibrary.Server.SMB2
NegotiateResponse response = new NegotiateResponse(); NegotiateResponse response = new NegotiateResponse();
if (request.Dialects.Contains(SMB2Dialect.SMB210)) if (request.Dialects.Contains(SMB2Dialect.SMB210))
{ {
state.ServerDialect = SMBDialect.SMB210; state.Dialect = SMBDialect.SMB210;
response.DialectRevision = SMB2Dialect.SMB210; response.DialectRevision = SMB2Dialect.SMB210;
} }
else if (request.Dialects.Contains(SMB2Dialect.SMB202)) else if (request.Dialects.Contains(SMB2Dialect.SMB202))
{ {
state.ServerDialect = SMBDialect.SMB202; state.Dialect = SMBDialect.SMB202;
response.DialectRevision = SMB2Dialect.SMB202; response.DialectRevision = SMB2Dialect.SMB202;
} }
else else

View file

@ -67,7 +67,7 @@ namespace SMBLibrary.Server
/// </summary> /// </summary>
private List<SMB1Command> ProcessSMB1Command(SMB1Header header, SMB1Command command, ref ConnectionState state) private List<SMB1Command> ProcessSMB1Command(SMB1Header header, SMB1Command command, ref ConnectionState state)
{ {
if (state.ServerDialect == SMBDialect.NotSet) if (state.Dialect == SMBDialect.NotSet)
{ {
if (command is NegotiateRequest) if (command is NegotiateRequest)
{ {
@ -75,7 +75,7 @@ namespace SMBLibrary.Server
if (request.Dialects.Contains(SMBServer.NTLanManagerDialect)) if (request.Dialects.Contains(SMBServer.NTLanManagerDialect))
{ {
state = new SMB1ConnectionState(state); state = new SMB1ConnectionState(state);
state.ServerDialect = SMBDialect.NTLM012; state.Dialect = SMBDialect.NTLM012;
if (EnableExtendedSecurity && header.ExtendedSecurityFlag) if (EnableExtendedSecurity && header.ExtendedSecurityFlag)
{ {
return NegotiateHelper.GetNegotiateResponseExtended(request, m_serverGuid); return NegotiateHelper.GetNegotiateResponseExtended(request, m_serverGuid);

View file

@ -69,13 +69,13 @@ namespace SMBLibrary.Server
/// </summary> /// </summary>
private SMB2Command ProcessSMB2Command(SMB2Command command, ref ConnectionState state) private SMB2Command ProcessSMB2Command(SMB2Command command, ref ConnectionState state)
{ {
if (state.ServerDialect == SMBDialect.NotSet) if (state.Dialect == SMBDialect.NotSet)
{ {
if (command is NegotiateRequest) if (command is NegotiateRequest)
{ {
NegotiateRequest request = (NegotiateRequest)command; NegotiateRequest request = (NegotiateRequest)command;
SMB2Command response = NegotiateHelper.GetNegotiateResponse(request, m_securityProvider, state, m_serverGuid, m_serverStartTime); SMB2Command response = NegotiateHelper.GetNegotiateResponse(request, m_securityProvider, state, m_serverGuid, m_serverStartTime);
if (state.ServerDialect != SMBDialect.NotSet) if (state.Dialect != SMBDialect.NotSet)
{ {
state = new SMB2ConnectionState(state, AllocatePersistentFileID); state = new SMB2ConnectionState(state, AllocatePersistentFileID);
} }

View file

@ -222,8 +222,8 @@ namespace SMBLibrary.Server
{ {
// Note: To be compatible with SMB2 specifications, we must accept SMB_COM_NEGOTIATE. // 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. // We will disconnect the connection if m_enableSMB1 == false and the client does not support SMB2.
bool acceptSMB1 = (state.ServerDialect == SMBDialect.NotSet || state.ServerDialect == SMBDialect.NTLM012); bool acceptSMB1 = (state.Dialect == SMBDialect.NotSet || state.Dialect == SMBDialect.NTLM012);
bool acceptSMB2 = (m_enableSMB2 && (state.ServerDialect == SMBDialect.NotSet || state.ServerDialect == SMBDialect.SMB202 || state.ServerDialect == SMBDialect.SMB210)); bool acceptSMB2 = (m_enableSMB2 && (state.Dialect == SMBDialect.NotSet || state.Dialect == SMBDialect.SMB202 || state.Dialect == SMBDialect.SMB210));
if (SMB1Header.IsValidSMB1Header(packet.Trailer)) if (SMB1Header.IsValidSMB1Header(packet.Trailer))
{ {
@ -246,14 +246,14 @@ namespace SMBLibrary.Server
return; return;
} }
state.LogToServer(Severity.Verbose, "SMB1 message received: {0} requests, First request: {1}, Packet length: {2}", message.Commands.Count, message.Commands[0].CommandName.ToString(), packet.Length); state.LogToServer(Severity.Verbose, "SMB1 message received: {0} requests, First request: {1}, Packet length: {2}", message.Commands.Count, message.Commands[0].CommandName.ToString(), packet.Length);
if (state.ServerDialect == SMBDialect.NotSet && m_enableSMB2) if (state.Dialect == SMBDialect.NotSet && m_enableSMB2)
{ {
// Check if the client supports SMB 2 // Check if the client supports SMB 2
List<string> smb2Dialects = SMB2.NegotiateHelper.FindSMB2Dialects(message); List<string> smb2Dialects = SMB2.NegotiateHelper.FindSMB2Dialects(message);
if (smb2Dialects.Count > 0) if (smb2Dialects.Count > 0)
{ {
SMB2Command response = SMB2.NegotiateHelper.GetNegotiateResponse(smb2Dialects, m_securityProvider, state, m_serverGuid, m_serverStartTime); SMB2Command response = SMB2.NegotiateHelper.GetNegotiateResponse(smb2Dialects, m_securityProvider, state, m_serverGuid, m_serverStartTime);
if (state.ServerDialect != SMBDialect.NotSet) if (state.Dialect != SMBDialect.NotSet)
{ {
state = new SMB2ConnectionState(state, AllocatePersistentFileID); state = new SMB2ConnectionState(state, AllocatePersistentFileID);
} }