original files of m241
This commit is contained in:
@@ -0,0 +1,510 @@
|
||||
/* ipmip_if.h - ipmip_if.h */
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip_if.h,v $ $Revision: 1.8 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip/include/private/ipmip_if.h,v $
|
||||
* $Author: jhorteli $ $Date: 2010-12-07 09:55:01 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMIP_IF_H
|
||||
#define IPMIP_IF_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
/*
|
||||
DESCRIPTION
|
||||
|
||||
Basic interface management required for MIP. Provides functions to
|
||||
instantiate interfaces information containers, resolve LLADDR identifiers
|
||||
and create and destroy tunnel interfaces. This is a base class that mostly
|
||||
acts as container. The real interface implementations are usually located
|
||||
higher up in the hierarchy such as IPMIP6 and IPMIP4.
|
||||
|
||||
EXAMPLE
|
||||
|
||||
.CS
|
||||
|
||||
struct Ipmip_my_iff
|
||||
{
|
||||
Ipmip_if_t ipmip;
|
||||
|
||||
|
||||
char *extra_data;
|
||||
};
|
||||
|
||||
static void ipmip_my_free_interface(struct Ipmip_my_context *ctx,
|
||||
Ipmip_proc_t *proc,
|
||||
struct Ipmip_my_iff *iff)
|
||||
{
|
||||
/@ Free any extra data associated with the interface @/
|
||||
ipcom_free(iff->extra_data);
|
||||
}
|
||||
|
||||
|
||||
struct Ipmip_my_iff *ipmip_my_allocate_interface(struct Ipmip_my_context *ctx, Ipmip_proc_t *proc, int ifindex, const char *ifname)
|
||||
{
|
||||
/@ Allocate an interface container for the indicated interface @/
|
||||
struct Ipmip_my_iff *iff = (struct Ipmip_my_iff *)ipmip_if_alloc(&ctx->ipmip,
|
||||
proc,
|
||||
sizeof(*iff),
|
||||
ifname,
|
||||
ifindex,
|
||||
IPMIP_IF_TYPE_GENERIC,
|
||||
0,
|
||||
(Ipmip_if_cleanup_t)ipmip_my_free_interface);
|
||||
|
||||
/@ Just allocate some extra data to highlight the use of the interface free routine @/
|
||||
iff->extra_data = ipcom_malloc(40);
|
||||
return iff;
|
||||
}
|
||||
|
||||
void ipmip_do_if(struct Ipmip_my_context *ctx, Ipmip_proc_t *proc, int ifindex, const char *ifname)
|
||||
{
|
||||
struct Ipmip_my_iff *iff = ipmip_my_allocate_interface(ctx, proc, ifindex, ifname);
|
||||
|
||||
/@ Set the interface UP @/
|
||||
ipmip_if_set_flags(&ctx->ipmip, proc, &iff->ipmip, IP_IFF_UP);
|
||||
|
||||
/@ Set the interface DOWN @/
|
||||
ipmip_if_clear_flags(&ctx->ipmip, proc, &iff->ipmip, IP_IFF_UP);
|
||||
|
||||
/@ Destroy the interface @/
|
||||
ipmip_if_free(&ctx->ipmip, proc, &iff->ipmip);
|
||||
}
|
||||
|
||||
.CE
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#include <private/ipmip_lladdr.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
enum
|
||||
{
|
||||
IPMIP_IF_TYPE_GENERIC,
|
||||
IPMIP_IF_TYPE_TUNNEL
|
||||
};
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
struct Ipmip_context;
|
||||
struct Ipmip_proc;
|
||||
struct Ipmip_if;
|
||||
|
||||
typedef void (*Ipmip_if_cleanup_t) (struct Ipmip_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip_if *ifp);
|
||||
|
||||
|
||||
typedef struct Ipmip_if
|
||||
{
|
||||
Ipcom_list next;
|
||||
|
||||
/**/
|
||||
char ifname[IP_IFNAMSIZ + 1];
|
||||
Ip_u32 ifindex;
|
||||
Ipmip_lladdr_t *lladdr;
|
||||
Ipmip_if_cleanup_t cleanup;
|
||||
|
||||
/* Type of interface */
|
||||
Ip_u8 type;
|
||||
Ip_u8 identity;
|
||||
Ip_u8 tunnel_type;
|
||||
Ip_u8 __reserved;
|
||||
|
||||
} Ipmip_if_t;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip_if_alloc - ipmip_if_alloc
|
||||
*
|
||||
* Allocate and initialize the interface structure. Will return a pointer
|
||||
* to the newly allocated interface structure. Since the IPMIP interface
|
||||
* usually is overloaded by other implementations in order to define parameters
|
||||
* required by those products, a size argument is provided that indicates the
|
||||
* entire size of the interface structure to be allocated. For the same reason
|
||||
* a cleanup hook can be registered, if there is data associated with an
|
||||
* interface that must be released when the interface is destroyed.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP. 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 ipmip_context_create(). See ipmip_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 ifsize
|
||||
* the size of the interface structure
|
||||
* \i ifname
|
||||
* The interface name
|
||||
* \i ifindex
|
||||
* The interface index if available.
|
||||
* \i type
|
||||
* One of the IPMIP_IF_TYPE_GENERIC or IPMIP_IF_TYPE_TUNNEL.
|
||||
* \i identity
|
||||
* Implementation specific sub-identity, if one needs to discern between
|
||||
* various types of interfaces.
|
||||
* \i cleanup
|
||||
* Cleanup hook that may be specified. Will be invoked during free.
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: The interface structure on success.
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ipmip_if_t * ipmip_if_alloc
|
||||
(
|
||||
struct Ipmip_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ip_size_t ifsize,
|
||||
const char *ifname,
|
||||
Ip_u32 ifindex,
|
||||
Ip_u8 type,
|
||||
Ip_u8 identity,
|
||||
Ipmip_if_cleanup_t cleanup
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip_if_free - ipmip_if_free
|
||||
*
|
||||
* Destroy and free the interface specific data. If a interface cleanup hook
|
||||
* has been registered in the ipmip_if_alloc call, it will be invoked in this
|
||||
* function.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP. 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 ipmip_context_create(). See ipmip_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 iff
|
||||
* the interface to destroy
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: No return value
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void ipmip_if_free
|
||||
(
|
||||
struct Ipmip_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmip_if_t *iff
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip_if_ioctl - ipmip_if_ioctl
|
||||
*
|
||||
* Invoke a interface ioctl.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP. 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 ipmip_context_create(). See ipmip_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 iff
|
||||
* the interface to destroy
|
||||
* \i ioctl
|
||||
* The ioctl
|
||||
* \i ifreq
|
||||
* The ioctl ifreq structure to complete
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: No return value
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL int ipmip_if_ioctl
|
||||
(
|
||||
struct Ipmip_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmip_if_t *iff,
|
||||
unsigned long ioctl,
|
||||
struct Ip_ifreq *ifreq
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip_if_get_flags - ipmip_if_get_flags
|
||||
*
|
||||
* Get the current interface flags.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP. 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 ipmip_context_create(). See ipmip_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 iff
|
||||
* The interface
|
||||
* \i flags
|
||||
* Where to store the flags.
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: IP_TRUE on success
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ip_bool ipmip_if_get_flags
|
||||
(
|
||||
struct Ipmip_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmip_if_t *iff,
|
||||
Ip_u16 *flags
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip_if_set_flags - ipmip_if_set_flags
|
||||
*
|
||||
* Set the current interface flags.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP. 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 ipmip_context_create(). See ipmip_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 iff
|
||||
* The interface
|
||||
* \i flags
|
||||
* The flags to set
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: IP_TRUE on success
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ip_bool ipmip_if_set_flags
|
||||
(
|
||||
struct Ipmip_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmip_if_t *iff,
|
||||
Ip_u16 flags
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip_if_clear_flags - ipmip_if_clear_flags
|
||||
*
|
||||
* Clear the current interface flags.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP. 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 ipmip_context_create(). See ipmip_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 iff
|
||||
* The interface
|
||||
* \i flags
|
||||
* The flags to clear
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: IP_TRUE on success
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ip_bool ipmip_if_clear_flags
|
||||
(
|
||||
struct Ipmip_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmip_if_t *iff,
|
||||
Ip_u16 flags
|
||||
);
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip_if_resolve_lla - ipmip_if_resolve_lla
|
||||
*
|
||||
* Resolve the LLA of the interface
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP. 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 ipmip_context_create(). See ipmip_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 iff
|
||||
* The interface
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: IP_TRUE on success; IP_FALSE otherwise.
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ip_bool ipmip_if_resolve_lla
|
||||
(
|
||||
struct Ipmip_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmip_if_t *iff
|
||||
);
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip_if_findbyindex - ipmip_if_findbyindex
|
||||
*
|
||||
* Locate an interface in our configuration based on index
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i iflist
|
||||
* The list of interfaces
|
||||
* \i idx
|
||||
* The interface index
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: The interface pointer if it exists, IP_NULL otherwise.
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ipmip_if_t * ipmip_if_findbyindex
|
||||
(
|
||||
Ipcom_list *iflist,
|
||||
Ip_u32 idx
|
||||
);
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip_if_findbyname - ipmip_if_findbyname
|
||||
*
|
||||
* Locate an interface in our configuration based on name.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i iflist
|
||||
* The list of interfaces.
|
||||
* \i ifname
|
||||
* The interface name
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: The interface pointer if it exists, IP_NULL otherwise.
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ipmip_if_t * ipmip_if_findbyname
|
||||
(
|
||||
Ipcom_list *iflist,
|
||||
const char *ifname
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
Reference in New Issue
Block a user