示例#1
0
        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));
        }
示例#2
0
        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)));
        }