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
b59c4532
Commit
b59c4532
authored
Sep 18, 2010
by
Brickner_cp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Warnings, Code Analysis and Documentation. 216 warnings left.
parent
8dcb5280
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
80 additions
and
7 deletions
+80
-7
CharExtensions.cs
PcapDotNet/src/PcapDotNet.Base/CharExtensions.cs
+10
-2
IDictionaryExtensions.cs
PcapDotNet/src/PcapDotNet.Base/IDictionaryExtensions.cs
+28
-0
IEnumerableExtensions.cs
PcapDotNet/src/PcapDotNet.Base/IEnumerableExtensions.cs
+7
-0
IListExtensions.cs
PcapDotNet/src/PcapDotNet.Base/IListExtensions.cs
+8
-0
MatchExtensions.cs
PcapDotNet/src/PcapDotNet.Base/MatchExtensions.cs
+13
-0
UIntExtensions.cs
PcapDotNet/src/PcapDotNet.Base/UIntExtensions.cs
+10
-1
LivePacketDeviceTests.cs
PcapDotNet/src/PcapDotNet.Core.Test/LivePacketDeviceTests.cs
+1
-1
HttpResponseLayer.cs
PcapDotNet/src/PcapDotNet.Packets/Http/HttpResponseLayer.cs
+1
-1
HttpTransferEncodingField.cs
.../src/PcapDotNet.Packets/Http/HttpTransferEncodingField.cs
+1
-1
HttpVersion.cs
PcapDotNet/src/PcapDotNet.Packets/Http/HttpVersion.cs
+1
-1
No files found.
PcapDotNet/src/PcapDotNet.Base/CharExtensions.cs
View file @
b59c4532
namespace
PcapDotNet.Base
namespace
PcapDotNet.Base
{
{
/// <summary>
/// Extension methods for char structure.
/// </summary>
public
static
class
CharExtensions
public
static
class
CharExtensions
{
{
public
static
bool
IsUpperCaseAlpha
(
this
char
c
)
/// <summary>
/// True iff the given character is one of the capital english letters.
/// </summary>
/// <param name="character">The input character to check.</param>
/// <returns>True for capital english letters.</returns>
public
static
bool
IsUppercaseAlpha
(
this
char
character
)
{
{
return
c
>=
'A'
&&
c
<=
'Z'
;
return
c
haracter
>=
'A'
&&
character
<=
'Z'
;
}
}
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Base/IDictionaryExtensions.cs
View file @
b59c4532
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
namespace
PcapDotNet.Base
namespace
PcapDotNet.Base
{
{
/// <summary>
/// Extension methods for IDictionary<TKey,TValue> interface.
/// </summary>
public
static
class
IDictionaryExtensions
public
static
class
IDictionaryExtensions
{
{
/// <summary>
/// Tests for equality between dictionaries.
/// Two dictionaries are equal if they have the same pairs.
/// Keys are compared using Equals() and values are compared using the given comparator.
/// </summary>
/// <typeparam name="TKey">The type of the key of the dictionary.</typeparam>
/// <typeparam name="TValue">The type of the value of the dictionary.</typeparam>
/// <param name="dictionary1">The first dictionary to compare.</param>
/// <param name="dictionary2">The second dictionary to compare.</param>
/// <param name="valueComparer">The comparator to check for values equality.</param>
/// <returns>True iff the dictionaries are equal.</returns>
public
static
bool
DictionaryEquals
<
TKey
,
TValue
>(
this
IDictionary
<
TKey
,
TValue
>
dictionary1
,
IDictionary
<
TKey
,
TValue
>
dictionary2
,
IEqualityComparer
<
TValue
>
valueComparer
)
public
static
bool
DictionaryEquals
<
TKey
,
TValue
>(
this
IDictionary
<
TKey
,
TValue
>
dictionary1
,
IDictionary
<
TKey
,
TValue
>
dictionary2
,
IEqualityComparer
<
TValue
>
valueComparer
)
{
{
if
(
valueComparer
==
null
)
throw
new
ArgumentNullException
(
"valueComparer"
);
if
(
ReferenceEquals
(
dictionary1
,
dictionary2
))
if
(
ReferenceEquals
(
dictionary1
,
dictionary2
))
return
true
;
return
true
;
...
@@ -27,6 +45,16 @@ namespace PcapDotNet.Base
...
@@ -27,6 +45,16 @@ namespace PcapDotNet.Base
return
true
;
return
true
;
}
}
/// <summary>
/// Tests for equality between dictionaries.
/// Two dictionaries are equal if they have the same pairs.
/// Keys are compared using Equals() and values are compared using the default EqualityComparer.
/// </summary>
/// <typeparam name="TKey">The type of the key of the dictionary.</typeparam>
/// <typeparam name="TValue">The type of the value of the dictionary.</typeparam>
/// <param name="dictionary1">The first dictionary to compare.</param>
/// <param name="dictionary2">The second dictionary to compare.</param>
/// <returns>True iff the dictionaries are equal.</returns>
public
static
bool
DictionaryEquals
<
TKey
,
TValue
>(
this
IDictionary
<
TKey
,
TValue
>
dictionary1
,
IDictionary
<
TKey
,
TValue
>
dictionary2
)
public
static
bool
DictionaryEquals
<
TKey
,
TValue
>(
this
IDictionary
<
TKey
,
TValue
>
dictionary1
,
IDictionary
<
TKey
,
TValue
>
dictionary2
)
{
{
return
dictionary1
.
DictionaryEquals
(
dictionary2
,
EqualityComparer
<
TValue
>.
Default
);
return
dictionary1
.
DictionaryEquals
(
dictionary2
,
EqualityComparer
<
TValue
>.
Default
);
...
...
PcapDotNet/src/PcapDotNet.Base/IEnumerableExtensions.cs
View file @
b59c4532
...
@@ -90,6 +90,13 @@ namespace PcapDotNet.Base
...
@@ -90,6 +90,13 @@ namespace PcapDotNet.Base
return
sequence
.
SequenceToString
(
separator
,
string
.
Empty
);
return
sequence
.
SequenceToString
(
separator
,
string
.
Empty
);
}
}
/// <summary>
/// Converts a sequence to a string by converting each element to a string.
/// </summary>
/// <typeparam name="T">The type of an element in the sequence.</typeparam>
/// <param name="sequence">The sequence with the elements to translate to string.</param>
/// <param name="separator">A separator between the elements.</param>
/// <returns>A string of all the elements.</returns>
public
static
string
SequenceToString
<
T
>(
this
IEnumerable
<
T
>
sequence
,
char
separator
)
public
static
string
SequenceToString
<
T
>(
this
IEnumerable
<
T
>
sequence
,
char
separator
)
{
{
return
sequence
.
SequenceToString
(
separator
.
ToString
());
return
sequence
.
SequenceToString
(
separator
.
ToString
());
...
...
PcapDotNet/src/PcapDotNet.Base/IListExtensions.cs
View file @
b59c4532
...
@@ -22,6 +22,14 @@ namespace PcapDotNet.Base
...
@@ -22,6 +22,14 @@ namespace PcapDotNet.Base
return
new
ReadOnlyCollection
<
T
>(
list
);
return
new
ReadOnlyCollection
<
T
>(
list
);
}
}
/// <summary>
/// Returns an enumerable of all the elements in the given list starting in a specific offset and taking no more than a specific count.
/// </summary>
/// <typeparam name="T">The type of an element in the collection.</typeparam>
/// <param name="list">The list to take the elements from.</param>
/// <param name="offset">The offset of the first element to take.</param>
/// <param name="count">The maximum number of elements to take.</param>
/// <returns>An enumerable of all the elements in the given list starting in a specific offset and taking no more than a specific count.</returns>
public
static
IEnumerable
<
T
>
Range
<
T
>(
this
IList
<
T
>
list
,
int
offset
,
int
count
)
public
static
IEnumerable
<
T
>
Range
<
T
>(
this
IList
<
T
>
list
,
int
offset
,
int
count
)
{
{
int
length
=
Math
.
Min
(
offset
+
count
,
list
.
Count
);
int
length
=
Math
.
Min
(
offset
+
count
,
list
.
Count
);
...
...
PcapDotNet/src/PcapDotNet.Base/MatchExtensions.cs
View file @
b59c4532
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Text.RegularExpressions
;
using
System.Text.RegularExpressions
;
using
System.Linq
;
using
System.Linq
;
namespace
PcapDotNet.Base
namespace
PcapDotNet.Base
{
{
/// <summary>
/// Extension methods for Match class.
/// </summary>
public
static
class
MatchExtensions
public
static
class
MatchExtensions
{
{
/// <summary>
/// Returns all the values that were captured for a given group name.
/// </summary>
/// <param name="match">The match to take the captured values from.</param>
/// <param name="groupName">The name of the capture group to take the values of.</param>
/// <returns>All the values that were captured for a given group name.</returns>
public
static
IEnumerable
<
string
>
GroupCapturesValues
(
this
Match
match
,
string
groupName
)
public
static
IEnumerable
<
string
>
GroupCapturesValues
(
this
Match
match
,
string
groupName
)
{
{
if
(
match
==
null
)
throw
new
ArgumentNullException
(
"match"
);
return
match
.
Groups
[
groupName
].
Captures
.
Cast
<
Capture
>().
Select
(
capture
=>
capture
.
Value
);
return
match
.
Groups
[
groupName
].
Captures
.
Cast
<
Capture
>().
Select
(
capture
=>
capture
.
Value
);
}
}
}
}
...
...
PcapDotNet/src/PcapDotNet.Base/UIntExtensions.cs
View file @
b59c4532
...
@@ -2,9 +2,18 @@ using System;
...
@@ -2,9 +2,18 @@ using System;
namespace
PcapDotNet.Base
namespace
PcapDotNet.Base
{
{
/// <summary>
/// Extension method for UInt structure.
/// </summary>
public
static
class
UIntExtensions
public
static
class
UIntExtensions
{
{
public
static
int
NumDigits
(
this
uint
value
,
double
digitsBase
)
/// <summary>
/// Returns the number of digits the number will be represented by according to a specific base.
/// </summary>
/// <param name="value">The number to check for number of digits.</param>
/// <param name="digitsBase">The base of the digits.</param>
/// <returns>The number of digits the number will be represented by according to a specific base.</returns>
public
static
int
DigitsCount
(
this
uint
value
,
double
digitsBase
)
{
{
return
(
int
)(
Math
.
Floor
(
Math
.
Log
(
value
,
digitsBase
))
+
1
);
return
(
int
)(
Math
.
Floor
(
Math
.
Log
(
value
,
digitsBase
))
+
1
);
}
}
...
...
PcapDotNet/src/PcapDotNet.Core.Test/LivePacketDeviceTests.cs
View file @
b59c4532
...
@@ -167,7 +167,7 @@ namespace PcapDotNet.Core.Test
...
@@ -167,7 +167,7 @@ namespace PcapDotNet.Core.Test
// Break loop
// Break loop
TestReceivePackets
(
NumPacketsToSend
,
NumPacketsToSend
,
0
,
2
,
PacketSize
,
PacketCommunicatorReceiveResult
.
BreakLoop
,
0
,
0
,
0.027
);
TestReceivePackets
(
NumPacketsToSend
,
NumPacketsToSend
,
0
,
2
,
PacketSize
,
PacketCommunicatorReceiveResult
.
BreakLoop
,
0
,
0
,
0.027
);
TestReceivePackets
(
NumPacketsToSend
,
NumPacketsToSend
,
NumPacketsToSend
/
2
,
2
,
PacketSize
,
PacketCommunicatorReceiveResult
.
BreakLoop
,
NumPacketsToSend
/
2
,
0
,
0.0
32
);
TestReceivePackets
(
NumPacketsToSend
,
NumPacketsToSend
,
NumPacketsToSend
/
2
,
2
,
PacketSize
,
PacketCommunicatorReceiveResult
.
BreakLoop
,
NumPacketsToSend
/
2
,
0
,
0.0
45
);
}
}
[
TestMethod
]
[
TestMethod
]
...
...
PcapDotNet/src/PcapDotNet.Packets/Http/HttpResponseLayer.cs
View file @
b59c4532
...
@@ -35,7 +35,7 @@ namespace PcapDotNet.Packets.Http
...
@@ -35,7 +35,7 @@ namespace PcapDotNet.Packets.Http
if
(
StatusCode
==
null
)
if
(
StatusCode
==
null
)
return
length
;
return
length
;
length
+=
StatusCode
.
Value
.
NumDigits
(
10
)
+
1
;
length
+=
StatusCode
.
Value
.
DigitsCount
(
10
)
+
1
;
if
(
ReasonPhrase
==
null
)
if
(
ReasonPhrase
==
null
)
return
length
;
return
length
;
...
...
PcapDotNet/src/PcapDotNet.Packets/Http/HttpTransferEncodingField.cs
View file @
b59c4532
...
@@ -36,7 +36,7 @@ namespace PcapDotNet.Packets.Http
...
@@ -36,7 +36,7 @@ namespace PcapDotNet.Packets.Http
private
void
SetTransferCodings
(
IList
<
string
>
transferCodings
)
private
void
SetTransferCodings
(
IList
<
string
>
transferCodings
)
{
{
if
(
transferCodings
.
Any
(
coding
=>
coding
.
Any
(
c
=>
c
.
IsUpper
C
aseAlpha
())))
if
(
transferCodings
.
Any
(
coding
=>
coding
.
Any
(
c
=>
c
.
IsUpper
c
aseAlpha
())))
_transferCodings
=
transferCodings
.
Select
(
coding
=>
coding
.
ToLowerInvariant
()).
ToArray
().
AsReadOnly
();
_transferCodings
=
transferCodings
.
Select
(
coding
=>
coding
.
ToLowerInvariant
()).
ToArray
().
AsReadOnly
();
else
else
_transferCodings
=
transferCodings
.
AsReadOnly
();
_transferCodings
=
transferCodings
.
AsReadOnly
();
...
...
PcapDotNet/src/PcapDotNet.Packets/Http/HttpVersion.cs
View file @
b59c4532
...
@@ -20,7 +20,7 @@ namespace PcapDotNet.Packets.Http
...
@@ -20,7 +20,7 @@ namespace PcapDotNet.Packets.Http
public
int
Length
public
int
Length
{
{
get
{
return
_httpSlashBytes
.
Length
+
Major
.
NumDigits
(
10
)
+
1
+
Minor
.
NumDigits
(
10
);
}
get
{
return
_httpSlashBytes
.
Length
+
Major
.
DigitsCount
(
10
)
+
1
+
Minor
.
DigitsCount
(
10
);
}
}
}
public
override
string
ToString
()
public
override
string
ToString
()
...
...
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