예제 #1
0
/****************************************************************************
  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;
	}
}
예제 #2
0
/****************************************************************************
  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;
	}
}