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
7304ac50
Commit
7304ac50
authored
Feb 11, 2012
by
Brickner_cp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Warnings, Code Analysis and Documentation. 444 warnings left.
parent
938da66c
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
37 additions
and
39 deletions
+37
-39
UInt128.cs
PcapDotNet/src/PcapDotNet.Base/UInt128.cs
+11
-10
OfflinePacketCommunicator.cpp
PcapDotNet/src/PcapDotNet.Core/OfflinePacketCommunicator.cpp
+6
-2
OfflinePacketCommunicator.h
PcapDotNet/src/PcapDotNet.Core/OfflinePacketCommunicator.h
+1
-1
DnsDataResourceRecord.cs
...otNet/src/PcapDotNet.Packets/Dns/DnsDataResourceRecord.cs
+3
-3
DnsDatagram.cs
PcapDotNet/src/PcapDotNet.Packets/Dns/DnsDatagram.cs
+2
-7
DnsDomainNameCompressionData.cs
...rc/PcapDotNet.Packets/Dns/DnsDomainNameCompressionData.cs
+2
-2
DnsLayer.cs
PcapDotNet/src/PcapDotNet.Packets/Dns/DnsLayer.cs
+9
-9
ListSegment.cs
PcapDotNet/src/PcapDotNet.Packets/Dns/ListSegment.cs
+1
-3
DnsResourceData.cs
...rc/PcapDotNet.Packets/Dns/ResourceData/DnsResourceData.cs
+1
-1
DnsTypeRegistrationAttribute.cs
....Packets/Dns/ResourceData/DnsTypeRegistrationAttribute.cs
+1
-1
No files found.
PcapDotNet/src/PcapDotNet.Base/UInt128.cs
View file @
7304ac50
...
@@ -9,7 +9,7 @@ namespace PcapDotNet.Base
...
@@ -9,7 +9,7 @@ namespace PcapDotNet.Base
/// A 128 bit unsigned integer.
/// A 128 bit unsigned integer.
/// </summary>
/// </summary>
[
StructLayout
(
LayoutKind
.
Sequential
,
Pack
=
1
)]
[
StructLayout
(
LayoutKind
.
Sequential
,
Pack
=
1
)]
public
struct
UInt128
:
IEquatable
<
UInt128
>,
IFormattable
public
struct
UInt128
:
I
Comparable
<
UInt128
>,
I
Equatable
<
UInt128
>,
IFormattable
{
{
/// <summary>
/// <summary>
/// The number of bytes this type will take.
/// The number of bytes this type will take.
...
@@ -361,10 +361,11 @@ namespace PcapDotNet.Base
...
@@ -361,10 +361,11 @@ namespace PcapDotNet.Base
Equals
((
UInt128
)
obj
);
Equals
((
UInt128
)
obj
);
}
}
public
bool
Smaller
(
UInt128
other
)
public
int
CompareTo
(
UInt128
other
)
{
{
return
_mostSignificant
<
other
.
_mostSignificant
||
if
(
_mostSignificant
!=
other
.
_mostSignificant
)
_mostSignificant
==
other
.
_mostSignificant
&&
_leastSignificant
<
other
.
_leastSignificant
;
return
_mostSignificant
.
CompareTo
(
other
.
_mostSignificant
);
return
_leastSignificant
.
CompareTo
(
other
.
_leastSignificant
);
}
}
/// <summary>
/// <summary>
...
@@ -391,22 +392,22 @@ namespace PcapDotNet.Base
...
@@ -391,22 +392,22 @@ namespace PcapDotNet.Base
public
static
bool
operator
<(
UInt128
value1
,
UInt128
value2
)
public
static
bool
operator
<(
UInt128
value1
,
UInt128
value2
)
{
{
return
value1
.
Smaller
(
value2
)
;
return
value1
.
CompareTo
(
value2
)
<
0
;
}
}
public
static
bool
operator
>(
UInt128
value1
,
UInt128
value2
)
public
static
bool
operator
>(
UInt128
value1
,
UInt128
value2
)
{
{
return
value
2
.
Smaller
(
value1
)
;
return
value
1
.
CompareTo
(
value2
)
>
0
;
}
}
public
static
bool
operator
<=(
UInt128
value1
,
UInt128
value2
)
public
static
bool
operator
<=(
UInt128
value1
,
UInt128
value2
)
{
{
return
!
value2
.
Smaller
(
value1
)
;
return
value1
.
CompareTo
(
value2
)
<=
0
;
}
}
public
static
bool
operator
>=(
UInt128
value1
,
UInt128
value2
)
public
static
bool
operator
>=(
UInt128
value1
,
UInt128
value2
)
{
{
return
!
value1
.
Smaller
(
value2
)
;
return
value1
.
CompareTo
(
value2
)
>=
0
;
}
}
/// <summary>
/// <summary>
...
@@ -488,10 +489,10 @@ namespace PcapDotNet.Base
...
@@ -488,10 +489,10 @@ namespace PcapDotNet.Base
public
static
UInt128
operator
+(
UInt128
value1
,
UInt128
value2
)
public
static
UInt128
operator
+(
UInt128
value1
,
UInt128
value2
)
{
{
return
Sum
(
value1
,
value2
);
return
Add
(
value1
,
value2
);
}
}
public
static
UInt128
Sum
(
UInt128
value1
,
UInt128
value2
)
public
static
UInt128
Add
(
UInt128
value1
,
UInt128
value2
)
{
{
ulong
leastSignificant
=
value1
.
_leastSignificant
+
value2
.
_leastSignificant
;
ulong
leastSignificant
=
value1
.
_leastSignificant
+
value2
.
_leastSignificant
;
bool
overflow
=
(
leastSignificant
<
Math
.
Max
(
value1
.
_leastSignificant
,
value2
.
_leastSignificant
));
bool
overflow
=
(
leastSignificant
<
Math
.
Max
(
value1
.
_leastSignificant
,
value2
.
_leastSignificant
));
...
...
PcapDotNet/src/PcapDotNet.Core/OfflinePacketCommunicator.cpp
View file @
7304ac50
...
@@ -24,6 +24,7 @@ OfflinePacketCommunicator::OfflinePacketCommunicator(String^ filename)
...
@@ -24,6 +24,7 @@ OfflinePacketCommunicator::OfflinePacketCommunicator(String^ filename)
// Private
// Private
// static
pcap_t
*
OfflinePacketCommunicator
::
OpenFile
(
String
^
fileName
)
pcap_t
*
OfflinePacketCommunicator
::
OpenFile
(
String
^
fileName
)
{
{
std
::
wstring
unamangedFilename
=
MarshalingServices
::
ManagedToUnmanagedWideString
(
fileName
);
std
::
wstring
unamangedFilename
=
MarshalingServices
::
ManagedToUnmanagedWideString
(
fileName
);
...
@@ -35,8 +36,11 @@ pcap_t* OfflinePacketCommunicator::OpenFile(String^ fileName)
...
@@ -35,8 +36,11 @@ pcap_t* OfflinePacketCommunicator::OpenFile(String^ fileName)
pcap_t
*
pcapDescriptor
=
pcap_fopen_offline
(
file
,
errorBuffer
);
pcap_t
*
pcapDescriptor
=
pcap_fopen_offline
(
file
,
errorBuffer
);
if
(
pcapDescriptor
==
NULL
)
if
(
pcapDescriptor
==
NULL
)
{
{
fclose
(
file
);
int
fcloseResult
=
fclose
(
file
);
throw
gcnew
InvalidOperationException
(
String
::
Format
(
CultureInfo
::
InvariantCulture
,
"Failed opening file {0}. Error: {1}"
,
fileName
,
gcnew
String
(
errorBuffer
)));
String
^
errorMessage
=
String
::
Format
(
CultureInfo
::
InvariantCulture
,
"Failed opening file {0}. Error: {1}."
,
fileName
,
gcnew
String
(
errorBuffer
));
if
(
fcloseResult
!=
0
)
errorMessage
+=
" Also failed closing the file."
;
throw
gcnew
InvalidOperationException
(
errorMessage
);
}
}
return
pcapDescriptor
;
return
pcapDescriptor
;
...
...
PcapDotNet/src/PcapDotNet.Core/OfflinePacketCommunicator.h
View file @
7304ac50
...
@@ -28,6 +28,6 @@ namespace PcapDotNet { namespace Core
...
@@ -28,6 +28,6 @@ namespace PcapDotNet { namespace Core
OfflinePacketCommunicator
(
System
::
String
^
fileName
);
OfflinePacketCommunicator
(
System
::
String
^
fileName
);
private
:
private
:
pcap_t
*
OpenFile
(
System
::
String
^
filename
);
static
pcap_t
*
OpenFile
(
System
::
String
^
filename
);
};
};
}}
}}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/Dns/DnsDataResourceRecord.cs
View file @
7304ac50
...
@@ -27,14 +27,14 @@ namespace PcapDotNet.Packets.Dns
...
@@ -27,14 +27,14 @@ namespace PcapDotNet.Packets.Dns
/// For example, SOA records are always distributed with a zero TTL to prohibit caching.
/// For example, SOA records are always distributed with a zero TTL to prohibit caching.
/// Zero values can also be used for extremely volatile data.
/// Zero values can also be used for extremely volatile data.
/// </summary>
/// </summary>
public
override
int
Ttl
{
get
;
protected
set
;
}
public
override
sealed
int
Ttl
{
get
;
protected
set
;
}
/// <summary>
/// <summary>
/// A variable length string of octets that describes the resource.
/// A variable length string of octets that describes the resource.
/// The format of this information varies according to the TYPE and CLASS of the resource record.
/// The format of this information varies according to the TYPE and CLASS of the resource record.
/// For example, the if the TYPE is A and the CLASS is IN, the RDATA field is a 4 octet ARPA Internet address.
/// For example, the if the TYPE is A and the CLASS is IN, the RDATA field is a 4 octet ARPA Internet address.
/// </summary>
/// </summary>
public
override
DnsResourceData
Data
{
get
;
protected
set
;
}
public
override
sealed
DnsResourceData
Data
{
get
;
protected
set
;
}
public
override
string
ToString
()
public
override
string
ToString
()
{
{
...
@@ -75,7 +75,7 @@ namespace PcapDotNet.Packets.Dns
...
@@ -75,7 +75,7 @@ namespace PcapDotNet.Packets.Dns
numBytesRead
+=
MinimumLengthAfterBase
;
numBytesRead
+=
MinimumLengthAfterBase
;
if
(
offsetInDns
+
numBytesRead
+
dataLength
>
dns
.
Length
)
if
(
offsetInDns
+
numBytesRead
+
dataLength
>
dns
.
Length
)
return
null
;
return
null
;
DnsResourceData
data
=
DnsResourceData
.
Read
(
dns
,
type
,
dnsClass
,
offsetInDns
+
numBytesRead
,
dataLength
);
DnsResourceData
data
=
DnsResourceData
.
Read
(
dns
,
type
,
offsetInDns
+
numBytesRead
,
dataLength
);
if
(
data
==
null
)
if
(
data
==
null
)
return
null
;
return
null
;
numBytesRead
+=
dataLength
;
numBytesRead
+=
dataLength
;
...
...
PcapDotNet/src/PcapDotNet.Packets/Dns/DnsDatagram.cs
View file @
7304ac50
...
@@ -88,7 +88,7 @@ namespace PcapDotNet.Packets.Dns
...
@@ -88,7 +88,7 @@ namespace PcapDotNet.Packets.Dns
/// <summary>
/// <summary>
/// The number of bytes the DNS header takes.
/// The number of bytes the DNS header takes.
/// </summary>
/// </summary>
public
const
int
HeaderLength
=
12
;
public
const
int
HeaderLength
=
Offset
.
Query
;
/// <summary>
/// <summary>
/// A 16 bit identifier assigned by the program that generates any kind of query.
/// A 16 bit identifier assigned by the program that generates any kind of query.
...
@@ -424,11 +424,6 @@ namespace PcapDotNet.Packets.Dns
...
@@ -424,11 +424,6 @@ namespace PcapDotNet.Packets.Dns
}
}
}
}
private
int
QueriesOffset
{
get
{
return
HeaderLength
;
}
}
private
int
AnswersOffset
private
int
AnswersOffset
{
{
get
get
...
@@ -458,7 +453,7 @@ namespace PcapDotNet.Packets.Dns
...
@@ -458,7 +453,7 @@ namespace PcapDotNet.Packets.Dns
private
void
ParseQueries
()
private
void
ParseQueries
()
{
{
ParseRecords
(
QueriesOffset
,
()
=>
QueryCount
,
DnsQueryResourceRecord
.
Parse
,
ref
_queries
,
ref
_answersOffset
);
ParseRecords
(
Offset
.
Query
,
()
=>
QueryCount
,
DnsQueryResourceRecord
.
Parse
,
ref
_queries
,
ref
_answersOffset
);
}
}
private
void
ParseAnswers
()
private
void
ParseAnswers
()
...
...
PcapDotNet/src/PcapDotNet.Packets/Dns/DnsDomainNameCompressionData.cs
View file @
7304ac50
...
@@ -31,7 +31,7 @@ namespace PcapDotNet.Packets.Dns
...
@@ -31,7 +31,7 @@ namespace PcapDotNet.Packets.Dns
offsetInDns
=
0
;
offsetInDns
=
0
;
return
false
;
return
false
;
default
:
default
:
throw
new
InvalidOperationException
(
string
.
Format
(
CultureInfo
.
InvariantCulture
,
"Invalid Domain
NameCompression
Mode {0}"
,
throw
new
InvalidOperationException
(
string
.
Format
(
CultureInfo
.
InvariantCulture
,
"Invalid Domain
Name Compression
Mode {0}"
,
DomainNameCompressionMode
));
DomainNameCompressionMode
));
}
}
}
}
...
@@ -50,7 +50,7 @@ namespace PcapDotNet.Packets.Dns
...
@@ -50,7 +50,7 @@ namespace PcapDotNet.Packets.Dns
case
DnsDomainNameCompressionMode
.
Nothing
:
case
DnsDomainNameCompressionMode
.
Nothing
:
return
;
return
;
default
:
default
:
throw
new
InvalidOperationException
(
string
.
Format
(
CultureInfo
.
InvariantCulture
,
"Invalid Domain
NameCompression
Mode {0}"
,
throw
new
InvalidOperationException
(
string
.
Format
(
CultureInfo
.
InvariantCulture
,
"Invalid Domain
Name Compression
Mode {0}"
,
DomainNameCompressionMode
));
DomainNameCompressionMode
));
}
}
}
}
...
...
PcapDotNet/src/PcapDotNet.Packets/Dns/DnsLayer.cs
View file @
7304ac50
...
@@ -38,25 +38,25 @@ namespace PcapDotNet.Packets.Dns
...
@@ -38,25 +38,25 @@ namespace PcapDotNet.Packets.Dns
public
DnsResponseCode
ResponseCode
{
get
;
set
;
}
public
DnsResponseCode
ResponseCode
{
get
;
set
;
}
[
System
.
Diagnostics
.
CodeAnalysis
.
SuppressMessage
(
"Microsoft.Usage"
,
"CA2227:CollectionPropertiesShouldBeReadOnly"
)]
public
IList
<
DnsQueryResourceRecord
>
Queries
{
get
;
set
;
}
public
IList
<
DnsQueryResourceRecord
>
Queries
{
get
;
set
;
}
[
System
.
Diagnostics
.
CodeAnalysis
.
SuppressMessage
(
"Microsoft.Usage"
,
"CA2227:CollectionPropertiesShouldBeReadOnly"
)]
public
IList
<
DnsDataResourceRecord
>
Answers
{
get
;
set
;
}
public
IList
<
DnsDataResourceRecord
>
Answers
{
get
;
set
;
}
[
System
.
Diagnostics
.
CodeAnalysis
.
SuppressMessage
(
"Microsoft.Usage"
,
"CA2227:CollectionPropertiesShouldBeReadOnly"
)]
public
IList
<
DnsDataResourceRecord
>
Authorities
{
get
;
set
;
}
public
IList
<
DnsDataResourceRecord
>
Authorities
{
get
;
set
;
}
[
System
.
Diagnostics
.
CodeAnalysis
.
SuppressMessage
(
"Microsoft.Usage"
,
"CA2227:CollectionPropertiesShouldBeReadOnly"
)]
public
IList
<
DnsDataResourceRecord
>
Additionals
{
get
;
set
;
}
public
IList
<
DnsDataResourceRecord
>
Additionals
{
get
;
set
;
}
public
IEnumerable
<
DnsResourceRecord
>
Records
public
IEnumerable
<
DnsResourceRecord
>
Re
sourceRe
cords
{
{
get
get
{
{
IEnumerable
<
DnsResourceRecord
>
allRecords
=
null
;
return
new
IEnumerable
<
DnsResourceRecord
>[]
{
Queries
,
Answers
,
Authorities
,
Additionals
}
foreach
(
IEnumerable
<
DnsResourceRecord
>
records
in
new
IEnumerable
<
DnsResourceRecord
>[]
{
Queries
,
Answers
,
Authorities
,
Additionals
})
.
Where
(
records
=>
records
!=
null
).
Aggregate
<
IEnumerable
<
DnsResourceRecord
>,
IEnumerable
<
DnsResourceRecord
>>(
{
null
,
(
current
,
records
)
=>
current
==
null
?
records
:
current
.
Concat
(
records
));
if
(
records
!=
null
)
allRecords
=
allRecords
==
null
?
records
:
allRecords
.
Concat
(
records
);
}
return
allRecords
;
}
}
}
}
...
@@ -69,7 +69,7 @@ namespace PcapDotNet.Packets.Dns
...
@@ -69,7 +69,7 @@ namespace PcapDotNet.Packets.Dns
{
{
get
get
{
{
return
DnsDatagram
.
GetLength
(
Records
,
DomainNameCompressionMode
);
return
DnsDatagram
.
GetLength
(
Re
sourceRe
cords
,
DomainNameCompressionMode
);
}
}
}
}
...
...
PcapDotNet/src/PcapDotNet.Packets/Dns/ListSegment.cs
View file @
7304ac50
using
System
;
using
System.Collections
;
using
System.Collections
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Linq
;
...
@@ -36,7 +35,6 @@ namespace PcapDotNet.Packets.Dns
...
@@ -36,7 +35,6 @@ namespace PcapDotNet.Packets.Dns
public
T
this
[
int
index
]
public
T
this
[
int
index
]
{
{
get
{
return
_data
[
_startIndex
+
index
];
}
get
{
return
_data
[
_startIndex
+
index
];
}
set
{
throw
new
NotSupportedException
(
"ListSegment<T> is read-only"
);
}
}
}
private
readonly
IList
<
T
>
_data
;
private
readonly
IList
<
T
>
_data
;
...
...
PcapDotNet/src/PcapDotNet.Packets/Dns/ResourceData/DnsResourceData.cs
View file @
7304ac50
...
@@ -32,7 +32,7 @@ namespace PcapDotNet.Packets.Dns
...
@@ -32,7 +32,7 @@ namespace PcapDotNet.Packets.Dns
internal
abstract
int
WriteData
(
byte
[]
buffer
,
int
dnsOffset
,
int
offsetInDns
,
DnsDomainNameCompressionData
compressionData
);
internal
abstract
int
WriteData
(
byte
[]
buffer
,
int
dnsOffset
,
int
offsetInDns
,
DnsDomainNameCompressionData
compressionData
);
internal
static
DnsResourceData
Read
(
DnsDatagram
dns
,
DnsType
type
,
DnsClass
dnsClass
,
int
offsetInDns
,
int
length
)
internal
static
DnsResourceData
Read
(
DnsDatagram
dns
,
DnsType
type
,
int
offsetInDns
,
int
length
)
{
{
DnsResourceData
prototype
=
TryGetPrototype
(
type
);
DnsResourceData
prototype
=
TryGetPrototype
(
type
);
if
(
prototype
!=
null
)
if
(
prototype
!=
null
)
...
...
PcapDotNet/src/PcapDotNet.Packets/Dns/ResourceData/DnsTypeRegistrationAttribute.cs
View file @
7304ac50
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
namespace
PcapDotNet.Packets.Dns
namespace
PcapDotNet.Packets.Dns
{
{
[
AttributeUsage
(
AttributeTargets
.
Class
,
AllowMultiple
=
true
)]
[
AttributeUsage
(
AttributeTargets
.
Class
,
AllowMultiple
=
true
)]
internal
class
DnsTypeRegistrationAttribute
:
Attribute
internal
sealed
class
DnsTypeRegistrationAttribute
:
Attribute
{
{
public
DnsType
Type
{
get
;
set
;
}
public
DnsType
Type
{
get
;
set
;
}
}
}
...
...
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