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
7228fb73
Commit
7228fb73
authored
Apr 11, 2012
by
Brickner_cp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GRE refactoring.
parent
433ea023
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
43 deletions
+18
-43
EthernetBaseDatagram.cs
...t/src/PcapDotNet.Packets/Ethernet/EthernetBaseDatagram.cs
+4
-4
EthernetDatagram.cs
...otNet/src/PcapDotNet.Packets/Ethernet/EthernetDatagram.cs
+3
-0
GreDatagram.cs
PcapDotNet/src/PcapDotNet.Packets/Gre/GreDatagram.cs
+11
-39
No files found.
PcapDotNet/src/PcapDotNet.Packets/Ethernet/EthernetBaseDatagram.cs
View file @
7228fb73
...
@@ -6,14 +6,14 @@ namespace PcapDotNet.Packets.Ethernet
...
@@ -6,14 +6,14 @@ namespace PcapDotNet.Packets.Ethernet
public
abstract
class
EthernetBaseDatagram
:
Datagram
public
abstract
class
EthernetBaseDatagram
:
Datagram
{
{
/// <summary>
/// <summary>
///
Ethernet type (next protocol)
.
///
Header length in bytes
.
/// </summary>
/// </summary>
public
abstract
EthernetType
EtherType
{
get
;
}
public
abstract
int
HeaderLength
{
get
;
}
/// <summary>
/// <summary>
///
Header length in bytes
.
///
Ethernet type (next protocol)
.
/// </summary>
/// </summary>
public
abstract
int
HeaderLength
{
get
;
}
public
abstract
EthernetType
EtherType
{
get
;
}
/// <summary>
/// <summary>
/// The Ethernet payload.
/// The Ethernet payload.
...
...
PcapDotNet/src/PcapDotNet.Packets/Ethernet/EthernetDatagram.cs
View file @
7228fb73
...
@@ -29,6 +29,9 @@ namespace PcapDotNet.Packets.Ethernet
...
@@ -29,6 +29,9 @@ namespace PcapDotNet.Packets.Ethernet
/// </summary>
/// </summary>
public
const
int
HeaderLengthValue
=
Offset
.
EtherTypeLength
+
sizeof
(
ushort
);
public
const
int
HeaderLengthValue
=
Offset
.
EtherTypeLength
+
sizeof
(
ushort
);
/// <summary>
/// Header length in bytes.
/// </summary>
public
override
int
HeaderLength
public
override
int
HeaderLength
{
{
get
{
return
HeaderLengthValue
;
}
get
{
return
HeaderLengthValue
;
}
...
...
PcapDotNet/src/PcapDotNet.Packets/Gre/GreDatagram.cs
View file @
7228fb73
...
@@ -28,7 +28,7 @@ namespace PcapDotNet.Packets.Gre
...
@@ -28,7 +28,7 @@ namespace PcapDotNet.Packets.Gre
/// +-----+---------------------------------------------------------------------+
/// +-----+---------------------------------------------------------------------+
/// </pre>
/// </pre>
/// </summary>
/// </summary>
public
sealed
class
GreDatagram
:
Datagram
public
sealed
class
GreDatagram
:
EthernetBase
Datagram
{
{
private
static
class
Offset
private
static
class
Offset
{
{
...
@@ -72,7 +72,7 @@ namespace PcapDotNet.Packets.Gre
...
@@ -72,7 +72,7 @@ namespace PcapDotNet.Packets.Gre
/// <summary>
/// <summary>
/// The length of the full GRE header on bytes.
/// The length of the full GRE header on bytes.
/// </summary>
/// </summary>
public
int
HeaderLength
public
override
int
HeaderLength
{
{
get
get
{
{
...
@@ -80,6 +80,14 @@ namespace PcapDotNet.Packets.Gre
...
@@ -80,6 +80,14 @@ namespace PcapDotNet.Packets.Gre
}
}
}
}
/// <summary>
/// Ethernet type (next protocol).
/// </summary>
public
override
EthernetType
EtherType
{
get
{
return
ProtocolType
;
}
}
/// <summary>
/// <summary>
/// If the Checksum Present bit is set to 1, then the Checksum field is present and contains valid information.
/// If the Checksum Present bit is set to 1, then the Checksum field is present and contains valid information.
/// If either the Checksum Present bit or the Routing Present bit are set, BOTH the Checksum and Offset fields are present in the GRE packet.
/// If either the Checksum Present bit or the Routing Present bit are set, BOTH the Checksum and Offset fields are present in the GRE packet.
...
@@ -320,30 +328,6 @@ namespace PcapDotNet.Packets.Gre
...
@@ -320,30 +328,6 @@ namespace PcapDotNet.Packets.Gre
};
};
}
}
/// <summary>
/// The Ethernet payload.
/// </summary>
public
Datagram
Payload
{
get
{
return
PayloadDatagrams
.
Payload
;
}
}
/// <summary>
/// The Ethernet payload as an IPv4 datagram.
/// </summary>
public
IpV4Datagram
IpV4
{
get
{
return
PayloadDatagrams
.
IpV4
;
}
}
/// <summary>
/// The Ethernet payload as an ARP datagram.
/// </summary>
public
ArpDatagram
Arp
{
get
{
return
PayloadDatagrams
.
Arp
;
}
}
/// <summary>
/// <summary>
/// A GRE Datagram is valid if its length is enough for the GRE header, its routing information is valid,
/// A GRE Datagram is valid if its length is enough for the GRE header, its routing information is valid,
/// the bits for future use are set to 0, it has acknowledgment sequence number only if it's Enhanced GRE,
/// the bits for future use are set to 0, it has acknowledgment sequence number only if it's Enhanced GRE,
...
@@ -354,7 +338,7 @@ namespace PcapDotNet.Packets.Gre
...
@@ -354,7 +338,7 @@ namespace PcapDotNet.Packets.Gre
{
{
if
(
Length
<
HeaderMinimumLength
||
Length
<
HeaderLength
)
if
(
Length
<
HeaderMinimumLength
||
Length
<
HeaderLength
)
return
false
;
return
false
;
Datagram
payloadByProtocolType
=
Payload
Datagrams
.
Get
(
ProtocolType
)
;
Datagram
payloadByProtocolType
=
Payload
ByEtherType
;
return
(
IsValidRouting
&&
FutureUseBits
==
0
&&
return
(
IsValidRouting
&&
FutureUseBits
==
0
&&
(
Version
==
GreVersion
.
EnhancedGre
||
Version
==
GreVersion
.
Gre
&&
!
AcknowledgmentSequenceNumberPresent
)
&&
(
Version
==
GreVersion
.
EnhancedGre
||
Version
==
GreVersion
.
Gre
&&
!
AcknowledgmentSequenceNumberPresent
)
&&
(!
ChecksumPresent
||
IsChecksumCorrect
)
&&
(!
ChecksumPresent
||
IsChecksumCorrect
)
&&
...
@@ -512,19 +496,7 @@ namespace PcapDotNet.Packets.Gre
...
@@ -512,19 +496,7 @@ namespace PcapDotNet.Packets.Gre
return
_isValidRouting
;
return
_isValidRouting
;
}
}
}
}
private
EthernetPayloadDatagrams
PayloadDatagrams
{
get
{
return
_payloadDatagrams
??
(
_payloadDatagrams
=
new
EthernetPayloadDatagrams
(
Length
>=
HeaderLength
?
new
Datagram
(
Buffer
,
StartOffset
+
HeaderLength
,
Length
-
HeaderLength
)
:
null
));
}
}
private
EthernetPayloadDatagrams
_payloadDatagrams
;
private
ReadOnlyCollection
<
GreSourceRouteEntry
>
_routing
;
private
ReadOnlyCollection
<
GreSourceRouteEntry
>
_routing
;
private
bool
_isValidRouting
=
true
;
private
bool
_isValidRouting
=
true
;
private
bool
?
_isChecksumCorrect
;
private
bool
?
_isChecksumCorrect
;
...
...
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