/* ****************************************************************************** * INTERPEAK SOURCE FILE * * Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmipfa_regext_test.c,v $ $Revision: 1.4.16.1 $ * $Source: /home/interpeak/CVSRoot/ipmipfa/config/ipmipfa_regext_test.c,v $ * $Author: svc-cmnet $ * $State: Exp $ $Locker: $ * * INTERPEAK_COPYRIGHT_STRING * Design and implementation by Joel Hortelius ****************************************************************************** */ /* **************************************************************************** * 1 DESCRIPTION **************************************************************************** */ /* **************************************************************************** * 2 CONFIGURATION **************************************************************************** */ #include "ipmipfa_config.h" /* **************************************************************************** * 3 INCLUDE FILES **************************************************************************** */ #ifdef IPTESTENGINE #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 #include "ipmipfa.h" #include "ipmipfa_h.h" #include "ipmipfa_attr_h.h" #include "ipmipfa_if.h" #include "ipmipfa_node.h" #include "ipmipfa_pktbuf.h" /* **************************************************************************** * 4 DEFINES **************************************************************************** */ #define IPMIPFA_REGEXT_TEST_VENDOR_WR "VENDOR-WR" /* **************************************************************************** * 5 TYPES **************************************************************************** */ typedef struct Ipmipfa_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; } Ipmipfa_regext_test_vendor_ext_wr_config_ifp_t; /* **************************************************************************** * 6 EXTERN PROTOTYPES **************************************************************************** */ /* **************************************************************************** * 7 LOCAL PROTOTYPES **************************************************************************** */ /* **************************************************************************** * 8 DATA **************************************************************************** */ static Ipmipfa_extension_t ipmipfa_regext_test_srv_wr; static Ipmip4_msgext_vendor_parse_ext_t ipmipfa_regext_msgext_wr; /* **************************************************************************** * 9 STATIC FUNCTIONS **************************************************************************** */ IP_STATIC int ipmipfa_regext_test_vendor_wr_parse(Ipmipfa_data_t *ctx, Ipmip_proc_t *proc, Ipmipfa_pktbuf_t *pbuf, union Ipmip4_msgext_uhdr *uhdr, Ipmipfa_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_FA: /* Must be atleast 4 byte data */ if (sz < 4) return IPMIP4_REG_EXT_POORLY_FORMED; wr->cvse_noop_fa = uhdr; IPMIP4_EVENT_IF(INFO, proc, ipmip_log_event_add(&ctx->ipmip4.ipmip, proc, "Wind River Critical Vendor Extension Extension cvse_noop_fa")); 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_FA: /* Must be atleast 4 byte data */ if (sz < 4) return IPMIP4_REG_EXT_POORLY_FORMED; wr->nvse_noop_fa = uhdr; IPMIP4_EVENT_IF(INFO, proc, ipmip_log_event_add(&ctx->ipmip4.ipmip, proc, "Wind River Normal Vendor Extension Extension nvse_noop_fa")); 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 * ipmipfa_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 ipmipfa_regext_test_vendor_wr_req_forward(struct Ipmipfa_data *ctx, struct Ipmip_proc *proc, void *global_config, Ipmipfa_regext_test_vendor_ext_wr_config_ifp_t *ifp_config, void *node_config, struct Ipmipfa_node *node, struct Ipmipfa_pktbuf *pbuf) { IPMIP_UNUSED_PARAMETER(ctx); IPMIP_UNUSED_PARAMETER(proc); IPMIP_UNUSED_PARAMETER(global_config); IPMIP_UNUSED_PARAMETER(node_config); IPMIP_UNUSED_PARAMETER(node); 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 ipmipfa_regext_test_vendor_wr_rep_forward(struct Ipmipfa_data *ctx, struct Ipmip_proc *proc, void *global_config, Ipmipfa_regext_test_vendor_ext_wr_config_ifp_t *ifp_config, void *node_config, struct Ipmipfa_node *node, struct Ipmipfa_pktbuf *pbuf) { IPMIP_UNUSED_PARAMETER(ctx); IPMIP_UNUSED_PARAMETER(proc); IPMIP_UNUSED_PARAMETER(global_config); IPMIP_UNUSED_PARAMETER(node_config); IPMIP_UNUSED_PARAMETER(node); 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 ipmipfa_regext_test_vendor_wr_config(struct Ipmipfa_data *ctx, struct Ipmip_proc *proc, int action, struct Ipmipfa_iff *ifp, void *gcfg, Ipmipfa_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 = ipmipfa_regext_test_vendor_wr_vse_wr(IP_FALSE, IPMIP4_VENDOR_EXT_MSGEXT_WINDRIVER_NOOP_MN, "ipmipfa.if.%s.nvse.wr.mn", ifp->iff.ipmip.ifname); cfg->cvse_noop_mn = ipmipfa_regext_test_vendor_wr_vse_wr(IP_TRUE, IPMIP4_VENDOR_EXT_MSGEXT_WINDRIVER_NOOP_MN, "ipmipfa.if.%s.cvse.wr.mn", ifp->iff.ipmip.ifname); cfg->nvse_noop_ha = ipmipfa_regext_test_vendor_wr_vse_wr(IP_FALSE, IPMIP4_VENDOR_EXT_MSGEXT_WINDRIVER_NOOP_HA, "ipmipfa.if.%s.nvse.wr.ha", ifp->iff.ipmip.ifname); cfg->cvse_noop_ha = ipmipfa_regext_test_vendor_wr_vse_wr(IP_TRUE, IPMIP4_VENDOR_EXT_MSGEXT_WINDRIVER_NOOP_HA, "ipmipfa.if.%s.cvse.wr.ha", ifp->iff.ipmip.ifname); cfg->nvse_noop_fa = ipmipfa_regext_test_vendor_wr_vse_wr(IP_FALSE, IPMIP4_VENDOR_EXT_MSGEXT_WINDRIVER_NOOP_FA, "ipmipfa.if.%s.nvse.wr.fa", ifp->iff.ipmip.ifname); cfg->cvse_noop_fa = ipmipfa_regext_test_vendor_wr_vse_wr(IP_TRUE, IPMIP4_VENDOR_EXT_MSGEXT_WINDRIVER_NOOP_FA, "ipmipfa.if.%s.cvse.wr.fa", ifp->iff.ipmip.ifname); cfg->nvse_noop_all = ipmipfa_regext_test_vendor_wr_vse_wr(IP_FALSE, IPMIP4_VENDOR_EXT_MSGEXT_WINDRIVER_NOOP_ALL, "ipmipfa.if.%s.nvse.wr.all", ifp->iff.ipmip.ifname); cfg->cvse_noop_all = ipmipfa_regext_test_vendor_wr_vse_wr(IP_TRUE, IPMIP4_VENDOR_EXT_MSGEXT_WINDRIVER_NOOP_ALL, "ipmipfa.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 ipmipfa_regext_test_install(void); IP_GLOBAL void ipmipfa_regext_test_install(void) { ipcom_memset(&ipmipfa_regext_test_srv_wr, 0, sizeof(ipmipfa_regext_test_srv_wr)); ipmipfa_regext_test_srv_wr.name = IPMIPFA_REGEXT_TEST_VENDOR_WR; ipmipfa_regext_test_srv_wr.ifp_data_size = sizeof(Ipmipfa_regext_test_vendor_ext_wr_config_ifp_t); ipmipfa_regext_test_srv_wr.config_ifp = (Ipmipfa_extension_config_ifp_t)ipmipfa_regext_test_vendor_wr_config; ipmipfa_regext_test_srv_wr.pkt_rep_forward = (Ipmipfa_extension_pkt_rep_forward_t)ipmipfa_regext_test_vendor_wr_rep_forward; ipmipfa_regext_test_srv_wr.pkt_req_forward = (Ipmipfa_extension_pkt_req_forward_t)ipmipfa_regext_test_vendor_wr_req_forward; ipmipfa_context_register_extension(&ipmipfa_regext_test_srv_wr, IPMIPFA_FUNCTION_REGEXT); ipcom_memset(&ipmipfa_regext_msgext_wr, 0, sizeof(ipmipfa_regext_msgext_wr)); ipmipfa_regext_msgext_wr.vendor_id = IPMIP_SMI_WIND_RIVER; ipmipfa_regext_msgext_wr.parse = (Ipmip4_msgext_parse_ext_t) ipmipfa_regext_test_vendor_wr_parse; ipmipfa_regext_msgext_wr.pktaux.pktbuf_data_size = sizeof(Ipmipfa_regext_test_vendor_ext_wr_config_ifp_t); ipmipfa_msgext_vendor_parse_ext_register(&ipmipfa_regext_msgext_wr); } #else IP_GLOBAL void ipmipfa_regext_test_install(void); IP_GLOBAL void ipmipfa_regext_test_install(void) { } #endif /* **************************************************************************** * 11 PUBLIC FUNCTIONS **************************************************************************** */ /* **************************************************************************** * END OF FILE **************************************************************************** */