uint32_t cpa_mds_register(CPA_CB *cb) { NCSMDS_INFO svc_info; MDS_SVC_ID subs_id[2] = { NCSMDS_SVC_ID_CPND, NCSMDS_SVC_ID_CPD }; uint32_t rc = NCSCC_RC_SUCCESS; TRACE_ENTER(); /* STEP1: Get the MDS Handle */ if (cpa_mds_get_handle(cb) != NCSCC_RC_SUCCESS) return NCSCC_RC_FAILURE; /* memset the svc_info */ memset(&svc_info, 0, sizeof(NCSMDS_INFO)); /* STEP 2 : Install on ADEST with MDS with service ID NCSMDS_SVC_ID_CPA. */ svc_info.i_mds_hdl = cb->cpa_mds_hdl; svc_info.i_svc_id = NCSMDS_SVC_ID_CPA; svc_info.i_op = MDS_INSTALL; svc_info.info.svc_install.i_yr_svc_hdl = cb->agent_handle_id; svc_info.info.svc_install.i_install_scope = NCSMDS_SCOPE_NONE; /* node specific */ svc_info.info.svc_install.i_svc_cb = cpa_mds_callback; /* callback */ svc_info.info.svc_install.i_mds_q_ownership = false; /* CPA owns the mds queue */ svc_info.info.svc_install.i_mds_svc_pvt_ver = CPA_MDS_PVT_SUBPART_VERSION; /* Private Subpart Version of CPA for Versioning infrastructure */ if ((rc = ncsmds_api(&svc_info)) != NCSCC_RC_SUCCESS) { TRACE_4("CPA MDS:INSTALL failed with return value:%d",rc); return rc; } cb->cpa_mds_dest = svc_info.info.svc_install.o_dest; /* STEP 3: Subscribe to CPND up/down events */ svc_info.i_op = MDS_SUBSCRIBE; svc_info.info.svc_subscribe.i_num_svcs = 1; svc_info.info.svc_subscribe.i_scope = NCSMDS_SCOPE_NONE; svc_info.info.svc_subscribe.i_svc_ids = &subs_id[0]; if ((rc = ncsmds_api(&svc_info)) != NCSCC_RC_SUCCESS) { TRACE_4("CPA MDS:SUBSCRIBE failed with return value:%d",rc); goto error; } return NCSCC_RC_SUCCESS; error: /* Uninstall with the mds */ cpa_mds_unregister(cb); TRACE_LEAVE2("retval = %u", rc); return NCSCC_RC_FAILURE; }
uns32 cpa_mds_register(CPA_CB *cb) { NCSMDS_INFO svc_info; MDS_SVC_ID subs_id[2] = { NCSMDS_SVC_ID_CPND, NCSMDS_SVC_ID_CPD }; uns32 rc = NCSCC_RC_SUCCESS; /* STEP1: Get the MDS Handle */ if (cpa_mds_get_handle(cb) != NCSCC_RC_SUCCESS) return NCSCC_RC_FAILURE; /* memset the svc_info */ memset(&svc_info, 0, sizeof(NCSMDS_INFO)); /* STEP 2 : Install on ADEST with MDS with service ID NCSMDS_SVC_ID_CPA. */ svc_info.i_mds_hdl = cb->cpa_mds_hdl; svc_info.i_svc_id = NCSMDS_SVC_ID_CPA; svc_info.i_op = MDS_INSTALL; svc_info.info.svc_install.i_yr_svc_hdl = cb->agent_handle_id; svc_info.info.svc_install.i_install_scope = NCSMDS_SCOPE_NONE; /* node specific */ svc_info.info.svc_install.i_svc_cb = cpa_mds_callback; /* callback */ svc_info.info.svc_install.i_mds_q_ownership = FALSE; /* CPA owns the mds queue */ svc_info.info.svc_install.i_mds_svc_pvt_ver = CPA_MDS_PVT_SUBPART_VERSION; /* Private Subpart Version of CPA for Versioning infrastructure */ if ((rc = ncsmds_api(&svc_info)) != NCSCC_RC_SUCCESS) { m_LOG_CPA_CCLL(CPA_API_FAILED, NCSFL_LC_CKPT_MGMT, NCSFL_SEV_ERROR, "MDS:INSTALL", __FILE__, __LINE__, rc); return rc; } cb->cpa_mds_dest = svc_info.info.svc_install.o_dest; /* STEP 3: Subscribe to CPND up/down events */ svc_info.i_op = MDS_SUBSCRIBE; svc_info.info.svc_subscribe.i_num_svcs = 1; svc_info.info.svc_subscribe.i_scope = NCSMDS_SCOPE_NONE; svc_info.info.svc_subscribe.i_svc_ids = &subs_id[0]; if ((rc = ncsmds_api(&svc_info)) != NCSCC_RC_SUCCESS) { m_LOG_CPA_CCLL(CPA_API_FAILED, NCSFL_LC_CKPT_MGMT, NCSFL_SEV_ERROR, "MDS:SUBSCRIBE", __FILE__, __LINE__, rc); goto error; } return NCSCC_RC_SUCCESS; error: /* Uninstall with the mds */ cpa_mds_unregister(cb); return NCSCC_RC_FAILURE; }