Commit 6b9c23dc authored by Brickner_cp's avatar Brickner_cp

IPv6

parent 97e2aff3
......@@ -39,31 +39,21 @@ namespace PcapDotNet.Packets.IpV6
{
switch (nextHeader)
{
case IpV4Protocol.IpV6HopByHopOption: // 0
case IpV4Protocol.IpV6Route: // 43
case IpV4Protocol.IpV6HopByHopOption: // 0
case IpV4Protocol.IpV6Route: // 43
case IpV4Protocol.FragmentHeaderForIpV6: // 44
numBytesRead = 0;
if (extensionHeaderData.Length < MinimumLength)
return null;
IpV4Protocol nextNextHeader = (IpV4Protocol)extensionHeaderData[Offset.NextHeader];
int length = (extensionHeaderData[Offset.HeaderExtensionLength] + 1) * 8;
if (extensionHeaderData.Length < length)
return null;
DataSegment data = extensionHeaderData.Subsegment(Offset.Data, length - Offset.Data);
numBytesRead = data.Length;
return CreateStandardInstance(nextHeader, nextNextHeader, data);
case IpV4Protocol.IpV6Opts: // 60
return CreateStandardInstance(nextHeader, extensionHeaderData, out numBytesRead);
case IpV4Protocol.EncapsulatingSecurityPayload: // 50
return IpV6ExtensionHeaderEncapsulatingSecurityPayload.CreateInstance(extensionHeaderData, out numBytesRead);
case IpV4Protocol.AuthenticationHeader: // 51
return IpV6ExtensionHeaderAuthentication.CreateInstance(extensionHeaderData, out numBytesRead);
/*
case IpV4Protocol.IpV6Opts: // 60
return IpV6ExtensionHeaderDestinationOptions.Parse(data);
case IpV4Protocol.MobilityHeader: // 135
return IpV6MobilityExtensionHeader.Parse(data);
*/
......@@ -73,8 +63,19 @@ namespace PcapDotNet.Packets.IpV6
}
private static IpV6ExtensionHeader CreateStandardInstance(IpV4Protocol nextHeader, IpV4Protocol nextNextHeader, DataSegment data)
private static IpV6ExtensionHeader CreateStandardInstance(IpV4Protocol nextHeader, DataSegment extensionHeaderData, out int numBytesRead)
{
numBytesRead = 0;
if (extensionHeaderData.Length < MinimumLength)
return null;
IpV4Protocol nextNextHeader = (IpV4Protocol)extensionHeaderData[Offset.NextHeader];
int length = (extensionHeaderData[Offset.HeaderExtensionLength] + 1) * 8;
if (extensionHeaderData.Length < length)
return null;
DataSegment data = extensionHeaderData.Subsegment(Offset.Data, length - Offset.Data);
numBytesRead = data.Length;
switch (nextHeader)
{
case IpV4Protocol.IpV6HopByHopOption: // 0
......@@ -85,10 +86,13 @@ namespace PcapDotNet.Packets.IpV6
case IpV4Protocol.FragmentHeaderForIpV6: // 44
return IpV6ExtensionHeaderFragmentData.ParseData(nextNextHeader, data);
case IpV4Protocol.IpV6Opts: // 60
return IpV6ExtensionHeaderDestinationOptions.ParseData(nextNextHeader, data);
default:
throw new InvalidOperationException("Invalid nextHeader value" + nextHeader);
}
}
}
}
\ No newline at end of file
}
using PcapDotNet.Packets.IpV4;
namespace PcapDotNet.Packets.IpV6
{
/// <summary>
/// RFC 2460.
/// <pre>
/// +-----+-------------+-------------------------+
/// | Bit | 0-7 | 8-15 |
/// +-----+-------------+-------------------------+
/// | 0 | Next Header | Header Extension Length |
/// +-----+-------------+-------------------------+
/// | 32 | Options |
/// | ... | |
/// +-----+---------------------------------------+
/// </pre>
/// </summary>
public class IpV6ExtensionHeaderDestinationOptions : IpV6ExtensionHeaderOptions
{
public IpV6ExtensionHeaderDestinationOptions(IpV4Protocol nextHeader, IpV6Options options)
: base(nextHeader, options)
{
}
internal static IpV6ExtensionHeaderDestinationOptions ParseData(IpV4Protocol nextHeader, DataSegment data)
{
IpV6Options options = new IpV6Options(data);
return new IpV6ExtensionHeaderDestinationOptions(nextHeader, options);
}
}
}
\ No newline at end of file
......@@ -15,16 +15,13 @@ namespace PcapDotNet.Packets.IpV6
/// +-----+---------------------------------------+
/// </pre>
/// </summary>
public class IpV6ExtensionHeaderHopByHopOptions : IpV6ExtensionHeader
public class IpV6ExtensionHeaderHopByHopOptions : IpV6ExtensionHeaderOptions
{
private IpV6ExtensionHeaderHopByHopOptions(IpV4Protocol nextHeader, IpV6Options options)
: base(nextHeader)
: base(nextHeader, options)
{
Options = options;
}
public IpV6Options Options { get; private set; }
internal static IpV6ExtensionHeaderHopByHopOptions ParseData(IpV4Protocol nextHeader, DataSegment data)
{
IpV6Options options = new IpV6Options(data);
......
using PcapDotNet.Packets.IpV4;
namespace PcapDotNet.Packets.IpV6
{
/// <summary>
/// RFC 2460.
/// <pre>
/// +-----+-------------+-------------------------+
/// | Bit | 0-7 | 8-15 |
/// +-----+-------------+-------------------------+
/// | 0 | Next Header | Header Extension Length |
/// +-----+-------------+-------------------------+
/// | 16 | Options |
/// | ... | |
/// +-----+---------------------------------------+
/// </pre>
/// </summary>
public abstract class IpV6ExtensionHeaderOptions : IpV6ExtensionHeader
{
public IpV6Options Options { get; private set; }
internal IpV6ExtensionHeaderOptions(IpV4Protocol nextHeader, IpV6Options options)
: base(nextHeader)
{
Options = options;
}
}
}
\ No newline at end of file
......@@ -319,9 +319,11 @@
<Compile Include="IpV6\IpV6CalipsoDomainOfInterpretation.cs" />
<Compile Include="IpV6\IpV6ExtensionHeader.cs" />
<Compile Include="IpV6\IpV6ExtensionHeaderAuthentication.cs" />
<Compile Include="IpV6\IpV6ExtensionHeaderDestinationOptions.cs" />
<Compile Include="IpV6\IpV6ExtensionHeaderEncapsulatingSecurityPayload.cs" />
<Compile Include="IpV6\IpV6ExtensionHeaderFragmentData.cs" />
<Compile Include="IpV6\IpV6ExtensionHeaderHopByHopOptions.cs" />
<Compile Include="IpV6\IpV6ExtensionHeaderOptions.cs" />
<Compile Include="IpV6\IpV6ExtensionHeaderRouting.cs" />
<Compile Include="IpV6\IpV6ExtensionHeaderRoutingHomeAddress.cs" />
<Compile Include="IpV6\IpV6ExtensionHeaderRoutingRpl.cs" />
......
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