public static UUIDDUID FromByteArray(Byte[] data, Int32 offset) { UInt16 code = ByteHelper.ConvertToUInt16FromByte(data, offset); if (code != (UInt16)DUIDTypes.Uuid) { throw new ArgumentException($"invalid duid type. expected {(UInt16)DUIDTypes.Uuid} actual {code}"); } Guid guid = new Guid(ByteHelper.CopyData(data, offset + 2, 16)); return(new UUIDDUID(guid)); }
public static VendorBasedDUID FromByteArray(Byte[] data, Int32 offset) { UInt16 code = ByteHelper.ConvertToUInt16FromByte(data, offset); if (code != (UInt16)DUIDTypes.VendorBased) { throw new ArgumentException($"invalid duid type. expected {(UInt16)DUIDTypes.VendorBased} actual {code}"); } UInt32 enterpriseNumber = ByteHelper.ConvertToUInt32FromByte(data, offset + 2); Byte[] vendorInformation = ByteHelper.CopyData(data, offset + 6); return(new VendorBasedDUID(enterpriseNumber, vendorInformation)); }
public static LinkLayerAddressDUID FromByteArray(Byte[] data, Int32 offset) { UInt16 code = ByteHelper.ConvertToUInt16FromByte(data, offset); if (code != (UInt16)DUIDTypes.LinkLayer) { throw new ArgumentException($"invalid duid type. expected {(UInt16)DUIDTypes.LinkLayer} actual {code}"); } DUIDLinkLayerTypes linkLayerType = (DUIDLinkLayerTypes)ByteHelper.ConvertToUInt16FromByte(data, offset + 2); Byte[] hwAddress = ByteHelper.CopyData(data, offset + 4); return(new LinkLayerAddressDUID(linkLayerType, hwAddress)); }
public static LinkLayerAddressAndTimeDUID FromByteArray(Byte[] data, Int32 offset) { UInt16 code = ByteHelper.ConvertToUInt16FromByte(data, offset); if (code != (UInt16)DUIDTypes.LinkLayerAndTime) { throw new ArgumentException($"invalid duid type. expected {(UInt16)DUIDTypes.LinkLayerAndTime} actual {code}"); } DUIDLinkLayerTypes linkLayerType = (DUIDLinkLayerTypes)ByteHelper.ConvertToUInt16FromByte(data, offset + 2); UInt32 seconds = ByteHelper.ConvertToUInt32FromByte(data, offset + 4); Byte[] hwAddress = ByteHelper.CopyData(data, offset + 8); DateTime time = _nullReferenceTime + TimeSpan.FromSeconds(seconds); return(new LinkLayerAddressAndTimeDUID(linkLayerType, hwAddress, time, ByteHelper.CopyData(data, offset + 2))); }
public static DUID GetDUID(Byte[] data, Int32 offset) { UInt16 code = ByteHelper.ConvertToUInt16FromByte(data, offset); return(GetDUID(code, ByteHelper.CopyData(data, offset))); }