From 28fa346b5b33844a18e5c40ee368d39a06660c20 Mon Sep 17 00:00:00 2001 From: Tal Aloni Date: Sat, 25 Jan 2020 21:03:28 +0200 Subject: [PATCH] NetBiosUtils: Added GetSuffixFromMSNetBiosName method --- SMBLibrary/NetBios/NetBiosUtils.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/SMBLibrary/NetBios/NetBiosUtils.cs b/SMBLibrary/NetBios/NetBiosUtils.cs index 1553bf8..67fb9b1 100644 --- a/SMBLibrary/NetBios/NetBiosUtils.cs +++ b/SMBLibrary/NetBios/NetBiosUtils.cs @@ -1,4 +1,4 @@ -/* Copyright (C) 2014 Tal Aloni . All rights reserved. +/* Copyright (C) 2014-2020 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, @@ -44,6 +44,16 @@ namespace SMBLibrary.NetBios return netBiosName.TrimEnd(' '); } + public static NetBiosSuffix GetSuffixFromMSNetBiosName(string netBiosName) + { + if (netBiosName.Length != 16) + { + throw new ArgumentException("Invalid MS NetBIOS name"); + } + + return (NetBiosSuffix)netBiosName[15]; + } + public static byte[] EncodeName(string name, NetBiosSuffix suffix, string scopeID) { string netBiosName = GetMSNetBiosName(name, suffix);