Commit 6b9c23dc authored by Brickner_cp's avatar Brickner_cp

IPv6

parent 97e2aff3
...@@ -42,28 +42,18 @@ namespace PcapDotNet.Packets.IpV6 ...@@ -42,28 +42,18 @@ namespace PcapDotNet.Packets.IpV6
case IpV4Protocol.IpV6HopByHopOption: // 0 case IpV4Protocol.IpV6HopByHopOption: // 0
case IpV4Protocol.IpV6Route: // 43 case IpV4Protocol.IpV6Route: // 43
case IpV4Protocol.FragmentHeaderForIpV6: // 44 case IpV4Protocol.FragmentHeaderForIpV6: // 44
numBytesRead = 0; case IpV4Protocol.IpV6Opts: // 60
if (extensionHeaderData.Length < MinimumLength) return CreateStandardInstance(nextHeader, extensionHeaderData, out numBytesRead);
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.EncapsulatingSecurityPayload: // 50 case IpV4Protocol.EncapsulatingSecurityPayload: // 50
return IpV6ExtensionHeaderEncapsulatingSecurityPayload.CreateInstance(extensionHeaderData, out numBytesRead); return IpV6ExtensionHeaderEncapsulatingSecurityPayload.CreateInstance(extensionHeaderData, out numBytesRead);
case IpV4Protocol.AuthenticationHeader: // 51 case IpV4Protocol.AuthenticationHeader: // 51
return IpV6ExtensionHeaderAuthentication.CreateInstance(extensionHeaderData, out numBytesRead); return IpV6ExtensionHeaderAuthentication.CreateInstance(extensionHeaderData, out numBytesRead);
/*
case IpV4Protocol.IpV6Opts: // 60
return IpV6ExtensionHeaderDestinationOptions.Parse(data);
/*
case IpV4Protocol.MobilityHeader: // 135 case IpV4Protocol.MobilityHeader: // 135
return IpV6MobilityExtensionHeader.Parse(data); return IpV6MobilityExtensionHeader.Parse(data);
*/ */
...@@ -73,8 +63,19 @@ namespace PcapDotNet.Packets.IpV6 ...@@ -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) switch (nextHeader)
{ {
case IpV4Protocol.IpV6HopByHopOption: // 0 case IpV4Protocol.IpV6HopByHopOption: // 0
...@@ -86,6 +87,9 @@ namespace PcapDotNet.Packets.IpV6 ...@@ -86,6 +87,9 @@ namespace PcapDotNet.Packets.IpV6
case IpV4Protocol.FragmentHeaderForIpV6: // 44 case IpV4Protocol.FragmentHeaderForIpV6: // 44
return IpV6ExtensionHeaderFragmentData.ParseData(nextNextHeader, data); return IpV6ExtensionHeaderFragmentData.ParseData(nextNextHeader, data);
case IpV4Protocol.IpV6Opts: // 60
return IpV6ExtensionHeaderDestinationOptions.ParseData(nextNextHeader, data);
default: default:
throw new InvalidOperationException("Invalid nextHeader value" + nextHeader); throw new InvalidOperationException("Invalid nextHeader value" + nextHeader);
} }
......
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 ...@@ -15,16 +15,13 @@ namespace PcapDotNet.Packets.IpV6
/// +-----+---------------------------------------+ /// +-----+---------------------------------------+
/// </pre> /// </pre>
/// </summary> /// </summary>
public class IpV6ExtensionHeaderHopByHopOptions : IpV6ExtensionHeader public class IpV6ExtensionHeaderHopByHopOptions : IpV6ExtensionHeaderOptions
{ {
private IpV6ExtensionHeaderHopByHopOptions(IpV4Protocol nextHeader, IpV6Options options) 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) internal static IpV6ExtensionHeaderHopByHopOptions ParseData(IpV4Protocol nextHeader, DataSegment data)
{ {
IpV6Options options = new IpV6Options(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 @@ ...@@ -319,9 +319,11 @@
<Compile Include="IpV6\IpV6CalipsoDomainOfInterpretation.cs" /> <Compile Include="IpV6\IpV6CalipsoDomainOfInterpretation.cs" />
<Compile Include="IpV6\IpV6ExtensionHeader.cs" /> <Compile Include="IpV6\IpV6ExtensionHeader.cs" />
<Compile Include="IpV6\IpV6ExtensionHeaderAuthentication.cs" /> <Compile Include="IpV6\IpV6ExtensionHeaderAuthentication.cs" />
<Compile Include="IpV6\IpV6ExtensionHeaderDestinationOptions.cs" />
<Compile Include="IpV6\IpV6ExtensionHeaderEncapsulatingSecurityPayload.cs" /> <Compile Include="IpV6\IpV6ExtensionHeaderEncapsulatingSecurityPayload.cs" />
<Compile Include="IpV6\IpV6ExtensionHeaderFragmentData.cs" /> <Compile Include="IpV6\IpV6ExtensionHeaderFragmentData.cs" />
<Compile Include="IpV6\IpV6ExtensionHeaderHopByHopOptions.cs" /> <Compile Include="IpV6\IpV6ExtensionHeaderHopByHopOptions.cs" />
<Compile Include="IpV6\IpV6ExtensionHeaderOptions.cs" />
<Compile Include="IpV6\IpV6ExtensionHeaderRouting.cs" /> <Compile Include="IpV6\IpV6ExtensionHeaderRouting.cs" />
<Compile Include="IpV6\IpV6ExtensionHeaderRoutingHomeAddress.cs" /> <Compile Include="IpV6\IpV6ExtensionHeaderRoutingHomeAddress.cs" />
<Compile Include="IpV6\IpV6ExtensionHeaderRoutingRpl.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