/* ****************************************************************************** * INTERPEAK SOURCE FILE * * Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmipmn_regext_test.c,v $ $Revision: 1.4.16.1 $ * $Source: /home/interpeak/CVSRoot/ipmipmn/config/ipmipmn_regext_test.c,v $ * $Author: svc-cmnet $ * $State: Exp $ $Locker: $ * * INTERPEAK_COPYRIGHT_STRING * Design and implementation by Joel Hortelius ****************************************************************************** */ /* **************************************************************************** * 1 DESCRIPTION **************************************************************************** */ /* **************************************************************************** * 2 CONFIGURATION **************************************************************************** */ #include "ipmipmn_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 "ipmipmn.h" #include "ipmipmn_h.h" #include "ipmipmn_attr_h.h" #include "ipmipmn_pktbuf.h" #include "ipmipmn_if.h" #include "ipmipmn_node.h" /* **************************************************************************** * 4 DEFINES **************************************************************************** */ #define IPMIPMN_REGEXT_TEST_VENDOR_WR "VENDOR-WR" /* **************************************************************************** * 5 TYPES **************************************************************************** */ typedef struct Ipmipmn_regext_test_vendor_ext_wr_config_instance { 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; } Ipmipmn_regext_test_vendor_ext_wr_config_instance_t; /* **************************************************************************** * 6 EXTERN PROTOTYPES **************************************************************************** */ /* **************************************************************************** * 7 LOCAL PROTOTYPES **************************************************************************** */ /* **************************************************************************** * 8 DATA **************************************************************************** */ static Ipmipmn_api_extension_t ipmipmn_regext_test_srv_wr; static Ipmip4_msgext_vendor_parse_ext_t ipmipmn_regext_msgext_wr; /* **************************************************************************** * 9 STATIC FUNCTIONS **************************************************************************** */ IP_STATIC int ipmipmn_regext_test_vendor_wr_parse(Ipmipmn_context_t *ctx, Ipmip_proc_t *proc, Ipmipmn_pktbuf_t *pbuf, union Ipmip4_msgext_uhdr *uhdr, Ipmipmn_regext_test_vendor_ext_wr_config_instance_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_MN: /* Must be atleast 4 byte data */ if (sz < 4) return IPMIP4_REG_EXT_POORLY_FORMED; wr->cvse_noop_mn = uhdr; IPMIP4_EVENT_IF(INFO, proc, ipmip_log_event_add(&ctx->api.ipmip4.ipmip, proc, "Wind River Critical Vendor Extension Extension cvse_noop_mn")); 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->api.ipmip4.ipmip, proc, "Wind River Critical Vendor Extension Extension cvse_noop_all")); break; default: IPMIP4_EVENT_IF(INFO, proc, ipmip_log_event_add(&ctx->api.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_MN: /* Must be atleast 4 byte data */ if (sz < 4) return IPMIP4_REG_EXT_POORLY_FORMED; wr->nvse_noop_mn = uhdr; IPMIP4_EVENT_IF(INFO, proc, ipmip_log_event_add(&ctx->api.ipmip4.ipmip, proc, "Wind River Normal Vendor Extension Extension nvse_noop_mn")); 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->api.ipmip4.ipmip, proc, "Wind River Normal Vendor Extension Extension nvse_noop_all")); break; default: IPMIP4_EVENT_IF(INFO, proc, ipmip_log_event_add(&ctx->api.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 * ipmipmn_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 ipmipmn_regext_test_vendor_wr_req_mobile_home(struct Ipmipmn_context *ctx, struct Ipmip_proc *proc, struct Ipmipmn_api_node_conf *conf, Ipmipmn_regext_test_vendor_ext_wr_config_instance_t *inst_config, void *node_config, struct Ipmipmn_node *node, Ip_bool deregister, struct Ipmipmn_pktbuf *pbuf) { IPMIP_UNUSED_PARAMETER(ctx); IPMIP_UNUSED_PARAMETER(proc); IPMIP_UNUSED_PARAMETER(conf); IPMIP_UNUSED_PARAMETER(deregister); IPMIP_UNUSED_PARAMETER(node_config); IPMIP_UNUSED_PARAMETER(node); if (inst_config->nvse_noop_mn) ipmip4_msgext_buffer_append_shdr(&pbuf->api.ipmip4.ipmip.packet, inst_config->nvse_noop_mn); if (inst_config->cvse_noop_mn) ipmip4_msgext_buffer_append_lhdr(&pbuf->api.ipmip4.ipmip.packet, inst_config->cvse_noop_mn); if (inst_config->nvse_noop_ha) ipmip4_msgext_buffer_append_shdr(&pbuf->api.ipmip4.ipmip.packet, inst_config->nvse_noop_ha); if (inst_config->cvse_noop_ha) ipmip4_msgext_buffer_append_lhdr(&pbuf->api.ipmip4.ipmip.packet, inst_config->cvse_noop_ha); if (inst_config->nvse_noop_fa) ipmip4_msgext_buffer_append_shdr(&pbuf->api.ipmip4.ipmip.packet, inst_config->nvse_noop_fa); if (inst_config->cvse_noop_fa) ipmip4_msgext_buffer_append_lhdr(&pbuf->api.ipmip4.ipmip.packet, inst_config->cvse_noop_fa); if (inst_config->nvse_noop_all) ipmip4_msgext_buffer_append_shdr(&pbuf->api.ipmip4.ipmip.packet, inst_config->nvse_noop_all); if (inst_config->cvse_noop_all) ipmip4_msgext_buffer_append_lhdr(&pbuf->api.ipmip4.ipmip.packet, inst_config->cvse_noop_all); } IP_STATIC void ipmipmn_regext_test_vendor_wr_config(struct Ipmipmn_context *ctx, struct Ipmip_proc *proc, int action, const char *pre, const char *spec, struct Ipmipmn_api_node_conf *conf, Ipmipmn_regext_test_vendor_ext_wr_config_instance_t *inst_config, Ipmip_cli_message_t *request) { IPMIP_UNUSED_PARAMETER(ctx); IPMIP_UNUSED_PARAMETER(proc); IPMIP_UNUSED_PARAMETER(conf); IPMIP_UNUSED_PARAMETER(request); if (action == IPMIP_CALLBACK_CONFIG_READ) { inst_config->nvse_noop_mn = ipmipmn_regext_test_vendor_wr_vse_wr(IP_FALSE, IPMIP4_VENDOR_EXT_MSGEXT_WINDRIVER_NOOP_MN, "%s.%snvse.wr.mn", pre, spec); inst_config->cvse_noop_mn = ipmipmn_regext_test_vendor_wr_vse_wr(IP_TRUE, IPMIP4_VENDOR_EXT_MSGEXT_WINDRIVER_NOOP_MN, "%s.%scvse.wr.mn", pre, spec); inst_config->nvse_noop_ha = ipmipmn_regext_test_vendor_wr_vse_wr(IP_FALSE, IPMIP4_VENDOR_EXT_MSGEXT_WINDRIVER_NOOP_HA, "%s.%snvse.wr.ha", pre, spec); inst_config->cvse_noop_ha = ipmipmn_regext_test_vendor_wr_vse_wr(IP_TRUE, IPMIP4_VENDOR_EXT_MSGEXT_WINDRIVER_NOOP_HA, "%s.%scvse.wr.ha", pre, spec); inst_config->nvse_noop_fa = ipmipmn_regext_test_vendor_wr_vse_wr(IP_FALSE, IPMIP4_VENDOR_EXT_MSGEXT_WINDRIVER_NOOP_FA, "%s.%snvse.wr.fa", pre, spec); inst_config->cvse_noop_fa = ipmipmn_regext_test_vendor_wr_vse_wr(IP_TRUE, IPMIP4_VENDOR_EXT_MSGEXT_WINDRIVER_NOOP_FA, "%s.%scvse.wr.fa", pre, spec); inst_config->nvse_noop_all = ipmipmn_regext_test_vendor_wr_vse_wr(IP_FALSE, IPMIP4_VENDOR_EXT_MSGEXT_WINDRIVER_NOOP_ALL, "%s.%snvse.wr.all", pre, spec); inst_config->cvse_noop_all = ipmipmn_regext_test_vendor_wr_vse_wr(IP_TRUE, IPMIP4_VENDOR_EXT_MSGEXT_WINDRIVER_NOOP_ALL, "%s.%scvse.wr.all", pre, spec); } else if (action == IPMIP_CALLBACK_CONFIG_FREE) { if (inst_config->nvse_noop_mn) ipcom_free(inst_config->nvse_noop_mn); if (inst_config->cvse_noop_mn) ipcom_free(inst_config->cvse_noop_mn); if (inst_config->nvse_noop_ha) ipcom_free(inst_config->nvse_noop_ha); if (inst_config->cvse_noop_ha) ipcom_free(inst_config->cvse_noop_ha); if (inst_config->nvse_noop_fa) ipcom_free(inst_config->nvse_noop_fa); if (inst_config->cvse_noop_fa) ipcom_free(inst_config->cvse_noop_fa); if (inst_config->nvse_noop_all) ipcom_free(inst_config->nvse_noop_all); if (inst_config->cvse_noop_all) ipcom_free(inst_config->cvse_noop_all); } else if (action == IPMIP_CALLBACK_CONFIG_DUMP) { /* Could dump, but dont bother */ } } /* **************************************************************************** * 10 GLOBAL FUNCTIONS **************************************************************************** */ IP_GLOBAL void ipmipmn_regext_test_install(void); IP_GLOBAL void ipmipmn_regext_test_install(void) { ipcom_memset(&ipmipmn_regext_test_srv_wr, 0, sizeof(ipmipmn_regext_test_srv_wr)); ipmipmn_regext_test_srv_wr.name = IPMIPMN_REGEXT_TEST_VENDOR_WR; ipmipmn_regext_test_srv_wr.instance_data_size = sizeof(Ipmipmn_regext_test_vendor_ext_wr_config_instance_t); ipmipmn_regext_test_srv_wr.config_instance = (Ipmipmn_api_extension_config_instance_t)ipmipmn_regext_test_vendor_wr_config; ipmipmn_regext_test_srv_wr.pkt_req_mobile_home = (Ipmipmn_api_extension_pkt_req_mobile_home_t)ipmipmn_regext_test_vendor_wr_req_mobile_home; ipmipmn_context_register_function(&ipmipmn_regext_test_srv_wr); ipcom_memset(&ipmipmn_regext_msgext_wr, 0, sizeof(ipmipmn_regext_msgext_wr)); ipmipmn_regext_msgext_wr.vendor_id = IPMIP_SMI_WIND_RIVER; ipmipmn_regext_msgext_wr.parse = (Ipmip4_msgext_parse_ext_t) ipmipmn_regext_test_vendor_wr_parse; ipmipmn_regext_msgext_wr.pktaux.pktbuf_data_size = sizeof(Ipmipmn_regext_test_vendor_ext_wr_config_instance_t); ipmipmn_msgext_vendor_parse_ext_register(&ipmipmn_regext_msgext_wr); } #else IP_GLOBAL void ipmipmn_regext_test_install(void); IP_GLOBAL void ipmipmn_regext_test_install(void) { } #endif /* **************************************************************************** * 11 PUBLIC FUNCTIONS **************************************************************************** */ /* **************************************************************************** * END OF FILE **************************************************************************** */