Commit 96a2b340 authored by Brickner_cp's avatar Brickner_cp

Warnings, Code Analysis and Documentation. 314 warnings left.

parent 0ad9add1
......@@ -5,6 +5,9 @@
/// </summary>
public enum AddressFamily : ushort
{
/// <summary>
/// No address family defined.
/// </summary>
None = 0,
/// <summary>
......
......@@ -320,6 +320,13 @@ namespace PcapDotNet.Packets
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")]
public static long ReadLong(this byte[] buffer, int offset, Endianity endianity)
{
......@@ -329,6 +336,13 @@ namespace PcapDotNet.Packets
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")]
public static ulong ReadULong(this byte[] buffer, int offset, Endianity endianity)
{
......@@ -350,6 +364,14 @@ namespace PcapDotNet.Packets
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)
{
if (buffer == null)
......@@ -639,6 +661,13 @@ namespace PcapDotNet.Packets
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)
{
if (IsWrongEndianity(endianity))
......@@ -646,6 +675,13 @@ namespace PcapDotNet.Packets
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)
{
buffer.Write(offset, (long)value, endianity);
......@@ -665,6 +701,15 @@ namespace PcapDotNet.Packets
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)
{
if (buffer == null)
......
......@@ -12,6 +12,10 @@ using PcapDotNet.Packets.IpV6;
namespace PcapDotNet.Packets
{
/// <summary>
/// Represents segement of a byte array.
/// Never copies the given buffer.
/// </summary>
public class DataSegment : IEquatable<DataSegment>, IEnumerable<byte>
{
/// <summary>
......@@ -55,8 +59,17 @@ namespace PcapDotNet.Packets
get { return Buffer[StartOffset + offset]; }
}
/// <summary>
/// Returns the last byte of the segment.
/// </summary>
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)
{
return Subsegment(ref offset, length);
......@@ -140,6 +153,9 @@ namespace PcapDotNet.Packets
return encoding.GetString(Buffer, StartOffset, Length);
}
/// <summary>
/// An empty DataSegment.
/// </summary>
public static DataSegment Empty { get { return _empty; } }
internal void Write(byte[] buffer, ref int offset)
......
......@@ -7,6 +7,9 @@
/// </summary>
public enum DnsClass : ushort
{
/// <summary>
/// Represents no class.
/// </summary>
None = 0,
/// <summary>
......
......@@ -218,6 +218,9 @@ namespace PcapDotNet.Packets.Dns
get { return ReadBool(Offset.IsCheckingDisabled, Mask.IsCheckingDisabled); }
}
/// <summary>
/// A response of the server that can sign errors or other messages.
/// </summary>
public DnsResponseCode ResponseCode
{
get { return (DnsResponseCode)(this[Offset.ResponseCode] & Mask.ResponseCode); }
......@@ -255,6 +258,11 @@ namespace PcapDotNet.Packets.Dns
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
{
get
......@@ -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
{
get
......@@ -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
{
get
......@@ -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
{
get
......@@ -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
{
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
{
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
{
get
......@@ -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()
{
if (_isValid == null)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment