From 02242a9bdf67908cd129ee6d3f94c2bd38b9cf88 Mon Sep 17 00:00:00 2001 From: Shreyas Zare Date: Sat, 30 Apr 2022 12:01:48 +0530 Subject: [PATCH] ClientIdentifierOption: implemented Parse() and ToString() helper methods. --- .../Dhcp/Options/ClientIdentifierOption.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/DnsServerCore/Dhcp/Options/ClientIdentifierOption.cs b/DnsServerCore/Dhcp/Options/ClientIdentifierOption.cs index 8667bace..07bd965e 100644 --- a/DnsServerCore/Dhcp/Options/ClientIdentifierOption.cs +++ b/DnsServerCore/Dhcp/Options/ClientIdentifierOption.cs @@ -1,6 +1,6 @@ /* Technitium DNS Server -Copyright (C) 2021 Shreyas Zare (shreyas@technitium.com) +Copyright (C) 2022 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 @@ -47,6 +47,16 @@ namespace DnsServerCore.Dhcp.Options #endregion + #region static + + public static ClientIdentifierOption Parse(string clientIdentifier) + { + string[] parts = clientIdentifier.Split('-'); + return new ClientIdentifierOption(byte.Parse(parts[0]), Convert.FromHexString(parts[1])); + } + + #endregion + #region protected protected override void ParseOptionValue(Stream s) @@ -111,6 +121,11 @@ namespace DnsServerCore.Dhcp.Options return hashCode; } + public override string ToString() + { + return _type.ToString() + "-" + Convert.ToHexString(_identifier); + } + #endregion #region properties