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
6cec2f16
Commit
6cec2f16
authored
Apr 13, 2012
by
Brickner_cp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
VLanTaggedFrame
parent
f2a2a4e6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
170 additions
and
140 deletions
+170
-140
LivePacketDeviceTests.cs
PcapDotNet/src/PcapDotNet.Core.Test/LivePacketDeviceTests.cs
+1
-1
WiresharkCompareTests.cs
PcapDotNet/src/PcapDotNet.Core.Test/WiresharkCompareTests.cs
+131
-107
VLanTaggedFrameTests.cs
...otNet/src/PcapDotNet.Packets.Test/VLanTaggedFrameTests.cs
+1
-0
EthernetLayer.cs
PcapDotNet/src/PcapDotNet.Packets/Ethernet/EthernetLayer.cs
+36
-15
Layer.cs
PcapDotNet/src/PcapDotNet.Packets/Layer.cs
+0
-14
VLanTaggedFrameLayer.cs
...capDotNet.Packets/VLanTaggedFrame/VLanTaggedFrameLayer.cs
+1
-3
No files found.
PcapDotNet/src/PcapDotNet.Core.Test/LivePacketDeviceTests.cs
View file @
6cec2f16
...
...
@@ -184,7 +184,7 @@ namespace PcapDotNet.Core.Test
TestReceivePacketsEnumerable
(
NumPacketsToSend
,
NumPacketsToSend
+
1
,
int
.
MaxValue
,
2
,
PacketSize
,
NumPacketsToSend
,
2
,
2.13
);
// Break loop
TestReceivePacketsEnumerable
(
NumPacketsToSend
,
NumPacketsToSend
,
0
,
2
,
PacketSize
,
0
,
0
,
0.0
32
);
TestReceivePacketsEnumerable
(
NumPacketsToSend
,
NumPacketsToSend
,
0
,
2
,
PacketSize
,
0
,
0
,
0.0
51
);
TestReceivePacketsEnumerable
(
NumPacketsToSend
,
NumPacketsToSend
,
NumPacketsToSend
/
2
,
2
,
PacketSize
,
NumPacketsToSend
/
2
,
0
,
0.1
);
}
...
...
PcapDotNet/src/PcapDotNet.Core.Test/WiresharkCompareTests.cs
View file @
6cec2f16
This diff is collapsed.
Click to expand it.
PcapDotNet/src/PcapDotNet.Packets.Test/VLanTaggedFrameTests.cs
View file @
6cec2f16
...
...
@@ -84,6 +84,7 @@ namespace PcapDotNet.Packets.Test
Assert
.
AreEqual
(
ethernetLayer
,
packet
.
Ethernet
.
ExtractLayer
());
Assert
.
AreEqual
(
EthernetType
.
IpV4
,
packet
.
Ethernet
.
VLanTaggedFrame
.
EtherType
);
Assert
.
AreEqual
(
vLanTaggedFrameLayer
,
packet
.
Ethernet
.
VLanTaggedFrame
.
ExtractLayer
());
ipV4Layer
.
HeaderChecksum
=
packet
.
Ethernet
.
VLanTaggedFrame
.
IpV4
.
HeaderChecksum
;
Assert
.
AreEqual
(
ipV4Layer
,
packet
.
Ethernet
.
VLanTaggedFrame
.
IpV4
.
ExtractLayer
());
}
}
...
...
PcapDotNet/src/PcapDotNet.Packets/Ethernet/EthernetLayer.cs
View file @
6cec2f16
...
...
@@ -4,11 +4,46 @@ using PcapDotNet.Packets.Arp;
namespace
PcapDotNet.Packets.Ethernet
{
public
abstract
class
EthernetBaseLayer
:
Layer
,
IArpPreviousLayer
{
public
EthernetBaseLayer
()
{
EtherType
=
EthernetType
.
None
;
}
/// <summary>
/// Ethernet type (next protocol).
/// </summary>
public
EthernetType
EtherType
{
get
;
set
;
}
/// <summary>
/// The ARP Hardware Type of the layer before the ARP layer.
/// </summary>
public
ArpHardwareType
PreviousLayerHardwareType
{
get
{
return
ArpHardwareType
.
Ethernet
;
}
}
internal
static
EthernetType
GetEthernetType
(
EthernetType
ethernetType
,
ILayer
nextLayer
)
{
if
(
ethernetType
!=
EthernetType
.
None
)
return
ethernetType
;
if
(
nextLayer
==
null
)
throw
new
ArgumentException
(
"Can't determine ether type automatically from next layer because there is not next layer"
);
IEthernetNextLayer
ethernetNextLayer
=
nextLayer
as
IEthernetNextLayer
;
if
(
ethernetNextLayer
==
null
)
throw
new
ArgumentException
(
"Can't determine ether type automatically from next layer ("
+
nextLayer
.
GetType
()
+
")"
);
return
ethernetNextLayer
.
PreviousLayerEtherType
;
}
}
/// <summary>
/// Represents an Ethernet layer.
/// <seealso cref="EthernetDatagram"/>
/// </summary>
public
sealed
class
EthernetLayer
:
Layer
,
IArpPrevious
Layer
public
sealed
class
EthernetLayer
:
EthernetBase
Layer
{
/// <summary>
/// Creates an instance with zero values.
...
...
@@ -17,7 +52,6 @@ namespace PcapDotNet.Packets.Ethernet
{
Source
=
MacAddress
.
Zero
;
Destination
=
MacAddress
.
Zero
;
EtherType
=
EthernetType
.
None
;
}
/// <summary>
...
...
@@ -30,11 +64,6 @@ namespace PcapDotNet.Packets.Ethernet
/// </summary>
public
MacAddress
Destination
{
get
;
set
;
}
/// <summary>
/// Ethernet type (next protocol).
/// </summary>
public
EthernetType
EtherType
{
get
;
set
;
}
/// <summary>
/// The number of bytes this layer will take.
/// </summary>
...
...
@@ -75,14 +104,6 @@ namespace PcapDotNet.Packets.Ethernet
get
{
return
DataLinkKind
.
Ethernet
;
}
}
/// <summary>
/// The ARP Hardware Type of the layer before the ARP layer.
/// </summary>
public
ArpHardwareType
PreviousLayerHardwareType
{
get
{
return
ArpHardwareType
.
Ethernet
;
}
}
/// <summary>
/// Two Ethernet layers are equal if they have the same source, destination and ethernet type.
/// </summary>
...
...
PcapDotNet/src/PcapDotNet.Packets/Layer.cs
View file @
6cec2f16
...
...
@@ -70,19 +70,5 @@ namespace PcapDotNet.Packets
{
return
Length
.
GetHashCode
()
^
DataLink
.
GetHashCode
();
}
internal
static
EthernetType
GetEthernetType
(
EthernetType
ethernetType
,
ILayer
nextLayer
)
{
if
(
ethernetType
!=
EthernetType
.
None
)
return
ethernetType
;
if
(
nextLayer
==
null
)
throw
new
ArgumentException
(
"Can't determine ether type automatically from next layer because there is not next layer"
);
IEthernetNextLayer
ethernetNextLayer
=
nextLayer
as
IEthernetNextLayer
;
if
(
ethernetNextLayer
==
null
)
throw
new
ArgumentException
(
"Can't determine ether type automatically from next layer ("
+
nextLayer
.
GetType
()
+
")"
);
return
ethernetNextLayer
.
PreviousLayerEtherType
;
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/VLanTaggedFrame/VLanTaggedFrameLayer.cs
View file @
6cec2f16
...
...
@@ -4,7 +4,7 @@ using PcapDotNet.Packets.Ethernet;
namespace
PcapDotNet.Packets.VLanTaggedFrame
{
public
sealed
class
VLanTaggedFrameLayer
:
Layer
,
IEquatable
<
VLanTaggedFrameLayer
>,
IEthernetNextLayer
public
sealed
class
VLanTaggedFrameLayer
:
EthernetBase
Layer
,
IEquatable
<
VLanTaggedFrameLayer
>,
IEthernetNextLayer
{
public
VLanTaggedFrameLayer
()
{
...
...
@@ -21,8 +21,6 @@ namespace PcapDotNet.Packets.VLanTaggedFrame
get
{
return
VLanTaggedFrameDatagram
.
CalculateTagControlInformation
(
PriorityCodePoint
,
CanonicalFormatIndicator
,
VLanIdentifier
);
}
}
public
EthernetType
EtherType
{
get
;
set
;
}
/// <summary>
/// The number of bytes this layer will take.
/// </summary>
...
...
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