public IpV6OptionQuickStart(IpV4OptionQuickStartFunction function, byte rate, byte ttl, uint nonce) : base(IpV6OptionType.QuickStart) { IpOptionQuickStartCommon.AssertValidParameters(function, rate, ttl, nonce); Function = function; Rate = rate; Ttl = ttl; Nonce = nonce; }
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)); }
/// <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)); }
internal override void WriteData(byte[] buffer, ref int offset) { IpOptionQuickStartCommon.WriteData(buffer, ref offset, Function, Rate, Ttl, Nonce); }