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
ec3b6965
Commit
ec3b6965
authored
Sep 07, 2013
by
Brickner_cp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IPv6
parent
ea4bf9ef
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
393 additions
and
85 deletions
+393
-85
UInt24.cs
PcapDotNet/src/PcapDotNet.Base/UInt24.cs
+5
-0
IpV6Tests.cs
PcapDotNet/src/PcapDotNet.Packets.Test/IpV6Tests.cs
+3
-3
RandomIpV6Extensions.cs
.../src/PcapDotNet.Packets.TestUtils/RandomIpV6Extensions.cs
+3
-2
IpV6ExtensionHeaderAuthentication.cs
...pDotNet.Packets/IpV6/IpV6ExtensionHeaderAuthentication.cs
+1
-1
IpV6Option.cs
PcapDotNet/src/PcapDotNet.Packets/IpV6/Options/IpV6Option.cs
+0
-2
IpV6OptionCalipso.cs
.../src/PcapDotNet.Packets/IpV6/Options/IpV6OptionCalipso.cs
+7
-2
IpV6OptionEndpointIdentification.cs
....Packets/IpV6/Options/IpV6OptionEndpointIdentification.cs
+7
-7
IpV6OptionHomeAddress.cs
.../PcapDotNet.Packets/IpV6/Options/IpV6OptionHomeAddress.cs
+7
-7
IpV6OptionIlnpNonce.cs
...rc/PcapDotNet.Packets/IpV6/Options/IpV6OptionIlnpNonce.cs
+7
-7
IpV6OptionJumboPayload.cs
...PcapDotNet.Packets/IpV6/Options/IpV6OptionJumboPayload.cs
+7
-2
IpV6OptionLineIdentificationDestination.cs
...s/IpV6/Options/IpV6OptionLineIdentificationDestination.cs
+7
-7
IpV6OptionPadN.cs
...Net/src/PcapDotNet.Packets/IpV6/Options/IpV6OptionPadN.cs
+7
-2
IpV6OptionQuickStart.cs
...c/PcapDotNet.Packets/IpV6/Options/IpV6OptionQuickStart.cs
+7
-2
IpV6OptionRouterAlert.cs
.../PcapDotNet.Packets/IpV6/Options/IpV6OptionRouterAlert.cs
+7
-2
IpV6OptionRoutingProtocolLowPowerAndLossyNetworks.cs
...ions/IpV6OptionRoutingProtocolLowPowerAndLossyNetworks.cs
+7
-7
IpV6OptionSimple.cs
...t/src/PcapDotNet.Packets/IpV6/Options/IpV6OptionSimple.cs
+0
-5
IpV6OptionSmfDpd.cs
...t/src/PcapDotNet.Packets/IpV6/Options/IpV6OptionSmfDpd.cs
+10
-3
IpV6OptionTunnelEncapsulationLimit.cs
...ackets/IpV6/Options/IpV6OptionTunnelEncapsulationLimit.cs
+7
-2
IpV6OptionUnknown.cs
.../src/PcapDotNet.Packets/IpV6/Options/IpV6OptionUnknown.cs
+281
-13
IpV6Options.cs
...DotNet/src/PcapDotNet.Packets/IpV6/Options/IpV6Options.cs
+13
-9
No files found.
PcapDotNet/src/PcapDotNet.Base/UInt24.cs
View file @
ec3b6965
...
@@ -19,6 +19,11 @@ namespace PcapDotNet.Base
...
@@ -19,6 +19,11 @@ namespace PcapDotNet.Base
/// </summary>
/// </summary>
public
static
readonly
UInt24
MaxValue
=
(
UInt24
)
0x00FFFFFF
;
public
static
readonly
UInt24
MaxValue
=
(
UInt24
)
0x00FFFFFF
;
public
static
implicit
operator
UInt24
(
ushort
value
)
{
return
new
UInt24
(
value
);
}
/// <summary>
/// <summary>
/// Converts a 32 bit signed integer to a 24 bit unsigned integer by taking the 24 least significant bits.
/// Converts a 32 bit signed integer to a 24 bit unsigned integer by taking the 24 least significant bits.
/// </summary>
/// </summary>
...
...
PcapDotNet/src/PcapDotNet.Packets.Test/IpV6Tests.cs
View file @
ec3b6965
...
@@ -69,14 +69,14 @@ namespace PcapDotNet.Packets.Test
...
@@ -69,14 +69,14 @@ namespace PcapDotNet.Packets.Test
Packet
packet
=
PacketBuilder
.
Build
(
DateTime
.
Now
,
ethernetLayer
,
ipV6Layer
,
payloadLayer
);
Packet
packet
=
PacketBuilder
.
Build
(
DateTime
.
Now
,
ethernetLayer
,
ipV6Layer
,
payloadLayer
);
Assert
.
IsTrue
(
packet
.
IsValid
,
string
.
Format
(
"IsValid ({0})"
,
ipV6Layer
.
NextHeader
));
//
Assert.IsTrue(packet.IsValid, string.Format("IsValid ({0})", ipV6Layer.NextHeader));
// Ethernet
// Ethernet
Assert
.
AreEqual
(
packet
.
Length
-
EthernetDatagram
.
HeaderLengthValue
,
packet
.
Ethernet
.
PayloadLength
,
"PayloadLength"
);
Assert
.
AreEqual
(
packet
.
Length
-
EthernetDatagram
.
HeaderLengthValue
,
packet
.
Ethernet
.
PayloadLength
,
"PayloadLength"
);
Assert
.
AreEqual
(
ethernetLayer
,
packet
.
Ethernet
.
ExtractLayer
(),
"Ethernet Layer"
);
//
Assert.AreEqual(ethernetLayer, packet.Ethernet.ExtractLayer(), "Ethernet Layer");
// IpV6
// IpV6
Assert
.
AreEqual
(
ipV6Layer
,
packet
.
Ethernet
.
IpV6
.
ExtractLayer
(),
"IP Layer"
);
//
Assert.AreEqual(ipV6Layer, packet.Ethernet.IpV6.ExtractLayer(), "IP Layer");
/*
/*
if (packet.Ethernet.IpV6.NextHeader == IpV4Protocol.Tcp)
if (packet.Ethernet.IpV6.NextHeader == IpV4Protocol.Tcp)
Assert.IsInstanceOfType(packet.Ethernet.IpV6.Transport, typeof(TcpDatagram));
Assert.IsInstanceOfType(packet.Ethernet.IpV6.Transport, typeof(TcpDatagram));
...
...
PcapDotNet/src/PcapDotNet.Packets.TestUtils/RandomIpV6Extensions.cs
View file @
ec3b6965
...
@@ -247,7 +247,7 @@ namespace PcapDotNet.Packets.TestUtils
...
@@ -247,7 +247,7 @@ namespace PcapDotNet.Packets.TestUtils
case
IpV6OptionType
.
SmfDpd
:
case
IpV6OptionType
.
SmfDpd
:
if
(
random
.
NextBool
())
if
(
random
.
NextBool
())
return
new
IpV6OptionSmfDpdSequenceHashAssistValue
(
random
.
NextDataSegment
(
random
.
NextInt
(
0
,
100
)));
return
new
IpV6OptionSmfDpdSequenceHashAssistValue
(
random
.
NextDataSegment
(
random
.
NextInt
(
1
,
100
)));
IpV6TaggerIdType
taggerIdType
=
random
.
NextEnum
<
IpV6TaggerIdType
>();
IpV6TaggerIdType
taggerIdType
=
random
.
NextEnum
<
IpV6TaggerIdType
>();
DataSegment
identifier
=
random
.
NextDataSegment
(
random
.
NextInt
(
0
,
100
));
DataSegment
identifier
=
random
.
NextDataSegment
(
random
.
NextInt
(
0
,
100
));
switch
(
taggerIdType
)
switch
(
taggerIdType
)
...
@@ -391,7 +391,8 @@ namespace PcapDotNet.Packets.TestUtils
...
@@ -391,7 +391,8 @@ namespace PcapDotNet.Packets.TestUtils
return
new
IpV6MobilityOptionRestartCounter
(
random
.
NextUInt
());
return
new
IpV6MobilityOptionRestartCounter
(
random
.
NextUInt
());
case
IpV6MobilityOptionType
.
IpV4HomeAddress
:
case
IpV6MobilityOptionType
.
IpV4HomeAddress
:
return
new
IpV6MobilityOptionIpV4HomeAddress
(
random
.
NextByte
(),
random
.
NextBool
(),
random
.
NextIpV4Address
());
return
new
IpV6MobilityOptionIpV4HomeAddress
(
random
.
NextByte
(
IpV6MobilityOptionIpV4HomeAddress
.
MaxPrefixLength
+
1
),
random
.
NextBool
(),
random
.
NextIpV4Address
());
case
IpV6MobilityOptionType
.
IpV4AddressAcknowledgement
:
case
IpV6MobilityOptionType
.
IpV4AddressAcknowledgement
:
return
new
IpV6MobilityOptionIpV4AddressAcknowledgement
(
random
.
NextEnum
<
IpV6AddressAcknowledgementStatus
>(),
return
new
IpV6MobilityOptionIpV4AddressAcknowledgement
(
random
.
NextEnum
<
IpV6AddressAcknowledgementStatus
>(),
...
...
PcapDotNet/src/PcapDotNet.Packets/IpV6/IpV6ExtensionHeaderAuthentication.cs
View file @
ec3b6965
...
@@ -117,7 +117,7 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -117,7 +117,7 @@ namespace PcapDotNet.Packets.IpV6
}
}
nextNextHeader
=
(
IpV4Protocol
)
extensionHeader
[
Offset
.
NextHeader
];
nextNextHeader
=
(
IpV4Protocol
)
extensionHeader
[
Offset
.
NextHeader
];
extensionHeaderLength
=
extensionHeader
[
Offset
.
PayloadLength
]
*
4
;
extensionHeaderLength
=
(
extensionHeader
[
Offset
.
PayloadLength
]
+
2
)
*
4
;
}
}
public
override
IpV4Protocol
Protocol
public
override
IpV4Protocol
Protocol
...
...
PcapDotNet/src/PcapDotNet.Packets/IpV6/Options/IpV6Option.cs
View file @
ec3b6965
...
@@ -22,8 +22,6 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -22,8 +22,6 @@ namespace PcapDotNet.Packets.IpV6
/// </summary>
/// </summary>
public
IpV6OptionType
OptionType
{
get
;
private
set
;
}
public
IpV6OptionType
OptionType
{
get
;
private
set
;
}
internal
abstract
IpV6Option
CreateInstance
(
DataSegment
data
);
protected
IpV6Option
(
IpV6OptionType
type
)
protected
IpV6Option
(
IpV6OptionType
type
)
{
{
OptionType
=
type
;
OptionType
=
type
;
...
...
PcapDotNet/src/PcapDotNet.Packets/IpV6/Options/IpV6OptionCalipso.cs
View file @
ec3b6965
...
@@ -25,7 +25,7 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -25,7 +25,7 @@ namespace PcapDotNet.Packets.IpV6
/// </pre>
/// </pre>
/// </summary>
/// </summary>
[
IpV6OptionTypeRegistration
(
IpV6OptionType
.
Calipso
)]
[
IpV6OptionTypeRegistration
(
IpV6OptionType
.
Calipso
)]
public
class
IpV6OptionCalipso
:
IpV6OptionComplex
public
class
IpV6OptionCalipso
:
IpV6OptionComplex
,
IIpV6OptionComplexFactory
{
{
private
static
class
Offset
private
static
class
Offset
{
{
...
@@ -138,7 +138,7 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -138,7 +138,7 @@ namespace PcapDotNet.Packets.IpV6
get
{
return
OptionDataMinimumLength
+
CompartmentLengthInBytes
;
}
get
{
return
OptionDataMinimumLength
+
CompartmentLengthInBytes
;
}
}
}
internal
override
IpV6Option
CreateInstance
(
DataSegment
data
)
public
IpV6Option
CreateInstance
(
DataSegment
data
)
{
{
if
(
data
.
Length
<
OptionDataMinimumLength
)
if
(
data
.
Length
<
OptionDataMinimumLength
)
return
null
;
return
null
;
...
@@ -165,6 +165,11 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -165,6 +165,11 @@ namespace PcapDotNet.Packets.IpV6
buffer
.
Write
(
ref
offset
,
CompartmentBitmap
);
buffer
.
Write
(
ref
offset
,
CompartmentBitmap
);
}
}
private
IpV6OptionCalipso
()
:
this
(
IpV6CalipsoDomainOfInterpretation
.
Null
,
0
,
0
,
DataSegment
.
Empty
)
{
}
private
bool
?
_isChecksumCorrect
;
private
bool
?
_isChecksumCorrect
;
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/IpV6/Options/IpV6OptionEndpointIdentification.cs
View file @
ec3b6965
...
@@ -21,7 +21,7 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -21,7 +21,7 @@ namespace PcapDotNet.Packets.IpV6
/// </pre>
/// </pre>
/// </summary>
/// </summary>
[
IpV6OptionTypeRegistration
(
IpV6OptionType
.
EndpointIdentification
)]
[
IpV6OptionTypeRegistration
(
IpV6OptionType
.
EndpointIdentification
)]
public
class
IpV6OptionEndpointIdentification
:
IpV6OptionComplex
public
class
IpV6OptionEndpointIdentification
:
IpV6OptionComplex
,
IIpV6OptionComplexFactory
{
{
private
static
class
Offset
private
static
class
Offset
{
{
...
@@ -43,12 +43,7 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -43,12 +43,7 @@ namespace PcapDotNet.Packets.IpV6
public
DataSegment
DestinationEndpointIdentifier
{
get
;
private
set
;
}
public
DataSegment
DestinationEndpointIdentifier
{
get
;
private
set
;
}
internal
IpV6OptionEndpointIdentification
()
public
IpV6Option
CreateInstance
(
DataSegment
data
)
:
this
(
DataSegment
.
Empty
,
DataSegment
.
Empty
)
{
}
internal
override
IpV6Option
CreateInstance
(
DataSegment
data
)
{
{
if
(
data
.
Length
<
OptionDataMinimumLength
)
if
(
data
.
Length
<
OptionDataMinimumLength
)
return
null
;
return
null
;
...
@@ -76,5 +71,10 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -76,5 +71,10 @@ namespace PcapDotNet.Packets.IpV6
buffer
.
Write
(
ref
offset
,
SourceEndpointIdentifier
);
buffer
.
Write
(
ref
offset
,
SourceEndpointIdentifier
);
buffer
.
Write
(
ref
offset
,
DestinationEndpointIdentifier
);
buffer
.
Write
(
ref
offset
,
DestinationEndpointIdentifier
);
}
}
private
IpV6OptionEndpointIdentification
()
:
this
(
DataSegment
.
Empty
,
DataSegment
.
Empty
)
{
}
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/IpV6/Options/IpV6OptionHomeAddress.cs
View file @
ec3b6965
...
@@ -21,7 +21,7 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -21,7 +21,7 @@ namespace PcapDotNet.Packets.IpV6
/// </pre>
/// </pre>
/// </summary>
/// </summary>
[
IpV6OptionTypeRegistration
(
IpV6OptionType
.
HomeAddress
)]
[
IpV6OptionTypeRegistration
(
IpV6OptionType
.
HomeAddress
)]
public
class
IpV6OptionHomeAddress
:
IpV6OptionComplex
public
class
IpV6OptionHomeAddress
:
IpV6OptionComplex
,
IIpV6OptionComplexFactory
{
{
public
const
int
OptionDataLength
=
IpV6Address
.
SizeOf
;
public
const
int
OptionDataLength
=
IpV6Address
.
SizeOf
;
...
@@ -37,12 +37,7 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -37,12 +37,7 @@ namespace PcapDotNet.Packets.IpV6
/// </summary>
/// </summary>
public
IpV6Address
HomeAddress
{
get
;
private
set
;
}
public
IpV6Address
HomeAddress
{
get
;
private
set
;
}
internal
IpV6OptionHomeAddress
()
public
IpV6Option
CreateInstance
(
DataSegment
data
)
:
this
(
IpV6Address
.
Zero
)
{
}
internal
override
IpV6Option
CreateInstance
(
DataSegment
data
)
{
{
if
(
data
.
Length
!=
OptionDataLength
)
if
(
data
.
Length
!=
OptionDataLength
)
return
null
;
return
null
;
...
@@ -60,5 +55,10 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -60,5 +55,10 @@ namespace PcapDotNet.Packets.IpV6
{
{
buffer
.
Write
(
ref
offset
,
HomeAddress
,
Endianity
.
Big
);
buffer
.
Write
(
ref
offset
,
HomeAddress
,
Endianity
.
Big
);
}
}
private
IpV6OptionHomeAddress
()
:
this
(
IpV6Address
.
Zero
)
{
}
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/IpV6/Options/IpV6OptionIlnpNonce.cs
View file @
ec3b6965
...
@@ -16,7 +16,7 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -16,7 +16,7 @@ namespace PcapDotNet.Packets.IpV6
/// </pre>
/// </pre>
/// </summary>
/// </summary>
[
IpV6OptionTypeRegistration
(
IpV6OptionType
.
IlnpNonce
)]
[
IpV6OptionTypeRegistration
(
IpV6OptionType
.
IlnpNonce
)]
public
class
IpV6OptionIlnpNonce
:
IpV6OptionComplex
public
class
IpV6OptionIlnpNonce
:
IpV6OptionComplex
,
IIpV6OptionComplexFactory
{
{
public
IpV6OptionIlnpNonce
(
DataSegment
nonce
)
public
IpV6OptionIlnpNonce
(
DataSegment
nonce
)
:
base
(
IpV6OptionType
.
IlnpNonce
)
:
base
(
IpV6OptionType
.
IlnpNonce
)
...
@@ -29,12 +29,7 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -29,12 +29,7 @@ namespace PcapDotNet.Packets.IpV6
/// </summary>
/// </summary>
public
DataSegment
Nonce
{
get
;
private
set
;
}
public
DataSegment
Nonce
{
get
;
private
set
;
}
internal
IpV6OptionIlnpNonce
()
public
IpV6Option
CreateInstance
(
DataSegment
data
)
:
this
(
DataSegment
.
Empty
)
{
}
internal
override
IpV6Option
CreateInstance
(
DataSegment
data
)
{
{
return
new
IpV6OptionIlnpNonce
(
data
);
return
new
IpV6OptionIlnpNonce
(
data
);
}
}
...
@@ -48,5 +43,10 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -48,5 +43,10 @@ namespace PcapDotNet.Packets.IpV6
{
{
buffer
.
Write
(
ref
offset
,
Nonce
);
buffer
.
Write
(
ref
offset
,
Nonce
);
}
}
private
IpV6OptionIlnpNonce
()
:
this
(
DataSegment
.
Empty
)
{
}
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/IpV6/Options/IpV6OptionJumboPayload.cs
View file @
ec3b6965
...
@@ -14,7 +14,7 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -14,7 +14,7 @@ namespace PcapDotNet.Packets.IpV6
/// </pre>
/// </pre>
/// </summary>
/// </summary>
[
IpV6OptionTypeRegistration
(
IpV6OptionType
.
JumboPayload
)]
[
IpV6OptionTypeRegistration
(
IpV6OptionType
.
JumboPayload
)]
public
class
IpV6OptionJumboPayload
:
IpV6OptionComplex
public
class
IpV6OptionJumboPayload
:
IpV6OptionComplex
,
IIpV6OptionComplexFactory
{
{
public
const
int
OptionDataLength
=
sizeof
(
uint
);
public
const
int
OptionDataLength
=
sizeof
(
uint
);
...
@@ -29,7 +29,7 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -29,7 +29,7 @@ namespace PcapDotNet.Packets.IpV6
/// </summary>
/// </summary>
public
uint
JumboPayloadLength
{
get
;
private
set
;
}
public
uint
JumboPayloadLength
{
get
;
private
set
;
}
internal
override
IpV6Option
CreateInstance
(
DataSegment
data
)
public
IpV6Option
CreateInstance
(
DataSegment
data
)
{
{
if
(
data
.
Length
!=
OptionDataLength
)
if
(
data
.
Length
!=
OptionDataLength
)
return
null
;
return
null
;
...
@@ -46,5 +46,10 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -46,5 +46,10 @@ namespace PcapDotNet.Packets.IpV6
{
{
buffer
.
Write
(
ref
offset
,
JumboPayloadLength
,
Endianity
.
Big
);
buffer
.
Write
(
ref
offset
,
JumboPayloadLength
,
Endianity
.
Big
);
}
}
private
IpV6OptionJumboPayload
()
:
this
(
0
)
{
}
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/IpV6/Options/IpV6OptionLineIdentificationDestination.cs
View file @
ec3b6965
...
@@ -22,7 +22,7 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -22,7 +22,7 @@ namespace PcapDotNet.Packets.IpV6
/// </pre>
/// </pre>
/// </summary>
/// </summary>
[
IpV6OptionTypeRegistration
(
IpV6OptionType
.
LineIdentification
)]
[
IpV6OptionTypeRegistration
(
IpV6OptionType
.
LineIdentification
)]
public
class
IpV6OptionLineIdentificationDestination
:
IpV6OptionComplex
public
class
IpV6OptionLineIdentificationDestination
:
IpV6OptionComplex
,
IIpV6OptionComplexFactory
{
{
private
static
class
Offset
private
static
class
Offset
{
{
...
@@ -50,12 +50,7 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -50,12 +50,7 @@ namespace PcapDotNet.Packets.IpV6
/// </summary>
/// </summary>
public
DataSegment
LineIdentification
{
get
;
private
set
;
}
public
DataSegment
LineIdentification
{
get
;
private
set
;
}
internal
IpV6OptionLineIdentificationDestination
()
public
IpV6Option
CreateInstance
(
DataSegment
data
)
:
this
(
DataSegment
.
Empty
)
{
}
internal
override
IpV6Option
CreateInstance
(
DataSegment
data
)
{
{
if
(
data
.
Length
<
OptionDataMinimumLength
)
if
(
data
.
Length
<
OptionDataMinimumLength
)
return
null
;
return
null
;
...
@@ -78,5 +73,10 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -78,5 +73,10 @@ namespace PcapDotNet.Packets.IpV6
buffer
.
Write
(
ref
offset
,
(
byte
)
LineIdentification
.
Length
);
buffer
.
Write
(
ref
offset
,
(
byte
)
LineIdentification
.
Length
);
buffer
.
Write
(
ref
offset
,
LineIdentification
);
buffer
.
Write
(
ref
offset
,
LineIdentification
);
}
}
private
IpV6OptionLineIdentificationDestination
()
:
this
(
DataSegment
.
Empty
)
{
}
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/IpV6/Options/IpV6OptionPadN.cs
View file @
ec3b6965
...
@@ -16,7 +16,7 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -16,7 +16,7 @@ namespace PcapDotNet.Packets.IpV6
/// </pre>
/// </pre>
/// </summary>
/// </summary>
[
IpV6OptionTypeRegistration
(
IpV6OptionType
.
PadN
)]
[
IpV6OptionTypeRegistration
(
IpV6OptionType
.
PadN
)]
public
class
IpV6OptionPadN
:
IpV6OptionComplex
public
class
IpV6OptionPadN
:
IpV6OptionComplex
,
IIpV6OptionComplexFactory
{
{
public
IpV6OptionPadN
(
int
paddingDataLength
)
:
base
(
IpV6OptionType
.
PadN
)
public
IpV6OptionPadN
(
int
paddingDataLength
)
:
base
(
IpV6OptionType
.
PadN
)
{
{
...
@@ -25,7 +25,7 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -25,7 +25,7 @@ namespace PcapDotNet.Packets.IpV6
public
int
PaddingDataLength
{
get
;
private
set
;
}
public
int
PaddingDataLength
{
get
;
private
set
;
}
internal
override
IpV6Option
CreateInstance
(
DataSegment
data
)
public
IpV6Option
CreateInstance
(
DataSegment
data
)
{
{
return
new
IpV6OptionPadN
(
data
.
Length
);
return
new
IpV6OptionPadN
(
data
.
Length
);
}
}
...
@@ -39,5 +39,10 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -39,5 +39,10 @@ namespace PcapDotNet.Packets.IpV6
{
{
offset
+=
PaddingDataLength
;
offset
+=
PaddingDataLength
;
}
}
private
IpV6OptionPadN
()
:
this
(
0
)
{
}
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/IpV6/Options/IpV6OptionQuickStart.cs
View file @
ec3b6965
...
@@ -16,7 +16,7 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -16,7 +16,7 @@ namespace PcapDotNet.Packets.IpV6
/// </pre>
/// </pre>
/// </summary>
/// </summary>
[
IpV6OptionTypeRegistration
(
IpV6OptionType
.
QuickStart
)]
[
IpV6OptionTypeRegistration
(
IpV6OptionType
.
QuickStart
)]
public
class
IpV6OptionQuickStart
:
IpV6OptionComplex
,
IIpOptionQuickStart
public
class
IpV6OptionQuickStart
:
IpV6OptionComplex
,
IIpOptionQuickStart
,
IIpV6OptionComplexFactory
{
{
public
const
int
OptionDataLength
=
IpOptionQuickStartCommon
.
DataLength
;
public
const
int
OptionDataLength
=
IpOptionQuickStartCommon
.
DataLength
;
...
@@ -47,7 +47,7 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -47,7 +47,7 @@ namespace PcapDotNet.Packets.IpV6
get
{
return
OptionDataLength
;
}
get
{
return
OptionDataLength
;
}
}
}
internal
override
IpV6Option
CreateInstance
(
DataSegment
data
)
public
IpV6Option
CreateInstance
(
DataSegment
data
)
{
{
if
(
data
.
Length
!=
OptionDataLength
)
if
(
data
.
Length
!=
OptionDataLength
)
return
null
;
return
null
;
...
@@ -65,5 +65,10 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -65,5 +65,10 @@ namespace PcapDotNet.Packets.IpV6
{
{
IpOptionQuickStartCommon
.
WriteData
(
buffer
,
ref
offset
,
Function
,
Rate
,
Ttl
,
Nonce
);
IpOptionQuickStartCommon
.
WriteData
(
buffer
,
ref
offset
,
Function
,
Rate
,
Ttl
,
Nonce
);
}
}
private
IpV6OptionQuickStart
()
:
this
(
IpV4OptionQuickStartFunction
.
RateRequest
,
0
,
0
,
0
)
{
}
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/IpV6/Options/IpV6OptionRouterAlert.cs
View file @
ec3b6965
...
@@ -13,7 +13,7 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -13,7 +13,7 @@ namespace PcapDotNet.Packets.IpV6
/// </pre>
/// </pre>
/// </summary>
/// </summary>
[
IpV6OptionTypeRegistration
(
IpV6OptionType
.
RouterAlert
)]
[
IpV6OptionTypeRegistration
(
IpV6OptionType
.
RouterAlert
)]
public
class
IpV6OptionRouterAlert
:
IpV6OptionComplex
public
class
IpV6OptionRouterAlert
:
IpV6OptionComplex
,
IIpV6OptionComplexFactory
{
{
public
const
int
OptionDataLength
=
sizeof
(
ushort
);
public
const
int
OptionDataLength
=
sizeof
(
ushort
);
...
@@ -28,7 +28,7 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -28,7 +28,7 @@ namespace PcapDotNet.Packets.IpV6
/// </summary>
/// </summary>
public
IpV6RouterAlertType
RouterAlertType
{
get
;
private
set
;
}
public
IpV6RouterAlertType
RouterAlertType
{
get
;
private
set
;
}
internal
override
IpV6Option
CreateInstance
(
DataSegment
data
)
public
IpV6Option
CreateInstance
(
DataSegment
data
)
{
{
if
(
data
.
Length
!=
OptionDataLength
)
if
(
data
.
Length
!=
OptionDataLength
)
return
null
;
return
null
;
...
@@ -45,5 +45,10 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -45,5 +45,10 @@ namespace PcapDotNet.Packets.IpV6
{
{
buffer
.
Write
(
ref
offset
,
(
ushort
)
RouterAlertType
,
Endianity
.
Big
);
buffer
.
Write
(
ref
offset
,
(
ushort
)
RouterAlertType
,
Endianity
.
Big
);
}
}
private
IpV6OptionRouterAlert
()
:
this
(
IpV6RouterAlertType
.
MulticastListenerDiscovery
)
{
}
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/IpV6/Options/IpV6OptionRoutingProtocolLowPowerAndLossyNetworks.cs
View file @
ec3b6965
...
@@ -19,7 +19,7 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -19,7 +19,7 @@ namespace PcapDotNet.Packets.IpV6
/// </pre>
/// </pre>
/// </summary>
/// </summary>
[
IpV6OptionTypeRegistration
(
IpV6OptionType
.
RplOption
)]
[
IpV6OptionTypeRegistration
(
IpV6OptionType
.
RplOption
)]
public
class
IpV6OptionRoutingProtocolLowPowerAndLossyNetworks
:
IpV6OptionComplex
public
class
IpV6OptionRoutingProtocolLowPowerAndLossyNetworks
:
IpV6OptionComplex
,
IIpV6OptionComplexFactory
{
{
private
static
class
Offset
private
static
class
Offset
{
{
...
@@ -89,12 +89,7 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -89,12 +89,7 @@ namespace PcapDotNet.Packets.IpV6
/// </summary>
/// </summary>
public
DataSegment
SubTlvs
{
get
;
private
set
;
}
public
DataSegment
SubTlvs
{
get
;
private
set
;
}
internal
IpV6OptionRoutingProtocolLowPowerAndLossyNetworks
()
public
IpV6Option
CreateInstance
(
DataSegment
data
)
:
this
(
false
,
false
,
false
,
0
,
0
,
DataSegment
.
Empty
)
{
}
internal
override
IpV6Option
CreateInstance
(
DataSegment
data
)
{
{
if
(
data
.
Length
<
OptionDataMinimumLength
)
if
(
data
.
Length
<
OptionDataMinimumLength
)
return
null
;
return
null
;
...
@@ -122,5 +117,10 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -122,5 +117,10 @@ namespace PcapDotNet.Packets.IpV6
buffer
.
Write
(
ref
offset
,
SenderRank
,
Endianity
.
Big
);
buffer
.
Write
(
ref
offset
,
SenderRank
,
Endianity
.
Big
);
buffer
.
Write
(
ref
offset
,
SubTlvs
);
buffer
.
Write
(
ref
offset
,
SubTlvs
);
}
}
private
IpV6OptionRoutingProtocolLowPowerAndLossyNetworks
()
:
this
(
false
,
false
,
false
,
0
,
0
,
DataSegment
.
Empty
)
{
}
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/IpV6/Options/IpV6OptionSimple.cs
View file @
ec3b6965
...
@@ -27,10 +27,5 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -27,10 +27,5 @@ namespace PcapDotNet.Packets.IpV6
{
{
base
.
Write
(
buffer
,
ref
offset
);
base
.
Write
(
buffer
,
ref
offset
);
}
}
internal
override
sealed
IpV6Option
CreateInstance
(
DataSegment
data
)
{
throw
new
InvalidOperationException
(
"Simple options shouldn't be registered."
);
}
}
}
}
}
PcapDotNet/src/PcapDotNet.Packets/IpV6/Options/IpV6OptionSmfDpd.cs
View file @
ec3b6965
...
@@ -17,7 +17,6 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -17,7 +17,6 @@ namespace PcapDotNet.Packets.IpV6
/// +-----+----------------------+
/// +-----+----------------------+
/// </pre>
/// </pre>
/// </summary>
/// </summary>
[
IpV6OptionTypeRegistration
(
IpV6OptionType
.
SmfDpd
)]
public
abstract
class
IpV6OptionSmfDpd
:
IpV6OptionComplex
public
abstract
class
IpV6OptionSmfDpd
:
IpV6OptionComplex
{
{
private
static
class
Offset
private
static
class
Offset
...
@@ -43,8 +42,7 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -43,8 +42,7 @@ namespace PcapDotNet.Packets.IpV6
/// 1 == indicates a hash assist value (HAV) field follows to aid in avoiding hash-based DPD collisions.
/// 1 == indicates a hash assist value (HAV) field follows to aid in avoiding hash-based DPD collisions.
/// </summary>
/// </summary>
public
abstract
bool
HashIndicator
{
get
;
}
public
abstract
bool
HashIndicator
{
get
;
}
internal
static
IpV6Option
CreateInstance
(
DataSegment
data
)
internal
override
IpV6Option
CreateInstance
(
DataSegment
data
)
{
{
if
(
data
.
Length
<
OptionDataMinimumLength
)
if
(
data
.
Length
<
OptionDataMinimumLength
)
return
null
;
return
null
;
...
@@ -55,4 +53,13 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -55,4 +53,13 @@ namespace PcapDotNet.Packets.IpV6
return
IpV6OptionSmfDpdSequenceBased
.
CreateSpecificInstance
(
data
);
return
IpV6OptionSmfDpdSequenceBased
.
CreateSpecificInstance
(
data
);
}
}
}
}
[
IpV6OptionTypeRegistration
(
IpV6OptionType
.
SmfDpd
)]
internal
class
IpV6OptionSmfDpdFactory
:
IIpV6OptionComplexFactory
{
public
IpV6Option
CreateInstance
(
DataSegment
data
)
{
return
IpV6OptionSmfDpd
.
CreateInstance
(
data
);
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/IpV6/Options/IpV6OptionTunnelEncapsulationLimit.cs
View file @
ec3b6965
...
@@ -13,7 +13,7 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -13,7 +13,7 @@ namespace PcapDotNet.Packets.IpV6
/// </pre>
/// </pre>
/// </summary>
/// </summary>
[
IpV6OptionTypeRegistration
(
IpV6OptionType
.
TunnelEncapsulationLimit
)]
[
IpV6OptionTypeRegistration
(
IpV6OptionType
.
TunnelEncapsulationLimit
)]
public
class
IpV6OptionTunnelEncapsulationLimit
:
IpV6OptionComplex
public
class
IpV6OptionTunnelEncapsulationLimit
:
IpV6OptionComplex
,
IIpV6OptionComplexFactory
{
{
public
const
int
OptionDataLength
=
sizeof
(
byte
);
public
const
int
OptionDataLength
=
sizeof
(
byte
);
...
@@ -28,7 +28,7 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -28,7 +28,7 @@ namespace PcapDotNet.Packets.IpV6
/// </summary>
/// </summary>
public
byte
TunnelEncapsulationLimit
{
get
;
private
set
;
}
public
byte
TunnelEncapsulationLimit
{
get
;
private
set
;
}
internal
override
IpV6Option
CreateInstance
(
DataSegment
data
)
public
IpV6Option
CreateInstance
(
DataSegment
data
)
{
{
if
(
data
.
Length
!=
OptionDataLength
)
if
(
data
.
Length
!=
OptionDataLength
)
return
null
;
return
null
;
...
@@ -45,5 +45,10 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -45,5 +45,10 @@ namespace PcapDotNet.Packets.IpV6
{
{
buffer
.
Write
(
ref
offset
,
TunnelEncapsulationLimit
);
buffer
.
Write
(
ref
offset
,
TunnelEncapsulationLimit
);
}
}
private
IpV6OptionTunnelEncapsulationLimit
()
:
this
(
0
)
{
}
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/IpV6/Options/IpV6OptionUnknown.cs
View file @
ec3b6965
This diff is collapsed.
Click to expand it.
PcapDotNet/src/PcapDotNet.Packets/IpV6/Options/IpV6Options.cs
View file @
ec3b6965
...
@@ -7,6 +7,11 @@ using PcapDotNet.Packets.Ip;
...
@@ -7,6 +7,11 @@ using PcapDotNet.Packets.Ip;
namespace
PcapDotNet.Packets.IpV6
namespace
PcapDotNet.Packets.IpV6
{
{
internal
interface
IIpV6OptionComplexFactory
{
IpV6Option
CreateInstance
(
DataSegment
data
);
}
public
class
IpV6Options
:
Options
<
IpV6Option
>
public
class
IpV6Options
:
Options
<
IpV6Option
>
{
{
public
IpV6Options
(
IList
<
IpV6Option
>
options
)
public
IpV6Options
(
IList
<
IpV6Option
>
options
)
...
@@ -65,24 +70,23 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -65,24 +70,23 @@ namespace PcapDotNet.Packets.IpV6
private
static
IpV6Option
CreateOption
(
IpV6OptionType
optionType
,
DataSegment
data
)
private
static
IpV6Option
CreateOption
(
IpV6OptionType
optionType
,
DataSegment
data
)
{
{
I
pV6Option
prototype
;
I
IpV6OptionComplexFactory
factory
;
if
(!
_
prototypes
.
TryGetValue
(
optionType
,
out
prototype
))
if
(!
_
factories
.
TryGetValue
(
optionType
,
out
factory
))
return
new
IpV6OptionUnknown
(
optionType
,
data
);
return
new
IpV6OptionUnknown
(
optionType
,
data
);
return
prototype
.
CreateInstance
(
data
);
return
factory
.
CreateInstance
(
data
);
}
}
private
static
readonly
Dictionary
<
IpV6OptionType
,
I
pV6Option
>
_prototypes
=
InitializePrototyp
es
();
private
static
readonly
Dictionary
<
IpV6OptionType
,
I
IpV6OptionComplexFactory
>
_factories
=
InitializeFactori
es
();
private
static
Dictionary
<
IpV6OptionType
,
I
pV6Option
>
InitializePrototyp
es
()
private
static
Dictionary
<
IpV6OptionType
,
I
IpV6OptionComplexFactory
>
InitializeFactori
es
()
{
{
var
prototypes
=
var
prototypes
=
from
type
in
Assembly
.
GetExecutingAssembly
().
GetTypes
()
from
type
in
Assembly
.
GetExecutingAssembly
().
GetTypes
()
where
typeof
(
IpV6Option
).
IsAssignableFrom
(
type
)
&&
where
GetRegistrationAttribute
(
type
)
!=
null
GetRegistrationAttribute
(
type
)
!=
null
select
new
select
new
{
{
GetRegistrationAttribute
(
type
).
OptionType
,
GetRegistrationAttribute
(
type
).
OptionType
,
Option
=
(
I
pV6Option
)
Activator
.
CreateInstance
(
typ
e
)
Option
=
(
I
IpV6OptionComplexFactory
)
Activator
.
CreateInstance
(
type
,
tru
e
)
};
};
return
prototypes
.
ToDictionary
(
option
=>
option
.
OptionType
,
option
=>
option
.
Option
);
return
prototypes
.
ToDictionary
(
option
=>
option
.
OptionType
,
option
=>
option
.
Option
);
...
@@ -195,7 +199,7 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -195,7 +199,7 @@ namespace PcapDotNet.Packets.IpV6
select
new
select
new
{
{
GetRegistrationAttribute
(
type
).
OptionType
,
GetRegistrationAttribute
(
type
).
OptionType
,
Option
=
(
IpV6MobilityOption
)
Activator
.
CreateInstance
(
type
)
Option
=
(
IpV6MobilityOption
)
Activator
.
CreateInstance
(
type
,
true
)
};
};
return
prototypes
.
ToDictionary
(
option
=>
option
.
OptionType
,
option
=>
option
.
Option
);
return
prototypes
.
ToDictionary
(
option
=>
option
.
OptionType
,
option
=>
option
.
Option
);
...
...
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