503 lines
17 KiB
C
503 lines
17 KiB
C
/* ipmip6_netlink.h - ipmip6_netlink.h */
|
|
/*
|
|
******************************************************************************
|
|
* HEADER FILE
|
|
*
|
|
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip6_netlink.h,v $ $Revision: 1.18 $
|
|
* $Source: /home/interpeak/CVSRoot/ipmip6/include/private/ipmip6_netlink.h,v $
|
|
* $Author: jhorteli $ $Date: 2010-12-07 09:55:19 $
|
|
* $State: Exp $ $Locker: $
|
|
*
|
|
* INTERPEAK_COPYRIGHT_STRING
|
|
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
|
******************************************************************************
|
|
*/
|
|
#ifndef IPMIP6_NETLINK_H
|
|
#define IPMIP6_NETLINK_H
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 1 DESCRIPTION
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
DESCRIPTION
|
|
|
|
This module defines MIP6 internal NETLINK commands.The MIP6 methods mostly
|
|
deals with registering entities in the kernel for more advanced GRE and
|
|
statistics management than is usually provided by the base IPNET functionality.
|
|
|
|
EXAMPLE
|
|
|
|
This example illustrates how one can register a MIP handle in the kernel,
|
|
and retrieve statistics.
|
|
|
|
.CS
|
|
|
|
IP_GLOBAL void
|
|
my_handle_function(struct Ipmip6my_context *ctx,
|
|
struct Ipmip_proc *proc,
|
|
struct Ipmip_my_entities *node)
|
|
{
|
|
Ipmip6_netlink_kern_statistics_t link_recv, link_send;
|
|
Ipmip_netlink_kern_handle_t handle;
|
|
|
|
/@ Register this nodes handle in the kernel @/
|
|
ipmip6_netlink_new_handle(&ctx->ipmip6, proc, IPCOM_IPD_ID_IPMYMIP, node->identity);
|
|
|
|
/@ Setup a userspace integrated handle @/
|
|
handle.mip_facility = IPCOM_IPD_ID_IPMIPMYMIP;
|
|
handle.mip_ident = node->identity;
|
|
|
|
/@ Retrieve current non-polled statistics from the kernel @/
|
|
if (ipmip6_netlink_get_handle_stat(&ctx->ipmip6, proc, &handle, &link_recv, &link_send))
|
|
{
|
|
/@ Store the retrieved statistics @/
|
|
}
|
|
|
|
/@ Register this nodes handle in the kernel @/
|
|
ipmip6_netlink_del_handle(&ctx->ipmip6, proc, IPCOM_IPD_ID_IPMYMIP, node->identity);
|
|
}
|
|
*/
|
|
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 2 CONFIGURATION
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 3 INCLUDE FILES
|
|
****************************************************************************
|
|
*/
|
|
|
|
#include <private/ipmip_netlink.h>
|
|
|
|
#include <private/ipmip6_netlink_kern.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 4 DEFINES
|
|
****************************************************************************
|
|
*/
|
|
#define IPMIP6_NETLINK_ENCAP_UDP_TLV(x) ((x) | IP_UDP_NAT_T_DSMIPV6_TLV << 16)
|
|
#define IPMIP6_NETLINK_ENCAP_UDP(x) ((x) | IP_UDP_NAT_T_DSMIPV6 << 16)
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 5 TYPES
|
|
****************************************************************************
|
|
*/
|
|
struct Ipmip6_context;
|
|
struct Ipmip_proc;
|
|
struct Ipmip6_if_router;
|
|
struct Ip_sockaddr_dl;
|
|
struct Ipmip6_address;
|
|
struct Ipmip_netlink_kern_compare;
|
|
struct Ipmip_netlink_kern_handle;
|
|
struct Ipmip6_netlink_kern_statistics;
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 6 FUNCTIONS
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*******************************************************************************
|
|
*
|
|
* ipmip6_netlink_address_do - ipmip6_netlink_address_do
|
|
*
|
|
* MIP6 specific netlink address modification routine.
|
|
*
|
|
* 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 cmd
|
|
* IPMIP6 netlink command
|
|
* \i type
|
|
* IPMIP6 netlink address subcommand.
|
|
* \i flags
|
|
* IPMIP6 netlink address flags
|
|
* \i ifindex
|
|
* Interface index on the interface we are trying to modify addresses on.
|
|
* \i family
|
|
* IP_AF_INET or IP_AF_INET6
|
|
* \i addr
|
|
* Address to remove or add.
|
|
* \i reply
|
|
* Reply buffer if a GET operation has been requested.
|
|
* \ie
|
|
*
|
|
* RETURNS: 0 on success, <0 error code otherwise.
|
|
*
|
|
* ERRNO:
|
|
*
|
|
*/
|
|
IP_GLOBAL int ipmip6_netlink_address_do
|
|
(
|
|
struct Ipmip6_context *ctx,
|
|
struct Ipmip_proc *proc,
|
|
int cmd,
|
|
Ip_u16 type,
|
|
Ip_u8 flags,
|
|
Ip_u32 ifindex,
|
|
Ip_u8 family,
|
|
const void *addr,
|
|
Ipmip_buffer_t *reply
|
|
);
|
|
|
|
|
|
/*******************************************************************************
|
|
*
|
|
* ipmip6_netlink_prefix_generate - ipmip6_netlink_prefix_generate
|
|
*
|
|
* Generate a prefix for the indicated interface based on provided parameters.
|
|
*
|
|
* 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 ifindex
|
|
* Interface index on the interface we are trying to modify prefixes on.
|
|
* \i prefix
|
|
* Prefix to remove or add.
|
|
* \i prefix_length
|
|
* Bit length of prefix
|
|
* \i reply
|
|
* Reply buffer if a GET operation has been requested.
|
|
* \ie
|
|
*
|
|
* RETURNS: 0 on success, <0 error code otherwise.
|
|
*
|
|
* ERRNO:
|
|
*
|
|
*/
|
|
IP_GLOBAL Ip_bool
|
|
ipmip6_netlink_prefix_generate
|
|
(
|
|
struct Ipmip6_context *ctx,
|
|
struct Ipmip_proc *proc,
|
|
Ip_u32 ifindex,
|
|
const void *prefix,
|
|
Ip_u32 prefix_length,
|
|
struct Ipmip6_address *reply
|
|
);
|
|
|
|
|
|
/*******************************************************************************
|
|
*
|
|
* ipmip6_netlink_route_mip_do - ipmip6_netlink_route_mip_do
|
|
*
|
|
* MIP6 specific netlink route modification routine.
|
|
*
|
|
* 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 cmd
|
|
* IPMIP6 netlink command
|
|
* \i type
|
|
* IPMIP6 netlink route subcommand.
|
|
* \i flags
|
|
* IPMIP6 netlink route flags
|
|
* \i table
|
|
* Route Table to modify
|
|
* \i ifindex
|
|
* Interface index for the indicated route
|
|
* \i prefix
|
|
* Route prefix
|
|
* \i psize
|
|
* Size of the variable pointed to by route prefix. That is,
|
|
* sizeof(struct Ip_in6_addr) or sizeof(struct Ip_in_addr)
|
|
* depending on family
|
|
* \i prefix_len
|
|
* Number of bits set in the prefix
|
|
* \i nexthop
|
|
* Nexthop address
|
|
* \i nsize
|
|
* Size of the variable pointed to by nexthop.That is,
|
|
* sizeof(struct Ip_in6_addr) or sizeof(struct Ip_in_addr)
|
|
* depending on family
|
|
* \i nat_port
|
|
* NAT port, if required
|
|
* \i srccmp
|
|
* Source Comparison object.
|
|
* \i handle
|
|
* Generic MIP Handle as registered by ipmip6_netlink_handle_new.
|
|
* \i link
|
|
* If this route should collect statistic as an up or downlink.
|
|
* \i gre_key
|
|
* Optional GRE Key
|
|
* \i rtf_flags
|
|
* Extra IPNET RTF flags for route creation.
|
|
* \ie
|
|
*
|
|
* RETURNS: 0 on success, <0 error code otherwise.
|
|
*
|
|
* ERRNO:
|
|
*
|
|
*/
|
|
IP_GLOBAL int ipmip6_netlink_route_mip_do
|
|
(
|
|
struct Ipmip6_context *ctx,
|
|
struct Ipmip_proc *proc,
|
|
int cmd,
|
|
Ip_u16 type,
|
|
Ip_u8 flags,
|
|
Ip_u32 table,
|
|
Ip_u32 ifindex,
|
|
const void *prefix,
|
|
Ip_size_t psize,
|
|
Ip_u32 prefix_len,
|
|
const void *nexthop,
|
|
Ip_size_t nsize,
|
|
Ip_u32 nat_port,
|
|
const struct Ipmip_netlink_kern_compare *srccmp,
|
|
const struct Ipmip_netlink_kern_handle *handle,
|
|
int link,
|
|
Ip_u32 *gre_key,
|
|
Ip_u32 rtf_flags
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
*
|
|
* ipmip6_netlink_process - ipmip6_netlink_process
|
|
*
|
|
* Process a netlink message and call the appropriate callbacks depending
|
|
* on received message. Will also update interface structures.
|
|
*
|
|
* 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 hdr
|
|
* NETLINK message header.
|
|
* \ie
|
|
*
|
|
* RETURNS: No return value.
|
|
*
|
|
* ERRNO:
|
|
*
|
|
*/
|
|
IP_GLOBAL void ipmip6_netlink_process
|
|
(
|
|
struct Ipmip6_context *ctx,
|
|
struct Ipmip_proc *proc,
|
|
struct Ip_nlmsghdr *hdr
|
|
);
|
|
|
|
|
|
/*******************************************************************************
|
|
*
|
|
* ipmip6_netlink_new_handle - ipmip6_netlink_new_handle
|
|
*
|
|
* Create a MIP handle.The facility/identity combination must be unique,
|
|
* or this method will fail with an EEXIST errno.
|
|
*
|
|
* 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 facility
|
|
* The MIP facility. One of the IPCOM_IPD_ID_IPMIPXX product definitions.
|
|
* \i identity
|
|
* The unique identity parameter.
|
|
* \ie
|
|
*
|
|
* RETURNS: 0 on success
|
|
*
|
|
* ERRNO:
|
|
*
|
|
*/
|
|
IP_GLOBAL int ipmip6_netlink_new_handle
|
|
(
|
|
struct Ipmip6_context *ctx,
|
|
struct Ipmip_proc *proc,
|
|
Ip_u32 facility,
|
|
Ip_u32 identity
|
|
);
|
|
|
|
/*******************************************************************************
|
|
*
|
|
* ipmip6_netlink_del_handle - ipmip6_netlink_del_handle
|
|
*
|
|
* Delete a MIP handle previously registered using ipmip4_netlink_new_handle.
|
|
*
|
|
* 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 facility
|
|
* The MIP facility. One of the IPCOM_IPD_ID_IPMIPXX product definitions.
|
|
* \i identity
|
|
* The unique identity parameter.
|
|
* \ie
|
|
*
|
|
* RETURNS: 0 on success
|
|
*
|
|
* ERRNO:
|
|
*
|
|
*/
|
|
IP_GLOBAL int ipmip6_netlink_del_handle
|
|
(
|
|
struct Ipmip6_context *ctx,
|
|
struct Ipmip_proc *proc,
|
|
Ip_u32 facility,
|
|
Ip_u32 identity
|
|
);
|
|
|
|
|
|
/*******************************************************************************
|
|
*
|
|
* ipmip6_netlink_get_handle_stat - ipmip6_netlink_get_handle_stat
|
|
*
|
|
* Retrieve the statistics associated with a handle. The statistics retrieved
|
|
* is the currently non-polled statistics present in the kernel. This function
|
|
* will reset the kernel structures. That is, for each invocation of this
|
|
* method you will retrieve the statistics collected with start from the
|
|
* previous invocation.
|
|
*
|
|
* 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 handle
|
|
* The MIP handle
|
|
* \i link_recv
|
|
* Container to populate with RECEIVE statistics
|
|
* \i link_send
|
|
* Container to populate with SEND statistics
|
|
* \ie
|
|
*
|
|
* RETURNS: IP_TRUE on success
|
|
*
|
|
* ERRNO:
|
|
*
|
|
*/
|
|
IP_GLOBAL Ip_bool ipmip6_netlink_get_handle_stat
|
|
(
|
|
struct Ipmip6_context *ctx,
|
|
struct Ipmip_proc *proc,
|
|
struct Ipmip_netlink_kern_handle *handle,
|
|
struct Ipmip6_netlink_kern_statistics *link_recv,
|
|
struct Ipmip6_netlink_kern_statistics *link_send
|
|
);
|
|
|
|
|
|
|
|
/** TO BE OBSOLETED **/
|
|
IP_GLOBAL int ipmip6_netlink_route_do(struct Ipmip6_context *ctx,
|
|
struct Ipmip_proc *proc,
|
|
int cmd,
|
|
Ip_u16 type,
|
|
Ip_u8 flags,
|
|
Ip_u32 table,
|
|
Ip_u32 ifindex,
|
|
const struct Ip_in6_addr *hoa,
|
|
const struct Ip_in6_addr *coa,
|
|
const void *prefix,
|
|
Ip_size_t psize,
|
|
Ip_u32 prefix_len,
|
|
const void *nexthop,
|
|
Ip_size_t nsize,
|
|
Ip_u32 nat_port,
|
|
const struct Ipmip_netlink_kern_compare *srccmp,
|
|
Ip_u32 *gre_key,
|
|
Ipmip_buffer_t *reply,
|
|
Ip_u32 rtf_flags);
|
|
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|
|
|
|
/*
|
|
****************************************************************************
|
|
* END OF FILE
|
|
****************************************************************************
|
|
*/
|