Option IOptionComplexFactory.CreateInstance(byte[] buffer, ref int offset, byte valueLength) { if ((int)valueLength < 2 || (int)valueLength % 4 != 2) { return((Option)null); } byte num1 = buffer[offset++]; if ((int)num1 % 4 != 1 || (int)num1 < 5) { return((Option)null); } byte pointedIndex = (byte)((int)num1 / 4 - 1); byte num2 = buffer[offset++]; IpV4OptionTimestampType timestampType = (IpV4OptionTimestampType)((uint)num2 & 15U); byte overflow = (byte)((uint)num2 >> 4); int numValues = (int)valueLength / 4; switch (timestampType) { case IpV4OptionTimestampType.TimestampOnly: return((Option)IpV4OptionTimestampOnly.Read(overflow, pointedIndex, buffer, ref offset, numValues)); case IpV4OptionTimestampType.AddressAndTimestamp: case IpV4OptionTimestampType.AddressPrespecified: return((Option)IpV4OptionTimestampAndAddress.Read(timestampType, overflow, pointedIndex, buffer, ref offset, numValues)); default: return((Option)null); } }
Option IOptionComplexFactory.CreateInstance(byte[] buffer, ref int offset, byte valueLength) { if (valueLength < OptionValueMinimumLength || valueLength % 4 != 2) { return(null); } byte pointer = buffer[offset++]; if (pointer % 4 != 1 || pointer < 5) { return(null); } byte pointedIndex = (byte)(pointer / 4 - 1); byte overflow = buffer[offset++]; IpV4OptionTimestampType timestampType = (IpV4OptionTimestampType)(overflow & 0x0F); overflow >>= 4; int numValues = valueLength / 4; switch (timestampType) { case IpV4OptionTimestampType.TimestampOnly: return(IpV4OptionTimestampOnly.Read(overflow, pointedIndex, buffer, ref offset, numValues)); case IpV4OptionTimestampType.AddressAndTimestamp: case IpV4OptionTimestampType.AddressPrespecified: return(IpV4OptionTimestampAndAddress.Read(timestampType, overflow, pointedIndex, buffer, ref offset, numValues)); default: return(null); } }