mirror of
https://github.com/TalAloni/SMBLibrary.git
synced 2025-07-21 16:55:54 +02:00
NetBIOS: Minor code refactoring
This commit is contained in:
parent
48c6822454
commit
71e2e4096f
2 changed files with 9 additions and 4 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright (C) 2014-2017 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
|
/* Copyright (C) 2014-2020 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
|
||||||
*
|
*
|
||||||
* You can redistribute this program and/or modify it under the terms of
|
* 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,
|
* the GNU Lesser Public License as published by the Free Software Foundation,
|
||||||
|
@ -43,9 +43,7 @@ namespace SMBLibrary.NetBios
|
||||||
{
|
{
|
||||||
if (!m_packetLength.HasValue)
|
if (!m_packetLength.HasValue)
|
||||||
{
|
{
|
||||||
byte flags = ByteReader.ReadByte(m_buffer, m_readOffset + 1);
|
m_packetLength = SessionPacket.GetSessionPacketLength(m_buffer, m_readOffset);
|
||||||
int trailerLength = (flags & 0x01) << 16 | BigEndianConverter.ToUInt16(m_buffer, m_readOffset + 2);
|
|
||||||
m_packetLength = 4 + trailerLength;
|
|
||||||
}
|
}
|
||||||
return m_bytesInBuffer >= m_packetLength.Value;
|
return m_bytesInBuffer >= m_packetLength.Value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,13 @@ namespace SMBLibrary.NetBios
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int GetSessionPacketLength(byte[] buffer, int offset)
|
||||||
|
{
|
||||||
|
byte flags = ByteReader.ReadByte(buffer, offset + 1);
|
||||||
|
int trailerLength = (flags & 0x01) << 16 | BigEndianConverter.ToUInt16(buffer, offset + 2);
|
||||||
|
return 4 + trailerLength;
|
||||||
|
}
|
||||||
|
|
||||||
public static SessionPacket GetSessionPacket(byte[] buffer, int offset)
|
public static SessionPacket GetSessionPacket(byte[] buffer, int offset)
|
||||||
{
|
{
|
||||||
SessionPacketTypeName type = (SessionPacketTypeName)ByteReader.ReadByte(buffer, offset);
|
SessionPacketTypeName type = (SessionPacketTypeName)ByteReader.ReadByte(buffer, offset);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue