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
77749cd4
Commit
77749cd4
authored
Aug 01, 2009
by
Brickner_cp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IpV4
parent
3fcd9057
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
52 additions
and
29 deletions
+52
-29
LivePacketDeviceTests.cs
PcapDotNet/src/PcapDotNet.Core.Test/LivePacketDeviceTests.cs
+1
-1
IpV4Tests.cs
PcapDotNet/src/PcapDotNet.Packets.Test/IpV4Tests.cs
+1
-1
MoreRandomPackets.cs
...Net/src/PcapDotNet.Packets.TestUtils/MoreRandomPackets.cs
+6
-6
IpV4Fragmentation.cs
PcapDotNet/src/PcapDotNet.Packets/IpV4/IpV4Fragmentation.cs
+5
-0
IpV4OptionRoute.cs
PcapDotNet/src/PcapDotNet.Packets/IpV4/IpV4OptionRoute.cs
+3
-0
IpV4OptionTimestamp.cs
...DotNet/src/PcapDotNet.Packets/IpV4/IpV4OptionTimestamp.cs
+7
-5
IpV4OptionTimestampAndAddress.cs
.../PcapDotNet.Packets/IpV4/IpV4OptionTimestampAndAddress.cs
+14
-8
IpV4OptionTimestampOnly.cs
...et/src/PcapDotNet.Packets/IpV4/IpV4OptionTimestampOnly.cs
+6
-6
IpV4Options.cs
PcapDotNet/src/PcapDotNet.Packets/IpV4/IpV4Options.cs
+3
-1
MoreRandom.cs
PcapDotNet/src/PcapDotNet.TestUtils/MoreRandom.cs
+6
-1
No files found.
PcapDotNet/src/PcapDotNet.Core.Test/LivePacketDeviceTests.cs
View file @
77749cd4
...
@@ -734,7 +734,7 @@ namespace PcapDotNet.Core.Test
...
@@ -734,7 +734,7 @@ namespace PcapDotNet.Core.Test
MoreAssert
.
IsSmallerOrEqual
<
uint
>(
1
,
totalStatistics
.
PacketsCaptured
,
"PacketsCaptured"
);
MoreAssert
.
IsSmallerOrEqual
<
uint
>(
1
,
totalStatistics
.
PacketsCaptured
,
"PacketsCaptured"
);
Assert
.
AreEqual
<
uint
>(
0
,
totalStatistics
.
PacketsDroppedByDriver
,
"PacketsDroppedByDriver"
);
Assert
.
AreEqual
<
uint
>(
0
,
totalStatistics
.
PacketsDroppedByDriver
,
"PacketsDroppedByDriver"
);
Assert
.
AreEqual
<
uint
>(
0
,
totalStatistics
.
PacketsDroppedByInterface
,
"PacketsDroppedByInterface"
);
Assert
.
AreEqual
<
uint
>(
0
,
totalStatistics
.
PacketsDroppedByInterface
,
"PacketsDroppedByInterface"
);
Assert
.
AreEqual
<
uint
>(
0
,
totalStatistics
.
PacketsReceived
,
"PacketsReceived"
);
MoreAssert
.
IsSmallerOrEqual
<
uint
>(
1
,
totalStatistics
.
PacketsReceived
,
"PacketsReceived"
);
Assert
.
IsNotNull
(
totalStatistics
.
ToString
());
Assert
.
IsNotNull
(
totalStatistics
.
ToString
());
communicator
.
SetKernelBufferSize
(
2
*
1024
*
1024
);
// 2 MB instead of 1
communicator
.
SetKernelBufferSize
(
2
*
1024
*
1024
);
// 2 MB instead of 1
communicator
.
SetKernelMinimumBytesToCopy
(
10
);
// 10 bytes minimum to copy
communicator
.
SetKernelMinimumBytesToCopy
(
10
);
// 10 bytes minimum to copy
...
...
PcapDotNet/src/PcapDotNet.Packets.Test/IpV4Tests.cs
View file @
77749cd4
...
@@ -108,7 +108,7 @@ namespace PcapDotNet.Packets.Test
...
@@ -108,7 +108,7 @@ namespace PcapDotNet.Packets.Test
ushort
ipV4Identification
=
random
.
NextUShort
();
ushort
ipV4Identification
=
random
.
NextUShort
();
byte
ipV4Ttl
=
random
.
NextByte
();
byte
ipV4Ttl
=
random
.
NextByte
();
IpV4FragmentationOptions
ipV4FragmentationOptions
=
random
.
NextEnum
<
IpV4FragmentationOptions
>();
IpV4FragmentationOptions
ipV4FragmentationOptions
=
random
.
NextEnum
<
IpV4FragmentationOptions
>();
ushort
ipV4FragmentationOffset
=
random
.
NextUShort
(
);
ushort
ipV4FragmentationOffset
=
(
ushort
)(
random
.
NextUShort
(
ushort
.
MaxValue
/
8
)
*
8
);
IpV4Fragmentation
ipV4Fragmentation
=
new
IpV4Fragmentation
(
ipV4FragmentationOptions
,
ipV4FragmentationOffset
);
IpV4Fragmentation
ipV4Fragmentation
=
new
IpV4Fragmentation
(
ipV4FragmentationOptions
,
ipV4FragmentationOffset
);
IpV4Protocol
ipV4Protocol
=
random
.
NextEnum
<
IpV4Protocol
>();
IpV4Protocol
ipV4Protocol
=
random
.
NextEnum
<
IpV4Protocol
>();
IpV4Address
ipV4Source
=
new
IpV4Address
(
random
.
NextUInt
());
IpV4Address
ipV4Source
=
new
IpV4Address
(
random
.
NextUInt
());
...
...
PcapDotNet/src/PcapDotNet.Packets.TestUtils/MoreRandomPackets.cs
View file @
77749cd4
...
@@ -70,7 +70,7 @@ namespace PcapDotNet.Packets.TestUtils
...
@@ -70,7 +70,7 @@ namespace PcapDotNet.Packets.TestUtils
public
static
IpV4Options
NextIpV4Options
(
this
Random
random
)
public
static
IpV4Options
NextIpV4Options
(
this
Random
random
)
{
{
int
optionsLength
=
random
.
Next
(
IpV4Options
.
MaximumLength
)
/
4
*
4
;
int
optionsLength
=
random
.
Next
(
IpV4Options
.
Maximum
Bytes
Length
)
/
4
*
4
;
List
<
IpV4Option
>
options
=
new
List
<
IpV4Option
>();
List
<
IpV4Option
>
options
=
new
List
<
IpV4Option
>();
while
(
optionsLength
>
0
)
while
(
optionsLength
>
0
)
{
{
...
@@ -135,7 +135,7 @@ namespace PcapDotNet.Packets.TestUtils
...
@@ -135,7 +135,7 @@ namespace PcapDotNet.Packets.TestUtils
break
;
break
;
IpV4OptionTimestampType
timestampType
=
random
.
NextEnum
<
IpV4OptionTimestampType
>();
IpV4OptionTimestampType
timestampType
=
random
.
NextEnum
<
IpV4OptionTimestampType
>();
byte
overflow
=
random
.
NextByte
(
16
);
byte
overflow
=
random
.
NextByte
(
IpV4OptionTimestamp
.
OverflowMaxValue
+
1
);
byte
pointedIndex
;
byte
pointedIndex
;
if
(
random
.
NextBool
())
if
(
random
.
NextBool
())
pointedIndex
=
random
.
NextByte
(
IpV4OptionTimestamp
.
PointedIndexMaxValue
+
1
);
pointedIndex
=
random
.
NextByte
(
IpV4OptionTimestamp
.
PointedIndexMaxValue
+
1
);
...
@@ -146,17 +146,17 @@ namespace PcapDotNet.Packets.TestUtils
...
@@ -146,17 +146,17 @@ namespace PcapDotNet.Packets.TestUtils
{
{
case
IpV4OptionTimestampType
.
TimestampOnly
:
case
IpV4OptionTimestampType
.
TimestampOnly
:
int
numTimestamps
=
random
.
Next
((
optionsLength
-
IpV4OptionTimestamp
.
OptionMinimumLength
)
/
4
+
1
);
int
numTimestamps
=
random
.
Next
((
optionsLength
-
IpV4OptionTimestamp
.
OptionMinimumLength
)
/
4
+
1
);
TimeSpan
[]
timestamps
=
new
TimeSpan
[
numTimestamps
];
uint
[]
timestamps
=
new
uint
[
numTimestamps
];
for
(
int
i
=
0
;
i
!=
numTimestamps
;
++
i
)
for
(
int
i
=
0
;
i
!=
numTimestamps
;
++
i
)
timestamps
[
i
]
=
TimeSpan
.
FromMilliseconds
((
uint
)
random
.
NextDateTime
().
TimeOfDay
.
TotalMilliseconds
);
timestamps
[
i
]
=
random
.
NextUInt
(
);
option
=
new
IpV4OptionTimestampOnly
(
overflow
,
pointedIndex
,
timestamps
);
option
=
new
IpV4OptionTimestampOnly
(
overflow
,
pointedIndex
,
timestamps
);
break
;
break
;
case
IpV4OptionTimestampType
.
AddressAndTimestamp
:
case
IpV4OptionTimestampType
.
AddressAndTimestamp
:
int
numPairs
=
random
.
Next
((
optionsLength
-
IpV4OptionTimestamp
.
OptionMinimumLength
)
/
8
+
1
);
int
numPairs
=
random
.
Next
((
optionsLength
-
IpV4OptionTimestamp
.
OptionMinimumLength
)
/
8
+
1
);
KeyValuePair
<
IpV4Address
,
TimeSpan
>[]
pairs
=
new
KeyValuePair
<
IpV4Address
,
TimeSpan
>[
numPairs
];
KeyValuePair
<
IpV4Address
,
uint
>[]
pairs
=
new
KeyValuePair
<
IpV4Address
,
uint
>[
numPairs
];
for
(
int
i
=
0
;
i
!=
numPairs
;
++
i
)
for
(
int
i
=
0
;
i
!=
numPairs
;
++
i
)
pairs
[
i
]
=
new
KeyValuePair
<
IpV4Address
,
TimeSpan
>(
random
.
NextIpV4Address
(),
TimeSpan
.
FromMilliseconds
((
uint
)
random
.
NextDateTime
().
TimeOfDay
.
TotalMilliseconds
));
pairs
[
i
]
=
new
KeyValuePair
<
IpV4Address
,
uint
>(
random
.
NextIpV4Address
(),
random
.
NextUInt
(
));
option
=
new
IpV4OptionTimestampAndAddress
(
timestampType
,
overflow
,
pointedIndex
,
pairs
);
option
=
new
IpV4OptionTimestampAndAddress
(
timestampType
,
overflow
,
pointedIndex
,
pairs
);
break
;
break
;
...
...
PcapDotNet/src/PcapDotNet.Packets/IpV4/IpV4Fragmentation.cs
View file @
77749cd4
...
@@ -12,6 +12,11 @@ namespace PcapDotNet.Packets
...
@@ -12,6 +12,11 @@ namespace PcapDotNet.Packets
public
IpV4Fragmentation
(
IpV4FragmentationOptions
options
,
ushort
offset
)
public
IpV4Fragmentation
(
IpV4FragmentationOptions
options
,
ushort
offset
)
:
this
((
ushort
)((
ushort
)
options
|
(
offset
/
8
)))
:
this
((
ushort
)((
ushort
)
options
|
(
offset
/
8
)))
{
{
if
(
offset
%
8
!=
0
)
throw
new
ArgumentException
(
"offset must divide by 8"
,
"offset"
);
if
(((
ushort
)
options
&
0x1FFF
)
!=
0
)
throw
new
ArgumentException
(
"invalid options "
+
options
);
}
}
public
IpV4FragmentationOptions
Options
public
IpV4FragmentationOptions
Options
...
...
PcapDotNet/src/PcapDotNet.Packets/IpV4/IpV4OptionRoute.cs
View file @
77749cd4
...
@@ -84,6 +84,9 @@ namespace PcapDotNet.Packets
...
@@ -84,6 +84,9 @@ namespace PcapDotNet.Packets
protected
IpV4OptionRoute
(
IpV4OptionType
optionType
,
IpV4Address
[]
addresses
,
byte
pointedAddressIndex
)
protected
IpV4OptionRoute
(
IpV4OptionType
optionType
,
IpV4Address
[]
addresses
,
byte
pointedAddressIndex
)
:
base
(
optionType
)
:
base
(
optionType
)
{
{
if
(
pointedAddressIndex
>
PointedAddressIndexMaxValue
)
throw
new
ArgumentOutOfRangeException
(
"pointedAddressIndex"
,
pointedAddressIndex
,
"Maximum value is "
+
PointedAddressIndexMaxValue
);
_addresses
=
addresses
;
_addresses
=
addresses
;
_pointedAddressIndex
=
pointedAddressIndex
;
_pointedAddressIndex
=
pointedAddressIndex
;
}
}
...
...
PcapDotNet/src/PcapDotNet.Packets/IpV4/IpV4OptionTimestamp.cs
View file @
77749cd4
...
@@ -6,6 +6,7 @@ namespace PcapDotNet.Packets
...
@@ -6,6 +6,7 @@ namespace PcapDotNet.Packets
{
{
public
const
int
OptionMinimumLength
=
4
;
public
const
int
OptionMinimumLength
=
4
;
public
const
int
OptionValueMinimumLength
=
OptionMinimumLength
-
OptionHeaderLength
;
public
const
int
OptionValueMinimumLength
=
OptionMinimumLength
-
OptionHeaderLength
;
public
const
int
OverflowMaxValue
=
15
;
public
const
int
PointedIndexMaxValue
=
byte
.
MaxValue
/
4
-
1
;
public
const
int
PointedIndexMaxValue
=
byte
.
MaxValue
/
4
-
1
;
public
IpV4OptionTimestampType
TimestampType
public
IpV4OptionTimestampType
TimestampType
...
@@ -105,6 +106,12 @@ namespace PcapDotNet.Packets
...
@@ -105,6 +106,12 @@ namespace PcapDotNet.Packets
protected
IpV4OptionTimestamp
(
IpV4OptionTimestampType
timestampType
,
byte
overflow
,
byte
pointedIndex
)
protected
IpV4OptionTimestamp
(
IpV4OptionTimestampType
timestampType
,
byte
overflow
,
byte
pointedIndex
)
:
base
(
IpV4OptionType
.
InternetTimestamp
)
:
base
(
IpV4OptionType
.
InternetTimestamp
)
{
{
if
(
overflow
>
OverflowMaxValue
)
throw
new
ArgumentOutOfRangeException
(
"overflow"
,
overflow
,
"Maximum value is "
+
OverflowMaxValue
);
if
(
pointedIndex
>
PointedIndexMaxValue
)
throw
new
ArgumentOutOfRangeException
(
"pointedIndex"
,
pointedIndex
,
"Maximum value is "
+
PointedIndexMaxValue
);
_timestampType
=
timestampType
;
_timestampType
=
timestampType
;
_overflow
=
overflow
;
_overflow
=
overflow
;
_pointedIndex
=
pointedIndex
;
_pointedIndex
=
pointedIndex
;
...
@@ -116,11 +123,6 @@ namespace PcapDotNet.Packets
...
@@ -116,11 +123,6 @@ namespace PcapDotNet.Packets
protected
abstract
void
WriteValues
(
byte
[]
buffer
,
ref
int
offset
);
protected
abstract
void
WriteValues
(
byte
[]
buffer
,
ref
int
offset
);
protected
static
TimeSpan
ReadTimeOfDay
(
byte
[]
buffer
,
ref
int
offset
)
{
return
TimeSpan
.
FromMilliseconds
(
buffer
.
ReadUInt
(
ref
offset
,
Endianity
.
Big
));
}
private
readonly
IpV4OptionTimestampType
_timestampType
;
private
readonly
IpV4OptionTimestampType
_timestampType
;
private
readonly
byte
_overflow
;
private
readonly
byte
_overflow
;
private
readonly
byte
_pointedIndex
;
private
readonly
byte
_pointedIndex
;
...
...
PcapDotNet/src/PcapDotNet.Packets/IpV4/IpV4OptionTimestampAndAddress.cs
View file @
77749cd4
...
@@ -6,9 +6,15 @@ namespace PcapDotNet.Packets
...
@@ -6,9 +6,15 @@ namespace PcapDotNet.Packets
{
{
public
class
IpV4OptionTimestampAndAddress
:
IpV4OptionTimestamp
public
class
IpV4OptionTimestampAndAddress
:
IpV4OptionTimestamp
{
{
public
IpV4OptionTimestampAndAddress
(
IpV4OptionTimestampType
timestampType
,
byte
overflow
,
byte
pointedIndex
,
KeyValuePair
<
IpV4Address
,
TimeSpan
>[]
addressesAndTimestamps
)
public
IpV4OptionTimestampAndAddress
(
IpV4OptionTimestampType
timestampType
,
byte
overflow
,
byte
pointedIndex
,
KeyValuePair
<
IpV4Address
,
uint
>[]
addressesAndTimestamps
)
:
base
(
timestampType
,
overflow
,
pointedIndex
)
:
base
(
timestampType
,
overflow
,
pointedIndex
)
{
{
if
(
timestampType
!=
IpV4OptionTimestampType
.
AddressAndTimestamp
&&
timestampType
!=
IpV4OptionTimestampType
.
AddressPrespecified
)
{
throw
new
ArgumentException
(
"Illegal timestamp type "
+
timestampType
,
"timestampType"
);
}
_addressesAndTimestamps
=
addressesAndTimestamps
;
_addressesAndTimestamps
=
addressesAndTimestamps
;
}
}
...
@@ -17,7 +23,7 @@ namespace PcapDotNet.Packets
...
@@ -17,7 +23,7 @@ namespace PcapDotNet.Packets
return
base
.
GetHashCode
()
^
return
base
.
GetHashCode
()
^
_addressesAndTimestamps
.
Aggregate
(
0
,
(
value
,
pair
)
=>
value
^
_addressesAndTimestamps
.
Aggregate
(
0
,
(
value
,
pair
)
=>
value
^
pair
.
Key
.
GetHashCode
()
^
pair
.
Key
.
GetHashCode
()
^
pair
.
Value
.
GetHashCode
()
);
(
int
)
pair
.
Value
);
}
}
internal
static
IpV4OptionTimestampAndAddress
Read
(
IpV4OptionTimestampType
timestampType
,
byte
overflow
,
byte
pointedIndex
,
byte
[]
buffer
,
ref
int
offset
,
int
numValues
)
internal
static
IpV4OptionTimestampAndAddress
Read
(
IpV4OptionTimestampType
timestampType
,
byte
overflow
,
byte
pointedIndex
,
byte
[]
buffer
,
ref
int
offset
,
int
numValues
)
...
@@ -25,11 +31,11 @@ namespace PcapDotNet.Packets
...
@@ -25,11 +31,11 @@ namespace PcapDotNet.Packets
if
(
numValues
%
2
!=
0
)
if
(
numValues
%
2
!=
0
)
return
null
;
return
null
;
KeyValuePair
<
IpV4Address
,
TimeSpan
>[]
addressesAndTimestamps
=
new
KeyValuePair
<
IpV4Address
,
TimeSpan
>[
numValues
/
2
];
KeyValuePair
<
IpV4Address
,
uint
>[]
addressesAndTimestamps
=
new
KeyValuePair
<
IpV4Address
,
uint
>[
numValues
/
2
];
for
(
int
i
=
0
;
i
!=
numValues
/
2
;
++
i
)
for
(
int
i
=
0
;
i
!=
numValues
/
2
;
++
i
)
{
{
addressesAndTimestamps
[
i
]
=
new
KeyValuePair
<
IpV4Address
,
TimeSpan
>(
new
IpV4Address
(
buffer
.
ReadUInt
(
ref
offset
,
Endianity
.
Big
)
),
addressesAndTimestamps
[
i
]
=
new
KeyValuePair
<
IpV4Address
,
uint
>(
buffer
.
ReadIpV4Address
(
ref
offset
,
Endianity
.
Big
),
ReadTimeOfDay
(
buffer
,
ref
offset
));
buffer
.
ReadUInt
(
ref
offset
,
Endianity
.
Big
));
}
}
return
new
IpV4OptionTimestampAndAddress
(
timestampType
,
overflow
,
pointedIndex
,
addressesAndTimestamps
);
return
new
IpV4OptionTimestampAndAddress
(
timestampType
,
overflow
,
pointedIndex
,
addressesAndTimestamps
);
...
@@ -47,13 +53,13 @@ namespace PcapDotNet.Packets
...
@@ -47,13 +53,13 @@ namespace PcapDotNet.Packets
protected
override
void
WriteValues
(
byte
[]
buffer
,
ref
int
offset
)
protected
override
void
WriteValues
(
byte
[]
buffer
,
ref
int
offset
)
{
{
foreach
(
KeyValuePair
<
IpV4Address
,
TimeSpan
>
addressAndTimestamp
in
_addressesAndTimestamps
)
foreach
(
KeyValuePair
<
IpV4Address
,
uint
>
addressAndTimestamp
in
_addressesAndTimestamps
)
{
{
buffer
.
Write
(
ref
offset
,
addressAndTimestamp
.
Key
,
Endianity
.
Big
);
buffer
.
Write
(
ref
offset
,
addressAndTimestamp
.
Key
,
Endianity
.
Big
);
buffer
.
Write
(
ref
offset
,
(
uint
)
addressAndTimestamp
.
Value
.
TotalMilliseconds
,
Endianity
.
Big
);
buffer
.
Write
(
ref
offset
,
addressAndTimestamp
.
Value
,
Endianity
.
Big
);
}
}
}
}
private
readonly
KeyValuePair
<
IpV4Address
,
TimeSpan
>[]
_addressesAndTimestamps
;
private
readonly
KeyValuePair
<
IpV4Address
,
uint
>[]
_addressesAndTimestamps
;
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/IpV4/IpV4OptionTimestampOnly.cs
View file @
77749cd4
...
@@ -5,7 +5,7 @@ namespace PcapDotNet.Packets
...
@@ -5,7 +5,7 @@ namespace PcapDotNet.Packets
{
{
public
class
IpV4OptionTimestampOnly
:
IpV4OptionTimestamp
public
class
IpV4OptionTimestampOnly
:
IpV4OptionTimestamp
{
{
public
IpV4OptionTimestampOnly
(
byte
overflow
,
byte
pointedIndex
,
params
TimeSpan
[]
timestamps
)
public
IpV4OptionTimestampOnly
(
byte
overflow
,
byte
pointedIndex
,
params
uint
[]
timestamps
)
:
base
(
IpV4OptionTimestampType
.
TimestampOnly
,
overflow
,
pointedIndex
)
:
base
(
IpV4OptionTimestampType
.
TimestampOnly
,
overflow
,
pointedIndex
)
{
{
_timestamps
=
timestamps
;
_timestamps
=
timestamps
;
...
@@ -19,9 +19,9 @@ namespace PcapDotNet.Packets
...
@@ -19,9 +19,9 @@ namespace PcapDotNet.Packets
internal
static
IpV4OptionTimestampOnly
Read
(
byte
overflow
,
byte
pointedIndex
,
byte
[]
buffer
,
ref
int
offset
,
int
numValues
)
internal
static
IpV4OptionTimestampOnly
Read
(
byte
overflow
,
byte
pointedIndex
,
byte
[]
buffer
,
ref
int
offset
,
int
numValues
)
{
{
TimeSpan
[]
timestamps
=
new
TimeSpan
[
numValues
];
uint
[]
timestamps
=
new
uint
[
numValues
];
for
(
int
i
=
0
;
i
!=
numValues
;
++
i
)
for
(
int
i
=
0
;
i
!=
numValues
;
++
i
)
timestamps
[
i
]
=
ReadTimeOfDay
(
buffer
,
ref
offset
);
timestamps
[
i
]
=
buffer
.
ReadUInt
(
ref
offset
,
Endianity
.
Big
);
return
new
IpV4OptionTimestampOnly
(
overflow
,
pointedIndex
,
timestamps
);
return
new
IpV4OptionTimestampOnly
(
overflow
,
pointedIndex
,
timestamps
);
}
}
...
@@ -38,10 +38,10 @@ namespace PcapDotNet.Packets
...
@@ -38,10 +38,10 @@ namespace PcapDotNet.Packets
protected
override
void
WriteValues
(
byte
[]
buffer
,
ref
int
offset
)
protected
override
void
WriteValues
(
byte
[]
buffer
,
ref
int
offset
)
{
{
foreach
(
TimeSpan
timestamp
in
_timestamps
)
foreach
(
uint
timestamp
in
_timestamps
)
buffer
.
Write
(
ref
offset
,
(
uint
)
timestamp
.
TotalMilliseconds
,
Endianity
.
Big
);
buffer
.
Write
(
ref
offset
,
timestamp
,
Endianity
.
Big
);
}
}
private
readonly
TimeSpan
[]
_timestamps
;
private
readonly
uint
[]
_timestamps
;
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/IpV4/IpV4Options.cs
View file @
77749cd4
...
@@ -8,7 +8,7 @@ namespace PcapDotNet.Packets
...
@@ -8,7 +8,7 @@ namespace PcapDotNet.Packets
{
{
public
class
IpV4Options
:
ReadOnlyCollection
<
IpV4Option
>,
IEquatable
<
IpV4Options
>
public
class
IpV4Options
:
ReadOnlyCollection
<
IpV4Option
>,
IEquatable
<
IpV4Options
>
{
{
public
const
int
MaximumLength
=
IpV4Datagram
.
HeaderMaximumLength
-
IpV4Datagram
.
HeaderMinimumLength
;
public
const
int
Maximum
Bytes
Length
=
IpV4Datagram
.
HeaderMaximumLength
-
IpV4Datagram
.
HeaderMinimumLength
;
public
static
IpV4Options
None
public
static
IpV4Options
None
{
{
...
@@ -18,6 +18,8 @@ namespace PcapDotNet.Packets
...
@@ -18,6 +18,8 @@ namespace PcapDotNet.Packets
public
IpV4Options
(
IList
<
IpV4Option
>
options
)
public
IpV4Options
(
IList
<
IpV4Option
>
options
)
:
this
(
EndOptions
(
options
),
true
)
:
this
(
EndOptions
(
options
),
true
)
{
{
if
(
BytesLength
>
MaximumBytesLength
)
throw
new
ArgumentException
(
"given options take "
+
BytesLength
+
" bytes and maximum number of bytes for options is "
+
MaximumBytesLength
,
"options"
);
}
}
public
IpV4Options
(
params
IpV4Option
[]
options
)
public
IpV4Options
(
params
IpV4Option
[]
options
)
...
...
PcapDotNet/src/PcapDotNet.TestUtils/MoreRandom.cs
View file @
77749cd4
...
@@ -23,9 +23,14 @@ namespace PcapDotNet.TestUtils
...
@@ -23,9 +23,14 @@ namespace PcapDotNet.TestUtils
return
random
.
NextByte
(
byte
.
MaxValue
+
1
);
return
random
.
NextByte
(
byte
.
MaxValue
+
1
);
}
}
public
static
ushort
NextUShort
(
this
Random
random
,
int
maxValue
)
{
return
(
ushort
)
random
.
Next
(
maxValue
);
}
public
static
ushort
NextUShort
(
this
Random
random
)
public
static
ushort
NextUShort
(
this
Random
random
)
{
{
return
(
ushort
)
random
.
Nex
t
(
ushort
.
MaxValue
+
1
);
return
random
.
NextUShor
t
(
ushort
.
MaxValue
+
1
);
}
}
public
static
UInt24
NextUInt24
(
this
Random
random
)
public
static
UInt24
NextUInt24
(
this
Random
random
)
...
...
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