private LinkLayerAddressAndTimeDUID( DUIDLinkLayerTypes type, Byte[] hwAddress, DateTime time, Byte[] raw) : base(DUIDTypes.LinkLayerAndTime, raw) { LinkType = type; LinkLayerAddress = hwAddress; Time = time; }
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 LinkLayerAddressDUID(DUIDLinkLayerTypes addressType, Byte[] linkLayerAddress) : base( DUIDTypes.LinkLayer, ByteHelper.GetBytes((UInt16)addressType), linkLayerAddress) { if (addressType == DUIDLinkLayerTypes.Ethernet) { if (linkLayerAddress.Length != 6) { throw new ArgumentException("invalid mac address", nameof(linkLayerAddress)); } } AddressType = addressType; LinkLayerAddress = ByteHelper.CopyData(linkLayerAddress); }
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))); }