mirror of
https://github.com/TalAloni/SMBLibrary.git
synced 2025-04-30 10:47:48 +02:00
NetBIOS name service packets implementation refactoring
This commit is contained in:
parent
9d8ee88f1e
commit
dd8e867693
5 changed files with 23 additions and 17 deletions
|
@ -1,3 +1,9 @@
|
|||
/* Copyright (C) 2014-2017 Tal Aloni <tal.aloni.il@gmail.com>. 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.Text;
|
||||
|
@ -19,17 +25,14 @@ namespace SMBLibrary.NetBios
|
|||
public OwnerNodeType NodeType;
|
||||
public bool WorkGroup;
|
||||
|
||||
public ushort Value
|
||||
public static explicit operator ushort(NameFlags nameFlags)
|
||||
{
|
||||
get
|
||||
{
|
||||
ushort value = (ushort)(((byte)NodeType) << 13);
|
||||
if (WorkGroup)
|
||||
ushort value = (ushort)(((byte)nameFlags.NodeType) << 13);
|
||||
if (nameFlags.WorkGroup)
|
||||
{
|
||||
value |= 0x8000;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2014 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
|
||||
/* Copyright (C) 2014-2017 Tal Aloni <tal.aloni.il@gmail.com>. 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,
|
||||
|
@ -58,7 +58,7 @@ namespace SMBLibrary.NetBios
|
|||
public byte[] GetData()
|
||||
{
|
||||
byte[] data = new byte[DataLength];
|
||||
BigEndianWriter.WriteUInt16(data, 0, NameFlags.Value);
|
||||
BigEndianWriter.WriteUInt16(data, 0, (ushort)NameFlags);
|
||||
ByteWriter.WriteBytes(data, 2, Address, 4);
|
||||
return data;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
/* Copyright (C) 2014 Tal Aloni <tal.aloni.il@gmail.com>. 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.IO;
|
||||
|
@ -55,7 +61,6 @@ namespace SMBLibrary.NetBios
|
|||
BigEndianWriter.WriteUInt16(stream, ANCount);
|
||||
BigEndianWriter.WriteUInt16(stream, NSCount);
|
||||
BigEndianWriter.WriteUInt16(stream, ARCount);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2014 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
|
||||
/* Copyright (C) 2014-2017 Tal Aloni <tal.aloni.il@gmail.com>. 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,
|
||||
|
@ -51,9 +51,7 @@ namespace SMBLibrary.NetBios
|
|||
foreach (KeyValuePair<string, NameFlags> entry in Names)
|
||||
{
|
||||
ByteWriter.WriteAnsiString(stream, entry.Key);
|
||||
//byte[] encodedName = NetBiosUtils.EncodeName(entry.Key, String.Empty);
|
||||
//ByteWriter.WriteBytes(stream, encodedName);
|
||||
BigEndianWriter.WriteUInt16(stream, entry.Value.Value);
|
||||
BigEndianWriter.WriteUInt16(stream, (ushort)entry.Value);
|
||||
}
|
||||
|
||||
ByteWriter.WriteBytes(stream, Statistics.GetBytes());
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2014 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
|
||||
/* Copyright (C) 2014-2017 Tal Aloni <tal.aloni.il@gmail.com>. 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,
|
||||
|
@ -48,7 +48,7 @@ namespace SMBLibrary.NetBios
|
|||
int offset = 0;
|
||||
foreach (KeyValuePair<byte[], NameFlags> entry in Addresses)
|
||||
{
|
||||
BigEndianWriter.WriteUInt16(data, ref offset, entry.Value.Value);
|
||||
BigEndianWriter.WriteUInt16(data, ref offset, (ushort)entry.Value);
|
||||
ByteWriter.WriteBytes(data, ref offset, entry.Key, 4);
|
||||
}
|
||||
return data;
|
||||
|
|
Loading…
Add table
Reference in a new issue