diff --git a/DnsServerCore/Dhcp/DhcpOption.cs b/DnsServerCore/Dhcp/DhcpOption.cs index 8792de38..37c5c017 100644 --- a/DnsServerCore/Dhcp/DhcpOption.cs +++ b/DnsServerCore/Dhcp/DhcpOption.cs @@ -1,6 +1,6 @@ /* Technitium DNS Server -Copyright (C) 2022 Shreyas Zare (shreyas@technitium.com) +Copyright (C) 2023 Shreyas Zare (shreyas@technitium.com) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -19,8 +19,8 @@ along with this program. If not, see . using DnsServerCore.Dhcp.Options; using System; -using System.Globalization; using System.IO; +using TechnitiumLibrary; using TechnitiumLibrary.IO; namespace DnsServerCore.Dhcp @@ -129,7 +129,7 @@ namespace DnsServerCore.Dhcp _code = code; if (hexValue.Contains(':')) - _value = ParseColonHexString(hexValue); + _value = hexValue.ParseColonHexString(); else _value = Convert.FromHexString(hexValue); } @@ -260,38 +260,6 @@ namespace DnsServerCore.Dhcp } } - protected static byte[] ParseColonHexString(string value) - { - int i; - int j = -1; - string strHex; - int b; - - using (MemoryStream mS = new MemoryStream()) - { - while (true) - { - i = value.IndexOf(':', j + 1); - if (i < 0) - i = value.Length; - - strHex = value.Substring(j + 1, i - j - 1); - - if (!int.TryParse(strHex, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out b) || (b < byte.MinValue) || (b > byte.MaxValue)) - throw new InvalidDataException("VendorSpecificInformation option data must be a colon (:) separated hex string."); - - mS.WriteByte((byte)b); - - if (i == value.Length) - break; - - j = i; - } - - return mS.ToArray(); - } - } - #endregion #region internal