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
d0ed8367
Commit
d0ed8367
authored
Nov 29, 2009
by
Brickner_cp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PacketBuilder new design
parent
cd86ed94
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
173 additions
and
882 deletions
+173
-882
LocalTestRun.testrunconfig
PcapDotNet/src/LocalTestRun.testrunconfig
+8
-1
PacketDumpFileTests.cs
PcapDotNet/src/PcapDotNet.Core.Test/PacketDumpFileTests.cs
+11
-2
WiresharkCompareTests.cs
PcapDotNet/src/PcapDotNet.Core.Test/WiresharkCompareTests.cs
+21
-121
ArpTests.cs
PcapDotNet/src/PcapDotNet.Packets.Test/ArpTests.cs
+42
-9
IgmpTests.cs
PcapDotNet/src/PcapDotNet.Packets.Test/IgmpTests.cs
+70
-75
TcpTests.cs
PcapDotNet/src/PcapDotNet.Packets.Test/TcpTests.cs
+8
-5
RandomPacketsExtensions.cs
...c/PcapDotNet.Packets.TestUtils/RandomPacketsExtensions.cs
+8
-3
PacketBuilder.cs
PcapDotNet/src/PcapDotNet.Packets/PacketBuilder.cs
+0
-666
PacketBuilder2.cs
PcapDotNet/src/PcapDotNet.Packets/PacketBuilder2.cs
+5
-0
No files found.
PcapDotNet/src/LocalTestRun.testrunconfig
View file @
d0ed8367
<?xml version="1.0" encoding="UTF-8"?>
<TestRunConfiguration
name=
"Local Test Run"
id=
"be17286c-6d1c-43dd-b068-e83867abf9c5"
xmlns=
"http://microsoft.com/schemas/VisualStudio/TeamTest/2006"
>
<Description>
This is a default test run configuration for a local test run.
</Description>
<CodeCoverage
keyFile=
"PcapDotNet.snk"
/>
<CodeCoverage
enabled=
"true"
keyFile=
"PcapDotNet.snk"
>
<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.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"
/>
</Regular>
</CodeCoverage>
<TestTypeSpecific>
<WebTestRunConfiguration
testTypeId=
"4e7599fa-5ecb-43e9-a887-cd63cf72d207"
>
<Browser
name=
"Internet Explorer 7.0"
>
...
...
PcapDotNet/src/PcapDotNet.Core.Test/PacketDumpFileTests.cs
View file @
d0ed8367
...
...
@@ -64,8 +64,17 @@ namespace PcapDotNet.Core.Test
{
string
filename
=
Path
.
GetTempPath
()
+
@"dump.pcap"
;
Packet
expectedPacket
=
PacketBuilder
.
Ethernet
(
DateTime
.
Now
,
new
MacAddress
(
1
),
new
MacAddress
(
2
),
EthernetType
.
QInQ
,
new
Datagram
(
new
byte
[]
{
1
,
2
,
3
}));
Packet
expectedPacket
=
PacketBuilder2
.
Build
(
DateTime
.
Now
,
new
EthernetLayer
{
Source
=
new
MacAddress
(
1
),
Destination
=
new
MacAddress
(
2
),
EtherType
=
EthernetType
.
QInQ
,
},
new
PayloadLayer
{
Data
=
new
Datagram
(
new
byte
[]
{
1
,
2
,
3
})
});
PacketDumpFile
.
Dump
(
filename
,
new
PcapDataLink
(
DataLinkKind
.
Ethernet
),
PacketDevice
.
DefaultSnapshotLength
,
new
[]
{
expectedPacket
});
...
...
PcapDotNet/src/PcapDotNet.Core.Test/WiresharkCompareTests.cs
View file @
d0ed8367
This diff is collapsed.
Click to expand it.
PcapDotNet/src/PcapDotNet.Packets.Test/ArpTests.cs
View file @
d0ed8367
...
...
@@ -85,11 +85,20 @@ namespace PcapDotNet.Packets.Test
[
TestMethod
]
public
void
ArpProtocolIpV4Address
()
{
Packet
packet
=
PacketBuilder
.
EthernetArp
(
DateTime
.
Now
,
new
MacAddress
(),
EthernetType
.
QInQ
,
ArpOperation
.
Request
,
new
byte
[
8
],
new
byte
[]
{
1
,
2
,
3
,
4
},
new
byte
[
8
],
new
byte
[]
{
11
,
22
,
33
,
44
});
Packet
packet
=
PacketBuilder2
.
Build
(
DateTime
.
Now
,
new
EthernetLayer
{
Source
=
new
MacAddress
(),
EtherType
=
EthernetType
.
QInQ
},
new
ArpLayer
{
Operation
=
ArpOperation
.
Request
,
SenderHardwareAddress
=
new
byte
[
8
],
SenderProtocolAddress
=
new
byte
[]{
1
,
2
,
3
,
4
},
TargetHardwareAddress
=
new
byte
[
8
],
TargetProtocolAddress
=
new
byte
[]{
11
,
22
,
33
,
44
}
});
Assert
.
AreEqual
(
new
IpV4Address
(
"1.2.3.4"
),
packet
.
Ethernet
.
Arp
.
SenderProtocolIpV4Address
);
Assert
.
AreEqual
(
new
IpV4Address
(
"11.22.33.44"
),
packet
.
Ethernet
.
Arp
.
TargetProtocolIpV4Address
);
...
...
@@ -99,8 +108,20 @@ namespace PcapDotNet.Packets.Test
[
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
]);
Packet
packet
=
PacketBuilder2
.
Build
(
DateTime
.
Now
,
new
EthernetLayer
{
Source
=
new
MacAddress
(),
EtherType
=
EthernetType
.
IpV4
},
new
ArpLayer
{
Operation
=
ArpOperation
.
Request
,
SenderHardwareAddress
=
new
byte
[
4
],
SenderProtocolAddress
=
new
byte
[
6
],
TargetHardwareAddress
=
new
byte
[
5
],
TargetProtocolAddress
=
new
byte
[
6
]
});
Assert
.
IsNull
(
packet
);
Assert
.
Fail
();
}
...
...
@@ -109,8 +130,20 @@ namespace PcapDotNet.Packets.Test
[
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
]);
Packet
packet
=
PacketBuilder2
.
Build
(
DateTime
.
Now
,
new
EthernetLayer
{
Source
=
new
MacAddress
(),
EtherType
=
EthernetType
.
IpV4
},
new
ArpLayer
{
Operation
=
ArpOperation
.
Request
,
SenderHardwareAddress
=
new
byte
[
4
],
SenderProtocolAddress
=
new
byte
[
6
],
TargetHardwareAddress
=
new
byte
[
4
],
TargetProtocolAddress
=
new
byte
[
7
]
});
Assert
.
IsNull
(
packet
);
Assert
.
Fail
();
}
...
...
PcapDotNet/src/PcapDotNet.Packets.Test/IgmpTests.cs
View file @
d0ed8367
This diff is collapsed.
Click to expand it.
PcapDotNet/src/PcapDotNet.Packets.Test/TcpTests.cs
View file @
d0ed8367
...
...
@@ -160,11 +160,14 @@ namespace PcapDotNet.Packets.Test
[
TestMethod
]
public
void
TcpOptionMd5SignatureCreateInstanceErrorDataLengthTest
()
{
Packet
packet
=
PacketBuilder
.
EthernetIpV4Tcp
(
DateTime
.
Now
,
new
MacAddress
(),
new
MacAddress
(),
0
,
0
,
new
IpV4Fragmentation
(),
0
,
new
IpV4Address
(),
new
IpV4Address
(),
new
IpV4Options
(),
0
,
0
,
0
,
0
,
new
TcpControlBits
(),
0
,
0
,
new
TcpOptions
(
new
TcpOptionMd5Signature
(
new
byte
[]{
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
,
12
,
13
,
14
,
15
,
16
})),
Datagram
.
Empty
);
Packet
packet
=
PacketBuilder2
.
Build
(
DateTime
.
Now
,
new
EthernetLayer
(),
new
IpV4Layer
(),
new
TcpLayer
{
Options
=
new
TcpOptions
(
new
TcpOptionMd5Signature
(
new
byte
[]
{
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
,
12
,
13
,
14
,
15
,
16
}))
});
Assert
.
IsTrue
(
packet
.
IsValid
);
Assert
.
IsTrue
(
packet
.
Ethernet
.
IpV4
.
Tcp
.
Options
.
IsValid
);
...
...
PcapDotNet/src/PcapDotNet.Packets.TestUtils/RandomPacketsExtensions.cs
View file @
d0ed8367
...
...
@@ -75,9 +75,14 @@ namespace PcapDotNet.Packets.TestUtils
if
(
packetSize
<
EthernetDatagram
.
HeaderLength
)
throw
new
ArgumentOutOfRangeException
(
"packetSize"
,
packetSize
,
"Must be at least the ethernet header length ("
+
EthernetDatagram
.
HeaderLength
+
")"
);
return
PacketBuilder
.
Ethernet
(
timestamp
,
ethernetSource
,
ethernetDestination
,
random
.
NextEthernetType
(),
random
.
NextDatagram
(
packetSize
-
EthernetDatagram
.
HeaderLength
));
return
PacketBuilder2
.
Build
(
timestamp
,
new
EthernetLayer
{
Source
=
ethernetSource
,
Destination
=
ethernetDestination
,
EtherType
=
random
.
NextEthernetType
()
},
random
.
NextPayloadLayer
(
packetSize
-
EthernetDatagram
.
HeaderLength
));
}
public
static
Packet
NextEthernetPacket
(
this
Random
random
,
int
packetSize
,
DateTime
timestamp
,
string
ethernetSource
,
string
ethernetDestination
)
...
...
PcapDotNet/src/PcapDotNet.Packets/PacketBuilder.cs
View file @
d0ed8367
This diff is collapsed.
Click to expand it.
PcapDotNet/src/PcapDotNet.Packets/PacketBuilder2.cs
View file @
d0ed8367
...
...
@@ -592,6 +592,11 @@ namespace PcapDotNet.Packets
public
class
IgmpQueryVersion3Layer
:
IgmpLayer
,
IIgmpLayerWithGroupAddress
{
public
IgmpQueryVersion3Layer
()
{
SourceAddresses
=
new
List
<
IpV4Address
>();
}
public
TimeSpan
MaxResponseTime
{
get
;
set
;
}
public
IpV4Address
GroupAddress
{
get
;
set
;
}
public
bool
IsSuppressRouterSideProcessing
{
get
;
set
;
}
...
...
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