Files
2026-07-30 11:19:44 +05:30

1134 lines
40 KiB
C

/* ipmip6_mh_pkt.h - ipmip6_mh_pkt.h */
/*
******************************************************************************
* HEADER FILE
*
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip6_mh_pkt.h,v $ $Revision: 1.24 $
* $Source: /home/interpeak/CVSRoot/ipmip6/include/private/ipmip6_mh_pkt.h,v $
* $Author: jhorteli $ $Date: 2011-01-21 15:31:47 $
* $State: Exp $ $Locker: $
*
* INTERPEAK_COPYRIGHT_STRING
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
******************************************************************************
*/
#ifndef IPMIP6_MH_PKT_H
#define IPMIP6_MH_PKT_H
/*
****************************************************************************
* 1 DESCRIPTION
****************************************************************************
*/
/*
DESCRIPTION
This module defines the Mobile Header values. Such as mesage types,
error code, options and structures.
EXAMPLE
This example shows how an incoming MIP6 frame could be parsed using the
process options routine.
.CS
void my_parse_request(struct Ipmip6_my_context *ctx, Ipmip_proc_t *proc, Ipmip6_pktbuf_t *pbuf)
{
if (ipmip6_mh_pkt_process_options(&ctx->ipmip6, proc, &pbuf->mo, IPMIP_BUFFER_PTR(&pbuf->ipmip.packet), sizeof(Ipmip6_mh_binding_update_t), (int)IPMIP_BUFFER_SIZE(&pbuf->ipmip.packet)) == IP_FALSE)
{
/@ Failed to parse the message @/
return;
}
/@ Process the request @/
}
.CE
*/
/*
****************************************************************************
* 2 CONFIGURATION
****************************************************************************
*/
/*
****************************************************************************
* 3 INCLUDE FILES
****************************************************************************
*/
#ifdef __cplusplus
extern "C" {
#endif
/*
****************************************************************************
* 4 DEFINES
****************************************************************************
*/
/* !!TBA!! */
#define IPMIP6_DSMIP_UDP_PORT 8000
/* Binding Refresh Advice in BA from HA during Home Registration
* Alignment: 2n */
#define IPMIP6_MH_MO_BINDING_REFRESH_ADVICE 2
/* Alternate Care-Of address for BU.
* Alignment: 8n+6 */
#define IPMIP6_MH_MO_ALTERNATE_CARE_OF_ADDRESS 3
/* In BU for correspondent node. Needs Binding Authorization Data
* Alignment: 2n */
#define IPMIP6_MH_MO_NONCE_INDICES 4
/* Binding Authorization Data.
* Implicit alignemnt: 8n+2
* Must be last option */
#define IPMIP6_MH_MO_BINDING_AUTHORIZATION_DATA 5
/* Mobile Prefix.
* Alignment: 8n+4 */
#define IPMIP6_MH_MO_BINDING_MOBILE_PREFIX 6
/* Mobile node identifier
* No alignment requirement */
#define IPMIP6_MH_MO_MOBILE_NODE_IDENTIFIER 8
# define IPMIP6_MH_MO_MOBILE_NODE_IDENTIFIER_MN_NAI 1
/* Vendor Specific Option; RFC5094 */
#define IPMIP6_MH_MO_VENDOR_SPECIFIC_MOBILITY_OPTION 19
/* Service Selection Specific Option; RFC5149 */
#define IPMIP6_MH_MO_SERVICE_SELECTION_MOBILITY_OPTION 20
/* Proxy Mobility Options; RFC5213 */
#define IPMIP6_MH_MO_PMIPV6_HOME_NETWORK_PREFIX_OPTION 22
#define IPMIP6_MH_MO_PMIPV6_HANDOFF_INDICATOR_OPTION 23
# define IPMIP6_MH_MO_PMIPV6_HANDOFF_INDICATOR_NEW_INTERFACE 1
# define IPMIP6_MH_MO_PMIPV6_HANDOFF_INDICATOR_DIFFERENT_INTERFACE 2
# define IPMIP6_MH_MO_PMIPV6_HANDOFF_INDICATOR_SAME_INTERFACE_NEW_MAG 3
# define IPMIP6_MH_MO_PMIPV6_HANDOFF_INDICATOR_UNKNOWN 4
# define IPMIP6_MH_MO_PMIPV6_HANDOFF_INDICATOR_NOT_CHANGED 5
#define IPMIP6_MH_MO_PMIPV6_ACCESS_TECHNOLOGY_TYPE_OPTION 24
# define IPMIP6_MH_MO_PMIPV6_ACCESS_TECHNOLOGY_TYPE_VIRTUAL 1
# define IPMIP6_MH_MO_PMIPV6_ACCESS_TECHNOLOGY_TYPE_PPP 2
# define IPMIP6_MH_MO_PMIPV6_ACCESS_TECHNOLOGY_TYPE_ETHERNET 3
# define IPMIP6_MH_MO_PMIPV6_ACCESS_TECHNOLOGY_TYPE_WLAN 4
# define IPMIP6_MH_MO_PMIPV6_ACCESS_TECHNOLOGY_TYPE_WIMAX 5
#define IPMIP6_MH_MO_PMIPV6_MN_LINK_LAYER_IDENTIFIER_OPTION 25
#define IPMIP6_MH_MO_PMIPV6_LINK_LOCAL_ADDRESS_OPTION 26
#define IPMIP6_MH_MO_PMIPV6_TIMESTAMP_OPTION 27
/* RFC5555 */
/* v4 Home Address Request Option */
#define IPMIP6_MH_MO_DSMIPV6_IPV4_HOME_ADDRESS 29
# define IPMIP6_MH_MO_DSMIPV6_IPV4_HOME_ADDRESS_P (1 << 9)
# define IPMIP6_MH_MO_DSMIPV6_IPV4_HOME_ADDRESS_PREF 10
/* v4 Care of Address Option */
#define IPMIP6_MH_MO_DSMIPV6_IPV4_CARE_OF_ADDRESS 32
/* v4 Home Address Acknowledgement Option */
#define IPMIP6_MH_MO_DSMIPV6_IPV4_HOME_ADDRESS_ACK 30
# define IPMIP6_MH_MO_DSMIPV6_IPV4_HOME_ADDRESS_ACK_PREF 2
/* v4 NAT Detection Option */
#define IPMIP6_MH_MO_DSMIPV6_IPV4_NAT_DETECT 31
# define IPMIP6_MH_MO_DSMIPV6_IPV4_NAT_DETECT_F (1 << 15)
/* !!DSMIP NETLMM Definitions; values TBD!! */
#define IPMIP6_MH_MO_PDSMIPV6_IPV4_DEFAULT_ROUTER_ADDRESS 251
#define IPMIP6_MH_MO_PDSMIPV6_IPV4_DHCP_SUPPORT_MODE 250
# define IPMIP6_MH_MO_PDSMIPV6_IPV4_DHCP_SUPPORT_MODE_S (1 << 0)
/* !!GREKEY NETLMM defintions; values TBD!!! */
#define IPMIP6_MH_MO_GRE_KEY_OPTION 249
/*!! TBD -- HEARTBEAT MESSAGE OPTION !!!*/
#define IPMIP6_MH_MO_HEARTBEAT_RESTART_COUNTER 248
/*
****************************************************************************
* Mobility Header Types
****************************************************************************
*/
#define IPMIP6_MH_BINDING_REFRESH_REQUEST 0
#define IPMIP6_MH_HOME_TEST_INIT 1
#define IPMIP6_MH_CARE_OF_TEST_INIT 2
#define IPMIP6_MH_HOME_TEST 3
#define IPMIP6_MH_CARE_OF_TEST 4
#define IPMIP6_MH_BINDING_UPDATE 5
#define IPMIP6_MH_BINDING_ACKNOWLEDGEMENT 6
#define IPMIP6_MH_BINDING_ERROR 7
/*!! TBD -- HEARTBEAT MESSAGE !!!*/
#define IPMIP6_MH_HEARTBEAT_MESSAGE 254
/*!! TBD -- REVOCATION !!!*/
#define IPMIP6_MH_BINDING_REVOCATION_MESSAGE 253
/*
****************************************************************************
* Mobility Header Binding Update (5) FLAG definitions
****************************************************************************
*/
/* Request Binding Acknowledgement */
#define IPMIP6_MH_BU_A (1 << 15)
/* Receiving node should act as home agent */
#define IPMIP6_MH_BU_H (1 << 14)
/* Link-Local Compatibility. MN's link-local address and home address
* has same Interface identifier */
#define IPMIP6_MH_BU_L (1 << 13)
/* If cleared, protocol for establishing security associations does not
* survive movements */
#define IPMIP6_MH_BU_K (1 << 12)
/* Mobile router flag */
#define IPMIP6_MH_BU_R (1 << 10)
/* Proxy Mobility Flag */
#define IPMIP6_MH_BU_P (1 << 9)
/* NAT-T Force flag */
#define IPMIP6_MH_BU_F (1 << 8)
/* NAT-T TLV Support flag */
#define IPMIP6_MH_BU_T (1 << 7)
#define IPMIP6_MH_BU_IS_P(f) (((f) & (IPMIP6_MH_BU_H|IPMIP6_MH_BU_R|IPMIP6_MH_BU_P)) == (IPMIP6_MH_BU_P|IPMIP6_MH_BU_H))
#define IPMIP6_MH_BU_IS_H(f) (((f) & (IPMIP6_MH_BU_H|IPMIP6_MH_BU_P)) == (IPMIP6_MH_BU_H))
#define IPMIP6_MH_BU_IS_R(f) (((f) & (IPMIP6_MH_BU_H|IPMIP6_MH_BU_R)) == (IPMIP6_MH_BU_H|IPMIP6_MH_BU_R))
/*
****************************************************************************
* Mobility Header Binding Acknowledgement (6) FLAG definitions
****************************************************************************
*/
/* If cleared, protocol for establishing security associations does not
* survive movements */
#define IPMIP6_MH_BA_K (1 << 7)
/* Mobile Router */
#define IPMIP6_MH_BA_R (1 << 6)
/* Proxy Mobility Flag */
#define IPMIP6_MH_BA_P (1 << 5)
/* UDP ENCAP TLV support */
#define IPMIP6_MH_BA_T (1 << 4)
/*
****************************************************************************
* Mobility Header Binding Acknowledgement (6) STATUS definitions
****************************************************************************
*/
/* Success results. */
/* Status OK */
#define IPMIP6_MH_BA_STATUS_SUCCESS_ACCEPTED 0
/* Status OK, prefix discovery necessary */
#define IPMIP6_MH_BA_STATUS_SUCCESS_PREFIX_DISCOVERY 1
/* !!VALUE TBD: Status OK, GRE key option not required!! */
#define IPMIP6_MH_BA_STATUS_SUCCESS_GRE_KEY_OPTION_NOT_REQUIRED 2
#define IPMIP6_MH_BA_STATUS_SUCCESS_GRE_TUNNELING_BUT_TLV_NOT_SUPPORTED 3
/* Error results. */
/* Unspecified error */
#define IPMIP6_MH_BA_STATUS_ERROR_UNKNOWN 128
/* Administratively prohibited */
#define IPMIP6_MH_BA_STATUS_ERROR_PROHIBITED 129
/* Insufficient resources */
#define IPMIP6_MH_BA_STATUS_ERROR_RESOURCES 130
/* Home registration unsupported */
#define IPMIP6_MH_BA_STATUS_ERROR_HOME_REGISTRATION_UNSUPPORTED 131
/* Not home subnet */
#define IPMIP6_MH_BA_STATUS_ERROR_NOT_HOME_SUBNET 132
/* Not home agent for this mobile node */
#define IPMIP6_MH_BA_STATUS_ERROR_NOT_HOME_AGENT 133
/* Duplicate Address Detection failed for Home Agent. */
#define IPMIP6_MH_BA_STATUS_ERROR_DUPLICATE_ADDRESS_DETECTION 134
/* Sequence number out of window */
#define IPMIP6_MH_BA_STATUS_ERROR_SEQUENCE_NUMBER 135
/* The Home Nonce Index has expired */
#define IPMIP6_MH_BA_STATUS_ERROR_EXPIRED_HOME_NONCE 136
/* The Care-Of Nonce Index has expired */
#define IPMIP6_MH_BA_STATUS_ERROR_EXPIRED_CARE_OF_NONCE 137
/* The Home and Care-Of Nonce Indices has expired */
#define IPMIP6_MH_BA_STATUS_ERROR_EXPIRED_NONCES 138
/* Registration Type Change disallowed */
#define IPMIP6_MH_BA_STATUS_ERROR_REGISTRATION_TYPE_CHANGE 139
/* Mobile Router Operation not permitted */
#define IPMIP6_MH_BA_STATUS_ERROR_MOBILE_ROUTER_UNSUPPORTED 140
/* Mobile Router Invalid Prefix */
#define IPMIP6_MH_BA_STATUS_ERROR_INVALID_PREFIX 141
/* Mobile Router Not Authorized for Prefix */
#define IPMIP6_MH_BA_STATUS_ERROR_UNAUTHORIZED_PREFIX 142
/* Mobile Router Forwarding setup failed (prefix missing) */
#define IPMIP6_MH_BA_STATUS_ERROR_FORWARDING_SETUP_FAILED 143
/* Home Agent do not allow UDP force */
#define IPMIP6_MH_BA_STATUS_ERROR_CANNOT_FORCE_UDP_ENCAPSULATION 144
/* Service selection */
#define IPMIP6_MH_BA_STATUS_ERROR_SERVICE_AUTHORIZATION_FAILED 151
/* Proxy Mobile IP BA STATUS messages */
/* Proxy registration not enabled for the mobile node */
#define IPMIP6_MH_BA_STATUS_ERROR_PROXY_REG_NOT_ENABLED 152
/* Not local mobility anchor for this mobile node */
#define IPMIP6_MH_BA_STATUS_ERROR_NOT_LMA_FOR_THIS_MOBILE_NODE 153
/* The mobile access gateway is not authorized to send proxy binding updates */
#define IPMIP6_MH_BA_STATUS_ERROR_MAG_NOT_AUTHORIZED_FOR_PROXY_REG 154
/* The mobile node is not authorized for one or more of the
requesting home network prefixes */
#define IPMIP6_MH_BA_STATUS_ERROR_NOT_AUTHORIZED_FOR_HOME_NETWORK_PREFIX 155
/* Invalid timestamp value (the clocks are out of sync) */
#define IPMIP6_MH_BA_STATUS_ERROR_TIMESTAMP_MISMATCH 156
/* The timestamp value is lower than the previously accepted value */
#define IPMIP6_MH_BA_STATUS_ERROR_TIMESTAMP_LOWER_THAN_PREV_ACCEPTED 157
/* Missing home network prefix option */
#define IPMIP6_MH_BA_STATUS_ERROR_MISSING_HOME_NETWORK_PREFIX_OPTION 158
/* All the home network prefixes listed in the BCE do not match all
the prefixes in the received PBU */
#define IPMIP6_MH_BA_STATUS_ERROR_BCE_PBU_PREFIX_SET_DO_NOT_MATCH 159
/* Missing mobile node identifier option */
#define IPMIP6_MH_BA_STATUS_ERROR_MISSING_MN_IDENTIFIER_OPTION 160
/* Missing handoff indicator option */
#define IPMIP6_MH_BA_STATUS_ERROR_MISSING_HANDOFF_INDICATOR_OPTION 161
/* Missing access technology type option */
#define IPMIP6_MH_BA_STATUS_ERROR_MISSING_ACCESS_TECH_TYPE_OPTION 162
/* TBD - NETLMM PMIPv6 / DSMIPv6 draft */
#define IPMIP6_MH_BA_STATUS_ERROR_NOT_AUTHORIZED_FOR_IPV4_HOME_ADDRESS 240
#define IPMIP6_MH_BA_STATUS_ERROR_NOT_AUTHORIZED_FOR_IPV6_HOME_NETWORK_PREFIX 241
#define IPMIP6_MH_BA_STATUS_ERROR_MULTIPLE_IPV4_HOME_ADDRESS_ASSIGNMENT_NOT_SUPPORTED 242
#define IPMIP6_MH_BA_STATUS_ERROR_IPV4_PREFIX_ASSIGNMENT_NOT_SUPPORTED 243
#define IPMIP6_MH_BA_STATUS_ERROR_GRE_KEY_OPTION_REQUIRED 244
#define IPMIP6_MH_BA_STATUS_SUCCESS(x)((x) < IPMIP6_MH_BA_STATUS_ERROR_UNKNOWN)
#define IPMIP6_MH_BA_STATUS_ERROR(x) ((x) >= IPMIP6_MH_BA_STATUS_ERROR_UNKNOWN)
/*
****************************************************************************
* Mobility Header Binding Error (7) STATUS definitions
****************************************************************************
*/
/* Unknown binding for Home Address Destination Option */
#define IPMIP6_MH_BE_STATUS_ERROR_UNKNOWN_BINDING 1
/* Unrecognized MH Type */
#define IPMIP6_MH_BE_STATUS_ERROR_UNKNOWN_MH_TYPE 2
/*
****************************************************************************
* Mobility Header DSMIPv6 (7) STATUS definitions
****************************************************************************
*/
#define IPMIP6_MH_BU_DSMIPV6_HOA_ACK_SUCCESS 0
#define IPMIP6_MH_BU_DSMIPV6_HOA_ACK_REASON_UNSPECIFIED 128
#define IPMIP6_MH_BU_DSMIPV6_HOA_ACK_ADMIN_PROHIBITED 129
#define IPMIP6_MH_BU_DSMIPV6_HOA_ACK_INCORRECT_HOA 130
#define IPMIP6_MH_BU_DSMIPV6_HOA_ACK_INVALID_ADDRESS 131
#define IPMIP6_MH_BU_DSMIPV6_HOA_ACK_DYNAMIC_HOA_UNAVAILABLE 132
#define IPMIP6_MH_BU_DSMIPV6_HOA_ACK_PREFIX_UNAUTHORIZED 133
/* DSMIPv6 Protocol constants */
#define IPMIP6_NATKATIMEOUT 110
/* Mobility Header Binding Revocation */
#define IPMIP6_MH_BR_INDICATION 1
#define IPMIP6_MH_BR_ACKNOWLEDGEMENT 2
#define IPMIP6_MH_BRI_TRIGGER_RESERVED 0
#define IPMIP6_MH_BRI_TRIGGER_UNSPECIFIED 1
#define IPMIP6_MH_BRI_TRIGGER_ADMINISTRATIVE_REASON 2
#define IPMIP6_MH_BRI_TRIGGER_INTER_MAG_SAME_ACCESS_TYPE 3
#define IPMIP6_MH_BRI_TRIGGER_INTER_MAG_DIFFERENT_ACCESS_TYPE 4
#define IPMIP6_MH_BRI_TRIGGER_INTER_MAG_UNKNOWN_HANDOFF 5
#define IPMIP6_MH_BRI_TRIGGER_USER_INITIATED_SESSION_TERMINATION 6
#define IPMIP6_MH_BRI_TRIGGER_ACCESS_NETWORK_SESSION_TERMINATION 7
#define IPMIP6_MH_BRI_TRIGGER_POSSIBLE_OUT_OF_SYNC_BCE_STATE 8
#define IPMIP6_MH_BRI_TRIGGER_PER_PEER_POLICY 128
#define IPMIP6_MH_BRI_TRIGGER_REVOKING_NODE_LOCAL_POLICY 129
#define IPMIP6_MH_BRA_STATUS_SUCCESS 0
#define IPMIP6_MH_BRA_STATUS_PARTIAL_SUCCESS 1
#define IPMIP6_MH_BRA_STATUS_BINDING_DOES_NOT_EXIST 128
#define IPMIP6_MH_BRA_STATUS_IPV4_HOA_OPTION_REQUIRED 129
#define IPMIP6_MH_BRA_STATUS_GLOBAL_REVOCATION_NOT_AUTHORIZED 130
#define IPMIP6_MH_BRA_STATUS_REVOKED_MOBILE_NODES_IDENTITY_REQUIRED 131
#define IPMIP6_MH_BRA_STATUS_REVOCATION_FAILED_MN_IS_ATTACHED 132
#define IPMIP6_MH_BRA_STATUS_REVOCATION_TRIGGER_NOT_SUPPORTED 133
#define IPMIP6_MH_BRA_STATUS_REVOCATION_FUNCTION_NOT_SUPPORTED 134
#define IPMIP6_MH_BRA_STATUS_OK(s) ((s) == IPMIP6_MH_BRA_STATUS_SUCCESS || (s) == IPMIP6_MH_BRA_STATUS_PARTIAL_SUCCESS || (s) == IPMIP6_MH_BRA_STATUS_BINDING_DOES_NOT_EXIST)
/*
****************************************************************************
* 5 TYPES
****************************************************************************
*/
struct Ipmip6_context;
struct Ipmip6_pktbuf;
struct Ipmip_proc;
#include <ipcom_align16.h>
typedef struct IP_PACKED1 Ipmip6_mobility_header
{
Ip_u8 mh_nxt; /* Payload Proto */
Ip_u8 mh_len; /* Header Length */
Ip_u8 mh_type; /* Mobility Header Type */
Ip_u8 mh_reserved; /* Reserved, must be zero */
Ip_u16 mh_cksum; /* Checksum */
/* Sub header */
} IP_PACKED2
Ipmip6_mobility_header_t;
/*
****************************************************************************
* Mobility Header Subheaders
****************************************************************************
*/
/*
* The Binding Refresh Request (BRR) message requests a mobile node to
* update its mobility binding.
*
* MH Type 0.
* If no options specified, mobility header length is 0.
*/
typedef struct IP_PACKED1 Ipmip6_mh_binding_refresh_request
{
Ipmip6_mobility_header_t brr_hdr; /* Basic mobility header */
Ip_u16 brr_reserved; /* 16 bit reserved, must be 0 */
/* Options */
} IP_PACKED2
Ipmip6_mh_binding_refresh_request_t;
/*
* A mobile node uses the Home Test Init (HoTI) message to initiate the
* return routability procedure and request a home keygen token from a
* correspondent node
*
* MH Type 1
* If no options specified, mobility header length is 1.
*/
typedef struct IP_PACKED1 Ipmip6_mh_home_test_init
{
Ipmip6_mobility_header_t hti_hdr; /* Basic mobility header */
Ip_u16 hti_reserved; /* 16 bit reserved, must be 0 */
Ip_u8 hti_cookie[8]; /* 64 Bit random value */
/* Options */
} IP_PACKED2
Ipmip6_mh_home_test_init_t;
/*
* A mobile node uses the Care-of Test Init (CoTI) message to initiate
* the return routability procedure and request a care-of keygen token
* from a correspondent node
*
* MH Type 2
* If no options specified, mobility header length is 1.
*/
typedef struct IP_PACKED1 Ipmip6_mh_care_of_test_init
{
Ipmip6_mobility_header_t cti_hdr; /* Basic mobility header */
Ip_u16 cti_reserved; /* 16 bit reserved, must be 0 */
Ip_u8 cti_cookie[8]; /* 64 Bit random value */
/* Options */
} IP_PACKED2
Ipmip6_mh_care_of_test_init_t;
/*
* The Home Test (HoT) message is a response to the Home Test Init
* message, and is sent from the correspondent node to the mobile node
*
* MH Type 3
* If no options specified, mobility header length is 2.
*/
typedef struct IP_PACKED1 Ipmip6_mh_home_test
{
Ipmip6_mobility_header_t ht_hdr; /* Basic mobility header */
Ip_u16 ht_nonce; /* Nonce index */
Ip_u8 ht_cookie[8]; /* Home init cookie */
Ip_u8 ht_keygen[8]; /* 64 Bit Keygen token */
/* Options */
} IP_PACKED2
Ipmip6_mh_home_test_t;
/*
* The Care-of Test (CoT) message is a response to the Care-of Test Init
* message, and is sent from the correspondent node to the mobile node
*
* MH Type 4
* If no options specified, mobility header length is 2.
*/
typedef struct IP_PACKED1 Ipmip6_mh_care_of_test
{
Ipmip6_mobility_header_t ct_hdr; /* Basic mobility header */
Ip_u16 ct_nonce; /* Nonce index */
Ip_u8 ct_cookie[8]; /* Care-Of init cookie */
Ip_u8 ct_keygen[8]; /* 64 bit Keygen token */
/* Options */
} IP_PACKED2
Ipmip6_mh_care_of_test_t;
/*
* The Binding Update (BU) message is used by a mobile node to notify
* other nodes of a new care-of address for itself
*
* MH Type 5
* If no options specified, requires 4 bytes of padding and mobility
* header length is 1.
*/
typedef struct IP_PACKED1 Ipmip6_mh_binding_update
{
Ipmip6_mobility_header_t bu_hdr; /* Basic mobility header */
Ip_u16 bu_seq; /* Sequence number */
Ip_u16 bu_flags; /* Flags */
Ip_u16 bu_lifetime; /* Lifetime value (unit = 4s)*/
/* Possible Options
* - Alternate Care-Of address
* - Nonce Indices for BU to correspondent node, req. Auth Data.
* - Binding Authorization Data
*/
} IP_PACKED2
Ipmip6_mh_binding_update_t;
/*
* The Binding Acknowledgement is used to acknowledge receipt of a
* Binding Update
*
* MH Type 6
*
*/
typedef struct IP_PACKED1 Ipmip6_mh_binding_acknowledgement
{
Ipmip6_mobility_header_t ba_hdr; /* Basic mobility header */
Ip_u8 ba_status; /* Status Code */
Ip_u8 ba_flags; /* Flags */
Ip_u16 ba_seq; /* Sequence number (from BU)*/
Ip_u16 ba_lifetime; /* Lifetime value (unit = 4s) */
/* Possible Options
* - Binding Refresh Advice option from HA, in response to Home
* Registration
* - Binding Authorization Data
*/
} IP_PACKED2
Ipmip6_mh_binding_acknowledgement_t;
/*
* The Binding Error (BE) message is used by the correspondent node to
* signal an error related to mobility, such as an inappropriate attempt
* to use the Home Address destination option without an existing
* binding
*
* MH Type 7
* If no options specified, mobility header length is 2.
*/
typedef struct IP_PACKED1 Ipmip6_mh_binding_error
{
Ipmip6_mobility_header_t be_hdr; /* Basic mobility header */
Ip_u8 be_status; /* Status Code */
Ip_u8 be_reserved; /* Reserved - must be 0 */
struct Ip_in6_addr be_ha; /* Home address */
/* Options */
} IP_PACKED2
Ipmip6_mh_binding_error_t;
typedef struct IP_PACKED1 Ipmip6_mh_heartbeat_message
{
Ipmip6_mobility_header_t bh_hdr; /* Basic mobility header */
Ip_u16 bh_flags; /* Status Code */
Ip_u32 bh_seq;
/* Options */
} IP_PACKED2
Ipmip6_mh_heartbeat_message_t;
#define IPMIP6_MH_HEARTBEAT_FLAG_R (1 << 0)
#define IPMIP6_MH_HEARTBEAT_FLAG_U (1 << 1)
typedef struct IP_PACKED1 Ipmip6_mh_br_message
{
Ipmip6_mobility_header_t br_hdr; /* Basic mobility header */
Ip_u8 br_type; /* I or A */
Ip_u8 br_unknown;
/* Options */
} IP_PACKED2
Ipmip6_mh_br_message_t;
typedef struct IP_PACKED1 Ipmip6_mh_bri_message
{
Ipmip6_mobility_header_t bri_hdr; /* Basic mobility header */
Ip_u8 bri_type; /* I or A */
Ip_u8 bri_trigger; /* I or A */
Ip_u16 bri_seq;
Ip_u16 bri_flags;
/* Options */
} IP_PACKED2
Ipmip6_mh_bri_message_t;
#define IPMIP6_MH_BRI_FLAG_P (1 << 15)
#define IPMIP6_MH_BRI_FLAG_V (1 << 14)
#define IPMIP6_MH_BRI_FLAG_G (1 << 13)
typedef struct IP_PACKED1 Ipmip6_mh_bra_message
{
Ipmip6_mobility_header_t bra_hdr; /* Basic mobility header */
Ip_u8 bra_type; /* I or A */
Ip_u8 bra_status; /* I or A */
Ip_u16 bra_seq;
Ip_u16 bra_flags;
/* Options */
} IP_PACKED2
Ipmip6_mh_bra_message_t;
#define IPMIP6_MH_BRA_FLAG_P (1 << 15)
#define IPMIP6_MH_BRA_FLAG_V (1 << 14)
#define IPMIP6_MH_BRA_FLAG_G (1 << 13)
/*
****************************************************************************
* Mobility Header Mobility Options
****************************************************************************
*/
typedef struct IP_PACKED1 Ipmip6_mh_mo_hdr
{
Ip_u8 val;
Ip_u8 len;
} IP_PACKED2
Ipmip6_mh_mo_hdr_t;
/*
* The Binding Refresh Advice option is only valid in the Binding
* Acknowledgement, and only on Binding Acknowledgements sent from the
* mobile node's home agent in reply to a home registration. The
* Refresh Interval is measured in units of four seconds, and indicates
* remaining time until the mobile node SHOULD send a new home
* registration to the home agent. The Refresh Interval MUST be set to
* indicate a smaller time interval than the Lifetime value of the
* Binding Acknowledgement.
*
* Type: 2
* Alignment: 2n
*/
typedef struct IP_PACKED1 Ipmip6_mh_mo_binding_refresh_advice
{
Ipmip6_mh_mo_hdr_t hdr;
Ip_u16 interval; /* Interval, unit = 4s */
} IP_PACKED2
Ipmip6_mh_mo_binding_refresh_advice_t;
/*
* Normally, a Binding Update specifies the desired care-of address in
* the Source Address field of the IPv6 header. However, this is not
* possible in some cases, such as when the mobile node wishes to
* indicate a care-of address which it cannot use as a topologically
* correct source address (Section 6.1.7 and Section 11.7.2) or when the
* used security mechanism does not protect the IPv6 header (Section
* 11.7.1).
*
* Type: 3
* Alignemnt: 8n+6
*/
typedef struct IP_PACKED1 Ipmip6_mh_mo_alternate_care_of_address
{
Ipmip6_mh_mo_hdr_t hdr;
struct Ip_in6_addr address; /* 128 bit alternate care of address */
} IP_PACKED2
Ipmip6_mh_mo_alternate_care_of_address_t;
/*
* The Nonce Indices option is valid only in the Binding Update message
* sent to a correspondent node, and only when present together with a
* Binding Authorization Data option. When the correspondent node
* authorizes the Binding Update, it needs to produce home and care-of
* keygen tokens from its stored random nonce values.
*
* Type: 4
* Alignment: 2n
*/
typedef struct IP_PACKED1 Ipmip6_mh_mo_nonce_indices
{
Ipmip6_mh_mo_hdr_t hdr;
Ip_u16 home; /* Home Nonce Index */
Ip_u16 care_of; /* Care-Of Nonce Index */
} IP_PACKED2
Ipmip6_mh_mo_nonce_indices_t;
/*
* The Authenticator field contains a cryptographic value which can be
* used to determine that the message in question comes from the right
* authority. Rules for calculating this value depends on the used
* authorization procedure.
*
* Type: 5
* Implicit Alignment: 8n+2
*/
typedef struct IP_PACKED1 Ipmip6_mh_mo_binding_authorization_data
{
Ipmip6_mh_mo_hdr_t hdr;
Ip_u8 auth_data[12]; /* Authorization Data */
} IP_PACKED2
Ipmip6_mh_mo_binding_authorization_data_t;
typedef struct IP_PACKED1 Ipmip6_mh_mo_nai
{
Ipmip6_mh_mo_hdr_t hdr;
Ip_u8 subtype; /* Authorization Data */
Ip_u8 nai[3];
} IP_PACKED2
Ipmip6_mh_mo_nai_t;
typedef struct IP_PACKED1 Ipmip6_mh_mo_mobile_prefix
{
Ipmip6_mh_mo_hdr_t hdr;
Ip_u8 reserved; /* Authorization Data */
Ip_u8 prefix_length;
struct Ip_in6_addr prefix;
} IP_PACKED2
Ipmip6_mh_mo_mobile_prefix_t;
/* PMIPv6 Options */
typedef struct IP_PACKED1 Ipmip6_mh_mo_pmipv6_home_prefix
{
Ipmip6_mh_mo_hdr_t hdr;
Ip_u8 reserved;
Ip_u8 prefix_length;
struct Ip_in6_addr prefix;
} IP_PACKED2
Ipmip6_mh_mo_pmipv6_home_prefix_t;
typedef struct IP_PACKED1 Ipmip6_mh_mo_pmipv6_handoff_indicator
{
Ipmip6_mh_mo_hdr_t hdr;
Ip_u8 reserved;
Ip_u8 hi;
} IP_PACKED2
Ipmip6_mh_mo_pmipv6_handoff_indicator_t;
typedef struct IP_PACKED1 Ipmip6_mh_mo_pmipv6_access_technology_type
{
Ipmip6_mh_mo_hdr_t hdr;
Ip_u8 reserved;
Ip_u8 att;
} IP_PACKED2
Ipmip6_mh_mo_pmipv6_access_technology_type_t;
typedef struct IP_PACKED1 Ipmip6_mh_mo_pmipv6_mn_link_layer_id
{
Ipmip6_mh_mo_hdr_t hdr;
Ip_u16 reserved;
Ip_u8 lli[4];
} IP_PACKED2
Ipmip6_mh_mo_pmipv6_mn_link_layer_id_t;
typedef struct IP_PACKED1 Ipmip6_mh_mo_pmipv6_link_local_address
{
Ipmip6_mh_mo_hdr_t hdr;
struct Ip_in6_addr prefix;
} IP_PACKED2
Ipmip6_mh_mo_pmipv6_link_local_address_t;
typedef struct IP_PACKED1 Ipmip6_mh_mo_pmipv6_timstamp
{
Ipmip6_mh_mo_hdr_t hdr;
Ip_u64 timestamp;
} IP_PACKED2
Ipmip6_mh_mo_pmipv6_timstamp_t;
/* DSMIPv6 Options */
typedef struct IP_PACKED1 Ipmip6_mh_mo_dsmipv6_ipv4_home_address
{
Ipmip6_mh_mo_hdr_t hdr;
Ip_u16 pref_flags;
Ip_u32 home_address;
} IP_PACKED2
Ipmip6_mh_mo_dsmipv6_ipv4_home_address_t;
typedef struct IP_PACKED1 Ipmip6_mh_mo_dsmipv6_ipv4_care_of_address
{
Ipmip6_mh_mo_hdr_t hdr;
Ip_u16 reserved;
Ip_u32 care_of_address;
} IP_PACKED2
Ipmip6_mh_mo_dsmipv6_ipv4_care_of_address_t;
typedef struct IP_PACKED1 Ipmip6_mh_mo_dsmipv6_ipv4_home_address_ack
{
Ipmip6_mh_mo_hdr_t hdr;
Ip_u8 status;
Ip_u8 pref;
Ip_u32 home_address;
} IP_PACKED2
Ipmip6_mh_mo_dsmipv6_ipv4_home_address_ack_t;
typedef struct IP_PACKED1 Ipmip6_mh_mo_dsmipv6_ipv4_nat_detect
{
Ipmip6_mh_mo_hdr_t hdr;
Ip_u16 flags;
Ip_u32 refresh;
} IP_PACKED2
Ipmip6_mh_mo_dsmipv6_ipv4_nat_detect_t;
typedef struct IP_PACKED1 Ipmip6_mh_mo_pdsmipv6_ipv4_default_router_address
{
Ipmip6_mh_mo_hdr_t hdr;
Ip_u16 reserved;
Ip_u32 gw;
} IP_PACKED2
Ipmip6_mh_mo_pdsmipv6_ipv4_default_router_address_t;
typedef struct IP_PACKED1 Ipmip6_mh_mo_pdsmipv6_ipv4_dhcp_support_mode
{
Ipmip6_mh_mo_hdr_t hdr;
Ip_u16 flags;
} IP_PACKED2
Ipmip6_mh_mo_pdsmipv6_ipv4_dhcp_support_mode_t;
typedef struct IP_PACKED1 Ipmip6_mh_mo_vendor_specific_mobility_option
{
Ipmip6_mh_mo_hdr_t hdr;
Ip_u32 vendor_id;
Ip_u8 sub_type;
} IP_PACKED2
Ipmip6_mh_mo_vendor_specific_mobility_option_t;
typedef struct IP_PACKED1 Ipmip6_mh_mo_service_selection_mobility_option
{
Ipmip6_mh_mo_hdr_t hdr;
Ip_u8 identifier[1];
} IP_PACKED2
Ipmip6_mh_mo_service_selection_mobility_option_t;
typedef struct IP_PACKED1 Ipmip6_mh_mo_gre_key_option
{
Ipmip6_mh_mo_hdr_t hdr;
Ip_u16 reserved;
Ip_u32 gre_key;
} IP_PACKED2
Ipmip6_mh_mo_gre_key_option_t;
typedef struct IP_PACKED1 Ipmip6_mh_mo_heartbeat_restart_counter_option
{
Ipmip6_mh_mo_hdr_t hdr;
Ip_u32 restart_counter;
} IP_PACKED2
Ipmip6_mh_mo_heartbeat_restart_counter_option_t;
#include <ipcom_align16.h>
#define IPMIP6_MH_OPTION_ARRAY_MAX 16
typedef struct Ipmip6_mh_option_array
{
Ipmip6_mh_mo_hdr_t *hdrs[IPMIP6_MH_OPTION_ARRAY_MAX];
Ip_u32 numelem;
} Ipmip6_mh_option_array_t;
/* Support structure */
typedef struct Ipmip6_mh_options
{
/* Binding refresh advice option */
Ipmip6_mh_mo_binding_refresh_advice_t *brap;
/* Alternate care of address option */
Ipmip6_mh_mo_alternate_care_of_address_t *acoap;
/* Nonce indices option */
Ipmip6_mh_mo_nonce_indices_t *nip;
/* Binding authorization option data */
Ipmip6_mh_mo_binding_authorization_data_t *badp;
/* MN_NAI */
Ipmip6_mh_mo_nai_t *mn_naip;
/* Mobile prefixes */
Ipmip6_mh_option_array_t mobile_prefix;
/* Service Selection */
Ipmip6_mh_mo_service_selection_mobility_option_t *service_selection;
/* Gre Key */
Ipmip6_mh_mo_gre_key_option_t *gre_key;
/* Restart Option */
Ipmip6_mh_mo_heartbeat_restart_counter_option_t *restart_option;
/* Vendor Options */
Ipmip6_mh_option_array_t vendor_options;
/* PMIPV6 Options */
Ipmip6_mh_option_array_t pmipv6_home_prefix;
Ipmip6_mh_mo_pmipv6_handoff_indicator_t *pmipv6_handoff_indicator;
Ipmip6_mh_mo_pmipv6_access_technology_type_t *pmipv6_access_technology;
Ipmip6_mh_mo_pmipv6_mn_link_layer_id_t *pmipv6_mn_link_layer_id;
Ipmip6_mh_mo_pmipv6_link_local_address_t *pmipv6_link_local_address;
Ipmip6_mh_mo_pmipv6_timstamp_t *pmipv6_timestamp;
/* DSMIP options */
Ipmip6_mh_option_array_t dsmipv6_prefix_request;
Ipmip6_mh_option_array_t dsmipv6_prefix_ack;
Ipmip6_mh_mo_dsmipv6_ipv4_care_of_address_t *dsmipv6_coap;
Ipmip6_mh_mo_dsmipv6_ipv4_nat_detect_t *dsmipv6_nat_detectp;
/* NETLMM DSMIPV6 Options */
Ipmip6_mh_mo_pdsmipv6_ipv4_default_router_address_t *pdsmipv6_default_router;
Ipmip6_mh_mo_pdsmipv6_ipv4_dhcp_support_mode_t *pdsmipv6_dhcp_support_mode;
}
Ipmip6_mh_options_t;
/*
****************************************************************************
* 6 FUNCTIONS
****************************************************************************
*/
/*******************************************************************************
*
* ipmip6_mh_pkt_alloc - ipmip6_mh_pkt_alloc
*
* Allocate a MH packet.
*
* Parameters:
* \is
* \i ctx
* The generic mobility singleton context for IPMIP6. For each started mobility
* entity, there exists a mobility context which tracks configuration, system
* events, available features and started processes. The mobility context is
* created using ipmip6_context_create(). See ipmip6_context.h for
* more information regarding the mobility entity context singleton.
* \i proc
* The process context associated with the currently executing thread. Each
* thread and/or process in MIP must have its own unique process context.
* If a process is started using ipmip_proc_start, the process context will
* be allocated automatically by the IPMIP framework. Otherwise it must
* be allocated using ipmip_proc_alloc().
* \i size
* The size of the packet
* \i type
* The MH type
* \ie
*
* RETURNS: The packet buffer
*
* ERRNO:
*
*/
IP_GLOBAL struct Ipmip6_pktbuf *ipmip6_mh_pkt_alloc
(
struct Ipmip6_context *ctx,
struct Ipmip_proc *proc,
Ip_u16 size,
Ip_u8 type
);
/*******************************************************************************
*
* ipmip6_mh_pkt_opt_add - ipmip6_mh_pkt_opt_add
*
* Adds an option to the tail of the packet option list, and
* calculates the necessary padding based on the alignment requirements
*
* Parameters:
* \is
* \i ctx
* The generic mobility singleton context for IPMIP6. For each started mobility
* entity, there exists a mobility context which tracks configuration, system
* events, available features and started processes. The mobility context is
* created using ipmip6_context_create(). See ipmip6_context.h for
* more information regarding the mobility entity context singleton.
* \i proc
* The process context associated with the currently executing thread. Each
* thread and/or process in MIP must have its own unique process context.
* If a process is started using ipmip_proc_start, the process context will
* be allocated automatically by the IPMIP framework. Otherwise it must
* be allocated using ipmip_proc_alloc().
* \i pkt
* The packet
* \i type
* The option type
* \i len
* The length of data
* \i data
* The data
* \ie
*
* RETURNS: IP_TRUE on success.
*
* ERRNO:
*
*/
IP_GLOBAL Ip_bool ipmip6_mh_pkt_opt_add
(
struct Ipmip6_context *ctx,
struct Ipmip_proc *proc,
struct Ipmip6_pktbuf *pkt,
Ip_u8 type,
Ip_u8 len,
void* data
);
/*******************************************************************************
*
* ipmip6_mh_pkt_opt_add_mo - ipmip6_mh_pkt_opt_add_mo
*
* Adds an option to the tail of the packet option list, and
* calculates the necessary padding based on the alignment requirements
*
* Parameters:
* \is
* \i ctx
* The generic mobility singleton context for IPMIP6. For each started mobility
* entity, there exists a mobility context which tracks configuration, system
* events, available features and started processes. The mobility context is
* created using ipmip6_context_create(). See ipmip6_context.h for
* more information regarding the mobility entity context singleton.
* \i proc
* The process context associated with the currently executing thread. Each
* thread and/or process in MIP must have its own unique process context.
* If a process is started using ipmip_proc_start, the process context will
* be allocated automatically by the IPMIP framework. Otherwise it must
* be allocated using ipmip_proc_alloc().
* \i pkt
* The packet
* \i mo
* The mobile option
* \ie
*
* RETURNS: IP_TRUE on success.
*
* ERRNO:
*
*/
IP_GLOBAL Ip_bool ipmip6_mh_pkt_opt_add_mo
(
struct Ipmip6_context *ctx,
struct Ipmip_proc *proc,
struct Ipmip6_pktbuf *pbuf,
Ipmip6_mh_mo_hdr_t *mo
);
/*******************************************************************************
*
* ipmip6_mh_pkt_opt_add_nai - ipmip6_mh_pkt_opt_add_nai
*
* Adds a NAI option to the tail of the packet option list, and
* calculates the necessary padding based on the alignment requirements
*
* Parameters:
* \is
* \i ctx
* The generic mobility singleton context for IPMIP6. For each started mobility
* entity, there exists a mobility context which tracks configuration, system
* events, available features and started processes. The mobility context is
* created using ipmip6_context_create(). See ipmip6_context.h for
* more information regarding the mobility entity context singleton.
* \i proc
* The process context associated with the currently executing thread. Each
* thread and/or process in MIP must have its own unique process context.
* If a process is started using ipmip_proc_start, the process context will
* be allocated automatically by the IPMIP framework. Otherwise it must
* be allocated using ipmip_proc_alloc().
* \i pbuf
* The packet
* \i nai
* The NAI string
* \i nai_len
* The length of the NAI string
* \ie
*
* RETURNS: IP_TRUE on success.
*
* ERRNO:
*
*/
IP_GLOBAL Ip_bool ipmip6_mh_pkt_opt_add_nai
(
struct Ipmip6_context *ctx,
struct Ipmip_proc *proc,
struct Ipmip6_pktbuf *pbuf,
const char *nai,
Ip_size_t nai_len
);
/*******************************************************************************
*
* ipmip6_mh_pkt_process_options - ipmip6_mh_pkt_process_options
*
* Process the mobility options present in a mobility header
* and verify that any Authorization Data is properly aligned.
*
* Parameters:
* \is
* \i ctx
* The generic mobility singleton context for IPMIP6. For each started mobility
* entity, there exists a mobility context which tracks configuration, system
* events, available features and started processes. The mobility context is
* created using ipmip6_context_create(). See ipmip6_context.h for
* more information regarding the mobility entity context singleton.
* \i opt
* The option structure to store results in.
* \i data
* The data
* \i offset
* Where to start look for mobile options.
* \i len
* The total length of the packet.
* \ie
*
* RETURNS: IP_TRUE on success.
*
* ERRNO:
*
* NOMANUAL
*/
IP_GLOBAL Ip_bool ipmip6_mh_pkt_process_options
(
struct Ipmip6_context *ctx,
struct Ipmip_proc *proc,
Ipmip6_mh_options_t *opt,
void *data,
int offset,
int len
);
#ifdef __cplusplus
}
#endif
#endif
/*
****************************************************************************
* END OF FILE
****************************************************************************
*/