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
16995cfa
Commit
16995cfa
authored
Aug 02, 2009
by
Brickner_cp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code Analysis
parent
23b567f8
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
94 additions
and
31 deletions
+94
-31
MoreIEnumerable.cs
PcapDotNet/src/PcapDotNet.Base/MoreIEnumerable.cs
+5
-0
Tuple.cs
PcapDotNet/src/PcapDotNet.Base/Tuple.cs
+6
-6
UInt24.cs
PcapDotNet/src/PcapDotNet.Base/UInt24.cs
+2
-1
UInt48.cs
PcapDotNet/src/PcapDotNet.Base/UInt48.cs
+2
-1
MoreRandomPackets.cs
...Net/src/PcapDotNet.Packets.TestUtils/MoreRandomPackets.cs
+2
-2
IpV4OptionRoute.cs
PcapDotNet/src/PcapDotNet.Packets/IpV4/IpV4OptionRoute.cs
+1
-1
IpV4OptionStreamIdentifier.cs
...src/PcapDotNet.Packets/IpV4/IpV4OptionStreamIdentifier.cs
+1
-1
IpV4OptionTimedAddress.cs
...Net/src/PcapDotNet.Packets/IpV4/IpV4OptionTimedAddress.cs
+59
-0
IpV4OptionTimestampAndAddress.cs
.../PcapDotNet.Packets/IpV4/IpV4OptionTimestampAndAddress.cs
+10
-13
IpV4OptionTimestampOnly.cs
...et/src/PcapDotNet.Packets/IpV4/IpV4OptionTimestampOnly.cs
+4
-5
IpV4Options.cs
PcapDotNet/src/PcapDotNet.Packets/IpV4/IpV4Options.cs
+1
-1
PcapDotNet.Packets.csproj
PcapDotNet/src/PcapDotNet.Packets/PcapDotNet.Packets.csproj
+1
-0
No files found.
PcapDotNet/src/PcapDotNet.Base/MoreIEnumerable.cs
View file @
16995cfa
...
@@ -44,5 +44,10 @@ namespace PcapDotNet.Base
...
@@ -44,5 +44,10 @@ namespace PcapDotNet.Base
{
{
return
sequence
.
SequenceToString
(
string
.
Empty
);
return
sequence
.
SequenceToString
(
string
.
Empty
);
}
}
public
static
int
SequenceGetHashCode
<
T
>(
this
IEnumerable
<
T
>
sequence
)
{
return
sequence
.
Aggregate
(
0
,
(
valueSoFar
,
element
)
=>
valueSoFar
^
element
.
GetHashCode
());
}
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Base/Tuple.cs
View file @
16995cfa
namespace
PcapDotNet.Base
namespace
PcapDotNet.Base
{
{
public
class
Tuple
<
T
1
,
T
2
>
public
class
Tuple
<
T
Value1
,
TValue
2
>
{
{
public
Tuple
(
T
1
value1
,
T
2
value2
)
public
Tuple
(
T
Value1
value1
,
TValue
2
value2
)
{
{
_value1
=
value1
;
_value1
=
value1
;
_value2
=
value2
;
_value2
=
value2
;
}
}
public
T1
Value1
public
T
Value
1
Value1
{
{
get
{
return
_value1
;
}
get
{
return
_value1
;
}
}
}
public
T2
Value2
public
T
Value
2
Value2
{
{
get
{
return
_value2
;
}
get
{
return
_value2
;
}
}
}
private
readonly
T1
_value1
;
private
readonly
T
Value
1
_value1
;
private
readonly
T2
_value2
;
private
readonly
T
Value
2
_value2
;
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Base/UInt24.cs
View file @
16995cfa
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Globalization
;
using
System.Linq
;
using
System.Linq
;
using
System.Runtime.InteropServices
;
using
System.Runtime.InteropServices
;
using
System.Text
;
using
System.Text
;
...
@@ -51,7 +52,7 @@ namespace PcapDotNet.Base
...
@@ -51,7 +52,7 @@ namespace PcapDotNet.Base
public
override
string
ToString
()
public
override
string
ToString
()
{
{
return
((
int
)
this
).
ToString
();
return
((
int
)
this
).
ToString
(
CultureInfo
.
InvariantCulture
);
}
}
private
UInt24
(
int
value
)
private
UInt24
(
int
value
)
...
...
PcapDotNet/src/PcapDotNet.Base/UInt48.cs
View file @
16995cfa
using
System.Globalization
;
using
System.Runtime.InteropServices
;
using
System.Runtime.InteropServices
;
namespace
PcapDotNet.Base
namespace
PcapDotNet.Base
...
@@ -47,7 +48,7 @@ namespace PcapDotNet.Base
...
@@ -47,7 +48,7 @@ namespace PcapDotNet.Base
public
override
string
ToString
()
public
override
string
ToString
()
{
{
return
((
long
)
this
).
ToString
();
return
((
long
)
this
).
ToString
(
CultureInfo
.
InvariantCulture
);
}
}
private
UInt48
(
long
value
)
private
UInt48
(
long
value
)
...
...
PcapDotNet/src/PcapDotNet.Packets.TestUtils/MoreRandomPackets.cs
View file @
16995cfa
...
@@ -154,9 +154,9 @@ namespace PcapDotNet.Packets.TestUtils
...
@@ -154,9 +154,9 @@ namespace PcapDotNet.Packets.TestUtils
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
,
uint
>[]
pairs
=
new
KeyValuePair
<
IpV4Address
,
uint
>
[
numPairs
];
IpV4OptionTimedAddress
[]
pairs
=
new
IpV4OptionTimedAddress
[
numPairs
];
for
(
int
i
=
0
;
i
!=
numPairs
;
++
i
)
for
(
int
i
=
0
;
i
!=
numPairs
;
++
i
)
pairs
[
i
]
=
new
KeyValuePair
<
IpV4Address
,
uint
>
(
random
.
NextIpV4Address
(),
random
.
NextUInt
());
pairs
[
i
]
=
new
IpV4OptionTimedAddress
(
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/IpV4OptionRoute.cs
View file @
16995cfa
...
@@ -46,7 +46,7 @@ namespace PcapDotNet.Packets
...
@@ -46,7 +46,7 @@ namespace PcapDotNet.Packets
{
{
return
base
.
GetHashCode
()
^
return
base
.
GetHashCode
()
^
PointedAddressIndex
^
PointedAddressIndex
^
Route
.
Aggregate
(
0
,
(
value
,
address
)
=>
value
^
address
.
GetHashCode
()
);
Route
.
SequenceGetHashCode
(
);
}
}
public
ReadOnlyCollection
<
IpV4Address
>
Route
public
ReadOnlyCollection
<
IpV4Address
>
Route
...
...
PcapDotNet/src/PcapDotNet.Packets/IpV4/IpV4OptionStreamIdentifier.cs
View file @
16995cfa
...
@@ -5,7 +5,7 @@ namespace PcapDotNet.Packets
...
@@ -5,7 +5,7 @@ namespace PcapDotNet.Packets
public
class
IpV4OptionStreamIdentifier
:
IpV4OptionComplex
,
IEquatable
<
IpV4OptionStreamIdentifier
>
public
class
IpV4OptionStreamIdentifier
:
IpV4OptionComplex
,
IEquatable
<
IpV4OptionStreamIdentifier
>
{
{
public
const
int
OptionLength
=
4
;
public
const
int
OptionLength
=
4
;
public
const
int
Option
v
alueLength
=
OptionLength
-
OptionHeaderLength
;
public
const
int
Option
V
alueLength
=
OptionLength
-
OptionHeaderLength
;
public
IpV4OptionStreamIdentifier
(
ushort
identifier
)
public
IpV4OptionStreamIdentifier
(
ushort
identifier
)
:
base
(
IpV4OptionType
.
StreamIdentifier
)
:
base
(
IpV4OptionType
.
StreamIdentifier
)
...
...
PcapDotNet/src/PcapDotNet.Packets/IpV4/IpV4OptionTimedAddress.cs
0 → 100644
View file @
16995cfa
using
System
;
namespace
PcapDotNet.Packets
{
public
struct
IpV4OptionTimedAddress
:
IEquatable
<
IpV4OptionTimedAddress
>
{
public
IpV4OptionTimedAddress
(
IpV4Address
address
,
uint
timestamp
)
{
_address
=
address
;
_millisecondsSinceMidnightUt
=
timestamp
;
}
public
IpV4Address
Address
{
get
{
return
_address
;
}
}
public
uint
MillisecondsSinceMidnight
{
get
{
return
_millisecondsSinceMidnightUt
;
}
}
public
TimeSpan
TimeOfDay
{
get
{
return
TimeSpan
.
FromMilliseconds
(
MillisecondsSinceMidnight
);
}
}
public
bool
Equals
(
IpV4OptionTimedAddress
other
)
{
return
Address
==
other
.
Address
&&
MillisecondsSinceMidnight
==
other
.
MillisecondsSinceMidnight
;
}
public
override
bool
Equals
(
object
obj
)
{
return
(
obj
is
IpV4OptionTimedAddress
)
&&
Equals
((
IpV4OptionTimedAddress
)
obj
);
}
public
static
bool
operator
==(
IpV4OptionTimedAddress
value1
,
IpV4OptionTimedAddress
value2
)
{
return
value1
.
Equals
(
value2
);
}
public
static
bool
operator
!=(
IpV4OptionTimedAddress
value1
,
IpV4OptionTimedAddress
value2
)
{
return
!(
value1
==
value2
);
}
public
override
int
GetHashCode
()
{
return
_address
.
GetHashCode
()
^
(
int
)
_millisecondsSinceMidnightUt
;
}
private
readonly
IpV4Address
_address
;
private
readonly
uint
_millisecondsSinceMidnightUt
;
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/IpV4/IpV4OptionTimestampAndAddress.cs
View file @
16995cfa
...
@@ -8,7 +8,7 @@ namespace PcapDotNet.Packets
...
@@ -8,7 +8,7 @@ namespace PcapDotNet.Packets
{
{
public
class
IpV4OptionTimestampAndAddress
:
IpV4OptionTimestamp
public
class
IpV4OptionTimestampAndAddress
:
IpV4OptionTimestamp
{
{
public
IpV4OptionTimestampAndAddress
(
IpV4OptionTimestampType
timestampType
,
byte
overflow
,
byte
pointedIndex
,
IList
<
KeyValuePair
<
IpV4Address
,
uint
>
>
addressesAndTimestamps
)
public
IpV4OptionTimestampAndAddress
(
IpV4OptionTimestampType
timestampType
,
byte
overflow
,
byte
pointedIndex
,
IList
<
IpV4OptionTimedAddress
>
addressesAndTimestamps
)
:
base
(
timestampType
,
overflow
,
pointedIndex
)
:
base
(
timestampType
,
overflow
,
pointedIndex
)
{
{
if
(
timestampType
!=
IpV4OptionTimestampType
.
AddressAndTimestamp
&&
if
(
timestampType
!=
IpV4OptionTimestampType
.
AddressAndTimestamp
&&
...
@@ -20,17 +20,14 @@ namespace PcapDotNet.Packets
...
@@ -20,17 +20,14 @@ namespace PcapDotNet.Packets
_addressesAndTimestamps
=
addressesAndTimestamps
.
AsReadOnly
();
_addressesAndTimestamps
=
addressesAndTimestamps
.
AsReadOnly
();
}
}
public
ReadOnlyCollection
<
KeyValuePair
<
IpV4Address
,
uint
>
>
TimedRoute
public
ReadOnlyCollection
<
IpV4OptionTimedAddress
>
TimedRoute
{
{
get
{
return
_addressesAndTimestamps
;
}
get
{
return
_addressesAndTimestamps
;
}
}
}
public
override
int
GetHashCode
()
public
override
int
GetHashCode
()
{
{
return
base
.
GetHashCode
()
^
return
base
.
GetHashCode
()
^
TimedRoute
.
SequenceGetHashCode
();
TimedRoute
.
Aggregate
(
0
,
(
value
,
pair
)
=>
value
^
pair
.
Key
.
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
)
...
@@ -38,11 +35,11 @@ namespace PcapDotNet.Packets
...
@@ -38,11 +35,11 @@ namespace PcapDotNet.Packets
if
(
numValues
%
2
!=
0
)
if
(
numValues
%
2
!=
0
)
return
null
;
return
null
;
KeyValuePair
<
IpV4Address
,
uint
>[]
addressesAndTimestamps
=
new
KeyValuePair
<
IpV4Address
,
uint
>
[
numValues
/
2
];
IpV4OptionTimedAddress
[]
addressesAndTimestamps
=
new
IpV4OptionTimedAddress
[
numValues
/
2
];
for
(
int
i
=
0
;
i
!=
numValues
/
2
;
++
i
)
for
(
int
i
=
0
;
i
!=
numValues
/
2
;
++
i
)
{
{
addressesAndTimestamps
[
i
]
=
new
KeyValuePair
<
IpV4Address
,
uint
>
(
buffer
.
ReadIpV4Address
(
ref
offset
,
Endianity
.
Big
),
addressesAndTimestamps
[
i
]
=
new
IpV4OptionTimedAddress
(
buffer
.
ReadIpV4Address
(
ref
offset
,
Endianity
.
Big
),
buffer
.
ReadUInt
(
ref
offset
,
Endianity
.
Big
));
buffer
.
ReadUInt
(
ref
offset
,
Endianity
.
Big
));
}
}
return
new
IpV4OptionTimestampAndAddress
(
timestampType
,
overflow
,
pointedIndex
,
addressesAndTimestamps
);
return
new
IpV4OptionTimestampAndAddress
(
timestampType
,
overflow
,
pointedIndex
,
addressesAndTimestamps
);
...
@@ -60,13 +57,13 @@ namespace PcapDotNet.Packets
...
@@ -60,13 +57,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
,
uint
>
addressAndTimestamp
in
TimedRoute
)
foreach
(
IpV4OptionTimedAddress
addressAndTimestamp
in
TimedRoute
)
{
{
buffer
.
Write
(
ref
offset
,
addressAndTimestamp
.
Key
,
Endianity
.
Big
);
buffer
.
Write
(
ref
offset
,
addressAndTimestamp
.
Address
,
Endianity
.
Big
);
buffer
.
Write
(
ref
offset
,
addressAndTimestamp
.
Value
,
Endianity
.
Big
);
buffer
.
Write
(
ref
offset
,
addressAndTimestamp
.
MillisecondsSinceMidnight
,
Endianity
.
Big
);
}
}
}
}
private
readonly
ReadOnlyCollection
<
KeyValuePair
<
IpV4Address
,
uint
>
>
_addressesAndTimestamps
;
private
readonly
ReadOnlyCollection
<
IpV4OptionTimedAddress
>
_addressesAndTimestamps
;
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/IpV4/IpV4OptionTimestampOnly.cs
View file @
16995cfa
...
@@ -26,8 +26,7 @@ namespace PcapDotNet.Packets
...
@@ -26,8 +26,7 @@ namespace PcapDotNet.Packets
public
override
int
GetHashCode
()
public
override
int
GetHashCode
()
{
{
return
base
.
GetHashCode
()
^
return
base
.
GetHashCode
()
^
Timestamps
.
SequenceGetHashCode
();
_timestamps
.
Aggregate
(
0
,
(
value
,
timestamp
)
=>
value
^
timestamp
.
GetHashCode
());
}
}
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
)
...
@@ -41,17 +40,17 @@ namespace PcapDotNet.Packets
...
@@ -41,17 +40,17 @@ namespace PcapDotNet.Packets
protected
override
int
ValuesLength
protected
override
int
ValuesLength
{
{
get
{
return
_timestamps
.
Count
*
4
;
}
get
{
return
Timestamps
.
Count
*
sizeof
(
uint
)
;
}
}
}
protected
override
bool
EqualValues
(
IpV4OptionTimestamp
other
)
protected
override
bool
EqualValues
(
IpV4OptionTimestamp
other
)
{
{
return
_timestamps
.
SequenceEqual
(((
IpV4OptionTimestampOnly
)
other
).
_t
imestamps
);
return
Timestamps
.
SequenceEqual
(((
IpV4OptionTimestampOnly
)
other
).
T
imestamps
);
}
}
protected
override
void
WriteValues
(
byte
[]
buffer
,
ref
int
offset
)
protected
override
void
WriteValues
(
byte
[]
buffer
,
ref
int
offset
)
{
{
foreach
(
uint
timestamp
in
_t
imestamps
)
foreach
(
uint
timestamp
in
T
imestamps
)
buffer
.
Write
(
ref
offset
,
timestamp
,
Endianity
.
Big
);
buffer
.
Write
(
ref
offset
,
timestamp
,
Endianity
.
Big
);
}
}
...
...
PcapDotNet/src/PcapDotNet.Packets/IpV4/IpV4Options.cs
View file @
16995cfa
...
@@ -56,7 +56,7 @@ namespace PcapDotNet.Packets
...
@@ -56,7 +56,7 @@ namespace PcapDotNet.Packets
public
override
int
GetHashCode
()
public
override
int
GetHashCode
()
{
{
return
BytesLength
.
GetHashCode
()
^
return
BytesLength
.
GetHashCode
()
^
this
.
Aggregate
(
0
,
(
value
,
option
)
=>
value
^
option
.
GetHashCode
()
);
this
.
SequenceGetHashCode
(
);
}
}
public
override
string
ToString
()
public
override
string
ToString
()
...
...
PcapDotNet/src/PcapDotNet.Packets/PcapDotNet.Packets.csproj
View file @
16995cfa
...
@@ -83,6 +83,7 @@
...
@@ -83,6 +83,7 @@
<Compile
Include=
"IpV4\IpV4OptionSecurityLevel.cs"
/>
<Compile
Include=
"IpV4\IpV4OptionSecurityLevel.cs"
/>
<Compile
Include=
"IpV4\IpV4OptionStreamIdentifier.cs"
/>
<Compile
Include=
"IpV4\IpV4OptionStreamIdentifier.cs"
/>
<Compile
Include=
"IpV4\IpV4OptionStrictSourceRouting.cs"
/>
<Compile
Include=
"IpV4\IpV4OptionStrictSourceRouting.cs"
/>
<Compile
Include=
"IpV4\IpV4OptionTimedAddress.cs"
/>
<Compile
Include=
"IpV4\IpV4OptionTimestamp.cs"
/>
<Compile
Include=
"IpV4\IpV4OptionTimestamp.cs"
/>
<Compile
Include=
"IpV4\IpV4OptionTimestampAndAddress.cs"
/>
<Compile
Include=
"IpV4\IpV4OptionTimestampAndAddress.cs"
/>
<Compile
Include=
"IpV4\IpV4OptionTimestampOnly.cs"
/>
<Compile
Include=
"IpV4\IpV4OptionTimestampOnly.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