Files
m241Neelima/components/ip_net2-6.9/ipmipha/config/ipmipha_regext_test.c
T
2026-07-30 11:19:44 +05:30

405 lines
17 KiB
C

/*
******************************************************************************
* INTERPEAK SOURCE FILE
*
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmipha_regext_test.c,v $ $Revision: 1.3.16.1 $
* $Source: /home/interpeak/CVSRoot/ipmipha/config/ipmipha_regext_test.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 "ipmipha_config.h"
/*
****************************************************************************
* 3 INCLUDE FILES
****************************************************************************
*/
#ifdef IPTESTENGINE
#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_radvd.h>
#include <ipmip.h>
#include <private/ipmip_util.h>
#include <private/ipmip_sysvar.h>
#include <ipmip4.h>
#include <private/ipmip4_context.h>
#include <private/ipmip4_util.h>
#include <private/ipmip4_sysext.h>
#include "ipmipha.h"
#include "ipmipha_h.h"
#include "ipmipha_attr_h.h"
#include "ipmipha_if.h"
#include "ipmipha_node.h"
#include "ipmipha_pktbuf.h"
/*
****************************************************************************
* 4 DEFINES
****************************************************************************
*/
#define IPMIPHA_REGEXT_TEST_VENDOR_WR "VENDOR-WR"
/*
****************************************************************************
* 5 TYPES
****************************************************************************
*/
typedef struct Ipmipha_regext_test_vendor_ext_wr_config_ifp
{
union Ipmip4_msgext_uhdr *nvse_noop_mn;
union Ipmip4_msgext_uhdr *nvse_noop_fa;
union Ipmip4_msgext_uhdr *nvse_noop_ha;
union Ipmip4_msgext_uhdr *nvse_noop_all;
union Ipmip4_msgext_uhdr *cvse_noop_mn;
union Ipmip4_msgext_uhdr *cvse_noop_fa;
union Ipmip4_msgext_uhdr *cvse_noop_ha;
union Ipmip4_msgext_uhdr *cvse_noop_all;
} Ipmipha_regext_test_vendor_ext_wr_config_ifp_t;
/*
****************************************************************************
* 6 EXTERN PROTOTYPES
****************************************************************************
*/
/*
****************************************************************************
* 7 LOCAL PROTOTYPES
****************************************************************************
*/
/*
****************************************************************************
* 8 DATA
****************************************************************************
*/
static Ipmipha_extension_t ipmipha_regext_test_srv_wr;
static Ipmip4_msgext_vendor_parse_ext_t ipmipha_regext_msgext_wr;
/*
****************************************************************************
* 9 STATIC FUNCTIONS
****************************************************************************
*/
IP_STATIC int
ipmipha_regext_test_vendor_wr_parse(Ipmipha_data_t *ctx,
Ipmip_proc_t *proc,
Ipmipha_pktbuf_t *pbuf,
union Ipmip4_msgext_uhdr *uhdr,
Ipmipha_regext_test_vendor_ext_wr_config_ifp_t *wr)
{
Ip_size_t sz;
IPMIP_UNUSED_PARAMETER(pbuf);
/* There are no CISCO CVSE's */
if (IPMIP4_MSGEXT_UHDR_TYPE(uhdr) == IPMIP4_EXT_TYPE_CVSE)
{
Ipmip4_cvse_t *vse;
/* Get the CVSE data */
vse = (void *)IPMIP4_MSGEXT_LHDR_EXT_DATA(uhdr);
sz = IPMIP4_MSGEXT_CVSE_EXT_SIZE(uhdr);
switch (IP_GET_NTOHS(&vse->vendor_type))
{
case IPMIP4_VENDOR_EXT_MSGEXT_WINDRIVER_NOOP_HA:
/* Must be atleast 4 byte data */
if (sz < 4)
return IPMIP4_REG_EXT_POORLY_FORMED;
wr->cvse_noop_ha = uhdr;
IPMIP4_EVENT_IF(INFO, proc,
ipmip_log_event_add(&ctx->ipmip4.ipmip,
proc,
"Wind River Critical Vendor Extension Extension cvse_noop_ha"));
break;
case IPMIP4_VENDOR_EXT_MSGEXT_WINDRIVER_NOOP_ALL:
/* Must be atleast 4 byte data */
if (sz < 4)
return IPMIP4_REG_EXT_POORLY_FORMED;
wr->cvse_noop_all = uhdr;
IPMIP4_EVENT_IF(INFO, proc,
ipmip_log_event_add(&ctx->ipmip4.ipmip,
proc,
"Wind River Critical Vendor Extension Extension cvse_noop_all"));
break;
default:
IPMIP4_EVENT_IF(INFO, proc,
ipmip_log_event_add(&ctx->ipmip4.ipmip,
proc,
"Unknown Wind River Critical Vendor Extension Extension %d", IP_GET_NTOHS(&vse->vendor_type)));
return IPMIP4_REG_EXT_UNKNOWN_VSE;
}
}
else
{
Ipmip4_nvse_t *vse;
/* Get the NVSE data */
vse = (void *)IPMIP4_MSGEXT_SHDR_EXT_DATA(uhdr);
sz = IPMIP4_MSGEXT_NVSE_EXT_SIZE(uhdr);
switch (IP_GET_NTOHS(&vse->vendor_type))
{
case IPMIP4_VENDOR_EXT_MSGEXT_WINDRIVER_NOOP_HA:
/* Must be atleast 4 byte data */
if (sz < 4)
return IPMIP4_REG_EXT_POORLY_FORMED;
wr->nvse_noop_ha = uhdr;
IPMIP4_EVENT_IF(INFO, proc,
ipmip_log_event_add(&ctx->ipmip4.ipmip,
proc,
"Wind River Normal Vendor Extension Extension nvse_noop_ha"));
break;
case IPMIP4_VENDOR_EXT_MSGEXT_WINDRIVER_NOOP_ALL:
/* Must be atleast 4 byte data */
if (sz < 4)
return IPMIP4_REG_EXT_POORLY_FORMED;
wr->nvse_noop_all = uhdr;
IPMIP4_EVENT_IF(INFO, proc,
ipmip_log_event_add(&ctx->ipmip4.ipmip,
proc,
"Wind River Normal Vendor Extension Extension nvse_noop_all"));
break;
default:
IPMIP4_EVENT_IF(INFO, proc,
ipmip_log_event_add(&ctx->ipmip4.ipmip,
proc,
"Unknown Wind River Normal Vendor Extension Extension %d", IP_GET_NTOHS(&vse->vendor_type)));
return IPMIP4_REG_EXT_UNKNOWN_VSE;
}
}
return IPMIP4_REG_EXT_SUCCESS;
}
IP_STATIC Ipmip4_msgext_uhdr_t *
ipmipha_regext_test_vendor_wr_vse_wr(Ip_bool cvse,
Ip_u16 subtype,
const char *format,
...)
{
va_list ap;
char *value;
Ipmip4_msgext_uhdr_t *vse = IP_NULL;
va_start(ap, format);
value = ipmip_vsysvar(format, ap);
va_end(ap);
/**/
if (value)
{
if (cvse)
vse = ipmip4_sysext_cvse_alloc(IPMIP_SMI_WIND_RIVER,
subtype,
value,
ipcom_strlen(value));
else
vse = ipmip4_sysext_nvse_alloc(IPMIP_SMI_WIND_RIVER,
subtype,
value,
ipcom_strlen(value));
ipcom_free(value);
}
return vse;
}
IP_STATIC void
ipmipha_regext_test_vendor_wr_rep_mobile_home(struct Ipmipha_data *ctx,
struct Ipmip_proc *proc,
void *global_config,
Ipmipha_regext_test_vendor_ext_wr_config_ifp_t *ifp_config,
void *node_config,
struct Ipmipha_node *node,
struct Ipmipha_pktbuf *req_pbuf,
struct Ipmipha_pktbuf *pbuf)
{
IPMIP_UNUSED_PARAMETER(ctx);
IPMIP_UNUSED_PARAMETER(proc);
IPMIP_UNUSED_PARAMETER(global_config);
IPMIP_UNUSED_PARAMETER(node_config);
IPMIP_UNUSED_PARAMETER(node);
IPMIP_UNUSED_PARAMETER(req_pbuf);
if (ifp_config->nvse_noop_mn)
ipmip4_msgext_buffer_append_shdr(&pbuf->ipmip4.ipmip.packet, ifp_config->nvse_noop_mn);
if (ifp_config->cvse_noop_mn)
ipmip4_msgext_buffer_append_lhdr(&pbuf->ipmip4.ipmip.packet, ifp_config->cvse_noop_mn);
if (ifp_config->nvse_noop_ha)
ipmip4_msgext_buffer_append_shdr(&pbuf->ipmip4.ipmip.packet, ifp_config->nvse_noop_ha);
if (ifp_config->cvse_noop_ha)
ipmip4_msgext_buffer_append_lhdr(&pbuf->ipmip4.ipmip.packet, ifp_config->cvse_noop_ha);
if (ifp_config->nvse_noop_fa)
ipmip4_msgext_buffer_append_shdr(&pbuf->ipmip4.ipmip.packet, ifp_config->nvse_noop_fa);
if (ifp_config->cvse_noop_fa)
ipmip4_msgext_buffer_append_lhdr(&pbuf->ipmip4.ipmip.packet, ifp_config->cvse_noop_fa);
if (ifp_config->nvse_noop_all)
ipmip4_msgext_buffer_append_shdr(&pbuf->ipmip4.ipmip.packet, ifp_config->nvse_noop_all);
if (ifp_config->cvse_noop_all)
ipmip4_msgext_buffer_append_lhdr(&pbuf->ipmip4.ipmip.packet, ifp_config->cvse_noop_all);
}
IP_STATIC void
ipmipha_regext_test_vendor_wr_config(struct Ipmipha_data *ctx,
struct Ipmip_proc *proc,
int action,
struct Ipmipha_iff *ifp,
void *gcfg,
Ipmipha_regext_test_vendor_ext_wr_config_ifp_t *cfg,
Ipmip_cli_message_t *request)
{
IPMIP_UNUSED_PARAMETER(ctx);
IPMIP_UNUSED_PARAMETER(proc);
IPMIP_UNUSED_PARAMETER(gcfg);
IPMIP_UNUSED_PARAMETER(request);
if (action == IPMIP_CALLBACK_CONFIG_READ)
{
cfg->nvse_noop_mn = ipmipha_regext_test_vendor_wr_vse_wr(IP_FALSE,
IPMIP4_VENDOR_EXT_MSGEXT_WINDRIVER_NOOP_MN,
"ipmipha.if.%s.nvse.wr.mn",
ifp->iff.ipmip.ifname);
cfg->cvse_noop_mn = ipmipha_regext_test_vendor_wr_vse_wr(IP_TRUE,
IPMIP4_VENDOR_EXT_MSGEXT_WINDRIVER_NOOP_MN,
"ipmipha.if.%s.cvse.wr.mn",
ifp->iff.ipmip.ifname);
cfg->nvse_noop_ha = ipmipha_regext_test_vendor_wr_vse_wr(IP_FALSE,
IPMIP4_VENDOR_EXT_MSGEXT_WINDRIVER_NOOP_HA,
"ipmipha.if.%s.nvse.wr.ha",
ifp->iff.ipmip.ifname);
cfg->cvse_noop_ha = ipmipha_regext_test_vendor_wr_vse_wr(IP_TRUE,
IPMIP4_VENDOR_EXT_MSGEXT_WINDRIVER_NOOP_HA,
"ipmipha.if.%s.cvse.wr.ha",
ifp->iff.ipmip.ifname);
cfg->nvse_noop_fa = ipmipha_regext_test_vendor_wr_vse_wr(IP_FALSE,
IPMIP4_VENDOR_EXT_MSGEXT_WINDRIVER_NOOP_FA,
"ipmipha.if.%s.nvse.wr.fa",
ifp->iff.ipmip.ifname);
cfg->cvse_noop_fa = ipmipha_regext_test_vendor_wr_vse_wr(IP_TRUE,
IPMIP4_VENDOR_EXT_MSGEXT_WINDRIVER_NOOP_FA,
"ipmipha.if.%s.cvse.wr.fa",
ifp->iff.ipmip.ifname);
cfg->nvse_noop_all = ipmipha_regext_test_vendor_wr_vse_wr(IP_FALSE,
IPMIP4_VENDOR_EXT_MSGEXT_WINDRIVER_NOOP_ALL,
"ipmipha.if.%s.nvse.wr.all",
ifp->iff.ipmip.ifname);
cfg->cvse_noop_all = ipmipha_regext_test_vendor_wr_vse_wr(IP_TRUE,
IPMIP4_VENDOR_EXT_MSGEXT_WINDRIVER_NOOP_ALL,
"ipmipha.if.%s.cvse.wr.all",
ifp->iff.ipmip.ifname);
}
else if (action == IPMIP_CALLBACK_CONFIG_FREE)
{
if (cfg->nvse_noop_mn)
ipcom_free(cfg->nvse_noop_mn);
if (cfg->cvse_noop_mn)
ipcom_free(cfg->cvse_noop_mn);
if (cfg->nvse_noop_ha)
ipcom_free(cfg->nvse_noop_ha);
if (cfg->cvse_noop_ha)
ipcom_free(cfg->cvse_noop_ha);
if (cfg->nvse_noop_fa)
ipcom_free(cfg->nvse_noop_fa);
if (cfg->cvse_noop_fa)
ipcom_free(cfg->cvse_noop_fa);
if (cfg->nvse_noop_all)
ipcom_free(cfg->nvse_noop_all);
if (cfg->cvse_noop_all)
ipcom_free(cfg->cvse_noop_all);
}
else if (action == IPMIP_CALLBACK_CONFIG_DUMP)
{
/* Could dump, but dont bother */
}
}
/*
****************************************************************************
* 10 GLOBAL FUNCTIONS
****************************************************************************
*/
IP_GLOBAL void ipmipha_regext_test_install(void);
IP_GLOBAL void
ipmipha_regext_test_install(void)
{
ipcom_memset(&ipmipha_regext_test_srv_wr, 0, sizeof(ipmipha_regext_test_srv_wr));
ipmipha_regext_test_srv_wr.name = IPMIPHA_REGEXT_TEST_VENDOR_WR;
ipmipha_regext_test_srv_wr.ifp_data_size = sizeof(Ipmipha_regext_test_vendor_ext_wr_config_ifp_t);
ipmipha_regext_test_srv_wr.config_ifp = (Ipmipha_extension_config_ifp_t)ipmipha_regext_test_vendor_wr_config;
ipmipha_regext_test_srv_wr.pkt_rep_mobile_home = (Ipmipha_extension_pkt_req_mobile_home_t)ipmipha_regext_test_vendor_wr_rep_mobile_home;
ipmipha_context_register_extension(&ipmipha_regext_test_srv_wr, IPMIPHA_FUNCTION_REGEXT);
ipcom_memset(&ipmipha_regext_msgext_wr, 0, sizeof(ipmipha_regext_msgext_wr));
ipmipha_regext_msgext_wr.vendor_id = IPMIP_SMI_WIND_RIVER;
ipmipha_regext_msgext_wr.parse = (Ipmip4_msgext_parse_ext_t) ipmipha_regext_test_vendor_wr_parse;
ipmipha_regext_msgext_wr.pktaux.pktbuf_data_size = sizeof(Ipmipha_regext_test_vendor_ext_wr_config_ifp_t);
ipmipha_msgext_vendor_parse_ext_register(&ipmipha_regext_msgext_wr);
}
#else
IP_GLOBAL void ipmipha_regext_test_install(void);
IP_GLOBAL void
ipmipha_regext_test_install(void)
{
}
#endif
/*
****************************************************************************
* 11 PUBLIC FUNCTIONS
****************************************************************************
*/
/*
****************************************************************************
* END OF FILE
****************************************************************************
*/