original files of m241
This commit is contained in:
@@ -0,0 +1,340 @@
|
||||
/* ipmip6_icmp_pkt.h - ipmip6_icmp_pkt.h */
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip6_icmp_pkt.h,v $ $Revision: 1.7 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip6/include/private/ipmip6_icmp_pkt.h,v $
|
||||
* $Author: jhorteli $ $Date: 2010-12-07 09:55:18 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IP_IPMIP6_ICMP_PKT_H
|
||||
#define IP_IPMIP6_ICMP_PKT_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
DESCRIPTION
|
||||
|
||||
This module defines the ICMP packet utility functions required by MIP6. They
|
||||
include parsing and processing of ICMP packets as well as creation and
|
||||
configuration of ICMP packets.
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#include <private/ipmip6_pkt.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/* ICMPv6 type field */
|
||||
#define IPMIP6_ICMP6_DST_UNREACH 1
|
||||
#define IPMIP6_ICMP6_PARAM_PROB 4
|
||||
|
||||
/* ICMP Types as defined by RFC 3775, 6.5, 6.6, 6.7, 6.8 */
|
||||
#define IPMIP6_ICMP6_HA_DISCOVERY_REQUEST 144
|
||||
#define IPMIP6_ICMP6_HA_DISCOVERY_REPLY 145
|
||||
#define IPMIP6_ICMP6_PREFIX_SOLICIT 146
|
||||
#define IPMIP6_ICMP6_PREFIX_ADVERT 147
|
||||
|
||||
/* Neighbor Discovery ICMPv6 Types */
|
||||
#define IPMIP6_ND_ROUTER_SOLICIT 133
|
||||
#define IPMIP6_ND_ROUTER_ADVERT 134
|
||||
#define IPMIP6_ND_NEIGHBOR_SOLICIT 135
|
||||
#define IPMIP6_ND_NEIGHBOR_ADVERT 136
|
||||
#define IPMIP6_ND_REDIRECT 137
|
||||
|
||||
/* ICMPv6 Parameter Problem Codes */
|
||||
#define IPMIP6_ICMP6_PARAM_PROB_NXT_HDR 1
|
||||
#define IPMIP6_ICMP6_PARAM_PROB_OPT 2
|
||||
|
||||
/* DHAAD ICMP flags */
|
||||
#define IPMIP6_DHAAD_MOBILE_ROUTER 0x8000
|
||||
|
||||
/* Home agent flag, defined by RFC 3775, 7.1 */
|
||||
#define IPMIP6_ND_RA_FLAG_HOMEAGENT 0x20
|
||||
|
||||
#define IPMIP6_ND_OPT_PI_FLAG_ONLINK 0x80
|
||||
#define IPMIP6_ND_OPT_PI_FLAG_AUTO 0x40
|
||||
/* Global address flag, defined by RFC 3775, 7.2 */
|
||||
#define IPMIP6_ND_OPT_PI_FLAG_ROUTER_ADDRESS 0x20
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ICMPv6 Neighbor Discovery options
|
||||
*===========================================================================
|
||||
*/
|
||||
#define IPMIP6_ND_OPT_SOURCE_LINKADDR 1
|
||||
#define IPMIP6_ND_OPT_TARGET_LINKADDR 2
|
||||
#define IPMIP6_ND_OPT_PREFIX_INFORMATION 3
|
||||
|
||||
/* MIP6 ND options, as defined by RFC 3775, 7.* */
|
||||
#define IPMIP6_ND_OPT_ADVERT_INTERVAL 7
|
||||
|
||||
#define IPMIP6_ND_OPT_HOMEAGENT_INFO 8
|
||||
# define IPMIP6_ND_OPT_HOMEAGENT_INFO_MR 0x8000
|
||||
|
||||
|
||||
#define IPMIP6_ND_SET_IS_ROUTER(adv) \
|
||||
(adv)->nd_na_hdr.icmp6_dataun.icmp6_un_data16[0] |= ip_htons(0x8000)
|
||||
#define IPMIP6_ND_IS_ROUTER(adv) \
|
||||
((adv)->nd_na_hdr.icmp6_dataun.icmp6_un_data16[0] & ip_htons(0x8000))
|
||||
#define IPMIP6_ND_SET_SOLICATED_FLAG(adv) \
|
||||
(adv)->nd_na_hdr.icmp6_dataun.icmp6_un_data16[0] |= ip_htons(0x4000)
|
||||
#define IPMIP6_ND_IS_SOLICATED(adv) \
|
||||
((adv)->nd_na_hdr.icmp6_dataun.icmp6_un_data16[0] & ip_htons(0x4000))
|
||||
#define IPMIP6_ND_SET_OVERRIDE_FLAG(adv) \
|
||||
(adv)->nd_na_hdr.icmp6_dataun.icmp6_un_data16[0] |= ip_htons(0x2000)
|
||||
#define IPMIP6_ND_IS_OVERRIDE(adv) \
|
||||
((adv)->nd_na_hdr.icmp6_dataun.icmp6_un_data16[0] & ip_htons(0x2000))
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
struct Ipmip6_if;
|
||||
struct Ipmip6_if_inet6;
|
||||
struct Ipmip6_nd_nud;
|
||||
struct Ipmip6_nd_proxy;
|
||||
struct Ipmip6_context;
|
||||
struct Ipmip_proc;
|
||||
|
||||
#include <ipcom_align16.h>
|
||||
|
||||
/* Advertisement interval Header Options */
|
||||
typedef IP_PACKED1 struct Ipmip6_nd_opt_adv_interval
|
||||
{
|
||||
Ip_u8 nd_opt_ai_type;
|
||||
Ip_u8 nd_opt_ai_len;
|
||||
Ip_u16 nd_opt_ai_reserved;
|
||||
Ip_u32 nd_opt_ai_interval;
|
||||
} IP_PACKED2
|
||||
Ipmip6_nd_opt_adv_interval_t;
|
||||
|
||||
/* Homeagent info Header Options */
|
||||
typedef IP_PACKED1 struct Ipmip6_nd_opt_ha_info
|
||||
{
|
||||
Ip_u8 nd_opt_hai_type;
|
||||
Ip_u8 nd_opt_hai_len;
|
||||
Ip_u16 nd_opt_hai_reserved;
|
||||
Ip_u16 nd_opt_hai_preference;
|
||||
Ip_u16 nd_opt_hai_lifetime;
|
||||
} IP_PACKED2
|
||||
Ipmip6_nd_opt_ha_info_t;
|
||||
|
||||
|
||||
typedef struct IP_PACKED1 Ipmip6_icmp6_hdr
|
||||
{
|
||||
Ip_u8 icmp6_type; /* type field */
|
||||
Ip_u8 icmp6_code; /* code field */
|
||||
Ip_u16 icmp6_cksum; /* checksum field */
|
||||
union IP_PACKED1
|
||||
{
|
||||
Ip_u32 icmp6_un_data32[1]; /* type-specific field */
|
||||
Ip_u16 icmp6_un_data16[2]; /* type-specific field */
|
||||
Ip_u8 icmp6_un_data8[4]; /* type-specific field */
|
||||
} IP_PACKED2 icmp6_dataun;
|
||||
} IP_PACKED2
|
||||
Ipmip6_pkt_icmp6_t;
|
||||
|
||||
/* Router Advertisement Message */
|
||||
typedef IP_PACKED1 struct Ipmip6_nd_router_advert
|
||||
{
|
||||
Ipmip6_pkt_icmp6_t nd_ra_hdr;
|
||||
Ip_u32 nd_ra_reachable; /* Reachable time. */
|
||||
Ip_u32 nd_ra_retransmit; /* Retransmission time. */
|
||||
/* could be followed by options. */
|
||||
} IP_PACKED2
|
||||
Ipmip6_nd_router_advert_t;
|
||||
|
||||
/* Neighbor Advertisment */
|
||||
typedef IP_PACKED1 struct Ipmip6_nd_neighbor_advert
|
||||
{
|
||||
Ipmip6_pkt_icmp6_t nd_na_hdr;
|
||||
struct Ip_in6_addr nd_na_target; /* target address. */
|
||||
|
||||
/* could be followed by options. */
|
||||
} IP_PACKED2
|
||||
Ipmip6_pkt_nd_neighbor_advert_t;
|
||||
|
||||
/* Neighbor Advertisment */
|
||||
typedef IP_PACKED1 struct Ipmip6_nd_neighbor_solicitation
|
||||
{
|
||||
Ipmip6_pkt_icmp6_t nd_ns_hdr;
|
||||
struct Ip_in6_addr nd_ns_target; /* target address. */
|
||||
|
||||
/* could be followed by options. */
|
||||
} IP_PACKED2
|
||||
Ipmip6_pkt_nd_neighbor_solicitation_t;
|
||||
|
||||
|
||||
/* ICMPv6 Neighbor Discovery Options Types */
|
||||
typedef IP_PACKED1 struct Ipmip6_nd_opt_hdr
|
||||
{
|
||||
Ip_u8 nd_opt_type;
|
||||
Ip_u8 nd_opt_len;
|
||||
} IP_PACKED2
|
||||
Ipmip6_pkt_nd_opt_hdr_t;
|
||||
|
||||
/* Prefix Extension Header Options */
|
||||
typedef IP_PACKED1 struct Ipmip6_nd_opt_prefix_info
|
||||
{
|
||||
Ip_u8 nd_opt_pi_type;
|
||||
Ip_u8 nd_opt_pi_len;
|
||||
Ip_u8 nd_opt_pi_prefix_len;
|
||||
Ip_u8 nd_opt_pi_flags_reserved;
|
||||
Ip_u32 nd_opt_pi_valid_time;
|
||||
Ip_u32 nd_opt_pi_preferred_time;
|
||||
Ip_u32 nd_opt_pi_reserved2;
|
||||
struct Ip_in6_addr nd_opt_pi_prefix;
|
||||
} IP_PACKED2
|
||||
Ipmip6_pkt_nd_opt_prefix_info_t;
|
||||
|
||||
/* Prefix Extension Header Options */
|
||||
typedef IP_PACKED1 struct Ipmip6_nd_opt_advertisement_interval
|
||||
{
|
||||
Ip_u8 nd_opt_ai_type;
|
||||
Ip_u8 nd_opt_ai_len;
|
||||
Ip_u16 nd_opt_ai_reserved;
|
||||
Ip_u32 nd_opt_ai_interval;
|
||||
} IP_PACKED2
|
||||
Ipmip6_nd_opt_advertisement_interval_t;
|
||||
|
||||
#include <ipcom_align16.h>
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip6_icmp_pkt_opt_add - ipmip6_icmp_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 we're adding to.
|
||||
* \i type
|
||||
* Option type
|
||||
* \i len
|
||||
* Option data len
|
||||
* \i data
|
||||
* Option data
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: IP_TRUE on success, IP_FALSE otherwise.
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ip_bool ipmip6_icmp_pkt_opt_add
|
||||
(
|
||||
struct Ipmip6_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmip6_pktbuf_t *pkt,
|
||||
Ip_u8 type,
|
||||
Ip_u8 len,
|
||||
void* data
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip6_icmp_pkt_alloc - ipmip6_icmp_pkt_alloc
|
||||
*
|
||||
* Allocates a new ICMP header of size bytes
|
||||
*
|
||||
* 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 header
|
||||
* \i type
|
||||
* ICMP type
|
||||
* \i code
|
||||
* ICMP code
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: The packet buffer, or IP_NULL on failure.
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ipmip6_pktbuf_t *ipmip6_icmp_pkt_alloc
|
||||
(
|
||||
struct Ipmip6_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ip_u16 size,
|
||||
Ip_u8 type,
|
||||
Ip_u8 code
|
||||
);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
Reference in New Issue
Block a user