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
96a2b340
Commit
96a2b340
authored
Feb 18, 2012
by
Brickner_cp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Warnings, Code Analysis and Documentation. 314 warnings left.
parent
0ad9add1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
100 additions
and
0 deletions
+100
-0
AddressFamily.cs
PcapDotNet/src/PcapDotNet.Packets/AddressFamily.cs
+3
-0
ByteArrayExtensions.cs
PcapDotNet/src/PcapDotNet.Packets/ByteArrayExtensions.cs
+45
-0
DataSegment.cs
PcapDotNet/src/PcapDotNet.Packets/DataSegment.cs
+16
-0
DnsClass.cs
PcapDotNet/src/PcapDotNet.Packets/Dns/DnsClass.cs
+3
-0
DnsDatagram.cs
PcapDotNet/src/PcapDotNet.Packets/Dns/DnsDatagram.cs
+33
-0
No files found.
PcapDotNet/src/PcapDotNet.Packets/AddressFamily.cs
View file @
96a2b340
...
@@ -5,6 +5,9 @@
...
@@ -5,6 +5,9 @@
/// </summary>
/// </summary>
public
enum
AddressFamily
:
ushort
public
enum
AddressFamily
:
ushort
{
{
/// <summary>
/// No address family defined.
/// </summary>
None
=
0
,
None
=
0
,
/// <summary>
/// <summary>
...
...
PcapDotNet/src/PcapDotNet.Packets/ByteArrayExtensions.cs
View file @
96a2b340
...
@@ -320,6 +320,13 @@ namespace PcapDotNet.Packets
...
@@ -320,6 +320,13 @@ namespace PcapDotNet.Packets
return
result
;
return
result
;
}
}
/// <summary>
/// Reads 8 bytes from a specific offset as a long with a given endianity.
/// </summary>
/// <param name="buffer">The buffer to read the bytes from.</param>
/// <param name="offset">The offset in the buffer to start reading.</param>
/// <param name="endianity">The endianity to use to translate the bytes to the value.</param>
/// <returns>The value converted from the read bytes according to the endianity.</returns>
[
System
.
Diagnostics
.
CodeAnalysis
.
SuppressMessage
(
"Microsoft.Naming"
,
"CA1720:IdentifiersShouldNotContainTypeNames"
,
MessageId
=
"long"
)]
[
System
.
Diagnostics
.
CodeAnalysis
.
SuppressMessage
(
"Microsoft.Naming"
,
"CA1720:IdentifiersShouldNotContainTypeNames"
,
MessageId
=
"long"
)]
public
static
long
ReadLong
(
this
byte
[]
buffer
,
int
offset
,
Endianity
endianity
)
public
static
long
ReadLong
(
this
byte
[]
buffer
,
int
offset
,
Endianity
endianity
)
{
{
...
@@ -329,6 +336,13 @@ namespace PcapDotNet.Packets
...
@@ -329,6 +336,13 @@ namespace PcapDotNet.Packets
return
value
;
return
value
;
}
}
/// <summary>
/// Reads 8 bytes from a specific offset as a ulong with a given endianity.
/// </summary>
/// <param name="buffer">The buffer to read the bytes from.</param>
/// <param name="offset">The offset in the buffer to start reading.</param>
/// <param name="endianity">The endianity to use to translate the bytes to the value.</param>
/// <returns>The value converted from the read bytes according to the endianity.</returns>
[
System
.
Diagnostics
.
CodeAnalysis
.
SuppressMessage
(
"Microsoft.Naming"
,
"CA1720:IdentifiersShouldNotContainTypeNames"
,
MessageId
=
"ulong"
)]
[
System
.
Diagnostics
.
CodeAnalysis
.
SuppressMessage
(
"Microsoft.Naming"
,
"CA1720:IdentifiersShouldNotContainTypeNames"
,
MessageId
=
"ulong"
)]
public
static
ulong
ReadULong
(
this
byte
[]
buffer
,
int
offset
,
Endianity
endianity
)
public
static
ulong
ReadULong
(
this
byte
[]
buffer
,
int
offset
,
Endianity
endianity
)
{
{
...
@@ -350,6 +364,14 @@ namespace PcapDotNet.Packets
...
@@ -350,6 +364,14 @@ namespace PcapDotNet.Packets
return
value
;
return
value
;
}
}
/// <summary>
/// Reads a given amount of bytes from a specific offset as an unsigned BigInteger with a given endianity.
/// </summary>
/// <param name="buffer">The buffer to read the bytes from.</param>
/// <param name="offset">The offset in the buffer to start reading.</param>
/// <param name="length">The number of bytes to read.</param>
/// <param name="endianity">The endianity to use to translate the bytes to the value.</param>
/// <returns>The value converted from the read bytes according to the endianity.</returns>
public
static
BigInteger
ReadUnsignedBigInteger
(
this
byte
[]
buffer
,
int
offset
,
int
length
,
Endianity
endianity
)
public
static
BigInteger
ReadUnsignedBigInteger
(
this
byte
[]
buffer
,
int
offset
,
int
length
,
Endianity
endianity
)
{
{
if
(
buffer
==
null
)
if
(
buffer
==
null
)
...
@@ -639,6 +661,13 @@ namespace PcapDotNet.Packets
...
@@ -639,6 +661,13 @@ namespace PcapDotNet.Packets
offset
+=
UInt48
.
SizeOf
;
offset
+=
UInt48
.
SizeOf
;
}
}
/// <summary>
/// Writes the given value to the buffer using the given endianity.
/// </summary>
/// <param name="buffer">The buffer to write the value to.</param>
/// <param name="offset">The offset in the buffer to start writing.</param>
/// <param name="value">The value to write.</param>
/// <param name="endianity">The endianity to use when converting the value to bytes.</param>
public
static
void
Write
(
this
byte
[]
buffer
,
int
offset
,
long
value
,
Endianity
endianity
)
public
static
void
Write
(
this
byte
[]
buffer
,
int
offset
,
long
value
,
Endianity
endianity
)
{
{
if
(
IsWrongEndianity
(
endianity
))
if
(
IsWrongEndianity
(
endianity
))
...
@@ -646,6 +675,13 @@ namespace PcapDotNet.Packets
...
@@ -646,6 +675,13 @@ namespace PcapDotNet.Packets
Write
(
buffer
,
offset
,
value
);
Write
(
buffer
,
offset
,
value
);
}
}
/// <summary>
/// Writes the given value to the buffer using the given endianity.
/// </summary>
/// <param name="buffer">The buffer to write the value to.</param>
/// <param name="offset">The offset in the buffer to start writing.</param>
/// <param name="value">The value to write.</param>
/// <param name="endianity">The endianity to use when converting the value to bytes.</param>
public
static
void
Write
(
this
byte
[]
buffer
,
int
offset
,
ulong
value
,
Endianity
endianity
)
public
static
void
Write
(
this
byte
[]
buffer
,
int
offset
,
ulong
value
,
Endianity
endianity
)
{
{
buffer
.
Write
(
offset
,
(
long
)
value
,
endianity
);
buffer
.
Write
(
offset
,
(
long
)
value
,
endianity
);
...
@@ -665,6 +701,15 @@ namespace PcapDotNet.Packets
...
@@ -665,6 +701,15 @@ namespace PcapDotNet.Packets
Write
(
buffer
,
offset
,
value
);
Write
(
buffer
,
offset
,
value
);
}
}
/// <summary>
/// Writes the given amount of least significant bytes of the value to the buffer using the given endianity.
/// Doesn't write leading zero bytes.
/// </summary>
/// <param name="buffer">The buffer to write the value to.</param>
/// <param name="offset">The offset in the buffer to start writing.</param>
/// <param name="value">The value to write.</param>
/// <param name="length">The maximum amount of bytes to write.</param>
/// <param name="endianity">The endianity to use when converting the value to bytes.</param>
public
static
void
WriteUnsigned
(
this
byte
[]
buffer
,
int
offset
,
BigInteger
value
,
int
length
,
Endianity
endianity
)
public
static
void
WriteUnsigned
(
this
byte
[]
buffer
,
int
offset
,
BigInteger
value
,
int
length
,
Endianity
endianity
)
{
{
if
(
buffer
==
null
)
if
(
buffer
==
null
)
...
...
PcapDotNet/src/PcapDotNet.Packets/DataSegment.cs
View file @
96a2b340
...
@@ -12,6 +12,10 @@ using PcapDotNet.Packets.IpV6;
...
@@ -12,6 +12,10 @@ using PcapDotNet.Packets.IpV6;
namespace
PcapDotNet.Packets
namespace
PcapDotNet.Packets
{
{
/// <summary>
/// Represents segement of a byte array.
/// Never copies the given buffer.
/// </summary>
public
class
DataSegment
:
IEquatable
<
DataSegment
>,
IEnumerable
<
byte
>
public
class
DataSegment
:
IEquatable
<
DataSegment
>,
IEnumerable
<
byte
>
{
{
/// <summary>
/// <summary>
...
@@ -55,8 +59,17 @@ namespace PcapDotNet.Packets
...
@@ -55,8 +59,17 @@ namespace PcapDotNet.Packets
get
{
return
Buffer
[
StartOffset
+
offset
];
}
get
{
return
Buffer
[
StartOffset
+
offset
];
}
}
}
/// <summary>
/// Returns the last byte of the segment.
/// </summary>
public
byte
Last
{
get
{
return
this
[
Length
-
1
];
}
}
public
byte
Last
{
get
{
return
this
[
Length
-
1
];
}
}
/// <summary>
/// Creates a subsegment starting from a given offset in the segment taking a given number of bytes.
/// </summary>
/// <param name="offset">The offset in the segment to start taking.</param>
/// <param name="length">The number of bytes to take from the segment.</param>
/// <returns>A new DataSegment that is part of the given DataSegment.</returns>
public
DataSegment
Subsegment
(
int
offset
,
int
length
)
public
DataSegment
Subsegment
(
int
offset
,
int
length
)
{
{
return
Subsegment
(
ref
offset
,
length
);
return
Subsegment
(
ref
offset
,
length
);
...
@@ -140,6 +153,9 @@ namespace PcapDotNet.Packets
...
@@ -140,6 +153,9 @@ namespace PcapDotNet.Packets
return
encoding
.
GetString
(
Buffer
,
StartOffset
,
Length
);
return
encoding
.
GetString
(
Buffer
,
StartOffset
,
Length
);
}
}
/// <summary>
/// An empty DataSegment.
/// </summary>
public
static
DataSegment
Empty
{
get
{
return
_empty
;
}
}
public
static
DataSegment
Empty
{
get
{
return
_empty
;
}
}
internal
void
Write
(
byte
[]
buffer
,
ref
int
offset
)
internal
void
Write
(
byte
[]
buffer
,
ref
int
offset
)
...
...
PcapDotNet/src/PcapDotNet.Packets/Dns/DnsClass.cs
View file @
96a2b340
...
@@ -7,6 +7,9 @@
...
@@ -7,6 +7,9 @@
/// </summary>
/// </summary>
public
enum
DnsClass
:
ushort
public
enum
DnsClass
:
ushort
{
{
/// <summary>
/// Represents no class.
/// </summary>
None
=
0
,
None
=
0
,
/// <summary>
/// <summary>
...
...
PcapDotNet/src/PcapDotNet.Packets/Dns/DnsDatagram.cs
View file @
96a2b340
...
@@ -218,6 +218,9 @@ namespace PcapDotNet.Packets.Dns
...
@@ -218,6 +218,9 @@ namespace PcapDotNet.Packets.Dns
get
{
return
ReadBool
(
Offset
.
IsCheckingDisabled
,
Mask
.
IsCheckingDisabled
);
}
get
{
return
ReadBool
(
Offset
.
IsCheckingDisabled
,
Mask
.
IsCheckingDisabled
);
}
}
}
/// <summary>
/// A response of the server that can sign errors or other messages.
/// </summary>
public
DnsResponseCode
ResponseCode
public
DnsResponseCode
ResponseCode
{
{
get
{
return
(
DnsResponseCode
)(
this
[
Offset
.
ResponseCode
]
&
Mask
.
ResponseCode
);
}
get
{
return
(
DnsResponseCode
)(
this
[
Offset
.
ResponseCode
]
&
Mask
.
ResponseCode
);
}
...
@@ -255,6 +258,11 @@ namespace PcapDotNet.Packets.Dns
...
@@ -255,6 +258,11 @@ namespace PcapDotNet.Packets.Dns
get
{
return
ReadUShort
(
Offset
.
AdditionalCount
,
Endianity
.
Big
);
}
get
{
return
ReadUShort
(
Offset
.
AdditionalCount
,
Endianity
.
Big
);
}
}
}
/// <summary>
/// The queries resource records.
/// The amount of records here should be equal to <see cref="QueryCount"/>.
/// Typically exactly one query will exist.
/// </summary>
public
ReadOnlyCollection
<
DnsQueryResourceRecord
>
Queries
public
ReadOnlyCollection
<
DnsQueryResourceRecord
>
Queries
{
{
get
get
...
@@ -264,6 +272,10 @@ namespace PcapDotNet.Packets.Dns
...
@@ -264,6 +272,10 @@ namespace PcapDotNet.Packets.Dns
}
}
}
}
/// <summary>
/// The answers resource records.
/// The amount of records here should be equal to <see cref="AnswerCount"/>.
/// </summary>
public
ReadOnlyCollection
<
DnsDataResourceRecord
>
Answers
public
ReadOnlyCollection
<
DnsDataResourceRecord
>
Answers
{
{
get
get
...
@@ -273,6 +285,10 @@ namespace PcapDotNet.Packets.Dns
...
@@ -273,6 +285,10 @@ namespace PcapDotNet.Packets.Dns
}
}
}
}
/// <summary>
/// The authorities resource records.
/// The amount of records here should be equal to <see cref="AuthorityCount"/>.
/// </summary>
public
ReadOnlyCollection
<
DnsDataResourceRecord
>
Authorities
public
ReadOnlyCollection
<
DnsDataResourceRecord
>
Authorities
{
{
get
get
...
@@ -282,6 +298,10 @@ namespace PcapDotNet.Packets.Dns
...
@@ -282,6 +298,10 @@ namespace PcapDotNet.Packets.Dns
}
}
}
}
/// <summary>
/// The additionals resource records.
/// The amount of records here should be equal to <see cref="AdditionalCount"/>.
/// </summary>
public
ReadOnlyCollection
<
DnsDataResourceRecord
>
Additionals
public
ReadOnlyCollection
<
DnsDataResourceRecord
>
Additionals
{
{
get
get
...
@@ -291,16 +311,26 @@ namespace PcapDotNet.Packets.Dns
...
@@ -291,16 +311,26 @@ namespace PcapDotNet.Packets.Dns
}
}
}
}
/// <summary>
/// All the resource records in the datagram by order of appearance.
/// </summary>
public
IEnumerable
<
DnsResourceRecord
>
ResourceRecords
public
IEnumerable
<
DnsResourceRecord
>
ResourceRecords
{
{
get
{
return
Queries
.
Cast
<
DnsResourceRecord
>().
Concat
(
DataResourceRecords
);
}
get
{
return
Queries
.
Cast
<
DnsResourceRecord
>().
Concat
(
DataResourceRecords
);
}
}
}
/// <summary>
/// All the data resource records (all resource records but the queries) in the datagram by order of appearance.
/// </summary>
public
IEnumerable
<
DnsDataResourceRecord
>
DataResourceRecords
public
IEnumerable
<
DnsDataResourceRecord
>
DataResourceRecords
{
{
get
{
return
Answers
.
Concat
(
Authorities
).
Concat
(
Additionals
);
}
get
{
return
Answers
.
Concat
(
Authorities
).
Concat
(
Additionals
);
}
}
}
/// <summary>
/// The special OPT resource record.
/// This takes the first OPT resource record in additional section.
/// </summary>
public
DnsOptResourceRecord
OptionsRecord
public
DnsOptResourceRecord
OptionsRecord
{
{
get
get
...
@@ -335,6 +365,9 @@ namespace PcapDotNet.Packets.Dns
...
@@ -335,6 +365,9 @@ namespace PcapDotNet.Packets.Dns
};
};
}
}
/// <summary>
/// A DNS datagram is valid if parsing of all sections was successful.
/// </summary>
protected
override
bool
CalculateIsValid
()
protected
override
bool
CalculateIsValid
()
{
{
if
(
_isValid
==
null
)
if
(
_isValid
==
null
)
...
...
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