original files of m241
This commit is contained in:
@@ -0,0 +1,195 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip6ha.c,v $ $Revision: 1.19 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip6ha/src/ipmip6ha.c,v $
|
||||
* $Author: jhorteli $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelis@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
#include "ipmip6ha_config.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#include <ipcom_type.h>
|
||||
#include <ipcom_cstyle.h>
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_os.h>
|
||||
#include <ipcom_sock.h>
|
||||
#include <ipcom_sock6.h>
|
||||
#include <ipcom_inet.h>
|
||||
#include <ipcom_list.h>
|
||||
#include <ipcom_ipd.h>
|
||||
#include <ipcom_syslog.h>
|
||||
|
||||
#include <ipmip.h>
|
||||
#include <private/ipmip_util.h>
|
||||
#include <private/ipmip_dhcp.h>
|
||||
#include <private/ipmip_sysvar.h>
|
||||
|
||||
#include <ipmip6.h>
|
||||
#include <private/ipmip6_context.h>
|
||||
#include <private/ipmip6_pkt.h>
|
||||
#include <private/ipmip6_if.h>
|
||||
#include <private/ipmip6_mh.h>
|
||||
#include <private/ipmip6_mh_pkt.h>
|
||||
#include <private/ipmip6_util.h>
|
||||
|
||||
#include "ipmip6ha.h"
|
||||
#include "ipmip6ha_h.h"
|
||||
#include "ipmip6ha_node.h"
|
||||
#include "ipmip6ha_nemo.h"
|
||||
#include "ipmip6ha_attr_h.h"
|
||||
#include "ipmip6ha_cli.h"
|
||||
#include "ipmip6ha_ifevent.h"
|
||||
#include "ipmip6ha_mh.h"
|
||||
#include "ipmip6ha_icmp.h"
|
||||
#include "ipmip6ha_if.h"
|
||||
#include "ipmip6ha_route.h"
|
||||
#include "ipmip6ha_pktbuf.h"
|
||||
#include "ipmip6ha_mag.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
IP_PUBLIC Ip_err ipmip6ha_start(void);
|
||||
IP_PUBLIC const char *ipmip6ha_version(void);
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_PUBLIC IPCOM_PROCESS(ipmip6ha_proc);
|
||||
IP_PUBLIC
|
||||
IPCOM_PROCESS(ipmip6ha_proc)
|
||||
{
|
||||
/* Invoke main */
|
||||
ipmip6ha_main();
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmipha_start
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_err
|
||||
ipmip6ha_start(void)
|
||||
{
|
||||
Ipcom_proc_attr attr;
|
||||
Ip_err ret;
|
||||
|
||||
ipcom_proc_attr_init(&attr);
|
||||
attr.stacksize = IPCOM_PROC_STACK_LARGE;
|
||||
|
||||
ret = ipcom_proc_acreate("ipmip6had", ipmip6ha_proc, &attr, IP_NULL);
|
||||
ip_assert(ret == IPCOM_SUCCESS);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmipha_version
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC const char *
|
||||
ipmip6ha_version(void)
|
||||
{
|
||||
return "@(#) IPMIP6HA $Name: VXWORKS_ITER40_2019102207 $ - INTERPEAK_COPYRIGHT_STRING";
|
||||
}
|
||||
|
||||
|
||||
#if defined (IP_PORT_LAS)
|
||||
|
||||
IP_PUBLIC Ip_err ipcom_daemon_configure(void);
|
||||
IP_PUBLIC Ip_err ipcom_daemon_create(void);
|
||||
|
||||
IP_PUBLIC Ip_err
|
||||
ipcom_daemon_configure(void)
|
||||
{
|
||||
return IPCOM_SUCCESS;
|
||||
}
|
||||
|
||||
IP_PUBLIC Ip_err
|
||||
ipcom_daemon_create(void)
|
||||
{
|
||||
return IPCOM_SUCCESS;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,755 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip6ha_attr.c,v $ $Revision: 1.27 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip6ha/src/ipmip6ha_attr.c,v $
|
||||
* $Author: jhorteli $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelis@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipmip6ha_config.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_err.h>
|
||||
#include <ipcom_inet.h>
|
||||
#include <ipcom_ipd.h>
|
||||
#include <ipcom_list.h>
|
||||
#include <ipcom_hash.h>
|
||||
#include <ipcom_os.h>
|
||||
#include <ipcom_sock.h>
|
||||
#include <ipcom_sock.h>
|
||||
#include <ipcom_sock2.h>
|
||||
#include <ipcom_sysctl.h>
|
||||
#include <ipcom_syslog.h>
|
||||
#include <ipcom_route.h>
|
||||
|
||||
#include <ipmip.h>
|
||||
#include <private/ipmip_buffer.h>
|
||||
#include <private/ipmip_util.h>
|
||||
|
||||
#include <ipmip6.h>
|
||||
#include <private/ipmip6_context.h>
|
||||
#include <private/ipmip6_icmp_pkt.h>
|
||||
#include <private/ipmip6_mh.h>
|
||||
#include <private/ipmip6_mh_pkt.h>
|
||||
#include <private/ipmip6_if.h>
|
||||
#include <private/ipmip6_attr.h>
|
||||
#include <private/ipmip6_util.h>
|
||||
|
||||
#include "ipmip6ha_h.h"
|
||||
#include "ipmip6ha_attr.h"
|
||||
#include "ipmip6ha_attr_h.h"
|
||||
#include "ipmip6ha_node.h"
|
||||
#include "ipmip6ha_nemo.h"
|
||||
#include "ipmip6ha_nemo_dsmipv6.h"
|
||||
#include "ipmip6ha_if.h"
|
||||
#include "ipmip6ha_route.h"
|
||||
#include "ipmip6ha_mag.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
struct Ipmip6ha_attr_op
|
||||
{
|
||||
Ipmip_cli_message_t *request;
|
||||
struct Ip_in6_addr *hoa;
|
||||
const char *nai_mn;
|
||||
Ip_size_t nai_mn_len;
|
||||
Ip_u32 ifindex;
|
||||
};
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmipfa_node_del_cb
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipmip6ha_attr_list_nodes(Ipmip6ha_context_t *ctx,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmip6ha_node_t *node,
|
||||
struct Ipmip6ha_attr_op *ops,
|
||||
void *unused)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(ctx);
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
IPMIP_UNUSED_PARAMETER(unused);
|
||||
|
||||
if (ops->hoa != IP_NULL && !IP_IN6_ARE_ADDR_EQUAL(ops->hoa, &node->mip6BindingCacheEntry.mip6BindingHomeAddress.ipv6))
|
||||
return;
|
||||
|
||||
if (ops->nai_mn != IP_NULL && ops->nai_mn_len > 0)
|
||||
{
|
||||
/* Check NAI */
|
||||
Ipmip6_mh_mo_nai_t *nai = (Ipmip6_mh_mo_nai_t *)node->nai_mn;
|
||||
|
||||
if (!nai)
|
||||
return;
|
||||
|
||||
/* Does the NAI match? */
|
||||
if (!ipmip_util_strnnmatch(ops->nai_mn, ops->nai_mn_len, (char *)&nai->nai[0], (Ip_size_t)(nai->hdr.len - 1)))
|
||||
return;
|
||||
}
|
||||
|
||||
if (ops->ifindex != 0 && ops->ifindex != node->ifp_home->ipmip6.iff.ifindex)
|
||||
return;
|
||||
|
||||
/**/
|
||||
ipmip_attr_put_u32(&ops->request->message, IPMIP6HA_CLI_ATTR_BC_X_HANDLE, node->identity);
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip6ha_attr_node_dump
|
||||
*===========================================================================
|
||||
* Description: Dump a node
|
||||
* Parameters: event - Current event
|
||||
* data - Data
|
||||
* proc - Current process
|
||||
* lock - Command locking structure
|
||||
* node - Node.
|
||||
* Returns: IP_FALSE
|
||||
*
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipmip6ha_attr_node_dump(Ipmip6ha_context_t *ctx,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmip_cli_message_t *request,
|
||||
Ipmip6ha_node_t *node)
|
||||
{
|
||||
struct Ipmip_attr_header *hdr = (struct Ipmip_attr_header *)IPMIP_BUFFER_DATA(&request->request);
|
||||
Ip_size_t rhdr = 0;
|
||||
Ip_size_t rta;
|
||||
|
||||
if (node == IP_NULL)
|
||||
rhdr = ipmip_attr_hdr_err(&request->message, hdr, IP_ERRNO_ENOENT, IP_NULL);
|
||||
else
|
||||
{
|
||||
/**/
|
||||
rhdr = ipmip_attr_hdr_ack(&request->message, hdr);
|
||||
|
||||
/* Do retrieve statistics */
|
||||
ipmip6ha_netlink_get_handle_stat(ctx, proc, node);
|
||||
|
||||
/**/
|
||||
rta = ipmip_attr_begin(&request->message, IPMIP6HA_CLI_ATTR_BC_X);
|
||||
|
||||
/* */
|
||||
if (!IP_IN6_IS_ADDR_UNSPECIFIED(&node->mip6BindingCacheEntry.mip6BindingHomeAddress.ipv6))
|
||||
ipmip_attr_put_inet6(&request->message, IPMIP6HA_CLI_ATTR_BC_X_HOA_V6, &node->mip6BindingCacheEntry.mip6BindingHomeAddress.ipv6);
|
||||
|
||||
/* Put the home address entry */
|
||||
ipmip_attr_put_str(&request->message, IPMIP6HA_CLI_ATTR_BC_X_IFNAME,node->ifp_home->ipmip6.iff.ifname);
|
||||
ipmip_attr_put_time_t(&request->message, IPMIP6HA_CLI_ATTR_BC_X_UPDATED, node->updated);
|
||||
ipmip_attr_put_u32(&request->message, IPMIP6HA_CLI_ATTR_BC_X_REGFLAGS, node->regflags);
|
||||
ipmip_attr_put_u32(&request->message, IPMIP6HA_CLI_ATTR_BC_X_HANDLE, node->identity);
|
||||
|
||||
if (node->nemo_v6.size > 0
|
||||
#ifdef IPMIP_USE_INET
|
||||
|| node->nemo_hoa_v4.size > 0 || node->nemo_prefix_v4.size > 0
|
||||
#endif
|
||||
)
|
||||
{
|
||||
Ipmip6ha_nemo_t *nemo;
|
||||
#ifdef IPMIP_USE_INET
|
||||
Ipmip6ha_nemo_dsmipv6_t *dsmipv6;
|
||||
#endif
|
||||
Ipmip_buffer_t pdata;
|
||||
|
||||
ipmip_buffer_init(&pdata);
|
||||
for (nemo = IPCOM_LIST_FIRST(&node->nemo_v6); nemo != IP_NULL; nemo = IPCOM_LIST_NEXT(&nemo->next))
|
||||
{
|
||||
Ipmip6_address_t address;
|
||||
|
||||
ipcom_memcpy(&address.prefix, &nemo->prefix, sizeof(address.prefix));
|
||||
address.len = nemo->len;
|
||||
|
||||
ipmip_buffer_append(&pdata, &address, sizeof(address));
|
||||
}
|
||||
|
||||
if (IPMIP_BUFFER_SIZE(&pdata))
|
||||
{
|
||||
ipmip_attr_put(&request->message, IPMIP6HA_CLI_ATTR_BC_X_PREFIX_V6,(Ip_u32)IPMIP_BUFFER_SIZE(&pdata),IPMIP_BUFFER_DATA(&pdata));
|
||||
ipmip_buffer_shrink(&pdata, 0);
|
||||
}
|
||||
#ifdef IPMIP_USE_INET
|
||||
for (dsmipv6 = IPCOM_LIST_FIRST(&node->nemo_prefix_v4); dsmipv6 != IP_NULL; dsmipv6 = IPCOM_LIST_NEXT(&dsmipv6->next))
|
||||
{
|
||||
Ipmip6_inet_t address;
|
||||
|
||||
address.prefix = dsmipv6->prefix;
|
||||
address.len = (Ip_u8)dsmipv6->len;
|
||||
|
||||
ipmip_buffer_append(&pdata, &address, sizeof(address));
|
||||
}
|
||||
|
||||
if (IPMIP_BUFFER_SIZE(&pdata))
|
||||
{
|
||||
ipmip_attr_put(&request->message, IPMIP6HA_CLI_ATTR_BC_X_PREFIX_V4,(Ip_u32)IPMIP_BUFFER_SIZE(&pdata),IPMIP_BUFFER_DATA(&pdata));
|
||||
ipmip_buffer_shrink(&pdata, 0);
|
||||
}
|
||||
|
||||
for (dsmipv6 = IPCOM_LIST_FIRST(&node->nemo_hoa_v4); dsmipv6 != IP_NULL; dsmipv6 = IPCOM_LIST_NEXT(&dsmipv6->next))
|
||||
ipmip_buffer_append(&pdata, &dsmipv6->prefix, sizeof(dsmipv6->prefix));
|
||||
|
||||
if (IPMIP_BUFFER_SIZE(&pdata))
|
||||
{
|
||||
ipmip_attr_put(&request->message, IPMIP6HA_CLI_ATTR_BC_X_HOA_V4,(Ip_u32)IPMIP_BUFFER_SIZE(&pdata),IPMIP_BUFFER_DATA(&pdata));
|
||||
ipmip_buffer_shrink(&pdata, 0);
|
||||
}
|
||||
#endif
|
||||
/* Free memory */
|
||||
ipmip_buffer_release(&pdata);
|
||||
}
|
||||
|
||||
/* Add the MO for MN NAI */
|
||||
if (node->nai_mn != IP_NULL)
|
||||
ipmip_attr_put_strn(&request->message, IPMIP6HA_CLI_ATTR_BC_X_MOBILE_NAI,(char *)&((Ipmip6_mh_mo_nai_t *)node->nai_mn)->nai[0], (Ip_size_t)(node->nai_mn->len - 1));
|
||||
|
||||
/**/
|
||||
ipmip_attr_put(&request->message, IPMIP6HA_CLI_ATTR_BC_X_MIB_mip6BindingCacheEntry, sizeof(node->mip6BindingCacheEntry), &node->mip6BindingCacheEntry);
|
||||
ipmip_attr_put(&request->message, IPMIP6HA_CLI_ATTR_BC_X_MIB_mip6NodeTrafficEntry, sizeof(node->mip6NodeTrafficEntry), &node->mip6NodeTrafficEntry);
|
||||
|
||||
ipmip_attr_end(&request->message, rta);
|
||||
}
|
||||
|
||||
/* If we have a reply header; terminate it */
|
||||
ipmip_attr_hdr_finalize(&request->message, rhdr);
|
||||
|
||||
/* Commit the reply */
|
||||
ipmip_cli_message_commit(&ctx->ipmip6.ipmip, proc, request);
|
||||
return IPMIP_TIMER_RET_DONE;
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip6ha_attr_node_delete
|
||||
*===========================================================================
|
||||
* Description: Dump a node
|
||||
* Parameters: event - Current event
|
||||
* data - Data
|
||||
* proc - Current process
|
||||
* lock - Command locking structure
|
||||
* node - Node.
|
||||
* Returns: IP_FALSE
|
||||
*
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipmip6ha_attr_node_delete(Ipmip6ha_context_t *ctx,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmip_cli_message_t *request,
|
||||
Ipmip6ha_node_t *node)
|
||||
{
|
||||
struct Ipmip_attr_header *hdr = (struct Ipmip_attr_header *)IPMIP_BUFFER_DATA(&request->request);
|
||||
|
||||
/**/
|
||||
ipmip_attr_hdr_finalize(&request->message, ipmip_attr_hdr_ack(&request->message, hdr));
|
||||
/* Commit the reply */
|
||||
ipmip_cli_message_commit(&ctx->ipmip6.ipmip, proc, request);
|
||||
|
||||
/* Terminate the node(s) */
|
||||
ipmip6ha_node_delete(ctx, proc, node, "administrative termination");
|
||||
|
||||
return IPMIP_TIMER_RET_DONE;
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip6ha_attr_node_delete
|
||||
*===========================================================================
|
||||
* Description: Dump a node
|
||||
* Parameters: event - Current event
|
||||
* data - Data
|
||||
* proc - Current process
|
||||
* lock - Command locking structure
|
||||
* node - Node.
|
||||
* Returns: IP_FALSE
|
||||
*
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipmip6ha_attr_node_revoke(Ipmip6ha_context_t *ctx,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmip_cli_message_t *request,
|
||||
Ipmip6ha_node_t *node,
|
||||
Ip_bool inet)
|
||||
{
|
||||
struct Ipmip_attr_header *hdr = (struct Ipmip_attr_header *)IPMIP_BUFFER_DATA(&request->request);
|
||||
Ip_size_t rhdr = 0;
|
||||
int ret = IPMIP_TIMER_RET_DONE;
|
||||
if (node == IP_NULL)
|
||||
rhdr = ipmip_attr_hdr_err(&request->message, hdr, IP_ERRNO_ENOENT, IP_NULL);
|
||||
else
|
||||
{
|
||||
struct Ipmip_attr *rta_reason = ipmip_attr_hdr_find(hdr, IPMIP6HA_CLI_ATTR_BC_X_REVOKE_REASON);
|
||||
Ip_u8 reason = IPMIP6_MH_BRI_TRIGGER_ADMINISTRATIVE_REASON;
|
||||
|
||||
/**/
|
||||
if (rta_reason != IP_NULL)
|
||||
reason = (Ip_u8)ipmip_attr_get_u32(rta_reason);
|
||||
|
||||
/**/
|
||||
rhdr = ipmip_attr_hdr_ack(&request->message, hdr);
|
||||
|
||||
|
||||
/* Terminate the node(s) */
|
||||
ret = ipmip6ha_node_revoke(ctx, proc, node, inet, reason, IP_NULL);
|
||||
}
|
||||
|
||||
/* If we have a reply header; terminate it */
|
||||
ipmip_attr_hdr_finalize(&request->message, rhdr);
|
||||
|
||||
/* Commit the reply */
|
||||
ipmip_cli_message_commit(&ctx->ipmip6.ipmip, proc, request);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip6mn_attr_network_dump
|
||||
*===========================================================================
|
||||
* Description: Dump a node
|
||||
* Parameters: event - Current event
|
||||
* data - Data
|
||||
* proc - Current process
|
||||
* lock - Command locking structure
|
||||
* node - Node.
|
||||
* Returns: IP_FALSE
|
||||
*
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipmip6ha_attr_node_do(int event,
|
||||
Ipmip6ha_context_t *ctx,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmip_cli_message_t *request,
|
||||
Ipmip6ha_node_t *node)
|
||||
{
|
||||
if (event == IPMIP_TIMER_EVENT_RUN)
|
||||
{
|
||||
struct Ipmip_attr_header *hdr = (struct Ipmip_attr_header *)IPMIP_BUFFER_DATA(&request->request);
|
||||
switch (IPMIP_ATTR_HDR_TYPE(hdr))
|
||||
{
|
||||
case IPMIP6HA_CLI_BC_X_GET:
|
||||
return ipmip6ha_attr_node_dump(ctx, proc, request, node);
|
||||
case IPMIP6HA_CLI_BC_X_DELETE:
|
||||
return ipmip6ha_attr_node_delete(ctx, proc, request, node);
|
||||
case IPMIP6HA_CLI_BC_X_REVOKE_NODE:
|
||||
return ipmip6ha_attr_node_revoke(ctx, proc, request, node, IP_FALSE);
|
||||
case IPMIP6HA_CLI_BC_X_REVOKE_NODE_INET:
|
||||
return ipmip6ha_attr_node_revoke(ctx, proc, request, node, IP_TRUE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Free the request */
|
||||
ipmip_cli_message_free(&ctx->ipmip6.ipmip, proc, request);
|
||||
}
|
||||
|
||||
/**/
|
||||
return IPMIP_TIMER_RET_DONE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
IP_GLOBAL int
|
||||
ipmip6ha_attr_command(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip_cli_message *request)
|
||||
{
|
||||
struct Ipmip_attr_header *hdr = (struct Ipmip_attr_header *)IPMIP_BUFFER_DATA(&request->request);
|
||||
Ip_size_t rhdr = 0;
|
||||
struct Ipmip_attr *idattr[IPMIP6HA_CLI_ATTR_BC_X_MAX + 1];
|
||||
|
||||
|
||||
switch (IPMIP_ATTR_HDR_TYPE(hdr))
|
||||
{
|
||||
case IPMIP6HA_CLI_BC_X_LIST:
|
||||
{
|
||||
struct Ipmip6ha_attr_op aop;
|
||||
Ip_bool do_nai;
|
||||
|
||||
ipcom_memset(&aop, 0, sizeof(aop));
|
||||
|
||||
aop.request = request;
|
||||
|
||||
ipmip_attr_hdr_parse(IPMIP6HA_CLI_ATTR_BC_X_MAX, hdr, idattr);
|
||||
|
||||
|
||||
aop.hoa = ipmip_attr_get_inet6(idattr[IPMIP6HA_CLI_ATTR_BC_X_HOA_V6]);
|
||||
|
||||
if (idattr[IPMIP6HA_CLI_ATTR_BC_X_IFNAME])
|
||||
aop.ifindex = ipcom_if_nametoindex(ipmip_attr_get_str(idattr[IPMIP6HA_CLI_ATTR_BC_X_IFNAME]));
|
||||
|
||||
/* NAI */
|
||||
if (idattr[IPMIP6HA_CLI_ATTR_BC_X_MOBILE_NAI] != IP_NULL)
|
||||
{
|
||||
aop.nai_mn = IPMIP_ATTR_DATA(idattr[IPMIP6HA_CLI_ATTR_BC_X_MOBILE_NAI]);
|
||||
aop.nai_mn_len = IPMIP_ATTR_PAYLOAD(idattr[IPMIP6HA_CLI_ATTR_BC_X_MOBILE_NAI]);
|
||||
}
|
||||
|
||||
rhdr = ipmip_attr_hdr_ack(&request->message, hdr);
|
||||
|
||||
ipmip_context_id_lock(ctx->idents);
|
||||
ipmip_context_id_foreach(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
ctx->idents,
|
||||
(Ipmip_util_hash_foreach_t)ipmip6ha_attr_list_nodes,
|
||||
&aop,
|
||||
&do_nai);
|
||||
ipmip_context_id_unlock(ctx->idents);
|
||||
}
|
||||
break;
|
||||
case IPMIP6HA_CLI_BC_X_GET:
|
||||
case IPMIP6HA_CLI_BC_X_DELETE:
|
||||
case IPMIP6HA_CLI_BC_X_REVOKE_NODE:
|
||||
case IPMIP6HA_CLI_BC_X_REVOKE_NODE_INET:
|
||||
{
|
||||
struct Ipmip_attr *rta_handle = ipmip_attr_hdr_find(hdr, IPMIP6HA_CLI_ATTR_BC_X_HANDLE);
|
||||
/**/
|
||||
if (rta_handle == IP_NULL)
|
||||
return -IP_ERRNO_EINVAL;
|
||||
|
||||
/* Get by identity */
|
||||
ipmip6ha_node_lookup_handle(ctx,
|
||||
proc,
|
||||
ipmip_attr_get_u32(rta_handle),
|
||||
&request->timer,
|
||||
(Ipmip_timer_func_t)ipmip6ha_attr_node_do,
|
||||
request);
|
||||
return 0;
|
||||
}
|
||||
|
||||
case IPMIP_CLI_NAME_LIST:
|
||||
rhdr = ipmip_attr_hdr_ack(&request->message, hdr);
|
||||
{
|
||||
/* Dump each configuration item we've currently got in human readable form */
|
||||
Ipmip6ha_if_notify_t *notify;
|
||||
|
||||
ipmip_attr_put_str(&request->message, IPMIP_CLI_ITEM_NAME, "global");
|
||||
|
||||
/* Clear any old interfaces */
|
||||
for (notify = IPCOM_LIST_FIRST(&ctx->ifs); notify != IP_NULL; notify = IPCOM_LIST_NEXT(¬ify->next))
|
||||
ipmip_attr_put_str(&request->message, IPMIP_CLI_ITEM_NAME, notify->ipmip6.ifp->iff.ifname);
|
||||
}
|
||||
break;
|
||||
case IPMIP_CLI_CONFIG_GET:
|
||||
rhdr = ipmip_attr_hdr_ack(&request->message, hdr);
|
||||
|
||||
{
|
||||
/* Dump each configuration item we've currently got in human readable form */
|
||||
Ipmip6ha_if_notify_t *notify;
|
||||
unsigned int si;
|
||||
|
||||
struct Ipmip_attr *rta_name = ipmip_attr_hdr_find(hdr, IPMIP_CLI_ITEM_NAME);
|
||||
|
||||
if (rta_name == IP_NULL || ipcom_strcasecmp("global", ipmip_attr_get_str(rta_name)) == 0)
|
||||
{
|
||||
for (si = 0; si < ctx->extensions_num; si++)
|
||||
{
|
||||
if (ctx->extensions[si]->config_global != IP_NULL && ctx->extdata[si] != IP_NULL)
|
||||
(*ctx->extensions[si]->config_global) (ctx, proc, IPMIP_CALLBACK_CONFIG_DUMP, ctx->extdata[si], request);
|
||||
}
|
||||
|
||||
/* Dump the relay map */
|
||||
ipmip6ha_dump_relay_map(ctx, proc, &request->message);
|
||||
}
|
||||
|
||||
/* Clear any old interfaces */
|
||||
for (notify = IPCOM_LIST_FIRST(&ctx->ifs); notify != IP_NULL; notify = IPCOM_LIST_NEXT(¬ify->next))
|
||||
{
|
||||
Ipmip6ha_if_t *ife = (Ipmip6ha_if_t *)notify->ipmip6.ifp;
|
||||
|
||||
if (rta_name != IP_NULL && ipcom_strcasecmp(ife->ipmip6.iff.ifname, ipmip_attr_get_str(rta_name)) != 0)
|
||||
continue;
|
||||
|
||||
/**/
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6ha.interface.%s.lifetime=%d",
|
||||
ife->ipmip6.iff.ifname, ife->lifetime);
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6ha.interface.%s.refresh=%d",
|
||||
ife->ipmip6.iff.ifname, ife->refresh);
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6ha.interface.%s.homeagent=%s",
|
||||
ife->ipmip6.iff.ifname, ipmip_ntop_inet6(proc, &ife->ifaddr.prefix, IP_NULL));
|
||||
|
||||
#ifdef IPMIP_USE_INET
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6ha.interface.%s.inet.homeagent=%s",
|
||||
ife->ipmip6.iff.ifname, ipmip_ntop_inet(proc, ife->ifaddr_v4));
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6ha.interface.%s.tunnel.inet.ipip=%s",
|
||||
ife->ipmip6.iff.ifname, ife->ifenabled_H[IPMIP_TUNNELTYPE_IPIP]? "enabled" : "disabled");
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6ha.interface.%s.LMA.inet.tunnel.ipip=%s",
|
||||
ife->ipmip6.iff.ifname, ife->ifenabled_P[IPMIP_TUNNELTYPE_IPIP]? "enabled" : "disabled");
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6ha.interface.%s.LMA.inet.tunnel.gre=%s",
|
||||
ife->ipmip6.iff.ifname, ife->ifenabled_P[IPMIP_TUNNELTYPE_GRE]? "enabled" : "disabled");
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6ha.interface.%s.inet.AcceptForcedIPv4UDPEncapsulationRequest=%s",
|
||||
ife->ipmip6.iff.ifname, ife->AcceptForcedIPv4UDPEncapsulationRequest? "true" : "false");
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6ha.interface.%s.inet.ForceIPv4UDPEncapsulation=%s",
|
||||
ife->ipmip6.iff.ifname, ife->ForceIPv4UDPEncapsulation? "true" : "false");
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6ha.interface.%s.inet.IPv4UDPEncapsulationNATTimeout=%u",
|
||||
ife->ipmip6.iff.ifname, ife->IPv4UDPEncapsulationNATTimeout);
|
||||
#endif
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6ha.interface.%s.AcceptUDPTLVEncapsulation=%s",
|
||||
ife->ipmip6.iff.ifname, ife->AcceptUDPTLVEncapsulation? "true" : "false");
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6ha.interface.%s.tunnel.ip6ip6=%s",
|
||||
ife->ipmip6.iff.ifname, ife->ifenabled_H[IPMIP_TUNNELTYPE_IP6IP6]? "enabled" : "disabled");
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6ha.interface.%s.BRIMaxRetriesNumber=%d",
|
||||
ife->ipmip6.iff.ifname, ife->BRIMaxRetriesNumber);
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6ha.interface.%s.LMA.BindingRevocation=%s",
|
||||
ife->ipmip6.iff.ifname, ife->BindingRevocationEnabled? "enabled" : "disabled");
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6ha.interface.%s.MINDelayBRIs=%d",
|
||||
ife->ipmip6.iff.ifname, ife->MINDelayBRIs);
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6ha.interface.%s.LMA.tunnel.ip6ip6=%s",
|
||||
ife->ipmip6.iff.ifname, ife->ifenabled_P[IPMIP_TUNNELTYPE_IP6IP6]? "enabled" : "disabled");
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6ha.interface.%s.LMA.tunnel.gre=%s",
|
||||
ife->ipmip6.iff.ifname, ife->ifenabled_P[IPMIP_TUNNELTYPE_GRE6]? "enabled" : "disabled");
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6ha.interface.%s.LMA.MinDelayBeforeBCEDelete=%d",
|
||||
ife->ipmip6.iff.ifname, ife->MinDelayBeforeBCEDelete);
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6ha.interface.%s.LMA.MaxDelayBeforeNewBCEAssign=%d",
|
||||
ife->ipmip6.iff.ifname, ife->MaxDelayBeforeNewBCEAssign);
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6ha.interface.%s.LMA.TimestampValidityWindow=%d",
|
||||
ife->ipmip6.iff.ifname, ife->TimestampValidityWindow);
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6ha.interface.%s.LMA.TimestampBasedApproachInUse=%d",
|
||||
ife->ipmip6.iff.ifname, ife->TimestampBasedApproachInUse? 1 : 0);
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6ha.interface.%s.LMA.MobileNodeGeneratedTimestampInUse=%d",
|
||||
ife->ipmip6.iff.ifname, ife->MobileNodeGeneratedTimestampInUse? 1 : 0);
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6ha.interface.%s.AlwaysVerifyTunnelSrc=%s",
|
||||
ife->ipmip6.iff.ifname, ife->AlwaysVerifyTunnelSrc? "enabled" : "disabled");
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmip6ha.interface.%s.RelayBindings=%s",
|
||||
ife->ipmip6.iff.ifname, ife->RelayBindings? "enabled" : "disabled");
|
||||
|
||||
ipmip6ha_mag_configure_dump(ctx, proc, ife, &request->message);
|
||||
|
||||
ipmip6ha_nemo_dump_config(ctx, proc, ife->nemo, ife->ipmip6.iff.ifname, &request->message);
|
||||
|
||||
for (si = 0; si < ctx->extensions_num; si++)
|
||||
{
|
||||
if (ctx->extensions[si]->config_ifp != IP_NULL)
|
||||
(*ctx->extensions[si]->config_ifp) (ctx, proc, IPMIP_CALLBACK_CONFIG_DUMP, ife, ctx->extdata[si], ife->extdata[si], request);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* */
|
||||
break;
|
||||
case IPMIP6HA_CLI_PREFIX_GET:
|
||||
rhdr = ipmip_attr_hdr_ack(&request->message, hdr);
|
||||
{
|
||||
Ipmip6ha_if_notify_t *notify;
|
||||
/* Clear any old interfaces */
|
||||
for (notify = IPCOM_LIST_FIRST(&ctx->ifs); notify != IP_NULL; notify = IPCOM_LIST_NEXT(¬ify->next))
|
||||
{
|
||||
Ipmip6ha_if_t *ifp = (Ipmip6ha_if_t *)notify->ipmip6.ifp;
|
||||
Ipmip6_if_prefix_t *prefix;
|
||||
Ipmip6_if_router_t *router;
|
||||
|
||||
ipmip_timer_lock_acquire(&ctx->ipmip6.ipmip, proc, ifp->ipmip6.iff_lock);
|
||||
|
||||
/* We have the address; do prefix matching */
|
||||
for (router = IPCOM_LIST_FIRST(&ifp->ipmip6.routers); router != IP_NULL; router = IPCOM_LIST_NEXT(&router->next))
|
||||
{
|
||||
for (prefix = IPCOM_LIST_FIRST(&router->prefixes); prefix != IP_NULL; prefix = IPCOM_LIST_NEXT(&prefix->next))
|
||||
{
|
||||
if (IP_BIT_ISSET(prefix->flags, IPMIP6_ND_OPT_PI_FLAG_ONLINK))
|
||||
{
|
||||
Ip_size_t rta = ipmip_attr_begin(&request->message, IPMIP6HA_CLI_ATTR_PREFIX);
|
||||
|
||||
/* */
|
||||
ipmip_attr_put(&request->message, IPMIP6HA_CLI_ATTR_PREFIX_PREFIX, sizeof(prefix->prefix), &prefix->prefix);
|
||||
ipmip_attr_put_inet6(&request->message, IPMIP6HA_CLI_ATTR_PREFIX_ROUTER, &router->addr);
|
||||
ipmip_attr_put_str(&request->message, IPMIP6HA_CLI_ATTR_PREFIX_IFNAME, ifp->ipmip6.iff.ifname);
|
||||
ipmip_attr_put_time_t(&request->message, IPMIP6HA_CLI_ATTR_PREFIX_VALID, prefix->valid);
|
||||
ipmip_attr_put_time_t(&request->message, IPMIP6HA_CLI_ATTR_PREFIX_TIMESTAMP, prefix->stamp);
|
||||
ipmip_attr_end(&request->message, rta);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ipmip_timer_lock_release(&ctx->ipmip6.ipmip, proc, ifp->ipmip6.iff_lock);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case IPMIP6HA_CLI_MAG_GET:
|
||||
rhdr = ipmip_attr_hdr_ack(&request->message, hdr);
|
||||
{
|
||||
Ipmip6ha_if_notify_t *notify;
|
||||
/* Clear any old interfaces */
|
||||
for (notify = IPCOM_LIST_FIRST(&ctx->ifs); notify != IP_NULL; notify = IPCOM_LIST_NEXT(¬ify->next))
|
||||
ipmip6ha_mag_attr_get(ctx, proc, (Ipmip6ha_if_t *)notify->ipmip6.ifp, &request->message);
|
||||
}
|
||||
break;
|
||||
|
||||
case IPMIP6HA_CLI_MAG_REVOKE:
|
||||
/* Must locate MAG and */
|
||||
{
|
||||
const char *m_ifname = ipmip_attr_hdr_find_str(hdr, IPMIP6HA_CLI_ATTR_MAG_IFNAME);
|
||||
struct Ip_in6_addr *m_addr = ipmip_attr_hdr_find_inet6(hdr, IPMIP6HA_CLI_ATTR_MAG_ADDR_V6);
|
||||
Ipmip6ha_if_notify_t *notify;
|
||||
Ipmip6ha_if_t *ife;
|
||||
Ipmip6ha_mag_t *mag;
|
||||
|
||||
/**/
|
||||
if (m_ifname == IP_NULL || m_addr == IP_NULL)
|
||||
return -IP_ERRNO_EINVAL;
|
||||
|
||||
for (notify = IPCOM_LIST_FIRST(&ctx->ifs); notify != IP_NULL; notify = IPCOM_LIST_NEXT(¬ify->next))
|
||||
{
|
||||
ife = (Ipmip6ha_if_t *)notify->ipmip6.ifp;
|
||||
if (ipcom_strcasecmp(ife->ipmip6.iff.ifname, m_ifname) == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
if (notify == IP_NULL)
|
||||
return -IP_ERRNO_ENXIO;
|
||||
|
||||
/* Time to find the MAG */
|
||||
mag = ipmip6ha_mag_get(ctx, proc, ife, m_addr, 0);
|
||||
if (mag == IP_NULL)
|
||||
return -IP_ERRNO_ENOENT;
|
||||
|
||||
/* Time to revoke */
|
||||
ipmip6ha_mag_revoke(ctx, proc, mag, (Ip_u8)ipmip_attr_hdr_find_u32(hdr, IPMIP6HA_CLI_ATTR_MAG_REASON), ipmip_attr_hdr_find_str(hdr, IPMIP6HA_CLI_ATTR_MAG_MATCH));
|
||||
|
||||
/* Must release */
|
||||
ipmip6ha_mag_release(ctx, proc, mag);
|
||||
|
||||
rhdr = ipmip_attr_hdr_ack(&request->message, hdr);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
/**/
|
||||
return ipmip6_attr_command(&ctx->ipmip6, proc, request);
|
||||
}
|
||||
|
||||
/* If we have a reply header; terminate it */
|
||||
ipmip_attr_hdr_finalize(&request->message, rhdr);
|
||||
|
||||
/* Commit the reply */
|
||||
ipmip_cli_message_commit(&ctx->ipmip6.ipmip, proc, request);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,108 @@
|
||||
/* ipmipfa_attr_h.h - ipmipfa_attr_h.h */
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip6ha_attr_h.h,v $ $Revision: 1.3 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip6ha/src/ipmip6ha_attr_h.h,v $
|
||||
* $Author: jhorteli $ $Date: 2008-12-01 16:18:39 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMIP6HA_ATTR_H_H
|
||||
#define IPMIP6HA_ATTR_H_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
/*
|
||||
DESCRIPTION
|
||||
|
||||
No description currently provided
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#include "ipmip6ha_attr.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
struct Ipmip6ha_context;
|
||||
struct Ipmip6ha_node;
|
||||
struct Ipmip_proc;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip6ha_attr_command - ipmip6ha_attr_command
|
||||
*
|
||||
* Process an attribute command
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i data
|
||||
* Context
|
||||
* \i proc
|
||||
* Process
|
||||
* \i request
|
||||
* Issued command.
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: IPCOM_SUCCESS when successful
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
* \NOMANUAL
|
||||
*/
|
||||
IP_GLOBAL int ipmip6ha_attr_command
|
||||
(
|
||||
struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip_cli_message *request
|
||||
);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,517 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip6ha_cli.c,v $ $Revision: 1.8 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip6ha/src/ipmip6ha_cli.c,v $
|
||||
* $Author: jhorteli $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelis@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipmip6ha_config.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_err.h>
|
||||
#include <ipcom_inet.h>
|
||||
#include <ipcom_ipd.h>
|
||||
#include <ipcom_list.h>
|
||||
#include <ipcom_hash.h>
|
||||
#include <ipcom_os.h>
|
||||
#include <ipcom_sock.h>
|
||||
#include <ipcom_sock.h>
|
||||
#include <ipcom_sock2.h>
|
||||
#include <ipcom_sysctl.h>
|
||||
#include <ipcom_syslog.h>
|
||||
#include <ipcom_route.h>
|
||||
|
||||
#include <ipmip.h>
|
||||
#include <private/ipmip_buffer.h>
|
||||
#include <private/ipmip_util.h>
|
||||
|
||||
#include <ipmip6.h>
|
||||
#include <private/ipmip6_context.h>
|
||||
#include <private/ipmip6_mh.h>
|
||||
#include <private/ipmip6_mh_pkt.h>
|
||||
#include <private/ipmip6_if.h>
|
||||
#include <private/ipmip6_util.h>
|
||||
#include <private/ipmip6_address.h>
|
||||
|
||||
#include "ipmip6ha.h"
|
||||
#include "ipmip6ha_attr.h"
|
||||
#include "ipmip6ha_cli.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_PUBLIC Ip_bool
|
||||
ipmip6ha_cli_connect(Ipmip_cli_daemon_t *daemon_info)
|
||||
{
|
||||
ipmip_cli_daemon_init(daemon_info, "ipmip6ha", IPCOM_IPD_ID_IPMIP6HA);
|
||||
return ipmip_cli_daemon_connect(daemon_info);
|
||||
}
|
||||
|
||||
|
||||
IP_PUBLIC int
|
||||
ipmip6ha_cli_node_list(Ipmip_cli_daemon_t *daemon,
|
||||
Ipmip_cli_daemon_req_t *req,
|
||||
const char *ifname,
|
||||
const struct Ip_in6_addr *hoa,
|
||||
const char *nai)
|
||||
{
|
||||
ipmip_cli_daemon_request_start(req, IPMIP6HA_CLI_BC_X_LIST);
|
||||
|
||||
ipmip6ha_cli_request_set_ifname(req, ifname);
|
||||
ipmip6ha_cli_request_set_nai(req, nai);
|
||||
ipmip6ha_cli_request_set_hoa(req, hoa);
|
||||
|
||||
return ipmip_cli_daemon_request(daemon, req);
|
||||
}
|
||||
|
||||
|
||||
IP_PUBLIC void
|
||||
ipmip6ha_cli_request_set_nai(Ipmip_cli_daemon_req_t *req,
|
||||
const char *nai)
|
||||
{
|
||||
if (nai)
|
||||
ipmip_attr_put_str(&req->reqbuf, IPMIP6HA_CLI_ATTR_BC_X_MOBILE_NAI, nai);
|
||||
}
|
||||
|
||||
IP_PUBLIC void
|
||||
ipmip6ha_cli_request_set_ifname(Ipmip_cli_daemon_req_t *req,
|
||||
const char *ifname)
|
||||
{
|
||||
if (ifname)
|
||||
ipmip_attr_put_str(&req->reqbuf, IPMIP6HA_CLI_ATTR_BC_X_IFNAME, ifname);
|
||||
}
|
||||
|
||||
IP_PUBLIC void
|
||||
ipmip6ha_cli_request_set_hoa(Ipmip_cli_daemon_req_t *req,
|
||||
const struct Ip_in6_addr *hoa)
|
||||
{
|
||||
if (hoa)
|
||||
ipmip_attr_put_inet6(&req->reqbuf, IPMIP6HA_CLI_ATTR_BC_X_HOA_V6, hoa);
|
||||
}
|
||||
|
||||
#ifdef IPMIP_USE_INET
|
||||
IP_PUBLIC void
|
||||
ipmip6ha_cli_request_set_inet_hoa(Ipmip_cli_daemon_req_t *req,
|
||||
Ip_u32 inet_hoa)
|
||||
{
|
||||
if (inet_hoa)
|
||||
ipmip_attr_put_inet(&req->reqbuf, IPMIP6HA_CLI_ATTR_BC_X_HOA_V4, inet_hoa);
|
||||
}
|
||||
#endif
|
||||
|
||||
IP_PUBLIC void
|
||||
ipmip6ha_cli_request_set_handle(Ipmip_cli_daemon_req_t *req,
|
||||
Ip_u32 handle)
|
||||
{
|
||||
ipmip_attr_put_u32(&req->reqbuf, IPMIP6HA_CLI_ATTR_BC_X_HANDLE, handle);
|
||||
}
|
||||
|
||||
IP_PUBLIC void
|
||||
ipmip6ha_cli_request_set_revoke_reason(Ipmip_cli_daemon_req_t *req,
|
||||
Ip_u32 reason)
|
||||
{
|
||||
ipmip_attr_put_u32(&req->reqbuf, IPMIP6HA_CLI_ATTR_BC_X_REVOKE_REASON, reason);
|
||||
}
|
||||
|
||||
IP_PUBLIC Ip_u32
|
||||
ipmip6ha_cli_handle_next(Ipmip_attr_iter_t *iter)
|
||||
{
|
||||
return ipmip_attr_get_u32(ipmip_attr_iter_next(iter, IPMIP6HA_CLI_ATTR_BC_X_HANDLE));
|
||||
}
|
||||
|
||||
|
||||
IP_PUBLIC const char *
|
||||
ipmip6ha_cli_node_get_ifname(struct Ipmip_attr *node)
|
||||
{
|
||||
/**/
|
||||
return ipmip_attr_payload_find_str(node, IPMIP6HA_CLI_ATTR_BC_X_IFNAME);
|
||||
}
|
||||
|
||||
IP_PUBLIC const char *
|
||||
ipmip6ha_cli_node_get_nai(struct Ipmip_attr *node)
|
||||
{
|
||||
/**/
|
||||
return ipmip_attr_payload_find_str(node, IPMIP6HA_CLI_ATTR_BC_X_MOBILE_NAI);
|
||||
}
|
||||
|
||||
|
||||
IP_PUBLIC const struct Ip_in6_addr *
|
||||
ipmip6ha_cli_node_get_hoa(struct Ipmip_attr *node)
|
||||
{
|
||||
/**/
|
||||
return ipmip_attr_payload_find_inet6(node, IPMIP6HA_CLI_ATTR_BC_X_HOA_V6);
|
||||
}
|
||||
|
||||
IP_PUBLIC struct Ipmip_attr *
|
||||
ipmip6ha_cli_node_get(Ipmip_cli_daemon_t *daemon,
|
||||
Ipmip_cli_daemon_req_t *req,
|
||||
Ip_u32 handle)
|
||||
{
|
||||
ipmip_cli_daemon_request_start(req, IPMIP6HA_CLI_BC_X_GET);
|
||||
|
||||
ipmip6ha_cli_request_set_handle(req, handle);
|
||||
|
||||
if (ipmip_cli_daemon_request(daemon, req) == IPCOM_SUCCESS)
|
||||
return ipmip_cli_daemon_find_request(req, IPMIP6HA_CLI_ATTR_BC_X);
|
||||
|
||||
return IP_NULL;
|
||||
}
|
||||
|
||||
IP_PUBLIC void
|
||||
ipmip6ha_cli_node_delete(Ipmip_cli_daemon_t *daemon,
|
||||
Ip_u32 handle)
|
||||
{
|
||||
Ipmip_cli_daemon_req_t req;
|
||||
|
||||
ipmip_cli_daemon_request_init(&req);
|
||||
ipmip_cli_daemon_request_start(&req, IPMIP6HA_CLI_BC_X_DELETE);
|
||||
|
||||
ipmip6ha_cli_request_set_handle(&req, handle);
|
||||
|
||||
ipmip_cli_daemon_request(daemon, &req);
|
||||
ipmip_cli_daemon_request_release(&req);
|
||||
}
|
||||
|
||||
|
||||
IP_PUBLIC void
|
||||
ipmip6ha_cli_node_revoke(Ipmip_cli_daemon_t *daemon,
|
||||
Ip_u32 handle,
|
||||
Ip_u32 reason)
|
||||
{
|
||||
Ipmip_cli_daemon_req_t req;
|
||||
|
||||
ipmip_cli_daemon_request_init(&req);
|
||||
ipmip_cli_daemon_request_start(&req, IPMIP6HA_CLI_BC_X_REVOKE_NODE);
|
||||
|
||||
ipmip6ha_cli_request_set_handle(&req, handle);
|
||||
ipmip6ha_cli_request_set_revoke_reason(&req, reason);
|
||||
|
||||
ipmip_cli_daemon_request(daemon, &req);
|
||||
ipmip_cli_daemon_request_release(&req);
|
||||
}
|
||||
|
||||
#ifdef IPMIP_USE_INET
|
||||
IP_PUBLIC void
|
||||
ipmip6ha_cli_node_revoke_inet(Ipmip_cli_daemon_t *daemon,
|
||||
Ip_u32 handle,
|
||||
Ip_u32 reason)
|
||||
{
|
||||
Ipmip_cli_daemon_req_t req;
|
||||
|
||||
ipmip_cli_daemon_request_init(&req);
|
||||
ipmip_cli_daemon_request_start(&req, IPMIP6HA_CLI_BC_X_REVOKE_NODE_INET);
|
||||
|
||||
ipmip6ha_cli_request_set_handle(&req, handle);
|
||||
ipmip6ha_cli_request_set_revoke_reason(&req, reason);
|
||||
|
||||
ipmip_cli_daemon_request(daemon, &req);
|
||||
ipmip_cli_daemon_request_release(&req);
|
||||
}
|
||||
#endif
|
||||
|
||||
IP_PUBLIC Ip_time_t
|
||||
ipmip6ha_cli_node_get_updated(struct Ipmip_attr *node)
|
||||
{
|
||||
/**/
|
||||
return ipmip_attr_payload_find_time_t(node, IPMIP6HA_CLI_ATTR_BC_X_UPDATED);
|
||||
}
|
||||
|
||||
IP_PUBLIC Ip_u32
|
||||
ipmip6ha_cli_node_get_handle(struct Ipmip_attr *node)
|
||||
{
|
||||
/**/
|
||||
return ipmip_attr_payload_find_u32(node, IPMIP6HA_CLI_ATTR_BC_X_HANDLE);
|
||||
}
|
||||
|
||||
IP_PUBLIC Ip_u32
|
||||
ipmip6ha_cli_node_get_regflags(struct Ipmip_attr *node)
|
||||
{
|
||||
/**/
|
||||
return ipmip_attr_payload_find_u32(node, IPMIP6HA_CLI_ATTR_BC_X_REGFLAGS);
|
||||
}
|
||||
|
||||
IP_PUBLIC const struct Ipmip6_address *
|
||||
ipmip6ha_cli_node_get_home_prefix_list(struct Ipmip_attr *node,
|
||||
Ip_u32 *sz)
|
||||
{
|
||||
struct Ipmip_attr *rta = ipmip_attr_payload_find(node, IPMIP6HA_CLI_ATTR_BC_X_PREFIX_V6);
|
||||
if (rta)
|
||||
{
|
||||
*sz = (Ip_u32)(IPMIP_ATTR_PAYLOAD(rta) / sizeof(Ipmip6_address_t));
|
||||
return *sz? (Ipmip6_address_t *)IPMIP_ATTR_DATA(rta) : IP_NULL;
|
||||
}
|
||||
|
||||
return IP_NULL;
|
||||
}
|
||||
|
||||
#ifdef IPMIP_USE_INET
|
||||
|
||||
IP_PUBLIC const Ip_u32 *
|
||||
ipmip6ha_cli_node_get_inet_home_address_list(struct Ipmip_attr *node,
|
||||
Ip_u32 *sz)
|
||||
{
|
||||
struct Ipmip_attr *rta = ipmip_attr_payload_find(node, IPMIP6HA_CLI_ATTR_BC_X_HOA_V4);
|
||||
if (rta)
|
||||
{
|
||||
*sz = (Ip_u32)(IPMIP_ATTR_PAYLOAD(rta) / sizeof(Ip_u32));
|
||||
return *sz? (Ip_u32 *)IPMIP_ATTR_DATA(rta) : IP_NULL;
|
||||
}
|
||||
|
||||
return IP_NULL;
|
||||
}
|
||||
|
||||
IP_PUBLIC const struct Ipmip6_inet *
|
||||
ipmip6ha_cli_node_get_inet_home_prefix_list(struct Ipmip_attr *node,
|
||||
Ip_u32 *sz)
|
||||
{
|
||||
struct Ipmip_attr *rta = ipmip_attr_payload_find(node, IPMIP6HA_CLI_ATTR_BC_X_PREFIX_V4);
|
||||
if (rta)
|
||||
{
|
||||
*sz = (Ip_u32)(IPMIP_ATTR_PAYLOAD(rta) / sizeof(Ipmip6_inet_t));
|
||||
return *sz? (Ipmip6_inet_t *)IPMIP_ATTR_DATA(rta) : IP_NULL;
|
||||
}
|
||||
|
||||
return IP_NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
IP_PUBLIC const struct Ipmip6_mib_mip6NodeTrafficEntry *
|
||||
ipmip6ha_cli_node_get_mip6NodeTrafficEntry(struct Ipmip_attr *node)
|
||||
{
|
||||
/**/
|
||||
return (const struct Ipmip6_mib_mip6NodeTrafficEntry *)ipmip_attr_payload_find_data(node, IPMIP6HA_CLI_ATTR_BC_X_MIB_mip6NodeTrafficEntry);
|
||||
}
|
||||
|
||||
IP_PUBLIC const struct Ipmip6_mib_mip6BindingCacheEntry *
|
||||
ipmip6ha_cli_node_get_mip6BindingCacheEntry(struct Ipmip_attr *node)
|
||||
{
|
||||
/**/
|
||||
return (const struct Ipmip6_mib_mip6BindingCacheEntry *)ipmip_attr_payload_find_data(node, IPMIP6HA_CLI_ATTR_BC_X_MIB_mip6BindingCacheEntry);
|
||||
}
|
||||
|
||||
|
||||
IP_PUBLIC int
|
||||
ipmip6ha_cli_prefix_list(Ipmip_cli_daemon_t *daemon,
|
||||
Ipmip_cli_daemon_req_t *req)
|
||||
{
|
||||
ipmip_cli_daemon_request_start(req, IPMIP6HA_CLI_PREFIX_GET);
|
||||
return ipmip_cli_daemon_request(daemon, req);
|
||||
}
|
||||
|
||||
IP_PUBLIC struct Ipmip_attr*
|
||||
ipmip6ha_cli_prefix_next(Ipmip_attr_iter_t *iter)
|
||||
{
|
||||
/**/
|
||||
return ipmip_attr_iter_next(iter, IPMIP6HA_CLI_ATTR_PREFIX);
|
||||
}
|
||||
|
||||
IP_PUBLIC const char *
|
||||
ipmip6ha_cli_prefix_get_ifname(struct Ipmip_attr *prefix)
|
||||
{
|
||||
return ipmip_attr_payload_find_str(prefix, IPMIP6HA_CLI_ATTR_PREFIX_IFNAME);
|
||||
}
|
||||
|
||||
IP_PUBLIC const struct Ip_in6_addr *
|
||||
ipmip6ha_cli_prefix_get_router(struct Ipmip_attr *prefix)
|
||||
{
|
||||
return ipmip_attr_payload_find_inet6(prefix, IPMIP6HA_CLI_ATTR_PREFIX_ROUTER);
|
||||
}
|
||||
|
||||
IP_PUBLIC const Ipmip6_address_t *
|
||||
ipmip6ha_cli_prefix_get_prefix(struct Ipmip_attr *prefix)
|
||||
{
|
||||
return (const Ipmip6_address_t *)ipmip_attr_payload_find_data(prefix, IPMIP6HA_CLI_ATTR_PREFIX_PREFIX);
|
||||
}
|
||||
|
||||
IP_PUBLIC Ip_time_t
|
||||
ipmip6ha_cli_prefix_get_prefix_valid(struct Ipmip_attr *prefix)
|
||||
{
|
||||
return ipmip_attr_payload_find_time_t(prefix, IPMIP6HA_CLI_ATTR_PREFIX_VALID);
|
||||
}
|
||||
|
||||
IP_PUBLIC Ip_time_t
|
||||
ipmip6ha_cli_prefix_get_prefix_timestamp(struct Ipmip_attr *prefix)
|
||||
{
|
||||
return ipmip_attr_payload_find_time_t(prefix, IPMIP6HA_CLI_ATTR_PREFIX_TIMESTAMP);
|
||||
}
|
||||
|
||||
IP_PUBLIC int
|
||||
ipmip6ha_cli_mag_list(Ipmip_cli_daemon_t *daemon,
|
||||
Ipmip_cli_daemon_req_t *req)
|
||||
{
|
||||
ipmip_cli_daemon_request_start(req, IPMIP6HA_CLI_MAG_GET);
|
||||
return ipmip_cli_daemon_request(daemon, req);
|
||||
}
|
||||
|
||||
IP_PUBLIC struct Ipmip_attr*
|
||||
ipmip6ha_cli_mag_next(Ipmip_attr_iter_t *iter)
|
||||
{
|
||||
/**/
|
||||
return ipmip_attr_iter_next(iter, IPMIP6HA_CLI_ATTR_MAG);
|
||||
}
|
||||
|
||||
IP_PUBLIC const char *
|
||||
ipmip6ha_cli_mag_get_ifname(struct Ipmip_attr *mag)
|
||||
{
|
||||
return ipmip_attr_payload_find_str(mag, IPMIP6HA_CLI_ATTR_MAG_IFNAME);
|
||||
}
|
||||
|
||||
IP_PUBLIC const struct Ip_in6_addr *
|
||||
ipmip6ha_cli_mag_get_addr_v6(struct Ipmip_attr *mag)
|
||||
{
|
||||
return ipmip_attr_payload_find_inet6(mag, IPMIP6HA_CLI_ATTR_MAG_ADDR_V6);
|
||||
}
|
||||
|
||||
#ifdef IPMIP_USE_INET
|
||||
IP_PUBLIC Ip_u32
|
||||
ipmip6ha_cli_mag_get_addr_v4(struct Ipmip_attr *mag)
|
||||
{
|
||||
return ipmip_attr_payload_find_inet(mag, IPMIP6HA_CLI_ATTR_MAG_ADDR_V4);
|
||||
}
|
||||
#endif
|
||||
|
||||
IP_PUBLIC Ip_u32
|
||||
ipmip6ha_cli_mag_get_references(struct Ipmip_attr *mag)
|
||||
{
|
||||
return ipmip_attr_payload_find_u32(mag, IPMIP6HA_CLI_ATTR_MAG_REFERENCES);
|
||||
}
|
||||
|
||||
IP_PUBLIC Ip_u32
|
||||
ipmip6ha_cli_mag_get_heartbeat(struct Ipmip_attr *mag)
|
||||
{
|
||||
return ipmip_attr_payload_find_u32(mag, IPMIP6HA_CLI_ATTR_MAG_HEARTBEAT);
|
||||
}
|
||||
|
||||
|
||||
IP_PUBLIC void
|
||||
ipmip6ha_cli_mag_request_set_mag(Ipmip_cli_daemon_req_t *req,
|
||||
const struct Ip_in6_addr *mag)
|
||||
{
|
||||
if (mag)
|
||||
ipmip_attr_put_inet6(&req->reqbuf, IPMIP6HA_CLI_ATTR_MAG_ADDR_V6, mag);
|
||||
}
|
||||
|
||||
IP_PUBLIC void
|
||||
ipmip6ha_cli_mag_request_set_revoke_reason(Ipmip_cli_daemon_req_t *req,
|
||||
Ip_u32 reason)
|
||||
{
|
||||
ipmip_attr_put_u32(&req->reqbuf, IPMIP6HA_CLI_ATTR_MAG_REASON, reason);
|
||||
}
|
||||
|
||||
IP_PUBLIC void
|
||||
ipmip6ha_cli_mag_request_set_ifname(Ipmip_cli_daemon_req_t *req,
|
||||
const char *ifname)
|
||||
{
|
||||
if (ifname)
|
||||
ipmip_attr_put_str(&req->reqbuf, IPMIP6HA_CLI_ATTR_MAG_IFNAME, ifname);
|
||||
}
|
||||
|
||||
IP_PUBLIC void
|
||||
ipmip6ha_cli_mag_request_set_match(Ipmip_cli_daemon_req_t *req,
|
||||
const char *match)
|
||||
{
|
||||
if (match)
|
||||
ipmip_attr_put_str(&req->reqbuf, IPMIP6HA_CLI_ATTR_MAG_MATCH, match);
|
||||
}
|
||||
|
||||
|
||||
IP_PUBLIC void
|
||||
ipmip6ha_cli_mag_revoke(Ipmip_cli_daemon_t *daemon,
|
||||
const char *ifname,
|
||||
const struct Ip_in6_addr *mag,
|
||||
Ip_u8 reason,
|
||||
const char *nai_match)
|
||||
{
|
||||
Ipmip_cli_daemon_req_t req;
|
||||
|
||||
ipmip_cli_daemon_request_init(&req);
|
||||
ipmip_cli_daemon_request_start(&req, IPMIP6HA_CLI_MAG_REVOKE);
|
||||
|
||||
ipmip6ha_cli_mag_request_set_mag(&req, mag);
|
||||
ipmip6ha_cli_mag_request_set_revoke_reason(&req, reason);
|
||||
ipmip6ha_cli_mag_request_set_match(&req, nai_match);
|
||||
ipmip6ha_cli_mag_request_set_ifname(&req, ifname);
|
||||
|
||||
ipmip_cli_daemon_request(daemon, &req);
|
||||
ipmip_cli_daemon_request_release(&req);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,844 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip6ha_cmd_ha6.c,v $ $Revision: 1.21 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip6ha/src/ipmip6ha_cmd_ha6.c,v $
|
||||
* $Author: jhorteli $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
#include "ipmip6ha_config.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_os.h>
|
||||
#include <ipcom_list.h>
|
||||
#include <ipcom_sock.h>
|
||||
#include <ipcom_sock6.h>
|
||||
#include <ipcom_inet.h>
|
||||
#include <ipcom_err.h>
|
||||
#include <ipcom_ipd.h>
|
||||
#include <ipcom_syslog.h>
|
||||
#include <ipcom_cmd.h>
|
||||
#include <ipcom_getopt.h>
|
||||
|
||||
#include <ipmip.h>
|
||||
#include <private/ipmip_context.h>
|
||||
#include <private/ipmip_cli.h>
|
||||
#include <private/ipmip_util.h>
|
||||
|
||||
#include <ipmip6.h>
|
||||
#include <private/ipmip6_address.h>
|
||||
#include <private/ipmip6_ntop.h>
|
||||
#include <private/ipmip6_mh_pkt.h>
|
||||
|
||||
#include "ipmip6ha_attr.h"
|
||||
#include "ipmip6ha_cli.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
enum
|
||||
{
|
||||
IPMIP6HA_CMD_HA6_OP_LIST = 1,
|
||||
IPMIP6HA_CMD_HA6_OP_SHOW,
|
||||
IPMIP6HA_CMD_HA6_OP_DELETE,
|
||||
IPMIP6HA_CMD_HA6_OP_REVOKE,
|
||||
IPMIP6HA_CMD_HA6_OP_PREFIX,
|
||||
IPMIP6HA_CMD_HA6_OP_REVOKE_NODE,
|
||||
IPMIP6HA_CMD_HA6_OP_REVOKE_NODE_INET,
|
||||
IPMIP6HA_CMD_HA6_OP_REVOKE_MAG,
|
||||
IPMIP6HA_CMD_HA6_OP_MAG
|
||||
};
|
||||
|
||||
#define IPMIP6HA_CMD_HDRSIZE 30
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
struct Ipmip6ha_cmd_op_val
|
||||
{
|
||||
int cmd;
|
||||
Ip_bool verbose;
|
||||
Ip_u8 reason;
|
||||
};
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
IP_STATIC Ipcom_cmd_int_str_map ipmip6ha_cmd_ha6_ops[] =
|
||||
{
|
||||
{ IPMIP6HA_CMD_HA6_OP_SHOW, "status" },
|
||||
{ IPMIP6HA_CMD_HA6_OP_SHOW, "show" },
|
||||
{ IPMIP6HA_CMD_HA6_OP_LIST, "list" },
|
||||
{ IPMIP6HA_CMD_HA6_OP_DELETE, "delete" },
|
||||
{ IPMIP6HA_CMD_HA6_OP_REVOKE, "revoke" },
|
||||
{ IPMIP6HA_CMD_HA6_OP_PREFIX, "prefix" },
|
||||
{ IPMIP6HA_CMD_HA6_OP_MAG, "mag" },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip6ha_cmd_ha6_print_usage
|
||||
*===========================================================================
|
||||
* Description: Prints the usage for the command.
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipmip6ha_cmd_ha6_print_usage(Ipmip_proc_t *proc)
|
||||
{
|
||||
ipmip_util_identprintf(proc, 0, "NAME"IP_LF);
|
||||
ipmip_util_identprintf(proc, 1, "ha6 - Displays Home Agent IPv6 bindings, statistics and status" IP_LF);
|
||||
ipmip_util_identprintf(proc, 0, "SYNOPSIS"IP_LF);
|
||||
ipmip_util_identprintf(proc, 1, "ha6 <command> [arguments]"IP_LF);
|
||||
ipmip_util_identprintf(proc, 0, "DESCRIPTION"IP_LF);
|
||||
ipmip_util_identprintf(proc, 1,
|
||||
"The ha6 command is used to display current Home Agent MIPv6"IP_LF
|
||||
"bindings, statistics and status"IP_LF);
|
||||
ipmip_util_identprintf(proc, 0, "COMMANDS"IP_LF);
|
||||
ipmip_util_cmdprintf(proc, 1, "list", "List all home agent bindings");
|
||||
ipmip_util_cmdprintf(proc, 1, "mag", "List all MAGs currently seen by the LMA");
|
||||
ipmip_util_cmdprintf(proc, 1, "prefix", "List all Prefixes currently seen by the Home Agent");
|
||||
ipmip_util_cmdprintf(proc, 1, "show [-va] [hoa|nai]", "Display information for specified binding");
|
||||
ipmip_util_identprintf(proc, 2, "-v Verbose information"IP_LF);
|
||||
ipmip_util_identprintf(proc, 2, "-a All bindings"IP_LF);
|
||||
ipmip_util_cmdprintf(proc, 1, "delete [-a] [hoa|nai]", "Delete specified binding");
|
||||
ipmip_util_identprintf(proc, 2, "-v Verbose information"IP_LF);
|
||||
ipmip_util_identprintf(proc, 2, "-a All bindings"IP_LF);
|
||||
|
||||
ipmip_util_cmdprintf(proc, 1, "revoke node [-a4] [hoa] [nai]", "Revoke the specified binding(s)");
|
||||
ipmip_util_identprintf(proc, 2, "-a All bindings"IP_LF);
|
||||
ipmip_util_identprintf(proc, 2, "-4 Only revoke INET bindings"IP_LF);
|
||||
ipmip_util_identprintf(proc, 2, "[nai] NAI of the binding to revoke"IP_LF);
|
||||
ipmip_util_identprintf(proc, 2, "[hoa] Home Address of the binding to revoke"IP_LF);
|
||||
|
||||
ipmip_util_cmdprintf(proc, 1, "revoke mag [-i <interface>] [-m <MAG Address>] [-r <reason>] [-n <NAI match>]", "Revoke all bindings attached to a MAG");
|
||||
ipmip_util_identprintf(proc, 2, "-i <interface> Specify the interface to be globally revoked"IP_LF);
|
||||
ipmip_util_identprintf(proc, 2, "-m <MAG address> Specify the exact MAG to revoke"IP_LF);
|
||||
ipmip_util_identprintf(proc, 2, "-r <number> Specify the binding revocation reason. Will be per-peer policy if not specified"IP_LF);
|
||||
ipmip_util_identprintf(proc, 2, "-n <NAI match> Specify a domain NAI match string such as *@domain.com that should be revoked"IP_LF);
|
||||
|
||||
ipmip6_cli_shell_usage(proc);
|
||||
}
|
||||
|
||||
|
||||
typedef void (*Ipmip6ha_cmd_foreach_func_t) (Ipmip_proc_t *proc,
|
||||
Ipmip_cli_daemon_t *daemon,
|
||||
Ip_u32 num,
|
||||
Ip_u32 handle,
|
||||
void *opaque);
|
||||
|
||||
IP_STATIC void
|
||||
ipmip6ha_cmd_foreach_binding(Ipmip_proc_t *proc,
|
||||
Ipmip_cli_daemon_t *daemon,
|
||||
Ipmip_cli_daemon_req_t *req,
|
||||
Ipmip6ha_cmd_foreach_func_t func,
|
||||
void *opaque)
|
||||
{
|
||||
Ip_u32 num = 0;
|
||||
Ipmip_attr_iter_t riter;
|
||||
Ip_u32 handle;
|
||||
|
||||
/**/
|
||||
ipmip_cli_daemon_iter_request_init(req, &riter);
|
||||
while ((handle = ipmip6ha_cli_handle_next(&riter)) != 0)
|
||||
(*func) (proc, daemon, num++, handle, opaque);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmipha_cmd_binding_flags
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC char *
|
||||
ipmip6ha_cmd_binding_flags(char *buffer,
|
||||
struct Ipmip_attr *node)
|
||||
{
|
||||
Ip_u32 flags = ipmip6ha_cli_node_get_regflags(node);
|
||||
int p = 0;
|
||||
|
||||
if (IP_BIT_ISSET(flags, IPMIP6_MH_BU_P))
|
||||
buffer[p++] = 'P';
|
||||
if (IP_BIT_ISSET(flags, IPMIP6_MH_BU_R))
|
||||
buffer[p++] = 'R';
|
||||
if (IP_BIT_ISSET(flags, IPMIP6_MH_BU_H))
|
||||
buffer[p++] = 'H';
|
||||
buffer[p++] = '\0';
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmipha_cmd_print_binding_fmt
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipmip6ha_cmd_print_binding_fmt(const char *hoa,
|
||||
const char *coa,
|
||||
const char *ifname,
|
||||
const char *lifetime,
|
||||
const char *flags)
|
||||
{
|
||||
/* */
|
||||
ipcom_printf("%-20s %-20s %-16s %-15s %s"IP_LF,
|
||||
hoa, coa, ifname, lifetime, flags);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmipha_cmd_print_binding
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipmip6ha_cmd_print_binding(Ipmip_proc_t *proc,
|
||||
Ipmip_cli_daemon_t *daemon,
|
||||
Ip_u32 num,
|
||||
struct Ipmip_attr *node,
|
||||
struct Ipmip6ha_cmd_op_val *ops)
|
||||
{
|
||||
char flags[16];
|
||||
const struct Ipmip6_mib_mip6BindingCacheEntry *entry = ipmip6ha_cli_node_get_mip6BindingCacheEntry(node);
|
||||
const char *name;
|
||||
|
||||
IPMIP_UNUSED_PARAMETER(ops);
|
||||
IPMIP_UNUSED_PARAMETER(daemon);
|
||||
IPMIP_UNUSED_PARAMETER(num);
|
||||
|
||||
ipcom_snprintf(proc->ntop.ntop_lla, sizeof(proc->ntop.ntop_lla),
|
||||
"%d/%d",
|
||||
IP_GET_32ON8(&entry->mip6BindingTimeRemaining),
|
||||
IP_GET_32ON8(&entry->mip6BindingTimeGranted));
|
||||
|
||||
if ((name = ipmip6ha_cli_node_get_nai(node)) == IP_NULL)
|
||||
{
|
||||
const struct Ip_in6_addr *hoa;
|
||||
if ((hoa = ipmip6ha_cli_node_get_hoa(node)) != IP_NULL)
|
||||
name = ipmip_ntop_inet6(proc, hoa, IP_NULL);
|
||||
}
|
||||
|
||||
if (name != IP_NULL)
|
||||
{
|
||||
ipmip6ha_cmd_print_binding_fmt(name,
|
||||
ipmip6_ntop_InetAddress(proc, entry->mip6BindingCOAType, &entry->mip6BindingCOA),
|
||||
ipmip6ha_cli_node_get_ifname(node),
|
||||
proc->ntop.ntop_lla,
|
||||
ipmip6ha_cmd_binding_flags(flags, node));
|
||||
}
|
||||
}
|
||||
|
||||
IP_STATIC void
|
||||
ipmip6ha_cmd_delete_binding(Ipmip_proc_t *proc,
|
||||
Ipmip_cli_daemon_t *daemon,
|
||||
Ip_u32 num,
|
||||
struct Ipmip_attr *node,
|
||||
struct Ipmip6ha_cmd_op_val *ops)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(ops);
|
||||
IPMIP_UNUSED_PARAMETER(num);
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
|
||||
ipmip6ha_cli_node_delete(daemon, ipmip6ha_cli_node_get_handle(node));
|
||||
}
|
||||
|
||||
IP_STATIC void
|
||||
ipmip6ha_cmd_revoke_node_binding(Ipmip_proc_t *proc,
|
||||
Ipmip_cli_daemon_t *daemon,
|
||||
Ip_u32 num,
|
||||
struct Ipmip_attr *node,
|
||||
struct Ipmip6ha_cmd_op_val *ops)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(ops);
|
||||
IPMIP_UNUSED_PARAMETER(num);
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
|
||||
#ifdef IPMIP_USE_INET
|
||||
if (ops->cmd == IPMIP6HA_CMD_HA6_OP_REVOKE_NODE_INET)
|
||||
ipmip6ha_cli_node_revoke_inet(daemon, ipmip6ha_cli_node_get_handle(node), IPMIP6_MH_BRI_TRIGGER_ADMINISTRATIVE_REASON);
|
||||
else
|
||||
#endif
|
||||
ipmip6ha_cli_node_revoke(daemon, ipmip6ha_cli_node_get_handle(node), IPMIP6_MH_BRI_TRIGGER_ADMINISTRATIVE_REASON);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmipha_cmd_show_binding
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipmip6ha_cmd_show_binding(Ipmip_proc_t *proc,
|
||||
Ipmip_cli_daemon_t *daemon,
|
||||
Ip_u32 num,
|
||||
struct Ipmip_attr *node,
|
||||
struct Ipmip6ha_cmd_op_val *ops)
|
||||
{
|
||||
const struct Ip_in6_addr *addr;
|
||||
const char *nai;
|
||||
const Ipmip6_address_t *prefix;
|
||||
Ip_u32 sz;
|
||||
Ip_u32 i;
|
||||
#ifdef IPMIP_USE_INET
|
||||
const Ip_u32 *inet_hoa;
|
||||
const Ipmip6_inet_t *inet_prefix;
|
||||
#endif
|
||||
char flags[16];
|
||||
|
||||
const struct Ipmip6_mib_mip6NodeTrafficEntry *mip6NodeTrafficEntry = ipmip6ha_cli_node_get_mip6NodeTrafficEntry(node);
|
||||
const struct Ipmip6_mib_mip6BindingCacheEntry *mip6BindingCacheEntry = ipmip6ha_cli_node_get_mip6BindingCacheEntry(node);
|
||||
|
||||
IPMIP_UNUSED_PARAMETER(daemon);
|
||||
IPMIP_UNUSED_PARAMETER(ops);
|
||||
IPMIP_UNUSED_PARAMETER(num);
|
||||
/**/
|
||||
ipmip_util_hdrprintf(proc, 0, "BCE", IPMIP6HA_CMD_HDRSIZE, IP_LF);
|
||||
if ((addr = ipmip6ha_cli_node_get_hoa(node)) != IP_NULL)
|
||||
ipmip_util_hdrprintf(proc, 1, "HoA", IPMIP6HA_CMD_HDRSIZE, "%s"IP_LF, ipmip_ntop_inet6(proc, addr, IP_NULL));
|
||||
if ((nai = ipmip6ha_cli_node_get_nai(node)) != IP_NULL)
|
||||
ipmip_util_hdrprintf(proc, 1, "Mobile NAI", IPMIP6HA_CMD_HDRSIZE, "%s"IP_LF, nai);
|
||||
ipmip_util_hdrprintf(proc, 1, "CoA", IPMIP6HA_CMD_HDRSIZE, "%s"IP_LF, ipmip6_ntop_InetAddress(proc, IP_GET_32ON8(&mip6BindingCacheEntry->mip6BindingCOAType), &mip6BindingCacheEntry->mip6BindingCOA));
|
||||
|
||||
ipmip_util_hdrprintf(proc, 1, "Creation", IPMIP6HA_CMD_HDRSIZE, "%s"IP_LF, ipmip_ntop_tm(proc, ipmip_util_safe_time_t(&mip6BindingCacheEntry->mip6BindingTimeRegistered)));
|
||||
ipmip_util_hdrprintf(proc, 1, "Last updated", IPMIP6HA_CMD_HDRSIZE, "%s"IP_LF, ipmip_ntop_tm(proc, ipmip6ha_cli_node_get_updated(node)));
|
||||
ipmip_util_hdrprintf(proc, 1, "Interface", IPMIP6HA_CMD_HDRSIZE, "%s"IP_LF, ipmip6ha_cli_node_get_ifname(node));
|
||||
ipmip_util_hdrprintf(proc, 1, "Lifetime requested", IPMIP6HA_CMD_HDRSIZE, "%u"IP_LF, IP_GET_32ON8(&mip6BindingCacheEntry->mip6BindingTimeGranted));
|
||||
ipmip_util_hdrprintf(proc, 1, "Lifetime remaining", IPMIP6HA_CMD_HDRSIZE, "%u"IP_LF, IP_GET_32ON8(&mip6BindingCacheEntry->mip6BindingTimeRemaining));
|
||||
ipmip_util_hdrprintf(proc, 1, "Registration Flags", IPMIP6HA_CMD_HDRSIZE, "%s"IP_LF, ipmip6ha_cmd_binding_flags(flags, node));
|
||||
|
||||
if ((prefix = ipmip6ha_cli_node_get_home_prefix_list(node, &sz)) != IP_NULL)
|
||||
{
|
||||
for (i = 0; i < sz; i++)
|
||||
ipmip_util_hdrprintf(proc, 1, "Allocated Prefix", IPMIP6HA_CMD_HDRSIZE, "%s/%d"IP_LF, ipmip_ntop_inet6(proc, &prefix[i].prefix, IP_NULL), prefix[i].len);
|
||||
}
|
||||
|
||||
#ifdef IPMIP_USE_INET
|
||||
/* */
|
||||
if ((inet_hoa = ipmip6ha_cli_node_get_inet_home_address_list(node, &sz)) != 0)
|
||||
{
|
||||
for (i = 0; i < sz; i++)
|
||||
ipmip_util_hdrprintf(proc, 1, "DSMIPv6 HoA", IPMIP6HA_CMD_HDRSIZE, "%s"IP_LF, ipmip_ntop_inet(proc, IP_GET_32ON8(&inet_hoa[i])));
|
||||
}
|
||||
|
||||
if ((inet_prefix = ipmip6ha_cli_node_get_inet_home_prefix_list(node, &sz)) != IP_NULL)
|
||||
{
|
||||
for (i = 0; i < sz; i++)
|
||||
ipmip_util_hdrprintf(proc, 1, "DSMIPv6 Prefix", IPMIP6HA_CMD_HDRSIZE, "%s/%d"IP_LF, ipmip_ntop_inet(proc, IP_GET_32ON8(&inet_prefix[i].prefix)), inet_prefix[i].len);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**/
|
||||
ipmip_util_hdrprintf(proc, 1, "Sent Bytes", IPMIP6HA_CMD_HDRSIZE, "%lld"IP_LF, ipmip_util_safe_u64(&mip6NodeTrafficEntry->mip6HCNodeOutOctets));
|
||||
ipmip_util_hdrprintf(proc, 1, "Sent Packets", IPMIP6HA_CMD_HDRSIZE, "%lld"IP_LF, ipmip_util_safe_u64(&mip6NodeTrafficEntry->mip6HCNodeOutPkts));
|
||||
ipmip_util_hdrprintf(proc, 1, "Receive Bytes", IPMIP6HA_CMD_HDRSIZE, "%lld"IP_LF, ipmip_util_safe_u64(&mip6NodeTrafficEntry->mip6HCNodeInOctets));
|
||||
ipmip_util_hdrprintf(proc, 1, "Receive Packets", IPMIP6HA_CMD_HDRSIZE, "%lld"IP_LF, ipmip_util_safe_u64(&mip6NodeTrafficEntry->mip6HCNodeInPkts));
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmipha_cmd_show_binding
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipmip6ha_cmd_do_binding(Ipmip_proc_t *proc,
|
||||
Ipmip_cli_daemon_t *daemon,
|
||||
Ip_u32 num,
|
||||
Ip_u32 handle,
|
||||
void *opaque)
|
||||
{
|
||||
struct Ipmip6ha_cmd_op_val *ops = opaque;
|
||||
struct Ipmip_attr *node;
|
||||
Ipmip_cli_daemon_req_t breq;
|
||||
|
||||
ipmip_cli_daemon_request_init(&breq);
|
||||
if ((node = ipmip6ha_cli_node_get(daemon, &breq, handle)) != IP_NULL)
|
||||
{
|
||||
|
||||
switch (ops->cmd)
|
||||
{
|
||||
case IPMIP6HA_CMD_HA6_OP_LIST:
|
||||
ipmip6ha_cmd_print_binding(proc, daemon, num, node, ops);
|
||||
break;
|
||||
case IPMIP6HA_CMD_HA6_OP_SHOW:
|
||||
/* OK; Got the node; print it */
|
||||
ipmip6ha_cmd_show_binding(proc, daemon, num, node, ops);
|
||||
break;
|
||||
case IPMIP6HA_CMD_HA6_OP_DELETE:
|
||||
/* OK; Got the node; print it */
|
||||
ipmip6ha_cmd_delete_binding(proc, daemon, num, node, ops);
|
||||
break;
|
||||
case IPMIP6HA_CMD_HA6_OP_REVOKE_NODE_INET:
|
||||
case IPMIP6HA_CMD_HA6_OP_REVOKE_NODE:
|
||||
/* OK; Got the node; print it */
|
||||
ipmip6ha_cmd_revoke_node_binding(proc, daemon, num, node, ops);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**/
|
||||
ipmip_cli_daemon_request_release(&breq);
|
||||
}
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipnet_cmd_mn6
|
||||
*===========================================================================
|
||||
* Description: Print status and statistics for networks
|
||||
* Parameters: network - Network if one is specified, IP_NULL otherwise.
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL int ipmip6ha_cmd_ha6(int argc, char **argv);
|
||||
IP_GLOBAL int
|
||||
ipmip6ha_cmd_ha6(int argc, char **argv)
|
||||
{
|
||||
char *op;
|
||||
int op_val;
|
||||
int ret = -1;
|
||||
Ipmip_proc_t *proc = IP_NULL;
|
||||
Ipcom_getopt opt;
|
||||
int i;
|
||||
Ipmip_cli_daemon_t daemon;
|
||||
Ipmip_cli_daemon_req_t req;
|
||||
|
||||
/**/
|
||||
daemon.fd = IP_INVALID_SOCKET;
|
||||
|
||||
ipmip_cli_daemon_request_init(&req);
|
||||
|
||||
proc = ipmip_proc_alloc();
|
||||
if (proc == IP_NULL)
|
||||
{
|
||||
ipcom_printf("ha6: failed to create process context"IP_LF);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Get a connection to the home agent. */
|
||||
for (i = 0; i < 10; i++)
|
||||
{
|
||||
if (ipmip6ha_cli_connect(&daemon))
|
||||
break;
|
||||
ipcom_sleep(1);
|
||||
}
|
||||
|
||||
if (daemon.fd == IP_INVALID_SOCKET)
|
||||
{
|
||||
ipcom_printf("ha6: failed to connect to mobile node"IP_LF);
|
||||
ipmip_proc_destroy(proc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
ipmip6ha_cmd_ha6_print_usage(proc);
|
||||
goto exit_out;
|
||||
}
|
||||
|
||||
op = argv[1];
|
||||
op_val = ipcom_cmd_str_to_key(ipmip6ha_cmd_ha6_ops, op);
|
||||
|
||||
if (op_val == -1)
|
||||
{
|
||||
if (ipmip6_cli_shell_cmd(argc, argv, proc, &daemon) == -1)
|
||||
ipcom_printf("'%s' is an invalid operation"IP_LF, op);
|
||||
goto exit_out;
|
||||
}
|
||||
|
||||
ipcom_getopt_clear_r(&opt);
|
||||
|
||||
/* Specified network? */
|
||||
if (op_val == IPMIP6HA_CMD_HA6_OP_SHOW ||
|
||||
op_val == IPMIP6HA_CMD_HA6_OP_DELETE ||
|
||||
op_val == IPMIP6HA_CMD_HA6_OP_LIST)
|
||||
{
|
||||
struct Ipmip6ha_cmd_op_val opval;
|
||||
Ip_bool all = IP_FALSE;
|
||||
|
||||
/**/
|
||||
ipcom_memset(&opval, 0, sizeof(opval));
|
||||
|
||||
opval.cmd = op_val;
|
||||
|
||||
/* Time to retrieve data regarding this particular network */
|
||||
while ((i = ipcom_getopt_r(argc - 1, argv + 1, "av", &opt)) != -1)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 'v':
|
||||
opval.verbose = IP_TRUE;
|
||||
break;
|
||||
case 'a':
|
||||
all = IP_TRUE;
|
||||
break;
|
||||
default:
|
||||
ipcom_printf("invalid option '%c'"IP_LF, i);
|
||||
goto exit_out;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (op_val == IPMIP6HA_CMD_HA6_OP_LIST)
|
||||
ipmip6ha_cmd_print_binding_fmt("Home Address",
|
||||
"Care of Address",
|
||||
"Interface",
|
||||
"Lifetime",
|
||||
"Flags");
|
||||
if (all)
|
||||
{
|
||||
/**/
|
||||
if (ipmip6ha_cli_node_list(&daemon, &req, IP_NULL, IP_NULL, IP_NULL) == IPCOM_SUCCESS)
|
||||
ipmip6ha_cmd_foreach_binding(proc, &daemon, &req, ipmip6ha_cmd_do_binding, &opval);
|
||||
}
|
||||
else
|
||||
{
|
||||
struct Ip_in6_addr hoa;
|
||||
|
||||
if (argc <= opt.optind + 1)
|
||||
{
|
||||
ipcom_printf("ha6: no node identifiers specified"IP_LF);
|
||||
goto exit_out;
|
||||
}
|
||||
|
||||
for (i = opt.optind + 1; i < argc; i++)
|
||||
{
|
||||
char *cptr;
|
||||
Ip_u32 handle;
|
||||
|
||||
if ((handle = (Ip_u32)ipcom_strtoul(argv[i], &cptr, 0)) != 0 && *cptr == '\0')
|
||||
ipmip6ha_cmd_do_binding(proc, &daemon, 0, handle, &opval);
|
||||
else
|
||||
{
|
||||
int lret;
|
||||
if (ipcom_inet_pton(IP_AF_INET6, argv[i], &hoa) == 1)
|
||||
lret = ipmip6ha_cli_node_list(&daemon, &req, IP_NULL, &hoa, IP_NULL);
|
||||
else
|
||||
lret = ipmip6ha_cli_node_list(&daemon, &req, IP_NULL, IP_NULL, argv[i]);
|
||||
|
||||
if (lret == IPCOM_SUCCESS)
|
||||
ipmip6ha_cmd_foreach_binding(proc, &daemon, &req, ipmip6ha_cmd_do_binding, &opval);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Success */
|
||||
ret = 0;
|
||||
}
|
||||
else if (op_val == IPMIP6HA_CMD_HA6_OP_REVOKE)
|
||||
{
|
||||
struct Ipmip6ha_cmd_op_val opval;
|
||||
|
||||
ipcom_memset(&opval, 0, sizeof(opval));
|
||||
if (argc < 3)
|
||||
{
|
||||
ipmip6ha_cmd_ha6_print_usage(proc);
|
||||
goto exit_out;
|
||||
}
|
||||
|
||||
if (ipcom_strcasecmp(argv[2], "node") == 0)
|
||||
{
|
||||
Ip_bool all = IP_FALSE;
|
||||
opval.cmd = IPMIP6HA_CMD_HA6_OP_REVOKE_NODE;
|
||||
|
||||
/* Handle, NAI or HoA. May do DOMAIN as well */
|
||||
while ((i = ipcom_getopt_r(argc - 2, argv + 2, "a4", &opt)) != -1)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case '4':
|
||||
/**/
|
||||
#ifdef IPMIP_USE_INET
|
||||
opval.cmd = IPMIP6HA_CMD_HA6_OP_REVOKE_NODE_INET;
|
||||
#endif
|
||||
break;
|
||||
case 'a':
|
||||
all = IP_TRUE;
|
||||
break;
|
||||
default:
|
||||
ipcom_printf("invalid option '%c'"IP_LF, i);
|
||||
goto exit_out;
|
||||
}
|
||||
}
|
||||
|
||||
if (all)
|
||||
{
|
||||
/**/
|
||||
if (ipmip6ha_cli_node_list(&daemon, &req, IP_NULL, IP_NULL, IP_NULL) == IPCOM_SUCCESS)
|
||||
ipmip6ha_cmd_foreach_binding(proc, &daemon, &req, ipmip6ha_cmd_do_binding, &opval);
|
||||
}
|
||||
else
|
||||
{
|
||||
struct Ip_in6_addr hoa;
|
||||
|
||||
if (argc <= opt.optind + 1)
|
||||
{
|
||||
ipcom_printf("ha6: no node identifiers specified"IP_LF);
|
||||
goto exit_out;
|
||||
}
|
||||
|
||||
for (i = opt.optind + 1; i < argc; i++)
|
||||
{
|
||||
char *cptr;
|
||||
Ip_u32 handle;
|
||||
|
||||
if ((handle = (Ip_u32)ipcom_strtoul(argv[i], &cptr, 0)) != 0 && *cptr == '\0')
|
||||
ipmip6ha_cmd_do_binding(proc, &daemon, 0, handle, &opval);
|
||||
else
|
||||
{
|
||||
int lret;
|
||||
if (ipcom_inet_pton(IP_AF_INET6, argv[i], &hoa) == 1)
|
||||
lret = ipmip6ha_cli_node_list(&daemon, &req, IP_NULL, &hoa, IP_NULL);
|
||||
else
|
||||
lret = ipmip6ha_cli_node_list(&daemon, &req, IP_NULL, IP_NULL, argv[i]);
|
||||
|
||||
if (lret == IPCOM_SUCCESS)
|
||||
ipmip6ha_cmd_foreach_binding(proc, &daemon, &req, ipmip6ha_cmd_do_binding, &opval);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (ipcom_strcasecmp(argv[2], "mag") == 0)
|
||||
{
|
||||
struct Ip_in6_addr mag;
|
||||
const char *ifname = IP_NULL;
|
||||
const char *nai_match = IP_NULL;
|
||||
Ip_u8 reason = 0;
|
||||
|
||||
opval.cmd = IPMIP6HA_CMD_HA6_OP_REVOKE_MAG;
|
||||
|
||||
ipcom_memset(&mag, 0, sizeof(mag));
|
||||
|
||||
/* Handle, NAI or HoA. May do DOMAIN as well */
|
||||
while ((i = ipcom_getopt_r(argc - 2, argv + 2, "i:m:n:r:", &opt)) != -1)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 'm':
|
||||
/**/
|
||||
if (ipcom_inet_pton(IP_AF_INET6, opt.optarg, &mag) != 1)
|
||||
{
|
||||
ipcom_printf("ha6: invalid MAG inet6 address '%s'"IP_LF, opt.optarg);
|
||||
goto exit_out;
|
||||
}
|
||||
break;
|
||||
case 'i':
|
||||
ifname = opt.optarg;
|
||||
break;
|
||||
case 'n':
|
||||
nai_match = opt.optarg;
|
||||
break;
|
||||
case 'r':
|
||||
reason = (Ip_u8)ipcom_strtoul(opt.optarg, IP_NULL, 0);
|
||||
break;
|
||||
default:
|
||||
ipcom_printf("invalid option '%c'"IP_LF, i);
|
||||
goto exit_out;
|
||||
}
|
||||
}
|
||||
|
||||
if (reason == 0)
|
||||
reason = (Ip_u8)(nai_match? IPMIP6_MH_BRI_TRIGGER_REVOKING_NODE_LOCAL_POLICY : IPMIP6_MH_BRI_TRIGGER_PER_PEER_POLICY);
|
||||
|
||||
if (ipmip6ha_cli_mag_list(&daemon, &req) == IPCOM_SUCCESS)
|
||||
{
|
||||
Ipmip_attr_iter_t riter;
|
||||
struct Ipmip_attr *pattr;
|
||||
|
||||
ipmip_cli_daemon_iter_request_init(&req, &riter);
|
||||
while ((pattr = ipmip6ha_cli_mag_next(&riter)) != IP_NULL)
|
||||
{
|
||||
const char *m_ifname = ipmip6ha_cli_mag_get_ifname(pattr);
|
||||
const struct Ip_in6_addr *m_addr = ipmip6ha_cli_mag_get_addr_v6(pattr);
|
||||
|
||||
if (ifname && ipcom_strcmp(ifname, m_ifname) != 0)
|
||||
continue;
|
||||
|
||||
if (!IP_IN6_IS_ADDR_UNSPECIFIED(&mag) && !IP_IN6_ARE_ADDR_EQUAL(&mag, m_addr))
|
||||
continue;
|
||||
|
||||
/* Revoke me */
|
||||
ipmip6ha_cli_mag_revoke(&daemon, m_ifname, m_addr, reason, nai_match);
|
||||
}
|
||||
}
|
||||
|
||||
/**/
|
||||
}
|
||||
else
|
||||
{
|
||||
ipmip6ha_cmd_ha6_print_usage(proc);
|
||||
goto exit_out;
|
||||
}
|
||||
|
||||
/* Success */
|
||||
ret = 0;
|
||||
}
|
||||
else if (op_val == IPMIP6HA_CMD_HA6_OP_PREFIX)
|
||||
{
|
||||
if (ipmip6ha_cli_prefix_list(&daemon, &req) == IPCOM_SUCCESS)
|
||||
{
|
||||
Ipmip_attr_iter_t riter;
|
||||
struct Ipmip_attr *pattr;
|
||||
|
||||
ipmip_cli_daemon_iter_request_init(&req, &riter);
|
||||
while ((pattr = ipmip6ha_cli_prefix_next(&riter)) != IP_NULL)
|
||||
{
|
||||
const char *ifname = ipmip6ha_cli_prefix_get_ifname(pattr);
|
||||
const struct Ip_in6_addr *router = ipmip6ha_cli_prefix_get_router(pattr);
|
||||
const Ipmip6_address_t *prefix = ipmip6ha_cli_prefix_get_prefix(pattr);
|
||||
Ip_time_t timestamp = ipmip6ha_cli_prefix_get_prefix_timestamp(pattr);
|
||||
Ip_time_t valid = ipmip6ha_cli_prefix_get_prefix_valid(pattr);
|
||||
Ip_time_t now = ipmip_util_time();
|
||||
|
||||
now -= timestamp;
|
||||
valid -= now;
|
||||
|
||||
if (ifname && router && prefix)
|
||||
ipcom_printf("%s - %s/%d@%s - %ld sec"IP_LF,
|
||||
ifname,
|
||||
ipmip_ntop_inet6(proc, &prefix->prefix, IP_NULL),
|
||||
prefix->len,
|
||||
ipmip_ntop_inet6(proc, router, IP_NULL),
|
||||
valid);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (op_val == IPMIP6HA_CMD_HA6_OP_MAG)
|
||||
{
|
||||
if (ipmip6ha_cli_mag_list(&daemon, &req) == IPCOM_SUCCESS)
|
||||
{
|
||||
Ipmip_attr_iter_t riter;
|
||||
struct Ipmip_attr *pattr;
|
||||
|
||||
ipmip_cli_daemon_iter_request_init(&req, &riter);
|
||||
while ((pattr = ipmip6ha_cli_mag_next(&riter)) != IP_NULL)
|
||||
{
|
||||
const char *ifname = ipmip6ha_cli_mag_get_ifname(pattr);
|
||||
const struct Ip_in6_addr *addr = ipmip6ha_cli_mag_get_addr_v6(pattr);
|
||||
Ip_u32 hb = ipmip6ha_cli_mag_get_heartbeat(pattr);
|
||||
Ip_u32 refcnt = ipmip6ha_cli_mag_get_references(pattr);
|
||||
#ifdef IPMIP_USE_INET
|
||||
Ip_u32 v4 = ipmip6ha_cli_mag_get_addr_v4(pattr);
|
||||
#else
|
||||
Ip_u32 v4 = 0;
|
||||
#endif
|
||||
|
||||
ipcom_printf("MAG %s%s%s@%s"IP_LF,
|
||||
ipmip_ntop_inet6(proc, addr, IP_NULL),
|
||||
v4? "/" : "",
|
||||
v4? ipmip_ntop_inet(proc, v4) : "",
|
||||
ifname);
|
||||
ipcom_printf(" HeartBeat : %s"IP_LF, hb? "enabled" : "disabled");
|
||||
ipcom_printf(" References: %d"IP_LF, refcnt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exit_out:
|
||||
ipmip_cli_daemon_disconnect(&daemon);
|
||||
ipmip_cli_daemon_request_release(&req);
|
||||
|
||||
if (proc)
|
||||
ipmip_proc_destroy(proc);
|
||||
|
||||
/* No go */
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,251 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip6ha_h.h,v $ $Revision: 1.15 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip6ha/src/ipmip6ha_h.h,v $
|
||||
* $Author: jhorteli $ $Date: 2009-03-31 15:00:32 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMIP6HA_H_H
|
||||
#define IPMIP6HA_H_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#include <ipcom_route.h>
|
||||
#include <ipcom_hash.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
struct Ipmip6ha_nemo_pool;
|
||||
struct Ipmip6ha_context;
|
||||
struct Ipmip6ha_pktbuf;
|
||||
struct Ipmip_proc;
|
||||
struct Ipmip6ha_if;
|
||||
struct Ipmip_cli_message;
|
||||
struct Ipmip6ha_node;
|
||||
struct Ipmip_timer;
|
||||
struct Ipmip6ha_nemo_context;
|
||||
struct Ipmip_buffer;
|
||||
struct Ipmip_context_id;
|
||||
|
||||
typedef void (*Ipmip6ha_extension_config_global_t)
|
||||
(
|
||||
struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
int action,
|
||||
void *global_config,
|
||||
struct Ipmip_cli_message *request
|
||||
);
|
||||
|
||||
typedef void (*Ipmip6ha_extension_config_ifp_t)
|
||||
(
|
||||
struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
int action,
|
||||
struct Ipmip6ha_if *ifp,
|
||||
void *global_config,
|
||||
void *ifp_config,
|
||||
struct Ipmip_cli_message *request
|
||||
);
|
||||
|
||||
typedef int (*Ipmip6ha_extension_provide_t)
|
||||
(
|
||||
struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
int action,
|
||||
void *global_config,
|
||||
void *ifp_config,
|
||||
void *node_config,
|
||||
struct Ipmip6ha_node *node,
|
||||
struct Ipmip_timer *service
|
||||
);
|
||||
|
||||
typedef Ip_bool (*Ipmip6ha_extension_setup_t)
|
||||
(
|
||||
struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
int action,
|
||||
void *global_config,
|
||||
void *ifp_config,
|
||||
void *node_config,
|
||||
struct Ipmip6ha_node *node,
|
||||
struct Ipmip_cli_message *request
|
||||
);
|
||||
|
||||
typedef Ip_bool (*Ipmip6ha_extension_pkt_req_validate_t)
|
||||
(
|
||||
struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
void *global_config,
|
||||
void *ifp_config,
|
||||
void *node_config,
|
||||
struct Ipmip6ha_node *node,
|
||||
struct Ipmip6ha_pktbuf *pbuf,
|
||||
struct Ipmip_timer *service
|
||||
);
|
||||
|
||||
|
||||
typedef Ip_bool (*Ipmip6ha_extension_pkt_req_accept_t)
|
||||
(
|
||||
struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
void *global_config,
|
||||
void *ifp_config,
|
||||
void *node_config,
|
||||
struct Ipmip6ha_node *node,
|
||||
struct Ipmip6ha_pktbuf *pbuf,
|
||||
struct Ipmip_timer *service
|
||||
);
|
||||
|
||||
typedef void (*Ipmip6ha_extension_pkt_rep_apply_t)
|
||||
(
|
||||
struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
void *global_config,
|
||||
void *ifp_config,
|
||||
void *node_config,
|
||||
struct Ipmip6ha_node *node,
|
||||
struct Ipmip6ha_pktbuf *pbuf_reply,
|
||||
struct Ipmip6ha_pktbuf *pbuf_request
|
||||
);
|
||||
|
||||
|
||||
typedef struct Ipmip6ha_extension
|
||||
{
|
||||
const char *name;
|
||||
|
||||
Ip_u32 node_data_size;
|
||||
Ip_u32 ifp_data_size;
|
||||
Ip_u32 global_data_size;
|
||||
|
||||
/* Callbacks */
|
||||
Ipmip6ha_extension_config_ifp_t config_ifp;
|
||||
Ipmip6ha_extension_config_global_t config_global;
|
||||
Ipmip6ha_extension_provide_t provide;
|
||||
Ipmip6ha_extension_setup_t setup;
|
||||
|
||||
Ipmip6ha_extension_pkt_req_validate_t pkt_req_validate;
|
||||
Ipmip6ha_extension_pkt_req_accept_t pkt_req_accept;
|
||||
Ipmip6ha_extension_pkt_rep_apply_t pkt_rep_apply;
|
||||
|
||||
/* Set by PMIP */
|
||||
Ip_u32 type;
|
||||
} Ipmip6ha_extension_t;
|
||||
|
||||
typedef struct Ipmip6ha_context
|
||||
{
|
||||
Ipmip6_context_t ipmip6; /* Global context */
|
||||
|
||||
Ip_fd fd_ipd; /* ipd */
|
||||
|
||||
struct Ip_in6_addr link_local_prefix;
|
||||
|
||||
/* Mobile node specific information */
|
||||
|
||||
/* Current prefix lists */
|
||||
Ipcom_mutex prefixes_lock;
|
||||
Ipcom_route *prefixes;
|
||||
Ipcom_hash *relay_map;
|
||||
|
||||
struct Ipmip_context_id *idents;
|
||||
struct Ipmip_context_id *bri;
|
||||
|
||||
struct
|
||||
{
|
||||
Ip_u32 forward;
|
||||
Ip_u32 tunnel;
|
||||
} iftables;
|
||||
|
||||
/**/
|
||||
Ipcom_list ifs;
|
||||
Ipmip_timer_lock_t *ifs_lock;
|
||||
|
||||
/* NEMO */
|
||||
Ipcom_mutex nemo_lock;
|
||||
Ipcom_route *nemo_rtab;
|
||||
struct Ipmip6ha_nemo_context *nemo;
|
||||
|
||||
Ipmip6ha_extension_t *extensions[32];
|
||||
Ip_u32 extensions_num;
|
||||
|
||||
Ip_u32 extensions_P_mask;
|
||||
Ip_u32 extensions_H_mask;
|
||||
|
||||
Ip_u32 extensions_node_P_data;
|
||||
Ip_u32 extensions_node_H_data;
|
||||
|
||||
void *extdata[32];
|
||||
}
|
||||
Ipmip6ha_context_t;
|
||||
|
||||
typedef struct Ipmip6ha_relay_key
|
||||
{
|
||||
char *nai;
|
||||
Ip_size_t nai_len;
|
||||
|
||||
struct Ipmip6ha_if *ifp;
|
||||
} Ipmip6ha_relay_key_t;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_GLOBAL Ip_u32 ipmip6ha_context_register_extension(Ipmip6ha_context_t *ctx,
|
||||
Ipmip6ha_extension_t *srv,
|
||||
Ip_bool reg_H,
|
||||
Ip_bool reg_P);
|
||||
|
||||
IP_GLOBAL void ipmip6ha_dump_relay_map(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip_buffer *buffer);
|
||||
|
||||
IP_GLOBAL void ipmip6ha_main(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,402 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip6ha_icmp.c,v $ $Revision: 1.6 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip6ha/src/ipmip6ha_icmp.c,v $
|
||||
* $Author: jhorteli $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelis@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
#include "ipmip6ha_config.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_os.h>
|
||||
#include <ipcom_sock.h>
|
||||
#include <ipcom_sock6.h>
|
||||
#include <ipcom_inet.h>
|
||||
#include <ipcom_list.h>
|
||||
#include <ipcom_hash.h>
|
||||
#include <ipcom_syslog.h>
|
||||
|
||||
#include <ipmip.h>
|
||||
#include <private/ipmip_util.h>
|
||||
|
||||
|
||||
#include <ipmip6.h>
|
||||
#include <private/ipmip6_context.h>
|
||||
#include <private/ipmip6_if.h>
|
||||
#include <private/ipmip6_icmp.h>
|
||||
#include <private/ipmip6_icmp_pkt.h>
|
||||
#include <private/ipmip6_util.h>
|
||||
|
||||
#include "ipmip6ha_h.h"
|
||||
#include "ipmip6ha_icmp.h"
|
||||
#include "ipmip6ha_if.h"
|
||||
#include "ipmip6ha_pktbuf.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip6mn_icmp_homeagent_discovery
|
||||
*===========================================================================
|
||||
* Description: Sends a homeagent discovery request to the homeagent's anycast
|
||||
* address using the src prefix as sender address.
|
||||
* Parameters: instance - The mobile node instance
|
||||
* home - The home address.
|
||||
* src - The parameters to use as outbound source.
|
||||
* id - The mobile node configuration entry ID.
|
||||
* Returns: IP_TRUE if no network error occured
|
||||
*
|
||||
*/
|
||||
IP_STATIC Ip_bool
|
||||
ipmip6ha_icmp_homeagent_discovery_advertisement(Ipmip6ha_context_t *ctx,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmip6ha_if_t *ifp,
|
||||
Ip_bool mobile_router,
|
||||
struct Ip_in6_addr *src,
|
||||
Ip_u16 id)
|
||||
{
|
||||
Ipmip6ha_pktbuf_t *pkt;
|
||||
|
||||
/* Allocate the packet */
|
||||
pkt = (Ipmip6ha_pktbuf_t *)ipmip6_icmp_pkt_alloc(&ctx->ipmip6,
|
||||
proc,
|
||||
0,
|
||||
IPMIP6_ICMP6_HA_DISCOVERY_REPLY,
|
||||
0);
|
||||
|
||||
/* Successful allocation? */
|
||||
if (pkt != IP_NULL)
|
||||
{
|
||||
/* */
|
||||
Ipmip_timer_lock_t *lock;
|
||||
Ipmip6_if_router_t *router;
|
||||
int err;
|
||||
int cnt = 0;
|
||||
|
||||
/* Grab the payload */
|
||||
Ipmip6_pkt_icmp6_t *icmp = (Ipmip6_pkt_icmp6_t *) IPMIP_BUFFER_PTR(&pkt->ipmip6.ipmip.packet);
|
||||
|
||||
|
||||
/* Identifier */
|
||||
icmp->icmp6_dataun.icmp6_un_data16[0] = id;
|
||||
lock = ipmip_timer_lock_acquire(&ctx->ipmip6.ipmip, proc, ifp->ipmip6.iff_lock);
|
||||
if (mobile_router)
|
||||
{
|
||||
/* We have the address; do prefix matching */
|
||||
for (router = IPCOM_LIST_FIRST(&ifp->ipmip6.routers); router != IP_NULL; router = IPCOM_LIST_NEXT(&router->next))
|
||||
{
|
||||
if (IP_BIT_ISTRUE(router->ifr_type, (1 << IPMIP6_IF_RTR_HOMEAGENT)) && IP_BIT_ISTRUE(router->ifr_type, (1 << IPMIP6_IF_RTR_MOBILE)))
|
||||
{
|
||||
Ipmip6_if_prefix_t *gaddr = ipmip6_if_prefix_lookup_global(router);
|
||||
|
||||
if (gaddr)
|
||||
{
|
||||
ipmip_buffer_append(&pkt->ipmip6.ipmip.packet, &gaddr->prefix.prefix, sizeof(struct Ip_in6_addr));
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (cnt)
|
||||
{
|
||||
icmp = (Ipmip6_pkt_icmp6_t *) IPMIP_BUFFER_PTR(&pkt->ipmip6.ipmip.packet);
|
||||
icmp->icmp6_dataun.icmp6_un_data16[1] |= ip_ntohs(IPMIP6_DHAAD_MOBILE_ROUTER);
|
||||
}
|
||||
}
|
||||
|
||||
if (cnt == 0)
|
||||
{
|
||||
/* We have the address; do prefix matching */
|
||||
for (router = IPCOM_LIST_FIRST(&ifp->ipmip6.routers); router != IP_NULL; router = IPCOM_LIST_NEXT(&router->next))
|
||||
{
|
||||
if (IP_BIT_ISTRUE(router->ifr_type, (1 << IPMIP6_IF_RTR_HOMEAGENT)))
|
||||
{
|
||||
Ipmip6_if_prefix_t *gaddr = ipmip6_if_prefix_lookup_global(router);
|
||||
|
||||
if (gaddr)
|
||||
{
|
||||
ipmip_buffer_append(&pkt->ipmip6.ipmip.packet, &gaddr->prefix.prefix, sizeof(struct Ip_in6_addr));
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ipmip_timer_lock_release(&ctx->ipmip6.ipmip, proc, lock);
|
||||
|
||||
IPCOM_LOG2(INFO,
|
||||
"%s: Homeagent Discovery containing %d home agents sent",
|
||||
ctx->ipmip6.ipmip.name,
|
||||
cnt);
|
||||
|
||||
|
||||
/* Set the source address */
|
||||
ipmip6_pkt_pktinfo_opt_add(&pkt->ipmip6,
|
||||
&ifp->ifaddr.prefix,
|
||||
&ifp->ipmip6);
|
||||
|
||||
|
||||
/* Send */
|
||||
if ((err = ipmip6_pkt_send(&ctx->ipmip6, proc, ctx->ipmip6.pkt->fd_icmp_out, &pkt->ipmip6, src)) != 0)
|
||||
{
|
||||
IPCOM_LOG2(WARNING,
|
||||
"%s: Failed to send Homeagent Discovery = %d",
|
||||
ctx->ipmip6.ipmip.name,
|
||||
err);
|
||||
return IP_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* */
|
||||
return IP_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip6mn_icmp_mobile_prefix_solicitation
|
||||
*===========================================================================
|
||||
* Description: Sends a mobile prefix solicitation to the indicated homeagent.
|
||||
* Parameters: instance - Mpbile node instance
|
||||
* homeagent - The homeagent address.
|
||||
* coa - The CoA to use
|
||||
* home - The home address to use.
|
||||
* id - The mobile node configuration entry ID.
|
||||
* Returns: IP_TRUE if successful.
|
||||
*
|
||||
*/
|
||||
IP_STATIC Ip_bool
|
||||
ipmip6ha_icmp_mobile_prefix_advertisement(Ipmip6ha_context_t *ctx,
|
||||
Ipmip_proc_t *proc,
|
||||
struct Ipmip6ha_if *ifp,
|
||||
struct Ip_in6_addr *coa,
|
||||
struct Ip_in6_addr *hoa,
|
||||
Ip_u16 id)
|
||||
{
|
||||
Ipmip6ha_pktbuf_t *pkt;
|
||||
|
||||
/* Allocate the packet */
|
||||
pkt = (Ipmip6ha_pktbuf_t *)ipmip6_icmp_pkt_alloc(&ctx->ipmip6,
|
||||
proc,
|
||||
0,
|
||||
IPMIP6_ICMP6_PREFIX_ADVERT,
|
||||
0);
|
||||
|
||||
/* Successful allocation? */
|
||||
if (pkt != IP_NULL)
|
||||
{
|
||||
/* Grab the payload */
|
||||
int err;
|
||||
Ipmip6_pkt_icmp6_t *icmp = (Ipmip6_pkt_icmp6_t *) IPMIP_BUFFER_PTR(&pkt->ipmip6.ipmip.packet);
|
||||
|
||||
/* Identifier */
|
||||
icmp->icmp6_dataun.icmp6_un_data16[0] = id;
|
||||
|
||||
/* Set the source address */
|
||||
ipmip6_pkt_pktinfo_opt_add(&pkt->ipmip6,
|
||||
&ifp->ifaddr.prefix,
|
||||
&ifp->ipmip6);
|
||||
|
||||
|
||||
ipmip6_pkt_rthdr2_opt_add(&pkt->ipmip6, hoa);
|
||||
|
||||
|
||||
|
||||
|
||||
/* Need to add all routers & prefixes */
|
||||
{
|
||||
Ipmip_timer_lock_t *lock;
|
||||
Ipmip6_if_prefix_t *prefix;
|
||||
Ipmip6_if_router_t *router;
|
||||
Ipmip6ha_if_route_entry_t *se;
|
||||
|
||||
if (ifp->RelayBindings)
|
||||
{
|
||||
ipcom_mutex_lock(ctx->prefixes_lock);
|
||||
if (ipmip_route_lookup(ctx->prefixes, hoa, (Ipmip_route_t **)&se) != IPMIP_ROUTE_LOOKUP_MISS)
|
||||
ifp = se->ifp;
|
||||
ipcom_mutex_unlock(ctx->prefixes_lock);
|
||||
}
|
||||
|
||||
lock = ipmip_timer_lock_acquire(&ctx->ipmip6.ipmip, proc, ifp->ipmip6.iff_lock);
|
||||
|
||||
/* */
|
||||
/* We have the address; do prefix matching */
|
||||
for (router = IPCOM_LIST_FIRST(&ifp->ipmip6.routers); router != IP_NULL; router = IPCOM_LIST_NEXT(&router->next))
|
||||
{
|
||||
for (prefix = IPCOM_LIST_FIRST(&router->prefixes); prefix != IP_NULL; prefix = IPCOM_LIST_NEXT(&prefix->next))
|
||||
{
|
||||
/* Prefix */
|
||||
Ipmip6_pkt_nd_opt_prefix_info_t pinfo;
|
||||
|
||||
pinfo.nd_opt_pi_type = IPMIP6_ND_OPT_PREFIX_INFORMATION;
|
||||
pinfo.nd_opt_pi_len = 4;
|
||||
pinfo.nd_opt_pi_prefix_len = prefix->prefix.len;
|
||||
pinfo.nd_opt_pi_flags_reserved = prefix->flags;
|
||||
pinfo.nd_opt_pi_valid_time = ip_htonl(((Ip_u32)prefix->valid));
|
||||
pinfo.nd_opt_pi_preferred_time = ip_htonl(((Ip_u32)prefix->preferred));
|
||||
pinfo.nd_opt_pi_reserved2 = 0;
|
||||
ipcom_memcpy(&pinfo.nd_opt_pi_prefix, &prefix->prefix.prefix, sizeof(struct Ip_in6_addr));
|
||||
ipmip_buffer_append(&pkt->ipmip6.ipmip.packet, &pinfo, sizeof(pinfo));
|
||||
}
|
||||
}
|
||||
|
||||
ipmip_timer_lock_release(&ctx->ipmip6.ipmip, proc, lock);
|
||||
}
|
||||
|
||||
/* Send */
|
||||
if ((err = ipmip6_pkt_send(&ctx->ipmip6, proc, ctx->ipmip6.pkt->fd_icmp_out, &pkt->ipmip6, coa)) != 0)
|
||||
{
|
||||
IPCOM_LOG2(WARNING,
|
||||
"%s: Failed to send Mobile Prefix Advertisement = %d",
|
||||
ctx->ipmip6.ipmip.name,
|
||||
err);
|
||||
return IP_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return IP_TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip6mn_icmp_dispatch
|
||||
*===========================================================================
|
||||
* Description: Process an ICMP packet.
|
||||
* Parameters: context - The context.
|
||||
* icmp - The ICMP packet
|
||||
* icmp_len - The length of the ICMP packet.
|
||||
* pktinfo - Packet info.
|
||||
* src - The sender
|
||||
* salist - List of SA's processed
|
||||
* rthdr2 - Did this ICMP frame contain a RTHDR2.
|
||||
* Returns: IP_TRUE if successfully processed.
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ip_bool
|
||||
ipmip6ha_icmp_dispatch(Ipmip6ha_context_t *ctx,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmip6ha_pktbuf_t *pbuf)
|
||||
{
|
||||
Ipmip6_pkt_icmp6_t *icmp = IPMIP_BUFFER_PTR(&pbuf->ipmip6.ipmip.packet);
|
||||
|
||||
if ((pbuf->iff_home.priv = ipmip6ha_if_findbypktinfo(ctx, proc, pbuf->ipmip6.ipmip.srcinfo.dst)) == IP_NULL)
|
||||
goto done_out;
|
||||
|
||||
/* Just link */
|
||||
pbuf->iff_transport.priv = pbuf->iff_home.priv;
|
||||
|
||||
/* Determine what we've got */
|
||||
switch (icmp->icmp6_type)
|
||||
{
|
||||
case IPMIP6_ICMP6_PREFIX_SOLICIT:
|
||||
/* Sanity */
|
||||
if (pbuf->ipmip6.recvinfo.home != IP_NULL)
|
||||
ipmip6ha_icmp_mobile_prefix_advertisement(ctx,
|
||||
proc,
|
||||
pbuf->iff_home.priv,
|
||||
&pbuf->ipmip6.ipmip.srcinfo.src->sin6.sin6_addr,
|
||||
pbuf->ipmip6.recvinfo.home,
|
||||
icmp->icmp6_dataun.icmp6_un_data16[0]);
|
||||
break;
|
||||
case IPMIP6_ICMP6_HA_DISCOVERY_REQUEST:
|
||||
IPCOM_LOG2(DEBUG2,
|
||||
"%s: ICMP6 Home Agent Discovery Request received(%d)",
|
||||
ctx->ipmip6.ipmip.name,
|
||||
icmp->icmp6_dataun.icmp6_un_data16[0]);
|
||||
|
||||
/* Do reply */
|
||||
ipmip6ha_icmp_homeagent_discovery_advertisement(ctx,
|
||||
proc,
|
||||
pbuf->iff_home.priv,
|
||||
(icmp->icmp6_dataun.icmp6_un_data16[1] & ip_ntohs(IPMIP6_DHAAD_MOBILE_ROUTER)) != 0,
|
||||
&pbuf->ipmip6.ipmip.srcinfo.src->sin6.sin6_addr,
|
||||
icmp->icmp6_dataun.icmp6_un_data16[0]);
|
||||
break;
|
||||
default:
|
||||
return IP_FALSE;
|
||||
}
|
||||
|
||||
done_out:
|
||||
ipmip_pktbuf_free(&ctx->ipmip6.ipmip, proc, &pbuf->ipmip6.ipmip);
|
||||
return IP_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,91 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip6ha_icmp.h,v $ $Revision: 1.2 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip6ha/src/ipmip6ha_icmp.h,v $
|
||||
* $Author: jhorteli $ $Date: 2009-02-09 15:46:08 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMIP6HA_ICMP_H
|
||||
#define IPMIP6HA_ICMP_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
struct Ipmip6_address;
|
||||
struct Ipmip6ha_context;
|
||||
struct Ipmip_proc;
|
||||
struct Ipmip6ha_pktbuf;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip6ha_icmp_dispatch
|
||||
*===========================================================================
|
||||
* Description: Process an ICMP packet.
|
||||
* Parameters: context - The context.
|
||||
* icmp - The ICMP packet
|
||||
* icmp_len - The length of the ICMP packet.
|
||||
* pktinfo - Packet info.
|
||||
* src - The sender
|
||||
* salist - List of SA's processed
|
||||
* rthdr2 - Did this ICMP frame contain a RTHDR2.
|
||||
* Returns: IP_TRUE if successfully processed.
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ip_bool ipmip6ha_icmp_dispatch(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip6ha_pktbuf *pbuf);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,915 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip6ha_if.c,v $ $Revision: 1.27.10.1 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip6ha/src/ipmip6ha_if.c,v $
|
||||
* $Author: svc-cmnet $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelis@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip6ha_if.c,v $ $Revision: 1.27.10.1 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip6ha/src/ipmip6ha_if.c,v $
|
||||
* $Author: svc-cmnet $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelis@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
#include "ipmip6ha_config.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_os.h>
|
||||
#include <ipcom_sock.h>
|
||||
#include <ipcom_sock6.h>
|
||||
#include <ipcom_inet.h>
|
||||
#include <ipcom_list.h>
|
||||
#include <ipcom_hash.h>
|
||||
#include <ipcom_err.h>
|
||||
#include <ipcom_sysvar.h>
|
||||
#include <ipcom_syslog.h>
|
||||
#include <ipcom_shell.h>
|
||||
#include <ipcom_route.h>
|
||||
|
||||
#include <ipnet.h>
|
||||
#include <ipnet_policy_routing.h>
|
||||
|
||||
#include <ipmip.h>
|
||||
#include <private/ipmip_util.h>
|
||||
#include <private/ipmip_sysvar.h>
|
||||
#include <private/ipmip_dhcp.h>
|
||||
|
||||
#include <ipmip6.h>
|
||||
#include <private/ipmip6_context.h>
|
||||
#include <private/ipmip6_netlink.h>
|
||||
#include <private/ipmip6_if.h>
|
||||
#include <private/ipmip6_icmp.h>
|
||||
#include <private/ipmip6_util.h>
|
||||
|
||||
#include "ipmip6ha_h.h"
|
||||
#include "ipmip6ha_route.h"
|
||||
#include "ipmip6ha_attr_h.h"
|
||||
#include "ipmip6ha_if.h"
|
||||
#include "ipmip6ha_pktbuf.h"
|
||||
#include "ipmip6ha_mag.h"
|
||||
#include "ipmip6ha_node.h"
|
||||
#include "ipmip6ha_nemo.h"
|
||||
#include "ipmip6ha_nemo_dsmipv6.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
IP_STATIC void
|
||||
ipmip6ha_if_tunnel_cleanup(Ipmip6ha_context_t *ctx,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmip6ha_if_t *ife)
|
||||
{
|
||||
/* Delete the policy rule */
|
||||
ipmip_netlink_inX_rule(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
IP_AF_INET6,
|
||||
IP_RTM_DELRULE,
|
||||
ctx->iftables.forward,
|
||||
IPMIP6HA_ROUTE_PRIORITY_TUNNEL,
|
||||
ife->ipmip6.iff.ifindex,
|
||||
&ip_in6addr_any,
|
||||
0,
|
||||
&ip_in6addr_any,
|
||||
0,
|
||||
0,
|
||||
IP_FIB_RULE_FIND_SADDR);
|
||||
}
|
||||
|
||||
|
||||
IP_STATIC void
|
||||
ipmip6ha_if_cleanup(Ipmip6ha_context_t *ctx,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmip6ha_if_t *ife)
|
||||
{
|
||||
int i;
|
||||
unsigned int si;
|
||||
|
||||
ipmip6ha_node_if_destroy(ctx, proc, ife);
|
||||
|
||||
ipmip6ha_mag_unconfigure(ctx, proc, ife);
|
||||
|
||||
/**/
|
||||
for (si = 0; si < ctx->extensions_num; si++)
|
||||
{
|
||||
if (ctx->extensions[si]->config_ifp != IP_NULL)
|
||||
{
|
||||
if (ife->extdata[si])
|
||||
{
|
||||
(*ctx->extensions[si]->config_ifp) (ctx, proc, IPMIP_CALLBACK_CONFIG_FREE, ife, ctx->extdata[si], ife->extdata[si], IP_NULL);
|
||||
ipcom_free(ife->extdata[si]);
|
||||
ife->extdata[si] = IP_NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Join DHAAD */
|
||||
ipmip6_icmp_mc_anycast_address(&ctx->ipmip6, proc, IP_FALSE, &ife->ipmip6, &ife->ifaddr, 126);
|
||||
|
||||
/* Remove this configuration */
|
||||
ipmip6ha_nemo_unconfigure(ctx, proc, ife->nemo);
|
||||
|
||||
/* Do destroy any tunnels on this interface */
|
||||
for (i = 0; i < IPMIP_TUNNELTYPE_MAX + 1; i++)
|
||||
{
|
||||
if (ife->iftunnels[i] != IP_NULL)
|
||||
{
|
||||
ipmip_if_free(&ctx->ipmip6.ipmip, proc, &ife->iftunnels[i]->ipmip6.iff);
|
||||
ife->iftunnels[i] = IP_NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (ife->iftables.pending != IPCOM_ROUTE_TABLE_UNSPEC)
|
||||
{
|
||||
/* Delete the policy rule */
|
||||
ipmip_netlink_inX_rule(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
IP_AF_INET6,
|
||||
IP_RTM_DELRULE,
|
||||
ife->iftables.pending,
|
||||
IPMIP6HA_ROUTE_PRIORITY_PENDING,
|
||||
0,
|
||||
&ife->ifaddr.prefix,
|
||||
128,
|
||||
&ip_in6addr_any,
|
||||
0,
|
||||
0,
|
||||
0);
|
||||
|
||||
ipmip_util_route_table_free(&ctx->ipmip6.ipmip, proc, ife->iftables.pending);
|
||||
|
||||
}
|
||||
|
||||
if (ife->iftables.route_optimize != IPCOM_ROUTE_TABLE_UNSPEC)
|
||||
{
|
||||
/* Delete the policy rule */
|
||||
ipmip_netlink_inX_rule(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
IP_AF_INET6,
|
||||
IP_RTM_DELRULE,
|
||||
ife->iftables.route_optimize,
|
||||
IPMIP6HA_ROUTE_PRIORITY_RO,
|
||||
0,
|
||||
&ife->ifaddr.prefix,
|
||||
128,
|
||||
&ip_in6addr_any,
|
||||
0,
|
||||
0,
|
||||
0);
|
||||
|
||||
ipmip_util_route_table_free(&ctx->ipmip6.ipmip, proc, ife->iftables.route_optimize);
|
||||
}
|
||||
|
||||
if (ife->iftables.tunnel != IPCOM_ROUTE_TABLE_UNSPEC)
|
||||
{
|
||||
#ifdef IPMIP_USE_INET
|
||||
ipmip_netlink_inX_rule(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
IP_AF_INET,
|
||||
IP_RTM_DELRULE,
|
||||
ife->iftables.tunnel,
|
||||
IPMIP6HA_ROUTE_PRIORITY_FORWARD,
|
||||
ife->ipmip6.iff.ifindex,
|
||||
&ip_inaddr_any,
|
||||
0,
|
||||
&ip_inaddr_any,
|
||||
0,
|
||||
0,
|
||||
0);
|
||||
|
||||
if (ife->ifaddr_v4)
|
||||
{
|
||||
ipmip_netlink_inX_rule(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
IP_AF_INET,
|
||||
IP_RTM_DELRULE,
|
||||
ife->iftables.tunnel,
|
||||
IPMIP6HA_ROUTE_PRIORITY_FORWARD,
|
||||
0,
|
||||
&ife->ifaddr_v4,
|
||||
32,
|
||||
&ip_inaddr_any,
|
||||
0,
|
||||
0,
|
||||
0);
|
||||
}
|
||||
|
||||
#endif
|
||||
ipmip_netlink_inX_rule(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
IP_AF_INET6,
|
||||
IP_RTM_DELRULE,
|
||||
ife->iftables.tunnel,
|
||||
IPMIP6HA_ROUTE_PRIORITY_FORWARD,
|
||||
ife->ipmip6.iff.ifindex,
|
||||
&ip_in6addr_any,
|
||||
0,
|
||||
&ip_in6addr_any,
|
||||
0,
|
||||
0,
|
||||
0);
|
||||
ipmip_util_route_table_free(&ctx->ipmip6.ipmip, proc, ife->iftables.tunnel);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip6mn_route_tunnel_create
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC Ipmip6ha_if_t *
|
||||
ipmip6ha_if_tunnel_create(Ipmip6ha_context_t *ctx,
|
||||
Ipmip_proc_t *proc,
|
||||
int type,
|
||||
Ip_u8 family,
|
||||
void *addr,
|
||||
Ip_u8 addr_len,
|
||||
Ip_u32 ifindex)
|
||||
{
|
||||
Ipmip6ha_if_t *ifp = IP_NULL;
|
||||
char tname[IP_IFNAMSIZ];
|
||||
struct Ip_ip_tunnel_param tun;
|
||||
int ret;
|
||||
|
||||
ipcom_snprintf(tname, sizeof(tname), "%s%dha%x", ipmip_util_tunnel_to_bsdname((Ip_u8)type), type, ifindex);
|
||||
if (ipcom_if_nametoindex(tname) != 0)
|
||||
return IP_NULL;
|
||||
|
||||
ifp = (Ipmip6ha_if_t *)ipmip6_if_alloc_tunnel(&ctx->ipmip6,
|
||||
proc,
|
||||
sizeof(*ifp),
|
||||
tname,
|
||||
0,
|
||||
(Ip_u8)type,
|
||||
IP_FALSE,
|
||||
(Ipmip_if_cleanup_t)ipmip6ha_if_tunnel_cleanup);
|
||||
if (ifp == IP_NULL)
|
||||
return IP_NULL;
|
||||
|
||||
/**/
|
||||
IPMIP6_EVENT_IF(INFO, proc,
|
||||
ipmip_log_event_add(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
"%s created",
|
||||
tname));
|
||||
|
||||
/**/
|
||||
#ifdef IPMIP_USE_INET
|
||||
if (family == IP_AF_INET)
|
||||
ifp->ifaddr_v4 = IP_GET_32ON8(addr);
|
||||
else
|
||||
#endif
|
||||
ipcom_memcpy(&ifp->ifaddr.prefix, addr, sizeof(struct Ip_in6_addr));
|
||||
|
||||
/* Assign the home address */
|
||||
if (ipmip_netlink_inX_addr(&ctx->ipmip6.ipmip, proc, family, IP_RTM_NEWADDR, ifp->ipmip6.iff.ifindex, addr, addr_len, 0, 0) < 0)
|
||||
{
|
||||
IPCOM_LOG2(ERR,
|
||||
"%s: ipcom_socketioctl(IP_SIOCADDROUTETAB) failed, errno = %d",
|
||||
ctx->ipmip6.ipmip.name,
|
||||
ipcom_errno);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* Add the policy rule */
|
||||
ipmip_netlink_inX_rule(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
IP_AF_INET6,
|
||||
IP_RTM_NEWRULE,
|
||||
ctx->iftables.forward,
|
||||
IPMIP6HA_ROUTE_PRIORITY_TUNNEL,
|
||||
ifp->ipmip6.iff.ifindex,
|
||||
&ip_in6addr_any,
|
||||
0,
|
||||
&ip_in6addr_any,
|
||||
0,
|
||||
0,
|
||||
IP_FIB_RULE_FIND_SADDR);
|
||||
|
||||
/* Change tunnel */
|
||||
ipcom_memset(&tun, 0, sizeof(tun));
|
||||
ipcom_strncpy(tun.ifr_name, ifp->ipmip6.iff.ifname, sizeof(tun.ifr_name));
|
||||
|
||||
/* Set values */
|
||||
#ifdef IPMIP_USE_INET
|
||||
if (family == IP_AF_INET)
|
||||
{
|
||||
tun.local_addr.sin.sin_family = IP_AF_INET;
|
||||
tun.local_addr.sin.sin_addr.s_addr = IP_GET_32ON8(addr);
|
||||
IPCOM_SA_LEN_SET(&tun.local_addr.sin, sizeof(struct Ip_sockaddr_in));
|
||||
tun.local_addr.sin.sin_port = ctx->ipmip6.pkt->s_udp_nat.sin6_port;
|
||||
|
||||
tun.remote_addr.sin.sin_family = IP_AF_INET;
|
||||
tun.remote_addr.sin.sin_addr.s_addr = IP_INADDR_ANY;
|
||||
IPCOM_SA_LEN_SET(&tun.remote_addr.sin, sizeof(struct Ip_sockaddr_in));
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
tun.local_addr.sin6.sin6_family = IP_AF_INET6;
|
||||
tun.local_addr.sin6.sin6_addr = ifp->ifaddr.prefix;
|
||||
IPCOM_SA_LEN_SET(&tun.local_addr.sin6, sizeof(struct Ip_sockaddr_in6));
|
||||
tun.local_addr.sin6.sin6_port = ctx->ipmip6.pkt->s_udp_nat.sin6_port;
|
||||
|
||||
tun.remote_addr.sin6.sin6_family = IP_AF_INET6;
|
||||
tun.remote_addr.sin6.sin6_addr = ip_in6addr_any;
|
||||
IPCOM_SA_LEN_SET(&tun.remote_addr.sin6, sizeof(struct Ip_sockaddr_in6));
|
||||
tun.remote_addr.sin6.sin6_scope_id = 3;
|
||||
}
|
||||
tun.ttl = 64;
|
||||
|
||||
/* Try set the tunnel values */
|
||||
if (ipmip_util_ioctl(&ctx->ipmip6.ipmip, proc, IP_SIOCCHGTUNNEL, &tun) < 0)
|
||||
{
|
||||
IPCOM_LOG4(ERR,
|
||||
"%s: ipcom_socketioctl(%s, IP_SIOCCHGTUNNEL) failed: %s [%d]",
|
||||
ctx->ipmip6.ipmip.name,
|
||||
tname,
|
||||
ipcom_strerror(ipcom_errno),
|
||||
ipcom_errno);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* GO HUGE on MTU */
|
||||
if ((ret = ipmip_netlink_link(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
IP_RTM_SETLINK,
|
||||
ifp->ipmip6.iff.ifindex,
|
||||
0,
|
||||
0,
|
||||
IP_NULL,
|
||||
IP_NULL,
|
||||
0xFFFF) < 0))
|
||||
{
|
||||
IPCOM_LOG3(ERR,
|
||||
"%s: Unable to set large MTU on %s, ret = %d",
|
||||
ctx->ipmip6.ipmip.name,
|
||||
tname,
|
||||
-ret);
|
||||
}
|
||||
|
||||
/**/
|
||||
return ifp;
|
||||
|
||||
fail:
|
||||
ipmip_if_free(&ctx->ipmip6.ipmip, proc, &ifp->ipmip6.iff);
|
||||
return IP_NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
IP_STATIC Ip_bool
|
||||
ipmip6ha_if_setup(Ipmip6ha_context_t *ctx,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmip6ha_if_t *ife)
|
||||
{
|
||||
unsigned int si;
|
||||
char initfmt[IP_IFNAMSIZ + 1 + 20];
|
||||
|
||||
/**/
|
||||
IPMIP6_EVENT_IF(INFO, proc,
|
||||
ipmip_log_event_add(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
"%s created",
|
||||
ife->ipmip6.iff.ifname));
|
||||
|
||||
ipmip6ha_node_if_init(ctx, proc, ife);
|
||||
|
||||
/* Read some base values */
|
||||
ife->lifetime = ipmip_sysvar_ushort(ipmip_sysvar_ushort(0, "ipmip6ha.lifetime"), "ipmip6ha.interface.%s.lifetime", ife->ipmip6.iff.ifname);
|
||||
ife->refresh = ipmip_sysvar_ushort(ipmip_sysvar_ushort(0, "ipmip6ha.refresh"), "ipmip6ha.interface.%s.refresh", ife->ipmip6.iff.ifname);
|
||||
ife->AlwaysVerifyTunnelSrc = ipmip_sysvar_bool(ipmip_sysvar_bool(IP_FALSE, "ipmip6ha.AlwaysVerifyTunnelSrc"), "ipmip6ha.interface.%s.AlwaysVerifyTunnelSrc", ife->ipmip6.iff.ifname);
|
||||
ife->RelayBindings = ipmip_sysvar_bool(ipmip_sysvar_bool(IP_FALSE, "ipmip6ha.RelayBindings"), "ipmip6ha.interface.%s.RelayBindings", ife->ipmip6.iff.ifname);
|
||||
ife->BindingRevocationEnabled = ipmip_sysvar_bool(ipmip_sysvar_bool(IP_TRUE, "ipmip6ha.LMA.BindingRevocation"), "ipmip6ha.interface.%s.LMA.BindingRevocation", ife->ipmip6.iff.ifname);
|
||||
|
||||
if (ife->refresh >= 100)
|
||||
ife->refresh = 0;
|
||||
|
||||
ife->BRIMaxRetriesNumber = ipmip_sysvar_u32(ipmip_sysvar_u32(1, "ipmip6ha.BRIMaxRetriesNumber"), "ipmip6ha.interface.%s.BRIMaxRetriesNumber", ife->ipmip6.iff.ifname);
|
||||
ife->MINDelayBRIs = ipmip_sysvar_u32(ipmip_sysvar_u32(1000, "ipmip6ha.MINDelayBRIs"), "ipmip6ha.interface.%s.MINDelayBRIs", ife->ipmip6.iff.ifname);
|
||||
|
||||
ife->MinDelayBeforeBCEDelete = ipmip_sysvar_u32(ipmip_sysvar_u32(10000, "ipmip6ha.LMA.MinDelayBeforeBCEDelete"), "ipmip6ha.interface.%s.LMA.MinDelayBeforeBCEDelete", ife->ipmip6.iff.ifname);
|
||||
ife->MaxDelayBeforeNewBCEAssign = ipmip_sysvar_u32(ipmip_sysvar_u32(1500, "ipmip6ha.LMA.MaxDelayBeforeNewBCEAssign"), "ipmip6ha.interface.%s.LMA.MaxDelayBeforeNewBCEAssign", ife->ipmip6.iff.ifname);
|
||||
ife->TimestampValidityWindow = ipmip_sysvar_u32(ipmip_sysvar_u32(300, "ipmip6ha.LMA.TimestampValidityWindow"), "ipmip6ha.interface.%s.LMA.TimestampValidityWindow", ife->ipmip6.iff.ifname);
|
||||
|
||||
/* Create a timeval structure */
|
||||
ife->TimestampValidityWindow_tv.tv_sec = (long) (ife->TimestampValidityWindow / 1000);
|
||||
ife->TimestampValidityWindow_tv.tv_usec = (long) ((ife->TimestampValidityWindow % 1000) * 1000);
|
||||
|
||||
ife->TimestampBasedApproachInUse = ipmip_sysvar_bool(ipmip_sysvar_bool(IP_TRUE, "ipmip6ha.LMA.TimestampBasedApproachInUse"), "ipmip6ha.interface.%s.LMA.TimestampBasedApproachInUse", ife->ipmip6.iff.ifname);
|
||||
if (ife->TimestampBasedApproachInUse)
|
||||
ife->MobileNodeGeneratedTimestampInUse = ipmip_sysvar_bool(ipmip_sysvar_bool(IP_FALSE, "ipmip6ha.LMA.MobileNodeGeneratedTimestampInUse"), "ipmip6ha.interface.%s.LMA.MobileNodeGeneratedTimestampInUse", ife->ipmip6.iff.ifname);
|
||||
|
||||
/* Read the prefix list allowed for this interface */
|
||||
if (!ipmip_sysvar_inet6(&ip_in6addr_any, &ife->FixedMAGLinkLocalAddressOnAllAccessLinks.prefix, &ife->FixedMAGLinkLocalAddressOnAllAccessLinks.len, "ipmip6ha.interface.%s.LMA.FixedMAGLinkLocalAddressOnAllAccessLinks", ife->ipmip6.iff.ifname))
|
||||
ipmip_sysvar_inet6(&ip_in6addr_any, &ife->FixedMAGLinkLocalAddressOnAllAccessLinks.prefix, &ife->FixedMAGLinkLocalAddressOnAllAccessLinks.len, "ipmip6ha.LMA.FixedMAGLinkLocalAddressOnAllAccessLinks");
|
||||
|
||||
/* Check if its unspecified */
|
||||
if (IP_IN6_IS_ADDR_UNSPECIFIED(&ife->FixedMAGLinkLocalAddressOnAllAccessLinks.prefix))
|
||||
ife->FixedMAGLinkLocalAddressOnAllAccessLinks_ALL_ZERO = IP_TRUE;
|
||||
|
||||
/* Read the prefix list allowed for this interface */
|
||||
if (!ipmip_sysvar_inet6(&ip_in6addr_any, &ife->ifaddr.prefix, &ife->ifaddr.len, "ipmip6ha.interface.%s.homeagent", ife->ipmip6.iff.ifname))
|
||||
{
|
||||
Ipmip6_if_inet6_t *ifaddr;
|
||||
|
||||
/* No address found; resolve from interface */
|
||||
for (ifaddr = IPCOM_LIST_FIRST(&ife->ipmip6.inet6); ifaddr != IP_NULL; ifaddr = IPCOM_LIST_NEXT(&ifaddr->ifa_next))
|
||||
{
|
||||
/* Only check UNIVERSE scope addresses; and addresses covered by a broadcasted prefix */
|
||||
if (ifaddr->ifa_scope == IP_RT_SCOPE_UNIVERSE)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!ifaddr)
|
||||
{
|
||||
IPMIP6_EVENT_IF(WARNING, proc,
|
||||
ipmip_log_event_add(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
"Unable to retrieve global IPv6 address on interface %s - configuration aborted",
|
||||
ife->ipmip6.iff.ifname));
|
||||
return IP_FALSE;
|
||||
}
|
||||
|
||||
ipcom_memcpy(&ife->ifaddr.prefix, &ifaddr->ifa_address.prefix, sizeof(ife->ifaddr.prefix));
|
||||
ife->ifaddr.len = ifaddr->ifa_address.len;
|
||||
}
|
||||
|
||||
#ifdef IPMIP_USE_INET
|
||||
/* Read the prefix list allowed for this interface */
|
||||
if (!ipmip_sysvar_inet(0, &ife->ifaddr_v4, IP_NULL, "ipmip6ha.interface.%s.inet.homeagent", ife->ipmip6.iff.ifname))
|
||||
{
|
||||
Ipmip6_if_inet_t *ifaddr;
|
||||
|
||||
/* No address found; resolve from interface */
|
||||
ifaddr = IPCOM_LIST_FIRST(&ife->ipmip6.inet);
|
||||
if (ifaddr)
|
||||
ife->ifaddr_v4 = ifaddr->ifa_address;
|
||||
}
|
||||
|
||||
ife->AcceptForcedIPv4UDPEncapsulationRequest = ipmip_sysvar_bool(ipmip_sysvar_bool(IP_FALSE, "ipmip6ha.inet.AcceptForcedIPv4UDPEncapsulationRequest"), "ipmip6ha.interface.%s.inet.AcceptForcedIPv4UDPEncapsulationRequest", ife->ipmip6.iff.ifname);
|
||||
ife->ForceIPv4UDPEncapsulation = ipmip_sysvar_bool(ipmip_sysvar_bool(IP_FALSE, "ipmip6ha.inet.ForceIPv4UDPEncapsulation"), "ipmip6ha.interface.%s.inet.ForceIPv4UDPEncapsulation", ife->ipmip6.iff.ifname);
|
||||
ife->IPv4UDPEncapsulationNATTimeout = ipmip_sysvar_u32(ipmip_sysvar_u32(IPMIP6_NATKATIMEOUT, "ipmip6ha.inet.IPv4UDPEncapsulationNATTimeout"), "ipmip6ha.interface.%s.inet.IPv4UDPEncapsulationNATTimeout", ife->ipmip6.iff.ifname);
|
||||
#endif
|
||||
/**/
|
||||
ife->AcceptUDPTLVEncapsulation = ipmip_sysvar_bool(ipmip_sysvar_bool(IP_TRUE, "ipmip6ha.AcceptUDPTLVEncapsulation"), "ipmip6ha.interface.%s.AcceptUDPTLVEncapsulation", ife->ipmip6.iff.ifname);
|
||||
|
||||
/* SETUP THE IFTABLES */
|
||||
ife->iftables.pending = ipmip_util_route_table_alloc(&ctx->ipmip6.ipmip, proc);
|
||||
|
||||
/* Add the policy rule */
|
||||
ipmip_netlink_inX_rule(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
IP_AF_INET6,
|
||||
IP_RTM_NEWRULE,
|
||||
ife->iftables.pending,
|
||||
IPMIP6HA_ROUTE_PRIORITY_PENDING,
|
||||
0,
|
||||
&ife->ifaddr.prefix,
|
||||
128,
|
||||
&ip_in6addr_any,
|
||||
0,
|
||||
0,
|
||||
0);
|
||||
|
||||
ife->iftables.route_optimize = ipmip_util_route_table_alloc(&ctx->ipmip6.ipmip, proc);
|
||||
|
||||
/* Add the policy rule */
|
||||
ipmip_netlink_inX_rule(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
IP_AF_INET6,
|
||||
IP_RTM_NEWRULE,
|
||||
ife->iftables.route_optimize,
|
||||
IPMIP6HA_ROUTE_PRIORITY_RO,
|
||||
0,
|
||||
&ife->ifaddr.prefix,
|
||||
128,
|
||||
&ip_in6addr_any,
|
||||
0,
|
||||
0,
|
||||
0);
|
||||
|
||||
ife->iftables.tunnel = ipmip_util_route_table_alloc(&ctx->ipmip6.ipmip, proc);
|
||||
|
||||
#ifdef IPMIP_USE_INET
|
||||
/* Add the policy rule */
|
||||
ipmip_netlink_inX_rule(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
IP_AF_INET,
|
||||
IP_RTM_NEWRULE,
|
||||
ife->iftables.tunnel,
|
||||
IPMIP6HA_ROUTE_PRIORITY_FORWARD,
|
||||
ife->ipmip6.iff.ifindex,
|
||||
&ip_inaddr_any,
|
||||
0,
|
||||
&ip_inaddr_any,
|
||||
0,
|
||||
0,
|
||||
0);
|
||||
|
||||
/* Add the policy rule */
|
||||
if (ife->ifaddr_v4)
|
||||
{
|
||||
ipmip_netlink_inX_rule(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
IP_AF_INET,
|
||||
IP_RTM_NEWRULE,
|
||||
ife->iftables.tunnel,
|
||||
IPMIP6HA_ROUTE_PRIORITY_FORWARD,
|
||||
0,
|
||||
&ife->ifaddr_v4,
|
||||
32,
|
||||
&ip_inaddr_any,
|
||||
0,
|
||||
0,
|
||||
0);
|
||||
}
|
||||
|
||||
#endif
|
||||
/* Add the policy rule */
|
||||
ipmip_netlink_inX_rule(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
IP_AF_INET6,
|
||||
IP_RTM_NEWRULE,
|
||||
ife->iftables.tunnel,
|
||||
IPMIP6HA_ROUTE_PRIORITY_FORWARD,
|
||||
ife->ipmip6.iff.ifindex,
|
||||
&ip_in6addr_any,
|
||||
0,
|
||||
&ip_in6addr_any,
|
||||
0,
|
||||
0,
|
||||
0);
|
||||
|
||||
|
||||
/* Join DHAAD */
|
||||
ipmip6_icmp_mc_anycast_address(&ctx->ipmip6, proc, IP_TRUE, &ife->ipmip6, &ife->ifaddr, 126);
|
||||
|
||||
#ifdef IPMIP_USE_INET
|
||||
if (ife->ifaddr_v4 != 0)
|
||||
{
|
||||
ife->ifenabled_P[IPMIP_TUNNELTYPE_GRE] = ipmip_sysvar_bool(ipmip_sysvar_bool(IP_TRUE, "ipmip6ha.LMA.inet.tunnel.gre"), "ipmip6ha.interface.%s.LMA.inet.tunnel.gre", ife->ipmip6.iff.ifname);
|
||||
ife->ifenabled_P[IPMIP_TUNNELTYPE_IPIP] = ipmip_sysvar_bool(ipmip_sysvar_bool(IP_TRUE, "ipmip6ha.LMA.inet.tunnel.ipip"), "ipmip6ha.interface.%s.LMA.inet.tunnel.ipip", ife->ipmip6.iff.ifname);
|
||||
ife->ifenabled_H[IPMIP_TUNNELTYPE_IPIP] = ipmip_sysvar_bool(ipmip_sysvar_bool(IP_TRUE, "ipmip6ha.inet.tunnel.ipip"), "ipmip6ha.interface.%s.inet.tunnel.ipip", ife->ipmip6.iff.ifname);
|
||||
|
||||
/* IPIP allowed */
|
||||
if (ife->ifenabled_P[IPMIP_TUNNELTYPE_GRE] || ife->ifenabled_P[IPMIP_TUNNELTYPE_IPIP] || ife->ifenabled_H[IPMIP_TUNNELTYPE_IPIP])
|
||||
ife->iftunnels[IPMIP_TUNNELTYPE_IPIP] = ipmip6ha_if_tunnel_create(ctx, proc, IPMIP_TUNNELTYPE_IPIP, IP_AF_INET, &ife->ifaddr_v4, 32, ife->ipmip6.iff.ifindex);
|
||||
|
||||
if (ife->ifenabled_P[IPMIP_TUNNELTYPE_GRE])
|
||||
ife->iftunnels[IPMIP_TUNNELTYPE_GRE] = ipmip6ha_if_tunnel_create(ctx, proc, IPMIP_TUNNELTYPE_GRE, IP_AF_INET, &ife->ifaddr_v4, 32, ife->ipmip6.iff.ifindex);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* GRE allowed? */
|
||||
ife->ifenabled_H[IPMIP_TUNNELTYPE_IP6IP6] = ipmip_sysvar_bool(ipmip_sysvar_bool(IP_TRUE, "ipmip6ha.tunnel.ip6ip6"), "ipmip6ha.interface.%s.tunnel.ip6ip6", ife->ipmip6.iff.ifname);
|
||||
ife->ifenabled_P[IPMIP_TUNNELTYPE_IP6IP6] = ipmip_sysvar_bool(ipmip_sysvar_bool(IP_TRUE, "ipmip6ha.LMA.tunnel.ip6ip6"), "ipmip6ha.interface.%s.LMA.tunnel.ip6ip6", ife->ipmip6.iff.ifname);
|
||||
ife->ifenabled_P[IPMIP_TUNNELTYPE_GRE6] = ipmip_sysvar_bool(ipmip_sysvar_bool(IP_TRUE, "ipmip6ha.LMA.tunnel.gre"), "ipmip6ha.interface.%s.LMA.tunnel.gre", ife->ipmip6.iff.ifname);
|
||||
|
||||
if (ife->ifenabled_H[IPMIP_TUNNELTYPE_IP6IP6] || ife->ifenabled_P[IPMIP_TUNNELTYPE_IP6IP6])
|
||||
ife->iftunnels[IPMIP_TUNNELTYPE_IP6IP6] = ipmip6ha_if_tunnel_create(ctx, proc, IPMIP_TUNNELTYPE_IP6IP6, IP_AF_INET6, &ife->ifaddr.prefix, 128, ife->ipmip6.iff.ifindex);
|
||||
|
||||
if (ife->ifenabled_P[IPMIP_TUNNELTYPE_GRE6])
|
||||
ife->iftunnels[IPMIP_TUNNELTYPE_GRE6] = ipmip6ha_if_tunnel_create(ctx, proc, IPMIP_TUNNELTYPE_GRE6, IP_AF_INET6, &ife->ifaddr.prefix, 128, ife->ipmip6.iff.ifindex);
|
||||
|
||||
/**/
|
||||
for (si = 0; si < ctx->extensions_num; si++)
|
||||
{
|
||||
if (ctx->extensions[si]->config_ifp != IP_NULL)
|
||||
{
|
||||
if (ctx->extensions[si]->ifp_data_size)
|
||||
{
|
||||
ife->extdata[si] = ipcom_calloc(1, ctx->extensions[si]->ifp_data_size);
|
||||
(*ctx->extensions[si]->config_ifp) (ctx, proc, IPMIP_CALLBACK_CONFIG_READ, ife, ctx->extdata[si], ife->extdata[si], IP_NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ipcom_snprintf(initfmt, sizeof(initfmt), "ipmip6ha.interface.%s", ife->ipmip6.iff.ifname);
|
||||
|
||||
ipmip6ha_nemo_configure(ctx, proc, &ife->nemo, ife->ipmip6.iff.ifname);
|
||||
|
||||
/**/
|
||||
ipmip6ha_mag_configure(ctx, proc, ife);
|
||||
return IP_TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip6mn_route_tunnel_create
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC Ip_bool
|
||||
ipmip6ha_if_create(Ipmip6ha_context_t *ctx,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmip6_if_notify_t *notify)
|
||||
{
|
||||
Ipmip_timer_lock_t *lock;
|
||||
|
||||
/* Attach to the IFP */
|
||||
ipmip6_if_attach(&ctx->ipmip6,
|
||||
proc,
|
||||
sizeof(struct Ipmip6ha_if),
|
||||
notify,
|
||||
(Ipmip_if_cleanup_t)ipmip6ha_if_cleanup);
|
||||
|
||||
lock = notify->ifp->iff_lock;
|
||||
|
||||
/**/
|
||||
if (!ipmip6ha_if_setup(ctx, proc, (Ipmip6ha_if_t*)notify->ifp))
|
||||
{
|
||||
ipmip6_if_detach_iflocked(&ctx->ipmip6, proc, notify);
|
||||
notify->ifp = IP_NULL;
|
||||
}
|
||||
|
||||
ipmip_timer_lock_release(&ctx->ipmip6.ipmip, proc, lock);
|
||||
return notify->ifp != IP_NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip6mn_event_handler
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipmip6ha_if_event_handler(int event,
|
||||
Ipmip6ha_context_t *ctx,
|
||||
Ipmip_proc_t *proc,
|
||||
void *ifn,
|
||||
void *unused)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(unused);
|
||||
IPMIP_UNUSED_PARAMETER(ctx);
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
IPMIP_UNUSED_PARAMETER(ifn);
|
||||
IPMIP_UNUSED_PARAMETER(unused);
|
||||
|
||||
|
||||
/* Event on this particular interface */
|
||||
if (event == IPMIP_TIMER_EVENT_RUN)
|
||||
{
|
||||
}
|
||||
|
||||
return IPMIP_TIMER_RET_DONE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip6mn_route_tunnel_create
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void
|
||||
ipmip6ha_if_unconfigure(Ipmip6ha_context_t *ctx,
|
||||
Ipmip_proc_t *proc)
|
||||
{
|
||||
Ipmip6ha_if_notify_t *notify;
|
||||
|
||||
/* Clear any old interfaces */
|
||||
while ((notify = IPCOM_LIST_FIRST(&ctx->ifs)) != IP_NULL)
|
||||
{
|
||||
Ipmip_timer_lock_t *lock;
|
||||
|
||||
lock = ipmip_timer_lock_acquire(&ctx->ipmip6.ipmip, proc, notify->ipmip6.ifp->iff_lock);
|
||||
ipmip6_if_detach_iflocked(&ctx->ipmip6, proc, ¬ify->ipmip6);
|
||||
ipmip_timer_lock_release(&ctx->ipmip6.ipmip, proc, lock);
|
||||
|
||||
ipcom_list_remove(¬ify->next);
|
||||
ipcom_free(notify);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip6mn_route_tunnel_create
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void
|
||||
ipmip6ha_if_configure(Ipmip6ha_context_t *ctx,
|
||||
Ipmip_proc_t *proc)
|
||||
{
|
||||
Ip_u8 *dptr, *ptr;
|
||||
|
||||
/* Find all interfaces */
|
||||
dptr = ipmip_sysvar_strlist("ipmip6ha.interfaces");
|
||||
if (dptr == IP_NULL || *dptr == 0)
|
||||
{
|
||||
IPCOM_LOG0(ERR, "ipmip6ha_if_configure() failed : invalid/missing \"ipmip6ha.interfaces\"");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
ptr = dptr + 1;
|
||||
while (*ptr != 0)
|
||||
{
|
||||
Ipmip6ha_if_notify_t *notify = ipcom_calloc(1, sizeof(*notify));
|
||||
|
||||
ipcom_strcpy(notify->ipmip6.ifname, (char *)(ptr + 1));
|
||||
|
||||
notify->ipmip6.opaque = notify;
|
||||
notify->ipmip6.func = (Ipmip_timer_func_t)ipmip6ha_if_event_handler;
|
||||
notify->ipmip6.lock = ctx->ifs_lock;
|
||||
|
||||
if (!ipmip6ha_if_create(ctx, proc, ¬ify->ipmip6))
|
||||
{
|
||||
/* Just log for notifications sake */
|
||||
IPMIP6_EVENT_IF(WARNING, proc,
|
||||
ipmip_log_event_add(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
"unable to configure interface \"%s\"",
|
||||
(char *)(ptr + 1)));
|
||||
ipcom_free(notify);
|
||||
}
|
||||
else
|
||||
{
|
||||
/**/
|
||||
ipcom_list_insert_last(&ctx->ifs, ¬ify->next);
|
||||
}
|
||||
|
||||
/* Go to next item */
|
||||
ptr += *ptr;
|
||||
}
|
||||
|
||||
fail:
|
||||
if (dptr)
|
||||
ipcom_free(dptr);
|
||||
}
|
||||
|
||||
|
||||
IP_GLOBAL Ipmip6ha_if_t *
|
||||
ipmip6ha_if_findbypktinfo(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip_pktbuf_pktinfo *dst)
|
||||
{
|
||||
Ipmip6ha_if_notify_t *notify;
|
||||
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
|
||||
for (notify = IPCOM_LIST_FIRST(&ctx->ifs); notify != IP_NULL; notify = IPCOM_LIST_NEXT(¬ify->next))
|
||||
{
|
||||
Ipmip6ha_if_t *ifp = (Ipmip6ha_if_t *)notify->ipmip6.ifp;
|
||||
if (ifp->ipmip6.iff.ifindex == dst->ifindex)
|
||||
return ifp;
|
||||
}
|
||||
|
||||
for (notify = IPCOM_LIST_FIRST(&ctx->ifs); notify != IP_NULL; notify = IPCOM_LIST_NEXT(¬ify->next))
|
||||
{
|
||||
Ipmip6ha_if_t *ifp = (Ipmip6ha_if_t *)notify->ipmip6.ifp;
|
||||
|
||||
if (IP_IN6_ARE_ADDR_EQUAL(&ifp->ifaddr.prefix, &dst->dst.sin6.sin6_addr))
|
||||
return ifp;
|
||||
}
|
||||
|
||||
return IP_NULL;
|
||||
}
|
||||
|
||||
IP_GLOBAL Ipmip6ha_if_t *
|
||||
ipmip6ha_if_findbyname(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
const char *name)
|
||||
{
|
||||
Ipmip6ha_if_notify_t *notify;
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
for (notify = IPCOM_LIST_FIRST(&ctx->ifs); notify != IP_NULL; notify = IPCOM_LIST_NEXT(¬ify->next))
|
||||
{
|
||||
Ipmip6ha_if_t *ifp = (Ipmip6ha_if_t *)notify->ipmip6.ifp;
|
||||
if (ipcom_strcasecmp(name, ifp->ipmip6.iff.ifname) == 0)
|
||||
return ifp;
|
||||
}
|
||||
|
||||
return IP_NULL;
|
||||
}
|
||||
|
||||
|
||||
IP_GLOBAL Ipmip6ha_if_t *
|
||||
ipmip6ha_if_findbyifindex(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ip_u32 ifindex)
|
||||
{
|
||||
Ipmip6ha_if_notify_t *notify;
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
for (notify = IPCOM_LIST_FIRST(&ctx->ifs); notify != IP_NULL; notify = IPCOM_LIST_NEXT(¬ify->next))
|
||||
{
|
||||
Ipmip6ha_if_t *ifp = (Ipmip6ha_if_t *)notify->ipmip6.ifp;
|
||||
if (ifindex == ifp->ipmip6.iff.ifindex)
|
||||
return ifp;
|
||||
}
|
||||
|
||||
return IP_NULL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,184 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip6ha_if.h,v $ $Revision: 1.15 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip6ha/src/ipmip6ha_if.h,v $
|
||||
* $Author: jhorteli $ $Date: 2009-12-02 15:33:16 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMIP6HA_IF_H
|
||||
#define IPMIP6HA_IF_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#include <private/ipmip_rtab.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
struct Ipmip6ha_context;
|
||||
struct Ipmip_proc;
|
||||
struct Ipmip6ha_node;
|
||||
struct Ipmip_pktbuf_pktinfo;
|
||||
struct Ipmip6ha_pktbuf;
|
||||
struct Ipmip6ha_nemo_context;
|
||||
|
||||
typedef struct Ipmip6ha_if_notify
|
||||
{
|
||||
Ipcom_list next;
|
||||
Ipmip6_if_notify_t ipmip6;
|
||||
} Ipmip6ha_if_notify_t;
|
||||
|
||||
typedef struct Ipmip6ha_if
|
||||
{
|
||||
Ipmip6_if_t ipmip6;
|
||||
|
||||
/* Home agent specific configuration */
|
||||
Ipmip6_address_t ifaddr;
|
||||
|
||||
#ifdef IPMIP_USE_INET
|
||||
Ip_u32 ifaddr_v4;
|
||||
Ip_bool AcceptForcedIPv4UDPEncapsulationRequest;
|
||||
Ip_bool ForceIPv4UDPEncapsulation;
|
||||
Ip_u32 IPv4UDPEncapsulationNATTimeout;
|
||||
#endif
|
||||
|
||||
Ip_bool AcceptUDPTLVEncapsulation;
|
||||
|
||||
/**/
|
||||
Ip_bool ifenabled_P[IPMIP_TUNNELTYPE_MAX + 1];
|
||||
Ip_bool ifenabled_H[IPMIP_TUNNELTYPE_MAX + 1];
|
||||
struct Ipmip6ha_if *iftunnels[IPMIP_TUNNELTYPE_MAX + 1];
|
||||
|
||||
Ip_u16 lifetime;
|
||||
Ip_u16 refresh;
|
||||
Ip_u32 BRIMaxRetriesNumber;
|
||||
Ip_u32 MINDelayBRIs;
|
||||
Ip_u32 MinDelayBeforeBCEDelete;
|
||||
Ip_u32 MaxDelayBeforeNewBCEAssign;
|
||||
Ip_u32 TimestampValidityWindow;
|
||||
struct Ip_timeval TimestampValidityWindow_tv;
|
||||
Ip_bool TimestampBasedApproachInUse;
|
||||
Ip_bool MobileNodeGeneratedTimestampInUse;
|
||||
Ip_bool AlwaysVerifyTunnelSrc;
|
||||
Ip_bool FixedMAGLinkLocalAddressOnAllAccessLinks_ALL_ZERO;
|
||||
Ipmip6_address_t FixedMAGLinkLocalAddressOnAllAccessLinks;
|
||||
Ip_bool RelayBindings;
|
||||
Ip_u32 HeartBeatInterval;
|
||||
Ip_u32 HeartBeatMissAllowed;
|
||||
Ip_bool HeartBeatEnabled;
|
||||
Ip_bool BindingRevocationEnabled;
|
||||
|
||||
/* Contains the current MAG's */
|
||||
Ipcom_hash *mag_table;
|
||||
|
||||
struct Ipmip6ha_nemo_context *nemo;
|
||||
|
||||
Ipcom_hash *node_name;
|
||||
Ipcom_hash *node_addr;
|
||||
|
||||
struct
|
||||
{
|
||||
Ip_u32 pending;
|
||||
Ip_u32 route_optimize;
|
||||
Ip_u32 tunnel;
|
||||
Ip_u32 forward;
|
||||
} iftables;
|
||||
|
||||
/* */
|
||||
Ipcom_route *prefixes;
|
||||
|
||||
void *extdata[32];
|
||||
void *extensions[32];
|
||||
} Ipmip6ha_if_t;
|
||||
|
||||
|
||||
typedef struct Ipmip6ha_if_route_entry
|
||||
{
|
||||
Ipmip_route_t ipmip;
|
||||
|
||||
/* Key & Mask */
|
||||
struct Ip_in6_addr subnet;
|
||||
struct Ip_in6_addr mask;
|
||||
|
||||
Ip_u8 mask_len;
|
||||
|
||||
Ip_u32 refcnt;
|
||||
|
||||
/**/
|
||||
Ip_time_t valid;
|
||||
Ip_time_t timestamp;
|
||||
|
||||
Ipmip6ha_if_t *ifp;
|
||||
} Ipmip6ha_if_route_entry_t;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_GLOBAL void ipmip6ha_if_configure(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc);
|
||||
|
||||
IP_GLOBAL void ipmip6ha_if_unconfigure(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc);
|
||||
|
||||
IP_GLOBAL Ipmip6ha_if_t *ipmip6ha_if_findbypktinfo(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip_pktbuf_pktinfo *dst);
|
||||
|
||||
IP_GLOBAL Ipmip6ha_if_t *ipmip6ha_if_findbyname(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
const char *name);
|
||||
|
||||
IP_GLOBAL Ipmip6ha_if_t *ipmip6ha_if_findbyifindex(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ip_u32 ifindex);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,355 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip6ha_ifevent.c,v $ $Revision: 1.12 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip6ha/src/ipmip6ha_ifevent.c,v $
|
||||
* $Author: jhorteli $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelis@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
#include "ipmip6ha_config.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_os.h>
|
||||
#include <ipcom_sock.h>
|
||||
#include <ipcom_sock6.h>
|
||||
#include <ipcom_inet.h>
|
||||
#include <ipcom_list.h>
|
||||
#include <ipcom_hash.h>
|
||||
#include <ipcom_err.h>
|
||||
#include <ipcom_sysvar.h>
|
||||
#include <ipcom_syslog.h>
|
||||
#include <ipcom_shell.h>
|
||||
|
||||
#include <ipmip.h>
|
||||
#include <private/ipmip_timer.h>
|
||||
#include <private/ipmip_util.h>
|
||||
|
||||
#include <ipmip6.h>
|
||||
#include <private/ipmip6_if.h>
|
||||
#include <private/ipmip6_context.h>
|
||||
#include <private/ipmip6_netlink.h>
|
||||
#include <private/ipmip6_icmp_pkt.h>
|
||||
#include <private/ipmip6_util.h>
|
||||
|
||||
#include "ipmip6ha_h.h"
|
||||
#include "ipmip6ha_if.h"
|
||||
#include "ipmip6ha_attr_h.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
IP_STATIC void ipmip6ha_ifevent_router_new(Ipmip6ha_context_t *ctx,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmip6_if_t *ife,
|
||||
Ipmip6_if_router_t *router);
|
||||
IP_STATIC void ipmip6ha_ifevent_router_expire(Ipmip6_context_t *ctx,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmip6_if_t *ife,
|
||||
Ipmip6_if_router_t *router);
|
||||
IP_STATIC void ipmip6ha_ifevent_prefix_new(Ipmip6ha_context_t *ctx,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmip6ha_if_t *ife,
|
||||
Ipmip6_if_prefix_t *prefix);
|
||||
IP_STATIC void ipmip6ha_ifevent_prefix_expire(Ipmip6ha_context_t *ctx,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmip6ha_if_t *ife,
|
||||
Ipmip6_if_prefix_t *prefix);
|
||||
IP_STATIC void ipmip6ha_ifevent_prefix_advertise(Ipmip6_context_t *ctx,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmip6_if_t *ife,
|
||||
Ipmip6_if_prefix_t *prefix);
|
||||
IP_STATIC void ipmip6ha_ifevent_prefix_update(Ipmip6ha_context_t *ctx,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmip6ha_if_t *ife,
|
||||
Ipmip6_if_prefix_t *prefix);
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
Ipmip6_if_event_table_t ipmip6ha_ifevent_table =
|
||||
{
|
||||
(Ipmip6_if_event_t)IP_NULL,
|
||||
(Ipmip6_if_event_t)IP_NULL,
|
||||
(Ipmip6_if_event_t)ipmip6ha_ifevent_router_new,
|
||||
(Ipmip6_if_event_t)ipmip6ha_ifevent_router_expire,
|
||||
(Ipmip6_if_event_t)ipmip6ha_ifevent_prefix_new,
|
||||
(Ipmip6_if_event_t)ipmip6ha_ifevent_prefix_expire,
|
||||
(Ipmip6_if_event_t)ipmip6ha_ifevent_prefix_advertise,
|
||||
(Ipmip6_if_event_t)ipmip6ha_ifevent_prefix_update
|
||||
};
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipmip6ha_ifevent_router_new(Ipmip6ha_context_t *ctx,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmip6_if_t *ife,
|
||||
Ipmip6_if_router_t *router)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(ctx);
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
IPMIP_UNUSED_PARAMETER(ife);
|
||||
IPMIP_UNUSED_PARAMETER(router);
|
||||
}
|
||||
|
||||
|
||||
IP_STATIC void
|
||||
ipmip6ha_ifevent_router_expire(Ipmip6_context_t *ctx,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmip6_if_t *ife,
|
||||
Ipmip6_if_router_t *router)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(ctx);
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
IPMIP_UNUSED_PARAMETER(ife);
|
||||
IPMIP_UNUSED_PARAMETER(router);
|
||||
}
|
||||
|
||||
IP_STATIC void
|
||||
ipmip6ha_ifevent_prefix_new(Ipmip6ha_context_t *ctx,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmip6ha_if_t *ife,
|
||||
Ipmip6_if_prefix_t *prefix)
|
||||
{
|
||||
if (IP_BIT_ISSET(prefix->flags, IPMIP6_ND_OPT_PI_FLAG_ONLINK))
|
||||
{
|
||||
Ipmip6ha_if_route_entry_t *se;
|
||||
struct Ip_in6_addr lkey;
|
||||
|
||||
ipmip6_address_create_prefix(&lkey, &prefix->prefix.prefix, prefix->prefix.len);
|
||||
|
||||
|
||||
IPMIP_UNUSED_PARAMETER(ctx);
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
|
||||
ipcom_mutex_lock(ctx->prefixes_lock);
|
||||
|
||||
/* Found, already in the table */
|
||||
if ((se = (Ipmip6ha_if_route_entry_t *)ipmip_route_lookup_exact(ctx->prefixes, &lkey, prefix->prefix.len)) != IP_NULL)
|
||||
{
|
||||
if (se->ifp != ife)
|
||||
{
|
||||
IPMIP6_EVENT_IF(ERR, proc,
|
||||
ipmip_log_event_add(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
"On-link prefix %s/%d seen on both %s and %s -- may cause problems",
|
||||
ipmip_ntop_inet6(proc, &lkey, IP_NULL),
|
||||
se->ifp->ipmip6.iff.ifname,
|
||||
ife->ipmip6.iff.ifname));
|
||||
/* Switch to last seen */
|
||||
se->ifp = ife;
|
||||
}
|
||||
|
||||
se->refcnt++;
|
||||
}
|
||||
else
|
||||
{
|
||||
se = ipcom_calloc(1, sizeof(*se));
|
||||
if (se != IP_NULL)
|
||||
{
|
||||
ipmip_util_create_mask((Ip_u8 *)&se->mask, prefix->prefix.len);
|
||||
ipmip6_address_create_prefix(&se->subnet, &prefix->prefix.prefix, prefix->prefix.len);
|
||||
|
||||
se->mask_len = prefix->prefix.len;
|
||||
/* Create the entry */
|
||||
se->ipmip.hdr.key = &se->subnet;
|
||||
se->ipmip.hdr.mask = &se->mask;
|
||||
/**/
|
||||
se->refcnt = 1;
|
||||
|
||||
se->timestamp = prefix->stamp;
|
||||
se->valid = prefix->valid;
|
||||
|
||||
se->ifp = ife;
|
||||
|
||||
if (ipmip_route_add(ctx->prefixes, &se->ipmip) != IPCOM_SUCCESS)
|
||||
ipcom_free(se);
|
||||
}
|
||||
}
|
||||
ipcom_mutex_unlock(ctx->prefixes_lock);
|
||||
|
||||
IPMIP6_EVENT_IF(INFO, proc,
|
||||
ipmip_log_event_add(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
"Adding on-link prefix %s/%d@%s to configuration %s",
|
||||
ipmip_ntop_inet6(proc, &lkey, IP_NULL),
|
||||
prefix->prefix.len,
|
||||
ipmip_ntop_inet6(proc, &prefix->router->addr, IP_NULL),
|
||||
ife->ipmip6.iff.ifname));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
IP_STATIC void
|
||||
ipmip6ha_ifevent_prefix_expire(Ipmip6ha_context_t *ctx,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmip6ha_if_t *ife,
|
||||
Ipmip6_if_prefix_t *prefix)
|
||||
{
|
||||
Ipmip6ha_if_route_entry_t *se;
|
||||
|
||||
IPMIP_UNUSED_PARAMETER(ctx);
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
|
||||
if (IP_BIT_ISSET(prefix->flags, IPMIP6_ND_OPT_PI_FLAG_ONLINK))
|
||||
{
|
||||
struct Ip_in6_addr lkey;
|
||||
ipmip6_address_create_prefix(&lkey, &prefix->prefix.prefix, prefix->prefix.len);
|
||||
|
||||
ipcom_mutex_lock(ctx->prefixes_lock);
|
||||
/* Found, already in the table */
|
||||
if ((se = (Ipmip6ha_if_route_entry_t *)ipmip_route_lookup_exact(ctx->prefixes, &prefix->prefix.prefix, prefix->prefix.len)) != IP_NULL)
|
||||
{
|
||||
if (--se->refcnt == 0)
|
||||
ipmip_route_delete(ctx->prefixes, &se->ipmip);
|
||||
|
||||
IPMIP6_EVENT_IF(INFO, proc,
|
||||
ipmip_log_event_add(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
"Removing on-link prefix %s/%d@%s from configuration %s",
|
||||
ipmip_ntop_inet6(proc, &lkey, IP_NULL),
|
||||
prefix->prefix.len,
|
||||
ipmip_ntop_inet6(proc, &prefix->router->addr, IP_NULL),
|
||||
ife->ipmip6.iff.ifname));
|
||||
}
|
||||
ipcom_mutex_unlock(ctx->prefixes_lock);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
IP_STATIC void
|
||||
ipmip6ha_ifevent_prefix_advertise(Ipmip6_context_t *ctx,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmip6_if_t *ife,
|
||||
Ipmip6_if_prefix_t *prefix)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(ctx);
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
IPMIP_UNUSED_PARAMETER(ife);
|
||||
IPMIP_UNUSED_PARAMETER(prefix);
|
||||
/* ipmip6m_coa_advertise_prefix(prefix); */
|
||||
}
|
||||
|
||||
IP_STATIC void
|
||||
ipmip6ha_ifevent_prefix_update(Ipmip6ha_context_t *ctx,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmip6ha_if_t *ife,
|
||||
Ipmip6_if_prefix_t *prefix)
|
||||
{
|
||||
Ipmip6ha_if_route_entry_t *se;
|
||||
|
||||
IPMIP_UNUSED_PARAMETER(ctx);
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
|
||||
if (IP_BIT_ISSET(prefix->flags, IPMIP6_ND_OPT_PI_FLAG_ONLINK))
|
||||
{
|
||||
struct Ip_in6_addr lkey;
|
||||
ipmip6_address_create_prefix(&lkey, &prefix->prefix.prefix, prefix->prefix.len);
|
||||
|
||||
ipcom_mutex_lock(ctx->prefixes_lock);
|
||||
|
||||
/* Found, already in the table */
|
||||
if ((se = (Ipmip6ha_if_route_entry_t *)ipmip_route_lookup_exact(ctx->prefixes, &lkey, prefix->prefix.len)) != IP_NULL)
|
||||
{
|
||||
se->timestamp = prefix->stamp;
|
||||
se->valid = prefix->valid;
|
||||
|
||||
se->ifp = ife;
|
||||
|
||||
#if 0
|
||||
IPMIP6_EVENT_IF(DEBUG2, proc,
|
||||
ipmip_log_event_add(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
"Updating on-link prefix %s/%d@%s in configuration %s (%s - %d)",
|
||||
ipmip_ntop_inet6(proc, &lkey, IP_NULL),
|
||||
prefix->prefix.len,
|
||||
ipmip_ntop_inet6(proc, &prefix->router->addr, IP_NULL),
|
||||
ife->ipmip6.iff.ifname,
|
||||
ipmip_ntop_time(proc, se->timestamp)));
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
IPMIP6_EVENT_IF(INFO, proc,
|
||||
ipmip_log_event_add(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
"On-link prefix %s/%d@%s not found in configuration %s",
|
||||
ipmip_ntop_inet6(proc, &lkey, IP_NULL),
|
||||
prefix->prefix.len,
|
||||
ipmip_ntop_inet6(proc, &prefix->router->addr, IP_NULL),
|
||||
ife->ipmip6.iff.ifname));
|
||||
}
|
||||
|
||||
ipcom_mutex_unlock(ctx->prefixes_lock);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,69 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip6ha_ifevent.h,v $ $Revision: 1.1 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip6ha/src/ipmip6ha_ifevent.h,v $
|
||||
* $Author: jhorteli $ $Date: 2008-05-21 12:49:06 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMIP6HA_IFEVENT_H
|
||||
#define IPMIP6HA_IFEVENT_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
extern Ipmip6_if_event_table_t ipmip6ha_ifevent_table;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,160 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip6ha_mag.h,v $ $Revision: 1.4 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip6ha/src/ipmip6ha_mag.h,v $
|
||||
* $Author: jhorteli $ $Date: 2010-02-15 13:27:38 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMIP6HA_MAG_H
|
||||
#define IPMIP6HA_MAG_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPMIP6HA_MAG_CREATE (1 << 0)
|
||||
#define IPMIP6HA_MAG_PERMANENT (1 << 1)
|
||||
|
||||
|
||||
#define IPMIP6HA_MAG_HEARTBEAT_SEEN (1 << 0)
|
||||
#define IPMIP6HA_MAG_HEARTBEAT_DISABLED (1 << 1)
|
||||
#define IPMIP6HA_MAG_REVOCATION_SEEN (1 << 2)
|
||||
#define IPMIP6HA_MAG_REVOCATION_DISABLED (1 << 3)
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
struct Ipmip6ha_context;
|
||||
struct Ipmip_proc;
|
||||
struct Ipmip6ha_if;
|
||||
struct Ipmip6ha_pktbuf;
|
||||
struct Ipmip_buffer;
|
||||
union Ipmip6_mib_InetAddress;
|
||||
|
||||
typedef struct Ipmip6ha_mag
|
||||
{
|
||||
struct Ip_in6_addr endpoint;
|
||||
|
||||
Ipmip_timer_t timer;
|
||||
Ip_u32 sequence;
|
||||
Ip_u32 unacked;
|
||||
Ip_u32 restart_counter;
|
||||
Ip_bool have_restart_counter;
|
||||
|
||||
/**/
|
||||
Ip_u32 references;
|
||||
Ip_bool permanent;
|
||||
Ip_u32 flags;
|
||||
struct Ipmip6ha_if *ifp;
|
||||
|
||||
Ipcom_list bri;
|
||||
|
||||
/* If we've got a NAT */
|
||||
union Ipmip6_mib_InetAddress tunnel_endpoint;
|
||||
Ip_u32 tunnel_endpoint_type;
|
||||
|
||||
Ip_u16 port;
|
||||
} Ipmip6ha_mag_t;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_GLOBAL Ipmip6ha_mag_t *ipmip6ha_mag_get(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip6ha_if *ifp,
|
||||
struct Ip_in6_addr *endpoint,
|
||||
unsigned flags);
|
||||
|
||||
IP_GLOBAL void ipmip6ha_mag_release(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmip6ha_mag_t *mag);
|
||||
IP_GLOBAL void ipmip6ha_mag_reference(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmip6ha_mag_t *mag);
|
||||
|
||||
IP_GLOBAL void ipmip6ha_mag_set_tunnel(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmip6ha_mag_t *mag,
|
||||
union Ipmip6_mib_InetAddress *tunnel_endpoint,
|
||||
Ip_u32 tunnel_endpoint_type,
|
||||
Ip_u16 port);
|
||||
|
||||
IP_GLOBAL void ipmip6ha_mag_configure(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip6ha_if *ifp);
|
||||
IP_GLOBAL void ipmip6ha_mag_unconfigure(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip6ha_if *ifp);
|
||||
|
||||
IP_GLOBAL void ipmip6ha_mag_configure_dump(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip6ha_if *ife,
|
||||
struct Ipmip_buffer *buffer);
|
||||
|
||||
IP_GLOBAL Ip_bool ipmip6ha_mag_heartbeat_input(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip6ha_pktbuf *pbuf);
|
||||
IP_GLOBAL Ip_bool ipmip6ha_mag_binding_error_input(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip6ha_pktbuf *pbuf,
|
||||
Ipmip6ha_mag_t *mag);
|
||||
|
||||
|
||||
IP_GLOBAL void ipmip6ha_mag_attr_get(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip6ha_if *ife,
|
||||
struct Ipmip_buffer *buffer);
|
||||
|
||||
IP_GLOBAL void ipmip6ha_mag_revoke(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmip6ha_mag_t *mag,
|
||||
Ip_u8 reason,
|
||||
const char *match);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,657 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip6ha_main.c,v $ $Revision: 1.8 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip6ha/src/ipmip6ha_main.c,v $
|
||||
* $Author: jhorteli $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelis@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
#include "ipmip6ha_config.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#include <ipcom_type.h>
|
||||
#include <ipcom_cstyle.h>
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_os.h>
|
||||
#include <ipcom_sock.h>
|
||||
#include <ipcom_sock6.h>
|
||||
#include <ipcom_inet.h>
|
||||
#include <ipcom_list.h>
|
||||
#include <ipcom_ipd.h>
|
||||
#include <ipcom_syslog.h>
|
||||
|
||||
#include <ipmip.h>
|
||||
#include <private/ipmip_util.h>
|
||||
#include <private/ipmip_dhcp.h>
|
||||
#include <private/ipmip_dhcp6.h>
|
||||
#include <private/ipmip_sysvar.h>
|
||||
|
||||
#include <ipmip6.h>
|
||||
#include <private/ipmip6_context.h>
|
||||
#include <private/ipmip6_pkt.h>
|
||||
#include <private/ipmip6_if.h>
|
||||
#include <private/ipmip6_mh.h>
|
||||
#include <private/ipmip6_mh_pkt.h>
|
||||
#include <private/ipmip6_util.h>
|
||||
|
||||
#include "ipmip6ha.h"
|
||||
#include "ipmip6ha_h.h"
|
||||
#include "ipmip6ha_node.h"
|
||||
#include "ipmip6ha_nemo.h"
|
||||
#include "ipmip6ha_attr_h.h"
|
||||
#include "ipmip6ha_cli.h"
|
||||
#include "ipmip6ha_ifevent.h"
|
||||
#include "ipmip6ha_mh.h"
|
||||
#include "ipmip6ha_icmp.h"
|
||||
#include "ipmip6ha_if.h"
|
||||
#include "ipmip6ha_route.h"
|
||||
#include "ipmip6ha_pktbuf.h"
|
||||
#include "ipmip6ha_mag.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
IP_PUBLIC Ip_err ipmip6ha_exit(void);
|
||||
IP_PUBLIC Ip_err ipmip6ha_init(void);
|
||||
IP_PUBLIC Ip_err ipmip6ha_start(void);
|
||||
IP_PUBLIC const char *ipmip6ha_version(void);
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
static int ipmip6ha_instances = 0;
|
||||
|
||||
/* Dispatch function callbacks */
|
||||
static Ipmip6_pkt_context_dispatch_t ipmip6ha_dispatch_table =
|
||||
{
|
||||
(Ipmip6_pkt_dispatch_t)ipmip6ha_mh_dispatch,
|
||||
(Ipmip6_pkt_dispatch_t)ipmip6ha_icmp_dispatch
|
||||
};
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_STATIC unsigned
|
||||
ipmip6ha_relay_nai_obj_hash(Ipmip6ha_relay_key_t *obj)
|
||||
{
|
||||
return ipcom_hash_update(obj->nai, (int)obj->nai_len, 0);
|
||||
}
|
||||
|
||||
IP_STATIC Ip_bool
|
||||
ipmip6ha_relay_nai_key_cmp(Ipmip6ha_relay_key_t *obj,
|
||||
Ipmip6ha_relay_key_t *key)
|
||||
{
|
||||
/**/
|
||||
return ipmip_util_strnncmp(obj->nai, obj->nai_len, key->nai, key->nai_len);
|
||||
}
|
||||
|
||||
|
||||
IP_STATIC void
|
||||
ipmip6ha_relay_map_sysvar_nai_foreach(struct Ipmip_proc *proc,
|
||||
char *name,
|
||||
char *subkey,
|
||||
const char *value,
|
||||
Ipmip6ha_context_t *ctx)
|
||||
{
|
||||
Ipmip6ha_relay_key_t *nkey;
|
||||
Ip_size_t slen = ipcom_strlen(subkey);
|
||||
Ipmip6ha_if_t *ifp = ipmip6ha_if_findbyname(ctx, proc, value);
|
||||
|
||||
|
||||
if (ifp == IP_NULL)
|
||||
{
|
||||
IPMIP6_EVENT_IF(ERR, proc,
|
||||
ipmip_log_event_add(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
"Unable to allocate to MAP %s to %s -- no such interface",
|
||||
subkey, value));
|
||||
return;
|
||||
}
|
||||
|
||||
IPMIP_UNUSED_PARAMETER(name);
|
||||
|
||||
nkey = ipcom_calloc(1, sizeof(*nkey) + slen + 1);
|
||||
if (!nkey)
|
||||
{
|
||||
IPMIP6_EVENT_IF(ERR, proc,
|
||||
ipmip_log_event_add(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
"Unable to allocate NAI entry"));
|
||||
return;
|
||||
}
|
||||
|
||||
nkey->nai = (char *)(nkey + 1);
|
||||
ipcom_strcpy(nkey->nai, subkey);
|
||||
nkey->nai_len = slen;
|
||||
nkey->ifp = ifp;
|
||||
|
||||
/* Overload? */
|
||||
ipcom_hash_add(ctx->relay_map, nkey);
|
||||
}
|
||||
|
||||
|
||||
IP_STATIC void
|
||||
ipmip6ha_configure_relay_map(Ipmip6ha_context_t *ctx,
|
||||
Ipmip_proc_t *proc)
|
||||
{
|
||||
ipmip_sysvar_foreach(proc,
|
||||
(Ipmip_sysvar_foreach_t) ipmip6ha_relay_map_sysvar_nai_foreach,
|
||||
ctx,
|
||||
"ipmip6ha.relay_map.*");
|
||||
}
|
||||
|
||||
IP_STATIC void
|
||||
ipmip6ha_unconfigure_relay_map_cb(Ipmip6ha_relay_key_t *obj,
|
||||
Ipcom_hash *htable)
|
||||
{
|
||||
ipcom_hash_remove(htable, obj);
|
||||
ipcom_free(obj);
|
||||
}
|
||||
|
||||
IP_STATIC void
|
||||
ipmip6ha_unconfigure_relay_map(Ipmip6ha_context_t *ctx,
|
||||
Ipmip_proc_t *proc)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
ipcom_hash_for_each(ctx->relay_map, (Ipcom_hash_foreach_cb_func)ipmip6ha_unconfigure_relay_map_cb, ctx->relay_map);
|
||||
}
|
||||
|
||||
|
||||
IP_STATIC void
|
||||
ipmip6ha_dump_relay_map_cb(Ipmip6ha_context_t *ctx,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmip6ha_relay_key_t *obj,
|
||||
Ipmip_buffer_t *buffer,
|
||||
void *unused)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(ctx);
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
IPMIP_UNUSED_PARAMETER(unused);
|
||||
|
||||
ipmip_cli_config_printf(buffer,
|
||||
"ipmip6ha.relay_map.%s=%s",
|
||||
obj->nai, obj->ifp->ipmip6.iff.ifname);
|
||||
}
|
||||
|
||||
|
||||
IP_STATIC void
|
||||
ipmip6ha_services_clear(Ipmip6ha_context_t *ctx,
|
||||
Ipmip_proc_t *proc)
|
||||
{
|
||||
unsigned si;
|
||||
|
||||
for (si = 0; si < ctx->extensions_num; si++)
|
||||
{
|
||||
if (ctx->extensions[si]->config_global != IP_NULL && ctx->extdata[si] != IP_NULL)
|
||||
{
|
||||
(*ctx->extensions[si]->config_global) (ctx, proc, IPMIP_CALLBACK_CONFIG_FREE, ctx->extdata[si], IP_NULL);
|
||||
ipcom_free(ctx->extdata[si]);
|
||||
ctx->extdata[si] = IP_NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
IP_STATIC void
|
||||
ipmip6ha_services_read(Ipmip6ha_context_t *ctx,
|
||||
Ipmip_proc_t *proc)
|
||||
{
|
||||
unsigned si;
|
||||
|
||||
for (si = 0; si < ctx->extensions_num; si++)
|
||||
{
|
||||
if (ctx->extensions[si]->config_global != IP_NULL && ctx->extensions[si]->global_data_size)
|
||||
{
|
||||
ctx->extdata[si] = ipcom_calloc(1, ctx->extensions[si]->global_data_size);
|
||||
(*ctx->extensions[si]->config_global) (ctx, proc, IPMIP_CALLBACK_CONFIG_READ, ctx->extdata[si], IP_NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmipha_config_init
|
||||
*===========================================================================
|
||||
* Description: Initialize the configuration for the specified instance
|
||||
* Parameters: instance - The HA instance
|
||||
* Returns: 0 on success
|
||||
*
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipmip6ha_update_config(Ipmip6ha_context_t *ctx,
|
||||
Ipmip_proc_t *proc)
|
||||
{
|
||||
ipmip6_pkt_context_stop(&ctx->ipmip6, proc);
|
||||
|
||||
/* Free all mobile nodes */
|
||||
ipmip6ha_node_clear(ctx, proc);
|
||||
|
||||
/* Stop the current context */
|
||||
ipmip6_context_stop(&ctx->ipmip6, proc);
|
||||
|
||||
/* Clear global service config */
|
||||
ipmip6ha_services_clear(ctx, proc);
|
||||
|
||||
#ifdef IPMIP_USE_INET
|
||||
ipmip_dhcp_context_destroy(&ctx->ipmip6.ipmip, proc);
|
||||
#endif
|
||||
|
||||
ipmip6ha_unconfigure_relay_map(ctx, proc);
|
||||
|
||||
/* Unconfigure IF */
|
||||
ipmip6ha_if_unconfigure(ctx, proc);
|
||||
|
||||
/* Restart Counter */
|
||||
ipmip6_context_restart_counter_update(&ctx->ipmip6, proc);
|
||||
|
||||
/* Clear global service config */
|
||||
ipmip6ha_services_read(ctx, proc);
|
||||
|
||||
if (ctx->prefixes != IP_NULL)
|
||||
ipcom_route_free_table(ctx->prefixes);
|
||||
|
||||
ctx->prefixes = ipcom_route_new_table(sizeof(struct Ip_in6_addr) * 8,
|
||||
(Ipcom_route_notify_func) ipmip_route_notify);
|
||||
|
||||
/* Re-read them */
|
||||
ipmip6ha_if_configure(ctx, proc);
|
||||
|
||||
/* Configure relay map */
|
||||
ipmip6ha_configure_relay_map(ctx, proc);
|
||||
|
||||
/**/
|
||||
ipmip6_context_start(&ctx->ipmip6, proc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip6mn_destroy
|
||||
*===========================================================================
|
||||
* Description: Shutdown the mobile node portion of the context.
|
||||
* Parameters: ctx - The MIP6 context.
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipmip6ha_context_destroy(Ipmip6ha_context_t *ctx,
|
||||
Ipmip_proc_t *proc)
|
||||
{
|
||||
/* Only if we actually got a context. */
|
||||
if (ctx != IP_NULL)
|
||||
{
|
||||
/* Stop the packet context; for starters */
|
||||
ipmip6_pkt_context_stop(&ctx->ipmip6, proc);
|
||||
|
||||
/* Destroy the entries that has been removed */
|
||||
ipmip6ha_node_clear(ctx, proc);
|
||||
|
||||
/* Stop the rest */
|
||||
ipmip6_context_stop(&ctx->ipmip6, proc);
|
||||
|
||||
/**/
|
||||
ipmip6ha_unconfigure_relay_map(ctx, proc);
|
||||
ipmip6ha_if_unconfigure(ctx, proc);
|
||||
ipmip6ha_nemo_unconfigure(ctx, proc, ctx->nemo);
|
||||
ipmip6ha_services_clear(ctx, proc);
|
||||
|
||||
/* Close the IPD */
|
||||
if (ctx->fd_ipd == IP_INVALID_SOCKET)
|
||||
(void)ipcom_ipd_init("ipmip6ha", IPCOM_ERR_FAILED, &ctx->fd_ipd);
|
||||
|
||||
ipcom_hash_delete(ctx->relay_map);
|
||||
|
||||
/**/
|
||||
ipcom_ipd_exit("ipmip6ha", ctx->fd_ipd);
|
||||
|
||||
/**/
|
||||
ipmip_timer_lock_destroy(&ctx->ipmip6.ipmip, proc, ctx->ifs_lock);
|
||||
|
||||
/* Free the lock */
|
||||
ipmip6ha_nemo_context_destroy(ctx, proc);
|
||||
|
||||
ipcom_mutex_delete(&ctx->prefixes_lock);
|
||||
|
||||
ipmip6ha_route_context_destroy(ctx, proc);
|
||||
|
||||
/* Free the identity contexts */
|
||||
ipmip_context_id_destroy(ctx->idents);
|
||||
ipmip_context_id_destroy(ctx->bri);
|
||||
|
||||
/* Shutdown the 'mip6' context */
|
||||
ipmip6_context_destroy(&ctx->ipmip6, proc);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip6ha_context_allocate
|
||||
*===========================================================================
|
||||
* Description: Initialize the mobile node portion of the context.
|
||||
* Parameters: ctx - The MIP6 context.
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC Ipmip6ha_context_t *
|
||||
ipmip6ha_context_allocate(Ipmip_proc_t *proc)
|
||||
{
|
||||
Ipmip6ha_context_t *ctx = (Ipmip6ha_context_t *)ipmip_context_alloc(proc, sizeof(*ctx), "ipmip6ha", IPMIP6_SYSTEM_PRIORITY, IPMIP6HA_EVENT_BACKLOG);
|
||||
int i;
|
||||
|
||||
/* */
|
||||
if (ctx == IP_NULL)
|
||||
return IP_NULL;
|
||||
|
||||
/* For LAS */
|
||||
ipmip_dhcp6_embedded_server_init(&ctx->ipmip6.ipmip, proc);
|
||||
|
||||
ipmip6ha_route_context_init(ctx, proc);
|
||||
|
||||
/* Initialize */
|
||||
ipmip6ha_nemo_context_init(ctx, proc);
|
||||
|
||||
ipcom_list_init(&ctx->ifs);
|
||||
|
||||
ipcom_mutex_create(&ctx->prefixes_lock);
|
||||
|
||||
ctx->ifs_lock = ipmip_timer_lock_alloc(&ctx->ipmip6.ipmip, proc, IP_NULL, IP_NULL);
|
||||
|
||||
ctx->idents = ipmip_context_id_create(ip_offsetof(Ipmip6ha_node_t, identity), 0xFFFFFFFF);
|
||||
ctx->bri = ipmip_context_id_create(ip_offsetof(Ipmip6ha_br_t, sequence), 0x0000FFFF);
|
||||
|
||||
/* Initialize the global information */
|
||||
if (ipmip6_context_initialize(&ctx->ipmip6,
|
||||
proc,
|
||||
&ipmip6ha_ifevent_table) == IP_FALSE)
|
||||
goto failure;
|
||||
|
||||
/* Server side; don't do solicitations */
|
||||
ctx->ipmip6.iff.no_solicitation = IP_TRUE;
|
||||
|
||||
/**/
|
||||
ctx->relay_map = ipcom_hash_new((Ipcom_hash_obj_func) ipmip6ha_relay_nai_obj_hash,
|
||||
(Ipcom_hash_key_func) ipmip6ha_relay_nai_obj_hash,
|
||||
(Ipcom_hash_cmp_func) ipmip6ha_relay_nai_key_cmp);
|
||||
|
||||
if (ipmip6_pkt_context_create(&ctx->ipmip6,
|
||||
proc,
|
||||
&ipmip6ha_dispatch_table,
|
||||
IPMIP6_DSMIP_UDP_PORT,
|
||||
(Ipmip_pkt_buf_alloc_t)ipmip6ha_pktbuf_alloc,
|
||||
(Ipmip_pkt_buf_free_t)ipmip6ha_pktbuf_free) == IP_FALSE)
|
||||
{
|
||||
IPCOM_LOG0(ERR, "Unable to create IPMIP6HA Packet Context");
|
||||
goto failure;
|
||||
}
|
||||
|
||||
ipmip_cli_context_create(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
"ipmip6ha",
|
||||
IPCOM_IPD_ID_IPMIP6HA,
|
||||
(Ipmip_cli_callback_t)ipmip6ha_attr_command);
|
||||
|
||||
/* IPD init */
|
||||
if (ipcom_ipd_init("ipmip6ha", IPCOM_SUCCESS, &ctx->fd_ipd) != IPCOM_SUCCESS)
|
||||
{
|
||||
IPCOM_LOG1(ERR, "Unable to create IPMIP6MN IPD pipe = %d", ipcom_errno);
|
||||
goto failure;
|
||||
}
|
||||
|
||||
(void) ipcom_inet_pton(IP_AF_INET6, "FE80::", &ctx->link_local_prefix);
|
||||
|
||||
|
||||
for (i = 0; ipmip6ha_service_registrations[i] != IP_NULL; i++)
|
||||
(*ipmip6ha_service_registrations[i]) (ctx);
|
||||
|
||||
/* Update configuration */
|
||||
ipmip6ha_update_config(ctx, proc);
|
||||
|
||||
/* Return the mobile node instance */
|
||||
return ctx;
|
||||
|
||||
failure:
|
||||
ipmip6ha_context_destroy(ctx, proc);
|
||||
return IP_NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmipha_data_process
|
||||
*===========================================================================
|
||||
* Description: Process any file descriptors set by the platform.
|
||||
* Parameters: data - The data structure
|
||||
* rset - The read set.
|
||||
* Returns: IP_FALSE if we should exit the process.
|
||||
*
|
||||
*/
|
||||
IP_STATIC Ip_bool
|
||||
ipmip6ha_ipd_process(Ipmip6ha_context_t *ctx,
|
||||
Ipmip_proc_t *proc)
|
||||
{
|
||||
/* IPD input. */
|
||||
int event;
|
||||
Ip_ssize_t len;
|
||||
Ipmip6ha_pktbuf_t *pbuf = (Ipmip6ha_pktbuf_t *)ipmip_pktbuf_alloc(&ctx->ipmip6.ipmip, proc, 512);
|
||||
|
||||
if (pbuf == IP_NULL)
|
||||
return IP_TRUE;
|
||||
|
||||
len = ipcom_ipd_read(ctx->fd_ipd, IPMIP_BUFFER_PTR(&pbuf->ipmip6.ipmip.packet), 512, &event);
|
||||
if (len < 0)
|
||||
{
|
||||
IPCOM_LOG2(ERR, "ipcom_socketread(IPD) failed : %s [%d]",
|
||||
ipcom_strerror(ipcom_errno), ipcom_errno);
|
||||
ipmip_util_sock_clear(ctx->fd_ipd);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Advance past */
|
||||
ipmip_buffer_append(&pbuf->ipmip6.ipmip.packet, IP_NULL, (Ip_size_t)len);
|
||||
|
||||
switch (event)
|
||||
{
|
||||
case IPCOM_IPD_EVENT_RECONFIGURE:
|
||||
IPCOM_LOG0(INFO, "Received IPD reconfigure message");
|
||||
ipmip6ha_update_config(ctx, proc);
|
||||
break;
|
||||
|
||||
case IPCOM_IPD_EVENT_KILL:
|
||||
IPCOM_LOG0(INFO, "Received IPD kill message");
|
||||
ipmip_pktbuf_release(&ctx->ipmip6.ipmip, proc, &pbuf->ipmip6.ipmip);
|
||||
return IP_FALSE;
|
||||
|
||||
default:
|
||||
/* Ignore all other IPD messages */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ipmip_pktbuf_release(&ctx->ipmip6.ipmip, proc, &pbuf->ipmip6.ipmip);
|
||||
return IP_TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_GLOBAL void
|
||||
ipmip6ha_main(void)
|
||||
{
|
||||
int num;
|
||||
int max_fd;
|
||||
Ipmip6ha_context_t *ctx = IP_NULL;
|
||||
Ipmip_proc_t *proc;
|
||||
|
||||
ipcom_proc_init();
|
||||
|
||||
proc = ipmip_proc_alloc();
|
||||
|
||||
IPCOM_LOG0(INFO,
|
||||
"ipmip6ha: starting");
|
||||
|
||||
/* Init the configuration */
|
||||
if (ipmip6ha_configure() != IPCOM_SUCCESS)
|
||||
goto done;
|
||||
|
||||
/* Init IPMIP6MN */
|
||||
if ((ctx = ipmip6ha_context_allocate(proc)) == IP_NULL)
|
||||
goto done;
|
||||
|
||||
if (ipmip6ha_instances++ == 0)
|
||||
if (ipmip6ha_init() != IPCOM_SUCCESS)
|
||||
goto end;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
Ip_fd_set read_set;
|
||||
|
||||
IP_FD_ZERO(&read_set);
|
||||
|
||||
/* Set the IPD */
|
||||
max_fd = ctx->fd_ipd;
|
||||
IP_FD_SET(ctx->fd_ipd, &read_set);
|
||||
|
||||
/* Select */
|
||||
num = ipcom_socketselect(max_fd + 1, &read_set, IP_NULL, IP_NULL, IP_NULL);
|
||||
|
||||
switch(num)
|
||||
{
|
||||
case -1: /* socket error. */
|
||||
IPCOM_LOG2(WARNING, "ipcom_socketselect() failed : %s [%d]", ipcom_strerror(ipcom_errno), ipcom_errno);
|
||||
(void)ipcom_sleep(1);
|
||||
break;
|
||||
|
||||
case 0: /* timeout, not used. triggered by bug in linux glibc if compiled with nptl */
|
||||
(void)ipcom_millisleep(1);
|
||||
break;
|
||||
|
||||
default:
|
||||
/* Process IPD */
|
||||
if (IP_FD_ISSET(ctx->fd_ipd, &read_set))
|
||||
{
|
||||
if (ipmip6ha_ipd_process(ctx, proc) == IP_FALSE)
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
end:
|
||||
ipmip6ha_context_destroy(ctx, proc);
|
||||
|
||||
/**/
|
||||
if (--ipmip6ha_instances == 0)
|
||||
ipmip6ha_exit();
|
||||
|
||||
|
||||
done:
|
||||
/* Free the context process */
|
||||
ipmip_proc_destroy(proc);
|
||||
|
||||
IPCOM_LOG0(NOTICE,
|
||||
"ipmip6ha: ending");
|
||||
|
||||
ipcom_proc_exit();
|
||||
}
|
||||
|
||||
|
||||
IP_GLOBAL Ip_u32
|
||||
ipmip6ha_context_register_extension(Ipmip6ha_context_t *ctx,
|
||||
Ipmip6ha_extension_t *srv,
|
||||
Ip_bool reg_H,
|
||||
Ip_bool reg_P)
|
||||
{
|
||||
srv->type = ctx->extensions_num++;
|
||||
ctx->extensions[srv->type] = srv;
|
||||
|
||||
if (reg_H)
|
||||
{
|
||||
ctx->extensions_H_mask |= (1 << srv->type);
|
||||
ctx->extensions_node_H_data += srv->node_data_size;
|
||||
}
|
||||
|
||||
if (reg_P)
|
||||
{
|
||||
ctx->extensions_P_mask |= (1 << srv->type);
|
||||
ctx->extensions_node_P_data += srv->node_data_size;
|
||||
}
|
||||
|
||||
return srv->type;
|
||||
}
|
||||
|
||||
IP_GLOBAL void
|
||||
ipmip6ha_dump_relay_map(Ipmip6ha_context_t *ctx,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmip_buffer_t *buffer)
|
||||
{
|
||||
ipmip_util_hash_foreach(&ctx->ipmip6.ipmip,
|
||||
proc,
|
||||
ctx->relay_map,
|
||||
(Ipmip_util_hash_foreach_t)ipmip6ha_dump_relay_map_cb,
|
||||
buffer,
|
||||
IP_NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,88 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip6ha_mh.h,v $ $Revision: 1.5 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip6ha/src/ipmip6ha_mh.h,v $
|
||||
* $Author: jhorteli $ $Date: 2009-06-18 12:53:11 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMIP6HA_MH_H
|
||||
#define IPMIP6HA_MH_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
struct Ipmip6ha_context;
|
||||
struct Ipmip_proc;
|
||||
struct Ipmip6ha_pktbuf;
|
||||
struct Ipmip6ha_br;
|
||||
struct Ipmip6ha_node;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
IP_GLOBAL Ip_bool ipmip6ha_mh_dispatch(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip6ha_pktbuf *pbuf);
|
||||
|
||||
IP_GLOBAL Ip_bool ipmip6ha_mh_bri_send(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip6ha_node *node,
|
||||
struct Ipmip6ha_br *br);
|
||||
IP_GLOBAL Ip_bool ipmip6ha_mh_bra_send(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip6ha_pktbuf *pbuf,
|
||||
Ip_u8 status);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,178 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip6ha_nemo.h,v $ $Revision: 1.9 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip6ha/src/ipmip6ha_nemo.h,v $
|
||||
* $Author: jhorteli $ $Date: 2009-02-25 14:33:56 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMIP6HA_NEMO_H
|
||||
#define IPMIP6HA_NEMO_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipmip6ha_nemo_dsmipv6.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPMIP6HA_NEMO_ACL_DELETED (1 << 0)
|
||||
#define IPMIP6HA_NEMO_ACL_ADDED (1 << 1)
|
||||
#define IPMIP6HA_NEMO_ACL_ROUTE (1 << 2)
|
||||
#define IPMIP6HA_NEMO_ACL_HOA_PROXY (1 << 3)
|
||||
#define IPMIP6HA_NEMO_ACL_STATIC (1 << 4)
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
struct Ipmip6ha_node;
|
||||
struct Ipmip6ha_context;
|
||||
struct Ipmip_proc;
|
||||
struct Ipmip_buffer;
|
||||
|
||||
typedef struct Ipmip6ha_nemo_pool_slice
|
||||
{
|
||||
Ipcom_list next;
|
||||
|
||||
struct Ip_in6_addr prefix;
|
||||
|
||||
Ip_u8 prefix_length;
|
||||
|
||||
Ip_u8 addr_bit;
|
||||
|
||||
Ip_u64 addr_hi;
|
||||
Ip_u64 addr_hi_mask;
|
||||
Ip_u64 addr_lo;
|
||||
Ip_u64 addr_lo_mask;
|
||||
} Ipmip6ha_nemo_pool_slice_t;
|
||||
|
||||
typedef struct Ipmip6ha_nemo_pool
|
||||
{
|
||||
Ipcom_list slices;
|
||||
struct Ipmip6ha_nemo_pool *npool;
|
||||
|
||||
const char *pool_name;
|
||||
Ip_size_t pool_name_size;
|
||||
} Ipmip6ha_nemo_pool_t;
|
||||
|
||||
|
||||
typedef struct Ipmip6ha_nemo
|
||||
{
|
||||
Ipcom_list next;
|
||||
|
||||
struct Ipmip6ha_nemo *acl_next;
|
||||
|
||||
struct Ip_in6_addr prefix;
|
||||
Ip_u8 len;
|
||||
Ip_u8 flags;
|
||||
} Ipmip6ha_nemo_t;
|
||||
|
||||
typedef struct Ipmip6ha_nemo_acl
|
||||
{
|
||||
Ipmip6ha_nemo_pool_t *pool;
|
||||
Ipmip6ha_nemo_t *nemo;
|
||||
Ip_size_t limit;
|
||||
Ip_bool nemo_copy;
|
||||
} Ipmip6ha_nemo_acl_t;
|
||||
|
||||
typedef struct Ipmip6ha_nemo_context
|
||||
{
|
||||
struct Ipmip6ha_nemo_pool *nemo_pools;
|
||||
Ipcom_hash *nemo_mr_acl_hoa;
|
||||
Ipcom_hash *nemo_mr_acl_nai;
|
||||
Ipcom_hash *nemo_lma_acl_nai;
|
||||
#ifdef IPMIP_USE_INET
|
||||
Ipmip6ha_nemo_dsmipv6_context_t *nemo_dsmipv6;
|
||||
#endif
|
||||
} Ipmip6ha_nemo_context_t;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_GLOBAL int ipmip6ha_nemo_verify(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip6ha_node *node,
|
||||
Ipmip6_mh_option_array_t *mo,
|
||||
Ip_bool *changed);
|
||||
IP_GLOBAL int ipmip6ha_nemo_pmipv6_verify(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip6ha_node *node,
|
||||
Ipmip6_mh_option_array_t *mo);
|
||||
IP_GLOBAL void ipmip6ha_nemo_free(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip6ha_node *node,
|
||||
Ipmip6ha_nemo_t *nemo);
|
||||
IP_GLOBAL void ipmip6ha_nemo_free_list(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip6ha_node *node,
|
||||
Ipcom_list *nemos);
|
||||
|
||||
|
||||
IP_GLOBAL void ipmip6ha_nemo_unconfigure(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmip6ha_nemo_context_t *nemo);
|
||||
IP_GLOBAL void ipmip6ha_nemo_configure(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmip6ha_nemo_context_t **nemop,
|
||||
const char *ifname);
|
||||
|
||||
|
||||
IP_GLOBAL void ipmip6ha_nemo_context_init(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc);
|
||||
|
||||
IP_GLOBAL void ipmip6ha_nemo_context_destroy(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc);
|
||||
|
||||
IP_GLOBAL void ipmip6ha_nemo_dump_config(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmip6ha_nemo_context_t *nemo,
|
||||
const char *ifname,
|
||||
struct Ipmip_buffer *buffer);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,174 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip6ha_nemo_dsmipv6.h,v $ $Revision: 1.6 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip6ha/src/ipmip6ha_nemo_dsmipv6.h,v $
|
||||
* $Author: jhorteli $ $Date: 2009-02-25 14:33:56 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMIP6HA_NEMO_DSMIPV6_H
|
||||
#define IPMIP6HA_NEMO_DSMIPV6_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef IPMIP_USE_INET
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
struct Ipmip6ha_node;
|
||||
struct Ipmip6ha_context;
|
||||
struct Ipmip_proc;
|
||||
struct Ipmip_dhcp_pool;
|
||||
struct Ipmip_dhcp_option;
|
||||
|
||||
typedef struct Ipmip6ha_nemo_dsmipv6
|
||||
{
|
||||
Ipcom_list next;
|
||||
struct Ipmip6ha_nemo_dsmipv6 *acl_next;
|
||||
|
||||
Ip_u32 prefix;
|
||||
Ip_u32 len;
|
||||
Ip_u32 netmask;
|
||||
Ip_u8 flags;
|
||||
} Ipmip6ha_nemo_dsmipv6_t;
|
||||
|
||||
typedef struct Ipmip6ha_nemo_dsmipv6_config
|
||||
{
|
||||
Ip_u32 netmask;
|
||||
|
||||
Ipcom_list opts;
|
||||
struct Ipmip6ha_nemo_dsmipv6_config *parent;
|
||||
} Ipmip6ha_nemo_dsmipv6_config_t;
|
||||
|
||||
typedef struct Ipmip6ha_nemo_dsmipv6_acl
|
||||
{
|
||||
Ipmip6ha_nemo_dsmipv6_t *hoa;
|
||||
Ipmip6ha_nemo_dsmipv6_t *pd;
|
||||
struct Ipmip_dhcp_pool *pool;
|
||||
|
||||
Ip_bool mobile_router;
|
||||
Ip_u32 limit_prefix;
|
||||
Ip_u32 limit_hoa;
|
||||
} Ipmip6ha_nemo_dsmipv6_acl_t;
|
||||
|
||||
typedef struct Ipmip6ha_nemo_dsmipv6_context
|
||||
{
|
||||
struct Ipmip_dhcp_rtab *nemo_dhcp_rtab;
|
||||
|
||||
Ipcom_list nemo_dsmipv6_pools;
|
||||
|
||||
Ipcom_route *nemo_dsmipv6_acl_mr_hoa;
|
||||
Ipcom_hash *nemo_dsmipv6_acl_mr_nai;
|
||||
|
||||
Ipcom_route *nemo_inet_config;
|
||||
Ipcom_hash *nemo_dsmipv6_acl_lma_nai;
|
||||
} Ipmip6ha_nemo_dsmipv6_context_t;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_GLOBAL Ipmip6ha_nemo_dsmipv6_config_t *ipmip6ha_nemo_dsmipv6_subnet_config_get(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmip6ha_nemo_dsmipv6_context_t *nctx,
|
||||
Ip_u32 addr);
|
||||
|
||||
IP_GLOBAL Ip_u32 ipmip6ha_nemo_dsmipv6_subnet_config_gateway(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmip6ha_nemo_dsmipv6_context_t *nemo,
|
||||
Ip_u32 addr);
|
||||
|
||||
IP_GLOBAL Ip_u32 ipmip6ha_nemo_dsmipv6_subnet_config_netmask(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmip6ha_nemo_dsmipv6_context_t *nemo,
|
||||
Ip_u32 addr);
|
||||
|
||||
IP_GLOBAL void ipmip6ha_nemo_dsmipv6_free(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip6ha_node *node,
|
||||
Ipmip6ha_nemo_dsmipv6_t *nemo);
|
||||
|
||||
IP_GLOBAL void ipmip6ha_nemo_dsmipv6_free_list(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip6ha_node *node,
|
||||
Ipcom_list *nemos);
|
||||
IP_GLOBAL int ipmip6ha_nemo_dsmipv6_verify(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip6ha_node *node,
|
||||
struct Ipmip6ha_pktbuf *pbuf,
|
||||
Ip_bool *changed);
|
||||
|
||||
IP_GLOBAL void ipmip6ha_nemo_dsmipv6_dump_config(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmip6ha_nemo_dsmipv6_context_t *nemo,
|
||||
const char *ifname,
|
||||
struct Ipmip_buffer *buffer);
|
||||
|
||||
|
||||
IP_GLOBAL void ipmip6ha_nemo_dsmipv6_unconfigure(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmip6ha_nemo_dsmipv6_context_t *nemo);
|
||||
|
||||
IP_GLOBAL void ipmip6ha_nemo_dsmipv6_configure(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmip6ha_nemo_dsmipv6_context_t **nemop,
|
||||
const char *ifname);
|
||||
|
||||
|
||||
IP_GLOBAL void ipmip6ha_nemo_dsmipv6_context_init(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc);
|
||||
|
||||
IP_GLOBAL void ipmip6ha_nemo_dsmipv6_context_destroy(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,383 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip6ha_node.h,v $ $Revision: 1.19 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip6ha/src/ipmip6ha_node.h,v $
|
||||
* $Author: jhorteli $ $Date: 2010-02-15 13:27:38 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMIP6HA_NODE_H
|
||||
#define IPMIP6HA_NODE_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#include <private/ipmip6_nd_proxy.h>
|
||||
#include <private/ipmip6_nd_nud.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPMIP6HA_NODE_STATE_HOME_AGENT (1 << 0)
|
||||
#define IPMIP6HA_NODE_STATE_HOME_ADDRESS (1 << 1)
|
||||
#define IPMIP6HA_NODE_STATE_PROXY_NDP (1 << 2)
|
||||
#define IPMIP6HA_NODE_STATE_PROXY_ARP (1 << 3)
|
||||
#define IPMIP6HA_NODE_STATE_DAD_FAILED (1 << 4)
|
||||
#define IPMIP6HA_NODE_STATE_SHUTDOWN (1 << 5)
|
||||
#define IPMIP6HA_NODE_STATE_PROXY_LL_NDP (1 << 6)
|
||||
#define IPMIP6HA_NODE_STATE_NDP_HOA (1 << 7)
|
||||
#define IPMIP6HA_NODE_STATE_NDP_LLOCAL (1 << 8)
|
||||
#define IPMIP6HA_NODE_STATE_SRCMAC (1 << 9)
|
||||
#define IPMIP6HA_NODE_STATE_GRE_KEY (1 << 10)
|
||||
|
||||
#define IPMIP6HA_NODE_HASH_HOA (1 << 0)
|
||||
#define IPMIP6HA_NODE_HASH_NAI (1 << 1)
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
struct Ipmip6ha_context;
|
||||
struct Ipmip_proc;
|
||||
struct Ipmip6ha_if;
|
||||
struct Ipmip6ha_pktbuf;
|
||||
struct Ipmip6ha_nemo_acl;
|
||||
struct Ipmip6ha_nemo_dsmipv6_acl;
|
||||
struct Ipmip6ha_mag;
|
||||
struct Ipmip6ha_node;
|
||||
struct Ipmip6ha_br;
|
||||
|
||||
typedef int (*Ipmip6ha_bri_done_t) (struct Ipmip6ha_context *ctx, struct Ipmip_proc *proc, struct Ipmip6ha_node *node, struct Ipmip6ha_br *bri, Ip_bool timeout, Ip_u8 status);
|
||||
|
||||
typedef struct Ipmip6ha_br
|
||||
{
|
||||
Ipcom_list next;
|
||||
|
||||
Ip_u32 sequence;
|
||||
|
||||
Ip_u8 xmits;
|
||||
Ip_u8 reason;
|
||||
Ip_u8 state;
|
||||
Ip_u16 flags;
|
||||
|
||||
Ip_bool inet;
|
||||
char *match;
|
||||
Ip_size_t match_len;
|
||||
|
||||
Ipmip_timer_t retransmit;
|
||||
Ipmip_timer_func_t reply;
|
||||
|
||||
void *opaque;
|
||||
Ipmip_timer_lock_t *lock;
|
||||
struct Ipmip6ha_mag *mag;
|
||||
Ipmip6ha_bri_done_t completion;
|
||||
|
||||
/**/
|
||||
|
||||
} Ipmip6ha_br_t;
|
||||
|
||||
typedef struct Ipmip6ha_node_coa
|
||||
{
|
||||
Ip_u32 mip6BindingTunnelType;
|
||||
Ip_u32 mip6BindingCOAType;
|
||||
union Ipmip6_mib_InetAddress mip6BindingCOA;
|
||||
Ip_u32 mip6BindingUDPEncapType;
|
||||
} Ipmip6ha_node_coa_t;
|
||||
|
||||
typedef struct Ipmip6ha_node
|
||||
{
|
||||
struct Ipmip6ha_node *next;
|
||||
struct Ipmip6ha_node *prev;
|
||||
|
||||
/**/
|
||||
Ipmip_timer_lock_t *lock;
|
||||
|
||||
Ipmip6_mh_mo_hdr_t *nai_mn;
|
||||
struct Ipmip6ha_if *ifp_transport;
|
||||
struct Ipmip6ha_if *ifp_home;
|
||||
|
||||
Ipcom_list bri_list;
|
||||
|
||||
/**/
|
||||
Ipmip_timer_t expire;
|
||||
Ipmip_timer_t revocation;
|
||||
Ipmip_timer_t service;
|
||||
|
||||
Ip_u16 termstate;
|
||||
Ip_u16 bristate;
|
||||
|
||||
Ip_time_t updated;
|
||||
Ip_u32 state;
|
||||
Ip_u32 route_state;
|
||||
Ip_u32 route_change;
|
||||
|
||||
Ip_u32 identity;
|
||||
Ip_u32 *gre_keys[2];
|
||||
|
||||
Ip_u16 sequence;
|
||||
Ip_u16 flags;
|
||||
Ip_u16 regflags;
|
||||
|
||||
Ipcom_list nemo_v6;
|
||||
struct Ipmip6ha_nemo_acl *nemo_acl_v6;
|
||||
#ifdef IPMIP_USE_INET
|
||||
Ipcom_list nemo_prefix_v4;
|
||||
Ipcom_list nemo_hoa_v4;
|
||||
struct Ipmip6ha_nemo_dsmipv6_acl *nemo_acl_v4;
|
||||
#endif
|
||||
|
||||
|
||||
/* Information required to deal with BA */
|
||||
Ipmip6ha_node_coa_t pending;
|
||||
Ipmip6ha_node_coa_t registered;
|
||||
|
||||
/* Statistics */
|
||||
struct Ipmip6_mib_mip6BindingCacheEntry mip6BindingCacheEntry;
|
||||
struct Ipmip6_mib_mip6NodeTrafficEntry mip6NodeTrafficEntry;
|
||||
|
||||
/**/
|
||||
void **extdata;
|
||||
Ip_u32 service_enabled;
|
||||
Ip_u32 service_supported;
|
||||
} Ipmip6ha_node_t;
|
||||
|
||||
|
||||
typedef struct Ipmip6ha_node_H
|
||||
{
|
||||
struct Ipmip6ha_node node;
|
||||
|
||||
struct Ip_in6_addr link_local;
|
||||
Ipmip6_nd_proxy_t link_local_proxy;
|
||||
Ipmip6_nd_nud_t link_local_nud;
|
||||
|
||||
Ipmip6_nd_proxy_t proxy;
|
||||
Ipmip6_nd_nud_t nud;
|
||||
|
||||
/**/
|
||||
} Ipmip6ha_node_H_t;
|
||||
|
||||
typedef struct Ipmip6ha_node_P
|
||||
{
|
||||
struct Ipmip6ha_node node;
|
||||
|
||||
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_link_local_address_t pmipv6_link_local_address;
|
||||
|
||||
struct Ip_timeval timestamp;
|
||||
|
||||
Ipmip6_mh_mo_pmipv6_mn_link_layer_id_t *pmipv6_mn_link_layer_id;
|
||||
|
||||
/**/
|
||||
struct Ip_in6_addr pendingBAEndpoint;
|
||||
Ip_u32 gre_down_link;
|
||||
|
||||
/**/
|
||||
struct Ipmip6ha_pktbuf *delayed_BU;
|
||||
struct Ip_timeval delayed_start;
|
||||
|
||||
#ifdef IPMIP_USE_INET
|
||||
Ip_u32 router;
|
||||
#endif
|
||||
struct Ipmip6ha_mag *mag;
|
||||
} Ipmip6ha_node_P_t;
|
||||
|
||||
typedef struct Ipmip6ha_node_key
|
||||
{
|
||||
struct Ip_in6_addr *hoa;
|
||||
const char *nai;
|
||||
Ip_size_t nai_len;
|
||||
} Ipmip6ha_node_key_t;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
IP_GLOBAL void ipmip6ha_node_clear(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc);
|
||||
|
||||
|
||||
IP_GLOBAL void ipmip6ha_node_if_init(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip6ha_if *ife);
|
||||
|
||||
IP_GLOBAL void ipmip6ha_node_if_destroy(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip6ha_if *ife);
|
||||
|
||||
IP_GLOBAL int ipmip6ha_node_terminate(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmip6ha_node_t *node,
|
||||
const char *reason,
|
||||
Ip_bool immediate);
|
||||
IP_GLOBAL void ipmip6ha_node_silence(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmip6ha_node_t *node);
|
||||
|
||||
|
||||
IP_GLOBAL void ipmip6ha_node_update(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmip6ha_node_t *node,
|
||||
struct Ipmip6ha_pktbuf *pbuf);
|
||||
IP_GLOBAL Ipmip6ha_node_t *ipmip6ha_node_create_H(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmip6ha_node_t *head,
|
||||
struct Ipmip6ha_if *iff_home,
|
||||
struct Ipmip6ha_if *iff_transport,
|
||||
struct Ip_in6_addr *hoa,
|
||||
Ipmip6_mh_mo_nai_t *nai,
|
||||
Ip_u16 regflags);
|
||||
|
||||
IP_GLOBAL Ipmip6ha_node_t *ipmip6ha_node_create_P(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmip6ha_node_t *head,
|
||||
struct Ipmip6ha_if *iff_home,
|
||||
struct Ipmip6ha_if *iff_transport,
|
||||
Ipmip6_mh_options_t *opts,
|
||||
Ip_u16 regflags);
|
||||
|
||||
IP_GLOBAL void ipmip6ha_node_lookup(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip6ha_if *ifp,
|
||||
struct Ip_in6_addr *hoa,
|
||||
Ipmip6_mh_mo_nai_t *nai,
|
||||
Ipmip_timer_t *timer,
|
||||
Ipmip_timer_func_t func,
|
||||
void *arg);
|
||||
|
||||
IP_GLOBAL void ipmip6ha_node_search(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip6ha_if *ifp,
|
||||
Ipmip6ha_node_key_t *key,
|
||||
Ipmip_timer_t *timer,
|
||||
Ipmip_timer_func_t func,
|
||||
void *arg);
|
||||
|
||||
IP_GLOBAL void ipmip6ha_node_lookup_handle(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ip_u32 handle,
|
||||
Ipmip_timer_t *timer,
|
||||
Ipmip_timer_func_t func,
|
||||
void *arg);
|
||||
|
||||
IP_GLOBAL void ipmip6ha_node_delete(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmip6ha_node_t *node,
|
||||
const char *reason);
|
||||
IP_GLOBAL int ipmip6ha_node_revoke(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmip6ha_node_t *node,
|
||||
Ip_bool inet,
|
||||
Ip_u8 reason,
|
||||
Ipmip6ha_bri_done_t completion);
|
||||
|
||||
|
||||
IP_GLOBAL const char *ipmip6ha_node_describe(struct Ipmip_proc *proc,
|
||||
Ipmip6ha_node_t *node);
|
||||
|
||||
|
||||
IP_GLOBAL Ip_bool ipmip6ha_node_enable_service(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmip6ha_node_t *node);
|
||||
IP_GLOBAL Ip_bool ipmip6ha_node_disable_service(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmip6ha_node_t *node);
|
||||
IP_GLOBAL Ip_bool ipmip6ha_node_update_service(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmip6ha_node_t *node);
|
||||
|
||||
IP_GLOBAL Ip_bool ipmip6ha_node_extension_pkt_req_validate(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip6ha_node *node,
|
||||
struct Ipmip6ha_pktbuf *pbuf);
|
||||
|
||||
IP_GLOBAL Ip_bool ipmip6ha_node_extension_pkt_req_accept(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip6ha_node *node,
|
||||
struct Ipmip6ha_pktbuf *pbuf);
|
||||
|
||||
|
||||
|
||||
IP_GLOBAL Ip_bool ipmip6ha_node_refresh_request(struct Ipmip6ha_node *node,
|
||||
struct Ipmip6ha_pktbuf *pbuf);
|
||||
|
||||
IP_GLOBAL int ipmip6ha_node_timeout(int event,
|
||||
struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip6ha_node *node,
|
||||
const char *reason);
|
||||
|
||||
IP_GLOBAL int ipmip6ha_node_bri_accept(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip6ha_node *node,
|
||||
Ipmip6ha_br_t *bri,
|
||||
Ip_bool timeout,
|
||||
Ip_u8 status);
|
||||
|
||||
IP_GLOBAL void ipmip6ha_node_bri_cancel(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip6ha_node *node,
|
||||
Ipmip6ha_bri_done_t completion);
|
||||
|
||||
IP_GLOBAL void ipmip6ha_node_bri_cancel_mag(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip6ha_node *node,
|
||||
Ipmip6ha_bri_done_t completion,
|
||||
struct Ipmip6ha_mag *mag);
|
||||
|
||||
IP_GLOBAL void ipmip6ha_node_bri_free(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip6ha_node *node,
|
||||
Ipmip6ha_br_t *bri);
|
||||
|
||||
|
||||
#ifdef IPMIP_USE_INET
|
||||
IP_GLOBAL int ipmip6ha_node_bri_inet_process(int event,
|
||||
struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip6ha_node *node,
|
||||
void *extarg);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,158 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip6ha_route.h,v $ $Revision: 1.10 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip6ha/src/ipmip6ha_route.h,v $
|
||||
* $Author: jhorteli $ $Date: 2010-12-08 12:52:37 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMIP6HA_ROUTE_H
|
||||
#define IPMIP6HA_ROUTE_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
enum
|
||||
{
|
||||
IPMIP6HA_ROUTE_BIT_IPV6 = 0,
|
||||
IPMIP6HA_ROUTE_BIT_TUNNEL_IPV6,
|
||||
IPMIP6HA_ROUTE_BIT_IPV6_NEMO,
|
||||
IPMIP6HA_ROUTE_BIT_IPV4_NEMO,
|
||||
IPMIP6HA_ROUTE_BIT_IPV4,
|
||||
IPMIP6HA_ROUTE_BIT_MAX
|
||||
};
|
||||
|
||||
|
||||
#define IPMIP6HA_ROUTE_STATE_BIT(x) (1 << (x))
|
||||
#define IPMIP6HA_ROUTE_STATE_CHECK(s,i) ((s) & IPMIP6HA_ROUTE_STATE_BIT(i))
|
||||
#define IPMIP6HA_ROUTE_STATE_ALL 0xFFFFFFFF
|
||||
|
||||
#define IPMIP6HA_ROUTE_STATE_IPV6 IPMIP6HA_ROUTE_STATE_BIT(IPMIP6HA_ROUTE_BIT_IPV6)
|
||||
#define IPMIP6HA_ROUTE_STATE_TUNNEL_IPV6 IPMIP6HA_ROUTE_STATE_BIT(IPMIP6HA_ROUTE_BIT_TUNNEL_IPV6)
|
||||
#define IPMIP6HA_ROUTE_STATE_NEMO_IPV6 IPMIP6HA_ROUTE_STATE_BIT(IPMIP6HA_ROUTE_BIT_IPV6_NEMO)
|
||||
#define IPMIP6HA_ROUTE_STATE_IPV4_NEMO IPMIP6HA_ROUTE_STATE_BIT(IPMIP6HA_ROUTE_BIT_IPV4_NEMO)
|
||||
#define IPMIP6HA_ROUTE_STATE_IPV4 IPMIP6HA_ROUTE_STATE_BIT(IPMIP6HA_ROUTE_BIT_IPV4)
|
||||
|
||||
#define IPMIP6HA_ROUTE_STATE_TRANSPORT (IPMIP6HA_ROUTE_STATE_ALL)
|
||||
|
||||
#define IPMIP6HA_ROUTE_PRIORITY_TUNNEL 98
|
||||
#define IPMIP6HA_ROUTE_PRIORITY_RO 99
|
||||
#define IPMIP6HA_ROUTE_PRIORITY_FORWARD 100
|
||||
#define IPMIP6HA_ROUTE_PRIORITY_PENDING 101
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
struct Ipmip6ha_context;
|
||||
struct Ipmip_proc;
|
||||
struct Ipmip6ha_node;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
IP_GLOBAL void ipmip6ha_route_state_del(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip6ha_node *node,
|
||||
Ip_u32 states);
|
||||
IP_GLOBAL void ipmip6ha_route_state_add(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip6ha_node *node,
|
||||
Ip_u32 states);
|
||||
|
||||
IP_GLOBAL void ipmip6ha_route_add_outbound(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip6ha_node *node,
|
||||
Ip_u64 octets,
|
||||
Ip_u64 pkts);
|
||||
|
||||
IP_GLOBAL void ipmip6ha_route_add_inbound(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip6ha_node *node,
|
||||
Ip_u64 octets,
|
||||
Ip_u64 pkts);
|
||||
|
||||
IP_GLOBAL Ip_bool ipmip6ha_route_update_temporary(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip6ha_pktbuf *pbuf,
|
||||
Ip_bool route_direct);
|
||||
|
||||
IP_GLOBAL void ipmip6ha_route_rthdr_temporary(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip6ha_if *ifp,
|
||||
struct Ip_in6_addr *hoa,
|
||||
union Ipmip6_mib_InetAddress *coa,
|
||||
Ip_u32 coa_type,
|
||||
Ip_u16 port);
|
||||
|
||||
IP_GLOBAL void ipmip6ha_route_direct_temporary(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip6ha_if *ifp,
|
||||
struct Ip_in6_addr *endpoint,
|
||||
union Ipmip6_mib_InetAddress *tunnel_endpoint,
|
||||
Ip_u32 tunnel_endpoint_type,
|
||||
Ip_u16 port);
|
||||
|
||||
|
||||
|
||||
IP_GLOBAL int ipmip6ha_netlink_new_handle(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip6ha_node *node);
|
||||
IP_GLOBAL int ipmip6ha_netlink_del_handle(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip6ha_node *node);
|
||||
IP_GLOBAL Ip_bool ipmip6ha_netlink_get_handle_stat(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip6ha_node *node);
|
||||
|
||||
|
||||
IP_GLOBAL void ipmip6ha_route_context_init(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc);
|
||||
IP_GLOBAL void ipmip6ha_route_context_destroy(struct Ipmip6ha_context *ctx,
|
||||
struct Ipmip_proc *proc);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
Reference in New Issue
Block a user