Commit 3cdc9cdb authored by Brickner_cp's avatar Brickner_cp

544 warnings left.

parent 541b67a5
......@@ -49,7 +49,7 @@ namespace PcapDotNet.Packets.Ip
if (rate == 0)
return 0;
return 40*(1 << rate);
return 40 * (1 << rate);
}
internal static void ReadData(DataSegment data, out IpV4OptionQuickStartFunction function, out byte rate, out byte ttl, out uint nonce)
......
......@@ -22,6 +22,21 @@ namespace PcapDotNet.Packets.IpV6
/// </summary>
public sealed class IpV6ExtensionHeaderMobilityExperimental : IpV6ExtensionHeaderMobility
{
/// <summary>
/// Creates an instance from next header, checksum and message data.
/// </summary>
/// <param name="nextHeader">
/// Identifies the type of header immediately following this extension header.
/// </param>
/// <param name="checksum">
/// Contains the checksum of the Mobility Header.
/// The checksum is calculated from the octet string consisting of a "pseudo-header"
/// followed by the entire Mobility Header starting with the Payload Proto field.
/// The checksum is the 16-bit one's complement of the one's complement sum of this string.
/// </param>
/// <param name="messageData">
/// Carries the data specific to the experimental protocol extension.
/// </param>
public IpV6ExtensionHeaderMobilityExperimental(IpV4Protocol nextHeader, ushort checksum, DataSegment messageData)
: base(nextHeader, checksum, IpV6MobilityOptions.None, null)
{
......
......@@ -22,8 +22,18 @@ namespace PcapDotNet.Packets.IpV6
ExtensionHeaders = IpV6ExtensionHeaders.Empty;
}
/// <summary>
/// Available for use by originating nodes and/or forwarding routers to identify and distinguish between different classes or priorities of
/// IPv6 packets.
/// </summary>
public byte TrafficClass { get; set; }
/// <summary>
/// May be used by a source to label sequences of packets for which it requests special handling by the IPv6 routers,
/// such as non-default quality of service or "real-time" service.
/// Hosts or routers that do not support the functions of the Flow Label field are required to set the field to zero when originating a packet,
/// pass the field on unchanged when forwarding a packet, and ignore the field when receiving a packet.
/// </summary>
public int FlowLabel { get; set; }
/// <summary>
......@@ -33,6 +43,10 @@ namespace PcapDotNet.Packets.IpV6
/// </summary>
public IpV4Protocol? NextHeader { get; set; }
/// <summary>
/// Decremented by 1 by each node that forwards the packet.
/// The packet is discarded if Hop Limit is decremented to zero.
/// </summary>
public byte HopLimit { get; set; }
/// <summary>
......
......@@ -21,21 +21,49 @@ namespace PcapDotNet.Packets.IpV6
[IpV6FlowIdentificationSubOptionTypeRegistration(IpV6FlowIdentificationSubOptionType.BindingReference)]
public sealed class IpV6FlowIdentificationSubOptionBindingReference : IpV6FlowIdentificationSubOptionComplex
{
/// <summary>
/// Creates an instance from a list of binding ids.
/// </summary>
/// <param name="bindingIds">
/// Indicates the BIDs that the mobile node wants to associate with the flow identification option.
/// One or more BID fields can be included in this sub-option.
/// </param>
public IpV6FlowIdentificationSubOptionBindingReference(IList<ushort> bindingIds)
: this((ReadOnlyCollection<ushort>)bindingIds.AsReadOnly())
{
}
/// <summary>
/// Creates an instance from an array of binding ids.
/// </summary>
/// <param name="bindingIds">
/// Indicates the BIDs that the mobile node wants to associate with the flow identification option.
/// One or more BID fields can be included in this sub-option.
/// </param>
public IpV6FlowIdentificationSubOptionBindingReference(params ushort[] bindingIds)
: this(bindingIds.AsReadOnly())
{
}
/// <summary>
/// Creates an instance from an enumerable of binding ids.
/// </summary>
/// <param name="bindingIds">
/// Indicates the BIDs that the mobile node wants to associate with the flow identification option.
/// One or more BID fields can be included in this sub-option.
/// </param>
public IpV6FlowIdentificationSubOptionBindingReference(IEnumerable<ushort> bindingIds)
: this((IList<ushort>)bindingIds.ToList())
{
}
/// <summary>
/// Creates an instance from a collection of binding ids.
/// </summary>
/// <param name="bindingIds">
/// Indicates the BIDs that the mobile node wants to associate with the flow identification option.
/// One or more BID fields can be included in this sub-option.
/// </param>
public IpV6FlowIdentificationSubOptionBindingReference(ReadOnlyCollection<ushort> bindingIds)
: base(IpV6FlowIdentificationSubOptionType.BindingReference)
{
......
......@@ -22,16 +22,17 @@ namespace PcapDotNet.Packets.IpV6
[IpV6MobilityOptionTypeRegistration(IpV6MobilityOptionType.AlternateCareOfAddress)]
public sealed class IpV6MobilityOptionAlternateCareOfAddress : IpV6MobilityOptionIpV6Address
{
/// <summary>
/// Creates an instance from an alternative care of address.
/// </summary>
/// <param name="alternateCareOfAddress">
/// Contains an address to use as the care-of address for the binding, rather than using the Source Address of the packet as the care-of address.
/// </param>
public IpV6MobilityOptionAlternateCareOfAddress(IpV6Address alternateCareOfAddress)
: base(IpV6MobilityOptionType.AlternateCareOfAddress, alternateCareOfAddress)
{
}
private IpV6MobilityOptionAlternateCareOfAddress()
: this(IpV6Address.Zero)
{
}
/// <summary>
/// Contains an address to use as the care-of address for the binding, rather than using the Source Address of the packet as the care-of address.
/// </summary>
......@@ -48,5 +49,10 @@ namespace PcapDotNet.Packets.IpV6
return new IpV6MobilityOptionAlternateCareOfAddress(alternateCareOfAddress);
}
private IpV6MobilityOptionAlternateCareOfAddress()
: this(IpV6Address.Zero)
{
}
}
}
\ No newline at end of file
......@@ -18,8 +18,18 @@ namespace PcapDotNet.Packets.IpV6
[IpV6MobilityOptionTypeRegistration(IpV6MobilityOptionType.AlternateIpV4CareOfAddress)]
public sealed class IpV6MobilityOptionAlternateIpV4CareOfAddress : IpV6MobilityOptionComplex
{
/// <summary>
/// The number of bytes the option data takes.
/// </summary>
public const int OptionDataLength = IpV4Address.SizeOf;
/// <summary>
/// Creates an instance from the given alternative care of address.
/// </summary>
/// <param name="alternateCareOfAddress">
/// An IPv4 equivalent of the RFC 6275 Alternate Care-of Address option for IPv6.
/// In the context of PMIPv6, its semantic is equivalent to the Alternate Care-of Address option for IPv6.
/// </param>
public IpV6MobilityOptionAlternateIpV4CareOfAddress(IpV4Address alternateCareOfAddress)
: base(IpV6MobilityOptionType.AlternateIpV4CareOfAddress)
{
......
......@@ -18,8 +18,23 @@ namespace PcapDotNet.Packets.IpV6
[IpV6MobilityOptionTypeRegistration(IpV6MobilityOptionType.CgaParameters)]
public sealed class IpV6MobilityOptionCgaParameters : IpV6MobilityOptionSingleDataSegmentField
{
/// <summary>
/// The maximum option data length in bytes.
/// </summary>
public const int OptionDataMaxLength = 255;
/// <summary>
/// Creates an instance from the given CGA parameters.
/// </summary>
/// <param name="cgaParameters">
/// Contains up to 255 bytes of the CGA Parameters data structure defined in RFC 3972.
/// The concatenation of all CGA Parameters options in the order they appear in the Binding Update message
/// must result in the original CGA Parameters data structure.
/// All CGA Parameters options in the Binding Update message except the last one must contain exactly 255 bytes in the CGA Parameters field,
/// and the Option Length field must be set to 255 accordingly.
/// All CGA Parameters options must appear directly one after another, that is,
/// a mobility option of a different type must not be placed in between two CGA Parameters options.
/// </param>
public IpV6MobilityOptionCgaParameters(DataSegment cgaParameters)
: base(IpV6MobilityOptionType.CgaParameters, cgaParameters)
{
......
......@@ -22,23 +22,54 @@ namespace PcapDotNet.Packets.IpV6
[IpV6MobilityOptionTypeRegistration(IpV6MobilityOptionType.FlowSummary)]
public sealed class IpV6MobilityOptionFlowSummary : IpV6MobilityOptionComplex
{
/// <summary>
/// The minimum number of bytes this option data takes.
/// </summary>
public const int OptionDataMinimumLength = sizeof(ushort);
/// <summary>
/// Creates an instance from an array of flow identifiers.
/// </summary>
/// <param name="flowIdentifiers">
/// Indicating a registered FID.
/// One or more FID fields can be included in this option.
/// </param>
public IpV6MobilityOptionFlowSummary(params ushort[] flowIdentifiers)
: this(flowIdentifiers.AsReadOnly())
{
}
/// <summary>
/// Creates an instance from an enumerable of flow identifiers.
/// </summary>
/// <param name="flowIdentifiers">
/// Indicating a registered FID.
/// One or more FID fields can be included in this option.
/// </param>
public IpV6MobilityOptionFlowSummary(IEnumerable<ushort> flowIdentifiers)
: this((IList<ushort>)flowIdentifiers.ToList())
{
}
/// <summary>
/// Creates an instance from a list of flow identifiers.
/// </summary>
/// <param name="flowIdentifiers">
/// Indicating a registered FID.
/// One or more FID fields can be included in this option.
/// </param>
public IpV6MobilityOptionFlowSummary(IList<ushort> flowIdentifiers)
: this(flowIdentifiers.AsReadOnly())
{
}
/// <summary>
/// Creates an instance from a collection of flow identifiers.
/// </summary>
/// <param name="flowIdentifiers">
/// Indicating a registered FID.
/// One or more FID fields can be included in this option.
/// </param>
public IpV6MobilityOptionFlowSummary(ReadOnlyCollection<ushort> flowIdentifiers)
: base(IpV6MobilityOptionType.FlowSummary)
{
......
......@@ -20,6 +20,13 @@ namespace PcapDotNet.Packets.IpV6
[IpV6MobilityOptionTypeRegistration(IpV6MobilityOptionType.IpV4CareOfAddress)]
public sealed class IpV6MobilityOptionIpV4CareOfAddress : IpV6MobilityOptionIpV4Address
{
/// <summary>
/// Creates an instance from a care-of address.
/// </summary>
/// <param name="careOfAddress">
/// Contains the mobile node's IPv4 care-of address.
/// The IPv4 care-of address is used when the mobile node is located in an IPv4-only network.
/// </param>
public IpV6MobilityOptionIpV4CareOfAddress(IpV4Address careOfAddress)
: base(IpV6MobilityOptionType.IpV4CareOfAddress, careOfAddress)
{
......
......@@ -20,6 +20,12 @@ namespace PcapDotNet.Packets.IpV6
[IpV6MobilityOptionTypeRegistration(IpV6MobilityOptionType.IpV4DefaultRouterAddress)]
public class IpV6MobilityOptionIpV4DefaultRouterAddress : IpV6MobilityOptionIpV4Address
{
/// <summary>
/// Creates an instance from default router address.
/// </summary>
/// <param name="defaultRouterAddress">
/// The mobile node's default router address.
/// </param>
public IpV6MobilityOptionIpV4DefaultRouterAddress(IpV4Address defaultRouterAddress)
: base(IpV6MobilityOptionType.IpV4DefaultRouterAddress, defaultRouterAddress)
{
......
......@@ -20,9 +20,12 @@ namespace PcapDotNet.Packets.IpV6
/// </summary>
public abstract class IpV6MobilityOptionIpV6Address : IpV6MobilityOptionComplex
{
/// <summary>
/// The number of bytes the option data takes.
/// </summary>
public const int OptionDataLength = IpV6Address.SizeOf;
public IpV6MobilityOptionIpV6Address(IpV6MobilityOptionType type, IpV6Address address)
internal IpV6MobilityOptionIpV6Address(IpV6MobilityOptionType type, IpV6Address address)
: base(type)
{
Address = address;
......
......@@ -22,6 +22,12 @@ namespace PcapDotNet.Packets.IpV6
[IpV6MobilityOptionTypeRegistration(IpV6MobilityOptionType.LinkLocalAddress)]
public sealed class IpV6MobilityOptionLinkLocalAddress : IpV6MobilityOptionIpV6Address
{
/// <summary>
/// Creates an instance from link local address.
/// </summary>
/// <param name="linkLocalAddress">
/// Contains the link-local address.
/// </param>
public IpV6MobilityOptionLinkLocalAddress(IpV6Address linkLocalAddress)
: base(IpV6MobilityOptionType.LinkLocalAddress, linkLocalAddress)
{
......
......@@ -20,6 +20,9 @@ namespace PcapDotNet.Packets.IpV6
[IpV6MobilityOptionTypeRegistration(IpV6MobilityOptionType.NatDetection)]
public sealed class IpV6MobilityOptionNatDetection : IpV6MobilityOptionComplex
{
/// <summary>
/// Recommended value for Refresh Time.
/// </summary>
public const uint RecommendedRefreshTime = 110;
private static class Offset
......@@ -28,6 +31,9 @@ namespace PcapDotNet.Packets.IpV6
public const int RefreshTime = UdpEncapsulationRequired + sizeof(ushort);
}
/// <summary>
/// The number of bytes the option data takes.
/// </summary>
public const int OptionDataLength = Offset.RefreshTime + sizeof(uint);
private static class Mask
......@@ -35,6 +41,21 @@ namespace PcapDotNet.Packets.IpV6
public const byte UdpEncapsulationRequired = 0x80;
}
/// <summary>
/// Creates an instance from UDP encapsulated required and refresh time.
/// </summary>
/// <param name="udpEncapsulationRequired">
/// Indicates to the mobile node that UDP encapsulation is required.
/// When set, this flag indicates that the mobile node must use UDP encapsulation even if a NAT is not located between the mobile node and home agent.
/// This flag should not be set when the mobile node is assigned an IPv6 care-of address with some exceptions.
/// </param>
/// <param name="refreshTime">
/// A suggested time (in seconds) for the mobile node to refresh the NAT binding.
/// If set to zero, it is ignored.
/// If this field is set to uint.MaxValue, it means that keepalives are not needed, i.e., no NAT was detected.
/// The home agent must be configured with a default value for the refresh time.
/// The recommended value is RecommendedRefreshTime.
/// </param>
public IpV6MobilityOptionNatDetection(bool udpEncapsulationRequired, uint refreshTime)
: base(IpV6MobilityOptionType.NatDetection)
{
......
......@@ -20,12 +20,19 @@ namespace PcapDotNet.Packets.IpV6
[IpV6MobilityOptionTypeRegistration(IpV6MobilityOptionType.PadN)]
public sealed class IpV6MobilityOptionPadN : IpV6MobilityOptionComplex
{
/// <summary>
/// Creates an instance from padding data length.
/// </summary>
/// <param name="paddingDataLength"></param>
public IpV6MobilityOptionPadN(int paddingDataLength)
: base(IpV6MobilityOptionType.PadN)
{
PaddingDataLength = paddingDataLength;
}
/// <summary>
/// The number of bytes the option data takes.
/// </summary>
public int PaddingDataLength { get; private set; }
internal override IpV6MobilityOption CreateInstance(DataSegment data)
......
......@@ -19,9 +19,12 @@ namespace PcapDotNet.Packets.IpV6
public const int Value = sizeof(byte);
}
/// <summary>
/// The number of bytes the option data takes.
/// </summary>
public const int OptionDataLength = Offset.Value + sizeof(byte);
public IpV6MobilityOptionReservedByteValueByte(IpV6MobilityOptionType type, byte value)
internal IpV6MobilityOptionReservedByteValueByte(IpV6MobilityOptionType type, byte value)
: base(type)
{
Value = value;
......
......@@ -18,14 +18,33 @@ namespace PcapDotNet.Packets.IpV6
[IpV6MobilityOptionTypeRegistration(IpV6MobilityOptionType.ServiceSelection)]
public sealed class IpV6MobilityOptionServiceSelection : IpV6MobilityOptionSingleDataSegmentField
{
/// <summary>
/// The minimum value that Identifier can be set to.
/// </summary>
public const int MinIdentifierLength = 1;
/// <summary>
/// The maximum value that Identifier can be set to.
/// </summary>
public const int MaxIdentifierLength = 255;
public IpV6MobilityOptionServiceSelection(DataSegment data)
: base(IpV6MobilityOptionType.ServiceSelection, data)
/// <summary>
/// Creates an instance from the given identifier.
/// </summary>
/// <param name="identifier">
/// Encoded service identifier string used to identify the requested service.
/// The identifier string length is between 1 and 255 octets.
/// This specification allows international identifier strings that are based on the use of Unicode characters, encoded as UTF-8,
/// and formatted using Normalization Form KC (NFKC).
///
/// 'ims', 'voip', and 'voip.companyxyz.example.com' are valid examples of Service Selection option Identifiers.
/// At minimum, the Identifier must be unique among the home agents to which the mobile node is authorized to register.
/// </param>
public IpV6MobilityOptionServiceSelection(DataSegment identifier)
: base(IpV6MobilityOptionType.ServiceSelection, identifier)
{
if (data.Length < MinIdentifierLength || data.Length > MaxIdentifierLength)
throw new ArgumentOutOfRangeException("data", data,
if (identifier.Length < MinIdentifierLength || identifier.Length > MaxIdentifierLength)
throw new ArgumentOutOfRangeException("identifier", identifier,
string.Format("Identifier length must be at least {0} bytes long and at most {1} bytes long.",
MinIdentifierLength, MaxIdentifierLength));
}
......
......@@ -20,6 +20,14 @@ namespace PcapDotNet.Packets.IpV6
[IpV6MobilityOptionTypeRegistration(IpV6MobilityOptionType.Timestamp)]
public sealed class IpV6MobilityOptionTimestamp : IpV6MobilityOptionULong
{
/// <summary>
/// Creates an instance from timestamp.
/// </summary>
/// <param name="timestamp">
/// Timestamp.
/// The value indicates the number of seconds since January 1, 1970, 00:00 UTC, by using a fixed point format.
/// In this format, the integer number of seconds is contained in the first 48 bits of the field, and the remaining 16 bits indicate the number of 1/65536 fractions of a second.
/// </param>
public IpV6MobilityOptionTimestamp(ulong timestamp)
: base(IpV6MobilityOptionType.Timestamp, timestamp)
{
......@@ -35,11 +43,19 @@ namespace PcapDotNet.Packets.IpV6
get { return Value; }
}
/// <summary>
/// Timestamp.
/// The value indicates the number of seconds since January 1, 1970, 00:00 UTC calculated from the ulong Timestamp field.
/// </summary>
public double TimestampSeconds
{
get { return (Timestamp >> 16) + (Timestamp & 0xFFFF) / 65536.0; }
}
/// <summary>
/// Timestamp.
/// The value indicates the Timestamp date calculated from the Timestamp ulong field.
/// </summary>
public DateTime TimestampDateTime
{
get
......
......@@ -19,8 +19,32 @@ namespace PcapDotNet.Packets.IpV6
[IpV6OptionTypeRegistration(IpV6OptionType.QuickStart)]
public sealed class IpV6OptionQuickStart : IpV6OptionComplex, IIpOptionQuickStart, IIpV6OptionComplexFactory
{
/// <summary>
/// The number of bytes the option data takes.
/// </summary>
public const int OptionDataLength = IpOptionQuickStartCommon.DataLength;
/// <summary>
/// Creates an instance from the given function, rate, TTL and nonce.
/// </summary>
/// <param name="function">Function field.</param>
/// <param name="rate">
/// For rate request, this is the Rate Request field.
/// For Report of Approved Rate, this is the Rate Report field.
/// </param>
/// <param name="ttl">
/// For a Rate Request, contains the Quick-Start TTL (QS TTL) field.
/// The sender must set the QS TTL field to a random value.
/// Routers that approve the Quick-Start Request decrement the QS TTL (mod 256) by the same amount that they decrement the IP TTL.
/// The QS TTL is used by the sender to detect if all the routers along the path understood and approved the Quick-Start option.
/// The transport sender must calculate and store the TTL Diff, the difference between the IP TTL value, and the QS TTL value in the Quick-Start Request packet, as follows:
/// TTL Diff = ( IP TTL - QS TTL ) mod 256.
/// For a Report of Approved Rate, this is not used.
/// </param>
/// <param name="nonce">
/// For a Rate Request and Report of Approved Rate, contain a 30-bit QS Nonce.
/// The sender should set the QS Nonce to a random value.
/// </param>
public IpV6OptionQuickStart(IpV4OptionQuickStartFunction function, byte rate, byte ttl, uint nonce)
: base(IpV6OptionType.QuickStart)
{
......@@ -32,22 +56,47 @@ namespace PcapDotNet.Packets.IpV6
Nonce = nonce;
}
/// <summary>
/// Function field.
/// </summary>
public IpV4OptionQuickStartFunction Function { get; private set; }
/// <summary>
/// For rate request, this is the Rate Request field.
/// For Report of Approved Rate, this is the Rate Report field.
/// </summary>
public byte Rate { get; private set; }
/// <summary>
/// The rate translated to KBPS.
/// </summary>
public int RateKbps
{
get { return IpOptionQuickStartCommon.CalcRateKbps(Rate); }
}
/// <summary>
/// For a Rate Request, contains the Quick-Start TTL (QS TTL) field.
/// The sender must set the QS TTL field to a random value.
/// Routers that approve the Quick-Start Request decrement the QS TTL (mod 256) by the same amount that they decrement the IP TTL.
/// The QS TTL is used by the sender to detect if all the routers along the path understood and approved the Quick-Start option.
/// The transport sender must calculate and store the TTL Diff, the difference between the IP TTL value, and the QS TTL value in the Quick-Start Request packet, as follows:
/// TTL Diff = ( IP TTL - QS TTL ) mod 256.
/// For a Report of Approved Rate, this is not used.
/// </summary>
public byte Ttl { get; private set; }
public uint Nonce { get; private set; }
internal override int DataLength
{
get { return OptionDataLength; }
}
/// <summary>
/// For a Rate Request and Report of Approved Rate, contain a 30-bit QS Nonce.
/// The sender should set the QS Nonce to a random value.
/// </summary>
public uint Nonce { get; private set; }
/// <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.Length != OptionDataLength)
......@@ -62,6 +111,11 @@ namespace PcapDotNet.Packets.IpV6
return new IpV6OptionQuickStart(function, rate, ttl, nonce);
}
internal override int DataLength
{
get { return OptionDataLength; }
}
internal override bool EqualsData(IpV6Option other)
{
return EqualsData(other as IpV6OptionQuickStart);
......
......@@ -22,6 +22,16 @@ namespace PcapDotNet.Packets.IpV6
/// </summary>
public sealed class IpV6OptionSmfDpdNull : IpV6OptionSmfDpdSequenceBased
{
/// <summary>
/// Creates an instance from an identifier.
/// </summary>
/// <param name="identifier">
/// DPD packet Identifier.
/// When the TaggerId field is present, the Identifier can be considered a unique packet identifier
/// in the context of the TaggerId:srcAddr:dstAddr tuple.
/// When the TaggerId field is not present, then it is assumed that the source applied the SMF_DPD option
/// and the Identifier can be considered unique in the context of the IPv6 packet header srcAddr:dstAddr tuple.
/// </param>
public IpV6OptionSmfDpdNull(DataSegment identifier)
: base(identifier)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment