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
04f41c99
Commit
04f41c99
authored
Aug 08, 2009
by
Brickner_cp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring
parent
1d2fe8dd
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
24 additions
and
34 deletions
+24
-34
MoreIpV4Option.cs
PcapDotNet/src/PcapDotNet.Core.Test/MoreIpV4Option.cs
+2
-15
WiresharkCompareTests.cs
PcapDotNet/src/PcapDotNet.Core.Test/WiresharkCompareTests.cs
+4
-1
MoreRandomPackets.cs
...Net/src/PcapDotNet.Packets.TestUtils/MoreRandomPackets.cs
+6
-6
IpV4Option.cs
PcapDotNet/src/PcapDotNet.Packets/IpV4/IpV4Option.cs
+1
-1
IpV4OptionBasicSecurity.cs
...et/src/PcapDotNet.Packets/IpV4/IpV4OptionBasicSecurity.cs
+7
-7
IpV4OptionComplex.cs
PcapDotNet/src/PcapDotNet.Packets/IpV4/IpV4OptionComplex.cs
+2
-2
IpV4OptionType.cs
PcapDotNet/src/PcapDotNet.Packets/IpV4/IpV4OptionType.cs
+1
-1
PcapDotNet.Packets.csproj
PcapDotNet/src/PcapDotNet.Packets/PcapDotNet.Packets.csproj
+1
-1
No files found.
PcapDotNet/src/PcapDotNet.Core.Test/MoreIpV4Option.cs
View file @
04f41c99
...
...
@@ -16,7 +16,7 @@ namespace PcapDotNet.Core.Test
case
IpV4OptionType
.
NoOperation
:
return
"NOP"
;
case
IpV4OptionType
.
Security
:
case
IpV4OptionType
.
Basic
Security
:
return
"Security:"
;
case
IpV4OptionType
.
LooseSourceRouting
:
...
...
@@ -48,20 +48,6 @@ namespace PcapDotNet.Core.Test
case
IpV4OptionType
.
StreamIdentifier
:
break
;
case
IpV4OptionType
.
Security
:
IpV4OptionSecurity
securityOption
=
(
IpV4OptionSecurity
)
option
;
switch
(
securityOption
.
ClassificationLevel
)
{
default
:
yield
return
"Security: "
+
securityOption
.
ClassificationLevel
;
break
;
}
// yield return "Compartments: " + securityOption.Compartments;
// yield return "Handling restrictions: ";
// yield return "Transmission control code: ";
break
;
case
IpV4OptionType
.
LooseSourceRouting
:
case
IpV4OptionType
.
StrictSourceRouting
:
case
IpV4OptionType
.
RecordRoute
:
...
...
@@ -112,6 +98,7 @@ namespace PcapDotNet.Core.Test
}
break
;
case
IpV4OptionType
.
BasicSecurity
:
default
:
throw
new
InvalidOperationException
(
"Illegal option type "
+
option
.
OptionType
);
}
...
...
PcapDotNet/src/PcapDotNet.Core.Test/WiresharkCompareTests.cs
View file @
04f41c99
...
...
@@ -308,8 +308,11 @@ namespace PcapDotNet.Core.Test
break
;
}
IpV4Option
option
=
options
[
currentOptionIndex
++];
if
(
option
.
OptionType
==
IpV4OptionType
.
Security
)
if
(
option
.
OptionType
==
IpV4OptionType
.
BasicSecurity
)
{
Assert
.
IsTrue
(
field
.
Show
().
StartsWith
(
"Security"
));
continue
;
// Wireshark doesn't support
}
field
.
AssertShow
(
option
.
GetWiresharkString
());
var
optionShows
=
from
f
in
field
.
Fields
()
select
f
.
Show
();
...
...
PcapDotNet/src/PcapDotNet.Packets.TestUtils/MoreRandomPackets.cs
View file @
04f41c99
...
...
@@ -92,8 +92,8 @@ namespace PcapDotNet.Packets.TestUtils
throw
new
ArgumentOutOfRangeException
(
"maximumOptionLength"
,
maximumOptionLength
,
"option length must be positive"
);
List
<
IpV4OptionType
>
impossibleOptionTypes
=
new
List
<
IpV4OptionType
>();
if
(
maximumOptionLength
<
IpV4OptionSecurity
.
OptionMinimumLength
)
impossibleOptionTypes
.
Add
(
IpV4OptionType
.
Security
);
if
(
maximumOptionLength
<
IpV4Option
Basic
Security
.
OptionMinimumLength
)
impossibleOptionTypes
.
Add
(
IpV4OptionType
.
Basic
Security
);
if
(
maximumOptionLength
<
IpV4OptionRoute
.
OptionMinimumLength
)
{
impossibleOptionTypes
.
Add
(
IpV4OptionType
.
LooseSourceRouting
);
...
...
@@ -113,14 +113,14 @@ namespace PcapDotNet.Packets.TestUtils
case
IpV4OptionType
.
NoOperation
:
return
IpV4Option
.
Nop
;
case
IpV4OptionType
.
Security
:
case
IpV4OptionType
.
Basic
Security
:
IpV4OptionSecurityProtectionAuthority
protectionAuthority
=
IpV4OptionSecurityProtectionAuthority
.
None
;
int
protectionAuthorityLength
=
random
.
Next
(
maximumOptionLength
-
IpV4OptionSecurity
.
OptionMinimumLength
);
int
protectionAuthorityLength
=
random
.
Next
(
maximumOptionLength
-
IpV4Option
Basic
Security
.
OptionMinimumLength
);
if
(
protectionAuthorityLength
>
0
)
protectionAuthority
=
random
.
NextEnum
<
IpV4OptionSecurityProtectionAuthority
>();
return
new
IpV4OptionSecurity
(
random
.
NextEnum
<
IpV4OptionSecurityClassificationLevel
>(),
protectionAuthority
,
(
byte
)(
IpV4OptionSecurity
.
OptionMinimumLength
+
protectionAuthorityLength
));
return
new
IpV4Option
Basic
Security
(
random
.
NextEnum
<
IpV4OptionSecurityClassificationLevel
>(),
protectionAuthority
,
(
byte
)(
IpV4Option
Basic
Security
.
OptionMinimumLength
+
protectionAuthorityLength
));
case
IpV4OptionType
.
LooseSourceRouting
:
case
IpV4OptionType
.
StrictSourceRouting
:
...
...
PcapDotNet/src/PcapDotNet.Packets/IpV4/IpV4Option.cs
View file @
04f41c99
...
...
@@ -109,7 +109,7 @@ namespace PcapDotNet.Packets.IpV4
case
IpV4OptionType
.
NoOperation
:
return
Nop
;
case
IpV4OptionType
.
Security
:
case
IpV4OptionType
.
Basic
Security
:
case
IpV4OptionType
.
LooseSourceRouting
:
case
IpV4OptionType
.
StrictSourceRouting
:
case
IpV4OptionType
.
RecordRoute
:
...
...
PcapDotNet/src/PcapDotNet.Packets/IpV4/IpV4OptionSecurity.cs
→
PcapDotNet/src/PcapDotNet.Packets/IpV4/IpV4Option
Basic
Security.cs
View file @
04f41c99
...
...
@@ -31,7 +31,7 @@ namespace PcapDotNet.Packets.IpV4
/// LEVEL AUTHORITY
/// FLAGS
/// </summary>
public
class
IpV4Option
Security
:
IpV4OptionComplex
,
IEquatable
<
IpV4Option
Security
>
public
class
IpV4Option
BasicSecurity
:
IpV4OptionComplex
,
IEquatable
<
IpV4OptionBasic
Security
>
{
/// <summary>
/// The minimum number of bytes this option take.
...
...
@@ -57,8 +57,8 @@ namespace PcapDotNet.Packets.IpV4
/// <param name="length">
/// The number of bytes this option will take.
/// </param>
public
IpV4OptionSecurity
(
IpV4OptionSecurityClassificationLevel
classificationLevel
,
IpV4OptionSecurityProtectionAuthority
protectionAuthority
,
byte
length
)
:
base
(
IpV4OptionType
.
Security
)
public
IpV4Option
Basic
Security
(
IpV4OptionSecurityClassificationLevel
classificationLevel
,
IpV4OptionSecurityProtectionAuthority
protectionAuthority
,
byte
length
)
:
base
(
IpV4OptionType
.
Basic
Security
)
{
if
(
length
<
OptionMinimumLength
)
throw
new
ArgumentOutOfRangeException
(
"length"
,
length
,
"Minimum option length is "
+
OptionMinimumLength
);
...
...
@@ -112,7 +112,7 @@ namespace PcapDotNet.Packets.IpV4
/// <summary>
/// Two security options are equal iff they have the exam same field values.
/// </summary>
public
bool
Equals
(
IpV4OptionSecurity
other
)
public
bool
Equals
(
IpV4Option
Basic
Security
other
)
{
if
(
other
==
null
)
return
false
;
...
...
@@ -127,7 +127,7 @@ namespace PcapDotNet.Packets.IpV4
/// </summary>
public
override
bool
Equals
(
IpV4Option
other
)
{
return
Equals
(
other
as
IpV4OptionSecurity
);
return
Equals
(
other
as
IpV4Option
Basic
Security
);
}
/// <summary>
...
...
@@ -141,7 +141,7 @@ namespace PcapDotNet.Packets.IpV4
((((
byte
)
ClassificationLevel
)
<<
16
)
|
(((
byte
)
ProtectionAuthority
)
<<
8
)
|
Length
).
GetHashCode
();
}
internal
static
IpV4OptionSecurity
ReadOptionSecurity
(
byte
[]
buffer
,
ref
int
offset
,
byte
valueLength
)
internal
static
IpV4Option
Basic
Security
ReadOptionSecurity
(
byte
[]
buffer
,
ref
int
offset
,
byte
valueLength
)
{
if
(
valueLength
<
OptionValueMinimumLength
)
return
null
;
...
...
@@ -173,7 +173,7 @@ namespace PcapDotNet.Packets.IpV4
}
offset
+=
protectionAuthorityLength
;
return
new
IpV4OptionSecurity
(
classificationLevel
,
protectionAuthority
,
(
byte
)(
OptionMinimumLength
+
protectionAuthorityLength
));
return
new
IpV4Option
Basic
Security
(
classificationLevel
,
protectionAuthority
,
(
byte
)(
OptionMinimumLength
+
protectionAuthorityLength
));
}
internal
override
void
Write
(
byte
[]
buffer
,
ref
int
offset
)
...
...
PcapDotNet/src/PcapDotNet.Packets/IpV4/IpV4OptionComplex.cs
View file @
04f41c99
...
...
@@ -23,8 +23,8 @@ namespace PcapDotNet.Packets.IpV4
switch
(
optionType
)
{
case
IpV4OptionType
.
Security
:
return
IpV4OptionSecurity
.
ReadOptionSecurity
(
buffer
,
ref
offset
,
optionValueLength
);
case
IpV4OptionType
.
Basic
Security
:
return
IpV4Option
Basic
Security
.
ReadOptionSecurity
(
buffer
,
ref
offset
,
optionValueLength
);
case
IpV4OptionType
.
LooseSourceRouting
:
return
IpV4OptionLooseSourceRouting
.
ReadOptionLooseSourceRouting
(
buffer
,
ref
offset
,
optionValueLength
);
...
...
PcapDotNet/src/PcapDotNet.Packets/IpV4/IpV4OptionType.cs
View file @
04f41c99
...
...
@@ -34,7 +34,7 @@ namespace PcapDotNet.Packets.IpV4
/// DoD Basic Security:
/// Used to carry the classification level and protection authority flags.
/// </summary>
Security
=
130
,
Basic
Security
=
130
,
/// <summary>
/// Loose Source Routing.
...
...
PcapDotNet/src/PcapDotNet.Packets/PcapDotNet.Packets.csproj
View file @
04f41c99
...
...
@@ -80,7 +80,7 @@
<Compile
Include=
"IpV4\IpV4OptionRecordRoute.cs"
/>
<Compile
Include=
"IpV4\IpV4OptionRoute.cs"
/>
<Compile
Include=
"IpV4\IpV4Options.cs"
/>
<Compile
Include=
"IpV4\IpV4OptionSecurity.cs"
/>
<Compile
Include=
"IpV4\IpV4Option
Basic
Security.cs"
/>
<Compile
Include=
"IpV4\IpV4OptionSecurityClassificationLevel.cs"
/>
<Compile
Include=
"IpV4\IpV4OptionStreamIdentifier.cs"
/>
<Compile
Include=
"IpV4\IpV4OptionStrictSourceRouting.cs"
/>
...
...
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