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
80e525f9
Commit
80e525f9
authored
Oct 03, 2009
by
Brickner_cp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code Coverage 94.73%
parent
5e6eba25
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
287 additions
and
12 deletions
+287
-12
LocalTestRun.testrunconfig
PcapDotNet/src/LocalTestRun.testrunconfig
+1
-1
LivePacketDeviceTests.cs
PcapDotNet/src/PcapDotNet.Core.Test/LivePacketDeviceTests.cs
+1
-1
ArpTests.cs
PcapDotNet/src/PcapDotNet.Packets.Test/ArpTests.cs
+20
-0
IgmpTests.cs
PcapDotNet/src/PcapDotNet.Packets.Test/IgmpTests.cs
+256
-0
IpV4AddressTests.cs
PcapDotNet/src/PcapDotNet.Packets.Test/IpV4AddressTests.cs
+3
-0
IgmpDatagram.cs
PcapDotNet/src/PcapDotNet.Packets/Igmp/IgmpDatagram.cs
+5
-9
IgmpGroupRecordDatagram.cs
...et/src/PcapDotNet.Packets/Igmp/IgmpGroupRecordDatagram.cs
+1
-1
No files found.
PcapDotNet/src/LocalTestRun.testrunconfig
View file @
80e525f9
...
@@ -5,8 +5,8 @@
...
@@ -5,8 +5,8 @@
<Regular>
<Regular>
<CodeCoverageItem
binaryFile=
"C:\TFS\tfs06.codeplex.com\PcapDotNet\PcapDotNet\bin\Debug\PcapDotNet.Base.dll"
pdbFile=
"C:\TFS\tfs06.codeplex.com\PcapDotNet\PcapDotNet\bin\Debug\PcapDotNet.Base.pdb"
instrumentInPlace=
"true"
/>
<CodeCoverageItem
binaryFile=
"C:\TFS\tfs06.codeplex.com\PcapDotNet\PcapDotNet\bin\Debug\PcapDotNet.Base.dll"
pdbFile=
"C:\TFS\tfs06.codeplex.com\PcapDotNet\PcapDotNet\bin\Debug\PcapDotNet.Base.pdb"
instrumentInPlace=
"true"
/>
<CodeCoverageItem
binaryFile=
"c:\TFS\tfs06.codeplex.com\PcapDotNet\PcapDotNet\bin\Debug\PcapDotNet.Core.dll"
pdbFile=
"c:\TFS\tfs06.codeplex.com\PcapDotNet\PcapDotNet\bin\Debug\PcapDotNet.Core.pdb"
instrumentInPlace=
"true"
/>
<CodeCoverageItem
binaryFile=
"c:\TFS\tfs06.codeplex.com\PcapDotNet\PcapDotNet\bin\Debug\PcapDotNet.Core.dll"
pdbFile=
"c:\TFS\tfs06.codeplex.com\PcapDotNet\PcapDotNet\bin\Debug\PcapDotNet.Core.pdb"
instrumentInPlace=
"true"
/>
<CodeCoverageItem
binaryFile=
"C:\TFS\tfs06.codeplex.com\PcapDotNet\PcapDotNet\bin\Debug\PcapDotNet.Core.Extensions.dll"
pdbFile=
"C:\TFS\tfs06.codeplex.com\PcapDotNet\PcapDotNet\bin\Debug\PcapDotNet.Core.Extensions.pdb"
instrumentInPlace=
"true"
/>
<CodeCoverageItem
binaryFile=
"C:\TFS\tfs06.codeplex.com\PcapDotNet\PcapDotNet\bin\Debug\PcapDotNet.Packets.dll"
pdbFile=
"C:\TFS\tfs06.codeplex.com\PcapDotNet\PcapDotNet\bin\Debug\PcapDotNet.Packets.pdb"
instrumentInPlace=
"true"
/>
<CodeCoverageItem
binaryFile=
"C:\TFS\tfs06.codeplex.com\PcapDotNet\PcapDotNet\bin\Debug\PcapDotNet.Packets.dll"
pdbFile=
"C:\TFS\tfs06.codeplex.com\PcapDotNet\PcapDotNet\bin\Debug\PcapDotNet.Packets.pdb"
instrumentInPlace=
"true"
/>
<CodeCoverageItem
binaryFile=
"C:\TFS\tfs06.codeplex.com\PcapDotNet\PcapDotNet\bin\Debug\PcapDotNet.Core.Extensions.dll"
pdbFile=
"C:\TFS\tfs06.codeplex.com\PcapDotNet\PcapDotNet\bin\Debug\PcapDotNet.Core.Extensions.pdb"
instrumentInPlace=
"true"
/>
</Regular>
</Regular>
</CodeCoverage>
</CodeCoverage>
<TestTypeSpecific>
<TestTypeSpecific>
...
...
PcapDotNet/src/PcapDotNet.Core.Test/LivePacketDeviceTests.cs
View file @
80e525f9
...
@@ -155,7 +155,7 @@ namespace PcapDotNet.Core.Test
...
@@ -155,7 +155,7 @@ namespace PcapDotNet.Core.Test
const
int
PacketSize
=
100
;
const
int
PacketSize
=
100
;
// Normal
// Normal
TestReceivePacketsEnumerable
(
NumPacketsToSend
,
NumPacketsToSend
,
int
.
MaxValue
,
2
,
PacketSize
,
NumPacketsToSend
,
0
,
0.
05
);
TestReceivePacketsEnumerable
(
NumPacketsToSend
,
NumPacketsToSend
,
int
.
MaxValue
,
2
,
PacketSize
,
NumPacketsToSend
,
0
,
0.
3
);
// Wait for less packets
// Wait for less packets
TestReceivePacketsEnumerable
(
NumPacketsToSend
,
NumPacketsToSend
/
2
,
int
.
MaxValue
,
2
,
PacketSize
,
NumPacketsToSend
/
2
,
0
,
0.02
);
TestReceivePacketsEnumerable
(
NumPacketsToSend
,
NumPacketsToSend
/
2
,
int
.
MaxValue
,
2
,
PacketSize
,
NumPacketsToSend
/
2
,
0
,
0.02
);
...
...
PcapDotNet/src/PcapDotNet.Packets.Test/ArpTests.cs
View file @
80e525f9
...
@@ -93,5 +93,25 @@ namespace PcapDotNet.Packets.Test
...
@@ -93,5 +93,25 @@ namespace PcapDotNet.Packets.Test
MoreAssert
.
AreSequenceEqual
(
arpTargetProtocolAddress
,
packet
.
Ethernet
.
Arp
.
TargetProtocolAddress
,
"Arp TargetProtocolAddress"
);
MoreAssert
.
AreSequenceEqual
(
arpTargetProtocolAddress
,
packet
.
Ethernet
.
Arp
.
TargetProtocolAddress
,
"Arp TargetProtocolAddress"
);
}
}
}
}
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentException
))]
public
void
ArpIncosistentSenderAddressSizeTest
()
{
Packet
packet
=
PacketBuilder
.
EthernetArp
(
DateTime
.
Now
,
new
MacAddress
(),
EthernetType
.
IpV4
,
ArpOperation
.
Request
,
new
byte
[
4
],
new
byte
[
6
],
new
byte
[
5
],
new
byte
[
6
]);
Assert
.
IsNull
(
packet
);
Assert
.
Fail
();
}
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentException
))]
public
void
ArpIncosistentTargetAddressSizeTest
()
{
Packet
packet
=
PacketBuilder
.
EthernetArp
(
DateTime
.
Now
,
new
MacAddress
(),
EthernetType
.
IpV4
,
ArpOperation
.
Request
,
new
byte
[
4
],
new
byte
[
6
],
new
byte
[
4
],
new
byte
[
7
]);
Assert
.
IsNull
(
packet
);
Assert
.
Fail
();
}
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets.Test/IgmpTests.cs
View file @
80e525f9
This diff is collapsed.
Click to expand it.
PcapDotNet/src/PcapDotNet.Packets.Test/IpV4AddressTests.cs
View file @
80e525f9
...
@@ -64,6 +64,8 @@ namespace PcapDotNet.Packets.Test
...
@@ -64,6 +64,8 @@ namespace PcapDotNet.Packets.Test
[
TestMethod
]
[
TestMethod
]
public
void
IpV4AddressRandomTest
()
public
void
IpV4AddressRandomTest
()
{
{
Assert
.
AreEqual
(
IpV4Address
.
AllHostsHroupAddress
,
new
IpV4Address
(
"224.0.0.1"
));
Random
random
=
new
Random
();
Random
random
=
new
Random
();
for
(
int
i
=
0
;
i
!=
1000
;
++
i
)
for
(
int
i
=
0
;
i
!=
1000
;
++
i
)
...
@@ -82,6 +84,7 @@ namespace PcapDotNet.Packets.Test
...
@@ -82,6 +84,7 @@ namespace PcapDotNet.Packets.Test
Assert
.
AreNotEqual
(
address
.
GetHashCode
(),
random
.
NextIpV4Address
().
GetHashCode
());
Assert
.
AreNotEqual
(
address
.
GetHashCode
(),
random
.
NextIpV4Address
().
GetHashCode
());
Assert
.
AreNotEqual
(
2
,
address
);
Assert
.
AreNotEqual
(
2
,
address
);
Assert
.
IsFalse
(
address
.
Equals
(
null
));
}
}
}
}
...
...
PcapDotNet/src/PcapDotNet.Packets/Igmp/IgmpDatagram.cs
View file @
80e525f9
...
@@ -563,16 +563,12 @@ namespace PcapDotNet.Packets.Igmp
...
@@ -563,16 +563,12 @@ namespace PcapDotNet.Packets.Igmp
case
IgmpMessageType
.
MembershipQuery
:
case
IgmpMessageType
.
MembershipQuery
:
switch
(
QueryVersion
)
switch
(
QueryVersion
)
{
{
case
IgmpQueryVersion
.
Version1
:
case
IgmpQueryVersion
.
Version1
:
// Version 1 actually means that the MaxResponseCode is 0.
return
Length
==
HeaderLength
&&
MaxResponseCode
==
0
;
case
IgmpQueryVersion
.
Version2
:
case
IgmpQueryVersion
.
Version2
:
return
Length
==
HeaderLength
;
return
Length
==
HeaderLength
;
case
IgmpQueryVersion
.
Version3
:
case
IgmpQueryVersion
.
Version3
:
return
Length
>=
QueryVersion3HeaderLength
&&
return
Length
==
GetQueryVersion3Length
(
NumberOfSources
);
Length
==
GetQueryVersion3Length
(
NumberOfSources
)
&&
NumberOfSources
==
SourceAddresses
.
Count
;
default
:
default
:
return
false
;
return
false
;
...
@@ -586,7 +582,7 @@ namespace PcapDotNet.Packets.Igmp
...
@@ -586,7 +582,7 @@ namespace PcapDotNet.Packets.Igmp
return
Length
==
HeaderLength
;
return
Length
==
HeaderLength
;
case
IgmpMessageType
.
MembershipReportVersion3
:
case
IgmpMessageType
.
MembershipReportVersion3
:
return
MaxResponseCode
==
0
&&
NumberOfGroupRecords
==
GroupRecords
.
Count
&&
return
MaxResponseCode
==
0
&&
Length
==
HeaderLength
+
GroupRecords
.
Sum
(
record
=>
record
.
Length
)
&&
Length
==
HeaderLength
+
GroupRecords
.
Sum
(
record
=>
record
.
Length
)
&&
GroupRecords
.
All
(
record
=>
record
.
IsValid
);
GroupRecords
.
All
(
record
=>
record
.
IsValid
);
...
@@ -629,11 +625,11 @@ namespace PcapDotNet.Packets.Igmp
...
@@ -629,11 +625,11 @@ namespace PcapDotNet.Packets.Igmp
{
{
int
exp
=
(
int
)(
Math
.
Log
(
value
,
2
)
-
7
);
int
exp
=
(
int
)(
Math
.
Log
(
value
,
2
)
-
7
);
if
(
exp
>
7
||
exp
<
0
)
if
(
exp
>
7
||
exp
<
0
)
throw
new
ArgumentOutOfRangeException
(
"
exp"
,
exp
,
"value "
+
value
+
" is out of range"
);
throw
new
ArgumentOutOfRangeException
(
"
value"
,
value
,
"exp "
+
exp
+
" is out of range"
);
int
mant
=
(
int
)(
value
*
Math
.
Pow
(
2
,
-
exp
-
3
)
-
16
);
int
mant
=
(
int
)(
value
*
Math
.
Pow
(
2
,
-
exp
-
3
)
-
16
);
if
(
mant
>
15
||
mant
<
0
)
if
(
mant
>
15
||
mant
<
0
)
throw
new
ArgumentOutOfRangeException
(
"
mant"
,
mant
,
"value "
+
value
+
" is out of range"
);
throw
new
ArgumentOutOfRangeException
(
"
value"
,
value
,
"mant "
+
mant
+
" is out of range"
);
return
(
byte
)(
0x80
|
(
exp
<<
4
)
|
mant
);
return
(
byte
)(
0x80
|
(
exp
<<
4
)
|
mant
);
}
}
...
...
PcapDotNet/src/PcapDotNet.Packets/Igmp/IgmpGroupRecordDatagram.cs
View file @
80e525f9
...
@@ -150,7 +150,7 @@ namespace PcapDotNet.Packets.Igmp
...
@@ -150,7 +150,7 @@ namespace PcapDotNet.Packets.Igmp
/// <summary>
/// <summary>
/// The record is valid if the length is correct according to the header fields.
/// The record is valid if the length is correct according to the header fields.
/// </summary>
/// </summary>
protected
override
bool
CalculateIsValid
()
protected
override
bool
CalculateIsValid
()
{
{
return
Length
>=
HeaderLength
&&
return
Length
>=
HeaderLength
&&
Length
==
HeaderLength
+
IpV4Address
.
SizeOf
*
NumberOfSources
+
AuxiliaryDataLength
;
Length
==
HeaderLength
+
IpV4Address
.
SizeOf
*
NumberOfSources
+
AuxiliaryDataLength
;
...
...
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