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
9cd5f91f
Commit
9cd5f91f
authored
Aug 22, 2009
by
Brickner_cp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
TCP
parent
f9bfb007
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
110 additions
and
1 deletion
+110
-1
MoreTcpOption.cs
PcapDotNet/src/PcapDotNet.Core.Test/MoreTcpOption.cs
+4
-0
MoreRandomPackets.cs
...Net/src/PcapDotNet.Packets.TestUtils/MoreRandomPackets.cs
+5
-1
PcapDotNet.Packets.csproj
PcapDotNet/src/PcapDotNet.Packets/PcapDotNet.Packets.csproj
+1
-0
TcpOptionMd5Signature.cs
...src/PcapDotNet.Packets/Transport/TcpOptionMd5Signature.cs
+100
-0
No files found.
PcapDotNet/src/PcapDotNet.Core.Test/MoreTcpOption.cs
View file @
9cd5f91f
...
...
@@ -59,6 +59,9 @@ namespace PcapDotNet.Core.Test
case
TcpOptionType
.
AlternateChecksumData
:
return
"Unknown (0x0f) ("
+
option
.
Length
+
" bytes)"
;
case
TcpOptionType
.
Md5Signature
:
return
"TCP MD5 signature"
;
case
(
TcpOptionType
)
20
:
return
"SCPS capabilities"
+
(
option
.
Length
>=
4
?
string
.
Empty
...
...
@@ -105,6 +108,7 @@ namespace PcapDotNet.Core.Test
case
TcpOptionType
.
ConnectionCountEcho
:
case
TcpOptionType
.
AlternateChecksumRequest
:
case
TcpOptionType
.
AlternateChecksumData
:
case
TcpOptionType
.
Md5Signature
:
break
;
case
TcpOptionType
.
SelectiveAcknowledgment
:
...
...
PcapDotNet/src/PcapDotNet.Packets.TestUtils/MoreRandomPackets.cs
View file @
9cd5f91f
...
...
@@ -303,8 +303,9 @@ namespace PcapDotNet.Packets.TestUtils
impossibleOptionTypes
.
Add
(
TcpOptionType
.
AlternateChecksumRequest
);
if
(
maximumOptionLength
<
TcpOptionAlternateChecksumData
.
OptionMinimumLength
)
impossibleOptionTypes
.
Add
(
TcpOptionType
.
AlternateChecksumData
);
if
(
maximumOptionLength
<
TcpOptionMd5Signature
.
OptionLength
)
impossibleOptionTypes
.
Add
(
TcpOptionType
.
Md5Signature
);
impossibleOptionTypes
.
Add
(
TcpOptionType
.
Md5Signature
);
impossibleOptionTypes
.
Add
(
TcpOptionType
.
QuickStartResponse
);
impossibleOptionTypes
.
Add
(
TcpOptionType
.
UserTimeout
);
...
...
@@ -363,6 +364,9 @@ namespace PcapDotNet.Packets.TestUtils
case
TcpOptionType
.
AlternateChecksumData
:
return
new
TcpOptionAlternateChecksumData
(
random
.
NextBytes
(
random
.
Next
(
maximumOptionLength
-
TcpOptionAlternateChecksumData
.
OptionMinimumLength
+
1
)));
case
TcpOptionType
.
Md5Signature
:
return
new
TcpOptionMd5Signature
(
random
.
NextBytes
(
TcpOptionMd5Signature
.
OptionValueLength
));
default
:
throw
new
InvalidOperationException
(
"optionType = "
+
optionType
);
}
...
...
PcapDotNet/src/PcapDotNet.Packets/PcapDotNet.Packets.csproj
View file @
9cd5f91f
...
...
@@ -122,6 +122,7 @@
<Compile
Include=
"Transport\TcpOptionEcho.cs"
/>
<Compile
Include=
"Transport\TcpOptionEchoReply.cs"
/>
<Compile
Include=
"Transport\TcpOptionMaximumSegmentSize.cs"
/>
<Compile
Include=
"Transport\TcpOptionMd5Signature.cs"
/>
<Compile
Include=
"Transport\TcpOptionPartialOrderConnectionPermitted.cs"
/>
<Compile
Include=
"Transport\TcpOptionPartialOrderServiceProfile.cs"
/>
<Compile
Include=
"Transport\TcpOptions.cs"
/>
...
...
PcapDotNet/src/PcapDotNet.Packets/Transport/TcpOptionMd5Signature.cs
0 → 100644
View file @
9cd5f91f
using
System
;
using
System.Collections.Generic
;
using
System.Collections.ObjectModel
;
using
System.Linq
;
namespace
PcapDotNet.Packets.Transport
{
/// <summary>
/// +---------+---------+-------------------+
/// | Kind=19 |Length=18| MD5 digest... |
/// +---------+---------+-------------------+
/// | |
/// +---------------------------------------+
/// | |
/// +---------------------------------------+
/// | |
/// +-------------------+-------------------+
/// | |
/// +-------------------+
///
/// The MD5 digest is always 16 bytes in length, and the option would appear in every segment of a connection.
/// </summary>
[
OptionTypeRegistration
(
typeof
(
TcpOptionType
),
TcpOptionType
.
Md5Signature
)]
public
class
TcpOptionMd5Signature
:
TcpOptionComplex
,
IOptionComplexFactory
,
IEquatable
<
TcpOptionMd5Signature
>
{
/// <summary>
/// The number of bytes this option take.
/// </summary>
public
const
int
OptionLength
=
OptionHeaderLength
+
16
;
public
const
int
OptionValueLength
=
OptionLength
-
OptionHeaderLength
;
public
TcpOptionMd5Signature
(
IList
<
byte
>
data
)
:
base
(
TcpOptionType
.
Md5Signature
)
{
if
(
data
.
Count
!=
OptionValueLength
)
throw
new
ArgumentException
(
"data must be "
+
OptionValueLength
+
" bytes and not "
+
data
.
Count
+
" bytes"
,
"data"
);
Data
=
new
ReadOnlyCollection
<
byte
>(
data
);
}
public
TcpOptionMd5Signature
()
:
this
(
new
byte
[
OptionValueLength
])
{
}
public
ReadOnlyCollection
<
byte
>
Data
{
get
;
private
set
;
}
/// <summary>
/// The number of bytes this option will take.
/// </summary>
public
override
int
Length
{
get
{
return
OptionLength
;
}
}
/// <summary>
/// True iff this option may appear at most once in a datagram.
/// </summary>
public
override
bool
IsAppearsAtMostOnce
{
get
{
return
true
;
}
}
public
bool
Equals
(
TcpOptionMd5Signature
other
)
{
if
(
other
==
null
)
return
false
;
return
Data
.
SequenceEqual
(
other
.
Data
);
}
public
override
bool
Equals
(
TcpOption
other
)
{
return
Equals
(
other
as
TcpOptionMd5Signature
);
}
/// <summary>
/// Tries to read the option from a buffer starting from the option value (after the type and length).
/// </summary>
/// <param name="buffer">The buffer to read the option from.</param>
/// <param name="offset">The offset to the first byte to read the buffer. Will be incremented by the number of bytes read.</param>
/// <param name="valueLength">The number of bytes the option value should take according to the length field that was already read.</param>
/// <returns>On success - the complex option read. On failure - null.</returns>
public
Option
CreateInstance
(
byte
[]
buffer
,
ref
int
offset
,
byte
valueLength
)
{
if
(
valueLength
!=
OptionValueLength
)
return
null
;
byte
[]
data
=
buffer
.
ReadBytes
(
ref
offset
,
OptionValueLength
);
return
new
TcpOptionMd5Signature
(
data
);
}
internal
override
void
Write
(
byte
[]
buffer
,
ref
int
offset
)
{
base
.
Write
(
buffer
,
ref
offset
);
buffer
.
Write
(
ref
offset
,
Data
);
}
}
}
\ 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