/* ****************************************************************************** * 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 ****************************************************************************** */ /* **************************************************************************** * 1 DESCRIPTION **************************************************************************** */ /* **************************************************************************** * 2 CONFIGURATION **************************************************************************** */ #include "ipmip6ha_config.h" /* **************************************************************************** * 3 INCLUDE FILES **************************************************************************** */ #define IPCOM_USE_CLIB_PROTO #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #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 **************************************************************************** */