Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pcap-Net
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Pcap-Net
Commits
97e2aff3
Commit
97e2aff3
authored
Sep 18, 2012
by
Brickner_cp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IPv6
parent
de0ecfbc
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
113 additions
and
3 deletions
+113
-3
IpV6ExtensionHeader.cs
...DotNet/src/PcapDotNet.Packets/IpV6/IpV6ExtensionHeader.cs
+2
-3
IpV6ExtensionHeaderAuthentication.cs
...pDotNet.Packets/IpV6/IpV6ExtensionHeaderAuthentication.cs
+110
-0
PcapDotNet.Packets.csproj
PcapDotNet/src/PcapDotNet.Packets/PcapDotNet.Packets.csproj
+1
-0
No files found.
PcapDotNet/src/PcapDotNet.Packets/IpV6/IpV6ExtensionHeader.cs
View file @
97e2aff3
...
...
@@ -58,10 +58,9 @@ namespace PcapDotNet.Packets.IpV6
case
IpV4Protocol
.
EncapsulatingSecurityPayload
:
// 50
return
IpV6ExtensionHeaderEncapsulatingSecurityPayload
.
CreateInstance
(
extensionHeaderData
,
out
numBytesRead
);
/*
case
IpV4Protocol
.
AuthenticationHeader
:
// 51
return IpV6ExtensionHeaderAuthentication.Parse(data
);
return
IpV6ExtensionHeaderAuthentication
.
CreateInstance
(
extensionHeaderData
,
out
numBytesRead
);
/*
case IpV4Protocol.IpV6Opts: // 60
return IpV6ExtensionHeaderDestinationOptions.Parse(data);
...
...
PcapDotNet/src/PcapDotNet.Packets/IpV6/IpV6ExtensionHeaderAuthentication.cs
0 → 100644
View file @
97e2aff3
using
PcapDotNet.Packets.IpV4
;
namespace
PcapDotNet.Packets.IpV6
{
/// <summary>
/// RFC 2402.
/// <pre>
/// +-----+-------------+-------------+----------+
/// | Bit | 0-7 | 8-15 | 16-31 |
/// +-----+-------------+-------------+----------+
/// | 0 | Next Header | Payload Len | RESERVED |
/// +-----+-------------+-------------+----------+
/// | 32 | Security Parameters Index (SPI) |
/// +-----+--------------------------------------+
/// | 64 | Sequence Number Field |
/// +-----+--------------------------------------+
/// | 96 | Authentication Data (variable) |
/// | ... | |
/// +-----+--------------------------------------+
/// </pre>
/// </summary>
public
class
IpV6ExtensionHeaderAuthentication
:
IpV6ExtensionHeader
{
private
static
class
Offset
{
public
const
int
NextHeader
=
0
;
public
const
int
PayloadLength
=
NextHeader
+
sizeof
(
byte
);
public
const
int
SecurityParametersIndex
=
PayloadLength
+
sizeof
(
byte
)
+
sizeof
(
ushort
);
public
const
int
SequenceNumber
=
SecurityParametersIndex
+
sizeof
(
uint
);
public
const
int
AuthenticationData
=
SequenceNumber
+
sizeof
(
uint
);
}
public
const
int
MinimumLength
=
Offset
.
AuthenticationData
;
public
IpV6ExtensionHeaderAuthentication
(
IpV4Protocol
nextHeader
,
uint
securityParametersIndex
,
uint
sequenceNumber
,
DataSegment
authenticationData
)
:
base
(
nextHeader
)
{
SecurityParametersIndex
=
securityParametersIndex
;
SequenceNumber
=
sequenceNumber
;
AuthenticationData
=
authenticationData
;
}
/// <summary>
/// <para>
/// The SPI is an arbitrary 32-bit value that, in combination with the destination IP address and security protocol (AH),
/// uniquely identifies the Security Association for this datagram.
/// The set of SPI values in the range 1 through 255 are reserved by the Internet Assigned Numbers Authority (IANA) for future use;
/// a reserved SPI value will not normally be assigned by IANA unless the use of the assigned SPI value is specified in an RFC.
/// It is ordinarily selected by the destination system upon establishment of an SA.
/// </para>
/// <para>
/// The SPI value of zero (0) is reserved for local, implementation-specific use and must not be sent on the wire.
/// For example, a key management implementation may use the zero SPI value to mean "No Security Association Exists"
/// during the period when the IPsec implementation has requested that its key management entity establish a new SA,
/// but the SA has not yet been established.
/// </para>
/// </summary>
public
uint
SecurityParametersIndex
{
get
;
private
set
;
}
/// <summary>
/// <para>
/// Contains a monotonically increasing counter value (sequence number).
/// It is mandatory and is always present even if the receiver does not elect to enable the anti-replay service for a specific SA.
/// Processing of the Sequence Number field is at the discretion of the receiver, i.e., the sender must always transmit this field,
/// but the receiver need not act upon it.
/// </para>
/// <para>
/// The sender's counter and the receiver's counter are initialized to 0 when an SA is established.
/// (The first packet sent using a given SA will have a Sequence Number of 1.)
/// If anti-replay is enabled (the default), the transmitted Sequence Number must never be allowed to cycle.
/// Thus, the sender's counter and the receiver's counter must be reset (by establishing a new SA and thus a new key)
/// prior to the transmission of the 2^32nd packet on an SA.
/// </para>
/// </summary>
public
uint
SequenceNumber
{
get
;
private
set
;
}
/// <summary>
/// This is a variable-length field that contains the Integrity Check Value (ICV) for this packet.
/// The field must be an integral multiple of 32 bits in length.
/// This field may include explicit padding.
/// This padding is included to ensure that the length of the AH header is an integral multiple of 32 bits (IPv4) or 64 bits (IPv6).
/// All implementations must support such padding.
/// The authentication algorithm specification must specify the length of the ICV and the comparison rules and processing steps for validation.
/// </summary>
public
DataSegment
AuthenticationData
{
get
;
private
set
;
}
internal
static
IpV6ExtensionHeaderAuthentication
CreateInstance
(
DataSegment
extensionHeaderData
,
out
int
numBytesRead
)
{
if
(
extensionHeaderData
.
Length
<
MinimumLength
)
{
numBytesRead
=
0
;
return
null
;
}
IpV4Protocol
nextHeader
=
(
IpV4Protocol
)
extensionHeaderData
[
Offset
.
NextHeader
];
byte
payloadLength
=
extensionHeaderData
[
Offset
.
PayloadLength
];
if
(
extensionHeaderData
.
Length
<
Offset
.
AuthenticationData
+
payloadLength
)
{
numBytesRead
=
0
;
return
null
;
}
uint
securityParametersIndex
=
extensionHeaderData
.
ReadUInt
(
Offset
.
SecurityParametersIndex
,
Endianity
.
Big
);
uint
sequenceNumber
=
extensionHeaderData
.
ReadUInt
(
Offset
.
SequenceNumber
,
Endianity
.
Big
);
DataSegment
authenticationData
=
extensionHeaderData
.
Subsegment
(
Offset
.
AuthenticationData
,
payloadLength
);
numBytesRead
=
Offset
.
AuthenticationData
+
payloadLength
;
return
new
IpV6ExtensionHeaderAuthentication
(
nextHeader
,
securityParametersIndex
,
sequenceNumber
,
authenticationData
);
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/PcapDotNet.Packets.csproj
View file @
97e2aff3
...
...
@@ -318,6 +318,7 @@
<Compile
Include=
"Igmp\IIgmpLayerWithGroupAddress.cs"
/>
<Compile
Include=
"IpV6\IpV6CalipsoDomainOfInterpretation.cs"
/>
<Compile
Include=
"IpV6\IpV6ExtensionHeader.cs"
/>
<Compile
Include=
"IpV6\IpV6ExtensionHeaderAuthentication.cs"
/>
<Compile
Include=
"IpV6\IpV6ExtensionHeaderEncapsulatingSecurityPayload.cs"
/>
<Compile
Include=
"IpV6\IpV6ExtensionHeaderFragmentData.cs"
/>
<Compile
Include=
"IpV6\IpV6ExtensionHeaderHopByHopOptions.cs"
/>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment