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
fd4ee701
Commit
fd4ee701
authored
Aug 02, 2014
by
Brickner_cp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IPv6
Code Coverage 95.26%
parent
a156a551
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
61 additions
and
10 deletions
+61
-10
WiresharkDatagramComparerIpV6MobilityHeader.cs
....Core.Test/WiresharkDatagramComparerIpV6MobilityHeader.cs
+1
-0
IpV6Tests.cs
PcapDotNet/src/PcapDotNet.Packets.Test/IpV6Tests.cs
+51
-1
IpV6ExtensionHeaderStandard.cs
...kets/IpV6/ExtensionHeaders/IpV6ExtensionHeaderStandard.cs
+0
-3
IpV6Options.cs
...DotNet/src/PcapDotNet.Packets/IpV6/Options/IpV6Options.cs
+9
-6
No files found.
PcapDotNet/src/PcapDotNet.Core.Test/WiresharkDatagramComparerIpV6MobilityHeader.cs
View file @
fd4ee701
...
@@ -107,6 +107,7 @@ namespace PcapDotNet.Core.Test
...
@@ -107,6 +107,7 @@ namespace PcapDotNet.Core.Test
protocol
==
IpV4Protocol
.
MeritInternodalProtocol
||
protocol
==
IpV4Protocol
.
MeritInternodalProtocol
||
protocol
==
IpV4Protocol
.
Skip
||
protocol
==
IpV4Protocol
.
Skip
||
protocol
==
IpV4Protocol
.
Bna
||
protocol
==
IpV4Protocol
.
Bna
||
protocol
==
IpV4Protocol
.
InterDomainRoutingProtocol
||
protocol
==
IpV4Protocol
.
RemoteVirtualDiskProtocol
))
protocol
==
IpV4Protocol
.
RemoteVirtualDiskProtocol
))
return
false
;
return
false
;
...
...
PcapDotNet/src/PcapDotNet.Packets.Test/IpV6Tests.cs
View file @
fd4ee701
using
System
;
using
System
;
using
System.Collections
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Linq
;
using
Microsoft.VisualStudio.TestTools.UnitTesting
;
using
Microsoft.VisualStudio.TestTools.UnitTesting
;
...
@@ -83,7 +84,7 @@ namespace PcapDotNet.Packets.Test
...
@@ -83,7 +84,7 @@ namespace PcapDotNet.Packets.Test
Assert
.
AreEqual
(
ipV6Layer
,
packet
.
Ethernet
.
IpV6
.
ExtractLayer
(),
"IP Layer"
);
Assert
.
AreEqual
(
ipV6Layer
,
packet
.
Ethernet
.
IpV6
.
ExtractLayer
(),
"IP Layer"
);
Assert
.
IsNotNull
(
ipV6Layer
.
GetHashCode
());
Assert
.
IsNotNull
(
ipV6Layer
.
GetHashCode
());
Assert
.
AreEqual
(
string
.
Format
(
"{0} -> {1} ({2})"
,
ipV6Layer
.
Source
,
ipV6Layer
.
CurrentDestination
,
ipV6Layer
.
NextHeader
),
ipV6Layer
.
ToString
());
Assert
.
AreEqual
(
string
.
Format
(
"{0} -> {1} ({2})"
,
ipV6Layer
.
Source
,
ipV6Layer
.
CurrentDestination
,
ipV6Layer
.
NextHeader
),
ipV6Layer
.
ToString
());
foreach
(
IpV6ExtensionHeader
extensionHeader
in
packet
.
Ethernet
.
IpV6
.
ExtensionHeaders
)
foreach
(
IpV6ExtensionHeader
extensionHeader
in
(
IEnumerable
)
packet
.
Ethernet
.
IpV6
.
ExtensionHeaders
)
{
{
IpV6ExtensionHeaderOptions
extensionHeaderOptions
=
extensionHeader
as
IpV6ExtensionHeaderOptions
;
IpV6ExtensionHeaderOptions
extensionHeaderOptions
=
extensionHeader
as
IpV6ExtensionHeaderOptions
;
if
(
extensionHeaderOptions
!=
null
)
if
(
extensionHeaderOptions
!=
null
)
...
@@ -451,5 +452,54 @@ namespace PcapDotNet.Packets.Test
...
@@ -451,5 +452,54 @@ namespace PcapDotNet.Packets.Test
{
{
Assert
.
IsNull
(
new
IpV6MobilityOptionBindingIdentifier
(
0
,
IpV6BindingAcknowledgementStatus
.
AcceptedBut
,
false
,
0x80
));
Assert
.
IsNull
(
new
IpV6MobilityOptionBindingIdentifier
(
0
,
IpV6BindingAcknowledgementStatus
.
AcceptedBut
,
false
,
0x80
));
}
}
[
TestMethod
]
public
void
IpV6ExtensionHeaderTooShort
()
{
Packet
packet
=
PacketBuilder
.
Build
(
DateTime
.
Now
,
new
EthernetLayer
(),
new
IpV6Layer
{
ExtensionHeaders
=
new
IpV6ExtensionHeaders
(
new
IpV6ExtensionHeaderDestinationOptions
(
IpV4Protocol
.
Skip
,
IpV6Options
.
Empty
))
});
Assert
.
IsTrue
(
packet
.
IsValid
);
Packet
invalidPacket
=
new
Packet
(
packet
.
Buffer
.
Take
(
packet
.
Length
-
1
).
ToArray
(),
DateTime
.
Now
,
DataLinkKind
.
Ethernet
);
Assert
.
IsFalse
(
invalidPacket
.
IsValid
);
}
[
TestMethod
]
public
void
IpV6ExtensionHeaderAuthenticationTooShort
()
{
Packet
packet
=
PacketBuilder
.
Build
(
DateTime
.
Now
,
new
EthernetLayer
(),
new
IpV6Layer
{
ExtensionHeaders
=
new
IpV6ExtensionHeaders
(
new
IpV6ExtensionHeaderAuthentication
(
IpV4Protocol
.
Skip
,
0
,
0
,
DataSegment
.
Empty
))
});
Assert
.
IsTrue
(
packet
.
IsValid
);
Packet
invalidPacket
=
new
Packet
(
packet
.
Buffer
.
Take
(
packet
.
Length
-
1
).
ToArray
(),
DateTime
.
Now
,
DataLinkKind
.
Ethernet
);
Assert
.
IsFalse
(
invalidPacket
.
IsValid
);
}
[
TestMethod
]
public
void
IpV6ExtensionHeaderAuthenticationBadPayloadLength
()
{
Packet
packet
=
PacketBuilder
.
Build
(
DateTime
.
Now
,
new
EthernetLayer
(),
new
IpV6Layer
{
ExtensionHeaders
=
new
IpV6ExtensionHeaders
(
new
IpV6ExtensionHeaderAuthentication
(
IpV4Protocol
.
Skip
,
0
,
0
,
new
DataSegment
(
new
byte
[
12
])))
});
Assert
.
IsTrue
(
packet
.
IsValid
);
++
packet
.
Buffer
[
14
+
40
+
1
];
Packet
invalidPacket
=
new
Packet
(
packet
.
Buffer
,
DateTime
.
Now
,
DataLinkKind
.
Ethernet
);
Assert
.
IsFalse
(
invalidPacket
.
IsValid
);
}
}
}
}
}
PcapDotNet/src/PcapDotNet.Packets/IpV6/ExtensionHeaders/IpV6ExtensionHeaderStandard.cs
View file @
fd4ee701
...
@@ -46,9 +46,6 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -46,9 +46,6 @@ namespace PcapDotNet.Packets.IpV6
{
{
buffer
.
Write
(
offset
+
Offset
.
NextHeader
,
(
byte
)
NextHeader
);
buffer
.
Write
(
offset
+
Offset
.
NextHeader
,
(
byte
)
NextHeader
);
int
length
=
Length
;
int
length
=
Length
;
// TODO: Remove this check.
if
(
length
%
8
!=
0
)
throw
new
InvalidOperationException
(
"Must be divided by 8."
);
buffer
.
Write
(
offset
+
Offset
.
HeaderExtensionLength
,
(
byte
)((
length
/
8
)
-
1
));
buffer
.
Write
(
offset
+
Offset
.
HeaderExtensionLength
,
(
byte
)((
length
/
8
)
-
1
));
WriteData
(
buffer
,
offset
+
Offset
.
Data
);
WriteData
(
buffer
,
offset
+
Offset
.
Data
);
offset
+=
length
;
offset
+=
length
;
...
...
PcapDotNet/src/PcapDotNet.Packets/IpV6/Options/IpV6Options.cs
View file @
fd4ee701
...
@@ -9,6 +9,8 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -9,6 +9,8 @@ namespace PcapDotNet.Packets.IpV6
{
{
public
sealed
class
IpV6Options
:
Options
<
IpV6Option
>
public
sealed
class
IpV6Options
:
Options
<
IpV6Option
>
{
{
public
static
IpV6Options
Empty
{
get
{
return
_empty
;
}
}
public
IpV6Options
(
IList
<
IpV6Option
>
options
)
public
IpV6Options
(
IList
<
IpV6Option
>
options
)
:
base
(
options
,
true
,
null
)
:
base
(
options
,
true
,
null
)
{
{
...
@@ -94,18 +96,16 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -94,18 +96,16 @@ namespace PcapDotNet.Packets.IpV6
return
factory
.
CreateInstance
(
data
);
return
factory
.
CreateInstance
(
data
);
}
}
private
static
readonly
Dictionary
<
IpV6OptionType
,
IIpV6OptionComplexFactory
>
_factories
=
InitializeFactories
();
private
static
Dictionary
<
IpV6OptionType
,
IIpV6OptionComplexFactory
>
InitializeFactories
()
private
static
Dictionary
<
IpV6OptionType
,
IIpV6OptionComplexFactory
>
InitializeFactories
()
{
{
var
prototypes
=
var
prototypes
=
from
type
in
Assembly
.
GetExecutingAssembly
().
GetTypes
()
from
type
in
Assembly
.
GetExecutingAssembly
().
GetTypes
()
where
GetRegistrationAttribute
(
type
)
!=
null
where
GetRegistrationAttribute
(
type
)
!=
null
select
new
select
new
{
{
GetRegistrationAttribute
(
type
).
OptionType
,
GetRegistrationAttribute
(
type
).
OptionType
,
Option
=
(
IIpV6OptionComplexFactory
)
Activator
.
CreateInstance
(
type
,
true
)
Option
=
(
IIpV6OptionComplexFactory
)
Activator
.
CreateInstance
(
type
,
true
)
};
};
return
prototypes
.
ToDictionary
(
option
=>
option
.
OptionType
,
option
=>
option
.
Option
);
return
prototypes
.
ToDictionary
(
option
=>
option
.
OptionType
,
option
=>
option
.
Option
);
}
}
...
@@ -118,5 +118,8 @@ namespace PcapDotNet.Packets.IpV6
...
@@ -118,5 +118,8 @@ namespace PcapDotNet.Packets.IpV6
return
registraionAttributes
.
First
();
return
registraionAttributes
.
First
();
}
}
private
static
readonly
IpV6Options
_empty
=
new
IpV6Options
();
private
static
readonly
Dictionary
<
IpV6OptionType
,
IIpV6OptionComplexFactory
>
_factories
=
InitializeFactories
();
}
}
}
}
\ No newline at end of file
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