示例#1
0
void ntfsv_dealloc_notification(ntfsv_send_not_req_t *param)
{
	TRACE_ENTER2("ntfsv_send_not_req_t ptr = %p " "notificationType = %#x", param, (int)param->notificationType);
	switch (param->notificationType) {
	case SA_NTF_TYPE_ALARM:
		ntfsv_free_alarm(&param->notification.alarm, true);
		break;
	case SA_NTF_TYPE_OBJECT_CREATE_DELETE:
		ntfsv_free_obj_create_del(&param->notification.objectCreateDelete, true);
		break;
	case SA_NTF_TYPE_ATTRIBUTE_CHANGE:
		ntfsv_free_attribute_change(&param->notification.attributeChange, true);
		break;
	case SA_NTF_TYPE_STATE_CHANGE:
		ntfsv_free_state_change(&param->notification.stateChange, true);
		break;
	case SA_NTF_TYPE_SECURITY_ALARM:
		ntfsv_free_security_alarm(&param->notification.securityAlarm, true);
		break;
	default:
		TRACE("notificationType not valid");
	}
	TRACE_1("free v_data.p_base %p", param->variable_data.p_base);
	free(param->variable_data.p_base);
	param->variable_data.p_base = NULL;
	param->variable_data.size = 0;
	TRACE_LEAVE();
}
示例#2
0
/**
 * 
 * @param instance
 */
void ntfa_hdl_rec_destructor(ntfa_notification_hdl_rec_t *instance)
{
	ntfa_notification_hdl_rec_t *notificationInstance = instance;

	switch (notificationInstance->ntfNotificationType) {
	case SA_NTF_TYPE_ALARM:
		ntfsv_free_alarm(&notificationInstance->ntfNotification.ntfAlarmNotification);
		break;

	case SA_NTF_TYPE_STATE_CHANGE:
		ntfsv_free_state_change(&notificationInstance->ntfNotification.ntfStateChangeNotification);
		break;

	case SA_NTF_TYPE_OBJECT_CREATE_DELETE:
		ntfsv_free_obj_create_del(&notificationInstance->ntfNotification.ntfObjectCreateDeleteNotification);
		break;

	case SA_NTF_TYPE_ATTRIBUTE_CHANGE:
		ntfsv_free_attribute_change(&notificationInstance->ntfNotification.ntfAttributeChangeNotification);

		break;

	case SA_NTF_TYPE_SECURITY_ALARM:
		ntfsv_free_security_alarm(&notificationInstance->ntfNotification.ntfSecurityAlarmNotification);
		break;

	default:
		TRACE("Invalid Notification Type!");
		break;
	}
	if (NULL != notificationInstance->cbk_notification) {
		free(notificationInstance->cbk_notification);
	}
	TRACE_1("free v_data.p_base %p", notificationInstance->variable_data.p_base);
	free(notificationInstance->variable_data.p_base);
	notificationInstance->variable_data.p_base = NULL;
	notificationInstance->variable_data.size = 0;
}
示例#3
0
SaAisErrorT ntfsv_alloc_ntf_alarm(SaNtfAlarmNotificationT *alarmNotification,
				  SaUint16T numSpecificProblems,
				  SaUint16T numMonitoredAttributes, SaUint16T numProposedRepairActions)
{
	TRACE_ENTER();
	SaAisErrorT rc = SA_AIS_OK;
	/* Perceived severity */
	alarmNotification->numSpecificProblems = numSpecificProblems;
	alarmNotification->numMonitoredAttributes = numMonitoredAttributes;
	alarmNotification->numProposedRepairActions = numProposedRepairActions;

	/* freed in */
	alarmNotification->probableCause = NULL;
	alarmNotification->specificProblems = NULL;
	alarmNotification->perceivedSeverity = NULL;
	alarmNotification->trend = NULL;
	alarmNotification->thresholdInformation = NULL;
	alarmNotification->monitoredAttributes = NULL;
	alarmNotification->proposedRepairActions = NULL;

	alarmNotification->perceivedSeverity = malloc(sizeof(SaNtfSeverityT));
	if (alarmNotification->perceivedSeverity == NULL) {
		TRACE("Out of memory in perceivedSeverity field");
		rc = SA_AIS_ERR_NO_MEMORY;
		goto done;
	}
	/* Trend */
	alarmNotification->trend = malloc(sizeof(SaNtfSeverityTrendT));
	if (alarmNotification->trend == NULL) {
		TRACE("Out of memory in trend field");
		rc = SA_AIS_ERR_NO_MEMORY;
		goto done;
	}

	*(alarmNotification->trend) = SA_NTF_TREND_NO_CHANGE;

	/* ThresholdInformation */
	alarmNotification->thresholdInformation = calloc(1, sizeof(SaNtfThresholdInformationT));
	if (alarmNotification->thresholdInformation == NULL) {
		TRACE("Out of memory in thresholdInformation field");
		rc = SA_AIS_ERR_NO_MEMORY;
		goto done;
	}
	/* Probable cause */
	alarmNotification->probableCause = malloc(sizeof(SaNtfProbableCauseT));
	if (alarmNotification->probableCause == NULL) {
		TRACE("Out of memory in probableCause field");
		rc = SA_AIS_ERR_NO_MEMORY;
		goto done;
	}
	/* Specific problems */
	if (numSpecificProblems != 0) {
		alarmNotification->specificProblems = (SaNtfSpecificProblemT *)
		    calloc(1, numSpecificProblems * sizeof(SaNtfSpecificProblemT));
		if (alarmNotification->specificProblems == NULL) {
			TRACE("Out of memory in specificProblems field");
			rc = SA_AIS_ERR_NO_MEMORY;
			goto done;
		}
	}
	/* Monitored attributes */
	if (numMonitoredAttributes != 0) {
		alarmNotification->monitoredAttributes = (SaNtfAttributeT *)
		    calloc(1, numMonitoredAttributes * sizeof(SaNtfAttributeT));
		if (alarmNotification->monitoredAttributes == NULL) {
			TRACE("Out of memory in monitoredAttributes field");
			rc = SA_AIS_ERR_NO_MEMORY;
			goto done;
		}
	}
	/* Proposed repair actions */
	if (numProposedRepairActions != 0) {
		alarmNotification->proposedRepairActions = (SaNtfProposedRepairActionT *)
		    calloc(1, numProposedRepairActions * sizeof(SaNtfProposedRepairActionT));
		if (alarmNotification->proposedRepairActions == NULL) {
			TRACE("Out of memory in proposedRepairActions field");
			rc = SA_AIS_ERR_NO_MEMORY;
			goto done;
		}
	}
 done:
	if (rc != SA_AIS_OK) {
		ntfsv_free_alarm(alarmNotification, false);
	}
	TRACE_LEAVE();
	return rc;
}