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
34f840dc
Commit
34f840dc
authored
May 21, 2010
by
Brickner_cp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ethernet Trailer and Frame Check Sequence
parent
7de27730
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
2 deletions
+34
-2
WiresharkCompareTests.cs
PcapDotNet/src/PcapDotNet.Core.Test/WiresharkCompareTests.cs
+18
-0
EthernetDatagram.cs
...otNet/src/PcapDotNet.Packets/Ethernet/EthernetDatagram.cs
+16
-2
No files found.
PcapDotNet/src/PcapDotNet.Core.Test/WiresharkCompareTests.cs
View file @
34f840dc
...
...
@@ -98,6 +98,22 @@ namespace PcapDotNet.Core.Test
ComparePacketsToWireshark
(
packet
);
}
[
TestMethod
]
public
void
CompareEthernetFcsToWiresharkTest
()
{
Packet
packet
=
PacketBuilder
.
Build
(
DateTime
.
Now
,
new
EthernetLayer
(),
new
IpV4Layer
{
Protocol
=
IpV4Protocol
.
Udp
});
byte
[]
buffer
=
new
byte
[
packet
.
Length
+
100
];
new
Random
().
NextBytes
(
buffer
);
packet
.
CopyTo
(
buffer
,
0
);
packet
=
new
Packet
(
buffer
,
DateTime
.
Now
,
DataLinkKind
.
Ethernet
);
ComparePacketsToWireshark
(
packet
);
}
private
enum
PacketType
{
Ethernet
,
...
...
@@ -416,6 +432,8 @@ namespace PcapDotNet.Core.Test
break
;
case
""
:
if
(
ethernetDatagram
.
Trailer
!=
null
)
field
.
AssertValue
(
ethernetDatagram
.
FrameCheckSequence
);
break
;
default
:
...
...
PcapDotNet/src/PcapDotNet.Packets/Ethernet/EthernetDatagram.cs
View file @
34f840dc
...
...
@@ -104,8 +104,22 @@ namespace PcapDotNet.Packets.Ethernet
return
null
;
int
payloadLength
=
PayloadByEtherType
.
Length
;
int
fcs
=
Length
>=
68
?
4
:
0
;
return
new
Datagram
(
Buffer
,
HeaderLength
+
payloadLength
,
Math
.
Max
(
0
,
Length
-
HeaderLength
-
payloadLength
-
fcs
));
Datagram
fcs
=
FrameCheckSequence
;
return
new
Datagram
(
Buffer
,
HeaderLength
+
payloadLength
,
Length
-
HeaderLength
-
payloadLength
-
(
fcs
==
null
?
0
:
fcs
.
Length
));
}
}
public
Datagram
FrameCheckSequence
{
get
{
Datagram
payloadByEtherType
=
PayloadByEtherType
;
if
(
payloadByEtherType
==
null
)
return
null
;
if
(
Length
-
payloadByEtherType
.
Length
>=
4
&&
Length
>=
68
)
return
new
Datagram
(
Buffer
,
Length
-
4
,
4
);
return
null
;
}
}
...
...
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