Commit 28625c92 authored by Brickner_cp's avatar Brickner_cp

Refactoring - make all IOptionComplexFactory.CreateInstance() implementations internal

parent 0808ef5b
...@@ -563,44 +563,6 @@ namespace PcapDotNet.Packets.Test ...@@ -563,44 +563,6 @@ namespace PcapDotNet.Packets.Test
Assert.IsNotNull(layer.GetHashCode()); Assert.IsNotNull(layer.GetHashCode());
} }
[TestMethod]
[ExpectedException(typeof(ArgumentNullException), AllowDerivedTypes = false)]
public void IpV4OptionQuickStartCreateInstanceNullBufferTest()
{
int offset = 0;
Assert.IsNotNull(new IpV4OptionQuickStart().CreateInstance(null, ref offset, 0));
}
[TestMethod]
[ExpectedException(typeof(ArgumentNullException), AllowDerivedTypes = false)]
public void IpV4OptionBasicSecurityCreateInstanceNullBufferTest()
{
int offset = 0;
Assert.IsNotNull(new IpV4OptionBasicSecurity().CreateInstance(null, ref offset, 0));
Assert.Fail();
}
[TestMethod]
[ExpectedException(typeof(ArgumentNullException), AllowDerivedTypes = false)]
public void IpV4OptionLooseSourceRoutingCreateInstanceNullBufferTest()
{
int offset = 0;
Assert.IsNotNull(new IpV4OptionLooseSourceRouting().CreateInstance(null, ref offset, 0));
Assert.Fail();
}
[TestMethod]
public void IpV4OptionCreateInstanceBadValueLengthTest()
{
int offset = 0;
Assert.IsNull(new IpV4OptionQuickStart().CreateInstance(new byte[0], ref offset, 0));
Assert.IsNull(new IpV4OptionTraceRoute().CreateInstance(new byte[0], ref offset, 123));
Assert.IsNull(new IpV4OptionRecordRoute().CreateInstance(new byte[0], ref offset, 0));
Assert.IsNull(new IpV4OptionRouterAlert().CreateInstance(new byte[0], ref offset, 123));
Assert.IsNull(new IpV4OptionStreamIdentifier().CreateInstance(new byte[0], ref offset, 123));
Assert.IsNull(new IpV4OptionStrictSourceRouting().CreateInstance(new byte[0], ref offset, 0));
}
private static Packet HexToPacket(string hexString, DataLinkKind dataLinkKind) private static Packet HexToPacket(string hexString, DataLinkKind dataLinkKind)
{ {
return Packet.FromHexadecimalString(hexString, DateTime.MinValue, dataLinkKind); return Packet.FromHexadecimalString(hexString, DateTime.MinValue, dataLinkKind);
......
...@@ -180,19 +180,5 @@ namespace PcapDotNet.Packets.Test ...@@ -180,19 +180,5 @@ namespace PcapDotNet.Packets.Test
Assert.IsNotNull(new TcpOptionMd5Signature(null)); Assert.IsNotNull(new TcpOptionMd5Signature(null));
Assert.Fail(); Assert.Fail();
} }
[TestMethod]
public void TcpOptionCreateInstanceBadValueLengthTest()
{
int offset = 0;
Assert.IsNull(new TcpOptionPartialOrderServiceProfile().CreateInstance(new byte[0], ref offset, 123));
Assert.IsNull(new TcpOptionTimestamp().CreateInstance(new byte[0], ref offset, 123));
Assert.IsNull(new TcpOptionAlternateChecksumRequest().CreateInstance(new byte[0], ref offset, 123));
Assert.IsNull(new TcpOptionConnectionCount().CreateInstance(new byte[0], ref offset, 123));
Assert.IsNull(new TcpOptionConnectionCountEcho().CreateInstance(new byte[0], ref offset, 123));
Assert.IsNull(new TcpOptionEcho().CreateInstance(new byte[0], ref offset, 123));
Assert.IsNull(new TcpOptionSelectiveAcknowledgment().CreateInstance(new byte[0], ref offset, 1));
Assert.IsNull(new TcpOptionWindowScale().CreateInstance(new byte[0], ref offset, 123));
}
} }
} }
\ No newline at end of file
...@@ -189,69 +189,6 @@ namespace PcapDotNet.Packets.Icmp ...@@ -189,69 +189,6 @@ namespace PcapDotNet.Packets.Icmp
IcmpMessageType messageType = (IcmpMessageType)buffer[offset + Offset.Type]; IcmpMessageType messageType = (IcmpMessageType)buffer[offset + Offset.Type];
return IcmpDatagramFactory.CreateInstance(messageType, buffer, offset, length); return IcmpDatagramFactory.CreateInstance(messageType, buffer, offset, length);
// switch (messageType)
// {
// case IcmpMessageType.DestinationUnreachable:
// return new IcmpDestinationUnreachableDatagram(buffer, offset, length);
//
// case IcmpMessageType.TimeExceeded:
// return new IcmpTimeExceededDatagram(buffer, offset, length);
//
// case IcmpMessageType.SourceQuench:
// return new IcmpSourceQuenchDatagram(buffer, offset, length);
//
// case IcmpMessageType.ParameterProblem:
// return new IcmpParameterProblemDatagram(buffer, offset, length);
//
// case IcmpMessageType.Redirect:
// return new IcmpRedirectDatagram(buffer, offset, length);
//
// case IcmpMessageType.Echo:
// return new IcmpEchoDatagram(buffer, offset, length);
//
// case IcmpMessageType.EchoReply:
// return new IcmpEchoReplyDatagram(buffer, offset, length);
//
// case IcmpMessageType.Timestamp:
// return new IcmpTimestampDatagram(buffer, offset, length);
//
// case IcmpMessageType.TimestampReply:
// return new IcmpTimestampReplyDatagram(buffer, offset, length);
//
// case IcmpMessageType.InformationRequest:
// return new IcmpInformationRequestDatagram(buffer, offset, length);
//
// case IcmpMessageType.InformationReply:
// return new IcmpInformationReplyDatagram(buffer, offset, length);
//
// case IcmpMessageType.DomainNameRequest:
// return new IcmpDomainNameRequestDatagram(buffer, offset, length);
//
// case IcmpMessageType.RouterAdvertisement:
// return new IcmpRouterAdvertisementDatagram(buffer, offset, length);
//
// case IcmpMessageType.AddressMaskRequest:
// return new IcmpAddressMaskRequestDatagram(buffer, offset, length);
//
// case IcmpMessageType.AddressMaskReply:
// return new IcmpAddressMaskReplyDatagram(buffer, offset, length);
//
// case IcmpMessageType.TraceRoute:
// return new IcmpTraceRouteDatagram(buffer, offset, length);
//
// case IcmpMessageType.ConversionFailed:
// return new IcmpConversionFailedDatagram(buffer, offset, length);
//
// case IcmpMessageType.SecurityFailures:
// return new IcmpSecurityFailuresDatagram(buffer, offset, length);
//
// case IcmpMessageType.RouterSolicitation:
// return new IcmpRouterSolicitationDatagram(buffer, offset, length);
//
// case IcmpMessageType.DomainNameReply: // Domain Name Reply is unsupported
// default:
// return new IcmpUnknownDatagram(buffer, offset, length);
// }
} }
internal abstract IcmpDatagram CreateInstance(byte[] buffer, int offset, int length); internal abstract IcmpDatagram CreateInstance(byte[] buffer, int offset, int length);
......
...@@ -186,10 +186,10 @@ namespace PcapDotNet.Packets.IpV4 ...@@ -186,10 +186,10 @@ namespace PcapDotNet.Packets.IpV4
/// <param name="offset">The offset to the first byte to read the buffer. Will be incremented by the number of bytes read.</param> /// <param name="offset">The offset to the first byte to read the buffer. Will be incremented by the number of bytes read.</param>
/// <param name="valueLength">The number of bytes the option value should take according to the length field that was already read.</param> /// <param name="valueLength">The number of bytes the option value should take according to the length field that was already read.</param>
/// <returns>On success - the complex option read. On failure - null.</returns> /// <returns>On success - the complex option read. On failure - null.</returns>
public Option CreateInstance(byte[] buffer, ref int offset, byte valueLength) Option IOptionComplexFactory.CreateInstance(byte[] buffer, ref int offset, byte valueLength)
{ {
if (buffer == null) // if (buffer == null)
throw new ArgumentNullException("buffer"); // throw new ArgumentNullException("buffer");
if (valueLength < OptionValueMinimumLength) if (valueLength < OptionValueMinimumLength)
return null; return null;
......
...@@ -86,7 +86,7 @@ namespace PcapDotNet.Packets.IpV4 ...@@ -86,7 +86,7 @@ namespace PcapDotNet.Packets.IpV4
/// <param name="offset">The offset to the first byte to read the buffer. Will be incremented by the number of bytes read.</param> /// <param name="offset">The offset to the first byte to read the buffer. Will be incremented by the number of bytes read.</param>
/// <param name="valueLength">The number of bytes the option value should take according to the length field that was already read.</param> /// <param name="valueLength">The number of bytes the option value should take according to the length field that was already read.</param>
/// <returns>On success - the complex option read. On failure - null.</returns> /// <returns>On success - the complex option read. On failure - null.</returns>
public Option CreateInstance(byte[] buffer, ref int offset, byte valueLength) Option IOptionComplexFactory.CreateInstance(byte[] buffer, ref int offset, byte valueLength)
{ {
IpV4Address[] addresses; IpV4Address[] addresses;
byte pointedAddressIndex; byte pointedAddressIndex;
......
...@@ -236,10 +236,10 @@ namespace PcapDotNet.Packets.IpV4 ...@@ -236,10 +236,10 @@ namespace PcapDotNet.Packets.IpV4
/// <param name="offset">The offset to the first byte to read the buffer. Will be incremented by the number of bytes read.</param> /// <param name="offset">The offset to the first byte to read the buffer. Will be incremented by the number of bytes read.</param>
/// <param name="valueLength">The number of bytes the option value should take according to the length field that was already read.</param> /// <param name="valueLength">The number of bytes the option value should take according to the length field that was already read.</param>
/// <returns>On success - the complex option read. On failure - null.</returns> /// <returns>On success - the complex option read. On failure - null.</returns>
public Option CreateInstance(byte[] buffer, ref int offset, byte valueLength) Option IOptionComplexFactory.CreateInstance(byte[] buffer, ref int offset, byte valueLength)
{ {
if (buffer == null) // if (buffer == null)
throw new ArgumentNullException("buffer"); // throw new ArgumentNullException("buffer");
if (valueLength != OptionValueLength) if (valueLength != OptionValueLength)
return null; return null;
......
...@@ -91,7 +91,7 @@ namespace PcapDotNet.Packets.IpV4 ...@@ -91,7 +91,7 @@ namespace PcapDotNet.Packets.IpV4
/// <param name="offset">The offset to the first byte to read the buffer. Will be incremented by the number of bytes read.</param> /// <param name="offset">The offset to the first byte to read the buffer. Will be incremented by the number of bytes read.</param>
/// <param name="valueLength">The number of bytes the option value should take according to the length field that was already read.</param> /// <param name="valueLength">The number of bytes the option value should take according to the length field that was already read.</param>
/// <returns>On success - the complex option read. On failure - null.</returns> /// <returns>On success - the complex option read. On failure - null.</returns>
public Option CreateInstance(byte[] buffer, ref int offset, byte valueLength) Option IOptionComplexFactory.CreateInstance(byte[] buffer, ref int offset, byte valueLength)
{ {
IpV4Address[] addresses; IpV4Address[] addresses;
byte pointedAddressIndex; byte pointedAddressIndex;
......
...@@ -106,12 +106,9 @@ namespace PcapDotNet.Packets.IpV4 ...@@ -106,12 +106,9 @@ namespace PcapDotNet.Packets.IpV4
/// <param name="offset">The offset in the buffer to start reading the value from.</param> /// <param name="offset">The offset in the buffer to start reading the value from.</param>
/// <param name="valueLength">The number of bytes that the value should be.</param> /// <param name="valueLength">The number of bytes that the value should be.</param>
/// <returns>True iff the read was successful.</returns> /// <returns>True iff the read was successful.</returns>
protected static bool TryRead(out IpV4Address[] addresses, out byte pointedAddressIndex, internal static bool TryRead(out IpV4Address[] addresses, out byte pointedAddressIndex,
byte[] buffer, ref int offset, byte valueLength) byte[] buffer, ref int offset, byte valueLength)
{ {
if (buffer == null)
throw new ArgumentNullException("buffer");
addresses = null; addresses = null;
pointedAddressIndex = 0; pointedAddressIndex = 0;
......
...@@ -119,7 +119,7 @@ namespace PcapDotNet.Packets.IpV4 ...@@ -119,7 +119,7 @@ namespace PcapDotNet.Packets.IpV4
/// <param name="offset">The offset to the first byte to read the buffer. Will be incremented by the number of bytes read.</param> /// <param name="offset">The offset to the first byte to read the buffer. Will be incremented by the number of bytes read.</param>
/// <param name="valueLength">The number of bytes the option value should take according to the length field that was already read.</param> /// <param name="valueLength">The number of bytes the option value should take according to the length field that was already read.</param>
/// <returns>On success - the complex option read. On failure - null.</returns> /// <returns>On success - the complex option read. On failure - null.</returns>
public Option CreateInstance(byte[] buffer, ref int offset, byte valueLength) Option IOptionComplexFactory.CreateInstance(byte[] buffer, ref int offset, byte valueLength)
{ {
if (valueLength != OptionHeaderLength) if (valueLength != OptionHeaderLength)
return null; return null;
......
...@@ -99,7 +99,7 @@ namespace PcapDotNet.Packets.IpV4 ...@@ -99,7 +99,7 @@ namespace PcapDotNet.Packets.IpV4
/// <param name="offset">The offset to the first byte to read the buffer. Will be incremented by the number of bytes read.</param> /// <param name="offset">The offset to the first byte to read the buffer. Will be incremented by the number of bytes read.</param>
/// <param name="valueLength">The number of bytes the option value should take according to the length field that was already read.</param> /// <param name="valueLength">The number of bytes the option value should take according to the length field that was already read.</param>
/// <returns>On success - the complex option read. On failure - null.</returns> /// <returns>On success - the complex option read. On failure - null.</returns>
public Option CreateInstance(byte[] buffer, ref int offset, byte valueLength) Option IOptionComplexFactory.CreateInstance(byte[] buffer, ref int offset, byte valueLength)
{ {
if (valueLength != OptionHeaderLength) if (valueLength != OptionHeaderLength)
return null; return null;
......
...@@ -87,7 +87,7 @@ namespace PcapDotNet.Packets.IpV4 ...@@ -87,7 +87,7 @@ namespace PcapDotNet.Packets.IpV4
/// <param name="offset">The offset to the first byte to read the buffer. Will be incremented by the number of bytes read.</param> /// <param name="offset">The offset to the first byte to read the buffer. Will be incremented by the number of bytes read.</param>
/// <param name="valueLength">The number of bytes the option value should take according to the length field that was already read.</param> /// <param name="valueLength">The number of bytes the option value should take according to the length field that was already read.</param>
/// <returns>On success - the complex option read. On failure - null.</returns> /// <returns>On success - the complex option read. On failure - null.</returns>
public Option CreateInstance(byte[] buffer, ref int offset, byte valueLength) Option IOptionComplexFactory.CreateInstance(byte[] buffer, ref int offset, byte valueLength)
{ {
IpV4Address[] addresses; IpV4Address[] addresses;
byte pointedAddressIndex; byte pointedAddressIndex;
......
...@@ -75,7 +75,7 @@ namespace PcapDotNet.Packets.IpV4 ...@@ -75,7 +75,7 @@ namespace PcapDotNet.Packets.IpV4
[OptionTypeRegistration(typeof(IpV4OptionType), IpV4OptionType.InternetTimestamp)] [OptionTypeRegistration(typeof(IpV4OptionType), IpV4OptionType.InternetTimestamp)]
internal class IpV4OptionTimestampFactory : IOptionComplexFactory internal class IpV4OptionTimestampFactory : IOptionComplexFactory
{ {
public Option CreateInstance(byte[] buffer, ref int offset, byte valueLength) Option IOptionComplexFactory.CreateInstance(byte[] buffer, ref int offset, byte valueLength)
{ {
if (valueLength < OptionValueMinimumLength || valueLength % 4 != 2) if (valueLength < OptionValueMinimumLength || valueLength % 4 != 2)
return null; return null;
......
...@@ -179,7 +179,7 @@ namespace PcapDotNet.Packets.IpV4 ...@@ -179,7 +179,7 @@ namespace PcapDotNet.Packets.IpV4
/// <param name="offset">The offset to the first byte to read the buffer. Will be incremented by the number of bytes read.</param> /// <param name="offset">The offset to the first byte to read the buffer. Will be incremented by the number of bytes read.</param>
/// <param name="valueLength">The number of bytes the option value should take according to the length field that was already read.</param> /// <param name="valueLength">The number of bytes the option value should take according to the length field that was already read.</param>
/// <returns>On success - the complex option read. On failure - null.</returns> /// <returns>On success - the complex option read. On failure - null.</returns>
public Option CreateInstance(byte[] buffer, ref int offset, byte valueLength) Option IOptionComplexFactory.CreateInstance(byte[] buffer, ref int offset, byte valueLength)
{ {
if (valueLength != OptionValueLength) if (valueLength != OptionValueLength)
return null; return null;
......
...@@ -118,7 +118,7 @@ namespace PcapDotNet.Packets.Transport ...@@ -118,7 +118,7 @@ namespace PcapDotNet.Packets.Transport
/// <param name="offset">The offset to the first byte to read the buffer. Will be incremented by the number of bytes read.</param> /// <param name="offset">The offset to the first byte to read the buffer. Will be incremented by the number of bytes read.</param>
/// <param name="valueLength">The number of bytes the option value should take according to the length field that was already read.</param> /// <param name="valueLength">The number of bytes the option value should take according to the length field that was already read.</param>
/// <returns>On success - the complex option read. On failure - null.</returns> /// <returns>On success - the complex option read. On failure - null.</returns>
public Option CreateInstance(byte[] buffer, ref int offset, byte valueLength) Option IOptionComplexFactory.CreateInstance(byte[] buffer, ref int offset, byte valueLength)
{ {
if (valueLength < OptionValueMinimumLength) if (valueLength < OptionValueMinimumLength)
return null; return null;
......
...@@ -112,7 +112,7 @@ namespace PcapDotNet.Packets.Transport ...@@ -112,7 +112,7 @@ namespace PcapDotNet.Packets.Transport
/// <param name="offset">The offset to the first byte to read the buffer. Will be incremented by the number of bytes read.</param> /// <param name="offset">The offset to the first byte to read the buffer. Will be incremented by the number of bytes read.</param>
/// <param name="valueLength">The number of bytes the option value should take according to the length field that was already read.</param> /// <param name="valueLength">The number of bytes the option value should take according to the length field that was already read.</param>
/// <returns>On success - the complex option read. On failure - null.</returns> /// <returns>On success - the complex option read. On failure - null.</returns>
public Option CreateInstance(byte[] buffer, ref int offset, byte valueLength) Option IOptionComplexFactory.CreateInstance(byte[] buffer, ref int offset, byte valueLength)
{ {
if (valueLength != OptionValueLength) if (valueLength != OptionValueLength)
return null; return null;
......
...@@ -41,7 +41,7 @@ namespace PcapDotNet.Packets.Transport ...@@ -41,7 +41,7 @@ namespace PcapDotNet.Packets.Transport
/// <param name="offset">The offset to the first byte to read the buffer. Will be incremented by the number of bytes read.</param> /// <param name="offset">The offset to the first byte to read the buffer. Will be incremented by the number of bytes read.</param>
/// <param name="valueLength">The number of bytes the option value should take according to the length field that was already read.</param> /// <param name="valueLength">The number of bytes the option value should take according to the length field that was already read.</param>
/// <returns>On success - the complex option read. On failure - null.</returns> /// <returns>On success - the complex option read. On failure - null.</returns>
public Option CreateInstance(byte[] buffer, ref int offset, byte valueLength) Option IOptionComplexFactory.CreateInstance(byte[] buffer, ref int offset, byte valueLength)
{ {
uint connectionCount; uint connectionCount;
if (!TryRead(out connectionCount, buffer, ref offset, valueLength)) if (!TryRead(out connectionCount, buffer, ref offset, valueLength))
......
...@@ -45,7 +45,7 @@ namespace PcapDotNet.Packets.Transport ...@@ -45,7 +45,7 @@ namespace PcapDotNet.Packets.Transport
/// <param name="offset">The offset to the first byte to read the buffer. Will be incremented by the number of bytes read.</param> /// <param name="offset">The offset to the first byte to read the buffer. Will be incremented by the number of bytes read.</param>
/// <param name="valueLength">The number of bytes the option value should take according to the length field that was already read.</param> /// <param name="valueLength">The number of bytes the option value should take according to the length field that was already read.</param>
/// <returns>On success - the complex option read. On failure - null.</returns> /// <returns>On success - the complex option read. On failure - null.</returns>
public Option CreateInstance(byte[] buffer, ref int offset, byte valueLength) Option IOptionComplexFactory.CreateInstance(byte[] buffer, ref int offset, byte valueLength)
{ {
uint connectionCount; uint connectionCount;
if (!TryRead(out connectionCount, buffer, ref offset, valueLength)) if (!TryRead(out connectionCount, buffer, ref offset, valueLength))
......
...@@ -42,7 +42,7 @@ namespace PcapDotNet.Packets.Transport ...@@ -42,7 +42,7 @@ namespace PcapDotNet.Packets.Transport
/// <param name="offset">The offset to the first byte to read the buffer. Will be incremented by the number of bytes read.</param> /// <param name="offset">The offset to the first byte to read the buffer. Will be incremented by the number of bytes read.</param>
/// <param name="valueLength">The number of bytes the option value should take according to the length field that was already read.</param> /// <param name="valueLength">The number of bytes the option value should take according to the length field that was already read.</param>
/// <returns>On success - the complex option read. On failure - null.</returns> /// <returns>On success - the complex option read. On failure - null.</returns>
public Option CreateInstance(byte[] buffer, ref int offset, byte valueLength) Option IOptionComplexFactory.CreateInstance(byte[] buffer, ref int offset, byte valueLength)
{ {
uint connectionCount; uint connectionCount;
if (!TryRead(out connectionCount, buffer, ref offset, valueLength)) if (!TryRead(out connectionCount, buffer, ref offset, valueLength))
......
...@@ -105,7 +105,7 @@ namespace PcapDotNet.Packets.Transport ...@@ -105,7 +105,7 @@ namespace PcapDotNet.Packets.Transport
/// <param name="offset">The offset to the first byte to read the buffer. Will be incremented by the number of bytes read.</param> /// <param name="offset">The offset to the first byte to read the buffer. Will be incremented by the number of bytes read.</param>
/// <param name="valueLength">The number of bytes the option value should take according to the length field that was already read.</param> /// <param name="valueLength">The number of bytes the option value should take according to the length field that was already read.</param>
/// <returns>On success - the complex option read. On failure - null.</returns> /// <returns>On success - the complex option read. On failure - null.</returns>
public Option CreateInstance(byte[] buffer, ref int offset, byte valueLength) Option IOptionComplexFactory.CreateInstance(byte[] buffer, ref int offset, byte valueLength)
{ {
if (valueLength != OptionValueLength) if (valueLength != OptionValueLength)
return null; return null;
......
...@@ -112,7 +112,7 @@ namespace PcapDotNet.Packets.Transport ...@@ -112,7 +112,7 @@ namespace PcapDotNet.Packets.Transport
/// <param name="offset">The offset to the first byte to read the buffer. Will be incremented by the number of bytes read.</param> /// <param name="offset">The offset to the first byte to read the buffer. Will be incremented by the number of bytes read.</param>
/// <param name="valueLength">The number of bytes the option value should take according to the length field that was already read.</param> /// <param name="valueLength">The number of bytes the option value should take according to the length field that was already read.</param>
/// <returns>On success - the complex option read. On failure - null.</returns> /// <returns>On success - the complex option read. On failure - null.</returns>
public Option CreateInstance(byte[] buffer, ref int offset, byte valueLength) Option IOptionComplexFactory.CreateInstance(byte[] buffer, ref int offset, byte valueLength)
{ {
if (valueLength != OptionValueLength) if (valueLength != OptionValueLength)
return null; return null;
......
...@@ -103,7 +103,7 @@ namespace PcapDotNet.Packets.Transport ...@@ -103,7 +103,7 @@ namespace PcapDotNet.Packets.Transport
/// <param name="offset">The offset to the first byte to read the buffer. Will be incremented by the number of bytes read.</param> /// <param name="offset">The offset to the first byte to read the buffer. Will be incremented by the number of bytes read.</param>
/// <param name="valueLength">The number of bytes the option value should take according to the length field that was already read.</param> /// <param name="valueLength">The number of bytes the option value should take according to the length field that was already read.</param>
/// <returns>On success - the complex option read. On failure - null.</returns> /// <returns>On success - the complex option read. On failure - null.</returns>
public Option CreateInstance(byte[] buffer, ref int offset, byte valueLength) Option IOptionComplexFactory.CreateInstance(byte[] buffer, ref int offset, byte valueLength)
{ {
if (valueLength != OptionValueLength) if (valueLength != OptionValueLength)
return null; return null;
......
...@@ -116,7 +116,7 @@ namespace PcapDotNet.Packets.Transport ...@@ -116,7 +116,7 @@ namespace PcapDotNet.Packets.Transport
/// <param name="offset">The offset to the first byte to read the buffer. Will be incremented by the number of bytes read.</param> /// <param name="offset">The offset to the first byte to read the buffer. Will be incremented by the number of bytes read.</param>
/// <param name="valueLength">The number of bytes the option value should take according to the length field that was already read.</param> /// <param name="valueLength">The number of bytes the option value should take according to the length field that was already read.</param>
/// <returns>On success - the complex option read. On failure - null.</returns> /// <returns>On success - the complex option read. On failure - null.</returns>
public Option CreateInstance(byte[] buffer, ref int offset, byte valueLength) Option IOptionComplexFactory.CreateInstance(byte[] buffer, ref int offset, byte valueLength)
{ {
if (valueLength != OptionValueLength) if (valueLength != OptionValueLength)
return null; return null;
......
...@@ -70,7 +70,7 @@ namespace PcapDotNet.Packets.Transport ...@@ -70,7 +70,7 @@ namespace PcapDotNet.Packets.Transport
/// <param name="offset">The offset to the first byte to read the buffer. Will be incremented by the number of bytes read.</param> /// <param name="offset">The offset to the first byte to read the buffer. Will be incremented by the number of bytes read.</param>
/// <param name="valueLength">The number of bytes the option value should take according to the length field that was already read.</param> /// <param name="valueLength">The number of bytes the option value should take according to the length field that was already read.</param>
/// <returns>On success - the complex option read. On failure - null.</returns> /// <returns>On success - the complex option read. On failure - null.</returns>
public Option CreateInstance(byte[] buffer, ref int offset, byte valueLength) Option IOptionComplexFactory.CreateInstance(byte[] buffer, ref int offset, byte valueLength)
{ {
if (valueLength != OptionValueLength) if (valueLength != OptionValueLength)
return null; return null;
......
...@@ -106,7 +106,7 @@ namespace PcapDotNet.Packets.Transport ...@@ -106,7 +106,7 @@ namespace PcapDotNet.Packets.Transport
/// <summary> /// <summary>
/// The hash code of the partial order service profile option is the hash code of the option type xored with a combination of the IsStart and IsEnd values. /// The hash code of the partial order service profile option is the hash code of the option type xored with a combination of the IsStart and IsEnd values.
/// </summary> /// </summary>
public override int GetHashCode() public override int GetHashCode()
{ {
return base.GetHashCode() ^ ((IsStart ? 1 : 0) << 1) ^ (IsEnd ? 1 : 0); return base.GetHashCode() ^ ((IsStart ? 1 : 0) << 1) ^ (IsEnd ? 1 : 0);
} }
...@@ -118,7 +118,7 @@ namespace PcapDotNet.Packets.Transport ...@@ -118,7 +118,7 @@ namespace PcapDotNet.Packets.Transport
/// <param name="offset">The offset to the first byte to read the buffer. Will be incremented by the number of bytes read.</param> /// <param name="offset">The offset to the first byte to read the buffer. Will be incremented by the number of bytes read.</param>
/// <param name="valueLength">The number of bytes the option value should take according to the length field that was already read.</param> /// <param name="valueLength">The number of bytes the option value should take according to the length field that was already read.</param>
/// <returns>On success - the complex option read. On failure - null.</returns> /// <returns>On success - the complex option read. On failure - null.</returns>
public Option CreateInstance(byte[] buffer, ref int offset, byte valueLength) Option IOptionComplexFactory.CreateInstance(byte[] buffer, ref int offset, byte valueLength)
{ {
if (valueLength != OptionValueLength) if (valueLength != OptionValueLength)
return null; return null;
......
...@@ -141,7 +141,7 @@ namespace PcapDotNet.Packets.Transport ...@@ -141,7 +141,7 @@ namespace PcapDotNet.Packets.Transport
/// <param name="offset">The offset to the first byte to read the buffer. Will be incremented by the number of bytes read.</param> /// <param name="offset">The offset to the first byte to read the buffer. Will be incremented by the number of bytes read.</param>
/// <param name="valueLength">The number of bytes the option value should take according to the length field that was already read.</param> /// <param name="valueLength">The number of bytes the option value should take according to the length field that was already read.</param>
/// <returns>On success - the complex option read. On failure - null.</returns> /// <returns>On success - the complex option read. On failure - null.</returns>
public Option CreateInstance(byte[] buffer, ref int offset, byte valueLength) Option IOptionComplexFactory.CreateInstance(byte[] buffer, ref int offset, byte valueLength)
{ {
if (valueLength < OptionValueMinimumLength || valueLength % TcpOptionSelectiveAcknowledgmentBlock.SizeOf != 0) if (valueLength < OptionValueMinimumLength || valueLength % TcpOptionSelectiveAcknowledgmentBlock.SizeOf != 0)
return null; return null;
......
...@@ -74,7 +74,7 @@ namespace PcapDotNet.Packets.Transport ...@@ -74,7 +74,7 @@ namespace PcapDotNet.Packets.Transport
/// <param name="offset">The offset to the first byte to read the buffer. Will be incremented by the number of bytes read.</param> /// <param name="offset">The offset to the first byte to read the buffer. Will be incremented by the number of bytes read.</param>
/// <param name="valueLength">The number of bytes the option value should take according to the length field that was already read.</param> /// <param name="valueLength">The number of bytes the option value should take according to the length field that was already read.</param>
/// <returns>On success - the complex option read. On failure - null.</returns> /// <returns>On success - the complex option read. On failure - null.</returns>
public Option CreateInstance(byte[] buffer, ref int offset, byte valueLength) Option IOptionComplexFactory.CreateInstance(byte[] buffer, ref int offset, byte valueLength)
{ {
if (valueLength != OptionValueLength) if (valueLength != OptionValueLength)
return null; return null;
......
...@@ -120,7 +120,7 @@ namespace PcapDotNet.Packets.Transport ...@@ -120,7 +120,7 @@ namespace PcapDotNet.Packets.Transport
/// <param name="offset">The offset to the first byte to read the buffer. Will be incremented by the number of bytes read.</param> /// <param name="offset">The offset to the first byte to read the buffer. Will be incremented by the number of bytes read.</param>
/// <param name="valueLength">The number of bytes the option value should take according to the length field that was already read.</param> /// <param name="valueLength">The number of bytes the option value should take according to the length field that was already read.</param>
/// <returns>On success - the complex option read. On failure - null.</returns> /// <returns>On success - the complex option read. On failure - null.</returns>
public Option CreateInstance(byte[] buffer, ref int offset, byte valueLength) Option IOptionComplexFactory.CreateInstance(byte[] buffer, ref int offset, byte valueLength)
{ {
if (valueLength != OptionValueLength) if (valueLength != OptionValueLength)
return null; return null;
......
...@@ -119,7 +119,7 @@ namespace PcapDotNet.Packets.Transport ...@@ -119,7 +119,7 @@ namespace PcapDotNet.Packets.Transport
/// <param name="offset">The offset to the first byte to read the buffer. Will be incremented by the number of bytes read.</param> /// <param name="offset">The offset to the first byte to read the buffer. Will be incremented by the number of bytes read.</param>
/// <param name="valueLength">The number of bytes the option value should take according to the length field that was already read.</param> /// <param name="valueLength">The number of bytes the option value should take according to the length field that was already read.</param>
/// <returns>On success - the complex option read. On failure - null.</returns> /// <returns>On success - the complex option read. On failure - null.</returns>
public Option CreateInstance(byte[] buffer, ref int offset, byte valueLength) Option IOptionComplexFactory.CreateInstance(byte[] buffer, ref int offset, byte valueLength)
{ {
if (valueLength != OptionValueLength) if (valueLength != OptionValueLength)
return null; return 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