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
457e35b8
Commit
457e35b8
authored
Nov 27, 2009
by
Brickner_cp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ICMP
parent
7bf4249c
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
489 additions
and
33 deletions
+489
-33
IcmpTests.cs
PcapDotNet/src/PcapDotNet.Packets.Test/IcmpTests.cs
+77
-17
RandomPacketsExtensions.cs
...c/PcapDotNet.Packets.TestUtils/RandomPacketsExtensions.cs
+2
-7
Datagram.cs
PcapDotNet/src/PcapDotNet.Packets/Datagram.cs
+8
-0
EthernetDatagram.cs
...otNet/src/PcapDotNet.Packets/Ethernet/EthernetDatagram.cs
+10
-0
IcmpAddressMaskDatagram.cs
...et/src/PcapDotNet.Packets/Icmp/IcmpAddressMaskDatagram.cs
+1
-1
IcmpDatagram.cs
PcapDotNet/src/PcapDotNet.Packets/Icmp/IcmpDatagram.cs
+150
-1
IcmpRouterAdvertisementDatagram.cs
...capDotNet.Packets/Icmp/IcmpRouterAdvertisementDatagram.cs
+12
-0
IcmpTracerouteLayer.cs
PcapDotNet/src/PcapDotNet.Packets/IcmpTracerouteLayer.cs
+14
-0
IpV4Datagram.cs
PcapDotNet/src/PcapDotNet.Packets/IpV4/IpV4Datagram.cs
+15
-0
PacketBuilder2.cs
PcapDotNet/src/PcapDotNet.Packets/PacketBuilder2.cs
+200
-7
No files found.
PcapDotNet/src/PcapDotNet.Packets.Test/IcmpTests.cs
View file @
457e35b8
...
@@ -90,28 +90,88 @@ namespace PcapDotNet.Packets.Test
...
@@ -90,28 +90,88 @@ namespace PcapDotNet.Packets.Test
for
(
int
i
=
0
;
i
!=
1000
;
++
i
)
for
(
int
i
=
0
;
i
!=
1000
;
++
i
)
{
{
IpV4Layer
icmpIpV4Layer
=
new
IpV4Layer
IcmpLayer
icmpLayer
=
random
.
NextIcmpLayer
();
{
TypeOfService
=
random
.
NextByte
(),
Identification
=
random
.
NextUShort
(),
Fragmentation
=
random
.
NextIpV4Fragmentation
(),
Ttl
=
random
.
NextByte
(),
Protocol
=
random
.
NextEnum
<
IpV4Protocol
>(),
Source
=
random
.
NextIpV4Address
(),
Destination
=
random
.
NextIpV4Address
(),
Options
=
random
.
NextIpV4Options
(),
};
PayloadLayer
icmpIpV4PayloadLayer
=
new
PayloadLayer
bool
isIpV4Payload
;
{
switch
(
icmpLayer
.
MessageType
)
Data
=
random
.
NextDatagram
(
random
.
Next
(
200
))
{
};
case
IcmpMessageType
.
DestinationUnreachable
:
case
IcmpMessageType
.
TimeExceeded
:
case
IcmpMessageType
.
ParameterProblem
:
case
IcmpMessageType
.
SourceQuench
:
case
IcmpMessageType
.
Redirect
:
case
IcmpMessageType
.
ConversionFailed
:
isIpV4Payload
=
true
;
break
;
IcmpLayer
icmpLayer
=
random
.
NextIcmpLayer
();
case
IcmpMessageType
.
Echo
:
case
IcmpMessageType
.
EchoReply
:
case
IcmpMessageType
.
Timestamp
:
case
IcmpMessageType
.
TimestampReply
:
case
IcmpMessageType
.
InformationRequest
:
case
IcmpMessageType
.
InformationReply
:
case
IcmpMessageType
.
RouterAdvertisement
:
case
IcmpMessageType
.
RouterSolicitation
:
case
IcmpMessageType
.
AddressMaskRequest
:
case
IcmpMessageType
.
AddressMaskReply
:
case
IcmpMessageType
.
Traceroute
:
case
IcmpMessageType
.
DomainNameRequest
:
case
IcmpMessageType
.
SecurityFailures
:
isIpV4Payload
=
false
;
break
;
case
IcmpMessageType
.
DomainNameReply
:
default
:
throw
new
InvalidOperationException
(
"Invalid icmpMessageType "
+
icmpLayer
.
MessageType
);
}
PacketBuilder2
packetBuilder2
;
IpV4Layer
icmpIpV4Layer
=
null
;
PayloadLayer
icmpIpV4PayloadLayer
=
null
;
if
(
isIpV4Payload
)
{
icmpIpV4Layer
=
new
IpV4Layer
{
TypeOfService
=
random
.
NextByte
(),
Identification
=
random
.
NextUShort
(),
Fragmentation
=
random
.
NextIpV4Fragmentation
(),
Ttl
=
random
.
NextByte
(),
Protocol
=
random
.
NextEnum
<
IpV4Protocol
>(),
Source
=
random
.
NextIpV4Address
(),
Destination
=
random
.
NextIpV4Address
(),
Options
=
random
.
NextIpV4Options
(),
};
Packet
packet
=
new
PacketBuilder2
(
ethernetLayer
,
ipV4Layer
,
icmpLayer
,
icmpIpV4Layer
,
icmpIpV4PayloadLayer
).
Build
(
DateTime
.
Now
);
icmpIpV4PayloadLayer
=
new
PayloadLayer
{
Data
=
random
.
NextDatagram
(
random
.
Next
(
200
))
};
packetBuilder2
=
new
PacketBuilder2
(
ethernetLayer
,
ipV4Layer
,
icmpLayer
,
icmpIpV4Layer
,
icmpIpV4PayloadLayer
);
}
else
packetBuilder2
=
new
PacketBuilder2
(
ethernetLayer
,
ipV4Layer
,
icmpLayer
);
Packet
packet
=
packetBuilder2
.
Build
(
DateTime
.
Now
);
Assert
.
IsTrue
(
packet
.
IsValid
,
"IsValid"
);
Assert
.
IsTrue
(
packet
.
IsValid
,
"IsValid"
);
// Ethernet
ethernetLayer
.
EtherType
=
EthernetType
.
IpV4
;
Assert
.
AreEqual
(
ethernetLayer
,
packet
.
Ethernet
.
ExtractLayer
(),
"Ethernet Layer"
);
// IPv4
ipV4Layer
.
Protocol
=
IpV4Protocol
.
InternetControlMessageProtocol
;
Assert
.
AreEqual
(
ipV4Layer
,
packet
.
Ethernet
.
IpV4
.
ExtractLayer
());
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
),
packet
.
Ethernet
.
IpV4
.
TotalLength
);
Assert
.
AreEqual
(
IpV4Datagram
.
DefaultVersion
,
packet
.
Ethernet
.
IpV4
.
Version
);
// ICMP
IcmpLayer
actualIcmpLayer
=
(
IcmpLayer
)
packet
.
Ethernet
.
IpV4
.
Icmp
.
ExtractLayer
();
Assert
.
AreEqual
(
icmpLayer
,
actualIcmpLayer
);
Assert
.
IsTrue
(
packet
.
Ethernet
.
IpV4
.
Icmp
.
IsChecksumCorrect
);
}
}
}
}
}
}
...
...
PcapDotNet/src/PcapDotNet.Packets.TestUtils/RandomPacketsExtensions.cs
View file @
457e35b8
...
@@ -476,12 +476,7 @@ namespace PcapDotNet.Packets.TestUtils
...
@@ -476,12 +476,7 @@ namespace PcapDotNet.Packets.TestUtils
public
static
IcmpLayer
NextIcmpLayer
(
this
Random
random
)
public
static
IcmpLayer
NextIcmpLayer
(
this
Random
random
)
{
{
IcmpMessageType
icmpMessageType
=
random
.
NextValue
(
new
[]
IcmpMessageType
icmpMessageType
=
random
.
NextEnum
<
IcmpMessageType
>(
IcmpMessageType
.
DomainNameReply
);
{
IcmpMessageType
.
DestinationUnreachable
,
IcmpMessageType
.
TimeExceeded
});
//random.NextEnum<IcmpMessageType>();
switch
(
icmpMessageType
)
switch
(
icmpMessageType
)
{
{
...
@@ -500,7 +495,7 @@ namespace PcapDotNet.Packets.TestUtils
...
@@ -500,7 +495,7 @@ namespace PcapDotNet.Packets.TestUtils
case
IcmpMessageType
.
ParameterProblem
:
case
IcmpMessageType
.
ParameterProblem
:
return
new
IcmpParameterProblemLayer
return
new
IcmpParameterProblemLayer
{
{
Pointer
=
random
.
Next
UShort
()
Pointer
=
random
.
Next
Byte
()
};
};
case
IcmpMessageType
.
SourceQuench
:
case
IcmpMessageType
.
SourceQuench
:
...
...
PcapDotNet/src/PcapDotNet.Packets/Datagram.cs
View file @
457e35b8
...
@@ -76,6 +76,14 @@ namespace PcapDotNet.Packets
...
@@ -76,6 +76,14 @@ namespace PcapDotNet.Packets
}
}
}
}
public
virtual
ILayer
ExtractLayer
()
{
return
new
PayloadLayer
{
Data
=
this
};
}
/// <summary>
/// <summary>
/// Iterate through all the bytes in the datagram.
/// Iterate through all the bytes in the datagram.
/// </summary>
/// </summary>
...
...
PcapDotNet/src/PcapDotNet.Packets/Ethernet/EthernetDatagram.cs
View file @
457e35b8
...
@@ -88,6 +88,16 @@ namespace PcapDotNet.Packets.Ethernet
...
@@ -88,6 +88,16 @@ namespace PcapDotNet.Packets.Ethernet
}
}
}
}
public
override
ILayer
ExtractLayer
()
{
return
new
EthernetLayer
()
{
Source
=
Source
,
Destination
=
Destination
,
EtherType
=
EtherType
,
};
}
/// <summary>
/// <summary>
/// The Ethernet payload as an IPv4 datagram.
/// The Ethernet payload as an IPv4 datagram.
/// </summary>
/// </summary>
...
...
PcapDotNet/src/PcapDotNet.Packets/Icmp/IcmpAddressMaskDatagram.cs
View file @
457e35b8
...
@@ -40,7 +40,7 @@ namespace PcapDotNet.Packets.Icmp
...
@@ -40,7 +40,7 @@ namespace PcapDotNet.Packets.Icmp
internal
static
void
WriteHeaderAdditional
(
byte
[]
buffer
,
int
offset
,
IpV4Address
addressMask
)
internal
static
void
WriteHeaderAdditional
(
byte
[]
buffer
,
int
offset
,
IpV4Address
addressMask
)
{
{
buffer
.
Write
(
offset
+
Offset
.
AddressMask
,
addressMask
,
Endianity
.
Big
);
buffer
.
Write
(
offset
,
addressMask
,
Endianity
.
Big
);
}
}
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/Icmp/IcmpDatagram.cs
View file @
457e35b8
using
System
;
using
System
;
using
System.Linq
;
namespace
PcapDotNet.Packets.Icmp
namespace
PcapDotNet.Packets.Icmp
{
{
...
@@ -75,9 +76,157 @@ namespace PcapDotNet.Packets.Icmp
...
@@ -75,9 +76,157 @@ namespace PcapDotNet.Packets.Icmp
}
}
}
}
public
override
ILayer
ExtractLayer
()
{
switch
(
MessageType
)
{
case
IcmpMessageType
.
DestinationUnreachable
:
return
new
IcmpDestinationUnreachableLayer
{
Code
=
(
IcmpCodeDestinationUnrechable
)
Code
};
case
IcmpMessageType
.
TimeExceeded
:
return
new
IcmpTimeExceededLayer
{
Code
=
(
IcmpCodeTimeExceeded
)
Code
};
case
IcmpMessageType
.
ParameterProblem
:
return
new
IcmpParameterProblemLayer
{
Pointer
=
ParameterProblem
.
Pointer
};
case
IcmpMessageType
.
SourceQuench
:
return
new
IcmpSourceQuenchLayer
();
case
IcmpMessageType
.
Redirect
:
return
new
IcmpRedirectLayer
{
Code
=
(
IcmpCodeRedirect
)
Code
,
GatewayInternetAddress
=
Redirect
.
GatewayInternetAddress
};
case
IcmpMessageType
.
Echo
:
return
new
IcmpEchoLayer
{
Identifier
=
Echo
.
Identifier
,
SequenceNumber
=
Echo
.
SequenceNumber
};
case
IcmpMessageType
.
EchoReply
:
return
new
IcmpEchoReplyLayer
{
Identifier
=
EchoReply
.
Identifier
,
SequenceNumber
=
EchoReply
.
SequenceNumber
};
case
IcmpMessageType
.
Timestamp
:
return
new
IcmpTimestampLayer
{
Identifier
=
Timestamp
.
Identifier
,
SequenceNumber
=
Timestamp
.
SequenceNumber
,
OriginateTimestamp
=
Timestamp
.
OriginateTimestamp
,
ReceiveTimestamp
=
Timestamp
.
ReceiveTimestamp
,
TransmitTimestamp
=
Timestamp
.
TransmitTimestamp
};
case
IcmpMessageType
.
TimestampReply
:
return
new
IcmpTimestampReplyLayer
{
Identifier
=
TimestampReply
.
Identifier
,
SequenceNumber
=
TimestampReply
.
SequenceNumber
,
OriginateTimestamp
=
TimestampReply
.
OriginateTimestamp
,
ReceiveTimestamp
=
TimestampReply
.
ReceiveTimestamp
,
TransmitTimestamp
=
TimestampReply
.
TransmitTimestamp
,
};
case
IcmpMessageType
.
InformationRequest
:
return
new
IcmpInformationRequestLayer
{
Identifier
=
InformationRequest
.
Identifier
,
SequenceNumber
=
InformationRequest
.
SequenceNumber
};
case
IcmpMessageType
.
InformationReply
:
return
new
IcmpInformationReplyLayer
{
Identifier
=
InformationReply
.
Identifier
,
SequenceNumber
=
InformationReply
.
SequenceNumber
};
case
IcmpMessageType
.
RouterAdvertisement
:
return
new
IcmpRouterAdvertisementLayer
{
Lifetime
=
RouterAdvertisement
.
Lifetime
,
Entries
=
RouterAdvertisement
.
Entries
.
ToList
()
};
case
IcmpMessageType
.
RouterSolicitation
:
return
new
IcmpRouterSolicitationLayer
();
case
IcmpMessageType
.
AddressMaskRequest
:
return
new
IcmpAddressMaskRequestLayer
{
Identifier
=
AddressMaskRequest
.
Identifier
,
SequenceNumber
=
AddressMaskRequest
.
SequenceNumber
,
AddressMask
=
AddressMaskRequest
.
AddressMask
};
case
IcmpMessageType
.
AddressMaskReply
:
return
new
IcmpAddressMaskReplyLayer
{
Identifier
=
AddressMaskReply
.
Identifier
,
SequenceNumber
=
AddressMaskReply
.
SequenceNumber
,
AddressMask
=
AddressMaskReply
.
AddressMask
};
case
IcmpMessageType
.
Traceroute
:
return
new
IcmpTracerouteLayer
{
Code
=
(
IcmpCodeTraceroute
)
Code
,
Identification
=
Traceroute
.
Identification
,
OutboundHopCount
=
Traceroute
.
OutboundHopCount
,
ReturnHopCount
=
Traceroute
.
ReturnHopCount
,
OutputLinkSpeed
=
Traceroute
.
OutputLinkSpeed
,
OutputLinkMtu
=
Traceroute
.
OutputLinkMtu
};
case
IcmpMessageType
.
ConversionFailed
:
return
new
IcmpConversionFailedLayer
{
Code
=
(
IcmpCodeConversionFailed
)
Code
,
Pointer
=
ConversionFailed
.
Pointer
};
case
IcmpMessageType
.
DomainNameRequest
:
return
new
IcmpDomainNameRequestLayer
{
Identifier
=
DomainNameRequest
.
Identifier
,
SequenceNumber
=
DomainNameRequest
.
SequenceNumber
};
case
IcmpMessageType
.
DomainNameReply
:
throw
new
NotSupportedException
(
"Message Type "
+
MessageType
+
" is not supported"
);
case
IcmpMessageType
.
SecurityFailures
:
return
new
IcmpSecurityFailuresLayer
{
Code
=
(
IcmpCodeSecurityFailures
)
Code
,
Pointer
=
SecurityFailures
.
Pointer
};
default
:
throw
new
InvalidOperationException
(
"Invalid icmpMessageType "
+
MessageType
);
}
}
public
Datagram
Payload
public
Datagram
Payload
{
{
get
{
return
new
Datagram
(
Buffer
,
StartOffset
+
HeaderLength
,
Length
-
HeaderLength
)
;
}
get
{
return
Typed
;
}
}
}
public
IcmpIpV4HeaderPlus64BitsPayloadDatagram
DestinationUncreachable
public
IcmpIpV4HeaderPlus64BitsPayloadDatagram
DestinationUncreachable
...
...
PcapDotNet/src/PcapDotNet.Packets/Icmp/IcmpRouterAdvertisementDatagram.cs
View file @
457e35b8
...
@@ -23,6 +23,18 @@ namespace PcapDotNet.Packets.Icmp
...
@@ -23,6 +23,18 @@ namespace PcapDotNet.Packets.Icmp
get
{
return
_routerAddressPreference
;
}
get
{
return
_routerAddressPreference
;
}
}
}
public
bool
Equals
(
IcmpRouterAdvertisementEntry
other
)
{
return
other
!=
null
&&
RouterAddress
==
other
.
RouterAddress
&&
RouterAddressPreference
==
other
.
RouterAddressPreference
;
}
public
override
bool
Equals
(
object
obj
)
{
return
Equals
(
obj
as
IcmpRouterAdvertisementEntry
);
}
private
readonly
IpV4Address
_routerAddress
;
private
readonly
IpV4Address
_routerAddress
;
private
readonly
int
_routerAddressPreference
;
private
readonly
int
_routerAddressPreference
;
}
}
...
...
PcapDotNet/src/PcapDotNet.Packets/IcmpTracerouteLayer.cs
View file @
457e35b8
...
@@ -50,5 +50,19 @@ namespace PcapDotNet.Packets
...
@@ -50,5 +50,19 @@ namespace PcapDotNet.Packets
{
{
IcmpTracerouteDatagram
.
WriteHeaderAdditional
(
buffer
,
offset
,
OutboundHopCount
,
ReturnHopCount
,
OutputLinkSpeed
,
OutputLinkMtu
);
IcmpTracerouteDatagram
.
WriteHeaderAdditional
(
buffer
,
offset
,
OutboundHopCount
,
ReturnHopCount
,
OutputLinkSpeed
,
OutputLinkMtu
);
}
}
public
bool
Equals
(
IcmpTracerouteLayer
other
)
{
return
other
!=
null
&&
OutboundHopCount
==
other
.
OutboundHopCount
&&
ReturnHopCount
==
other
.
ReturnHopCount
&&
OutputLinkSpeed
==
other
.
OutputLinkSpeed
&&
OutputLinkMtu
==
other
.
OutputLinkMtu
;
}
public
override
sealed
bool
Equals
(
IcmpLayer
other
)
{
return
base
.
Equals
(
other
)
&&
Equals
(
other
as
IcmpTracerouteLayer
);
}
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/IpV4/IpV4Datagram.cs
View file @
457e35b8
...
@@ -206,6 +206,21 @@ namespace PcapDotNet.Packets.IpV4
...
@@ -206,6 +206,21 @@ namespace PcapDotNet.Packets.IpV4
}
}
}
}
public
override
ILayer
ExtractLayer
()
{
return
new
IpV4Layer
{
TypeOfService
=
TypeOfService
,
Identification
=
Identification
,
Fragmentation
=
Fragmentation
,
Ttl
=
Ttl
,
Protocol
=
Protocol
,
Source
=
Source
,
Destination
=
Destination
,
Options
=
Options
,
};
}
/// <summary>
/// <summary>
/// The payload of the datagram.
/// The payload of the datagram.
/// </summary>
/// </summary>
...
...
PcapDotNet/src/PcapDotNet.Packets/PacketBuilder2.cs
View file @
457e35b8
...
@@ -53,6 +53,17 @@ namespace PcapDotNet.Packets
...
@@ -53,6 +53,17 @@ namespace PcapDotNet.Packets
{
{
get
{
return
null
;
}
get
{
return
null
;
}
}
}
public
virtual
bool
Equals
(
Layer
other
)
{
return
other
!=
null
&&
Length
==
other
.
Length
&&
DataLink
==
other
.
DataLink
;
}
public
override
sealed
bool
Equals
(
object
obj
)
{
return
Equals
(
obj
as
Layer
);
}
}
}
public
abstract
class
SimpleLayer
:
Layer
public
abstract
class
SimpleLayer
:
Layer
...
@@ -115,6 +126,17 @@ namespace PcapDotNet.Packets
...
@@ -115,6 +126,17 @@ namespace PcapDotNet.Packets
{
{
get
{
return
ArpHardwareType
.
Ethernet
;
}
get
{
return
ArpHardwareType
.
Ethernet
;
}
}
}
public
bool
Equals
(
EthernetLayer
other
)
{
return
other
!=
null
&&
Source
==
other
.
Source
&&
Destination
==
other
.
Destination
&&
EtherType
==
other
.
EtherType
;
}
public
override
sealed
bool
Equals
(
Layer
other
)
{
return
base
.
Equals
(
other
)
&&
Equals
(
other
as
EthernetLayer
);
}
}
}
public
class
PayloadLayer
:
SimpleLayer
public
class
PayloadLayer
:
SimpleLayer
...
@@ -131,6 +153,17 @@ namespace PcapDotNet.Packets
...
@@ -131,6 +153,17 @@ namespace PcapDotNet.Packets
get
{
return
Data
.
Length
;
}
get
{
return
Data
.
Length
;
}
}
}
public
bool
Equals
(
PayloadLayer
other
)
{
return
other
!=
null
&&
Data
.
Equals
(
other
.
Data
);
}
public
override
sealed
bool
Equals
(
Layer
other
)
{
return
base
.
Equals
(
other
)
&&
Equals
(
other
as
PayloadLayer
);
}
protected
override
void
Write
(
byte
[]
buffer
,
int
offset
)
protected
override
void
Write
(
byte
[]
buffer
,
int
offset
)
{
{
Data
.
Write
(
buffer
,
offset
);
Data
.
Write
(
buffer
,
offset
);
...
@@ -212,7 +245,21 @@ namespace PcapDotNet.Packets
...
@@ -212,7 +245,21 @@ namespace PcapDotNet.Packets
IpV4Datagram
.
WriteTransportChecksum
(
buffer
,
offset
,
Length
,
(
ushort
)
payloadLength
,
IpV4Datagram
.
WriteTransportChecksum
(
buffer
,
offset
,
Length
,
(
ushort
)
payloadLength
,
nextTransportLayer
.
NextLayerChecksumOffset
,
nextTransportLayer
.
NextLayerIsChecksumOptional
);
nextTransportLayer
.
NextLayerChecksumOffset
,
nextTransportLayer
.
NextLayerIsChecksumOptional
);
}
public
bool
Equals
(
IpV4Layer
other
)
{
return
other
!=
null
&&
TypeOfService
==
other
.
TypeOfService
&&
Identification
==
other
.
Identification
&&
Fragmentation
==
other
.
Fragmentation
&&
Ttl
==
other
.
Ttl
&&
Protocol
==
other
.
Protocol
&&
Source
==
other
.
Source
&&
Destination
==
other
.
Destination
&&
Options
.
Equals
(
other
.
Options
);
}
public
override
sealed
bool
Equals
(
Layer
other
)
{
return
base
.
Equals
(
other
)
&&
Equals
(
other
as
IpV4Layer
);
}
}
}
}
...
@@ -226,6 +273,18 @@ namespace PcapDotNet.Packets
...
@@ -226,6 +273,18 @@ namespace PcapDotNet.Packets
public
abstract
int
NextLayerChecksumOffset
{
get
;
}
public
abstract
int
NextLayerChecksumOffset
{
get
;
}
public
abstract
bool
NextLayerIsChecksumOptional
{
get
;
}
public
abstract
bool
NextLayerIsChecksumOptional
{
get
;
}
public
abstract
bool
NextLayerCalculateChecksum
{
get
;
}
public
abstract
bool
NextLayerCalculateChecksum
{
get
;
}
public
virtual
bool
Equals
(
TransportLayer
other
)
{
return
other
!=
null
&&
PreviousLayerProtocol
==
other
.
PreviousLayerProtocol
&&
SourcePort
==
other
.
SourcePort
&&
DestinationPort
==
other
.
DestinationPort
;
}
public
override
sealed
bool
Equals
(
Layer
other
)
{
return
base
.
Equals
(
other
)
&&
Equals
(
other
as
TransportLayer
);
}
}
}
public
class
TcpLayer
:
TransportLayer
public
class
TcpLayer
:
TransportLayer
...
@@ -275,6 +334,20 @@ namespace PcapDotNet.Packets
...
@@ -275,6 +334,20 @@ namespace PcapDotNet.Packets
ControlBits
,
Window
,
UrgentPointer
,
ControlBits
,
Window
,
UrgentPointer
,
Options
);
Options
);
}
}
public
bool
Equals
(
TcpLayer
other
)
{
return
other
!=
null
&&
SequenceNumber
==
other
.
SequenceNumber
&&
AcknowledgmentNumber
==
other
.
AcknowledgmentNumber
&&
ControlBits
==
other
.
ControlBits
&&
Window
==
other
.
Window
&&
UrgentPointer
==
other
.
UrgentPointer
&&
Options
==
other
.
Options
;
}
public
override
sealed
bool
Equals
(
TransportLayer
other
)
{
return
base
.
Equals
(
other
)
&&
Equals
(
other
as
TcpLayer
);
}
}
}
public
class
UdpLayer
:
TransportLayer
public
class
UdpLayer
:
TransportLayer
...
@@ -304,7 +377,7 @@ namespace PcapDotNet.Packets
...
@@ -304,7 +377,7 @@ namespace PcapDotNet.Packets
public
override
int
Length
public
override
int
Length
{
{
get
{
return
UdpDatagram
.
HeaderLength
;
}
get
{
return
UdpDatagram
.
HeaderLength
;
}
}
}
public
override
void
Write
(
byte
[]
buffer
,
int
offset
,
int
payloadLength
,
ILayer
previousLayer
,
ILayer
nextLayer
)
public
override
void
Write
(
byte
[]
buffer
,
int
offset
,
int
payloadLength
,
ILayer
previousLayer
,
ILayer
nextLayer
)
{
{
...
@@ -365,6 +438,21 @@ namespace PcapDotNet.Packets
...
@@ -365,6 +438,21 @@ namespace PcapDotNet.Packets
arpPreviousLayer
.
PreviousLayerHardwareType
,
ProtocolType
,
Operation
,
arpPreviousLayer
.
PreviousLayerHardwareType
,
ProtocolType
,
Operation
,
SenderHardwareAddress
,
SenderProtocolAddress
,
TargetHardwareAddress
,
TargetProtocolAddress
);
SenderHardwareAddress
,
SenderProtocolAddress
,
TargetHardwareAddress
,
TargetProtocolAddress
);
}
}
public
bool
Equals
(
ArpLayer
other
)
{
return
other
!=
null
&&
ProtocolType
==
other
.
ProtocolType
&&
Operation
==
other
.
Operation
&&
SenderHardwareAddress
.
SequenceEqual
(
other
.
SenderHardwareAddress
)
&&
SenderProtocolAddress
.
SequenceEqual
(
other
.
SenderProtocolAddress
)
&&
TargetHardwareAddress
.
SequenceEqual
(
other
.
TargetHardwareAddress
)
&&
TargetProtocolAddress
.
SequenceEqual
(
other
.
TargetProtocolAddress
);
}
public
override
sealed
bool
Equals
(
Layer
other
)
{
return
base
.
Equals
(
other
)
&&
Equals
(
other
as
ArpLayer
);
}
}
}
public
abstract
class
IgmpLayer
:
SimpleLayer
,
IIpV4NextLayer
public
abstract
class
IgmpLayer
:
SimpleLayer
,
IIpV4NextLayer
...
@@ -380,6 +468,19 @@ namespace PcapDotNet.Packets
...
@@ -380,6 +468,19 @@ namespace PcapDotNet.Packets
{
{
get
{
return
IpV4Protocol
.
InternetGroupManagementProtocol
;
}
get
{
return
IpV4Protocol
.
InternetGroupManagementProtocol
;
}
}
}
public
virtual
bool
Equals
(
IgmpLayer
other
)
{
return
other
!=
null
&&
MessageType
==
other
.
MessageType
&&
QueryVersion
==
other
.
QueryVersion
&&
MaxResponseTimeValue
==
other
.
MaxResponseTimeValue
;
}
public
sealed
override
bool
Equals
(
Layer
other
)
{
return
base
.
Equals
(
other
)
&&
Equals
(
other
as
IgmpLayer
);
}
}
}
public
interface
IIgmpLayerWithGroupAddress
public
interface
IIgmpLayerWithGroupAddress
...
@@ -387,7 +488,7 @@ namespace PcapDotNet.Packets
...
@@ -387,7 +488,7 @@ namespace PcapDotNet.Packets
IpV4Address
GroupAddress
{
get
;
set
;
}
IpV4Address
GroupAddress
{
get
;
set
;
}
}
}
public
abstract
class
SimpleIgmp
Layer
:
IgmpLayer
,
IIgmpLayerWithGroupAddress
public
abstract
class
IgmpSimple
Layer
:
IgmpLayer
,
IIgmpLayerWithGroupAddress
{
{
public
IpV4Address
GroupAddress
{
get
;
set
;
}
public
IpV4Address
GroupAddress
{
get
;
set
;
}
public
override
int
Length
public
override
int
Length
...
@@ -400,9 +501,20 @@ namespace PcapDotNet.Packets
...
@@ -400,9 +501,20 @@ namespace PcapDotNet.Packets
IgmpDatagram
.
WriteHeader
(
buffer
,
offset
,
IgmpDatagram
.
WriteHeader
(
buffer
,
offset
,
MessageType
,
MaxResponseTimeValue
,
GroupAddress
);
MessageType
,
MaxResponseTimeValue
,
GroupAddress
);
}
}
public
bool
Equals
(
IgmpSimpleLayer
other
)
{
return
other
!=
null
&&
GroupAddress
==
other
.
GroupAddress
;
}
public
override
sealed
bool
Equals
(
IgmpLayer
other
)
{
return
base
.
Equals
(
other
)
&&
Equals
(
other
as
IgmpSimpleLayer
);
}
}
}
public
abstract
class
IgmpVersion1Layer
:
SimpleIgmp
Layer
public
abstract
class
IgmpVersion1Layer
:
IgmpSimple
Layer
{
{
public
override
TimeSpan
MaxResponseTimeValue
public
override
TimeSpan
MaxResponseTimeValue
{
{
...
@@ -410,7 +522,7 @@ namespace PcapDotNet.Packets
...
@@ -410,7 +522,7 @@ namespace PcapDotNet.Packets
}
}
}
}
public
abstract
class
IgmpVersion2Layer
:
SimpleIgmp
Layer
public
abstract
class
IgmpVersion2Layer
:
IgmpSimple
Layer
{
{
public
TimeSpan
MaxResponseTime
{
get
;
set
;
}
public
TimeSpan
MaxResponseTime
{
get
;
set
;
}
public
override
TimeSpan
MaxResponseTimeValue
public
override
TimeSpan
MaxResponseTimeValue
...
@@ -492,6 +604,21 @@ namespace PcapDotNet.Packets
...
@@ -492,6 +604,21 @@ namespace PcapDotNet.Packets
{
{
get
{
return
MaxResponseTime
;
}
get
{
return
MaxResponseTime
;
}
}
}
public
bool
Equals
(
IgmpQueryVersion3Layer
other
)
{
return
other
!=
null
&&
GroupAddress
==
other
.
GroupAddress
&&
IsSuppressRouterSideProcessing
==
other
.
IsSuppressRouterSideProcessing
&&
QueryRobustnessVariable
==
other
.
QueryRobustnessVariable
&&
QueryInterval
==
other
.
QueryInterval
&&
SourceAddresses
.
SequenceEqual
(
other
.
SourceAddresses
);
}
public
override
sealed
bool
Equals
(
IgmpLayer
other
)
{
return
base
.
Equals
(
other
)
&&
Equals
(
other
as
IgmpQueryVersion3Layer
);
}
}
}
public
class
IgmpReportVersion1Layer
:
IgmpVersion1Layer
public
class
IgmpReportVersion1Layer
:
IgmpVersion1Layer
...
@@ -541,6 +668,17 @@ namespace PcapDotNet.Packets
...
@@ -541,6 +668,17 @@ namespace PcapDotNet.Packets
{
{
get
{
return
TimeSpan
.
Zero
;
}
get
{
return
TimeSpan
.
Zero
;
}
}
}
public
bool
Equals
(
IgmpReportVersion3Layer
other
)
{
return
other
!=
null
&&
GroupRecords
.
SequenceEqual
(
other
.
GroupRecords
);
}
public
sealed
override
bool
Equals
(
IgmpLayer
other
)
{
return
base
.
Equals
(
other
)
&&
Equals
(
other
as
IgmpReportVersion3Layer
);
}
}
}
public
abstract
class
IcmpLayer
:
SimpleLayer
,
IIpV4NextLayer
public
abstract
class
IcmpLayer
:
SimpleLayer
,
IIpV4NextLayer
...
@@ -579,6 +717,18 @@ namespace PcapDotNet.Packets
...
@@ -579,6 +717,18 @@ namespace PcapDotNet.Packets
{
{
get
{
return
IpV4Protocol
.
InternetControlMessageProtocol
;
}
get
{
return
IpV4Protocol
.
InternetControlMessageProtocol
;
}
}
}
public
virtual
bool
Equals
(
IcmpLayer
other
)
{
return
other
!=
null
&&
MessageType
==
other
.
MessageType
&&
CodeValue
==
other
.
CodeValue
&&
Value
==
other
.
Value
;
}
public
sealed
override
bool
Equals
(
Layer
other
)
{
return
base
.
Equals
(
other
)
&&
Equals
(
other
as
IcmpLayer
);
}
}
}
public
class
IcmpDestinationUnreachableLayer
:
IcmpLayer
public
class
IcmpDestinationUnreachableLayer
:
IcmpLayer
...
@@ -613,7 +763,7 @@ namespace PcapDotNet.Packets
...
@@ -613,7 +763,7 @@ namespace PcapDotNet.Packets
public
class
IcmpParameterProblemLayer
:
IcmpLayer
public
class
IcmpParameterProblemLayer
:
IcmpLayer
{
{
public
ushort
Pointer
{
get
;
set
;
}
public
byte
Pointer
{
get
;
set
;
}
public
override
IcmpMessageType
MessageType
public
override
IcmpMessageType
MessageType
{
{
...
@@ -624,7 +774,7 @@ namespace PcapDotNet.Packets
...
@@ -624,7 +774,7 @@ namespace PcapDotNet.Packets
{
{
get
get
{
{
return
(
uint
)(
Pointer
<<
16
);
return
(
uint
)(
Pointer
<<
24
);
}
}
}
}
}
}
...
@@ -717,6 +867,19 @@ namespace PcapDotNet.Packets
...
@@ -717,6 +867,19 @@ namespace PcapDotNet.Packets
IcmpTimestampDatagram
.
WriteHeaderAdditional
(
buffer
,
offset
,
IcmpTimestampDatagram
.
WriteHeaderAdditional
(
buffer
,
offset
,
OriginateTimestamp
,
ReceiveTimestamp
,
TransmitTimestamp
);
OriginateTimestamp
,
ReceiveTimestamp
,
TransmitTimestamp
);
}
}
public
bool
Equals
(
IcmpTimestampLayer
other
)
{
return
other
!=
null
&&
OriginateTimestamp
==
other
.
OriginateTimestamp
&&
ReceiveTimestamp
==
other
.
ReceiveTimestamp
&&
TransmitTimestamp
==
other
.
TransmitTimestamp
;
}
public
sealed
override
bool
Equals
(
IcmpLayer
other
)
{
return
base
.
Equals
(
other
)
&&
Equals
(
other
as
IcmpTimestampLayer
);
}
}
}
public
class
IcmpTimestampReplyLayer
:
IcmpTimestampLayer
public
class
IcmpTimestampReplyLayer
:
IcmpTimestampLayer
...
@@ -778,6 +941,17 @@ namespace PcapDotNet.Packets
...
@@ -778,6 +941,17 @@ namespace PcapDotNet.Packets
{
{
IcmpRouterAdvertisementDatagram
.
WriteHeaderAdditional
(
buffer
,
offset
,
Entries
);
IcmpRouterAdvertisementDatagram
.
WriteHeaderAdditional
(
buffer
,
offset
,
Entries
);
}
}
public
bool
Equals
(
IcmpRouterAdvertisementLayer
other
)
{
return
other
!=
null
&&
Entries
.
SequenceEqual
(
other
.
Entries
);
}
public
sealed
override
bool
Equals
(
IcmpLayer
other
)
{
return
base
.
Equals
(
other
)
&&
Equals
(
other
as
IcmpRouterAdvertisementLayer
);
}
}
}
public
class
IcmpRouterSolicitationLayer
:
IcmpLayer
public
class
IcmpRouterSolicitationLayer
:
IcmpLayer
...
@@ -809,6 +983,17 @@ namespace PcapDotNet.Packets
...
@@ -809,6 +983,17 @@ namespace PcapDotNet.Packets
{
{
IcmpAddressMaskDatagram
.
WriteHeaderAdditional
(
buffer
,
offset
,
AddressMask
);
IcmpAddressMaskDatagram
.
WriteHeaderAdditional
(
buffer
,
offset
,
AddressMask
);
}
}
public
bool
Equals
(
IcmpAddressMaskRequestLayer
other
)
{
return
other
!=
null
&&
AddressMask
==
other
.
AddressMask
;
}
public
override
sealed
bool
Equals
(
IcmpLayer
other
)
{
return
base
.
Equals
(
other
)
&&
Equals
(
other
as
IcmpAddressMaskRequestLayer
);
}
}
}
public
class
IcmpAddressMaskReplyLayer
:
IcmpAddressMaskRequestLayer
public
class
IcmpAddressMaskReplyLayer
:
IcmpAddressMaskRequestLayer
...
@@ -838,6 +1023,14 @@ namespace PcapDotNet.Packets
...
@@ -838,6 +1023,14 @@ namespace PcapDotNet.Packets
return
(
byte
)
Code
;
return
(
byte
)
Code
;
}
}
}
}
protected
override
uint
Value
{
get
{
return
Pointer
;
}
}
}
}
public
class
IcmpDomainNameRequestLayer
:
IcmpIdentifiedLayer
public
class
IcmpDomainNameRequestLayer
:
IcmpIdentifiedLayer
...
...
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