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
b9e2fbb1
Commit
b9e2fbb1
authored
Apr 24, 2010
by
Brickner_cp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GRE
parent
caa669f1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
15 deletions
+21
-15
GreTests.cs
PcapDotNet/src/PcapDotNet.Packets.Test/GreTests.cs
+2
-0
RandomPacketsExtensions.cs
...c/PcapDotNet.Packets.TestUtils/RandomPacketsExtensions.cs
+13
-12
GreDatagram.cs
PcapDotNet/src/PcapDotNet.Packets/Gre/GreDatagram.cs
+3
-2
GreLayer.cs
PcapDotNet/src/PcapDotNet.Packets/Gre/GreLayer.cs
+3
-1
No files found.
PcapDotNet/src/PcapDotNet.Packets.Test/GreTests.cs
View file @
b9e2fbb1
...
...
@@ -102,9 +102,11 @@ namespace PcapDotNet.Packets.Test
greLayer
.
Checksum
=
actualGre
.
Checksum
;
}
Assert
.
AreEqual
(
greLayer
,
actualGreLayer
,
"Layer"
);
Assert
.
AreNotEqual
(
random
.
NextGreLayer
(),
actualGreLayer
,
"Not Layer"
);
Assert
.
AreEqual
(
greLayer
.
Length
,
actualGre
.
HeaderLength
);
Assert
.
IsTrue
(
actualGre
.
KeyPresent
^
(
greLayer
.
Key
==
null
));
MoreAssert
.
IsSmaller
(
8
,
actualGre
.
RecursionControl
);
MoreAssert
.
IsSmaller
(
32
,
actualGre
.
Flags
);
Assert
.
IsTrue
(
actualGre
.
RoutingPresent
^
(
greLayer
.
Routing
==
null
&&
greLayer
.
RoutingOffset
==
null
));
Assert
.
IsTrue
(
actualGre
.
SequenceNumberPresent
^
(
greLayer
.
SequenceNumber
==
null
));
Assert
.
IsTrue
(!
actualGre
.
StrictSourceRoute
||
actualGre
.
RoutingPresent
);
...
...
PcapDotNet/src/PcapDotNet.Packets.TestUtils/RandomPacketsExtensions.cs
View file @
b9e2fbb1
...
...
@@ -640,18 +640,19 @@ namespace PcapDotNet.Packets.TestUtils
}
return
new
GreLayer
{
Version
=
random
.
NextEnum
<
GreVersion
>(),
ProtocolType
=
random
.
NextEnum
(
EthernetType
.
None
),
ChecksumPresent
=
isChecksum
,
Checksum
=
isChecksum
&&
random
.
NextBool
()
?
(
ushort
?)
random
.
NextUShort
()
:
null
,
Key
=
random
.
NextBool
()
?
(
uint
?)
random
.
NextUInt
()
:
null
,
SequenceNumber
=
random
.
NextBool
()
?
(
uint
?)
random
.
NextUInt
()
:
null
,
RecursionControl
=
random
.
NextByte
(
8
),
Routing
=
routing
==
null
?
null
:
routing
.
AsReadOnly
(),
RoutingOffset
=
routingOffset
,
StrictSourceRoute
=
strictSourceRoute
,
};
{
Version
=
random
.
NextEnum
<
GreVersion
>(),
ProtocolType
=
random
.
NextEnum
(
EthernetType
.
None
),
ChecksumPresent
=
isChecksum
,
Checksum
=
isChecksum
&&
random
.
NextBool
()
?
(
ushort
?)
random
.
NextUShort
()
:
null
,
Key
=
random
.
NextBool
()
?
(
uint
?)
random
.
NextUInt
()
:
null
,
SequenceNumber
=
random
.
NextBool
()
?
(
uint
?)
random
.
NextUInt
()
:
null
,
RecursionControl
=
random
.
NextByte
(
8
),
Flags
=
random
.
NextByte
(
32
),
Routing
=
routing
==
null
?
null
:
routing
.
AsReadOnly
(),
RoutingOffset
=
routingOffset
,
StrictSourceRoute
=
strictSourceRoute
,
};
}
// ICMP
...
...
PcapDotNet/src/PcapDotNet.Packets/Gre/GreDatagram.cs
View file @
b9e2fbb1
...
...
@@ -258,6 +258,7 @@ namespace PcapDotNet.Packets.Gre
Version
=
Version
,
ProtocolType
=
ProtocolType
,
RecursionControl
=
RecursionControl
,
Flags
=
Flags
,
ChecksumPresent
=
ChecksumPresent
,
Checksum
=
ChecksumPresent
?
(
ushort
?)
Checksum
:
null
,
Key
=
KeyPresent
?
(
uint
?)
Key
:
null
,
...
...
@@ -288,7 +289,7 @@ namespace PcapDotNet.Packets.Gre
}
internal
static
void
WriteHeader
(
byte
[]
buffer
,
int
offset
,
byte
recursionControl
,
GreVersion
version
,
EthernetType
protocolType
,
byte
recursionControl
,
byte
flags
,
GreVersion
version
,
EthernetType
protocolType
,
bool
checksumPresent
,
uint
?
key
,
uint
?
sequenceNumber
,
ReadOnlyCollection
<
GreSourceRouteEntry
>
routing
,
ushort
?
routingOffset
,
bool
strictSourceRoute
)
{
...
...
@@ -300,7 +301,7 @@ namespace PcapDotNet.Packets.Gre
(
strictSourceRoute
?
Mask
.
StrictSourceRoute
:
(
byte
)
0
)
|
(
recursionControl
&
Mask
.
RecursionControl
)));
buffer
.
Write
(
offset
+
Offset
.
Version
,
(
byte
)((
byte
)
version
&
Mask
.
Version
));
buffer
.
Write
(
offset
+
Offset
.
Flags
,
(
byte
)(((
flags
<<
Shift
.
Flags
)
&
Mask
.
Flags
)
|
((
byte
)
version
&
Mask
.
Version
)
));
buffer
.
Write
(
offset
+
Offset
.
ProtocolType
,
(
ushort
)
protocolType
,
Endianity
.
Big
);
...
...
PcapDotNet/src/PcapDotNet.Packets/Gre/GreLayer.cs
View file @
b9e2fbb1
...
...
@@ -11,6 +11,7 @@ namespace PcapDotNet.Packets.Gre
public
GreVersion
Version
{
get
;
set
;
}
public
EthernetType
ProtocolType
{
get
;
set
;
}
public
byte
RecursionControl
{
get
;
set
;
}
public
byte
Flags
{
get
;
set
;
}
public
bool
ChecksumPresent
{
get
;
set
;
}
public
ushort
?
Checksum
{
get
;
set
;
}
public
uint
?
Key
{
get
;
set
;
}
...
...
@@ -29,7 +30,7 @@ namespace PcapDotNet.Packets.Gre
public
override
void
Write
(
byte
[]
buffer
,
int
offset
,
int
payloadLength
,
ILayer
previousLayer
,
ILayer
nextLayer
)
{
GreDatagram
.
WriteHeader
(
buffer
,
offset
,
RecursionControl
,
Version
,
ProtocolType
,
ChecksumPresent
,
Key
,
SequenceNumber
,
Routing
,
RoutingOffset
,
StrictSourceRoute
);
GreDatagram
.
WriteHeader
(
buffer
,
offset
,
RecursionControl
,
Flags
,
Version
,
ProtocolType
,
ChecksumPresent
,
Key
,
SequenceNumber
,
Routing
,
RoutingOffset
,
StrictSourceRoute
);
}
public
override
void
Finalize
(
byte
[]
buffer
,
int
offset
,
int
payloadLength
,
ILayer
nextLayer
)
...
...
@@ -44,6 +45,7 @@ namespace PcapDotNet.Packets.Gre
Version
.
Equals
(
other
.
Version
)
&&
ProtocolType
.
Equals
(
other
.
ProtocolType
)
&&
RecursionControl
.
Equals
(
other
.
RecursionControl
)
&&
Flags
.
Equals
(
other
.
Flags
)
&&
ChecksumPresent
.
Equals
(
other
.
ChecksumPresent
)
&&
(
Checksum
==
null
?
other
.
Checksum
==
null
:
Checksum
.
Equals
(
other
.
Checksum
))
&&
(
Key
==
null
?
other
.
Key
==
null
:
Key
.
Equals
(
other
.
Key
))
&&
...
...
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