Exemple #1
0
        internal override IpV6Option CreateInstance(DataSegment data)
        {
            if (data.Length != OptionDataLength)
            {
                return(null);
            }

            IpV4OptionQuickStartFunction function;
            byte rate;
            byte ttl;
            uint nonce;

            IpOptionQuickStartCommon.ReadData(data, out function, out rate, out ttl, out nonce);

            return(new IpV6OptionQuickStart(function, rate, ttl, nonce));
        }
Exemple #2
0
        /// <summary>
        /// Tries to read the option from a buffer starting from the option value (after the type and length).
        /// </summary>
        /// <param name="buffer">The buffer to read the option from.</param>
        /// <param name="offset">The offset to the first byte to read the buffer. Will be incremented by the number of bytes read.</param>
        /// <param name="valueLength">The number of bytes the option value should take according to the length field that was already read.</param>
        /// <returns>On success - the complex option read. On failure - null.</returns>
        Option IOptionComplexFactory.CreateInstance(byte[] buffer, ref int offset, byte valueLength)
        {
            if (valueLength != OptionValueLength)
            {
                return(null);
            }

            IpV4OptionQuickStartFunction function;
            byte rate;
            byte ttl;
            uint nonce;

            IpOptionQuickStartCommon.ReadData(new DataSegment(buffer, offset, valueLength), out function, out rate, out ttl, out nonce);
            offset += OptionValueLength;

            return(new IpV4OptionQuickStart(function, rate, ttl, nonce));
        }
        /// <summary>
        /// Parses an option from the given data.
        /// </summary>
        /// <param name="data">The data to parse.</param>
        /// <returns>The option if parsing was successful, null otherwise.</returns>
        public IpV6Option CreateInstance(DataSegment data)
        {
            if (data == null)
            {
                throw new ArgumentNullException("data");
            }
            if (data.Length != OptionDataLength)
            {
                return(null);
            }

            IpV4OptionQuickStartFunction function;
            byte rate;
            byte ttl;
            uint nonce;

            IpOptionQuickStartCommon.ReadData(data, out function, out rate, out ttl, out nonce);

            return(new IpV6OptionQuickStart(function, rate, ttl, nonce));
        }