Example #1
0
 private LinkLayerAddressAndTimeDUID(
     DUIDLinkLayerTypes type,
     Byte[] hwAddress,
     DateTime time, Byte[] raw) : base(DUIDTypes.LinkLayerAndTime, raw)
 {
     LinkType         = type;
     LinkLayerAddress = hwAddress;
     Time             = time;
 }
Example #2
0
        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));
        }
Example #3
0
        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);
        }
Example #4
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)));
        }