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
40982c0c
Commit
40982c0c
authored
Oct 04, 2014
by
Brickner_cp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code Coverage 96.26%
parent
83dc50e8
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
5 deletions
+51
-5
EthernetTests.cs
PcapDotNet/src/PcapDotNet.Packets.Test/EthernetTests.cs
+9
-0
IpV4Tests.cs
PcapDotNet/src/PcapDotNet.Packets.Test/IpV4Tests.cs
+9
-1
IpV6Tests.cs
PcapDotNet/src/PcapDotNet.Packets.Test/IpV6Tests.cs
+33
-4
No files found.
PcapDotNet/src/PcapDotNet.Packets.Test/EthernetTests.cs
View file @
40982c0c
...
@@ -2,6 +2,8 @@ using System;
...
@@ -2,6 +2,8 @@ using System;
using
System.Linq
;
using
System.Linq
;
using
Microsoft.VisualStudio.TestTools.UnitTesting
;
using
Microsoft.VisualStudio.TestTools.UnitTesting
;
using
PcapDotNet.Packets.Ethernet
;
using
PcapDotNet.Packets.Ethernet
;
using
PcapDotNet.Packets.IpV4
;
using
PcapDotNet.Packets.IpV6
;
using
PcapDotNet.Packets.TestUtils
;
using
PcapDotNet.Packets.TestUtils
;
using
PcapDotNet.Packets.Transport
;
using
PcapDotNet.Packets.Transport
;
...
@@ -67,6 +69,13 @@ namespace PcapDotNet.Packets.Test
...
@@ -67,6 +69,13 @@ namespace PcapDotNet.Packets.Test
Assert
.
AreNotEqual
(
random
.
NextEthernetLayer
().
ToString
(),
packet
.
Ethernet
.
ExtractLayer
().
ToString
(),
"Ethernet Layer ToString()"
);
Assert
.
AreNotEqual
(
random
.
NextEthernetLayer
().
ToString
(),
packet
.
Ethernet
.
ExtractLayer
().
ToString
(),
"Ethernet Layer ToString()"
);
Assert
.
AreNotEqual
(
2
,
packet
.
Ethernet
.
Source
,
"Ethernet Source"
);
Assert
.
AreNotEqual
(
2
,
packet
.
Ethernet
.
Source
,
"Ethernet Source"
);
if
(
packet
.
Ethernet
.
EtherType
==
EthernetType
.
IpV4
)
Assert
.
IsInstanceOfType
(
packet
.
Ethernet
.
Ip
,
typeof
(
IpV4Datagram
));
else
if
(
packet
.
Ethernet
.
EtherType
==
EthernetType
.
IpV6
)
Assert
.
IsInstanceOfType
(
packet
.
Ethernet
.
Ip
,
typeof
(
IpV6Datagram
));
else
Assert
.
IsNull
(
packet
.
Ethernet
.
Ip
);
Assert
.
AreEqual
(
payloadLayer
.
Data
,
packet
.
Ethernet
.
Payload
);
Assert
.
AreEqual
(
payloadLayer
.
Data
,
packet
.
Ethernet
.
Payload
);
}
}
}
}
...
...
PcapDotNet/src/PcapDotNet.Packets.Test/IpV4Tests.cs
View file @
40982c0c
...
@@ -4,6 +4,7 @@ using System.Linq;
...
@@ -4,6 +4,7 @@ using System.Linq;
using
Microsoft.VisualStudio.TestTools.UnitTesting
;
using
Microsoft.VisualStudio.TestTools.UnitTesting
;
using
PcapDotNet.Packets.Ethernet
;
using
PcapDotNet.Packets.Ethernet
;
using
PcapDotNet.Packets.IpV4
;
using
PcapDotNet.Packets.IpV4
;
using
PcapDotNet.Packets.IpV6
;
using
PcapDotNet.Packets.TestUtils
;
using
PcapDotNet.Packets.TestUtils
;
using
PcapDotNet.Packets.Transport
;
using
PcapDotNet.Packets.Transport
;
using
PcapDotNet.TestUtils
;
using
PcapDotNet.TestUtils
;
...
@@ -158,6 +159,13 @@ namespace PcapDotNet.Packets.Test
...
@@ -158,6 +159,13 @@ namespace PcapDotNet.Packets.Test
else
else
Assert
.
IsNull
(
packet
.
Ethernet
.
IpV4
.
Transport
);
Assert
.
IsNull
(
packet
.
Ethernet
.
IpV4
.
Transport
);
if
(
packet
.
Ethernet
.
IpV4
.
Protocol
==
IpV4Protocol
.
Ip
)
Assert
.
IsInstanceOfType
(
packet
.
Ethernet
.
IpV4
.
Ip
,
typeof
(
IpV4Datagram
));
else
if
(
packet
.
Ethernet
.
IpV4
.
Protocol
==
IpV4Protocol
.
IpV6
)
Assert
.
IsInstanceOfType
(
packet
.
Ethernet
.
IpV4
.
Ip
,
typeof
(
IpV6Datagram
));
else
Assert
.
IsNull
(
packet
.
Ethernet
.
IpV4
.
Ip
);
Assert
.
AreEqual
(
payloadLayer
.
Data
,
packet
.
Ethernet
.
IpV4
.
Payload
,
"IP Payload"
);
Assert
.
AreEqual
(
payloadLayer
.
Data
,
packet
.
Ethernet
.
IpV4
.
Payload
,
"IP Payload"
);
}
}
}
}
...
...
PcapDotNet/src/PcapDotNet.Packets.Test/IpV6Tests.cs
View file @
40982c0c
...
@@ -69,7 +69,7 @@ namespace PcapDotNet.Packets.Test
...
@@ -69,7 +69,7 @@ namespace PcapDotNet.Packets.Test
Random
random
=
new
Random
();
Random
random
=
new
Random
();
int
seed
=
random
.
Next
();
int
seed
=
random
.
Next
();
Console
.
WriteLine
(
"Seed: "
+
seed
);
Console
.
WriteLine
(
"Seed: "
+
seed
);
random
=
new
Random
(
1930237499
);
random
=
new
Random
(
seed
);
for
(
int
i
=
0
;
i
!=
1000
;
++
i
)
for
(
int
i
=
0
;
i
!=
1000
;
++
i
)
{
{
...
@@ -77,9 +77,6 @@ namespace PcapDotNet.Packets.Test
...
@@ -77,9 +77,6 @@ namespace PcapDotNet.Packets.Test
PayloadLayer
payloadLayer
=
random
.
NextPayloadLayer
(
random
.
NextInt
(
0
,
50
*
1024
));
PayloadLayer
payloadLayer
=
random
.
NextPayloadLayer
(
random
.
NextInt
(
0
,
50
*
1024
));
if
(
i
<
26
)
continue
;
List
<
ILayer
>
layers
=
new
List
<
ILayer
>
{
ethernetLayer
,
ipV6Layer
};
List
<
ILayer
>
layers
=
new
List
<
ILayer
>
{
ethernetLayer
,
ipV6Layer
};
if
(
ipV6Layer
.
ExtensionHeaders
.
LastHeader
!=
IpV4Protocol
.
EncapsulatingSecurityPayload
)
if
(
ipV6Layer
.
ExtensionHeaders
.
LastHeader
!=
IpV4Protocol
.
EncapsulatingSecurityPayload
)
layers
.
Add
(
payloadLayer
);
layers
.
Add
(
payloadLayer
);
...
@@ -299,6 +296,38 @@ namespace PcapDotNet.Packets.Test
...
@@ -299,6 +296,38 @@ namespace PcapDotNet.Packets.Test
// IpV6ExtensionHeader tests.
// IpV6ExtensionHeader tests.
[
TestMethod
]
public
void
IpV6ExtensionHeadersAutomaticNextHeaderByNextExtensionHeader
()
{
Packet
packet
=
PacketBuilder
.
Build
(
DateTime
.
Now
,
new
EthernetLayer
(),
new
IpV6Layer
{
ExtensionHeaders
=
new
IpV6ExtensionHeaders
(
new
IpV6ExtensionHeaderDestinationOptions
(
null
,
IpV6Options
.
Empty
),
new
IpV6ExtensionHeaderDestinationOptions
(
IpV4Protocol
.
Skip
,
IpV6Options
.
Empty
))
});
Assert
.
IsTrue
(
packet
.
IsValid
);
Assert
.
AreEqual
(
IpV4Protocol
.
IpV6Opts
,
packet
.
Ethernet
.
IpV6
.
ExtensionHeaders
[
0
].
NextHeader
);
}
[
TestMethod
]
[
ExpectedException
(
typeof
(
InvalidOperationException
),
AllowDerivedTypes
=
false
)]
public
void
IpV6ExtensionHeadersAutomaticNextHeaderFailure
()
{
Assert
.
IsNull
(
PacketBuilder
.
Build
(
DateTime
.
Now
,
new
EthernetLayer
(),
new
IpV6Layer
{
ExtensionHeaders
=
new
IpV6ExtensionHeaders
(
new
IpV6ExtensionHeaderDestinationOptions
(
null
,
IpV6Options
.
Empty
))
}));
Assert
.
Fail
();
}
[
TestMethod
]
[
TestMethod
]
public
void
IpV6ExtensionHeaderAuthenticationBadPayloadLength
()
public
void
IpV6ExtensionHeaderAuthenticationBadPayloadLength
()
{
{
...
...
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