示例#1
0
        public Byte[] GetAsByteStream()
        {
            Byte[] result = new Byte[Value.Length + 2];

            Byte[] typeCode = ByteHelper.GetBytes((UInt16)Type);
            result[0] = typeCode[0];
            result[1] = typeCode[1];

            for (int i = 0, j = 2; i < Value.Length; i++, j++)
            {
                result[j] = Value[i];
            }

            return(result);
        }
示例#2
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);
        }
示例#3
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));
        }
示例#4
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);
        }