222 lines
7.5 KiB
C
222 lines
7.5 KiB
C
|
|
/*
|
|
******************************************************************************
|
|
* INTERPEAK SOURCE FILE
|
|
*
|
|
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip6ha_pmipv6_linklocal.c,v $ $Revision: 1.6 $
|
|
* $Source: /home/interpeak/CVSRoot/ipmip6ha/config/ipmip6ha_pmipv6_linklocal.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_hash.h>
|
|
#include <ipcom_inet.h>
|
|
#include <ipcom_ipd.h>
|
|
#include <ipcom_list.h>
|
|
#include <ipcom_os.h>
|
|
#include <ipcom_sock.h>
|
|
#include <ipcom_sock2.h>
|
|
#include <ipcom_syslog.h>
|
|
#include <ipcom_sysvar.h>
|
|
#include <ipcom_atomic.h>
|
|
|
|
#include <ipmip.h>
|
|
#include <private/ipmip_sysvar.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_attr_h.h"
|
|
#include "ipmip6ha_if.h"
|
|
#include "ipmip6ha_node.h"
|
|
#include "ipmip6ha_pktbuf.h"
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 4 DEFINES
|
|
****************************************************************************
|
|
*/
|
|
#define IPMIP6HA_PMIPV6_LINKLOCAL "LINKLOCAL"
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 5 TYPES
|
|
****************************************************************************
|
|
*/
|
|
typedef struct Ipmip6ha_pmipv6_linklocal_config
|
|
{
|
|
Ipcom_atomic_t counter;
|
|
} Ipmip6ha_pmipv6_linklocal_config_t;
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 6 EXTERN PROTOTYPES
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 7 LOCAL PROTOTYPES
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 8 DATA
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 9 STATIC FUNCTIONS
|
|
****************************************************************************
|
|
*/
|
|
IP_STATIC void
|
|
ipmip6ha_pmipv6_linklocal_config(struct Ipmip6ha_context *ctx,
|
|
struct Ipmip_proc *proc,
|
|
int action,
|
|
struct Ipmip6ha_if *ifp,
|
|
void *gcfg,
|
|
Ipmip6ha_pmipv6_linklocal_config_t *cfg,
|
|
Ipmip_cli_message_t *request)
|
|
{
|
|
IPMIP_UNUSED_PARAMETER(ctx);
|
|
IPMIP_UNUSED_PARAMETER(proc);
|
|
IPMIP_UNUSED_PARAMETER(ifp);
|
|
IPMIP_UNUSED_PARAMETER(gcfg);
|
|
|
|
if (action == IPMIP_CALLBACK_CONFIG_READ)
|
|
{
|
|
ipcom_atomic_set(&cfg->counter, 0);
|
|
}
|
|
else if (action == IPMIP_CALLBACK_CONFIG_FREE)
|
|
{
|
|
/* Do nothing */
|
|
}
|
|
else if (action == IPMIP_CALLBACK_CONFIG_DUMP)
|
|
{
|
|
IPMIP_UNUSED_PARAMETER(request);
|
|
}
|
|
}
|
|
|
|
|
|
IP_STATIC int
|
|
ipmip6ha_pmipv6_linklocal_provide(struct Ipmip6ha_context *ctx,
|
|
struct Ipmip_proc *proc,
|
|
int action,
|
|
void *gcfg,
|
|
Ipmip6ha_pmipv6_linklocal_config_t *cfg,
|
|
void *handle,
|
|
struct Ipmip6ha_node_P *node,
|
|
struct Ipmip_timer *service)
|
|
{
|
|
IPMIP_UNUSED_PARAMETER(service);
|
|
IPMIP_UNUSED_PARAMETER(cfg);
|
|
IPMIP_UNUSED_PARAMETER(handle);
|
|
IPMIP_UNUSED_PARAMETER(gcfg);
|
|
|
|
if (action == IPMIP_CALLBACK_ENABLE)
|
|
{
|
|
if (IP_IN6_IS_ADDR_UNSPECIFIED(&node->pmipv6_link_local_address.prefix))
|
|
{
|
|
Ip_u32 low;
|
|
|
|
while ((low = (Ip_u32)ipcom_atomic_add_and_return(&cfg->counter, 1)) == 0)
|
|
;
|
|
|
|
ipcom_memset(&node->pmipv6_link_local_address.prefix, 0, sizeof(node->pmipv6_link_local_address.prefix));
|
|
|
|
/**/
|
|
IP_SET_HTONS(&node->pmipv6_link_local_address.prefix.in6.addr16[0], 0xfe80);
|
|
IP_SET_HTONL(&node->pmipv6_link_local_address.prefix.in6.addr32[3], low);
|
|
|
|
IPMIP6_EVENT_IF(DEBUG2, proc,
|
|
ipmip_log_event_add(&ctx->ipmip6.ipmip,
|
|
proc,
|
|
"Generated Link-Local address %s for node %s",
|
|
ipmip_ntop_inet6(proc, &node->pmipv6_link_local_address.prefix, IP_NULL),
|
|
ipmip6ha_node_describe(proc, &node->node)));
|
|
}
|
|
}
|
|
else if (action == IPMIP_CALLBACK_DISABLE)
|
|
{
|
|
/* DO NOTHING */
|
|
}
|
|
|
|
/* Don't delay */
|
|
return IPMIP_CALLBACK_RET_SUCCESS;
|
|
}
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 10 GLOBAL FUNCTIONS
|
|
****************************************************************************
|
|
*/
|
|
|
|
IP_GLOBAL void ipmip6ha_pmipv6_linklocal_install(struct Ipmip6ha_context *ctx);
|
|
IP_GLOBAL void
|
|
ipmip6ha_pmipv6_linklocal_install(struct Ipmip6ha_context *ctx)
|
|
{
|
|
static Ipmip6ha_extension_t srv;
|
|
|
|
ipcom_memset(&srv, 0, sizeof(srv));
|
|
|
|
srv.name = IPMIP6HA_PMIPV6_LINKLOCAL;
|
|
srv.ifp_data_size = sizeof(Ipmip6ha_pmipv6_linklocal_config_t);
|
|
|
|
srv.config_ifp = (Ipmip6ha_extension_config_ifp_t)ipmip6ha_pmipv6_linklocal_config;
|
|
srv.provide = (Ipmip6ha_extension_provide_t)ipmip6ha_pmipv6_linklocal_provide;
|
|
|
|
/* This is a PMIP only feature */
|
|
ipmip6ha_context_register_extension(ctx, &srv, IP_FALSE, IP_TRUE);
|
|
}
|
|
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 11 PUBLIC FUNCTIONS
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
****************************************************************************
|
|
* END OF FILE
|
|
****************************************************************************
|
|
*/
|
|
|
|
|