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
9f094d21
Commit
9f094d21
authored
Sep 12, 2010
by
Brickner_cp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code Coverage 94.79%
parent
96bc7c08
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
42 additions
and
27 deletions
+42
-27
PcapDotNet.Base.csproj
PcapDotNet/src/PcapDotNet.Base/PcapDotNet.Base.csproj
+0
-1
HexEncoding.cs
PcapDotNet/src/PcapDotNet.Core.Test/HexEncoding.cs
+0
-0
PacketDumpFileTests.cs
PcapDotNet/src/PcapDotNet.Core.Test/PacketDumpFileTests.cs
+2
-2
PcapDotNet.Core.Test.csproj
...tNet/src/PcapDotNet.Core.Test/PcapDotNet.Core.Test.csproj
+1
-0
WiresharkCompareTests.cs
PcapDotNet/src/PcapDotNet.Core.Test/WiresharkCompareTests.cs
+6
-2
HttpTests.cs
PcapDotNet/src/PcapDotNet.Packets.Test/HttpTests.cs
+24
-0
HttpContentTypeField.cs
...otNet/src/PcapDotNet.Packets/Http/HttpContentTypeField.cs
+0
-8
HttpLayer.cs
PcapDotNet/src/PcapDotNet.Packets/Http/HttpLayer.cs
+2
-0
HttpRequestLayer.cs
PcapDotNet/src/PcapDotNet.Packets/Http/HttpRequestLayer.cs
+3
-0
HttpResponseLayer.cs
PcapDotNet/src/PcapDotNet.Packets/Http/HttpResponseLayer.cs
+4
-1
HttpTransferEncodingField.cs
.../src/PcapDotNet.Packets/Http/HttpTransferEncodingField.cs
+0
-13
No files found.
PcapDotNet/src/PcapDotNet.Base/PcapDotNet.Base.csproj
View file @
9f094d21
...
...
@@ -87,7 +87,6 @@
<ItemGroup>
<Compile
Include=
"CharExtensions.cs"
/>
<Compile
Include=
"FuncExtensions.cs"
/>
<Compile
Include=
"HexEncoding.cs"
/>
<Compile
Include=
"IDictionaryExtensions.cs"
/>
<Compile
Include=
"IEnumerableExtensions.cs"
/>
<Compile
Include=
"IListExtensions.cs"
/>
...
...
PcapDotNet/src/PcapDotNet.
Base
/HexEncoding.cs
→
PcapDotNet/src/PcapDotNet.
Core.Test
/HexEncoding.cs
View file @
9f094d21
File moved
PcapDotNet/src/PcapDotNet.Core.Test/PacketDumpFileTests.cs
View file @
9f094d21
...
...
@@ -56,9 +56,9 @@ namespace PcapDotNet.Core.Test
{
Data
=
new
Datagram
(
new
byte
[]
{
1
,
2
,
3
})
});
PacketDumpFile
.
Dump
(
filename
,
new
PcapDataLink
(
DataLinkKind
.
Ethernet
)
,
PacketDevice
.
DefaultSnapshotLength
,
PacketDumpFile
.
Dump
(
filename
,
DataLinkKind
.
Ethernet
,
PacketDevice
.
DefaultSnapshotLength
,
new
[]
{
expectedPacket
});
using
(
PacketCommunicator
communicator
=
new
OfflinePacketDevice
(
filename
).
Open
())
{
Packet
actualPacket
;
...
...
PcapDotNet/src/PcapDotNet.Core.Test/PcapDotNet.Core.Test.csproj
View file @
9f094d21
...
...
@@ -69,6 +69,7 @@
</ItemGroup>
<ItemGroup>
<Compile
Include=
"BerkeleyPacketFilterTests.cs"
/>
<Compile
Include=
"HexEncoding.cs"
/>
<Compile
Include=
"LivePacketDeviceExtensionsTests.cs"
/>
<Compile
Include=
"LivePacketDeviceTests.cs"
/>
<Compile
Include=
"MarshalingServicesTests.cs"
/>
...
...
PcapDotNet/src/PcapDotNet.Core.Test/WiresharkCompareTests.cs
View file @
9f094d21
...
...
@@ -195,8 +195,12 @@ namespace PcapDotNet.Core.Test
if
(
random
.
NextBool
())
ipV4Layer
.
Fragmentation
=
IpV4Fragmentation
.
None
;
TcpLayer
tcpLayer
=
random
.
NextTcpLayer
();
tcpLayer
.
DestinationPort
=
80
;
tcpLayer
.
SourcePort
=
80
;
HttpLayer
httpLayer
=
random
.
NextHttpLayer
();
if
(
httpLayer
.
IsRequest
)
tcpLayer
.
DestinationPort
=
80
;
else
tcpLayer
.
SourcePort
=
80
;
return
PacketBuilder
.
Build
(
packetTimestamp
,
ethernetLayer
,
ipV4Layer
,
tcpLayer
,
random
.
NextHttpLayer
());
default
:
...
...
PcapDotNet/src/PcapDotNet.Packets.Test/HttpTests.cs
View file @
9f094d21
...
...
@@ -69,7 +69,9 @@ namespace PcapDotNet.Packets.Test
if
(
httpLayer
is
HttpRequestLayer
)
{
Assert
.
IsTrue
(
httpDatagram
.
IsRequest
);
Assert
.
IsTrue
(
httpLayer
.
IsRequest
);
Assert
.
IsFalse
(
httpDatagram
.
IsResponse
);
Assert
.
IsFalse
(
httpLayer
.
IsResponse
);
HttpRequestLayer
httpRequestLayer
=
(
HttpRequestLayer
)
httpLayer
;
HttpRequestDatagram
httpRequestDatagram
=
(
HttpRequestDatagram
)
httpDatagram
;
...
...
@@ -81,7 +83,9 @@ namespace PcapDotNet.Packets.Test
else
{
Assert
.
IsFalse
(
httpDatagram
.
IsRequest
);
Assert
.
IsFalse
(
httpLayer
.
IsRequest
);
Assert
.
IsTrue
(
httpDatagram
.
IsResponse
);
Assert
.
IsTrue
(
httpLayer
.
IsResponse
);
HttpResponseLayer
httpResponseLayer
=
(
HttpResponseLayer
)
httpLayer
;
HttpResponseDatagram
httpResponseDatagram
=
(
HttpResponseDatagram
)
httpDatagram
;
...
...
@@ -89,6 +93,19 @@ namespace PcapDotNet.Packets.Test
Assert
.
AreEqual
(
httpResponseLayer
.
ReasonPhrase
,
httpResponseDatagram
.
ReasonPhrase
);
}
Assert
.
AreEqual
(
httpLayer
.
Header
,
httpDatagram
.
Header
);
if
(
httpLayer
.
Header
!=
null
)
{
foreach
(
var
field
in
httpLayer
.
Header
)
Assert
.
AreNotEqual
(
"abc"
,
field
);
if
(
httpLayer
.
Header
.
ContentType
!=
null
)
{
var
parameters
=
httpLayer
.
Header
.
ContentType
.
Parameters
;
Assert
.
AreEqual
<
object
>(
parameters
,
httpDatagram
.
Header
.
ContentType
.
Parameters
);
int
maxParameterNameLength
=
parameters
.
Any
()
?
parameters
.
Max
(
pair
=>
pair
.
Key
.
Length
)
:
0
;
Assert
.
IsNull
(
parameters
[
new
string
(
'a'
,
maxParameterNameLength
+
1
)]);
}
}
Assert
.
AreEqual
(
httpLayer
.
Body
,
httpDatagram
.
Body
);
Assert
.
AreEqual
(
httpLayer
,
httpDatagram
.
ExtractLayer
(),
"HTTP Layer"
);
Assert
.
AreEqual
(
httpLayer
.
Length
,
httpDatagram
.
Length
);
...
...
@@ -420,6 +437,13 @@ namespace PcapDotNet.Packets.Test
Assert
.
AreEqual
<
uint
>(
302
,
response
.
StatusCode
.
Value
);
}
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentException
))]
public
void
HttpRequestMethodBadKnownTest
()
{
Assert
.
IsNotNull
(
new
HttpRequestMethod
(
HttpRequestKnownMethod
.
Unknown
));
}
private
static
void
TestHttpRequest
(
string
httpString
,
string
expectedMethodString
=
null
,
string
expectedUri
=
null
,
HttpVersion
expectedVersion
=
null
,
HttpHeader
expectedHeader
=
null
,
string
expectedBodyString
=
null
)
{
Datagram
expectedBody
=
expectedBodyString
==
null
?
null
:
new
Datagram
(
Encoding
.
ASCII
.
GetBytes
(
expectedBodyString
));
...
...
PcapDotNet/src/PcapDotNet.Packets/Http/HttpContentTypeField.cs
View file @
9f094d21
...
...
@@ -43,14 +43,6 @@ namespace PcapDotNet.Packets.Http
Match
match
=
_regex
.
Match
(
fieldValueString
);
if
(!
match
.
Success
)
return
;
// {
// while (!match.Success && fieldValueString.Length > 0)
// {
// fieldValueString = fieldValueString.Substring(0, fieldValueString.Length - 1);
// match = _regex.Match(fieldValueString);
// }
// return;
// }
MediaType
=
match
.
Groups
[
MediaTypeGroupName
].
Captures
.
Cast
<
Capture
>().
First
().
Value
;
MediaSubType
=
match
.
Groups
[
MediaSubTypeGroupName
].
Captures
.
Cast
<
Capture
>().
First
().
Value
;
...
...
PcapDotNet/src/PcapDotNet.Packets/Http/HttpLayer.cs
View file @
9f094d21
...
...
@@ -4,6 +4,8 @@ namespace PcapDotNet.Packets.Http
{
public
abstract
class
HttpLayer
:
SimpleLayer
,
IEquatable
<
HttpLayer
>
{
public
abstract
bool
IsRequest
{
get
;
}
public
bool
IsResponse
{
get
{
return
!
IsRequest
;
}
}
public
HttpVersion
Version
{
get
;
set
;
}
public
HttpHeader
Header
{
get
;
set
;
}
public
Datagram
Body
{
get
;
set
;
}
...
...
PcapDotNet/src/PcapDotNet.Packets/Http/HttpRequestLayer.cs
View file @
9f094d21
...
...
@@ -5,7 +5,10 @@ namespace PcapDotNet.Packets.Http
{
public
class
HttpRequestLayer
:
HttpLayer
,
IEquatable
<
HttpRequestLayer
>
{
public
override
bool
IsRequest
{
get
{
return
true
;
}
}
public
HttpRequestMethod
Method
{
get
;
set
;
}
public
string
Uri
{
get
;
set
;
}
public
override
bool
Equals
(
HttpLayer
other
)
...
...
PcapDotNet/src/PcapDotNet.Packets/Http/HttpResponseLayer.cs
View file @
9f094d21
...
...
@@ -5,9 +5,12 @@ namespace PcapDotNet.Packets.Http
{
public
class
HttpResponseLayer
:
HttpLayer
,
IEquatable
<
HttpResponseLayer
>
{
public
override
bool
IsRequest
{
get
{
return
false
;
}
}
public
uint
?
StatusCode
{
get
;
set
;
}
public
Datagram
ReasonPhrase
{
get
;
set
;
}
public
Datagram
ReasonPhrase
{
get
;
set
;
}
public
override
bool
Equals
(
HttpLayer
other
)
{
return
Equals
(
other
as
HttpResponseLayer
);
...
...
PcapDotNet/src/PcapDotNet.Packets/Http/HttpTransferEncodingField.cs
View file @
9f094d21
...
...
@@ -53,24 +53,11 @@ namespace PcapDotNet.Packets.Http
string
fieldValueString
=
HttpRegex
.
GetString
(
fieldValue
);
Match
match
=
_regex
.
Match
(
fieldValueString
);
if
(!
match
.
Success
)
{
return
;
// while (!match.Success && fieldValueString.Length > 0)
// {
// fieldValueString = fieldValueString.Substring(0, fieldValueString.Length - 1);
// match = _regex.Match(fieldValueString);
// }
// return;
}
SetTransferCodings
(
match
.
GroupCapturesValues
(
RegexTransferCodingGroupName
).
ToArray
());
}
// protected override string ValueToString()
// {
// return TransferCodings == null ? string.Empty : TransferCodings.SequenceToString(",");
// }
private
ReadOnlyCollection
<
string
>
_transferCodings
;
private
static
readonly
Regex
_transferExtensionRegex
=
HttpRegex
.
Concat
(
HttpRegex
.
Token
,
HttpRegex
.
OptionalParameters
);
...
...
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