diff --git a/SMBLibrary/NetBios/NameServicePackets/EnumStructures/NameFlags.cs b/SMBLibrary/NetBios/NameServicePackets/EnumStructures/NameFlags.cs index cc9e6fe..211536d 100644 --- a/SMBLibrary/NetBios/NameServicePackets/EnumStructures/NameFlags.cs +++ b/SMBLibrary/NetBios/NameServicePackets/EnumStructures/NameFlags.cs @@ -1,3 +1,9 @@ +/* Copyright (C) 2014-2017 Tal Aloni . 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)nameFlags.NodeType) << 13); + if (nameFlags.WorkGroup) { - ushort value = (ushort)(((byte)NodeType) << 13); - if (WorkGroup) - { - value |= 0x8000; - } - return value; + value |= 0x8000; } + return value; } } } diff --git a/SMBLibrary/NetBios/NameServicePackets/NameRegistrationRequest.cs b/SMBLibrary/NetBios/NameServicePackets/NameRegistrationRequest.cs index 866453d..ce74768 100644 --- a/SMBLibrary/NetBios/NameServicePackets/NameRegistrationRequest.cs +++ b/SMBLibrary/NetBios/NameServicePackets/NameRegistrationRequest.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2014 Tal Aloni . All rights reserved. +/* Copyright (C) 2014-2017 Tal Aloni . 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; } diff --git a/SMBLibrary/NetBios/NameServicePackets/NameServicePacketHeader.cs b/SMBLibrary/NetBios/NameServicePackets/NameServicePacketHeader.cs index 8127b18..66cdb58 100644 --- a/SMBLibrary/NetBios/NameServicePackets/NameServicePacketHeader.cs +++ b/SMBLibrary/NetBios/NameServicePackets/NameServicePacketHeader.cs @@ -1,3 +1,9 @@ +/* Copyright (C) 2014 Tal Aloni . 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); - } } } diff --git a/SMBLibrary/NetBios/NameServicePackets/NodeStatusResponse.cs b/SMBLibrary/NetBios/NameServicePackets/NodeStatusResponse.cs index ca86251..42cda49 100644 --- a/SMBLibrary/NetBios/NameServicePackets/NodeStatusResponse.cs +++ b/SMBLibrary/NetBios/NameServicePackets/NodeStatusResponse.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2014 Tal Aloni . All rights reserved. +/* Copyright (C) 2014-2017 Tal Aloni . 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 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()); diff --git a/SMBLibrary/NetBios/NameServicePackets/PositiveNameQueryResponse.cs b/SMBLibrary/NetBios/NameServicePackets/PositiveNameQueryResponse.cs index 70cb79c..0249036 100644 --- a/SMBLibrary/NetBios/NameServicePackets/PositiveNameQueryResponse.cs +++ b/SMBLibrary/NetBios/NameServicePackets/PositiveNameQueryResponse.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2014 Tal Aloni . All rights reserved. +/* Copyright (C) 2014-2017 Tal Aloni . 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 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;