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
c1dde0d3
Commit
c1dde0d3
authored
Feb 06, 2010
by
Brickner_cp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring
parent
c115e21b
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
49 changed files
with
1281 additions
and
1101 deletions
+1281
-1101
ArpLayer.cs
PcapDotNet/src/PcapDotNet.Packets/Arp/ArpLayer.cs
+77
-0
IArpPreviousLayer.cs
PcapDotNet/src/PcapDotNet.Packets/Arp/IArpPreviousLayer.cs
+7
-0
EthernetLayer.cs
PcapDotNet/src/PcapDotNet.Packets/Ethernet/EthernetLayer.cs
+73
-0
IEthernetNextLayer.cs
...Net/src/PcapDotNet.Packets/Ethernet/IEthernetNextLayer.cs
+8
-0
ILayer.cs
PcapDotNet/src/PcapDotNet.Packets/ILayer.cs
+10
-0
IcmpAddressMaskReplyLayer.cs
.../src/PcapDotNet.Packets/Icmp/IcmpAddressMaskReplyLayer.cs
+13
-0
IcmpAddressMaskRequestLayer.cs
...rc/PcapDotNet.Packets/Icmp/IcmpAddressMaskRequestLayer.cs
+38
-0
IcmpConversionFailedLayer.cs
.../src/PcapDotNet.Packets/Icmp/IcmpConversionFailedLayer.cs
+28
-0
IcmpDestinationUnreachableLayer.cs
...capDotNet.Packets/Icmp/IcmpDestinationUnreachableLayer.cs
+17
-0
IcmpDomainNameRequestLayer.cs
...src/PcapDotNet.Packets/Icmp/IcmpDomainNameRequestLayer.cs
+10
-0
IcmpEchoLayer.cs
PcapDotNet/src/PcapDotNet.Packets/Icmp/IcmpEchoLayer.cs
+10
-0
IcmpEchoReplyLayer.cs
PcapDotNet/src/PcapDotNet.Packets/Icmp/IcmpEchoReplyLayer.cs
+10
-0
IcmpIdentifiedLayer.cs
...DotNet/src/PcapDotNet.Packets/Icmp/IcmpIdentifiedLayer.cs
+17
-0
IcmpInformationReplyLayer.cs
.../src/PcapDotNet.Packets/Icmp/IcmpInformationReplyLayer.cs
+10
-0
IcmpInformationRequestLayer.cs
...rc/PcapDotNet.Packets/Icmp/IcmpInformationRequestLayer.cs
+10
-0
IcmpLayer.cs
PcapDotNet/src/PcapDotNet.Packets/Icmp/IcmpLayer.cs
+56
-0
IcmpParameterProblemLayer.cs
.../src/PcapDotNet.Packets/Icmp/IcmpParameterProblemLayer.cs
+20
-0
IcmpRedirectLayer.cs
PcapDotNet/src/PcapDotNet.Packets/Icmp/IcmpRedirectLayer.cs
+30
-0
IcmpRouterAdvertisementLayer.cs
...c/PcapDotNet.Packets/Icmp/IcmpRouterAdvertisementLayer.cs
+51
-0
IcmpRouterSolicitationLayer.cs
...rc/PcapDotNet.Packets/Icmp/IcmpRouterSolicitationLayer.cs
+10
-0
IcmpSecurityFailuresLayer.cs
.../src/PcapDotNet.Packets/Icmp/IcmpSecurityFailuresLayer.cs
+28
-0
IcmpSourceQuenchLayer.cs
...tNet/src/PcapDotNet.Packets/Icmp/IcmpSourceQuenchLayer.cs
+10
-0
IcmpTimeExceededLayer.cs
...tNet/src/PcapDotNet.Packets/Icmp/IcmpTimeExceededLayer.cs
+17
-0
IcmpTimestampLayer.cs
PcapDotNet/src/PcapDotNet.Packets/Icmp/IcmpTimestampLayer.cs
+42
-0
IcmpTimestampReplyLayer.cs
...et/src/PcapDotNet.Packets/Icmp/IcmpTimestampReplyLayer.cs
+13
-0
IcmpTracerouteLayer.cs
...DotNet/src/PcapDotNet.Packets/Icmp/IcmpTracerouteLayer.cs
+1
-2
IIgmpLayerWithGroupAddress.cs
...src/PcapDotNet.Packets/Igmp/IIgmpLayerWithGroupAddress.cs
+9
-0
IgmpLayer.cs
PcapDotNet/src/PcapDotNet.Packets/Igmp/IgmpLayer.cs
+34
-0
IgmpLeaveGroupVersion2Layer.cs
...rc/PcapDotNet.Packets/Igmp/IgmpLeaveGroupVersion2Layer.cs
+10
-0
IgmpQueryVersion1Layer.cs
...Net/src/PcapDotNet.Packets/Igmp/IgmpQueryVersion1Layer.cs
+18
-0
IgmpQueryVersion2Layer.cs
...Net/src/PcapDotNet.Packets/Igmp/IgmpQueryVersion2Layer.cs
+18
-0
IgmpQueryVersion3Layer.cs
...Net/src/PcapDotNet.Packets/Igmp/IgmpQueryVersion3Layer.cs
+71
-0
IgmpReportVersion1Layer.cs
...et/src/PcapDotNet.Packets/Igmp/IgmpReportVersion1Layer.cs
+10
-0
IgmpReportVersion2Layer.cs
...et/src/PcapDotNet.Packets/Igmp/IgmpReportVersion2Layer.cs
+10
-0
IgmpReportVersion3Layer.cs
...et/src/PcapDotNet.Packets/Igmp/IgmpReportVersion3Layer.cs
+42
-0
IgmpSimpleLayer.cs
PcapDotNet/src/PcapDotNet.Packets/Igmp/IgmpSimpleLayer.cs
+30
-0
IgmpVersion1Layer.cs
PcapDotNet/src/PcapDotNet.Packets/Igmp/IgmpVersion1Layer.cs
+12
-0
IgmpVersion2Layer.cs
PcapDotNet/src/PcapDotNet.Packets/Igmp/IgmpVersion2Layer.cs
+13
-0
IIpV4NextLayer.cs
PcapDotNet/src/PcapDotNet.Packets/IpV4/IIpV4NextLayer.cs
+7
-0
IIpV4NextTransportLayer.cs
...et/src/PcapDotNet.Packets/IpV4/IIpV4NextTransportLayer.cs
+11
-0
IpV4Layer.cs
PcapDotNet/src/PcapDotNet.Packets/IpV4/IpV4Layer.cs
+109
-0
Layer.cs
PcapDotNet/src/PcapDotNet.Packets/Layer.cs
+27
-0
PacketBuilder.cs
PcapDotNet/src/PcapDotNet.Packets/PacketBuilder.cs
+0
-1098
PayloadLayer.cs
PcapDotNet/src/PcapDotNet.Packets/PayloadLayer.cs
+33
-0
PcapDotNet.Packets.csproj
PcapDotNet/src/PcapDotNet.Packets/PcapDotNet.Packets.csproj
+47
-1
SimpleLayer.cs
PcapDotNet/src/PcapDotNet.Packets/SimpleLayer.cs
+12
-0
TcpLayer.cs
PcapDotNet/src/PcapDotNet.Packets/Transport/TcpLayer.cs
+67
-0
TransportLayer.cs
...DotNet/src/PcapDotNet.Packets/Transport/TransportLayer.cs
+36
-0
UdpLayer.cs
PcapDotNet/src/PcapDotNet.Packets/Transport/UdpLayer.cs
+39
-0
No files found.
PcapDotNet/src/PcapDotNet.Packets/Arp/ArpLayer.cs
0 → 100644
View file @
c1dde0d3
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
PcapDotNet.Packets.Ethernet
;
namespace
PcapDotNet.Packets.Arp
{
public
class
ArpLayer
:
Layer
,
IEthernetNextLayer
{
public
EthernetType
ProtocolType
{
get
;
set
;
}
public
ArpOperation
Operation
{
get
;
set
;
}
public
IList
<
byte
>
SenderHardwareAddress
{
get
;
set
;
}
public
IList
<
byte
>
SenderProtocolAddress
{
get
;
set
;
}
public
IList
<
byte
>
TargetHardwareAddress
{
get
;
set
;
}
public
IList
<
byte
>
TargetProtocolAddress
{
get
;
set
;
}
public
EthernetType
PreviousLayerEtherType
{
get
{
return
EthernetType
.
Arp
;
}
}
public
MacAddress
?
PreviousLayerDefaultDestination
{
get
{
return
EthernetDatagram
.
BroadcastAddress
;
}
}
public
override
int
Length
{
get
{
return
ArpDatagram
.
GetHeaderLength
(
SenderHardwareAddress
.
Count
,
SenderProtocolAddress
.
Count
);
}
}
public
override
void
Write
(
byte
[]
buffer
,
int
offset
,
int
payloadLength
,
ILayer
previousLayer
,
ILayer
nextLayer
)
{
if
(
previousLayer
==
null
)
throw
new
ArgumentException
(
"Must have a previous layer"
);
IArpPreviousLayer
arpPreviousLayer
=
previousLayer
as
IArpPreviousLayer
;
if
(
arpPreviousLayer
==
null
)
throw
new
ArgumentException
(
"The layer before the ARP layer must be an ARP previous layer and can't be "
+
previousLayer
.
GetType
());
if
(
SenderHardwareAddress
.
Count
!=
TargetHardwareAddress
.
Count
)
{
throw
new
ArgumentException
(
"Sender hardware address length is "
+
SenderHardwareAddress
.
Count
+
" bytes "
+
"while target hardware address length is "
+
TargetHardwareAddress
.
Count
+
" bytes"
);
}
if
(
SenderProtocolAddress
.
Count
!=
TargetProtocolAddress
.
Count
)
{
throw
new
ArgumentException
(
"Sender protocol address length is "
+
SenderProtocolAddress
.
Count
+
" bytes "
+
"while target protocol address length is "
+
TargetProtocolAddress
.
Count
+
" bytes"
);
}
ArpDatagram
.
WriteHeader
(
buffer
,
offset
,
arpPreviousLayer
.
PreviousLayerHardwareType
,
ProtocolType
,
Operation
,
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
);
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/Arp/IArpPreviousLayer.cs
0 → 100644
View file @
c1dde0d3
namespace
PcapDotNet.Packets.Arp
{
public
interface
IArpPreviousLayer
:
ILayer
{
ArpHardwareType
PreviousLayerHardwareType
{
get
;
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/Ethernet/EthernetLayer.cs
0 → 100644
View file @
c1dde0d3
using
System
;
using
PcapDotNet.Packets.Arp
;
namespace
PcapDotNet.Packets.Ethernet
{
public
class
EthernetLayer
:
Layer
,
IArpPreviousLayer
{
public
MacAddress
Source
{
get
;
set
;
}
public
MacAddress
Destination
{
get
;
set
;
}
public
EthernetType
EtherType
{
get
;
set
;
}
public
EthernetLayer
()
{
Source
=
MacAddress
.
Zero
;
Destination
=
MacAddress
.
Zero
;
EtherType
=
EthernetType
.
None
;
}
public
override
int
Length
{
get
{
return
EthernetDatagram
.
HeaderLength
;
}
}
public
override
void
Write
(
byte
[]
buffer
,
int
offset
,
int
payloadLength
,
ILayer
previousLayer
,
ILayer
nextLayer
)
{
EthernetType
etherType
=
EtherType
;
MacAddress
destination
=
Destination
;
IEthernetNextLayer
ethernetNextLayer
=
nextLayer
as
IEthernetNextLayer
;
if
(
etherType
==
EthernetType
.
None
)
{
if
(
nextLayer
==
null
)
throw
new
ArgumentException
(
"Can't determine ether type automatically from next layer because there is not next layer"
);
if
(
ethernetNextLayer
==
null
)
throw
new
ArgumentException
(
"Can't determine ether type automatically from next layer ("
+
nextLayer
.
GetType
()
+
")"
);
etherType
=
ethernetNextLayer
.
PreviousLayerEtherType
;
}
if
(
destination
==
MacAddress
.
Zero
)
{
if
(
ethernetNextLayer
!=
null
&&
ethernetNextLayer
.
PreviousLayerDefaultDestination
!=
null
)
destination
=
ethernetNextLayer
.
PreviousLayerDefaultDestination
.
Value
;
}
EthernetDatagram
.
WriteHeader
(
buffer
,
0
,
Source
,
destination
,
etherType
);
}
public
override
DataLinkKind
?
DataLink
{
get
{
return
DataLinkKind
.
Ethernet
;
}
}
public
ArpHardwareType
PreviousLayerHardwareType
{
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
override
string
ToString
()
{
return
Source
+
" -> "
+
Destination
+
" ("
+
EtherType
+
")"
;
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/Ethernet/IEthernetNextLayer.cs
0 → 100644
View file @
c1dde0d3
namespace
PcapDotNet.Packets.Ethernet
{
public
interface
IEthernetNextLayer
:
ILayer
{
EthernetType
PreviousLayerEtherType
{
get
;
}
MacAddress
?
PreviousLayerDefaultDestination
{
get
;
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/ILayer.cs
0 → 100644
View file @
c1dde0d3
namespace
PcapDotNet.Packets
{
public
interface
ILayer
{
int
Length
{
get
;
}
void
Write
(
byte
[]
buffer
,
int
offset
,
int
payloadLength
,
ILayer
previousLayer
,
ILayer
nextLayer
);
void
Finalize
(
byte
[]
buffer
,
int
offset
,
int
payloadLength
,
ILayer
nextLayer
);
DataLinkKind
?
DataLink
{
get
;
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/Icmp/IcmpAddressMaskReplyLayer.cs
0 → 100644
View file @
c1dde0d3
namespace
PcapDotNet.Packets.Icmp
{
public
class
IcmpAddressMaskReplyLayer
:
IcmpAddressMaskRequestLayer
{
public
override
IcmpMessageType
MessageType
{
get
{
return
IcmpMessageType
.
AddressMaskReply
;
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/Icmp/IcmpAddressMaskRequestLayer.cs
0 → 100644
View file @
c1dde0d3
using
PcapDotNet.Packets.IpV4
;
namespace
PcapDotNet.Packets.Icmp
{
public
class
IcmpAddressMaskRequestLayer
:
IcmpIdentifiedLayer
{
public
IpV4Address
AddressMask
{
get
;
set
;
}
public
override
IcmpMessageType
MessageType
{
get
{
return
IcmpMessageType
.
AddressMaskRequest
;
}
}
public
override
int
Length
{
get
{
return
base
.
Length
+
IcmpAddressMaskDatagram
.
HeaderAdditionalLength
;
}
}
protected
override
void
WriteHeaderAdditional
(
byte
[]
buffer
,
int
offset
)
{
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
);
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/Icmp/IcmpConversionFailedLayer.cs
0 → 100644
View file @
c1dde0d3
namespace
PcapDotNet.Packets.Icmp
{
public
class
IcmpConversionFailedLayer
:
IcmpLayer
{
public
IcmpCodeConversionFailed
Code
{
get
;
set
;
}
public
uint
Pointer
{
get
;
set
;
}
public
override
IcmpMessageType
MessageType
{
get
{
return
IcmpMessageType
.
ConversionFailed
;
}
}
public
override
byte
CodeValue
{
get
{
return
(
byte
)
Code
;
}
}
protected
override
uint
Value
{
get
{
return
Pointer
;
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/Icmp/IcmpDestinationUnreachableLayer.cs
0 → 100644
View file @
c1dde0d3
namespace
PcapDotNet.Packets.Icmp
{
public
class
IcmpDestinationUnreachableLayer
:
IcmpLayer
{
public
IcmpCodeDestinationUnrechable
Code
{
get
;
set
;
}
public
override
IcmpMessageType
MessageType
{
get
{
return
IcmpMessageType
.
DestinationUnreachable
;
}
}
public
override
byte
CodeValue
{
get
{
return
(
byte
)
Code
;
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/Icmp/IcmpDomainNameRequestLayer.cs
0 → 100644
View file @
c1dde0d3
namespace
PcapDotNet.Packets.Icmp
{
public
class
IcmpDomainNameRequestLayer
:
IcmpIdentifiedLayer
{
public
override
IcmpMessageType
MessageType
{
get
{
return
IcmpMessageType
.
DomainNameRequest
;
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/Icmp/IcmpEchoLayer.cs
0 → 100644
View file @
c1dde0d3
namespace
PcapDotNet.Packets.Icmp
{
public
class
IcmpEchoLayer
:
IcmpIdentifiedLayer
{
public
override
IcmpMessageType
MessageType
{
get
{
return
IcmpMessageType
.
Echo
;
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/Icmp/IcmpEchoReplyLayer.cs
0 → 100644
View file @
c1dde0d3
namespace
PcapDotNet.Packets.Icmp
{
public
class
IcmpEchoReplyLayer
:
IcmpIdentifiedLayer
{
public
override
IcmpMessageType
MessageType
{
get
{
return
IcmpMessageType
.
EchoReply
;
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/Icmp/IcmpIdentifiedLayer.cs
0 → 100644
View file @
c1dde0d3
namespace
PcapDotNet.Packets.Icmp
{
public
abstract
class
IcmpIdentifiedLayer
:
IcmpLayer
{
public
ushort
Identifier
{
get
;
set
;
}
public
ushort
SequenceNumber
{
get
;
set
;
}
protected
override
sealed
uint
Value
{
get
{
return
(
uint
)((
Identifier
<<
16
)
|
SequenceNumber
);
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/Icmp/IcmpInformationReplyLayer.cs
0 → 100644
View file @
c1dde0d3
namespace
PcapDotNet.Packets.Icmp
{
public
class
IcmpInformationReplyLayer
:
IcmpIdentifiedLayer
{
public
override
IcmpMessageType
MessageType
{
get
{
return
IcmpMessageType
.
InformationReply
;
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/Icmp/IcmpInformationRequestLayer.cs
0 → 100644
View file @
c1dde0d3
namespace
PcapDotNet.Packets.Icmp
{
public
class
IcmpInformationRequestLayer
:
IcmpIdentifiedLayer
{
public
override
IcmpMessageType
MessageType
{
get
{
return
IcmpMessageType
.
InformationRequest
;
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/Icmp/IcmpLayer.cs
0 → 100644
View file @
c1dde0d3
using
PcapDotNet.Packets.IpV4
;
namespace
PcapDotNet.Packets.Icmp
{
public
abstract
class
IcmpLayer
:
SimpleLayer
,
IIpV4NextLayer
{
public
abstract
IcmpMessageType
MessageType
{
get
;
}
public
virtual
byte
CodeValue
{
get
{
return
0
;
}
}
public
ushort
?
Checksum
{
get
;
set
;
}
protected
virtual
uint
Value
{
get
{
return
0
;
}
}
public
override
int
Length
{
get
{
return
IcmpDatagram
.
HeaderLength
;
}
}
protected
override
sealed
void
Write
(
byte
[]
buffer
,
int
offset
)
{
IcmpDatagram
.
WriteHeader
(
buffer
,
offset
,
MessageType
,
CodeValue
,
Value
);
WriteHeaderAdditional
(
buffer
,
offset
+
IcmpDatagram
.
HeaderLength
);
}
protected
virtual
void
WriteHeaderAdditional
(
byte
[]
buffer
,
int
offset
)
{
}
public
override
void
Finalize
(
byte
[]
buffer
,
int
offset
,
int
payloadLength
,
ILayer
nextLayer
)
{
IcmpDatagram
.
WriteChecksum
(
buffer
,
offset
,
Length
+
payloadLength
,
Checksum
);
}
public
IpV4Protocol
PreviousLayerProtocol
{
get
{
return
IpV4Protocol
.
InternetControlMessageProtocol
;
}
}
public
virtual
bool
Equals
(
IcmpLayer
other
)
{
return
other
!=
null
&&
MessageType
==
other
.
MessageType
&&
CodeValue
==
other
.
CodeValue
&&
Checksum
==
other
.
Checksum
&&
Value
==
other
.
Value
;
}
public
sealed
override
bool
Equals
(
Layer
other
)
{
return
base
.
Equals
(
other
)
&&
Equals
(
other
as
IcmpLayer
);
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/Icmp/IcmpParameterProblemLayer.cs
0 → 100644
View file @
c1dde0d3
namespace
PcapDotNet.Packets.Icmp
{
public
class
IcmpParameterProblemLayer
:
IcmpLayer
{
public
byte
Pointer
{
get
;
set
;
}
public
override
IcmpMessageType
MessageType
{
get
{
return
IcmpMessageType
.
ParameterProblem
;
}
}
protected
override
uint
Value
{
get
{
return
(
uint
)(
Pointer
<<
24
);
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/Icmp/IcmpRedirectLayer.cs
0 → 100644
View file @
c1dde0d3
using
PcapDotNet.Packets.IpV4
;
namespace
PcapDotNet.Packets.Icmp
{
public
class
IcmpRedirectLayer
:
IcmpLayer
{
public
IcmpCodeRedirect
Code
{
get
;
set
;
}
public
IpV4Address
GatewayInternetAddress
{
get
;
set
;}
public
override
IcmpMessageType
MessageType
{
get
{
return
IcmpMessageType
.
Redirect
;
}
}
public
override
byte
CodeValue
{
get
{
return
(
byte
)
Code
;
}
}
protected
override
uint
Value
{
get
{
return
GatewayInternetAddress
.
ToValue
();
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/Icmp/IcmpRouterAdvertisementLayer.cs
0 → 100644
View file @
c1dde0d3
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
namespace
PcapDotNet.Packets.Icmp
{
public
class
IcmpRouterAdvertisementLayer
:
IcmpLayer
{
public
TimeSpan
Lifetime
{
get
;
set
;
}
public
List
<
IcmpRouterAdvertisementEntry
>
Entries
{
get
;
set
;
}
public
override
IcmpMessageType
MessageType
{
get
{
return
IcmpMessageType
.
RouterAdvertisement
;
}
}
protected
override
uint
Value
{
get
{
return
(
uint
)(((
byte
)
Entries
.
Count
<<
24
)
|
(
IcmpRouterAdvertisementDatagram
.
DefaultAddressEntrySize
<<
16
)
|
((
ushort
)
Lifetime
.
TotalSeconds
));
}
}
public
override
int
Length
{
get
{
return
base
.
Length
+
IcmpRouterAdvertisementDatagram
.
GetHeaderAdditionalLength
(
Entries
.
Count
);
}
}
protected
override
void
WriteHeaderAdditional
(
byte
[]
buffer
,
int
offset
)
{
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
);
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/Icmp/IcmpRouterSolicitationLayer.cs
0 → 100644
View file @
c1dde0d3
namespace
PcapDotNet.Packets.Icmp
{
public
class
IcmpRouterSolicitationLayer
:
IcmpLayer
{
public
override
IcmpMessageType
MessageType
{
get
{
return
IcmpMessageType
.
RouterSolicitation
;
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/Icmp/IcmpSecurityFailuresLayer.cs
0 → 100644
View file @
c1dde0d3
namespace
PcapDotNet.Packets.Icmp
{
public
class
IcmpSecurityFailuresLayer
:
IcmpLayer
{
public
IcmpCodeSecurityFailures
Code
{
get
;
set
;}
public
ushort
Pointer
{
get
;
set
;}
public
override
IcmpMessageType
MessageType
{
get
{
return
IcmpMessageType
.
SecurityFailures
;
}
}
public
override
byte
CodeValue
{
get
{
return
(
byte
)
Code
;
}
}
protected
override
uint
Value
{
get
{
return
Pointer
;
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/Icmp/IcmpSourceQuenchLayer.cs
0 → 100644
View file @
c1dde0d3
namespace
PcapDotNet.Packets.Icmp
{
public
class
IcmpSourceQuenchLayer
:
IcmpLayer
{
public
override
IcmpMessageType
MessageType
{
get
{
return
IcmpMessageType
.
SourceQuench
;
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/Icmp/IcmpTimeExceededLayer.cs
0 → 100644
View file @
c1dde0d3
namespace
PcapDotNet.Packets.Icmp
{
public
class
IcmpTimeExceededLayer
:
IcmpLayer
{
public
IcmpCodeTimeExceeded
Code
{
get
;
set
;
}
public
override
IcmpMessageType
MessageType
{
get
{
return
IcmpMessageType
.
TimeExceeded
;
}
}
public
override
byte
CodeValue
{
get
{
return
(
byte
)
Code
;
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/Icmp/IcmpTimestampLayer.cs
0 → 100644
View file @
c1dde0d3
using
PcapDotNet.Packets.IpV4
;
namespace
PcapDotNet.Packets.Icmp
{
public
class
IcmpTimestampLayer
:
IcmpIdentifiedLayer
{
public
IpV4TimeOfDay
OriginateTimestamp
{
get
;
set
;
}
public
IpV4TimeOfDay
ReceiveTimestamp
{
get
;
set
;
}
public
IpV4TimeOfDay
TransmitTimestamp
{
get
;
set
;
}
public
override
IcmpMessageType
MessageType
{
get
{
return
IcmpMessageType
.
Timestamp
;
}
}
public
override
int
Length
{
get
{
return
base
.
Length
+
IcmpTimestampDatagram
.
HeaderAdditionalLength
;
}
}
protected
override
void
WriteHeaderAdditional
(
byte
[]
buffer
,
int
offset
)
{
IcmpTimestampDatagram
.
WriteHeaderAdditional
(
buffer
,
offset
,
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
);
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/Icmp/IcmpTimestampReplyLayer.cs
0 → 100644
View file @
c1dde0d3
namespace
PcapDotNet.Packets.Icmp
{
public
class
IcmpTimestampReplyLayer
:
IcmpTimestampLayer
{
public
override
IcmpMessageType
MessageType
{
get
{
return
IcmpMessageType
.
TimestampReply
;
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/IcmpTracerouteLayer.cs
→
PcapDotNet/src/PcapDotNet.Packets/Icmp
/Icmp
TracerouteLayer.cs
View file @
c1dde0d3
using
System
;
using
PcapDotNet.Packets.Icmp
;
namespace
PcapDotNet.Packets
namespace
PcapDotNet.Packets
.Icmp
{
public
class
IcmpTracerouteLayer
:
IcmpLayer
{
...
...
PcapDotNet/src/PcapDotNet.Packets/Igmp/IIgmpLayerWithGroupAddress.cs
0 → 100644
View file @
c1dde0d3
using
PcapDotNet.Packets.IpV4
;
namespace
PcapDotNet.Packets.Igmp
{
public
interface
IIgmpLayerWithGroupAddress
{
IpV4Address
GroupAddress
{
get
;
set
;
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/Igmp/IgmpLayer.cs
0 → 100644
View file @
c1dde0d3
using
System
;
using
PcapDotNet.Base
;
using
PcapDotNet.Packets.IpV4
;
namespace
PcapDotNet.Packets.Igmp
{
public
abstract
class
IgmpLayer
:
SimpleLayer
,
IIpV4NextLayer
{
public
abstract
IgmpMessageType
MessageType
{
get
;
}
public
virtual
IgmpQueryVersion
QueryVersion
{
get
{
return
IgmpQueryVersion
.
None
;
}
}
public
abstract
TimeSpan
MaxResponseTimeValue
{
get
;
}
public
IpV4Protocol
PreviousLayerProtocol
{
get
{
return
IpV4Protocol
.
InternetGroupManagementProtocol
;
}
}
public
virtual
bool
Equals
(
IgmpLayer
other
)
{
return
other
!=
null
&&
MessageType
==
other
.
MessageType
&&
QueryVersion
==
other
.
QueryVersion
&&
MaxResponseTimeValue
.
Divide
(
2
)
<=
other
.
MaxResponseTimeValue
&&
MaxResponseTimeValue
.
Multiply
(
2
)
>=
other
.
MaxResponseTimeValue
;
}
public
sealed
override
bool
Equals
(
Layer
other
)
{
return
base
.
Equals
(
other
)
&&
Equals
(
other
as
IgmpLayer
);
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/Igmp/IgmpLeaveGroupVersion2Layer.cs
0 → 100644
View file @
c1dde0d3
namespace
PcapDotNet.Packets.Igmp
{
public
class
IgmpLeaveGroupVersion2Layer
:
IgmpVersion2Layer
{
public
override
IgmpMessageType
MessageType
{
get
{
return
IgmpMessageType
.
LeaveGroupVersion2
;
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/Igmp/IgmpQueryVersion1Layer.cs
0 → 100644
View file @
c1dde0d3
namespace
PcapDotNet.Packets.Igmp
{
public
class
IgmpQueryVersion1Layer
:
IgmpVersion1Layer
{
public
override
IgmpMessageType
MessageType
{
get
{
return
IgmpMessageType
.
MembershipQuery
;
}
}
public
override
IgmpQueryVersion
QueryVersion
{
get
{
return
IgmpQueryVersion
.
Version1
;
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/Igmp/IgmpQueryVersion2Layer.cs
0 → 100644
View file @
c1dde0d3
namespace
PcapDotNet.Packets.Igmp
{
public
class
IgmpQueryVersion2Layer
:
IgmpVersion2Layer
{
public
override
IgmpMessageType
MessageType
{
get
{
return
IgmpMessageType
.
MembershipQuery
;
}
}
public
override
IgmpQueryVersion
QueryVersion
{
get
{
return
IgmpQueryVersion
.
Version2
;
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/Igmp/IgmpQueryVersion3Layer.cs
0 → 100644
View file @
c1dde0d3
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
PcapDotNet.Base
;
using
PcapDotNet.Packets.IpV4
;
namespace
PcapDotNet.Packets.Igmp
{
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
;
}
public
byte
QueryRobustnessVariable
{
get
;
set
;}
public
TimeSpan
QueryInterval
{
get
;
set
;}
public
IList
<
IpV4Address
>
SourceAddresses
{
get
;
set
;}
public
override
int
Length
{
get
{
return
IgmpDatagram
.
GetQueryVersion3Length
(
SourceAddresses
.
Count
);
}
}
protected
override
void
Write
(
byte
[]
buffer
,
int
offset
)
{
IgmpDatagram
.
WriteQueryVersion3
(
buffer
,
offset
,
MaxResponseTime
,
GroupAddress
,
IsSuppressRouterSideProcessing
,
QueryRobustnessVariable
,
QueryInterval
,
SourceAddresses
);
}
public
override
IgmpMessageType
MessageType
{
get
{
return
IgmpMessageType
.
MembershipQuery
;
}
}
public
override
IgmpQueryVersion
QueryVersion
{
get
{
return
IgmpQueryVersion
.
Version3
;
}
}
public
override
TimeSpan
MaxResponseTimeValue
{
get
{
return
MaxResponseTime
;
}
}
public
bool
Equals
(
IgmpQueryVersion3Layer
other
)
{
return
other
!=
null
&&
GroupAddress
==
other
.
GroupAddress
&&
IsSuppressRouterSideProcessing
==
other
.
IsSuppressRouterSideProcessing
&&
QueryRobustnessVariable
==
other
.
QueryRobustnessVariable
&&
QueryInterval
.
Divide
(
2
)
<=
other
.
QueryInterval
&&
QueryInterval
.
Multiply
(
2
)
>=
other
.
QueryInterval
&&
SourceAddresses
.
SequenceEqual
(
other
.
SourceAddresses
);
}
public
override
sealed
bool
Equals
(
IgmpLayer
other
)
{
return
base
.
Equals
(
other
)
&&
Equals
(
other
as
IgmpQueryVersion3Layer
);
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/Igmp/IgmpReportVersion1Layer.cs
0 → 100644
View file @
c1dde0d3
namespace
PcapDotNet.Packets.Igmp
{
public
class
IgmpReportVersion1Layer
:
IgmpVersion1Layer
{
public
override
IgmpMessageType
MessageType
{
get
{
return
IgmpMessageType
.
MembershipReportVersion1
;
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/Igmp/IgmpReportVersion2Layer.cs
0 → 100644
View file @
c1dde0d3
namespace
PcapDotNet.Packets.Igmp
{
public
class
IgmpReportVersion2Layer
:
IgmpVersion2Layer
{
public
override
IgmpMessageType
MessageType
{
get
{
return
IgmpMessageType
.
MembershipReportVersion2
;
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/Igmp/IgmpReportVersion3Layer.cs
0 → 100644
View file @
c1dde0d3
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
namespace
PcapDotNet.Packets.Igmp
{
public
class
IgmpReportVersion3Layer
:
IgmpLayer
{
public
IList
<
IgmpGroupRecord
>
GroupRecords
{
get
;
set
;}
public
override
int
Length
{
get
{
return
IgmpDatagram
.
GetReportVersion3Length
(
GroupRecords
);
}
}
protected
override
void
Write
(
byte
[]
buffer
,
int
offset
)
{
IgmpDatagram
.
WriteReportVersion3
(
buffer
,
offset
,
GroupRecords
);
}
public
override
IgmpMessageType
MessageType
{
get
{
return
IgmpMessageType
.
MembershipReportVersion3
;
}
}
public
override
TimeSpan
MaxResponseTimeValue
{
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
);
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/Igmp/IgmpSimpleLayer.cs
0 → 100644
View file @
c1dde0d3
using
PcapDotNet.Packets.IpV4
;
namespace
PcapDotNet.Packets.Igmp
{
public
abstract
class
IgmpSimpleLayer
:
IgmpLayer
,
IIgmpLayerWithGroupAddress
{
public
IpV4Address
GroupAddress
{
get
;
set
;
}
public
override
int
Length
{
get
{
return
IgmpDatagram
.
HeaderLength
;
}
}
protected
override
void
Write
(
byte
[]
buffer
,
int
offset
)
{
IgmpDatagram
.
WriteHeader
(
buffer
,
offset
,
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
);
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/Igmp/IgmpVersion1Layer.cs
0 → 100644
View file @
c1dde0d3
using
System
;
namespace
PcapDotNet.Packets.Igmp
{
public
abstract
class
IgmpVersion1Layer
:
IgmpSimpleLayer
{
public
override
TimeSpan
MaxResponseTimeValue
{
get
{
return
TimeSpan
.
Zero
;
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/Igmp/IgmpVersion2Layer.cs
0 → 100644
View file @
c1dde0d3
using
System
;
namespace
PcapDotNet.Packets.Igmp
{
public
abstract
class
IgmpVersion2Layer
:
IgmpSimpleLayer
{
public
TimeSpan
MaxResponseTime
{
get
;
set
;
}
public
override
TimeSpan
MaxResponseTimeValue
{
get
{
return
MaxResponseTime
;
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/IpV4/IIpV4NextLayer.cs
0 → 100644
View file @
c1dde0d3
namespace
PcapDotNet.Packets.IpV4
{
public
interface
IIpV4NextLayer
:
ILayer
{
IpV4Protocol
PreviousLayerProtocol
{
get
;
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/IpV4/IIpV4NextTransportLayer.cs
0 → 100644
View file @
c1dde0d3
namespace
PcapDotNet.Packets.IpV4
{
public
interface
IIpV4NextTransportLayer
:
IIpV4NextLayer
{
ushort
?
Checksum
{
get
;
set
;
}
bool
CalculateChecksum
{
get
;
}
int
NextLayerChecksumOffset
{
get
;
}
bool
NextLayerIsChecksumOptional
{
get
;
}
bool
NextLayerCalculateChecksum
{
get
;
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/IpV4/IpV4Layer.cs
0 → 100644
View file @
c1dde0d3
using
System
;
using
PcapDotNet.Packets.Ethernet
;
namespace
PcapDotNet.Packets.IpV4
{
public
class
IpV4Layer
:
Layer
,
IEthernetNextLayer
{
public
IpV4Layer
()
{
TypeOfService
=
0
;
Identification
=
0
;
Fragmentation
=
IpV4Fragmentation
.
None
;
Ttl
=
0
;
Protocol
=
null
;
HeaderChecksum
=
null
;
Source
=
IpV4Address
.
Zero
;
Destination
=
IpV4Address
.
Zero
;
Options
=
IpV4Options
.
None
;
}
public
byte
TypeOfService
{
get
;
set
;
}
public
ushort
Identification
{
get
;
set
;
}
public
IpV4Fragmentation
Fragmentation
{
get
;
set
;
}
public
byte
Ttl
{
get
;
set
;
}
public
IpV4Protocol
?
Protocol
{
get
;
set
;
}
public
ushort
?
HeaderChecksum
{
get
;
set
;
}
public
IpV4Address
Source
{
get
;
set
;
}
public
IpV4Address
Destination
{
get
;
set
;
}
public
IpV4Options
Options
{
get
;
set
;
}
public
EthernetType
PreviousLayerEtherType
{
get
{
return
EthernetType
.
IpV4
;
}
}
public
MacAddress
?
PreviousLayerDefaultDestination
{
get
{
return
null
;
}
}
public
override
int
Length
{
get
{
return
IpV4Datagram
.
HeaderMinimumLength
+
Options
.
BytesLength
;
}
}
public
override
void
Write
(
byte
[]
buffer
,
int
offset
,
int
payloadLength
,
ILayer
previousLayer
,
ILayer
nextLayer
)
{
IpV4Protocol
protocol
;
if
(
Protocol
==
null
)
{
if
(
nextLayer
==
null
)
throw
new
ArgumentException
(
"Can't determine protocol automatically from next layer because there is no next layer"
);
IIpV4NextLayer
ipV4NextLayer
=
nextLayer
as
IIpV4NextLayer
;
if
(
ipV4NextLayer
==
null
)
throw
new
ArgumentException
(
"Can't determine protocol automatically from next layer ("
+
nextLayer
.
GetType
()
+
")"
);
protocol
=
ipV4NextLayer
.
PreviousLayerProtocol
;
}
else
protocol
=
Protocol
.
Value
;
IpV4Datagram
.
WriteHeader
(
buffer
,
offset
,
TypeOfService
,
Identification
,
Fragmentation
,
Ttl
,
protocol
,
HeaderChecksum
,
Source
,
Destination
,
Options
,
payloadLength
);
}
public
override
void
Finalize
(
byte
[]
buffer
,
int
offset
,
int
payloadLength
,
ILayer
nextLayer
)
{
IIpV4NextTransportLayer
nextTransportLayer
=
nextLayer
as
IIpV4NextTransportLayer
;
if
(
nextTransportLayer
==
null
||
!
nextTransportLayer
.
NextLayerCalculateChecksum
)
return
;
if
(
nextTransportLayer
.
CalculateChecksum
)
IpV4Datagram
.
WriteTransportChecksum
(
buffer
,
offset
,
Length
,
(
ushort
)
payloadLength
,
nextTransportLayer
.
NextLayerChecksumOffset
,
nextTransportLayer
.
NextLayerIsChecksumOptional
,
nextTransportLayer
.
Checksum
);
}
public
bool
Equals
(
IpV4Layer
other
)
{
return
other
!=
null
&&
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
);
}
public
override
sealed
bool
Equals
(
Layer
other
)
{
return
base
.
Equals
(
other
)
&&
Equals
(
other
as
IpV4Layer
);
}
public
override
string
ToString
()
{
return
Source
+
" -> "
+
Destination
+
" ("
+
Protocol
+
")"
;
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/Layer.cs
0 → 100644
View file @
c1dde0d3
namespace
PcapDotNet.Packets
{
public
abstract
class
Layer
:
ILayer
{
public
abstract
int
Length
{
get
;
}
public
abstract
void
Write
(
byte
[]
buffer
,
int
offset
,
int
payloadLength
,
ILayer
previousLayer
,
ILayer
nextLayer
);
public
virtual
void
Finalize
(
byte
[]
buffer
,
int
offset
,
int
payloadLength
,
ILayer
nextLayer
)
{
}
public
virtual
DataLinkKind
?
DataLink
{
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
);
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/PacketBuilder.cs
View file @
c1dde0d3
This diff is collapsed.
Click to expand it.
PcapDotNet/src/PcapDotNet.Packets/PayloadLayer.cs
0 → 100644
View file @
c1dde0d3
namespace
PcapDotNet.Packets
{
public
class
PayloadLayer
:
SimpleLayer
{
public
Datagram
Data
{
get
;
set
;
}
public
PayloadLayer
()
{
Data
=
Datagram
.
Empty
;
}
public
override
int
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
)
{
Data
.
Write
(
buffer
,
offset
);
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/PcapDotNet.Packets.csproj
View file @
c1dde0d3
...
...
@@ -60,6 +60,7 @@
<Reference
Include=
"System.Xml"
/>
</ItemGroup>
<ItemGroup>
<Compile
Include=
"Arp\ArpLayer.cs"
/>
<Compile
Include=
"Arp\ArpDatagram.cs"
/>
<Compile
Include=
"Arp\ArpHardwareType.cs"
/>
<Compile
Include=
"Arp\ArpOperation.cs"
/>
...
...
@@ -67,10 +68,32 @@
<Compile
Include=
"DataLink.cs"
/>
<Compile
Include=
"DataLinkKind.cs"
/>
<Compile
Include=
"Endianity.cs"
/>
<Compile
Include=
"Ethernet\EthernetLayer.cs"
/>
<Compile
Include=
"Ethernet\EthernetDatagram.cs"
/>
<Compile
Include=
"Ethernet\EthernetType.cs"
/>
<Compile
Include=
"Ethernet\MacAddress.cs"
/>
<Compile
Include=
"IcmpTracerouteLayer.cs"
/>
<Compile
Include=
"Arp\IArpPreviousLayer.cs"
/>
<Compile
Include=
"Icmp\IcmpAddressMaskReplyLayer.cs"
/>
<Compile
Include=
"Icmp\IcmpAddressMaskRequestLayer.cs"
/>
<Compile
Include=
"Icmp\IcmpConversionFailedLayer.cs"
/>
<Compile
Include=
"Icmp\IcmpDestinationUnreachableLayer.cs"
/>
<Compile
Include=
"Icmp\IcmpDomainNameRequestLayer.cs"
/>
<Compile
Include=
"Icmp\IcmpEchoLayer.cs"
/>
<Compile
Include=
"Icmp\IcmpEchoReplyLayer.cs"
/>
<Compile
Include=
"Icmp\IcmpIdentifiedLayer.cs"
/>
<Compile
Include=
"Icmp\IcmpInformationReplyLayer.cs"
/>
<Compile
Include=
"Icmp\IcmpInformationRequestLayer.cs"
/>
<Compile
Include=
"Icmp\IcmpLayer.cs"
/>
<Compile
Include=
"Icmp\IcmpParameterProblemLayer.cs"
/>
<Compile
Include=
"Icmp\IcmpRedirectLayer.cs"
/>
<Compile
Include=
"Icmp\IcmpRouterAdvertisementLayer.cs"
/>
<Compile
Include=
"Icmp\IcmpRouterSolicitationLayer.cs"
/>
<Compile
Include=
"Icmp\IcmpSecurityFailuresLayer.cs"
/>
<Compile
Include=
"Icmp\IcmpSourceQuenchLayer.cs"
/>
<Compile
Include=
"Icmp\IcmpTimeExceededLayer.cs"
/>
<Compile
Include=
"Icmp\IcmpTimestampLayer.cs"
/>
<Compile
Include=
"Icmp\IcmpTimestampReplyLayer.cs"
/>
<Compile
Include=
"Icmp\IcmpTracerouteLayer.cs"
/>
<Compile
Include=
"Icmp\IcmpAddressMaskDatagram.cs"
/>
<Compile
Include=
"Icmp\IcmpCodeDestinationUnrechable.cs"
/>
<Compile
Include=
"Icmp\IcmpConversionFailedDatagram.cs"
/>
...
...
@@ -89,15 +112,33 @@
<Compile
Include=
"Icmp\IcmpMessageTypeAndCode.cs"
/>
<Compile
Include=
"Icmp\IcmpTypedDatagram.cs"
/>
<Compile
Include=
"IDataLink.cs"
/>
<Compile
Include=
"Ethernet\IEthernetNextLayer.cs"
/>
<Compile
Include=
"Igmp\IgmpLayer.cs"
/>
<Compile
Include=
"Igmp\IgmpLeaveGroupVersion2Layer.cs"
/>
<Compile
Include=
"Igmp\IgmpQueryVersion1Layer.cs"
/>
<Compile
Include=
"Igmp\IgmpQueryVersion2Layer.cs"
/>
<Compile
Include=
"Igmp\IgmpQueryVersion3Layer.cs"
/>
<Compile
Include=
"Igmp\IgmpReportVersion1Layer.cs"
/>
<Compile
Include=
"Igmp\IgmpReportVersion2Layer.cs"
/>
<Compile
Include=
"Igmp\IgmpReportVersion3Layer.cs"
/>
<Compile
Include=
"Igmp\IgmpSimpleLayer.cs"
/>
<Compile
Include=
"Igmp\IgmpVersion1Layer.cs"
/>
<Compile
Include=
"Igmp\IgmpVersion2Layer.cs"
/>
<Compile
Include=
"Igmp\IgmpDatagram.cs"
/>
<Compile
Include=
"Igmp\IgmpGroupRecord.cs"
/>
<Compile
Include=
"Igmp\IgmpGroupRecordDatagram.cs"
/>
<Compile
Include=
"Igmp\IgmpQueryVersion.cs"
/>
<Compile
Include=
"Igmp\IgmpRecordType.cs"
/>
<Compile
Include=
"Igmp\IgmpMessageType.cs"
/>
<Compile
Include=
"Igmp\IIgmpLayerWithGroupAddress.cs"
/>
<Compile
Include=
"IpV4\IIpV4NextLayer.cs"
/>
<Compile
Include=
"IpV4\IIpV4NextTransportLayer.cs"
/>
<Compile
Include=
"ILayer.cs"
/>
<Compile
Include=
"IOptionUnknownFactory.cs"
/>
<Compile
Include=
"IpV4\IpV4Layer.cs"
/>
<Compile
Include=
"IpV4\IpV4OptionUnknown.cs"
/>
<Compile
Include=
"IpV6\IpV6Address.cs"
/>
<Compile
Include=
"Layer.cs"
/>
<Compile
Include=
"Option.cs"
/>
<Compile
Include=
"IOptionComplexFactory.cs"
/>
<Compile
Include=
"IpV4\IpV4Address.cs"
/>
...
...
@@ -135,7 +176,11 @@
<Compile
Include=
"OptionTypeRegistrationAttribute.cs"
/>
<Compile
Include=
"Packet.cs"
/>
<Compile
Include=
"PacketBuilder.cs"
/>
<Compile
Include=
"PayloadLayer.cs"
/>
<Compile
Include=
"Properties\AssemblyInfo.cs"
/>
<Compile
Include=
"SimpleLayer.cs"
/>
<Compile
Include=
"Transport\TcpLayer.cs"
/>
<Compile
Include=
"Transport\TransportLayer.cs"
/>
<Compile
Include=
"Transport\TcpDatagram.cs"
/>
<Compile
Include=
"Transport\TcpControlBits.cs"
/>
<Compile
Include=
"Transport\TcpOption.cs"
/>
...
...
@@ -164,6 +209,7 @@
<Compile
Include=
"Transport\TcpOptionWindowScale.cs"
/>
<Compile
Include=
"Transport\TransportDatagram.cs"
/>
<Compile
Include=
"Transport\UdpDatagram.cs"
/>
<Compile
Include=
"Transport\UdpLayer.cs"
/>
</ItemGroup>
<ItemGroup>
<None
Include=
"..\PcapDotNet.snk"
/>
...
...
PcapDotNet/src/PcapDotNet.Packets/SimpleLayer.cs
0 → 100644
View file @
c1dde0d3
namespace
PcapDotNet.Packets
{
public
abstract
class
SimpleLayer
:
Layer
{
public
override
sealed
void
Write
(
byte
[]
buffer
,
int
offset
,
int
payloadLength
,
ILayer
nextLayer
,
ILayer
nextLayer1
)
{
Write
(
buffer
,
offset
);
}
protected
abstract
void
Write
(
byte
[]
buffer
,
int
offset
);
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/Transport/TcpLayer.cs
0 → 100644
View file @
c1dde0d3
using
PcapDotNet.Packets.IpV4
;
namespace
PcapDotNet.Packets.Transport
{
public
class
TcpLayer
:
TransportLayer
{
public
uint
SequenceNumber
{
get
;
set
;}
public
uint
AcknowledgmentNumber
{
get
;
set
;}
public
TcpControlBits
ControlBits
{
get
;
set
;}
public
ushort
Window
{
get
;
set
;}
public
ushort
UrgentPointer
{
get
;
set
;}
public
TcpOptions
Options
{
get
;
set
;}
public
override
IpV4Protocol
PreviousLayerProtocol
{
get
{
return
IpV4Protocol
.
Tcp
;
}
}
public
override
int
NextLayerChecksumOffset
{
get
{
return
TcpDatagram
.
Offset
.
Checksum
;
}
}
public
override
bool
NextLayerIsChecksumOptional
{
get
{
return
false
;
}
}
public
override
bool
NextLayerCalculateChecksum
{
get
{
return
true
;
}
}
public
override
int
Length
{
get
{
return
TcpDatagram
.
HeaderMinimumLength
+
Options
.
BytesLength
;
}
}
public
override
void
Write
(
byte
[]
buffer
,
int
offset
,
int
payloadLength
,
ILayer
previousLayer
,
ILayer
nextLayer
)
{
TcpDatagram
.
WriteHeader
(
buffer
,
offset
,
SourcePort
,
DestinationPort
,
SequenceNumber
,
AcknowledgmentNumber
,
ControlBits
,
Window
,
UrgentPointer
,
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
.
Equals
(
other
.
Options
);
}
public
override
sealed
bool
Equals
(
TransportLayer
other
)
{
return
base
.
Equals
(
other
)
&&
Equals
(
other
as
TcpLayer
);
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/Transport/TransportLayer.cs
0 → 100644
View file @
c1dde0d3
using
PcapDotNet.Packets.IpV4
;
namespace
PcapDotNet.Packets.Transport
{
public
abstract
class
TransportLayer
:
Layer
,
IIpV4NextTransportLayer
{
public
ushort
?
Checksum
{
get
;
set
;
}
public
ushort
SourcePort
{
get
;
set
;
}
public
ushort
DestinationPort
{
get
;
set
;
}
public
abstract
IpV4Protocol
PreviousLayerProtocol
{
get
;
}
public
bool
CalculateChecksum
{
get
{
return
true
;
}
}
public
abstract
int
NextLayerChecksumOffset
{
get
;
}
public
abstract
bool
NextLayerIsChecksumOptional
{
get
;
}
public
abstract
bool
NextLayerCalculateChecksum
{
get
;
}
public
virtual
bool
Equals
(
TransportLayer
other
)
{
return
other
!=
null
&&
PreviousLayerProtocol
==
other
.
PreviousLayerProtocol
&&
Checksum
==
other
.
Checksum
&&
SourcePort
==
other
.
SourcePort
&&
DestinationPort
==
other
.
DestinationPort
;
}
public
override
sealed
bool
Equals
(
Layer
other
)
{
return
base
.
Equals
(
other
)
&&
Equals
(
other
as
TransportLayer
);
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/Transport/UdpLayer.cs
0 → 100644
View file @
c1dde0d3
using
PcapDotNet.Packets.IpV4
;
namespace
PcapDotNet.Packets.Transport
{
public
class
UdpLayer
:
TransportLayer
{
public
bool
CalculateChecksum
{
get
;
set
;
}
public
override
IpV4Protocol
PreviousLayerProtocol
{
get
{
return
IpV4Protocol
.
Udp
;
}
}
public
override
int
NextLayerChecksumOffset
{
get
{
return
UdpDatagram
.
Offset
.
Checksum
;
}
}
public
override
bool
NextLayerIsChecksumOptional
{
get
{
return
true
;
}
}
public
override
bool
NextLayerCalculateChecksum
{
get
{
return
CalculateChecksum
;
}
}
public
override
int
Length
{
get
{
return
UdpDatagram
.
HeaderLength
;
}
}
public
override
void
Write
(
byte
[]
buffer
,
int
offset
,
int
payloadLength
,
ILayer
previousLayer
,
ILayer
nextLayer
)
{
UdpDatagram
.
WriteHeader
(
buffer
,
offset
,
SourcePort
,
DestinationPort
,
payloadLength
);
}
}
}
\ No newline at end of file
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