/**************************************************************************** Name : mqnd_mds_dec Description : This function decodes an events sent to MQND. Arguments : cb : MQND control Block. info : Info for decoding Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE Notes : None. ******************************************************************************/ static uns32 mqnd_mds_dec(MQND_CB *cb, MDS_CALLBACK_DEC_INFO *dec_info) { MQSV_EVT *msg_ptr; EDU_ERR ederror = 0; uns32 rc = NCSCC_RC_SUCCESS; NCS_BOOL is_valid_msg_fmt; switch (dec_info->i_fr_svc_id) { case NCSMDS_SVC_ID_MQA: is_valid_msg_fmt = m_NCS_MSG_FORMAT_IS_VALID(dec_info->i_msg_fmt_ver, MQND_WRT_MQA_SUBPART_VER_AT_MIN_MSG_FMT, MQND_WRT_MQA_SUBPART_VER_AT_MAX_MSG_FMT, mqnd_mqa_msg_fmt_table); break; case NCSMDS_SVC_ID_MQND: is_valid_msg_fmt = m_NCS_MSG_FORMAT_IS_VALID(dec_info->i_msg_fmt_ver, MQND_WRT_MQND_SUBPART_VER_AT_MIN_MSG_FMT, MQND_WRT_MQND_SUBPART_VER_AT_MAX_MSG_FMT, mqnd_mqnd_msg_fmt_table); break; case NCSMDS_SVC_ID_MQD: is_valid_msg_fmt = m_NCS_MSG_FORMAT_IS_VALID(dec_info->i_msg_fmt_ver, MQND_WRT_MQD_SUBPART_VER_AT_MIN_MSG_FMT, MQND_WRT_MQD_SUBPART_VER_AT_MAX_MSG_FMT, mqnd_mqd_msg_fmt_table); break; default: return NCSCC_RC_FAILURE; } if (is_valid_msg_fmt && (dec_info->i_msg_fmt_ver != 1)) { msg_ptr = m_MMGR_ALLOC_MQSV_EVT(NCS_SERVICE_ID_MQND); if (!msg_ptr) { m_LOG_MQSV_ND(MQND_EVT_ALLOC_FAILED, NCSFL_LC_MQSV_INIT, NCSFL_SEV_ERROR, NCSCC_RC_FAILURE, __FILE__, __LINE__); return NCSCC_RC_FAILURE; } memset(msg_ptr, 0, sizeof(MQSV_EVT)); dec_info->o_msg = (NCSCONTEXT)msg_ptr; rc = m_NCS_EDU_EXEC(&cb->edu_hdl, mqsv_edp_mqsv_evt, dec_info->io_uba, EDP_OP_TYPE_DEC, (MQSV_EVT **)&dec_info->o_msg, &ederror); if (rc != NCSCC_RC_SUCCESS) { m_LOG_MQSV_ND(MQND_MDS_DEC_FAILED, NCSFL_LC_MQSV_INIT, NCSFL_SEV_ERROR, rc, __FILE__, __LINE__); m_MMGR_FREE_MQSV_EVT(dec_info->o_msg, NCS_SERVICE_ID_MQND); } return rc; } else { /* Drop The Message */ m_LOG_MQSV_ND(MQND_MSG_FRMT_VER_INVALID, NCSFL_LC_MQSV_INIT, NCSFL_SEV_ERROR, is_valid_msg_fmt, __FILE__, __LINE__); TRACE("mqnd_mds_dec:INVALID MSG FORMAT %d", is_valid_msg_fmt); return NCSCC_RC_FAILURE; } }
/************************************************************************************ * Name :glsv_gld_mbcsv_dec_sync_resp * * Description : Decode the message at Standby for cold sync and update the database * Arguments : NCS_MBCSV_CB_ARG - MBCSv callback argument * * Return Values : Success / Error *************************************************************************************/ static uint32_t glsv_gld_mbcsv_dec_sync_resp(GLSV_GLD_CB *gld_cb, NCS_MBCSV_CB_ARG *arg) { uint8_t *ptr, num_of_ckpts, data[16]; GLSV_GLD_A2S_RSC_DETAILS *rsc_info; uint32_t count = 0, rc = NCSCC_RC_SUCCESS, num_of_async_upd; EDU_ERR ederror = 0; GLSV_A2S_NODE_LIST *node_list, *tmp1_node_list; TRACE_ENTER(); if (arg->info.decode.i_uba.ub == NULL) { /* There is no data */ goto end; } /* Allocate memory */ rsc_info = m_MMGR_ALLOC_GLSV_GLD_A2S_RSC_DETAILS; if (rsc_info == NULL) { LOG_CR("Rsc info alloc failed: Error %s", strerror(errno)); assert(0); } memset(rsc_info, 0, sizeof(GLSV_GLD_A2S_RSC_DETAILS)); /* 1. Decode the 1st uint8_t region , we will get the num of ckpts */ ptr = ncs_dec_flatten_space(&arg->info.decode.i_uba, data, sizeof(uint8_t)); num_of_ckpts = ncs_decode_8bit(&ptr); ncs_dec_skip_space(&arg->info.decode.i_uba, sizeof(uint8_t)); /* Decode the data */ while (count < num_of_ckpts) { rc = m_NCS_EDU_EXEC(&gld_cb->edu_hdl, glsv_edp_gld_evt_a2s_rsc_details, &arg->info.decode.i_uba, EDP_OP_TYPE_DEC, &rsc_info, &ederror); if (rc != NCSCC_RC_SUCCESS) { goto end; } rc = gld_sb_proc_data_rsp(gld_cb, rsc_info); count++; memset(rsc_info, 0, sizeof(GLSV_GLD_A2S_RSC_DETAILS)); } /* Get the async update count */ ptr = ncs_dec_flatten_space(&arg->info.decode.i_uba, data, sizeof(uint32_t)); num_of_async_upd = ncs_decode_32bit(&ptr); gld_cb->gld_async_cnt = num_of_async_upd; /* New code */ node_list = rsc_info->node_list; while (node_list != NULL) { tmp1_node_list = node_list; node_list = node_list->next; m_MMGR_FREE_GLSV_NODE_LIST(tmp1_node_list); } m_MMGR_FREE_GLSV_GLD_A2S_RSC_DETAILS(rsc_info); end: TRACE_LEAVE(); return rc; }
/**************************************************************************** Name : cpa_mds_dec Description : This function decodes an events sent to CPA. Arguments : cb : CPA control Block. info : Info for decoding Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE Notes : None. ******************************************************************************/ static uint32_t cpa_mds_dec(CPA_CB *cb, MDS_CALLBACK_DEC_INFO *dec_info) { CPSV_EVT *msg_ptr = NULL; EDU_ERR ederror = 0; uint32_t rc = NCSCC_RC_SUCCESS; uint8_t local_data[20]; uint8_t *pstream; bool is_valid_msg_fmt = false; TRACE_ENTER(); if (dec_info->i_fr_svc_id == NCSMDS_SVC_ID_CPND) { is_valid_msg_fmt = m_NCS_MSG_FORMAT_IS_VALID(dec_info->i_msg_fmt_ver, CPA_WRT_CPND_SUBPART_VER_MIN, CPA_WRT_CPND_SUBPART_VER_MAX, cpa_cpnd_msg_fmt_table); } else if (dec_info->i_fr_svc_id == NCSMDS_SVC_ID_CPD) { is_valid_msg_fmt = m_NCS_MSG_FORMAT_IS_VALID(dec_info->i_msg_fmt_ver, CPA_WRT_CPD_SUBPART_VER_MIN, CPA_WRT_CPD_SUBPART_VER_MAX, cpa_cpd_msg_fmt_table); } if (is_valid_msg_fmt) { msg_ptr = m_MMGR_ALLOC_CPSV_EVT(NCS_SERVICE_ID_CPA); if (!msg_ptr) return NCSCC_RC_FAILURE; memset(msg_ptr, 0, sizeof(CPSV_EVT)); dec_info->o_msg = (NCSCONTEXT)msg_ptr; pstream = ncs_dec_flatten_space(dec_info->io_uba, local_data, 8); msg_ptr->type = ncs_decode_32bit(&pstream); if (msg_ptr->type == CPSV_EVT_TYPE_CPA) { /* For Events Write/Read Call EDU VER_EXEC*/ rc = m_NCS_EDU_VER_EXEC(&cb->edu_hdl, FUNC_NAME(CPSV_EVT), dec_info->io_uba, EDP_OP_TYPE_DEC, (CPSV_EVT **)&dec_info->o_msg, &ederror, dec_info->i_msg_fmt_ver); goto free; /* if(msg_ptr->info.cpa.type == CPA_EVT_ND2A_CKPT_DATA_RSP) */ } /* if( msg_ptr->type == CPSV_EVT_TYPE_CPA) */ /* For all Other Cases Other Than CPA( Read / Write Rsp Follow EDU rules */ rc = m_NCS_EDU_EXEC(&cb->edu_hdl, FUNC_NAME(CPSV_EVT), dec_info->io_uba, EDP_OP_TYPE_DEC, (CPSV_EVT **)&dec_info->o_msg, &ederror); free: if (rc != NCSCC_RC_SUCCESS) { m_MMGR_FREE_CPSV_EVT(dec_info->o_msg, NCS_SERVICE_ID_CPA); } TRACE_LEAVE(); return rc; } else { TRACE_4("CPA:Processing failed for mds_dec "); TRACE_LEAVE(); return NCSCC_RC_FAILURE; } }
/**************************************************************************** Name : cpa_mds_dec Description : This function decodes an events sent to CPA. Arguments : cb : CPA control Block. info : Info for decoding Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE Notes : None. ******************************************************************************/ static uns32 cpa_mds_dec(CPA_CB *cb, MDS_CALLBACK_DEC_INFO *dec_info) { CPSV_EVT *msg_ptr = NULL; EDU_ERR ederror = 0; uns32 rc = NCSCC_RC_SUCCESS; uns8 local_data[20]; uns8 *pstream; NCS_BOOL is_valid_msg_fmt = FALSE; if (dec_info->i_fr_svc_id == NCSMDS_SVC_ID_CPND) { is_valid_msg_fmt = m_NCS_MSG_FORMAT_IS_VALID(dec_info->i_msg_fmt_ver, CPA_WRT_CPND_SUBPART_VER_MIN, CPA_WRT_CPND_SUBPART_VER_MAX, cpa_cpnd_msg_fmt_table); } else if (dec_info->i_fr_svc_id == NCSMDS_SVC_ID_CPD) { is_valid_msg_fmt = m_NCS_MSG_FORMAT_IS_VALID(dec_info->i_msg_fmt_ver, CPA_WRT_CPD_SUBPART_VER_MIN, CPA_WRT_CPD_SUBPART_VER_MAX, cpa_cpd_msg_fmt_table); } if (is_valid_msg_fmt) { msg_ptr = m_MMGR_ALLOC_CPSV_EVT(NCS_SERVICE_ID_CPA); if (!msg_ptr) return NCSCC_RC_FAILURE; memset(msg_ptr, 0, sizeof(CPSV_EVT)); dec_info->o_msg = (NCSCONTEXT)msg_ptr; pstream = ncs_dec_flatten_space(dec_info->io_uba, local_data, 8); msg_ptr->type = ncs_decode_32bit(&pstream); if (msg_ptr->type == CPSV_EVT_TYPE_CPA) { msg_ptr->info.cpa.type = ncs_decode_32bit(&pstream); if (msg_ptr->info.cpa.type == CPA_EVT_ND2A_CKPT_DATA_RSP) { ncs_dec_skip_space(dec_info->io_uba, 8); rc = cpsv_data_access_rsp_decode(&msg_ptr->info.cpa.info.sec_data_rsp, dec_info->io_uba); goto free; } /* if(msg_ptr->info.cpa.type == CPA_EVT_ND2A_CKPT_DATA_RSP) */ } /* if( msg_ptr->type == CPSV_EVT_TYPE_CPA) */ /* For all Other Cases Other Than CPA( Read / Write Rsp Follow EDU rules */ rc = m_NCS_EDU_EXEC(&cb->edu_hdl, FUNC_NAME(CPSV_EVT), dec_info->io_uba, EDP_OP_TYPE_DEC, (CPSV_EVT **)&dec_info->o_msg, &ederror); free: if (rc != NCSCC_RC_SUCCESS) { m_MMGR_FREE_CPSV_EVT(dec_info->o_msg, NCS_SERVICE_ID_CPA); } return rc; } else { m_LOG_CPA_CCL(CPA_PROC_FAILED, NCSFL_LC_CKPT_MGMT, NCSFL_SEV_INFO, "mds_dec", __FILE__, __LINE__); return NCSCC_RC_FAILURE; } }
/**************************************************************************** Name : mqnd_mds_enc Description : This function encodes an events sent from MQND. Arguments : cb : MQND control Block. info : Info for encoding Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE Notes : None. ******************************************************************************/ static uns32 mqnd_mds_enc(MQND_CB *cb, MDS_CALLBACK_ENC_INFO *enc_info) { MQSV_EVT *msg_ptr; EDU_ERR ederror = 0; uns32 rc = NCSCC_RC_SUCCESS; msg_ptr = (MQSV_EVT *)enc_info->i_msg; /* Get the Msg Format version from the SERVICE_ID & RMT_SVC_PVT_SUBPART_VERSION */ switch (enc_info->i_to_svc_id) { case NCSMDS_SVC_ID_MQA: enc_info->o_msg_fmt_ver = m_NCS_ENC_MSG_FMT_GET(enc_info->i_rem_svc_pvt_ver, MQND_WRT_MQA_SUBPART_VER_AT_MIN_MSG_FMT, MQND_WRT_MQA_SUBPART_VER_AT_MAX_MSG_FMT, mqnd_mqa_msg_fmt_table); break; case NCSMDS_SVC_ID_MQND: enc_info->o_msg_fmt_ver = m_NCS_ENC_MSG_FMT_GET(enc_info->i_rem_svc_pvt_ver, MQND_WRT_MQND_SUBPART_VER_AT_MIN_MSG_FMT, MQND_WRT_MQND_SUBPART_VER_AT_MAX_MSG_FMT, mqnd_mqnd_msg_fmt_table); break; case NCSMDS_SVC_ID_MQD: enc_info->o_msg_fmt_ver = m_NCS_ENC_MSG_FMT_GET(enc_info->i_rem_svc_pvt_ver, MQND_WRT_MQD_SUBPART_VER_AT_MIN_MSG_FMT, MQND_WRT_MQD_SUBPART_VER_AT_MAX_MSG_FMT, mqnd_mqd_msg_fmt_table); break; default: return NCSCC_RC_FAILURE; } if (enc_info->o_msg_fmt_ver) { rc = (m_NCS_EDU_EXEC(&cb->edu_hdl, mqsv_edp_mqsv_evt, enc_info->io_uba, EDP_OP_TYPE_ENC, msg_ptr, &ederror)); if (rc != NCSCC_RC_SUCCESS) { m_LOG_MQSV_ND(MQND_MDS_ENC_FAILED, NCSFL_LC_MQSV_INIT, NCSFL_SEV_ERROR, rc, __FILE__, __LINE__); } return rc; } else { /* Drop The Message */ m_LOG_MQSV_ND(MQND_MSG_FRMT_VER_INVALID, NCSFL_LC_MQSV_INIT, NCSFL_SEV_ERROR, enc_info->o_msg_fmt_ver, __FILE__, __LINE__); TRACE("mqnd_mds_enc:INVALID MSG FORMAT %d", enc_info->o_msg_fmt_ver); return NCSCC_RC_FAILURE; } }
/**************************************************************************** Name : cpa_mds_enc Description : This function encodes an events sent from CPA to remote CPND. Arguments : cb : CPA control Block. info : Info for encoding Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE Notes : None. ******************************************************************************/ static uint32_t cpa_mds_enc(CPA_CB *cb, MDS_CALLBACK_ENC_INFO *enc_info) { CPSV_EVT *pevt = NULL; EDU_ERR ederror = 0; NCS_UBAID *io_uba = enc_info->io_uba; uint32_t rc = NCSCC_RC_SUCCESS; uint8_t *pstream = NULL; TRACE_ENTER(); /* Get the Msg Format version from the SERVICE_ID & RMT_SVC_PVT_SUBPART_VERSION */ if (enc_info->i_to_svc_id == NCSMDS_SVC_ID_CPND) { /* This is special case to handle the 4.2 deployed node upgrade , the 4.2 has inconsistency between `enc_info->i_rem_svc_pvt_ver` ( CPND_MDS_PVT_SUBPART_VERSION /CPA_MDS_PVT_SUBPART_VERSION ) and `cpa_cpnd_msg_fmt_table` ( CPND_WRT_CPND_SUBPART_VER_RANGE / CPND_WRT_CPA_SUBPART_VER_RANGE) For all other up coming version `m_NCS_ENC_MSG_FMT_GET` logic works fine */ if (enc_info->i_rem_svc_pvt_ver <= 3) /* opensaf 4.2 CPND_MDS_PVT_SUBPART_VERSION was 3 but CPND_WRT_CPND_SUBPART_VER_RANGE was 2 */ enc_info->o_msg_fmt_ver = cpa_cpnd_msg_fmt_table[enc_info->i_rem_svc_pvt_ver - 2]; else /* m_NCS_ENC_MSG_FMT_GET call is equal to cpa_cpnd_msg_fmt_table[enc_info->i_rem_svc_pvt_ver - 1] */ enc_info->o_msg_fmt_ver = m_NCS_ENC_MSG_FMT_GET(enc_info->i_rem_svc_pvt_ver, CPA_WRT_CPND_SUBPART_VER_MIN, CPA_WRT_CPND_SUBPART_VER_MAX, cpa_cpnd_msg_fmt_table); } if (enc_info->o_msg_fmt_ver) { pevt = (CPSV_EVT *)enc_info->i_msg; if (pevt->type == CPSV_EVT_TYPE_CPND) { if (pevt->info.cpnd.type == CPND_EVT_A2ND_CKPT_WRITE) { pstream = ncs_enc_reserve_space(io_uba, 12); if (!pstream) return m_CPSV_DBG_SINK(NCSCC_RC_FAILURE, "Memory alloc failed in cpa_mds_enc \n"); ncs_encode_32bit(&pstream, pevt->type); /* CPSV_EVT Type */ ncs_encode_32bit(&pstream, pevt->info.cpnd.error); /* cpnd_evt error This is for backword compatible purpose with EDU enc/dec with 3.0.2 */ ncs_encode_32bit(&pstream, pevt->info.cpnd.type); /* cpnd_evt SubType */ ncs_enc_claim_space(io_uba, 12); rc = cpsv_ckpt_access_encode(&pevt->info.cpnd.info.ckpt_write, io_uba); TRACE_LEAVE(); return rc; } else if (pevt->info.cpnd.type == CPND_EVT_A2ND_CKPT_READ) { pstream = ncs_enc_reserve_space(io_uba, 12); if (!pstream) return m_CPSV_DBG_SINK(NCSCC_RC_FAILURE, "Memory alloc failed in cpa_mds_enc \n"); ncs_encode_32bit(&pstream, pevt->type); /* CPSV_EVT Type */ ncs_encode_32bit(&pstream, pevt->info.cpnd.error); /* cpnd_evt error This is for backword compatible purpose with EDU enc/dec with 3.0.2 */ ncs_encode_32bit(&pstream, pevt->info.cpnd.type); /* cpnd_evt SubType */ ncs_enc_claim_space(io_uba, 12); rc = cpsv_ckpt_access_encode(&pevt->info.cpnd.info.ckpt_read, io_uba); TRACE_LEAVE(); return rc; } else if(pevt->info.cpnd.type == CPND_EVT_A2ND_CKPT_REFCNTSET) { if(enc_info->o_msg_fmt_ver < 2) { TRACE_LEAVE(); return NCSCC_RC_FAILURE; } else { pstream = ncs_enc_reserve_space(io_uba, 12); if(!pstream) return m_CPSV_DBG_SINK(NCSCC_RC_FAILURE,"Memory alloc failed in cpa_mds_enc \n"); ncs_encode_32bit(&pstream , pevt->type); ncs_encode_32bit(&pstream , pevt->info.cpnd.error); ncs_encode_32bit(&pstream , pevt->info.cpnd.type); ncs_enc_claim_space(io_uba, 12); rc = cpsv_ref_cnt_encode(io_uba,&pevt->info.cpnd.info.refCntsetReq); TRACE_LEAVE(); return rc; } } } /* For all other cases call EDU othen than Write/Read API's */ rc = m_NCS_EDU_EXEC(&cb->edu_hdl, FUNC_NAME(CPSV_EVT), enc_info->io_uba, EDP_OP_TYPE_ENC, pevt, &ederror); TRACE_LEAVE(); return rc; } else { /* Drop The Message As Msg Fmt Version Not understandable */ TRACE_4("cpa api processing failed in mds_enc "); return NCSCC_RC_FAILURE; } }
/**************************************************************************** Name : cpa_mds_enc Description : This function encodes an events sent from CPA to remote CPND. Arguments : cb : CPA control Block. info : Info for encoding Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE Notes : None. ******************************************************************************/ static uns32 cpa_mds_enc(CPA_CB *cb, MDS_CALLBACK_ENC_INFO *enc_info) { CPSV_EVT *pevt = NULL; EDU_ERR ederror = 0; NCS_UBAID *io_uba = enc_info->io_uba; uns32 rc = NCSCC_RC_SUCCESS; uns8 *pstream = NULL; /* Get the Msg Format version from the SERVICE_ID & RMT_SVC_PVT_SUBPART_VERSION */ if (enc_info->i_to_svc_id == NCSMDS_SVC_ID_CPND) { enc_info->o_msg_fmt_ver = m_NCS_ENC_MSG_FMT_GET(enc_info->i_rem_svc_pvt_ver, CPA_WRT_CPND_SUBPART_VER_MIN, CPA_WRT_CPND_SUBPART_VER_MAX, cpa_cpnd_msg_fmt_table); } if (enc_info->o_msg_fmt_ver) { pevt = (CPSV_EVT *)enc_info->i_msg; if (pevt->type == CPSV_EVT_TYPE_CPND) { if (pevt->info.cpnd.type == CPND_EVT_A2ND_CKPT_WRITE) { pstream = ncs_enc_reserve_space(io_uba, 12); if (!pstream) return m_CPSV_DBG_SINK(NCSCC_RC_FAILURE, "Memory alloc failed in cpa_mds_enc \n"); ncs_encode_32bit(&pstream, pevt->type); /* CPSV_EVT Type */ ncs_encode_32bit(&pstream, pevt->info.cpnd.error); /* cpnd_evt error This is for backword compatible purpose with EDU enc/dec with 3.0.2 */ ncs_encode_32bit(&pstream, pevt->info.cpnd.type); /* cpnd_evt SubType */ ncs_enc_claim_space(io_uba, 12); rc = cpsv_ckpt_access_encode(&pevt->info.cpnd.info.ckpt_write, io_uba); return rc; } else if (pevt->info.cpnd.type == CPND_EVT_A2ND_CKPT_READ) { pstream = ncs_enc_reserve_space(io_uba, 12); if (!pstream) return m_CPSV_DBG_SINK(NCSCC_RC_FAILURE, "Memory alloc failed in cpa_mds_enc \n"); ncs_encode_32bit(&pstream, pevt->type); /* CPSV_EVT Type */ ncs_encode_32bit(&pstream, pevt->info.cpnd.error); /* cpnd_evt error This is for backword compatible purpose with EDU enc/dec with 3.0.2 */ ncs_encode_32bit(&pstream, pevt->info.cpnd.type); /* cpnd_evt SubType */ ncs_enc_claim_space(io_uba, 12); rc = cpsv_ckpt_access_encode(&pevt->info.cpnd.info.ckpt_read, io_uba); return rc; } else if(pevt->info.cpnd.type == CPND_EVT_A2ND_CKPT_REFCNTSET) { if(enc_info->o_msg_fmt_ver < 2) return NCSCC_RC_FAILURE; else { pstream = ncs_enc_reserve_space(io_uba, 12); if(!pstream) return m_CPSV_DBG_SINK(NCSCC_RC_FAILURE,"Memory alloc failed in cpa_mds_enc \n"); ncs_encode_32bit(&pstream , pevt->type); ncs_encode_32bit(&pstream , pevt->info.cpnd.error); ncs_encode_32bit(&pstream , pevt->info.cpnd.type); ncs_enc_claim_space(io_uba, 12); rc = cpsv_ref_cnt_encode(io_uba,&pevt->info.cpnd.info.refCntsetReq); return rc; } } } /* For all other cases call EDU othen than Write/Read API's */ rc = m_NCS_EDU_EXEC(&cb->edu_hdl, FUNC_NAME(CPSV_EVT), enc_info->io_uba, EDP_OP_TYPE_ENC, pevt, &ederror); return rc; } else { /* Drop The Message As Msg Fmt Version Not understandable */ m_LOG_CPA_CCL(CPA_PROC_FAILED, NCSFL_LC_CKPT_MGMT, NCSFL_SEV_ERROR, "mds_enc", __FILE__, __LINE__); return NCSCC_RC_FAILURE; } }
/******************************************************************************************* * Name : glsv_gld_mbcsv_enc_msg_rsp * * Description : To encode the message that is to be sent to Standby for Cold Sync * Arguments : * * Return Values : |------------------|---------------|-----------|------|-----------|-----------| |No. of Ckpts | ckpt record 1 |ckpt rec 2 |..... |ckpt rec n | async upd | |that will be sent | | | | | cnt ( 0 ) | |------------------|---------------------------|------|-----------|-----------| *******************************************************************************************/ static uint32_t glsv_gld_mbcsv_enc_msg_rsp(GLSV_GLD_CB *gld_cb, NCS_MBCSV_CB_ARG *arg) { GLSV_GLD_RSC_INFO *rsc_info = NULL; GLSV_GLD_A2S_RSC_DETAILS rsc_details; GLSV_NODE_LIST *node_list = NULL; GLSV_A2S_NODE_LIST *a2s_node_list = NULL; GLSV_A2S_NODE_LIST *tmp_a2s_node_list = NULL; GLSV_GLD_GLND_DETAILS *node_details = NULL; uint32_t rc = NCSCC_RC_SUCCESS, no_of_ckpts = 0; EDU_ERR ederror = 0; uint8_t *header; uint8_t *async_cnt; TRACE_ENTER(); /* COLD_SYNC_RESP IS DONE BY THE ACTIVE */ if (gld_cb->ha_state == SA_AMF_HA_STANDBY) { rc = NCSCC_RC_FAILURE; goto end; } memset(&rsc_details, '\0', sizeof(GLSV_GLD_A2S_RSC_DETAILS)); /* First reserve space to store the number of checkpoints that will be sent */ header = ncs_enc_reserve_space(&arg->info.encode.io_uba, sizeof(uint8_t)); if (header == NULL) { LOG_CR("GLD enc reserve space failed: Error %s", strerror(errno)); assert(0); } ncs_enc_claim_space(&arg->info.encode.io_uba, sizeof(uint8_t)); /* Get the first node */ if (!gld_cb->prev_rsc_id) rsc_info = gld_cb->rsc_info; else { rsc_info = gld_cb->rsc_info; while (rsc_info != NULL) { if (rsc_info->rsc_id == gld_cb->prev_rsc_id) break; rsc_info = rsc_info->next; } if (rsc_info) rsc_info = rsc_info->next; } if (rsc_info == NULL) { /* LOG TBD */ rc = NCSCC_RC_FAILURE; goto end; } else { while (rsc_info != NULL) { node_list = rsc_info->node_list; no_of_ckpts++; memcpy(&rsc_details.resource_name, &rsc_info->lck_name, sizeof(SaNameT)); rsc_details.rsc_id = rsc_info->rsc_id; rsc_details.can_orphan = rsc_info->can_orphan; rsc_details.orphan_lck_mode = rsc_info->orphan_lck_mode; rsc_details.node_list = a2s_node_list = m_MMGR_ALLOC_A2S_GLSV_NODE_LIST; if (rsc_details.node_list == NULL) { LOG_CR("Rsc info alloc failed: Error %s", strerror(errno)); assert(0); } memset(rsc_details.node_list, '\0', sizeof(GLSV_A2S_NODE_LIST)); if (node_list != NULL) { memcpy(&rsc_details.node_list->dest_id, &rsc_info->node_list->dest_id, sizeof(MDS_DEST)); /* Get the master node for this resource */ node_details = (GLSV_GLD_GLND_DETAILS *)ncs_patricia_tree_get(&gld_cb->glnd_details, (uint8_t *)&node_list->node_id); if (node_details == NULL) { LOG_ER("Patricia tree get failed: node_id %u", node_list->node_id); } else rsc_details.node_list->status = node_details->status; node_list = node_list->next; while (node_list != NULL) { a2s_node_list->next = m_MMGR_ALLOC_A2S_GLSV_NODE_LIST; a2s_node_list = a2s_node_list->next; if (a2s_node_list == NULL) { LOG_CR("Rsc info alloc failed: Error %s", strerror(errno)); assert(0); if (rsc_details.node_list) { a2s_node_list = rsc_details.node_list; while (a2s_node_list != NULL) { tmp_a2s_node_list = a2s_node_list; a2s_node_list = a2s_node_list->next; m_MMGR_FREE_A2S_GLSV_NODE_LIST(tmp_a2s_node_list); } } rc = NCSCC_RC_FAILURE; goto end; } memset(a2s_node_list, '\0', sizeof(GLSV_A2S_NODE_LIST)); memcpy(&a2s_node_list->dest_id, &node_list->dest_id, sizeof(MDS_DEST)); node_details = (GLSV_GLD_GLND_DETAILS *)ncs_patricia_tree_get(&gld_cb->glnd_details, (uint8_t *)&node_list->node_id); if (node_details == NULL) { LOG_ER("Patricia tree get failed: node_id %u", node_list->node_id); rc = NCSCC_RC_FAILURE; goto end; } else a2s_node_list->status = node_details->status; node_list = node_list->next; } } /* DO THE EDU EXEC */ rc = m_NCS_EDU_EXEC(&gld_cb->edu_hdl, glsv_edp_gld_evt_a2s_rsc_details, &arg->info.encode.io_uba, EDP_OP_TYPE_ENC, &rsc_details, &ederror); if (rc != NCSCC_RC_SUCCESS) { LOG_ER("EDU exec coldsync evt failed"); rc = NCSCC_RC_FAILURE; goto end; } if (rsc_details.node_list) { a2s_node_list = rsc_details.node_list; while (a2s_node_list != NULL) { tmp_a2s_node_list = a2s_node_list; a2s_node_list = a2s_node_list->next; m_MMGR_FREE_A2S_GLSV_NODE_LIST(tmp_a2s_node_list); } } if (no_of_ckpts == MAX_NO_OF_RSC_INFO_RECORDS) break; rsc_info = rsc_info->next; } /* while */ } if (rsc_info != NULL) gld_cb->prev_rsc_id = rsc_info->rsc_id; ncs_encode_8bit(&header, no_of_ckpts); /* This will have the count of async updates that have been sent, this will be 0 initially */ async_cnt = ncs_enc_reserve_space(&arg->info.encode.io_uba, sizeof(uint32_t)); if (async_cnt == NULL) { LOG_CR("GLD enc reserve space failed: Error %s", strerror(errno)); assert(0); } ncs_enc_claim_space(&arg->info.encode.io_uba, sizeof(uint32_t)); ncs_encode_32bit(&async_cnt, gld_cb->gld_async_cnt); if (no_of_ckpts < MAX_NO_OF_RSC_INFO_RECORDS) { if (arg->info.encode.io_msg_type == NCS_MBCSV_MSG_COLD_SYNC_RESP) arg->info.encode.io_msg_type = NCS_MBCSV_MSG_COLD_SYNC_RESP_COMPLETE; else { if (arg->info.encode.io_msg_type == NCS_MBCSV_MSG_DATA_RESP) arg->info.encode.io_msg_type = NCS_MBCSV_MSG_DATA_RESP_COMPLETE; } gld_cb->prev_rsc_id = 0; } end: TRACE_LEAVE(); return rc; }
/******************************************************************************************* * Name : glsv_gld_mbcsv_enc_async_update * * Description : To encode the data and to send it to Standby at the time of Async Update * Arguments : NCS_MBCSV_CB_ARG - MBCSv callback Argument * * Return Values : Success / Error * Notes : from io_reo_type - the event is determined and based on the event we encode the MBCSv_MSG This is called at the active side *******************************************************************************************/ static uint32_t glsv_gld_mbcsv_enc_async_update(GLSV_GLD_CB *gld_cb, NCS_MBCSV_CB_ARG *arg) { GLSV_GLD_A2S_CKPT_EVT *a2s_msg; uint32_t rc = NCSCC_RC_SUCCESS; EDU_ERR ederror = 0; uint8_t *gld_type_ptr = NULL; TRACE_ENTER(); /* Increment the async update count gld_cb->gld_async_cnt */ gld_cb->gld_async_cnt++; gld_type_ptr = ncs_enc_reserve_space(&arg->info.encode.io_uba, sizeof(uint8_t)); if (gld_type_ptr == NULL) { LOG_CR("GLD enc reserve space failed:Error %s", strerror(errno)); assert(0); } ncs_enc_claim_space(&arg->info.encode.io_uba, sizeof(uint8_t)); ncs_encode_8bit(&gld_type_ptr, arg->info.encode.io_reo_type); switch (arg->info.encode.io_reo_type) { case GLSV_GLD_EVT_RSC_OPEN: a2s_msg = (GLSV_GLD_A2S_CKPT_EVT *)NCS_INT64_TO_PTR_CAST(arg->info.encode.io_reo_hdl); rc = m_NCS_EDU_EXEC(&gld_cb->edu_hdl, glsv_edp_gld_a2s_evt_rsc_open_info, &arg->info.encode.io_uba, EDP_OP_TYPE_ENC, &a2s_msg->info.rsc_open_info, &ederror); if (rc != NCSCC_RC_SUCCESS) { LOG_ER("EDU exec async rsc open evt failed"); rc = NCSCC_RC_FAILURE; } break; case GLSV_GLD_EVT_RSC_CLOSE: a2s_msg = (GLSV_GLD_A2S_CKPT_EVT *)NCS_INT64_TO_PTR_CAST(arg->info.encode.io_reo_hdl); rc = m_NCS_EDU_EXEC(&gld_cb->edu_hdl, glsv_edp_gld_a2s_evt_rsc_details, &arg->info.encode.io_uba, EDP_OP_TYPE_ENC, &a2s_msg->info.rsc_details, &ederror); if (rc != NCSCC_RC_SUCCESS) { LOG_ER("EDU exec async rsc close evt failed"); rc = NCSCC_RC_FAILURE; } break; case GLSV_GLD_EVT_SET_ORPHAN: a2s_msg = (GLSV_GLD_A2S_CKPT_EVT *)NCS_INT64_TO_PTR_CAST(arg->info.encode.io_reo_hdl); rc = m_NCS_EDU_EXEC(&gld_cb->edu_hdl, glsv_edp_gld_a2s_evt_rsc_details, &arg->info.encode.io_uba, EDP_OP_TYPE_ENC, &a2s_msg->info.rsc_details, &ederror); if (rc != NCSCC_RC_SUCCESS) { LOG_ER("EDU exec async set orphan evt failed"); rc = NCSCC_RC_FAILURE; } break; case GLSV_GLD_EVT_GLND_DOWN: case GLSV_GLD_EVT_GLND_OPERATIONAL: a2s_msg = (GLSV_GLD_A2S_CKPT_EVT *)NCS_INT64_TO_PTR_CAST(arg->info.encode.io_reo_hdl); rc = m_NCS_EDU_EXEC(&gld_cb->edu_hdl, glsv_edp_gld_a2s_evt_glnd_mds_info, &arg->info.encode.io_uba, EDP_OP_TYPE_ENC, &a2s_msg->info.glnd_mds_info, &ederror); if (rc != NCSCC_RC_SUCCESS) { LOG_ER("EDU exec async glnd down evt failed"); rc = NCSCC_RC_FAILURE; } break; default: rc = NCSCC_RC_FAILURE; goto end; } end: TRACE_LEAVE(); return rc; }
/*********************************************************************************** * Name : glsv_gld_mbcsv_dec_async_update * * Description : To decode the async update at the Standby, so the first field is decoded which will tell the type and based on the event, a corresponding action will be taken * Arguments : NCS_MBCSV_CB_ARG - MBCSv callback argument * * Return Values : Success / Error ***********************************************************************************/ static uint32_t glsv_gld_mbcsv_dec_async_update(GLSV_GLD_CB *gld_cb, NCS_MBCSV_CB_ARG *arg) { uint8_t *ptr, data[16]; GLSV_GLD_A2S_CKPT_EVT *a2s_evt; uint32_t evt_type, rc = NCSCC_RC_SUCCESS; EDU_ERR ederror = 0; GLSV_A2S_RSC_OPEN_INFO *rsc_info = NULL; GLSV_A2S_RSC_DETAILS *rsc_details = NULL; GLSV_A2S_GLND_MDS_INFO *node_details = NULL; TRACE_ENTER(); a2s_evt = m_MMGR_ALLOC_GLSV_GLD_A2S_EVT; if (a2s_evt == NULL) { LOG_CR("A2S event alloc failed: Error %s", strerror(errno)); assert(0); } memset(a2s_evt, 0, sizeof(GLSV_GLD_A2S_CKPT_EVT)); /* To store the value of Async Update received */ gld_cb->gld_async_cnt++; /* in the decode.i_uba , the 1st parameter is the Type , so first decode only the first field and based on the type then decode the entire message */ ptr = ncs_dec_flatten_space(&arg->info.decode.i_uba, data, sizeof(uint8_t)); evt_type = ncs_decode_8bit(&ptr); a2s_evt->evt_type = evt_type; ncs_dec_skip_space(&arg->info.decode.i_uba, sizeof(uint8_t)); switch (evt_type) { case GLSV_GLD_EVT_RSC_OPEN: rsc_info = &a2s_evt->info.rsc_open_info; /* The contents are decoded from i_uba a2s_evt */ rc = m_NCS_EDU_EXEC(&gld_cb->edu_hdl, glsv_edp_gld_a2s_evt_rsc_open_info, &arg->info.decode.i_uba, EDP_OP_TYPE_DEC, &rsc_info, &ederror); if (rc != NCSCC_RC_SUCCESS) { LOG_ER("EDU exec async rsc open evt failed"); rc = NCSCC_RC_FAILURE; goto end; } rc = gld_process_standby_evt(gld_cb, a2s_evt); if (rc != NCSCC_RC_SUCCESS) { LOG_ER("GLD standby rsc open evt failed"); goto end; } break; case GLSV_GLD_EVT_RSC_CLOSE: rsc_details = &a2s_evt->info.rsc_details; /* The contents are decoded from i_uba to a2s_evt */ rc = m_NCS_EDU_EXEC(&gld_cb->edu_hdl, glsv_edp_gld_a2s_evt_rsc_details, &arg->info.decode.i_uba, EDP_OP_TYPE_DEC, &rsc_details, &ederror); if (rc != NCSCC_RC_SUCCESS) { LOG_ER("EDU exec async rsc close evt failed"); rc = NCSCC_RC_FAILURE; goto end; } rc = gld_process_standby_evt(gld_cb, a2s_evt); if (rc != NCSCC_RC_SUCCESS) { LOG_ER("GLD standby rsc close evt failed"); rc = NCSCC_RC_FAILURE; goto end; } break; case GLSV_GLD_EVT_SET_ORPHAN: rsc_details = &a2s_evt->info.rsc_details; /* The contents are decoded from i_uba to a2s_evt */ rc = m_NCS_EDU_EXEC(&gld_cb->edu_hdl, glsv_edp_gld_a2s_evt_rsc_details, &arg->info.decode.i_uba, EDP_OP_TYPE_DEC, &rsc_details, &ederror); if (rc != NCSCC_RC_SUCCESS) { LOG_ER("EDU exec aysnc set orphan evt failed"); rc = NCSCC_RC_FAILURE; goto end; } rc = gld_process_standby_evt(gld_cb, a2s_evt); if (rc != NCSCC_RC_SUCCESS) { LOG_ER("GLD standby rsc set orphan evt failed"); rc = NCSCC_RC_FAILURE; goto end; } break; case GLSV_GLD_EVT_GLND_DOWN: case GLSV_GLD_EVT_GLND_OPERATIONAL: node_details = &a2s_evt->info.glnd_mds_info; /* The contents are decoded from i_uba to a2s_evt */ rc = m_NCS_EDU_EXEC(&gld_cb->edu_hdl, glsv_edp_gld_a2s_evt_glnd_mds_info, &arg->info.decode.i_uba, EDP_OP_TYPE_DEC, &node_details, &ederror); if (rc != NCSCC_RC_SUCCESS) { LOG_ER("EDU exec async glnd down evt failed"); rc = NCSCC_RC_FAILURE; goto end; } rc = gld_process_standby_evt(gld_cb, a2s_evt); if (rc != NCSCC_RC_SUCCESS) { LOG_ER("GLD standby glnd down evt failed"); rc = NCSCC_RC_FAILURE; goto end; } break; default: m_MMGR_FREE_GLSV_GLD_A2S_EVT(a2s_evt); rc = NCSCC_RC_FAILURE; goto end; } end: TRACE_LEAVE(); return rc; }