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
87c607eb
Commit
87c607eb
authored
Nov 28, 2009
by
Brickner_cp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IPv4 Header Checksum is in Layer
parent
b2293f3d
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
14 additions
and
4 deletions
+14
-4
IcmpTests.cs
PcapDotNet/src/PcapDotNet.Packets.Test/IcmpTests.cs
+2
-0
IgmpTests.cs
PcapDotNet/src/PcapDotNet.Packets.Test/IgmpTests.cs
+2
-0
IpV4Tests.cs
PcapDotNet/src/PcapDotNet.Packets.Test/IpV4Tests.cs
+1
-0
TcpTests.cs
PcapDotNet/src/PcapDotNet.Packets.Test/TcpTests.cs
+2
-0
IpV4Datagram.cs
PcapDotNet/src/PcapDotNet.Packets/IpV4/IpV4Datagram.cs
+6
-4
PacketBuilder2.cs
PcapDotNet/src/PcapDotNet.Packets/PacketBuilder2.cs
+1
-0
No files found.
PcapDotNet/src/PcapDotNet.Packets.Test/IcmpTests.cs
View file @
87c607eb
...
...
@@ -137,7 +137,9 @@ namespace PcapDotNet.Packets.Test
// IPv4
ipV4Layer
.
Protocol
=
IpV4Protocol
.
InternetControlMessageProtocol
;
ipV4Layer
.
HeaderChecksum
=
((
IpV4Layer
)
packet
.
Ethernet
.
IpV4
.
ExtractLayer
()).
HeaderChecksum
;
Assert
.
AreEqual
(
ipV4Layer
,
packet
.
Ethernet
.
IpV4
.
ExtractLayer
());
ipV4Layer
.
HeaderChecksum
=
null
;
Assert
.
AreEqual
(
ipV4Layer
.
Length
,
packet
.
Ethernet
.
IpV4
.
HeaderLength
);
Assert
.
IsTrue
(
packet
.
Ethernet
.
IpV4
.
IsHeaderChecksumCorrect
);
Assert
.
AreEqual
(
ipV4Layer
.
Length
+
icmpLayer
.
Length
+
(
isIpV4Payload
?
icmpIpV4Layer
.
Length
+
icmpIpV4PayloadLayer
.
Length
:
0
),
...
...
PcapDotNet/src/PcapDotNet.Packets.Test/IgmpTests.cs
View file @
87c607eb
...
...
@@ -92,7 +92,9 @@ namespace PcapDotNet.Packets.Test
// IPv4
ipV4Layer
.
Protocol
=
IpV4Protocol
.
InternetGroupManagementProtocol
;
ipV4Layer
.
HeaderChecksum
=
((
IpV4Layer
)
packet
.
Ethernet
.
IpV4
.
ExtractLayer
()).
HeaderChecksum
;
Assert
.
AreEqual
(
ipV4Layer
,
packet
.
Ethernet
.
IpV4
.
ExtractLayer
(),
"IPv4 Layer"
);
ipV4Layer
.
HeaderChecksum
=
null
;
// IGMP
Assert
.
IsTrue
(
packet
.
Ethernet
.
IpV4
.
Igmp
.
IsChecksumCorrect
);
...
...
PcapDotNet/src/PcapDotNet.Packets.Test/IpV4Tests.cs
View file @
87c607eb
...
...
@@ -132,6 +132,7 @@ namespace PcapDotNet.Packets.Test
Assert
.
AreEqual
(
ethernetLayer
,
packet
.
Ethernet
.
ExtractLayer
(),
"Ethernet Layer"
);
// IpV4
ipV4Layer
.
HeaderChecksum
=
((
IpV4Layer
)
packet
.
Ethernet
.
IpV4
.
ExtractLayer
()).
HeaderChecksum
;
Assert
.
AreEqual
(
ipV4Layer
,
packet
.
Ethernet
.
IpV4
.
ExtractLayer
(),
"IP Layer"
);
Assert
.
AreEqual
(
IpV4Datagram
.
HeaderMinimumLength
+
ipV4Layer
.
Options
.
BytesLength
,
packet
.
Ethernet
.
IpV4
.
HeaderLength
,
"IP HeaderLength"
);
Assert
.
AreEqual
(
packet
.
Length
-
EthernetDatagram
.
HeaderLength
,
packet
.
Ethernet
.
IpV4
.
TotalLength
,
"IP TotalLength"
);
...
...
PcapDotNet/src/PcapDotNet.Packets.Test/TcpTests.cs
View file @
87c607eb
...
...
@@ -94,7 +94,9 @@ namespace PcapDotNet.Packets.Test
// IpV4
ipV4Layer
.
Protocol
=
IpV4Protocol
.
Tcp
;
ipV4Layer
.
HeaderChecksum
=
((
IpV4Layer
)
packet
.
Ethernet
.
IpV4
.
ExtractLayer
()).
HeaderChecksum
;
Assert
.
AreEqual
(
ipV4Layer
,
packet
.
Ethernet
.
IpV4
.
ExtractLayer
(),
"IP Layer"
);
ipV4Layer
.
HeaderChecksum
=
null
;
// TCP
Assert
.
AreEqual
(
tcpLayer
,
packet
.
Ethernet
.
IpV4
.
Tcp
.
ExtractLayer
(),
"TCP Layer"
);
...
...
PcapDotNet/src/PcapDotNet.Packets/IpV4/IpV4Datagram.cs
View file @
87c607eb
...
...
@@ -313,7 +313,7 @@ namespace PcapDotNet.Packets.IpV4
internal
static
void
WriteHeader
(
byte
[]
buffer
,
int
offset
,
byte
typeOfService
,
ushort
identification
,
IpV4Fragmentation
fragmentation
,
byte
ttl
,
IpV4Protocol
protocol
,
ushort
?
c
hecksum
,
byte
ttl
,
IpV4Protocol
protocol
,
ushort
?
headerC
hecksum
,
IpV4Address
source
,
IpV4Address
destination
,
IpV4Options
options
,
int
payloadLength
)
{
...
...
@@ -331,9 +331,11 @@ namespace PcapDotNet.Packets.IpV4
buffer
.
Write
(
offset
+
Offset
.
Destination
,
destination
,
Endianity
.
Big
);
options
.
Write
(
buffer
,
offset
+
Offset
.
Options
);
if
(
checksum
==
null
)
checksum
=
Sum16BitsToChecksum
(
Sum16Bits
(
buffer
,
offset
,
headerLength
));
buffer
.
Write
(
offset
+
Offset
.
HeaderChecksum
,
checksum
.
Value
,
Endianity
.
Big
);
ushort
headerChecksumValue
=
headerChecksum
==
null
?
Sum16BitsToChecksum
(
Sum16Bits
(
buffer
,
offset
,
headerLength
))
:
headerChecksum
.
Value
;
buffer
.
Write
(
offset
+
Offset
.
HeaderChecksum
,
headerChecksumValue
,
Endianity
.
Big
);
}
internal
static
void
WriteTransportChecksum
(
byte
[]
buffer
,
int
offset
,
int
headerLength
,
ushort
transportLength
,
int
transportChecksumOffset
,
bool
isChecksumOptional
)
...
...
PcapDotNet/src/PcapDotNet.Packets/PacketBuilder2.cs
View file @
87c607eb
...
...
@@ -262,6 +262,7 @@ namespace PcapDotNet.Packets
TypeOfService
==
other
.
TypeOfService
&&
Identification
==
other
.
Identification
&&
Fragmentation
==
other
.
Fragmentation
&&
Ttl
==
other
.
Ttl
&&
Protocol
==
other
.
Protocol
&&
HeaderChecksum
==
other
.
HeaderChecksum
&&
Source
==
other
.
Source
&&
Destination
==
other
.
Destination
&&
Options
.
Equals
(
other
.
Options
);
}
...
...
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