示例#1
0
/*************************************************************************** 
@brief		: Delete all the scope registered for this client. This function 
		  does not free the client info itself, rather frees all the 
		  internal memory allocated for the scope infos. 
@param[in]	: client_info - Client to be cleand up.
*****************************************************************************/
void smfa_client_info_clean(SMFA_CLIENT_INFO *client_info)
{
	SMFA_SCOPE_INFO *scope_info_list = client_info->scope_info_list;
	
	while(NULL != scope_info_list){
		/* Delete from the head of the list.*/
		client_info->scope_info_list = scope_info_list->next_scope;
		smfa_scope_info_free(scope_info_list);
		scope_info_list = client_info->scope_info_list;
	}
}
示例#2
0
/*************************************************************************** 
@brief		: Delete the scope info node coresponding to the scope_id 
		  from the client_info->scope_info_list. 
@param[in]	: client_info - Client from which the scope info to be removed.
@param[in]	: scope_id - Scope to be removed.
@return		: NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
*****************************************************************************/
uint32_t smfa_scope_info_rmv(SMFA_CLIENT_INFO *client_info, SaSmfCallbackScopeIdT scope_id)
{
	SMFA_SCOPE_INFO *scope_info_list = client_info->scope_info_list;
	SMFA_SCOPE_INFO *scope_info_prev = scope_info_list;

	while(NULL != scope_info_list){
		if (scope_id == scope_info_list->scope_id){
			if (scope_info_prev->scope_id == scope_info_list->scope_id){
				/* Deleting the Head node.*/
				client_info->scope_info_list = scope_info_list->next_scope;
			}else{
				/* Deleting the non-head node.*/
				scope_info_prev->next_scope = scope_info_list->next_scope;
			}
			smfa_scope_info_free(scope_info_list);
			scope_info_list = NULL;
			return NCSCC_RC_SUCCESS;
		}else{
			scope_info_prev = scope_info_list;
			scope_info_list = scope_info_list->next_scope;
		}
	}
	return NCSCC_RC_FAILURE;
}
示例#3
0
/*************************************************************************** 
@brief		: saSmfCallbackScopeRegister. If no cbk is registered, then 
		  call to this api fails.
@param[in]	: smfHandle - Handle returned by successful intialize. 
@param[in]	: scopeId - Scope id provided by the client. 
@param[in]	: scopeOfInterest - Set of filters registered.
@return		: SA_AIS_OK if successful otherwise appropiate err code.
*****************************************************************************/
SaAisErrorT saSmfCallbackScopeRegister( SaSmfHandleT smfHandle, 
				SaSmfCallbackScopeIdT scopeId,
				const SaSmfLabelFilterArrayT *scopeOfInterest)
{
	SMFA_CB *cb = &_smfa_cb;
	SMFA_CLIENT_INFO *client_info;
	SMFA_SCOPE_INFO *scope_info;
	uns32 no_of_filters = 0;
	uns32 size_of_label = 0;

	TRACE_ENTER2("SMFA:Handle %llu, scopeId: %u",smfHandle,scopeId);
	if (NULL == scopeOfInterest){
		LOG_ER("SMFA: scopeOfInterest is NULL.");
		TRACE_LEAVE();
		return SA_AIS_ERR_INVALID_PARAM;
	}
	/* Should we still add the scope id to the client db??*/
	if (0 >= scopeOfInterest->filtersNumber){
		LOG_ER("SMFA: filtersNumber is ZERO.");
		TRACE_LEAVE();
		return SA_AIS_ERR_INVALID_PARAM;
	}
	
	if (cb->is_finalized){
		LOG_ER("SMFA: Called after finalize, Bad handle.");
		TRACE_LEAVE();
		return SA_AIS_ERR_BAD_HANDLE;
	}
	
	if (NCSCC_RC_SUCCESS != m_NCS_LOCK(&cb->cb_lock,NCS_LOCK_WRITE)){
		LOG_ER("SMFA: Cb lock acquire FAILED.");
		TRACE_LEAVE();
		return SA_AIS_ERR_NO_RESOURCES;
	}
	
	/* Get the client info structure for the handle.*/
	client_info = smfa_client_info_get(smfHandle);
	if (NULL == client_info){
		LOG_ER("SMFA: Bad handle %llu.",smfHandle);
		m_NCS_UNLOCK(&cb->cb_lock, NCS_LOCK_WRITE);
		TRACE_LEAVE();
		return SA_AIS_ERR_BAD_HANDLE;
	}

	/* If no callback is registered during initialization.*/
	if (NULL == client_info->reg_cbk.saSmfCampaignCallback){
		LOG_ER("SMFA: No cbk registered.");
		m_NCS_UNLOCK(&cb->cb_lock, NCS_LOCK_WRITE);
		TRACE_LEAVE();
		return SA_AIS_ERR_INIT;
	}

	/* Check if the scope id exists.*/
	if (NULL != smfa_scope_info_get(client_info,scopeId)){
		LOG_ER("SMFA: Scope id exists: %x",scopeId);
		m_NCS_UNLOCK(&cb->cb_lock, NCS_LOCK_WRITE);
		TRACE_LEAVE();
		return SA_AIS_ERR_EXIST;
	}
	
	scope_info = (SMFA_SCOPE_INFO *)calloc(1,sizeof(SMFA_SCOPE_INFO));	
	if (NULL == scope_info){
		LOG_ER("SMFA scope info: calloc FAILED, error: %s",strerror(errno));
		m_NCS_UNLOCK(&cb->cb_lock, NCS_LOCK_WRITE);
		TRACE_LEAVE();
		return SA_AIS_ERR_NO_MEMORY; 
	}
	
	/* Cpy the filter info if mentioned.*/
	scope_info->scope_of_interest.filtersNumber = scopeOfInterest->filtersNumber;
	scope_info->scope_of_interest.filters = (SaSmfLabelFilterT *)
	calloc(scopeOfInterest->filtersNumber,sizeof(SaSmfLabelFilterT));
	if (NULL == scope_info->scope_of_interest.filters){
		LOG_ER("SMFA filters: calloc FAILED, error: %s",strerror(errno));
		smfa_scope_info_free(scope_info);
		m_NCS_UNLOCK(&cb->cb_lock, NCS_LOCK_WRITE);
		TRACE_LEAVE();
		return SA_AIS_ERR_NO_MEMORY;
	}
	
	for (no_of_filters=0; no_of_filters < scopeOfInterest->filtersNumber; no_of_filters++){
		
		scope_info->scope_of_interest.filters[no_of_filters].filterType = 
		scopeOfInterest->filters[no_of_filters].filterType;
		
		size_of_label = scopeOfInterest->filters[no_of_filters].filter.labelSize;

		scope_info->scope_of_interest.filters[no_of_filters].filter.label = 
		(SaUint8T *)calloc(1,size_of_label);
		/* Fail the API.*/
		if (NULL == scope_info->scope_of_interest.filters[no_of_filters].filter.label){
			LOG_ER("SMFA filter label: calloc FAILED, error: %s",strerror(errno));
			smfa_scope_info_free(scope_info);
			m_NCS_UNLOCK(&cb->cb_lock, NCS_LOCK_WRITE);
			TRACE_LEAVE();
			return SA_AIS_ERR_NO_MEMORY;
		}

		scope_info->scope_of_interest.filters[no_of_filters].filter.labelSize = size_of_label;
		
		memcpy(scope_info->scope_of_interest.filters[no_of_filters].filter.label,
		scopeOfInterest->filters[no_of_filters].filter.label,size_of_label);
	}
	/* Store scope id.*/
	scope_info->scope_id = scopeId;

	/*Add the scope info to the client db.*/
	smfa_scope_info_add(client_info,scope_info);	
	
	m_NCS_UNLOCK(&cb->cb_lock, NCS_LOCK_WRITE);
	TRACE_LEAVE();
	return SA_AIS_OK;
}