internal override DnsResourceData CreateInstance(DataSegment data) { if (data.Length != 16) { return((DnsResourceData)null); } byte version = data[0]; ulong size = DnsResourceDataLocationInformation.ReadSize(data[1]); if (size > 9000000000UL) { return((DnsResourceData)null); } ulong horizontalPrecision = DnsResourceDataLocationInformation.ReadSize(data[2]); if (horizontalPrecision > 9000000000UL) { return((DnsResourceData)null); } ulong verticalPrecision = DnsResourceDataLocationInformation.ReadSize(data[3]); if (verticalPrecision > 9000000000UL) { return((DnsResourceData)null); } uint latitude = data.ReadUInt(4, Endianity.Big); uint longitude = data.ReadUInt(8, Endianity.Big); uint altitude = data.ReadUInt(12, Endianity.Big); return((DnsResourceData) new DnsResourceDataLocationInformation(version, size, horizontalPrecision, verticalPrecision, latitude, longitude, altitude)); }
internal override DnsResourceData CreateInstance(DataSegment data) { if (data.Length != Length) { return(null); } byte version = data[Offset.Version]; ulong size = ReadSize(data[Offset.Size]); if (size > MaxSizeValue) { return(null); } ulong horizontalPrecision = ReadSize(data[Offset.HorizontalPrecision]); if (horizontalPrecision > MaxSizeValue) { return(null); } ulong verticalPrecision = ReadSize(data[Offset.VerticalPrecision]); if (verticalPrecision > MaxSizeValue) { return(null); } uint latitude = data.ReadUInt(Offset.Latitude, Endianity.Big); uint longitude = data.ReadUInt(Offset.Longitude, Endianity.Big); uint altitude = data.ReadUInt(Offset.Altitude, Endianity.Big); return(new DnsResourceDataLocationInformation(version, size, horizontalPrecision, verticalPrecision, latitude, longitude, altitude)); }
internal static IpV6ExtensionHeaderEncapsulatingSecurityPayload CreateInstance(DataSegment extensionHeaderData, out int numBytesRead) { if (extensionHeaderData.Length < MinimumLength) { numBytesRead = 0; return(null); } uint securityParametersIndex = extensionHeaderData.ReadUInt(Offset.SecurityParametersIndex, Endianity.Big); uint sequenceNumber = extensionHeaderData.ReadUInt(Offset.SequenceNumber, Endianity.Big); DataSegment encryptedDataAndAuthenticationData = extensionHeaderData.Subsegment(Offset.PayloadData, extensionHeaderData.Length - Offset.PayloadData); numBytesRead = extensionHeaderData.Length; return(new IpV6ExtensionHeaderEncapsulatingSecurityPayload(securityParametersIndex, sequenceNumber, encryptedDataAndAuthenticationData)); }
internal override IpV6MobilityOption CreateInstance(DataSegment data) { if (data.Length != OptionDataLength) { return(null); } ushort priority = data.ReadUShort(Offset.Priority, Endianity.Big); uint sessionsInUse = data.ReadUInt(Offset.SessionsInUse, Endianity.Big); uint maximumSessions = data.ReadUInt(Offset.MaximumSessions, Endianity.Big); uint usedCapacity = data.ReadUInt(Offset.UsedCapacity, Endianity.Big); uint maximumCapacity = data.ReadUInt(Offset.MaximumCapacity, Endianity.Big); return(new IpV6MobilityOptionLoadInformation(priority, sessionsInUse, maximumSessions, usedCapacity, maximumCapacity)); }
internal override IpV6Option CreateInstance(DataSegment data) { if (data.Length != OptionDataLength) return null; return new IpV6OptionJumboPayload(data.ReadUInt(0, Endianity.Big)); }
internal static void ReadData(DataSegment data, out IpV4OptionQuickStartFunction function, out byte rate, out byte ttl, out uint nonce) { function = (IpV4OptionQuickStartFunction)((data[Offset.Function] & Mask.Function) >> Shift.Function); rate = (byte)(data[Offset.Rate] & Mask.Rate); ttl = data[Offset.Ttl]; nonce = data.ReadUInt(Offset.Nonce, Endianity.Big) >> Shift.Nonce; }
public static void ReadData(DataSegment data, out IpV4OptionQuickStartFunction function, out byte rate, out byte ttl, out uint nonce) { function = (IpV4OptionQuickStartFunction)(data[Offset.Function] & Mask.Function); rate = (byte)(data[Offset.Rate] & Mask.Rate); ttl = data[Offset.Ttl]; nonce = data.ReadUInt(Offset.Nonce, Endianity.Big); }
internal override IpV6MobilityOption CreateInstance(DataSegment data) { if (data.Length != OptionDataLength) return null; uint greKeyIdentifier = data.ReadUInt(Offset.GreKeyIdentifier, Endianity.Big); return new IpV6MobilityOptionGreKey(greKeyIdentifier); }
internal override IpV6MobilityOption CreateInstance(DataSegment data) { if (data.Length != OptionDataLength) return null; uint restartCounter = data.ReadUInt(0, Endianity.Big); return new IpV6MobilityOptionRestartCounter(restartCounter); }
internal override IpV6Option CreateInstance(DataSegment data) { if (data.Length != OptionDataLength) { return(null); } return(new IpV6OptionJumboPayload(data.ReadUInt(0, Endianity.Big))); }
/// <summary> /// Parses an option from the given data. /// </summary> /// <param name="data">The data to parse.</param> /// <returns>The option if parsing was successful, null otherwise.</returns> public IpV6Option CreateInstance(DataSegment data) { if (data == null) throw new ArgumentNullException("data"); if (data.Length != OptionDataLength) return null; return new IpV6OptionJumboPayload(data.ReadUInt(0, Endianity.Big)); }
internal override IpV6MobilityOption CreateInstance(DataSegment data) { if (data.Length < OptionDataMinimumLength) return null; uint vendorId = data.ReadUInt(Offset.VendorId, Endianity.Big); byte subType = data[Offset.SubType]; DataSegment vendorSpecificData = data.Subsegment(Offset.Data, data.Length - Offset.Data); return new IpV6MobilityOptionVendorSpecific(vendorId, subType, vendorSpecificData); }
internal override IpV6MobilityOption CreateInstance(DataSegment data) { if (data.Length != OptionDataLength) return null; IpV6MobileNodeGroupIdentifierSubtype subtype = (IpV6MobileNodeGroupIdentifierSubtype)data[Offset.SubType]; uint mobileNodeGroupIdentifier = data.ReadUInt(Offset.MobileNodeGroupIdentifier, Endianity.Big); return new IpV6MobilityOptionMobileNodeGroupIdentifier(subtype, mobileNodeGroupIdentifier); }
internal static IpV6ExtensionHeaderFragmentData ParseData(IpV4Protocol nextHeader, DataSegment data) { if (data.Length != DataLength) return null; ushort fragmentOffset = (ushort)((data.ReadUShort(DataOffset.FragmentOffset, Endianity.Big) & DataMask.FragmentOffset) >> DataShift.FragmentOffset); bool moreFragments = data.ReadBool(DataOffset.MoreFragments, DataMask.MoreFragments); uint identification = data.ReadUInt(DataOffset.Identification, Endianity.Big); return new IpV6ExtensionHeaderFragmentData(nextHeader, fragmentOffset, moreFragments, identification); }
internal override IpV6MobilityOption CreateInstance(DataSegment data) { if (data.Length < OptionDataMinimumLength) return null; IpV6AuthenticationSubtype subtype = (IpV6AuthenticationSubtype)data[Offset.Subtype]; uint mobilitySecurityParameterIndex = data.ReadUInt(Offset.MobilitySecurityParameterIndex, Endianity.Big); DataSegment authenticationData = data.Subsegment(Offset.AuthenticationData, data.Length - Offset.AuthenticationData); return new IpV6MobilityOptionAuthentication(subtype, mobilitySecurityParameterIndex, authenticationData); }
internal override IpV6MobilityOption CreateInstance(DataSegment data) { if (data.Length != OptionDataLength) { return(null); } uint greKeyIdentifier = data.ReadUInt(Offset.GreKeyIdentifier, Endianity.Big); return(new IpV6MobilityOptionGreKey(greKeyIdentifier)); }
internal override IpV6MobilityOption CreateInstance(DataSegment data) { if (data.Length != OptionDataLength) { return(null); } uint restartCounter = data.ReadUInt(0, Endianity.Big); return(new IpV6MobilityOptionRestartCounter(restartCounter)); }
internal override IpV6MobilityOption CreateInstance(DataSegment data) { if (data.Length != OptionDataLength) { return(null); } bool udpEncapsulationRequired = data.ReadBool(Offset.UdpEncapsulationRequired, Mask.UdpEncapsulationRequired); uint refreshTime = data.ReadUInt(Offset.RefreshTime, Endianity.Big); return(new IpV6MobilityOptionNatDetection(udpEncapsulationRequired, refreshTime)); }
internal override IpV6MobilityOption CreateInstance(DataSegment data) { if (data.Length < OptionDataMinimumLength) { return(null); } uint securityParameterIndex = data.ReadUInt(Offset.SecurityParameterIndex, Endianity.Big); DataSegment authenticator = data.Subsegment(Offset.Authenticator, data.Length - Offset.Authenticator); return(new IpV6MobilityOptionBindingAuthorizationDataForFmIpV6(securityParameterIndex, authenticator)); }
internal override IpV6MobilityOption CreateInstance(DataSegment data) { if (data.Length != OptionDataLength) { return(null); } IpV6MobileNodeGroupIdentifierSubtype subtype = (IpV6MobileNodeGroupIdentifierSubtype)data[Offset.SubType]; uint mobileNodeGroupIdentifier = data.ReadUInt(Offset.MobileNodeGroupIdentifier, Endianity.Big); return(new IpV6MobilityOptionMobileNodeGroupIdentifier(subtype, mobileNodeGroupIdentifier)); }
internal override IpV6MobilityOption CreateInstance(DataSegment data) { if (data.Length < OptionDataMinimumLength) { return(null); } uint vendorId = data.ReadUInt(Offset.VendorId, Endianity.Big); byte subType = data[Offset.SubType]; DataSegment vendorSpecificData = data.Subsegment(Offset.Data, data.Length - Offset.Data); return(new IpV6MobilityOptionVendorSpecific(vendorId, subType, vendorSpecificData)); }
internal override IpV6MobilityOption CreateInstance(DataSegment data) { if (data.Length < OptionDataMinimumLength) { return(null); } IpV6AuthenticationSubtype subtype = (IpV6AuthenticationSubtype)data[Offset.Subtype]; uint mobilitySecurityParameterIndex = data.ReadUInt(Offset.MobilitySecurityParameterIndex, Endianity.Big); DataSegment authenticationData = data.Subsegment(Offset.AuthenticationData, data.Length - Offset.AuthenticationData); return(new IpV6MobilityOptionAuthentication(subtype, mobilitySecurityParameterIndex, authenticationData)); }
/// <summary> /// Parses an option from the given data. /// </summary> /// <param name="data">The data to parse.</param> /// <returns>The option if parsing was successful, null otherwise.</returns> public IpV6Option CreateInstance(DataSegment data) { if (data == null) { throw new ArgumentNullException("data"); } if (data.Length != OptionDataLength) { return(null); } return(new IpV6OptionJumboPayload(data.ReadUInt(0, Endianity.Big))); }
internal static IpV6ExtensionHeaderFragmentData ParseData(IpV4Protocol nextHeader, DataSegment data) { if (data.Length != ExtensionHeaderDataLength) { return(null); } ushort fragmentOffset = (ushort)((data.ReadUShort(DataOffset.FragmentOffset, Endianity.Big) & DataMask.FragmentOffset) >> DataShift.FragmentOffset); bool moreFragments = data.ReadBool(DataOffset.MoreFragments, DataMask.MoreFragments); uint identification = data.ReadUInt(DataOffset.Identification, Endianity.Big); return(new IpV6ExtensionHeaderFragmentData(nextHeader, fragmentOffset, moreFragments, identification)); }
internal static DnsOptionLongLivedQuery Read(DataSegment data) { if (data.Length != ConstDataLength) { return(null); } ushort version = data.ReadUShort(Offset.Version, Endianity.Big); DnsLongLivedQueryOpCode opCode = (DnsLongLivedQueryOpCode)data.ReadUShort(Offset.OpCode, Endianity.Big); DnsLongLivedQueryErrorCode errorCode = (DnsLongLivedQueryErrorCode)data.ReadUShort(Offset.ErrorCode, Endianity.Big); ulong id = data.ReadULong(Offset.Id, Endianity.Big); uint leaseLife = data.ReadUInt(Offset.LeaseLife, Endianity.Big); return(new DnsOptionLongLivedQuery(version, opCode, errorCode, id, leaseLife)); }
internal static IpV6ExtensionHeaderMobilityHeartbeatMessage ParseMessageData(IpV4Protocol nextHeader, ushort checksum, DataSegment messageData) { if (messageData.Length < MinimumMessageDataLength) { return(null); } bool isUnsolicitedHeartbeatResponse = messageData.ReadBool(MessageDataOffset.IsUnsolicitedHeartbeatResponse, MessageDataMask.IsUnsolicitedHeartbeatResponse); bool isResponse = messageData.ReadBool(MessageDataOffset.IsResponse, MessageDataMask.IsResponse); uint sequenceNumber = messageData.ReadUInt(MessageDataOffset.SequenceNumber, Endianity.Big); IpV6MobilityOptions options = new IpV6MobilityOptions(messageData.Subsegment(MessageDataOffset.MobilityOptions, messageData.Length - MessageDataOffset.MobilityOptions)); return(new IpV6ExtensionHeaderMobilityHeartbeatMessage(nextHeader, checksum, isUnsolicitedHeartbeatResponse, isResponse, sequenceNumber, options)); }
internal static IpV6ExtensionHeaderAuthentication CreateInstance(DataSegment extensionHeaderData, out int numBytesRead) { if (extensionHeaderData.Length < MinimumLength) { numBytesRead = 0; return(null); } IpV4Protocol nextHeader = (IpV4Protocol)extensionHeaderData[Offset.NextHeader]; byte payloadLength = extensionHeaderData[Offset.PayloadLength]; if (extensionHeaderData.Length < Offset.AuthenticationData + payloadLength) { numBytesRead = 0; return(null); } uint securityParametersIndex = extensionHeaderData.ReadUInt(Offset.SecurityParametersIndex, Endianity.Big); uint sequenceNumber = extensionHeaderData.ReadUInt(Offset.SequenceNumber, Endianity.Big); DataSegment authenticationData = extensionHeaderData.Subsegment(Offset.AuthenticationData, payloadLength); numBytesRead = Offset.AuthenticationData + payloadLength; return(new IpV6ExtensionHeaderAuthentication(nextHeader, securityParametersIndex, sequenceNumber, authenticationData)); }
internal static DnsOptionLongLivedQuery Read(DataSegment data) { if (data.Length != ConstDataLength) return null; ushort version = data.ReadUShort(Offset.Version, Endianity.Big); DnsLongLivedQueryOpCode opCode = (DnsLongLivedQueryOpCode)data.ReadUShort(Offset.OpCode, Endianity.Big); DnsLongLivedQueryErrorCode errorCode = (DnsLongLivedQueryErrorCode)data.ReadUShort(Offset.ErrorCode, Endianity.Big); ulong id = data.ReadULong(Offset.Id, Endianity.Big); uint leaseLife = data.ReadUInt(Offset.LeaseLife, Endianity.Big); return new DnsOptionLongLivedQuery(version, opCode, errorCode, id, leaseLife); }
internal override IpV6MobilityOption CreateInstance(DataSegment data) { if (data.Length < OptionDataMinimumLength) return null; uint securityParameterIndex = data.ReadUInt(Offset.SecurityParameterIndex, Endianity.Big); DataSegment authenticator = data.Subsegment(Offset.Authenticator, data.Length - Offset.Authenticator); return new IpV6MobilityOptionBindingAuthorizationDataForFmIpV6(securityParameterIndex, authenticator); }
internal static IpV6ExtensionHeaderMobilityHeartbeatMessage ParseMessageData(IpV4Protocol nextHeader, ushort checksum, DataSegment messageData) { if (messageData.Length < MinimumMessageDataLength) return null; bool isUnsolicitedHeartbeatResponse = messageData.ReadBool(MessageDataOffset.IsUnsolicitedHeartbeatResponse, MessageDataMask.IsUnsolicitedHeartbeatResponse); bool isResponse = messageData.ReadBool(MessageDataOffset.IsResponse, MessageDataMask.IsResponse); uint sequenceNumber = messageData.ReadUInt(MessageDataOffset.SequenceNumber, Endianity.Big); IpV6MobilityOptions options = new IpV6MobilityOptions(messageData.Subsegment(MessageDataOffset.MobilityOptions, messageData.Length - MessageDataOffset.MobilityOptions)); return new IpV6ExtensionHeaderMobilityHeartbeatMessage(nextHeader, checksum, isUnsolicitedHeartbeatResponse, isResponse, sequenceNumber, options); }
/// <summary> /// Parses an option from the given data. /// </summary> /// <param name="data">The data to parse.</param> /// <returns>The option if parsing was successful, null otherwise.</returns> public IpV6Option CreateInstance(DataSegment data) { if (data == null) { throw new ArgumentNullException("data"); } if (data.Length < OptionDataMinimumLength) { return(null); } IpV6CalipsoDomainOfInterpretation domainOfInterpretation = (IpV6CalipsoDomainOfInterpretation)data.ReadUInt(Offset.DomainOfInterpretation, Endianity.Big); byte compartmentLength = data[Offset.CompartmentLength]; int compartmentLengthInBytes = compartmentLength * sizeof(int); if (OptionDataMinimumLength + compartmentLengthInBytes > data.Length) { return(null); } byte sensitivityLevel = data[Offset.SensitivityLevel]; ushort checksum = data.ReadUShort(Offset.Checksum, Endianity.Big); DataSegment compartmentBitmap = data.Subsegment(Offset.CompartmentBitmap, compartmentLengthInBytes); return(new IpV6OptionCalipso(domainOfInterpretation, sensitivityLevel, checksum, compartmentBitmap)); }
internal override IpV6MobilityOption CreateInstance(DataSegment data) { if (data.Length != OptionDataLength) return null; ushort priority = data.ReadUShort(Offset.Priority, Endianity.Big); uint sessionsInUse = data.ReadUInt(Offset.SessionsInUse, Endianity.Big); uint maximumSessions = data.ReadUInt(Offset.MaximumSessions, Endianity.Big); uint usedCapacity = data.ReadUInt(Offset.UsedCapacity, Endianity.Big); uint maximumCapacity = data.ReadUInt(Offset.MaximumCapacity, Endianity.Big); return new IpV6MobilityOptionLoadInformation(priority, sessionsInUse, maximumSessions, usedCapacity, maximumCapacity); }
/// <summary> /// Parses an option from the given data. /// </summary> /// <param name="data">The data to parse.</param> /// <returns>The option if parsing was successful, null otherwise.</returns> public IpV6Option CreateInstance(DataSegment data) { if (data == null) throw new ArgumentNullException("data"); if (data.Length < OptionDataMinimumLength) return null; IpV6CalipsoDomainOfInterpretation domainOfInterpretation = (IpV6CalipsoDomainOfInterpretation)data.ReadUInt(Offset.DomainOfInterpretation, Endianity.Big); byte compartmentLength = data[Offset.CompartmentLength]; int compartmentLengthInBytes = compartmentLength * sizeof(int); if (OptionDataMinimumLength + compartmentLengthInBytes > data.Length) return null; byte sensitivityLevel = data[Offset.SensitivityLevel]; ushort checksum = data.ReadUShort(Offset.Checksum, Endianity.Big); DataSegment compartmentBitmap = data.Subsegment(Offset.CompartmentBitmap, compartmentLengthInBytes); return new IpV6OptionCalipso(domainOfInterpretation, sensitivityLevel, checksum, compartmentBitmap); }
internal static IpV6ExtensionHeaderAuthentication CreateInstance(DataSegment extensionHeaderData, out int numBytesRead) { if (extensionHeaderData.Length < MinimumLength) { numBytesRead = 0; return null; } IpV4Protocol nextHeader = (IpV4Protocol)extensionHeaderData[Offset.NextHeader]; byte payloadLength = extensionHeaderData[Offset.PayloadLength]; if (extensionHeaderData.Length < Offset.AuthenticationData + payloadLength) { numBytesRead = 0; return null; } uint securityParametersIndex = extensionHeaderData.ReadUInt(Offset.SecurityParametersIndex, Endianity.Big); uint sequenceNumber = extensionHeaderData.ReadUInt(Offset.SequenceNumber, Endianity.Big); DataSegment authenticationData = extensionHeaderData.Subsegment(Offset.AuthenticationData, payloadLength); numBytesRead = Offset.AuthenticationData + payloadLength; return new IpV6ExtensionHeaderAuthentication(nextHeader, securityParametersIndex, sequenceNumber, authenticationData); }
internal static DnsOptionLongLivedQuery Read(DataSegment data) { if (data.Length != 18) { return((DnsOptionLongLivedQuery)null); } return(new DnsOptionLongLivedQuery(data.ReadUShort(0, Endianity.Big), (DnsLongLivedQueryOpCode)data.ReadUShort(2, Endianity.Big), (DnsLongLivedQueryErrorCode)data.ReadUShort(4, Endianity.Big), data.ReadULong(6, Endianity.Big), data.ReadUInt(14, Endianity.Big))); }
internal override IpV6MobilityOption CreateInstance(DataSegment data) { if (data.Length != OptionDataLength) return null; bool udpEncapsulationRequired = data.ReadBool(Offset.UdpEncapsulationRequired, Mask.UdpEncapsulationRequired); uint refreshTime = data.ReadUInt(Offset.RefreshTime, Endianity.Big); return new IpV6MobilityOptionNatDetection(udpEncapsulationRequired, refreshTime); }
internal static IpV6ExtensionHeaderEncapsulatingSecurityPayload CreateInstance(DataSegment extensionHeaderData, out int numBytesRead) { if (extensionHeaderData.Length < MinimumLength) { numBytesRead = 0; return null; } uint securityParametersIndex = extensionHeaderData.ReadUInt(Offset.SecurityParametersIndex, Endianity.Big); uint sequenceNumber = extensionHeaderData.ReadUInt(Offset.SequenceNumber, Endianity.Big); DataSegment encryptedDataAndAuthenticationData = extensionHeaderData.Subsegment(Offset.PayloadData, extensionHeaderData.Length - Offset.PayloadData); numBytesRead = extensionHeaderData.Length; return new IpV6ExtensionHeaderEncapsulatingSecurityPayload(securityParametersIndex, sequenceNumber, encryptedDataAndAuthenticationData); }