/// <summary>
        /// Creates an instance from code, prefix length and address or prefix.
        /// </summary>
        /// <param name="code">Describes the kind of the address or the prefix.</param>
        /// <param name="prefixLength">
        /// Indicates the length of the IPv6 Address Prefix.
        /// The value ranges from 0 to 128.
        /// </param>
        /// <param name="addressOrPrefix">The IP address/prefix defined by the Option-Code field.</param>
        public IpV6MobilityOptionIpV6AddressPrefix(IpV6MobilityIpV6AddressPrefixCode code, byte prefixLength, IpV6Address addressOrPrefix)
            : base(IpV6MobilityOptionType.IpV6AddressPrefix)
        {
            if (prefixLength > MaxPrefixLength)
                throw new ArgumentOutOfRangeException("prefixLength", prefixLength,
                                                      string.Format(CultureInfo.InvariantCulture, "Max value is {0}", MaxPrefixLength));

            Code = code;
            PrefixLength = prefixLength;
            AddressOrPrefix = addressOrPrefix;
        }
示例#2
0
        internal override IpV6MobilityOption CreateInstance(DataSegment data)
        {
            if (data.Length != OptionDataLength)
            {
                return(null);
            }

            IpV6MobilityIpV6AddressPrefixCode code = (IpV6MobilityIpV6AddressPrefixCode)data[Offset.Code];
            byte        prefixLength    = data[Offset.PrefixLength];
            IpV6Address addressOrPrefix = data.ReadIpV6Address(Offset.AddressOrPrefix, Endianity.Big);

            return(new IpV6MobilityOptionIpV6AddressPrefix(code, prefixLength, addressOrPrefix));
        }
示例#3
0
        /// <summary>
        /// Creates an instance from code, prefix length and address or prefix.
        /// </summary>
        /// <param name="code">Describes the kind of the address or the prefix.</param>
        /// <param name="prefixLength">
        /// Indicates the length of the IPv6 Address Prefix.
        /// The value ranges from 0 to 128.
        /// </param>
        /// <param name="addressOrPrefix">The IP address/prefix defined by the Option-Code field.</param>
        public IpV6MobilityOptionIpV6AddressPrefix(IpV6MobilityIpV6AddressPrefixCode code, byte prefixLength, IpV6Address addressOrPrefix)
            : base(IpV6MobilityOptionType.IpV6AddressPrefix)
        {
            if (prefixLength > MaxPrefixLength)
            {
                throw new ArgumentOutOfRangeException("prefixLength", prefixLength,
                                                      string.Format(CultureInfo.InvariantCulture, "Max value is {0}", MaxPrefixLength));
            }

            Code            = code;
            PrefixLength    = prefixLength;
            AddressOrPrefix = addressOrPrefix;
        }