internal static bool ParseMessageDataToFields(DataSegment messageData, out ushort sequenceNumber,
                                                      out bool acknowledge, out bool homeRegistration, out bool linkLocalAddressCompatibility,
                                                      out bool keyManagementMobilityCapability, out ushort lifetime, out IpV6MobilityOptions options)
        {
            if (messageData.Length < MinimumMessageDataLength)
            {
                sequenceNumber   = 0;
                acknowledge      = false;
                homeRegistration = false;
                linkLocalAddressCompatibility   = false;
                keyManagementMobilityCapability = false;
                lifetime = 0;
                options  = null;
                return(false);
            }

            sequenceNumber   = messageData.ReadUShort(MessageDataOffset.SequenceNumber, Endianity.Big);
            acknowledge      = messageData.ReadBool(MessageDataOffset.Acknowledge, MessageDataMask.Acknowledge);
            homeRegistration = messageData.ReadBool(MessageDataOffset.HomeRegistration, MessageDataMask.HomeRegistration);
            linkLocalAddressCompatibility   = messageData.ReadBool(MessageDataOffset.LinkLocalAddressCompatibility, MessageDataMask.LinkLocalAddressCompatibility);
            keyManagementMobilityCapability = messageData.ReadBool(MessageDataOffset.KeyManagementMobilityCapability,
                                                                   MessageDataMask.KeyManagementMobilityCapability);
            lifetime = messageData.ReadUShort(MessageDataOffset.Lifetime, Endianity.Big);
            options  = new IpV6MobilityOptions(messageData.Subsegment(MessageDataOffset.Options, messageData.Length - MessageDataOffset.Options));
            return(true);
        }
        internal static IpV6ExtensionHeaderMobilityHomeAgentSwitchMessage ParseMessageData(IpV4Protocol nextHeader, ushort checksum, DataSegment messageData)
        {
            if (messageData.Length < MinimumMessageDataLength)
            {
                return(null);
            }

            byte numberOfAddresses      = messageData[MessageDataOffset.NumberOfAddresses];
            int  homeAgentAddressesSize = numberOfAddresses * IpV6Address.SizeOf;

            if (messageData.Length < MinimumMessageDataLength + homeAgentAddressesSize)
            {
                return(null);
            }

            IpV6Address[] homeAgentAddresses = new IpV6Address[numberOfAddresses];
            for (int i = 0; i != numberOfAddresses; ++i)
            {
                homeAgentAddresses[i] = messageData.ReadIpV6Address(MessageDataOffset.HomeAgentAddresses + i * IpV6Address.SizeOf, Endianity.Big);
            }

            int optionsOffset           = MessageDataOffset.HomeAgentAddresses + homeAgentAddressesSize;
            IpV6MobilityOptions options = new IpV6MobilityOptions(messageData.Subsegment(optionsOffset, messageData.Length - optionsOffset));

            return(new IpV6ExtensionHeaderMobilityHomeAgentSwitchMessage(nextHeader, checksum, homeAgentAddresses, options));
        }
 internal IpV6ExtensionHeaderMobilityLocalizedRouting(IpV4Protocol?nextHeader, ushort checksum, ushort sequenceNumber, ushort lifetime,
                                                      IpV6MobilityOptions options)
     : base(nextHeader, checksum, options, MessageDataOffset.Options)
 {
     SequenceNumber = sequenceNumber;
     Lifetime       = lifetime;
 }
        internal static IpV6ExtensionHeaderMobilityBindingRevocationMessage ParseMessageData(IpV4Protocol nextHeader, ushort checksum, DataSegment messageData)
        {
            if (messageData.Length < MinimumMessageDataLength)
            {
                return(null);
            }

            IpV6MobilityBindingRevocationType bindingRevocationType = (IpV6MobilityBindingRevocationType)messageData[MessageDataOffset.BindingRevocationType];
            byte   revocationTriggerOrStatus = messageData[MessageDataOffset.RevocationTriggerOrStatus];
            ushort sequenceNumber            = messageData.ReadUShort(MessageDataOffset.SequenceNumber, Endianity.Big);
            bool   proxyBinding = messageData.ReadBool(MessageDataOffset.ProxyBinding, MessageDataMask.ProxyBinding);
            bool   ipV4HomeAddressBindingOnly = messageData.ReadBool(MessageDataOffset.IpV4HomeAddressBindingOnly, MessageDataMask.IpV4HomeAddressBindingOnly);
            bool   global = messageData.ReadBool(MessageDataOffset.Global, MessageDataMask.Global);
            IpV6MobilityOptions options =
                new IpV6MobilityOptions(messageData.Subsegment(MessageDataOffset.Options, messageData.Length - MessageDataOffset.Options));

            switch (bindingRevocationType)
            {
            case IpV6MobilityBindingRevocationType.BindingRevocationIndication:
                return(new IpV6ExtensionHeaderMobilityBindingRevocationIndicationMessage(nextHeader, checksum, (Ipv6MobilityBindingRevocationTrigger)revocationTriggerOrStatus, sequenceNumber,
                                                                                         proxyBinding, ipV4HomeAddressBindingOnly, global, options));

            case IpV6MobilityBindingRevocationType.BindingRevocationAcknowledgement:
                return(new IpV6ExtensionHeaderMobilityBindingRevocationAcknowledgementMessage(nextHeader, checksum,
                                                                                              (Ipv6MobilityBindingRevocationStatus)revocationTriggerOrStatus,
                                                                                              sequenceNumber, proxyBinding, ipV4HomeAddressBindingOnly,
                                                                                              global, options));

            default:
                return(null);
            }
        }
Example #5
0
 /// <summary>
 /// Creates an instance from next header, checksum, status, home address and options.
 /// </summary>
 /// <param name="nextHeader">
 /// Identifies the type of header immediately following this extension header.
 /// </param>
 /// <param name="checksum">
 /// Contains the checksum of the Mobility Header.
 /// The checksum is calculated from the octet string consisting of a "pseudo-header"
 /// followed by the entire Mobility Header starting with the Payload Proto field.
 /// The checksum is the 16-bit one's complement of the one's complement sum of this string.
 /// </param>
 /// <param name="status">Indicating the reason for this message.</param>
 /// <param name="homeAddress">
 /// The home address that was contained in the Home Address destination option.
 /// The mobile node uses this information to determine which binding does not exist, in cases where the mobile node has several home addresses.
 /// </param>
 /// <param name="options">
 /// Zero or more TLV-encoded mobility options.
 /// </param>
 public IpV6ExtensionHeaderMobilityBindingError(IpV4Protocol?nextHeader, ushort checksum, IpV6BindingErrorStatus status, IpV6Address homeAddress,
                                                IpV6MobilityOptions options)
     : base(nextHeader, checksum, options, MessageDataOffset.Options)
 {
     Status      = status;
     HomeAddress = homeAddress;
 }
 /// <summary>
 /// Creates an instance from next header, checksum, revocation trigger, sequence number, proxy binding, IPv4 home address binding only, global
 /// and options.
 /// </summary>
 /// <param name="nextHeader">
 /// Identifies the type of header immediately following this extension header.
 /// </param>
 /// <param name="checksum">
 /// Contains the checksum of the Mobility Header.
 /// The checksum is calculated from the octet string consisting of a "pseudo-header"
 /// followed by the entire Mobility Header starting with the Payload Proto field.
 /// The checksum is the 16-bit one's complement of the one's complement sum of this string.
 /// </param>
 /// <param name="revocationTrigger">
 /// Indicating the event that triggered the initiator to send the BRI message.
 /// </param>
 /// <param name="sequenceNumber">
 /// Used by the initiator to match a returned Binding Revocation Acknowledgement with this Binding Revocation Indication.
 /// This sequence number could be a random number.
 /// At any time, implementations must ensure there is no collision between the sequence numbers of all outstanding Binding Revocation Indication
 /// Messages.
 /// </param>
 /// <param name="proxyBinding">
 /// Set by the initiator to indicate that the revoked binding(s) is a PMIPv6 binding.
 /// </param>
 /// <param name="ipV4HomeAddressBindingOnly">
 /// Set by the initiator, home agent, or local mobility anchor to indicate to the receiving mobility entity the termination
 /// of the IPv4 Home Address binding only as in Home Agent Operation and Local Mobility Anchor Operation.
 /// </param>
 /// <param name="global">
 /// Set by the initiator, LMA or MAG, to indicate the termination of all Per-Peer mobility Bindings or Multiple Bindings that share
 /// a common identifier(s) and are served by the initiator and responder as in Local Mobility Anchor Operation and Mobile Access Gateway Operation.
 /// </param>
 /// <param name="options">
 /// Zero or more TLV-encoded mobility options.
 /// </param>
 public IpV6ExtensionHeaderMobilityBindingRevocationIndicationMessage(IpV4Protocol?nextHeader, ushort checksum,
                                                                      Ipv6MobilityBindingRevocationTrigger revocationTrigger, ushort sequenceNumber,
                                                                      bool proxyBinding, bool ipV4HomeAddressBindingOnly, bool global,
                                                                      IpV6MobilityOptions options)
     : base(nextHeader, checksum, sequenceNumber, proxyBinding, ipV4HomeAddressBindingOnly, global, options)
 {
     RevocationTrigger = revocationTrigger;
 }
 /// <summary>
 /// Creates an instance from next header, checksum, care of nonce index, care of init cookie, care of keygen token and options.
 /// </summary>
 /// <param name="nextHeader">Identifies the type of header immediately following this extension header.</param>
 /// <param name="checksum">
 /// Contains the checksum of the Mobility Header.
 /// The checksum is calculated from the octet string consisting of a "pseudo-header"
 /// followed by the entire Mobility Header starting with the Payload Proto field.
 /// The checksum is the 16-bit one's complement of the one's complement sum of this string.
 /// </param>
 /// <param name="careOfNonceIndex">Will be echoed back by the mobile node to the correspondent node in a subsequent Binding Update.</param>
 /// <param name="careOfInitCookie">Contains the care-of init cookie.</param>
 /// <param name="careOfKeygenToken">Contains the 64-bit care-of keygen token used in the return routability procedure.</param>
 /// <param name="options">Zero or more TLV-encoded mobility options.</param>
 public IpV6ExtensionHeaderMobilityCareOfTest(IpV4Protocol?nextHeader, ushort checksum, ushort careOfNonceIndex, ulong careOfInitCookie,
                                              ulong careOfKeygenToken, IpV6MobilityOptions options)
     : base(nextHeader, checksum, options, MessageDataOffset.Options)
 {
     CareOfNonceIndex  = careOfNonceIndex;
     CareOfInitCookie  = careOfInitCookie;
     CareOfKeygenToken = careOfKeygenToken;
 }
 /// <summary>
 /// Creates an instance from next header, checksum, home nonce index, home init cookie, home keygen token and options.
 /// </summary>
 /// <param name="nextHeader">Identifies the type of header immediately following this extension header.</param>
 /// <param name="checksum">
 /// Contains the checksum of the Mobility Header.
 /// The checksum is calculated from the octet string consisting of a "pseudo-header"
 /// followed by the entire Mobility Header starting with the Payload Proto field.
 /// The checksum is the 16-bit one's complement of the one's complement sum of this string.
 /// </param>
 /// <param name="homeNonceIndex">Will be echoed back by the mobile node to the correspondent node in a subsequent Binding Update.</param>
 /// <param name="homeInitCookie">Contains the home init cookie.</param>
 /// <param name="homeKeygenToken">Contains the 64-bit home keygen token used in the return routability procedure.</param>
 /// <param name="options">Zero or more TLV-encoded mobility options.</param>
 public IpV6ExtensionHeaderMobilityHomeTest(IpV4Protocol?nextHeader, ushort checksum, ushort homeNonceIndex, ulong homeInitCookie, ulong homeKeygenToken,
                                            IpV6MobilityOptions options)
     : base(nextHeader, checksum, options, MessageDataOffset.Options)
 {
     HomeNonceIndex  = homeNonceIndex;
     HomeInitCookie  = homeInitCookie;
     HomeKeygenToken = homeKeygenToken;
 }
Example #9
0
 /// <summary>
 /// Creates an instance from next header, checksum, status, sequence number, proxy binding, IPv4 home address binding only, global and options.
 /// </summary>
 /// <param name="nextHeader">
 /// Identifies the type of header immediately following this extension header.
 /// </param>
 /// <param name="checksum">
 /// Contains the checksum of the Mobility Header.
 /// The checksum is calculated from the octet string consisting of a "pseudo-header"
 /// followed by the entire Mobility Header starting with the Payload Proto field.
 /// The checksum is the 16-bit one's complement of the one's complement sum of this string.
 /// </param>
 /// <param name="status">
 /// Indicating the result of processing the Binding Revocation Indication message by the responder.
 /// </param>
 /// <param name="sequenceNumber">
 /// Copied from the Sequence Number field in the Binding Revocation Indication.
 /// It is used by the initiator, e.g., HA, LMA, MAG, in matching this Binding Revocation Acknowledgement
 /// with the outstanding Binding Revocation Indication.
 /// </param>
 /// <param name="proxyBinding">
 /// Set if set in the corresponding Binding Revocation Indication message.
 /// </param>
 /// <param name="ipV4HomeAddressBindingOnly">
 /// Set if the it is set in the corresponding Binding Revocation Indication message.
 /// </param>
 /// <param name="global">
 /// Set if it is set in the corresponding Binding Revocation Indication message.
 /// </param>
 /// <param name="options">
 /// Zero or more TLV-encoded mobility options.
 /// </param>
 public IpV6ExtensionHeaderMobilityBindingRevocationAcknowledgementMessage(IpV4Protocol?nextHeader, ushort checksum,
                                                                           Ipv6MobilityBindingRevocationStatus status, ushort sequenceNumber,
                                                                           bool proxyBinding, bool ipV4HomeAddressBindingOnly, bool global,
                                                                           IpV6MobilityOptions options)
     : base(nextHeader, checksum, sequenceNumber, proxyBinding, ipV4HomeAddressBindingOnly, global, options)
 {
     Status = status;
 }
 /// <summary>
 /// Creates an instance from next header, checksum, sequence number, unsolicited, status, lifetime and options.
 /// </summary>
 /// <param name="nextHeader">Identifies the type of header immediately following this extension header.</param>
 /// <param name="checksum">
 /// Contains the checksum of the Mobility Header.
 /// The checksum is calculated from the octet string consisting of a "pseudo-header"
 /// followed by the entire Mobility Header starting with the Payload Proto field.
 /// The checksum is the 16-bit one's complement of the one's complement sum of this string.
 /// </param>
 /// <param name="sequenceNumber">Copied from the sequence number field of the LRI message being responded to.</param>
 /// <param name="unsolicited">
 /// When true, the LRA message is sent unsolicited.
 /// The Lifetime field indicates a new requested value.
 /// The MAG must wait for the regular LRI message to confirm that the request is acceptable to the LMA.
 /// </param>
 /// <param name="status">The acknowledgement status.</param>
 /// <param name="lifetime">
 /// The time in seconds for which the local forwarding is supported.
 /// Typically copied from the corresponding field in the LRI message.
 /// </param>
 /// <param name="options">Zero or more TLV-encoded mobility options.</param>
 public IpV6ExtensionHeaderMobilityLocalizedRoutingAcknowledgement(IpV4Protocol?nextHeader, ushort checksum, ushort sequenceNumber, bool unsolicited,
                                                                   IpV6MobilityLocalizedRoutingAcknowledgementStatus status, ushort lifetime,
                                                                   IpV6MobilityOptions options)
     : base(nextHeader, checksum, sequenceNumber, lifetime, options)
 {
     Status      = status;
     Unsolicited = unsolicited;
 }
 /// <summary>
 /// Creates an instance from next header, checksum, is unsolicited heartbeat response, is response, sequence number and options.
 /// </summary>
 /// <param name="nextHeader">Identifies the type of header immediately following this extension header.</param>
 /// <param name="checksum">
 /// Contains the checksum of the Mobility Header.
 /// The checksum is calculated from the octet string consisting of a "pseudo-header"
 /// followed by the entire Mobility Header starting with the Payload Proto field.
 /// The checksum is the 16-bit one's complement of the one's complement sum of this string.
 /// </param>
 /// <param name="isUnsolicitedHeartbeatResponse">Set to true in Unsolicited Heartbeat Response.</param>
 /// <param name="isResponse">
 /// Indicates whether the message is a request or a response.
 /// When it's set to false, it indicates that the Heartbeat message is a request.
 /// When it's set to true, it indicates that the Heartbeat message is a response.
 /// </param>
 /// <param name="sequenceNumber">Sequence number used for matching the request to the reply.</param>
 /// <param name="options">Zero or more TLV-encoded mobility options.</param>
 public IpV6ExtensionHeaderMobilityHeartbeatMessage(IpV4Protocol?nextHeader, ushort checksum, bool isUnsolicitedHeartbeatResponse, bool isResponse,
                                                    uint sequenceNumber, IpV6MobilityOptions options)
     : base(nextHeader, checksum, options, MessageDataOffset.MobilityOptions)
 {
     IsUnsolicitedHeartbeatResponse = isUnsolicitedHeartbeatResponse;
     IsResponse     = isResponse;
     SequenceNumber = sequenceNumber;
 }
Example #12
0
 internal IpV6ExtensionHeaderMobilityBindingAcknowledgementBase(IpV4Protocol?nextHeader, ushort checksum, IpV6BindingAcknowledgementStatus status,
                                                                bool keyManagementMobilityCapability, ushort sequenceNumber, ushort lifetime,
                                                                IpV6MobilityOptions options)
     : base(nextHeader, checksum, options, MessageDataOffset.Options)
 {
     Status = status;
     KeyManagementMobilityCapability = keyManagementMobilityCapability;
     SequenceNumber = sequenceNumber;
     Lifetime       = lifetime;
 }
        internal static IpV6ExtensionHeaderMobilityBindingRefreshRequest ParseMessageData(IpV4Protocol nextHeader, ushort checksum, DataSegment messageData)
        {
            if (messageData.Length < MinimumMessageDataLength)
            {
                return(null);
            }

            IpV6MobilityOptions options = new IpV6MobilityOptions(messageData.Subsegment(MessageDataOffset.Options, messageData.Length - MessageDataOffset.Options));

            return(new IpV6ExtensionHeaderMobilityBindingRefreshRequest(nextHeader, checksum, options));
        }
 /// <summary>
 /// Creates an instance from next header, checksum, home agent addresses and options.
 /// </summary>
 /// <param name="nextHeader">Identifies the type of header immediately following this extension header.</param>
 /// <param name="checksum">
 /// Contains the checksum of the Mobility Header.
 /// The checksum is calculated from the octet string consisting of a "pseudo-header"
 /// followed by the entire Mobility Header starting with the Payload Proto field.
 /// The checksum is the 16-bit one's complement of the one's complement sum of this string.
 /// </param>
 /// <param name="homeAgentAddresses">A list of alternate home agent addresses for the mobile node.</param>
 /// <param name="options">Zero or more TLV-encoded mobility options.</param>
 public IpV6ExtensionHeaderMobilityHomeAgentSwitchMessage(IpV4Protocol?nextHeader, ushort checksum, ReadOnlyCollection <IpV6Address> homeAgentAddresses,
                                                          IpV6MobilityOptions options)
     : base(nextHeader, checksum, options,
            MessageDataOffset.HomeAgentAddresses + (homeAgentAddresses == null ? 0 : homeAgentAddresses.Count) * IpV6Address.SizeOf)
 {
     if (homeAgentAddresses == null)
     {
         throw new ArgumentNullException("homeAgentAddresses");
     }
     HomeAgentAddresses = homeAgentAddresses;
 }
Example #15
0
        internal static IpV6ExtensionHeaderMobilityCareOfTestInit ParseMessageData(IpV4Protocol nextHeader, ushort checksum, DataSegment messageData)
        {
            if (messageData.Length < MinimumMessageDataLength)
            {
                return(null);
            }

            ulong careOfInitCookie      = messageData.ReadULong(MessageDataOffset.CareOfInitCookie, Endianity.Big);
            IpV6MobilityOptions options = new IpV6MobilityOptions(messageData.Subsegment(MessageDataOffset.Options, messageData.Length - MessageDataOffset.Options));

            return(new IpV6ExtensionHeaderMobilityCareOfTestInit(nextHeader, checksum, careOfInitCookie, options));
        }
 internal IpV6ExtensionHeaderMobilityBindingUpdateBase(IpV4Protocol?nextHeader, ushort checksum, ushort sequenceNumber, bool acknowledge,
                                                       bool homeRegistration, bool linkLocalAddressCompatibility, bool keyManagementMobilityCapability,
                                                       ushort lifetime, IpV6MobilityOptions options)
     : base(nextHeader, checksum, options, MessageDataOffset.Options)
 {
     SequenceNumber   = sequenceNumber;
     Acknowledge      = acknowledge;
     HomeRegistration = homeRegistration;
     LinkLocalAddressCompatibility   = linkLocalAddressCompatibility;
     KeyManagementMobilityCapability = keyManagementMobilityCapability;
     Lifetime = lifetime;
 }
Example #17
0
        internal static IpV6ExtensionHeaderMobilityHandoverAcknowledgeMessage ParseMessageData(IpV4Protocol nextHeader, ushort checksum, DataSegment messageData)
        {
            if (messageData.Length < MinimumMessageDataLength)
            {
                return(null);
            }

            ushort sequenceNumber = messageData.ReadUShort(MessageDataOffset.SequenceNumber, Endianity.Big);
            IpV6MobilityHandoverAcknowledgeCode code = (IpV6MobilityHandoverAcknowledgeCode)messageData[MessageDataOffset.Code];
            IpV6MobilityOptions options = new IpV6MobilityOptions(messageData.Subsegment(MessageDataOffset.Options, messageData.Length - MessageDataOffset.Options));

            return(new IpV6ExtensionHeaderMobilityHandoverAcknowledgeMessage(nextHeader, checksum, sequenceNumber, code, options));
        }
Example #18
0
        internal static IpV6ExtensionHeaderMobilityBindingError ParseMessageData(IpV4Protocol nextHeader, ushort checksum, DataSegment messageData)
        {
            if (messageData.Length < MinimumMessageDataLength)
            {
                return(null);
            }

            IpV6BindingErrorStatus status      = (IpV6BindingErrorStatus)messageData[MessageDataOffset.Status];
            IpV6Address            homeAddress = messageData.ReadIpV6Address(MessageDataOffset.HomeAddress, Endianity.Big);
            IpV6MobilityOptions    options     = new IpV6MobilityOptions(messageData.Subsegment(MessageDataOffset.Options, messageData.Length - MessageDataOffset.Options));

            return(new IpV6ExtensionHeaderMobilityBindingError(nextHeader, checksum, status, homeAddress, options));
        }
        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 IpV6ExtensionHeaderMobilityHomeTest ParseMessageData(IpV4Protocol nextHeader, ushort checksum, DataSegment messageData)
        {
            if (messageData.Length < MinimumMessageDataLength)
            {
                return(null);
            }

            ushort homeNonceIndex       = messageData.ReadUShort(MessageDataOffset.HomeNonceIndex, Endianity.Big);
            ulong  homeInitCookie       = messageData.ReadULong(MessageDataOffset.HomeInitCookie, Endianity.Big);
            ulong  homeKeygenToken      = messageData.ReadULong(MessageDataOffset.HomeKeygenToken, Endianity.Big);
            IpV6MobilityOptions options = new IpV6MobilityOptions(messageData.Subsegment(MessageDataOffset.Options, messageData.Length - MessageDataOffset.Options));

            return(new IpV6ExtensionHeaderMobilityHomeTest(nextHeader, checksum, homeNonceIndex, homeInitCookie, homeKeygenToken, options));
        }
 internal IpV6ExtensionHeaderMobility(IpV4Protocol?nextHeader, ushort checksum, IpV6MobilityOptions mobilityOptions, int?messageDataMobilityOptionsOffset)
     : base(nextHeader)
 {
     if (messageDataMobilityOptionsOffset.HasValue)
     {
         int mobilityOptionsExtraBytes = (8 - (messageDataMobilityOptionsOffset.Value + 6) % 8) % 8;
         if (mobilityOptions.BytesLength % 8 != mobilityOptionsExtraBytes)
         {
             mobilityOptions = mobilityOptions.Pad((8 + mobilityOptionsExtraBytes - (mobilityOptions.BytesLength % 8)) % 8);
         }
     }
     Checksum        = checksum;
     MobilityOptions = mobilityOptions;
 }
        internal static bool ParseMessageDataToFields(DataSegment messageData, out ushort sequenceNumber, out ushort lifetime, out IpV6MobilityOptions options)
        {
            if (messageData.Length < MinimumMessageDataLength)
            {
                sequenceNumber = 0;
                lifetime       = 0;
                options        = null;
                return(false);
            }

            sequenceNumber = messageData.ReadUShort(MessageDataOffset.SequenceNumber, Endianity.Big);
            lifetime       = messageData.ReadUShort(MessageDataOffset.Lifetime, Endianity.Big);
            options        = new IpV6MobilityOptions(messageData.Subsegment(MessageDataOffset.Options, messageData.Length - MessageDataOffset.Options));
            return(true);
        }
        internal static IpV6ExtensionHeaderMobilityHandoverInitiateMessage ParseMessageData(IpV4Protocol nextHeader, ushort checksum, DataSegment messageData)
        {
            if (messageData.Length < MinimumMessageDataLength)
            {
                return(null);
            }

            ushort sequenceNumber = messageData.ReadUShort(MessageDataOffset.SequenceNumber, Endianity.Big);
            bool   assignedAddressConfiguration = messageData.ReadBool(MessageDataOffset.AssignedAddressConfiguration,
                                                                       MessageDataMask.AssignedAddressConfiguration);
            bool buffer = messageData.ReadBool(MessageDataOffset.Buffer, MessageDataMask.Buffer);
            IpV6HandoverInitiateMessageCode code    = (IpV6HandoverInitiateMessageCode)messageData[MessageDataOffset.Code];
            IpV6MobilityOptions             options = new IpV6MobilityOptions(messageData.Subsegment(MessageDataOffset.Options, messageData.Length - MessageDataOffset.Options));

            return(new IpV6ExtensionHeaderMobilityHandoverInitiateMessage(nextHeader, checksum, sequenceNumber, assignedAddressConfiguration, buffer, code, options));
        }
Example #24
0
        internal static bool ParseMessageDataFields(DataSegment messageData, out IpV6BindingAcknowledgementStatus status,
                                                    out bool keyManagementMobilityCapability, out ushort sequenceNumber, out ushort lifetime,
                                                    out IpV6MobilityOptions options)
        {
            if (messageData.Length < MinimumMessageDataLength)
            {
                status = IpV6BindingAcknowledgementStatus.BindingUpdateAccepted;
                keyManagementMobilityCapability = false;
                sequenceNumber = 0;
                lifetime       = 0;
                options        = null;
                return(false);
            }

            status = (IpV6BindingAcknowledgementStatus)messageData[MessageDataOffset.Status];
            keyManagementMobilityCapability = messageData.ReadBool(MessageDataOffset.KeyManagementMobilityCapability,
                                                                   MessageDataMask.KeyManagementMobilityCapability);

            sequenceNumber = messageData.ReadUShort(MessageDataOffset.SequenceNumber, Endianity.Big);
            lifetime       = messageData.ReadUShort(MessageDataOffset.Lifetime, Endianity.Big);
            options        = new IpV6MobilityOptions(messageData.Subsegment(MessageDataOffset.Options, messageData.Length - MessageDataOffset.Options));
            return(true);
        }
 /// <summary>
 /// Creates an instance from next header, checksum, sequence number, acknowledge, home registration, link local address compatibility,
 /// key management mobiltiy capability, map registration, mobile router, proxy registration flag, forcing UDP encapsulation, TLV header format,
 /// bulk binding update, lifetime and options.
 /// </summary>
 /// <param name="nextHeader">Identifies the type of header immediately following this extension header.</param>
 /// <param name="checksum">
 /// Contains the checksum of the Mobility Header.
 /// The checksum is calculated from the octet string consisting of a "pseudo-header"
 /// followed by the entire Mobility Header starting with the Payload Proto field.
 /// The checksum is the 16-bit one's complement of the one's complement sum of this string.
 /// </param>
 /// <param name="sequenceNumber">
 /// Used by the receiving node to sequence Binding Updates and by the sending node to match a returned Binding Acknowledgement with this Binding Update.
 /// </param>
 /// <param name="acknowledge">
 /// Set by the sending mobile node to request a Binding Acknowledgement be returned upon receipt of the Binding Update.
 /// For Fast Binding Update this must be set to one to request that PAR send a Fast Binding Acknowledgement message.
 /// </param>
 /// <param name="homeRegistration">
 /// Set by the sending mobile node to request that the receiving node should act as this node's home agent.
 /// The destination of the packet carrying this message must be that of a router sharing the same subnet prefix as the home address
 /// of the mobile node in the binding.
 /// For Fast Binding Update this must be set to one.
 /// </param>
 /// <param name="linkLocalAddressCompatibility">
 /// Set when the home address reported by the mobile node has the same interface identifier as the mobile node's link-local address.
 /// </param>
 /// <param name="keyManagementMobilityCapability">
 /// If this is cleared, the protocol used for establishing the IPsec security associations between the mobile node and the home agent
 /// does not survive movements.
 /// It may then have to be rerun. (Note that the IPsec security associations themselves are expected to survive movements.)
 /// If manual IPsec configuration is used, the bit must be cleared.
 /// </param>
 /// <param name="mapRegistration">
 /// Indicates MAP registration.
 /// When a mobile node registers with the MAP, the MapRegistration and Acknowledge must be set to distinguish this registration
 /// from a Binding Update being sent to the Home Agent or a correspondent node.
 /// </param>
 /// <param name="mobileRouter">
 /// Indicates to the Home Agent that the Binding Update is from a Mobile Router.
 /// If false, the Home Agent assumes that the Mobile Router is behaving as a Mobile Node,
 /// and it must not forward packets destined for the Mobile Network to the Mobile Router.
 /// </param>
 /// <param name="proxyRegistration">
 /// Indicates to the local mobility anchor that the Binding Update message is a proxy registration.
 /// Must be true for proxy registrations and must be false direct registrations sent by a mobile node.
 /// </param>
 /// <param name="forcingUdpEncapsulation">
 /// Indicates a request for forcing UDP encapsulation regardless of whether a NAT is present on the path between the mobile node and the home agent.
 /// May be set by the mobile node if it is required to use UDP encapsulation regardless of the presence of a NAT.
 /// </param>
 /// <param name="typeLengthValueHeaderFormat">
 /// Indicates that the mobile access gateway requests the use of the TLV header for encapsulating IPv6 or IPv4 packets in IPv4.
 /// </param>
 /// <param name="bulkBindingUpdate">
 /// If true, it informs the local mobility anchor to enable bulk binding update support for the mobility session associated with this message.
 /// If false, the local mobility anchor must exclude the mobility session associated with this message from any bulk-binding-related operations
 /// and any binding update, or binding revocation operations with bulk-specific scope will not be relevant to that mobility session.
 /// This flag is relevant only for Proxy Mobile IPv6 and therefore must be set to false when the ProxyRegistration is false.
 /// </param>
 /// <param name="lifetime">
 /// The number of time units remaining before the binding must be considered expired.
 /// A value of zero indicates that the Binding Cache entry for the mobile node must be deleted.
 /// One time unit is 4 seconds for Binding Update and 1 second for Fast Binding Update.
 /// </param>
 /// <param name="options">Zero or more TLV-encoded mobility options.</param>
 public IpV6ExtensionHeaderMobilityBindingUpdate(IpV4Protocol?nextHeader, ushort checksum, ushort sequenceNumber, bool acknowledge, bool homeRegistration,
                                                 bool linkLocalAddressCompatibility, bool keyManagementMobilityCapability, bool mapRegistration,
                                                 bool mobileRouter, bool proxyRegistration, bool forcingUdpEncapsulation, bool typeLengthValueHeaderFormat,
                                                 bool bulkBindingUpdate, ushort lifetime, IpV6MobilityOptions options)
     : base(nextHeader, checksum, sequenceNumber, acknowledge, homeRegistration, linkLocalAddressCompatibility, keyManagementMobilityCapability,
            lifetime, options)
 {
     MapRegistration             = mapRegistration;
     MobileRouter                = mobileRouter;
     ProxyRegistration           = proxyRegistration;
     ForcingUdpEncapsulation     = forcingUdpEncapsulation;
     TypeLengthValueHeaderFormat = typeLengthValueHeaderFormat;
     BulkBindingUpdate           = bulkBindingUpdate;
 }
 /// <summary>
 /// Creates an instance from next header, checksum, status, key management mobility capability, mobile router, proxy registration, TLV header format,
 /// sequence number, lifetime and options.
 /// </summary>
 /// <param name="nextHeader">Identifies the type of header immediately following this extension header.</param>
 /// <param name="checksum">
 /// Contains the checksum of the Mobility Header.
 /// The checksum is calculated from the octet string consisting of a "pseudo-header"
 /// followed by the entire Mobility Header starting with the Payload Proto field.
 /// The checksum is the 16-bit one's complement of the one's complement sum of this string.
 /// </param>
 /// <param name="status">
 /// Indicating the disposition of the Binding Update.
 /// Values of the Status field less than 128 indicate that the Binding Update was accepted by the receiving node.
 /// Values greater than or equal to 128 indicate that the Binding Update was rejected by the receiving node.
 /// </param>
 /// <param name="keyManagementMobilityCapability">
 /// If this is cleared, the protocol used by the home agent for establishing the IPsec security associations between the mobile node and the home agent
 /// does not survive movements.
 /// It may then have to be rerun.
 /// (Note that the IPsec security associations themselves are expected to survive movements.)
 /// </param>
 /// <param name="mobileRouter">
 /// Indicates that the Home Agent that processed the Binding Update supports Mobile Routers.
 /// True only if the corresponding Binding Update had the Mobile Router set to true.
 /// </param>
 /// <param name="proxyRegistration">
 /// Indicates that the local mobility anchor that processed the corresponding Proxy Binding Update message supports proxy registrations.
 /// True only if the corresponding Proxy Binding Update had the Proxy Registration set to true.
 /// </param>
 /// <param name="typeLengthValueHeaderFormat">
 /// Indicates that the sender of the Proxy Binding Acknowledgement, the LMA, supports tunneling IPv6-or-IPv4 in IPv4 using TLV-header format.
 /// </param>
 /// <param name="sequenceNumber">
 /// Copied from the Sequence Number field in the Binding Update.
 /// It is used by the mobile node in matching this Binding Acknowledgement with an outstanding Binding Update.
 /// </param>
 /// <param name="lifetime">
 /// The granted lifetime, in time units of 4 seconds for Binding Acknowledgement and 1 second for Fast Binding Acknowledgement,
 /// for which this node should retain the entry for this mobile node in its Binding Cache.
 /// </param>
 /// <param name="options">Zero or more TLV-encoded mobility options.</param>
 public IpV6ExtensionHeaderMobilityBindingAcknowledgement(IpV4Protocol?nextHeader, ushort checksum, IpV6BindingAcknowledgementStatus status,
                                                          bool keyManagementMobilityCapability, bool mobileRouter, bool proxyRegistration,
                                                          bool typeLengthValueHeaderFormat, ushort sequenceNumber, ushort lifetime, IpV6MobilityOptions options)
     : base(nextHeader, checksum, status, keyManagementMobilityCapability, sequenceNumber, lifetime, options)
 {
     MobileRouter                = mobileRouter;
     ProxyRegistration           = proxyRegistration;
     TypeLengthValueHeaderFormat = typeLengthValueHeaderFormat;
 }
 /// <summary>
 /// Creates an instance from next header, checksum and options.
 /// </summary>
 /// <param name="nextHeader">Identifies the type of header immediately following this extension header.</param>
 /// <param name="checksum">
 /// Contains the checksum of the Mobility Header.
 /// The checksum is calculated from the octet string consisting of a "pseudo-header"
 /// followed by the entire Mobility Header starting with the Payload Proto field.
 /// The checksum is the 16-bit one's complement of the one's complement sum of this string.
 /// </param>
 /// <param name="options">Zero or more TLV-encoded mobility options.</param>
 public IpV6ExtensionHeaderMobilityBindingRefreshRequest(IpV4Protocol?nextHeader, ushort checksum, IpV6MobilityOptions options)
     : base(nextHeader, checksum, options, MessageDataOffset.Options)
 {
 }
Example #28
0
 /// <summary>
 /// Creates an instance from next header, checksum, sequence number, lifetime and options.
 /// </summary>
 /// <param name="nextHeader">
 /// Identifies the type of header immediately following this extension header.
 /// </param>
 /// <param name="checksum">
 /// Contains the checksum of the Mobility Header.
 /// The checksum is calculated from the octet string consisting of a "pseudo-header"
 /// followed by the entire Mobility Header starting with the Payload Proto field.
 /// The checksum is the 16-bit one's complement of the one's complement sum of this string.
 /// </param>
 /// <param name="sequenceNumber">
 /// A monotonically increasing integer. Set by a sending node in a request message, and used to match a reply to the request.
 /// </param>
 /// <param name="lifetime">
 /// The requested time in seconds for which the sender wishes to have local forwarding.
 /// A value of 0xffff (all ones) indicates an infinite lifetime.
 /// When set to 0, indicates a request to stop localized routing.
 /// </param>
 /// <param name="options">
 /// Zero or more TLV-encoded mobility options.
 /// </param>
 public IpV6ExtensionHeaderMobilityLocalizedRoutingInitiation(IpV4Protocol?nextHeader, ushort checksum, ushort sequenceNumber,
                                                              ushort lifetime, IpV6MobilityOptions options)
     : base(nextHeader, checksum, sequenceNumber, lifetime, options)
 {
 }
 internal IpV6ExtensionHeaderMobilityBindingRevocationMessage(IpV4Protocol?nextHeader, ushort checksum, ushort sequenceNumber, bool proxyBinding,
                                                              bool ipV4HomeAddressBindingOnly, bool global, IpV6MobilityOptions options)
     : base(nextHeader, checksum, options, MessageDataOffset.Options)
 {
     SequenceNumber             = sequenceNumber;
     ProxyBinding               = proxyBinding;
     IpV4HomeAddressBindingOnly = ipV4HomeAddressBindingOnly;
     Global = global;
 }
Example #30
0
 /// <summary>
 /// Creates an instance from next header, checksum, care of init cookie and options.
 /// </summary>
 /// <param name="nextHeader">Identifies the type of header immediately following this extension header.</param>
 /// <param name="checksum">
 /// Contains the checksum of the Mobility Header.
 /// The checksum is calculated from the octet string consisting of a "pseudo-header"
 /// followed by the entire Mobility Header starting with the Payload Proto field.
 /// The checksum is the 16-bit one's complement of the one's complement sum of this string.
 /// </param>
 /// <param name="careOfInitCookie">Contains a random value, the care-of init cookie.</param>
 /// <param name="options">Zero or more TLV-encoded mobility options.</param>
 public IpV6ExtensionHeaderMobilityCareOfTestInit(IpV4Protocol?nextHeader, ushort checksum, ulong careOfInitCookie, IpV6MobilityOptions options)
     : base(nextHeader, checksum, options, MessageDataOffset.Options)
 {
     CareOfInitCookie = careOfInitCookie;
 }