コード例 #1
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)));
        }
コード例 #2
0
        public static LinkLayerAddressAndTimeDUID FromEthernet(
            Byte[] hwAddress, DateTime time)
        {
            if (time < _nullReferenceTime)
            {
                throw new ArgumentException($"the time value must greater than {_nullReferenceTime}", nameof(time));
            }

            if (hwAddress.Length != 6)
            {
                throw new ArgumentException("invalid mac address", nameof(hwAddress));
            }

            Byte[] duidTypeByte = ByteHelper.GetBytes((UInt16)DUIDTypes.LinkLayerAndTime);
            Byte[] hwTypeByte   = ByteHelper.GetBytes((UInt16)DUIDLinkLayerTypes.Ethernet);
            Byte[] timeByte     = ByteHelper.GetBytes((UInt32)((time - _nullReferenceTime).TotalSeconds));

            Byte[] concat = ByteHelper.ConcatBytes(
                new List <Byte[]> {
                duidTypeByte, hwTypeByte, timeByte, hwAddress
            });

            return(FromByteArray(concat, 0));
        }
コード例 #3
0
        public VendorBasedDUID(UInt32 enterpiseNumber, Byte[] vendorInformation) : base(DUIDTypes.VendorBased,
                                                                                        ByteHelper.GetBytes(enterpiseNumber),
                                                                                        vendorInformation)
        {
            EnterpriseNumber = enterpiseNumber;
            if (vendorInformation == null || vendorInformation.Length == 0)
            {
                throw new ArgumentNullException(nameof(vendorInformation));
            }

            Identifier = ByteHelper.CopyData(vendorInformation);
        }
コード例 #4
0
 public static UnknownDUID FromByteArray(Byte[] data, Int32 offset)
 {
     //UInt16 code = ByteHelper.ConvertToUInt16FromByte(data, offset);
     return(new UnknownDUID(ByteHelper.CopyData(data, offset + 2)));
 }
コード例 #5
0
        public static DUID GetDUID(Byte[] data, Int32 offset)
        {
            UInt16 code = ByteHelper.ConvertToUInt16FromByte(data, offset);

            return(GetDUID(code, ByteHelper.CopyData(data, offset)));
        }
コード例 #6
0
 protected DUID(DUIDTypes type, params Byte[][] data)
 {
     Type  = type;
     Value = ByteHelper.ConcatBytes(data);
 }