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
da9e87ef
Commit
da9e87ef
authored
Apr 25, 2014
by
Brickner_cp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve IPv4 tests.
parent
fa000133
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
1 deletion
+34
-1
WiresharkDatagramComparerIpV4.cs
...src/PcapDotNet.Core.Test/WiresharkDatagramComparerIpV4.cs
+34
-1
No files found.
PcapDotNet/src/PcapDotNet.Core.Test/WiresharkDatagramComparerIpV4.cs
View file @
da9e87ef
...
...
@@ -22,38 +22,66 @@ namespace PcapDotNet.Core.Test
{
case
"ip.version"
:
field
.
AssertShowDecimal
(
ipV4Datagram
.
Version
);
field
.
AssertNoFields
();
break
;
case
"ip.hdr_len"
:
field
.
AssertShowDecimal
(
ipV4Datagram
.
HeaderLength
);
field
.
AssertNoFields
();
break
;
case
"ip.dsfield"
:
field
.
AssertShowDecimal
((
int
)
ipV4Datagram
.
TypeOfService
);
// TODO: Parse TypeOfService to Differentiated Services and ECN.
break
;
case
"ip.len"
:
field
.
AssertShowDecimal
(
ipV4Datagram
.
TotalLength
);
field
.
AssertNoFields
();
break
;
case
"ip.id"
:
field
.
AssertShowHex
(
ipV4Datagram
.
Identification
);
field
.
AssertNoFields
();
break
;
case
"ip.flags"
:
field
.
AssertShowHex
((
byte
)((
ushort
)
ipV4Datagram
.
Fragmentation
.
Options
>>
13
));
foreach
(
XElement
subfield
in
field
.
Fields
())
{
subfield
.
AssertNoFields
();
switch
(
subfield
.
Name
())
{
case
"ip.flags.rb"
:
break
;
case
"ip.flags.df"
:
subfield
.
AssertShowDecimal
((
ipV4Datagram
.
Fragmentation
.
Options
&
IpV4FragmentationOptions
.
DoNotFragment
)
==
IpV4FragmentationOptions
.
DoNotFragment
);
break
;
case
"ip.flags.mf"
:
subfield
.
AssertShowDecimal
((
ipV4Datagram
.
Fragmentation
.
Options
&
IpV4FragmentationOptions
.
MoreFragments
)
==
IpV4FragmentationOptions
.
MoreFragments
);
break
;
default
:
throw
new
InvalidOperationException
(
string
.
Format
(
"Invalid ip flags subfield {0}"
,
subfield
.
Name
()));
}
}
break
;
case
"ip.frag_offset"
:
field
.
AssertShowDecimal
(
ipV4Datagram
.
Fragmentation
.
Offset
);
field
.
AssertNoFields
();
break
;
case
"ip.ttl"
:
field
.
AssertShowDecimal
(
ipV4Datagram
.
Ttl
);
field
.
AssertNoFields
();
break
;
case
"ip.proto"
:
field
.
AssertShowDecimal
((
byte
)
ipV4Datagram
.
Protocol
);
field
.
AssertNoFields
();
break
;
case
"ip.checksum"
:
...
...
@@ -64,6 +92,7 @@ namespace PcapDotNet.Core.Test
{
case
"ip.checksum_good"
:
checksumField
.
AssertShowDecimal
(
ipV4Datagram
.
IsHeaderChecksumCorrect
);
checksumField
.
AssertNoFields
();
break
;
case
"ip.checksum_bad"
:
...
...
@@ -72,6 +101,7 @@ namespace PcapDotNet.Core.Test
break
;
checksumField
.
AssertShowDecimal
(!
ipV4Datagram
.
IsHeaderChecksumCorrect
);
checksumField
.
AssertNoFields
();
break
;
}
}
...
...
@@ -80,6 +110,7 @@ namespace PcapDotNet.Core.Test
case
"ip.src"
:
case
"ip.src_host"
:
field
.
AssertShow
(
ipV4Datagram
.
Source
.
ToString
());
field
.
AssertNoFields
();
break
;
case
"ip.dst"
:
...
...
@@ -92,6 +123,7 @@ namespace PcapDotNet.Core.Test
string
.
Format
(
"Expected destination: {0}. Destination: {1}. Current destination: {2}."
,
field
.
Show
(),
ipV4Datagram
.
Destination
,
ipV4Datagram
.
CurrentDestination
));
}
field
.
AssertNoFields
();
break
;
case
"ip.addr"
:
...
...
@@ -105,6 +137,7 @@ namespace PcapDotNet.Core.Test
?
string
.
Format
(
"Source: {0}. Destination: {1}. Current destination: {2}."
,
ipV4Datagram
.
Source
,
ipV4Datagram
.
Destination
,
ipV4Datagram
.
CurrentDestination
)
:
""
));
field
.
AssertNoFields
();
break
;
case
""
:
...
...
@@ -112,7 +145,7 @@ namespace PcapDotNet.Core.Test
break
;
default
:
throw
new
InvalidOperationException
(
"Invalid ip field "
+
field
.
Name
(
));
throw
new
InvalidOperationException
(
string
.
Format
(
"Invalid ip field {0}"
,
field
.
Name
()
));
}
return
true
;
...
...
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