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
430c24ac
Commit
430c24ac
authored
Aug 08, 2009
by
Brickner_cp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for quick start IPv4 option.
Fixed IPv4 Header checksum bug.
parent
b4143c20
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
295 additions
and
2 deletions
+295
-2
MoreIpV4Option.cs
PcapDotNet/src/PcapDotNet.Core.Test/MoreIpV4Option.cs
+28
-0
WiresharkCompareTests.cs
PcapDotNet/src/PcapDotNet.Core.Test/WiresharkCompareTests.cs
+1
-1
MoreRandomPackets.cs
...Net/src/PcapDotNet.Packets.TestUtils/MoreRandomPackets.cs
+8
-0
IpV4Datagram.cs
PcapDotNet/src/PcapDotNet.Packets/IpV4/IpV4Datagram.cs
+3
-1
IpV4OptionQuickStart.cs
...otNet/src/PcapDotNet.Packets/IpV4/IpV4OptionQuickStart.cs
+249
-0
IpV4OptionType.cs
PcapDotNet/src/PcapDotNet.Packets/IpV4/IpV4OptionType.cs
+5
-0
PcapDotNet.Packets.csproj
PcapDotNet/src/PcapDotNet.Packets/PcapDotNet.Packets.csproj
+1
-0
No files found.
PcapDotNet/src/PcapDotNet.Core.Test/MoreIpV4Option.cs
View file @
430c24ac
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Text
;
using
PcapDotNet.Packets.IpV4
;
using
PcapDotNet.Packets.IpV4
;
namespace
PcapDotNet.Core.Test
namespace
PcapDotNet.Core.Test
...
@@ -40,6 +41,32 @@ namespace PcapDotNet.Core.Test
...
@@ -40,6 +41,32 @@ namespace PcapDotNet.Core.Test
case
IpV4OptionType
.
RouterAlert
:
case
IpV4OptionType
.
RouterAlert
:
return
"Router Alert: Unknown ("
+
((
IpV4OptionRouterAlert
)
option
).
Value
+
")"
;
return
"Router Alert: Unknown ("
+
((
IpV4OptionRouterAlert
)
option
).
Value
+
")"
;
case
IpV4OptionType
.
QuickStart
:
IpV4OptionQuickStart
quickStart
=
(
IpV4OptionQuickStart
)
option
;
StringBuilder
quickStartWireshark
=
new
StringBuilder
(
"Quick-Start: "
);
if
(
quickStart
.
Function
==
IpV4OptionQuickStartFunction
.
RateRequest
)
quickStartWireshark
.
Append
(
"Rate request"
);
else
quickStartWireshark
.
Append
(
"Rate report"
);
quickStartWireshark
.
Append
(
", "
);
if
(
quickStart
.
RateKbps
==
0
)
quickStartWireshark
.
Append
(
"0 bit/s"
);
else
if
(
quickStart
.
RateKbps
<
1024
)
quickStartWireshark
.
Append
(
quickStart
.
RateKbps
+
" kbit/s"
);
else
if
(
quickStart
.
RateKbps
<
1024
*
1024
)
quickStartWireshark
.
Append
(((
double
)
quickStart
.
RateKbps
/
1000
)
+
" Mbit/s"
);
else
quickStartWireshark
.
Append
(((
double
)
quickStart
.
RateKbps
/
1000000
)
+
" Gbit/s"
);
if
(
quickStart
.
Function
==
IpV4OptionQuickStartFunction
.
RateRequest
)
quickStartWireshark
.
Append
(
", QS TTL "
+
quickStart
.
Ttl
);
return
quickStartWireshark
.
ToString
();
default
:
default
:
throw
new
InvalidOperationException
(
"Illegal option type "
+
option
.
OptionType
);
throw
new
InvalidOperationException
(
"Illegal option type "
+
option
.
OptionType
);
}
}
...
@@ -53,6 +80,7 @@ namespace PcapDotNet.Core.Test
...
@@ -53,6 +80,7 @@ namespace PcapDotNet.Core.Test
case
IpV4OptionType
.
NoOperation
:
case
IpV4OptionType
.
NoOperation
:
case
IpV4OptionType
.
StreamIdentifier
:
case
IpV4OptionType
.
StreamIdentifier
:
case
IpV4OptionType
.
RouterAlert
:
case
IpV4OptionType
.
RouterAlert
:
case
IpV4OptionType
.
QuickStart
:
break
;
break
;
case
IpV4OptionType
.
LooseSourceRouting
:
case
IpV4OptionType
.
LooseSourceRouting
:
...
...
PcapDotNet/src/PcapDotNet.Core.Test/WiresharkCompareTests.cs
View file @
430c24ac
...
@@ -349,7 +349,7 @@ namespace PcapDotNet.Core.Test
...
@@ -349,7 +349,7 @@ namespace PcapDotNet.Core.Test
DateTime
fieldTimestamp
=
fieldShow
[
4
]
==
' '
DateTime
fieldTimestamp
=
fieldShow
[
4
]
==
' '
?
DateTime
.
ParseExact
(
fieldShow
,
"MMM d, yyyy HH:mm:ss.fffffff"
,
CultureInfo
.
InvariantCulture
)
?
DateTime
.
ParseExact
(
fieldShow
,
"MMM d, yyyy HH:mm:ss.fffffff"
,
CultureInfo
.
InvariantCulture
)
:
DateTime
.
ParseExact
(
fieldShow
,
"MMM dd, yyyy HH:mm:ss.fffffff"
,
CultureInfo
.
InvariantCulture
);
:
DateTime
.
ParseExact
(
fieldShow
,
"MMM dd, yyyy HH:mm:ss.fffffff"
,
CultureInfo
.
InvariantCulture
);
MoreAssert
.
IsInRange
(
fieldTimestamp
.
AddSeconds
(-
1
),
fieldTimestamp
.
AddSeconds
(
1
),
packet
.
Timestamp
);
MoreAssert
.
IsInRange
(
fieldTimestamp
.
AddSeconds
(-
2
),
fieldTimestamp
.
AddSeconds
(
2
),
packet
.
Timestamp
);
break
;
break
;
case
"frame.len"
:
case
"frame.len"
:
...
...
PcapDotNet/src/PcapDotNet.Packets.TestUtils/MoreRandomPackets.cs
View file @
430c24ac
...
@@ -106,6 +106,8 @@ namespace PcapDotNet.Packets.TestUtils
...
@@ -106,6 +106,8 @@ namespace PcapDotNet.Packets.TestUtils
impossibleOptionTypes
.
Add
(
IpV4OptionType
.
InternetTimestamp
);
impossibleOptionTypes
.
Add
(
IpV4OptionType
.
InternetTimestamp
);
if
(
maximumOptionLength
<
IpV4OptionTraceRoute
.
OptionLength
)
if
(
maximumOptionLength
<
IpV4OptionTraceRoute
.
OptionLength
)
impossibleOptionTypes
.
Add
(
IpV4OptionType
.
TraceRoute
);
impossibleOptionTypes
.
Add
(
IpV4OptionType
.
TraceRoute
);
if
(
maximumOptionLength
<
IpV4OptionQuickStart
.
OptionLength
)
impossibleOptionTypes
.
Add
(
IpV4OptionType
.
QuickStart
);
IpV4OptionType
optionType
=
random
.
NextEnum
<
IpV4OptionType
>(
impossibleOptionTypes
);
IpV4OptionType
optionType
=
random
.
NextEnum
<
IpV4OptionType
>(
impossibleOptionTypes
);
switch
(
optionType
)
switch
(
optionType
)
...
@@ -193,6 +195,12 @@ namespace PcapDotNet.Packets.TestUtils
...
@@ -193,6 +195,12 @@ namespace PcapDotNet.Packets.TestUtils
case
IpV4OptionType
.
RouterAlert
:
case
IpV4OptionType
.
RouterAlert
:
return
new
IpV4OptionRouterAlert
(
random
.
NextUShort
());
return
new
IpV4OptionRouterAlert
(
random
.
NextUShort
());
case
IpV4OptionType
.
QuickStart
:
return
new
IpV4OptionQuickStart
(
random
.
NextEnum
<
IpV4OptionQuickStartFunction
>(),
random
.
NextByte
(
IpV4OptionQuickStart
.
RateMaximumValue
+
1
),
random
.
NextByte
(),
random
.
NextUInt
()
&
0xFFFFFFFC
);
default
:
default
:
throw
new
InvalidOperationException
(
"optionType = "
+
optionType
);
throw
new
InvalidOperationException
(
"optionType = "
+
optionType
);
}
}
...
...
PcapDotNet/src/PcapDotNet.Packets/IpV4/IpV4Datagram.cs
View file @
430c24ac
...
@@ -254,7 +254,7 @@ namespace PcapDotNet.Packets.IpV4
...
@@ -254,7 +254,7 @@ namespace PcapDotNet.Packets.IpV4
private
ushort
CalculateHeaderChecksum
()
private
ushort
CalculateHeaderChecksum
()
{
{
uint
sum
=
Sum16Bits
(
Buffer
,
StartOffset
,
Math
.
Min
(
Offset
.
HeaderChecksum
,
Length
))
+
uint
sum
=
Sum16Bits
(
Buffer
,
StartOffset
,
Math
.
Min
(
Offset
.
HeaderChecksum
,
Length
))
+
Sum16Bits
(
Buffer
,
StartOffset
+
Offset
.
HeaderChecksum
+
2
,
Math
.
Min
(
HeaderLength
,
Length
)
-
Offset
.
HeaderChecksum
-
2
);
Sum16Bits
(
Buffer
,
StartOffset
+
Offset
.
HeaderChecksum
+
2
,
RealHeaderLength
-
Offset
.
HeaderChecksum
-
2
);
return
Sum16BitsToChecksum
(
sum
);
return
Sum16BitsToChecksum
(
sum
);
}
}
...
@@ -275,6 +275,8 @@ namespace PcapDotNet.Packets.IpV4
...
@@ -275,6 +275,8 @@ namespace PcapDotNet.Packets.IpV4
uint
sum
=
0
;
uint
sum
=
0
;
while
(
offset
<
endOffset
-
1
)
while
(
offset
<
endOffset
-
1
)
sum
+=
buffer
.
ReadUShort
(
ref
offset
,
Endianity
.
Big
);
sum
+=
buffer
.
ReadUShort
(
ref
offset
,
Endianity
.
Big
);
if
(
offset
<
endOffset
)
sum
+=
buffer
[
offset
];
return
sum
;
return
sum
;
}
}
...
...
PcapDotNet/src/PcapDotNet.Packets/IpV4/IpV4OptionQuickStart.cs
0 → 100644
View file @
430c24ac
This diff is collapsed.
Click to expand it.
PcapDotNet/src/PcapDotNet.Packets/IpV4/IpV4OptionType.cs
View file @
430c24ac
...
@@ -33,6 +33,11 @@ namespace PcapDotNet.Packets.IpV4
...
@@ -33,6 +33,11 @@ namespace PcapDotNet.Packets.IpV4
/// </summary>
/// </summary>
NoOperation
=
1
,
NoOperation
=
1
,
/// <summary>
/// Quick Start (QS). RFC 4782.
/// </summary>
QuickStart
=
25
,
/// <summary>
/// <summary>
/// Traceroute Using an IP Option.
/// Traceroute Using an IP Option.
/// RFC 1393.
/// RFC 1393.
...
...
PcapDotNet/src/PcapDotNet.Packets/PcapDotNet.Packets.csproj
View file @
430c24ac
...
@@ -75,6 +75,7 @@
...
@@ -75,6 +75,7 @@
<Compile
Include=
"IpV4\IpV4Option.cs"
/>
<Compile
Include=
"IpV4\IpV4Option.cs"
/>
<Compile
Include=
"IpV4\IpV4OptionComplex.cs"
/>
<Compile
Include=
"IpV4\IpV4OptionComplex.cs"
/>
<Compile
Include=
"IpV4\IpV4OptionLooseSourceRouting.cs"
/>
<Compile
Include=
"IpV4\IpV4OptionLooseSourceRouting.cs"
/>
<Compile
Include=
"IpV4\IpV4OptionQuickStart.cs"
/>
<Compile
Include=
"IpV4\IpV4OptionRouterAlert.cs"
/>
<Compile
Include=
"IpV4\IpV4OptionRouterAlert.cs"
/>
<Compile
Include=
"IpV4\IpV4OptionSecurityProtectionAuthority.cs"
/>
<Compile
Include=
"IpV4\IpV4OptionSecurityProtectionAuthority.cs"
/>
<Compile
Include=
"IpV4\IpV4OptionSimple.cs"
/>
<Compile
Include=
"IpV4\IpV4OptionSimple.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