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
ae2067b6
Commit
ae2067b6
authored
Aug 08, 2014
by
Brickner_cp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code Coverage 95.52%
parent
3e6b8508
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
145 additions
and
43 deletions
+145
-43
WiresharkDatagramComparerVLanTaggedFrame.cs
...Net.Core.Test/WiresharkDatagramComparerVLanTaggedFrame.cs
+5
-3
IpV6Tests.cs
PcapDotNet/src/PcapDotNet.Packets.Test/IpV6Tests.cs
+140
-40
No files found.
PcapDotNet/src/PcapDotNet.Core.Test/WiresharkDatagramComparerVLanTaggedFrame.cs
View file @
ae2067b6
...
@@ -39,9 +39,11 @@ namespace PcapDotNet.Core.Test
...
@@ -39,9 +39,11 @@ namespace PcapDotNet.Core.Test
break
;
break
;
case
"vlan.trailer"
:
case
"vlan.trailer"
:
if
(
if
(!
new
[]
!
new
[]
{(
EthernetType
)
1
,
(
EthernetType
)
5
,
(
EthernetType
)
17
,
(
EthernetType
)
30
,
(
EthernetType
)
43
,
(
EthernetType
)
50
}.
Contains
(
{
vLanTaggedFrameDatagram
.
EtherType
))
(
EthernetType
)
1
,
(
EthernetType
)
5
,
(
EthernetType
)
17
,
(
EthernetType
)
29
,
(
EthernetType
)
30
,
(
EthernetType
)
43
,
(
EthernetType
)
50
}.
Contains
(
vLanTaggedFrameDatagram
.
EtherType
))
field
.
AssertValue
(
vLanTaggedFrameDatagram
.
TrailerWithFrameCheckSequence
);
field
.
AssertValue
(
vLanTaggedFrameDatagram
.
TrailerWithFrameCheckSequence
);
break
;
break
;
...
...
PcapDotNet/src/PcapDotNet.Packets.Test/IpV6Tests.cs
View file @
ae2067b6
...
@@ -26,6 +26,7 @@ namespace PcapDotNet.Packets.Test
...
@@ -26,6 +26,7 @@ namespace PcapDotNet.Packets.Test
public
TestContext
TestContext
{
get
;
set
;
}
public
TestContext
TestContext
{
get
;
set
;
}
#
region
Additional
test
attributes
#
region
Additional
test
attributes
//
//
// You can use the following additional attributes as you write your tests:
// You can use the following additional attributes as you write your tests:
//
//
...
@@ -45,6 +46,7 @@ namespace PcapDotNet.Packets.Test
...
@@ -45,6 +46,7 @@ namespace PcapDotNet.Packets.Test
// [TestCleanup()]
// [TestCleanup()]
// public void MyTestCleanup() { }
// public void MyTestCleanup() { }
//
//
#
endregion
#
endregion
[
TestMethod
]
[
TestMethod
]
...
@@ -132,7 +134,8 @@ namespace PcapDotNet.Packets.Test
...
@@ -132,7 +134,8 @@ namespace PcapDotNet.Packets.Test
switch
(
subOption
.
OptionType
)
switch
(
subOption
.
OptionType
)
{
{
case
IpV6AccessNetworkIdentifierSubOptionType
.
GeoLocation
:
case
IpV6AccessNetworkIdentifierSubOptionType
.
GeoLocation
:
IpV6AccessNetworkIdentifierSubOptionGeoLocation
subOptionGeoLocation
=
(
IpV6AccessNetworkIdentifierSubOptionGeoLocation
)
subOption
;
IpV6AccessNetworkIdentifierSubOptionGeoLocation
subOptionGeoLocation
=
(
IpV6AccessNetworkIdentifierSubOptionGeoLocation
)
subOption
;
MoreAssert
.
IsBiggerOrEqual
(-
90
,
subOptionGeoLocation
.
LatitudeDegreesReal
);
MoreAssert
.
IsBiggerOrEqual
(-
90
,
subOptionGeoLocation
.
LatitudeDegreesReal
);
MoreAssert
.
IsSmallerOrEqual
(
90
,
subOptionGeoLocation
.
LatitudeDegreesReal
);
MoreAssert
.
IsSmallerOrEqual
(
90
,
subOptionGeoLocation
.
LatitudeDegreesReal
);
MoreAssert
.
IsBiggerOrEqual
(-
180
,
subOptionGeoLocation
.
LongitudeDegreesReal
);
MoreAssert
.
IsBiggerOrEqual
(-
180
,
subOptionGeoLocation
.
LongitudeDegreesReal
);
...
@@ -164,7 +167,7 @@ namespace PcapDotNet.Packets.Test
...
@@ -164,7 +167,7 @@ namespace PcapDotNet.Packets.Test
Assert
.
AreEqual
(
subOptionBindingReference
,
Assert
.
AreEqual
(
subOptionBindingReference
,
new
IpV6FlowIdentificationSubOptionBindingReference
(
new
IpV6FlowIdentificationSubOptionBindingReference
(
subOptionBindingReference
.
BindingIds
.
AsEnumerable
()));
subOptionBindingReference
.
BindingIds
.
AsEnumerable
()));
break
;
break
;
}
}
}
}
break
;
break
;
...
@@ -224,10 +227,10 @@ namespace PcapDotNet.Packets.Test
...
@@ -224,10 +227,10 @@ namespace PcapDotNet.Packets.Test
DateTime
.
Now
,
DateTime
.
Now
,
new
EthernetLayer
(),
new
EthernetLayer
(),
new
IpV6Layer
new
IpV6Layer
{
{
ExtensionHeaders
=
new
IpV6ExtensionHeaders
(
ExtensionHeaders
=
new
IpV6ExtensionHeaders
(
new
IpV6ExtensionHeaderDestinationOptions
(
IpV4Protocol
.
Skip
,
new
IpV6Options
(
option
)))
new
IpV6ExtensionHeaderDestinationOptions
(
IpV4Protocol
.
Skip
,
new
IpV6Options
(
option
)))
});
});
Assert
.
IsTrue
(
packet
.
IsValid
);
Assert
.
IsTrue
(
packet
.
IsValid
);
Assert
.
AreEqual
(
option
,
((
IpV6ExtensionHeaderDestinationOptions
)
packet
.
Ethernet
.
IpV6
.
ExtensionHeaders
[
0
]).
Options
[
0
]);
Assert
.
AreEqual
(
option
,
((
IpV6ExtensionHeaderDestinationOptions
)
packet
.
Ethernet
.
IpV6
.
ExtensionHeaders
[
0
]).
Options
[
0
]);
}
}
...
@@ -261,14 +264,14 @@ namespace PcapDotNet.Packets.Test
...
@@ -261,14 +264,14 @@ namespace PcapDotNet.Packets.Test
DateTime
.
Now
,
DateTime
.
Now
,
new
EthernetLayer
(),
new
EthernetLayer
(),
new
IpV6Layer
new
IpV6Layer
{
{
ExtensionHeaders
=
new
IpV6ExtensionHeaders
(
ExtensionHeaders
=
new
IpV6ExtensionHeaders
(
new
IpV6ExtensionHeaderMobilityBindingError
(
new
IpV6ExtensionHeaderMobilityBindingError
(
IpV4Protocol
.
Skip
,
0
,
IpV6BindingErrorStatus
.
UnrecognizedMhTypeValue
,
IpV6Address
.
Zero
,
IpV4Protocol
.
Skip
,
0
,
IpV6BindingErrorStatus
.
UnrecognizedMhTypeValue
,
IpV6Address
.
Zero
,
new
IpV6MobilityOptions
(
new
IpV6MobilityOptions
(
new
IpV6MobilityOptionAccessNetworkIdentifier
(
new
IpV6MobilityOptionAccessNetworkIdentifier
(
new
IpV6AccessNetworkIdentifierSubOptions
(
subOption
)))))
new
IpV6AccessNetworkIdentifierSubOptions
(
subOption
)))))
});
});
Assert
.
IsTrue
(
packet
.
IsValid
);
Assert
.
IsTrue
(
packet
.
IsValid
);
Assert
.
AreEqual
(
subOption
,
Assert
.
AreEqual
(
subOption
,
((
IpV6MobilityOptionAccessNetworkIdentifier
)
((
IpV6MobilityOptionAccessNetworkIdentifier
)
...
@@ -284,14 +287,14 @@ namespace PcapDotNet.Packets.Test
...
@@ -284,14 +287,14 @@ namespace PcapDotNet.Packets.Test
DateTime
.
Now
,
DateTime
.
Now
,
new
EthernetLayer
(),
new
EthernetLayer
(),
new
IpV6Layer
new
IpV6Layer
{
{
ExtensionHeaders
=
new
IpV6ExtensionHeaders
(
ExtensionHeaders
=
new
IpV6ExtensionHeaders
(
new
IpV6ExtensionHeaderMobilityBindingError
(
new
IpV6ExtensionHeaderMobilityBindingError
(
IpV4Protocol
.
Skip
,
0
,
IpV6BindingErrorStatus
.
UnrecognizedMhTypeValue
,
IpV6Address
.
Zero
,
IpV4Protocol
.
Skip
,
0
,
IpV6BindingErrorStatus
.
UnrecognizedMhTypeValue
,
IpV6Address
.
Zero
,
new
IpV6MobilityOptions
(
new
IpV6MobilityOptions
(
new
IpV6MobilityOptionFlowIdentification
(
0
,
0
,
IpV6FlowIdentificationStatus
.
FlowIdentifierNotFound
,
new
IpV6MobilityOptionFlowIdentification
(
0
,
0
,
IpV6FlowIdentificationStatus
.
FlowIdentifierNotFound
,
new
IpV6FlowIdentificationSubOptions
(
subOption
)))))
new
IpV6FlowIdentificationSubOptions
(
subOption
)))))
});
});
Assert
.
IsTrue
(
packet
.
IsValid
);
Assert
.
IsTrue
(
packet
.
IsValid
);
Assert
.
AreEqual
(
subOption
,
Assert
.
AreEqual
(
subOption
,
((
IpV6MobilityOptionFlowIdentification
)
((
IpV6MobilityOptionFlowIdentification
)
...
@@ -485,10 +488,10 @@ namespace PcapDotNet.Packets.Test
...
@@ -485,10 +488,10 @@ namespace PcapDotNet.Packets.Test
DateTime
.
Now
,
DateTime
.
Now
,
new
EthernetLayer
(),
new
EthernetLayer
(),
new
IpV6Layer
new
IpV6Layer
{
{
ExtensionHeaders
=
new
IpV6ExtensionHeaders
(
ExtensionHeaders
=
new
IpV6ExtensionHeaders
(
new
IpV6ExtensionHeaderDestinationOptions
(
IpV4Protocol
.
Skip
,
IpV6Options
.
Empty
))
new
IpV6ExtensionHeaderDestinationOptions
(
IpV4Protocol
.
Skip
,
IpV6Options
.
Empty
))
});
});
Assert
.
IsTrue
(
packet
.
IsValid
);
Assert
.
IsTrue
(
packet
.
IsValid
);
Packet
invalidPacket
=
new
Packet
(
packet
.
Buffer
.
Take
(
packet
.
Length
-
1
).
ToArray
(),
DateTime
.
Now
,
DataLinkKind
.
Ethernet
);
Packet
invalidPacket
=
new
Packet
(
packet
.
Buffer
.
Take
(
packet
.
Length
-
1
).
ToArray
(),
DateTime
.
Now
,
DataLinkKind
.
Ethernet
);
Assert
.
IsFalse
(
invalidPacket
.
IsValid
);
Assert
.
IsFalse
(
invalidPacket
.
IsValid
);
...
@@ -501,10 +504,10 @@ namespace PcapDotNet.Packets.Test
...
@@ -501,10 +504,10 @@ namespace PcapDotNet.Packets.Test
DateTime
.
Now
,
DateTime
.
Now
,
new
EthernetLayer
(),
new
EthernetLayer
(),
new
IpV6Layer
new
IpV6Layer
{
{
ExtensionHeaders
=
new
IpV6ExtensionHeaders
(
ExtensionHeaders
=
new
IpV6ExtensionHeaders
(
new
IpV6ExtensionHeaderAuthentication
(
IpV4Protocol
.
Skip
,
0
,
0
,
DataSegment
.
Empty
))
new
IpV6ExtensionHeaderAuthentication
(
IpV4Protocol
.
Skip
,
0
,
0
,
DataSegment
.
Empty
))
});
});
Assert
.
IsTrue
(
packet
.
IsValid
);
Assert
.
IsTrue
(
packet
.
IsValid
);
Packet
invalidPacket
=
new
Packet
(
packet
.
Buffer
.
Take
(
packet
.
Length
-
1
).
ToArray
(),
DateTime
.
Now
,
DataLinkKind
.
Ethernet
);
Packet
invalidPacket
=
new
Packet
(
packet
.
Buffer
.
Take
(
packet
.
Length
-
1
).
ToArray
(),
DateTime
.
Now
,
DataLinkKind
.
Ethernet
);
Assert
.
IsFalse
(
invalidPacket
.
IsValid
);
Assert
.
IsFalse
(
invalidPacket
.
IsValid
);
...
@@ -517,10 +520,10 @@ namespace PcapDotNet.Packets.Test
...
@@ -517,10 +520,10 @@ namespace PcapDotNet.Packets.Test
DateTime
.
Now
,
DateTime
.
Now
,
new
EthernetLayer
(),
new
EthernetLayer
(),
new
IpV6Layer
new
IpV6Layer
{
{
ExtensionHeaders
=
new
IpV6ExtensionHeaders
(
ExtensionHeaders
=
new
IpV6ExtensionHeaders
(
new
IpV6ExtensionHeaderAuthentication
(
IpV4Protocol
.
Skip
,
0
,
0
,
new
DataSegment
(
new
byte
[
12
])))
new
IpV6ExtensionHeaderAuthentication
(
IpV4Protocol
.
Skip
,
0
,
0
,
new
DataSegment
(
new
byte
[
12
])))
});
});
Assert
.
IsTrue
(
packet
.
IsValid
);
Assert
.
IsTrue
(
packet
.
IsValid
);
++
packet
.
Buffer
[
14
+
40
+
1
];
++
packet
.
Buffer
[
14
+
40
+
1
];
Packet
invalidPacket
=
new
Packet
(
packet
.
Buffer
,
DateTime
.
Now
,
DataLinkKind
.
Ethernet
);
Packet
invalidPacket
=
new
Packet
(
packet
.
Buffer
,
DateTime
.
Now
,
DataLinkKind
.
Ethernet
);
...
@@ -536,9 +539,9 @@ namespace PcapDotNet.Packets.Test
...
@@ -536,9 +539,9 @@ namespace PcapDotNet.Packets.Test
DateTime
.
Now
,
DateTime
.
Now
,
new
EthernetLayer
(),
new
EthernetLayer
(),
new
IpV6Layer
new
IpV6Layer
{
{
NextHeader
=
IpV4Protocol
.
IpV6Route
NextHeader
=
IpV4Protocol
.
IpV6Route
},
},
new
PayloadLayer
{
Data
=
new
Datagram
(
payload
)});
new
PayloadLayer
{
Data
=
new
Datagram
(
payload
)});
Assert
.
IsFalse
(
packet
.
IsValid
);
Assert
.
IsFalse
(
packet
.
IsValid
);
}
}
...
@@ -552,9 +555,9 @@ namespace PcapDotNet.Packets.Test
...
@@ -552,9 +555,9 @@ namespace PcapDotNet.Packets.Test
DateTime
.
Now
,
DateTime
.
Now
,
new
EthernetLayer
(),
new
EthernetLayer
(),
new
IpV6Layer
new
IpV6Layer
{
{
ExtensionHeaders
=
new
IpV6ExtensionHeaders
(
new
IpV6ExtensionHeaderEncapsulatingSecurityPayload
(
0
,
0
,
DataSegment
.
Empty
))
ExtensionHeaders
=
new
IpV6ExtensionHeaders
(
new
IpV6ExtensionHeaderEncapsulatingSecurityPayload
(
0
,
0
,
DataSegment
.
Empty
))
},
},
new
PayloadLayer
{
Data
=
new
Datagram
(
new
byte
[
10
])}));
new
PayloadLayer
{
Data
=
new
Datagram
(
new
byte
[
10
])}));
}
}
...
@@ -642,5 +645,102 @@ namespace PcapDotNet.Packets.Test
...
@@ -642,5 +645,102 @@ namespace PcapDotNet.Packets.Test
new
IpV6AccessNetworkIdentifierSubOptionOperatorIdentifier
(
IpV6AccessNetworkIdentifierOperatorIdentifierType
.
PrivateEnterpriseNumber
,
new
IpV6AccessNetworkIdentifierSubOptionOperatorIdentifier
(
IpV6AccessNetworkIdentifierOperatorIdentifierType
.
PrivateEnterpriseNumber
,
new
DataSegment
(
new
byte
[
254
])))));
new
DataSegment
(
new
byte
[
254
])))));
}
}
[
TestMethod
]
public
void
IpV6MobilityOptionRedirectCreateInstanceDataShorterThanMinimum
()
{
Packet
packet
=
PacketBuilder
.
Build
(
DateTime
.
Now
,
new
EthernetLayer
(),
new
IpV6Layer
{
ExtensionHeaders
=
new
IpV6ExtensionHeaders
(
new
IpV6ExtensionHeaderMobilityBindingError
(
IpV4Protocol
.
Skip
,
0
,
IpV6BindingErrorStatus
.
UnrecognizedMhTypeValue
,
IpV6Address
.
Zero
,
new
IpV6MobilityOptions
(
new
IpV6MobilityOptionRedirect
(
IpV4Address
.
Zero
))))
});
Assert
.
IsTrue
(
packet
.
IsValid
);
packet
.
Buffer
[
14
+
40
+
24
+
1
]
=
1
;
Packet
invalidPacket
=
new
Packet
(
packet
.
Buffer
,
DateTime
.
Now
,
DataLinkKind
.
Ethernet
);
Assert
.
IsFalse
(
invalidPacket
.
IsValid
);
}
[
TestMethod
]
public
void
IpV6MobilityOptionRedirectCreateInstanceDataTooShortForIpV4
()
{
Packet
packet
=
PacketBuilder
.
Build
(
DateTime
.
Now
,
new
EthernetLayer
(),
new
IpV6Layer
{
ExtensionHeaders
=
new
IpV6ExtensionHeaders
(
new
IpV6ExtensionHeaderMobilityBindingError
(
IpV4Protocol
.
Skip
,
0
,
IpV6BindingErrorStatus
.
UnrecognizedMhTypeValue
,
IpV6Address
.
Zero
,
new
IpV6MobilityOptions
(
new
IpV6MobilityOptionRedirect
(
IpV4Address
.
Zero
))))
});
Assert
.
IsTrue
(
packet
.
IsValid
);
packet
.
Buffer
[
14
+
40
+
24
+
1
]
=
3
;
Packet
invalidPacket
=
new
Packet
(
packet
.
Buffer
,
DateTime
.
Now
,
DataLinkKind
.
Ethernet
);
Assert
.
IsFalse
(
invalidPacket
.
IsValid
);
}
[
TestMethod
]
public
void
IpV6MobilityOptionRedirectCreateInstanceDataTooShortForIpV6
()
{
Packet
packet
=
PacketBuilder
.
Build
(
DateTime
.
Now
,
new
EthernetLayer
(),
new
IpV6Layer
{
ExtensionHeaders
=
new
IpV6ExtensionHeaders
(
new
IpV6ExtensionHeaderMobilityBindingError
(
IpV4Protocol
.
Skip
,
0
,
IpV6BindingErrorStatus
.
UnrecognizedMhTypeValue
,
IpV6Address
.
Zero
,
new
IpV6MobilityOptions
(
new
IpV6MobilityOptionRedirect
(
IpV6Address
.
Zero
))))
});
Assert
.
IsTrue
(
packet
.
IsValid
);
packet
.
Buffer
[
14
+
40
+
24
+
1
]
=
15
;
Packet
invalidPacket
=
new
Packet
(
packet
.
Buffer
,
DateTime
.
Now
,
DataLinkKind
.
Ethernet
);
Assert
.
IsFalse
(
invalidPacket
.
IsValid
);
}
[
TestMethod
]
public
void
IpV6MobilityOptionRedirectCreateInstanceNotIpV6OrIpV4
()
{
Packet
packet
=
PacketBuilder
.
Build
(
DateTime
.
Now
,
new
EthernetLayer
(),
new
IpV6Layer
{
ExtensionHeaders
=
new
IpV6ExtensionHeaders
(
new
IpV6ExtensionHeaderMobilityBindingError
(
IpV4Protocol
.
Skip
,
0
,
IpV6BindingErrorStatus
.
UnrecognizedMhTypeValue
,
IpV6Address
.
Zero
,
new
IpV6MobilityOptions
(
new
IpV6MobilityOptionRedirect
(
IpV4Address
.
Zero
))))
});
Assert
.
IsTrue
(
packet
.
IsValid
);
packet
.
Buffer
[
14
+
40
+
24
+
2
]
=
0
;
Packet
invalidPacket
=
new
Packet
(
packet
.
Buffer
,
DateTime
.
Now
,
DataLinkKind
.
Ethernet
);
Assert
.
IsFalse
(
invalidPacket
.
IsValid
);
}
[
TestMethod
]
public
void
IpV6ExtensionHeaderRoutingRplParseRoutingDataPadSizeMakeNumAddressesNegative
()
{
Packet
packet
=
PacketBuilder
.
Build
(
DateTime
.
Now
,
new
EthernetLayer
(),
new
IpV6Layer
{
ExtensionHeaders
=
new
IpV6ExtensionHeaders
(
new
IpV6ExtensionHeaderRoutingRpl
(
IpV4Protocol
.
Skip
,
8
,
8
,
0
))
});
packet
.
Buffer
[
14
+
40
+
5
]
=
0x10
;
Packet
invalidPacket
=
new
Packet
(
packet
.
Buffer
,
DateTime
.
Now
,
DataLinkKind
.
Ethernet
);
Assert
.
IsFalse
(
invalidPacket
.
IsValid
);
}
}
}
}
}
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