void saNtfStateChangeNotificationAllocate_01(void) { SaNtfStateChangeNotificationT myNotification; saNotificationAllocationParamsT myNotificationAllocationParams; saNotificationFilterAllocationParamsT myNotificationFilterAllocationParams; saNotificationParamsT myNotificationParams; fillInDefaultValues(&myNotificationAllocationParams, &myNotificationFilterAllocationParams, &myNotificationParams); safassert(saNtfInitialize(&ntfHandle, &ntfSendCallbacks, &ntfVersion), SA_AIS_OK); rc = saNtfStateChangeNotificationAllocate( ntfHandle, /* handle to Notification Service instance */ &myNotification, /* number of correlated notifications */ myNotificationAllocationParams.numCorrelatedNotifications, /* length of additional text */ myNotificationAllocationParams.lengthAdditionalText, /* number of additional info items*/ myNotificationAllocationParams.numAdditionalInfo, /* number of state changes */ myNotificationAllocationParams.numAttributes, /* use default allocation size */ myNotificationAllocationParams.variableDataSize); safassert(saNtfNotificationFree(myNotification.notificationHandle) , SA_AIS_OK); safassert(saNtfFinalize(ntfHandle) , SA_AIS_OK); test_validate(rc, SA_AIS_OK); }
/**************************************************************************** Name : avnd_ext_intf_destroy Description : This routine destroys external interfaces (logging service being the exception). Arguments : cb - ptr to AvND control block Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE Notes : None ******************************************************************************/ uns32 avnd_ext_intf_destroy(AVND_CB *cb) { uns32 rc = NCSCC_RC_SUCCESS; TRACE_ENTER(); /* MDS unregistration */ rc = avnd_mds_unreg(cb); if (NCSCC_RC_SUCCESS != rc) goto done; /* EDU cleanup */ m_NCS_EDU_HDL_FLUSH(&cb->edu_hdl); m_NCS_EDU_HDL_FLUSH(&cb->edu_hdl_avnd); m_NCS_EDU_HDL_FLUSH(&cb->edu_hdl_ava); /* NTFA Finalize */ rc = saNtfFinalize(cb->ntfHandle); if (rc != SA_AIS_OK) { LOG_ER("saNtfFinalize Failed (%u)", rc); } done: TRACE_LEAVE(); return rc; }
/** * Provoke a SA_AIS_ERR_INVALID_PARAM reply */ void saNtfArrayAllocateTest_05(void) { SaStringT *arrayPtr; SaNtfAlarmNotificationT myAlarmNotification; safassert(saNtfInitialize(&ntfHandle, &ntfSendCallbacks, &ntfVersion) , SA_AIS_OK); safassert(saNtfAlarmNotificationAllocate( ntfHandle, &myAlarmNotification, 0, 0, 0, 0, 0, 2, SA_NTF_ALLOC_SYSTEM_LIMIT), SA_AIS_OK); myAlarmNotification.proposedRepairActions[0].actionValueType = SA_NTF_VALUE_ARRAY; rc = saNtfArrayValAllocate( myAlarmNotification.notificationHandle, (SaUint16T)5, (SaUint16T)(strlen(DEFAULT_ADDITIONAL_TEXT) + 1), (void**) &arrayPtr, NULL); safassert(saNtfNotificationFree(myAlarmNotification.notificationHandle) , SA_AIS_OK); safassert(saNtfFinalize(ntfHandle), SA_AIS_OK); test_validate(rc, SA_AIS_ERR_INVALID_PARAM); }
/** * Test that the return value SA_AIS_ERR_INVALID_PARAM works * * Strategy: */ void saNtfObjectCreateDeleteNotificationAllocate_03(void) { saNotificationAllocationParamsT myNotificationAllocationParams; saNotificationFilterAllocationParamsT myNotificationFilterAllocationParams; saNotificationParamsT myNotificationParams; fillInDefaultValues(&myNotificationAllocationParams, &myNotificationFilterAllocationParams, &myNotificationParams); safassert(saNtfInitialize(&ntfHandle, &ntfCallbacks, &ntfVersion), SA_AIS_OK); rc = saNtfObjectCreateDeleteNotificationAllocate( ntfHandle, /* handle to Notification Service instance */ NULL, /* number of correlated notifications */ myNotificationAllocationParams.numCorrelatedNotifications, /* length of additional text */ myNotificationAllocationParams.lengthAdditionalText, /* number of additional info items*/ myNotificationAllocationParams.numAdditionalInfo, /* number of state changes */ myNotificationAllocationParams.numObjectAttributes, /* use default allocation size */ myNotificationAllocationParams.variableDataSize); free(myNotificationParams.additionalText); safassert(saNtfFinalize(ntfHandle), SA_AIS_OK); test_validate(rc, SA_AIS_ERR_INVALID_PARAM); }
/* Test all filter handles set to NULL */ void saNtfNotificationSubscribe_03(void) { SaNtfHandleT ntfHandle; SaNtfNotificationTypeFilterHandlesT myNotificationFilterHandles; saNotificationAllocationParamsT myNotificationAllocationParams; saNotificationFilterAllocationParamsT myNotificationFilterAllocationParams; saNotificationParamsT myNotificationParams; fillInDefaultValues(&myNotificationAllocationParams, &myNotificationFilterAllocationParams, &myNotificationParams); safassert(saNtfInitialize(&ntfHandle, &ntfCallbacks, &ntfVersion), SA_AIS_OK); /* Initialize filter handles */ myNotificationFilterHandles.alarmFilterHandle = 0; myNotificationFilterHandles.attributeChangeFilterHandle = 0; myNotificationFilterHandles.objectCreateDeleteFilterHandle = 0; myNotificationFilterHandles.securityAlarmFilterHandle = 0; myNotificationFilterHandles.stateChangeFilterHandle = 0; rc = saNtfNotificationSubscribe(&myNotificationFilterHandles, 4); safassert(saNtfNotificationUnsubscribe(4), SA_AIS_ERR_NOT_EXIST); safassert(saNtfFinalize(ntfHandle), SA_AIS_OK); free(myNotificationParams.additionalText); /* allocated in fillInDefaultValues */ test_validate(rc, SA_AIS_ERR_INVALID_PARAM); }
void saNtfNotificationReadInitialize_04(void) { SaNtfHandleT ntfHandle; SaNtfSearchCriteriaT searchCriteria; SaNtfAlarmNotificationFilterT myAlarmFilter; SaNtfObjectCreateDeleteNotificationFilterT myObjCrDeFilter; SaNtfNotificationTypeFilterHandlesT myNotificationFilterHandles; SaNtfReadHandleT readHandle; searchCriteria.searchMode = SA_NTF_SEARCH_AT_OR_AFTER_TIME; fillInDefaultValues(&myNotificationAllocationParams, &myNotificationFilterAllocationParams, &myNotificationParams); safassert(saNtfInitialize(&ntfHandle, &ntfCallbacks, &ntfVersion),SA_AIS_OK); safassert(saNtfAlarmNotificationFilterAllocate( ntfHandle, /* handle to Notification Service instance */ &myAlarmFilter, /* put filter here */ /* number of event types */ myNotificationFilterAllocationParams.numEventTypes, /* number of notification objects */ myNotificationFilterAllocationParams.numNotificationObjects, /* number of notifying objects */ myNotificationFilterAllocationParams.numNotifyingObjects, /* number of notification class ids */ myNotificationFilterAllocationParams.numNotificationClassIds, /* number of probable causes */ myNotificationFilterAllocationParams.numProbableCauses, /* number of perceived severities */ myNotificationFilterAllocationParams.numPerceivedSeverities, /* number of trend indications */ myNotificationFilterAllocationParams.numTrends), SA_AIS_OK); safassert(saNtfObjectCreateDeleteNotificationFilterAllocate( ntfHandle, /* handle to Notification Service instance */ &myObjCrDeFilter, /* put filter here */ /* number of event types */ myNotificationFilterAllocationParams.numEventTypes, /* number of notification objects */ myNotificationFilterAllocationParams.numNotificationObjects, /* number of notifying objects */ myNotificationFilterAllocationParams.numNotifyingObjects, /* number of notification class ids */ myNotificationFilterAllocationParams.numNotificationClassIds, /* number of source indicators */ 0), SA_AIS_OK); myNotificationFilterHandles.alarmFilterHandle = myAlarmFilter.notificationFilterHandle; myNotificationFilterHandles.alarmFilterHandle = myObjCrDeFilter.notificationFilterHandle; rc = saNtfNotificationReadInitialize(searchCriteria, &myNotificationFilterHandles, &readHandle); safassert(saNtfFinalize(ntfHandle), SA_AIS_OK); free(myNotificationParams.additionalText); test_validate(rc, SA_AIS_OK); }
/** * Provoke a SA_AIS_ERR_BAD_HANDLE reply */ void saNtfPtrAllocateTest_03(void) { SaStringT *destPtr; SaNtfAlarmNotificationT myAlarmNotification; safassert(saNtfInitialize(&ntfHandle, &ntfSendCallbacks, &ntfVersion) , SA_AIS_OK); safassert(saNtfAlarmNotificationAllocate( ntfHandle, &myAlarmNotification, 0, 0, 0, 0, 0, 2, SA_NTF_ALLOC_SYSTEM_LIMIT), SA_AIS_OK); myAlarmNotification.proposedRepairActions[0].actionValueType = SA_NTF_VALUE_STRING; safassert(saNtfNotificationFree(myAlarmNotification.notificationHandle) , SA_AIS_OK); rc = saNtfPtrValAllocate( myAlarmNotification.notificationHandle, (SaUint16T)(strlen(DEFAULT_ADDITIONAL_TEXT) + 1), (void**) &destPtr, &(myAlarmNotification.proposedRepairActions[0].actionValue)); safassert(saNtfFinalize(ntfHandle), SA_AIS_OK); test_validate(rc, SA_AIS_ERR_BAD_HANDLE); }
void saNtfNotificationUnsubscribe_03(void) { SaNtfHandleT ntfHandle; safassert(saNtfInitialize(&ntfHandle, &ntfCallbacks, &ntfVersion), SA_AIS_OK); rc = saNtfNotificationUnsubscribe(44); safassert(saNtfFinalize(ntfHandle), SA_AIS_OK); test_validate(rc, SA_AIS_ERR_NOT_EXIST); }
/** * Test that return value SA_AIS_ERR_BAD_HANDLE works * * Strategy: Set the handle to zero or invalid number * Create a handle and then destroy it. */ void saNtfObjectCreateDeleteNotificationAllocate_02(void) { int errors = 0; SaNtfObjectCreateDeleteNotificationT myNotification; saNotificationAllocationParamsT myNotificationAllocationParams; saNotificationFilterAllocationParamsT myNotificationFilterAllocationParams; saNotificationParamsT myNotificationParams; fillInDefaultValues(&myNotificationAllocationParams, &myNotificationFilterAllocationParams, &myNotificationParams); ntfHandle = 0; rc = saNtfObjectCreateDeleteNotificationAllocate( ntfHandle, /* handle to Notification Service instance */ &myNotification, /* number of correlated notifications */ myNotificationAllocationParams.numCorrelatedNotifications, /* length of additional text */ myNotificationAllocationParams.lengthAdditionalText, /* number of additional info items*/ myNotificationAllocationParams.numAdditionalInfo, /* number of state changes */ myNotificationAllocationParams.numObjectAttributes, /* use default allocation size */ myNotificationAllocationParams.variableDataSize); if(rc != SA_AIS_ERR_BAD_HANDLE) { errors++; } free(myNotificationParams.additionalText); safassert(saNtfInitialize(&ntfHandle, &ntfCallbacks, &ntfVersion), SA_AIS_OK); safassert(saNtfFinalize(ntfHandle), SA_AIS_OK); rc = saNtfObjectCreateDeleteNotificationAllocate( ntfHandle, /* handle to Notification Service instance */ &myNotification, /* number of correlated notifications */ myNotificationAllocationParams.numCorrelatedNotifications, /* length of additional text */ myNotificationAllocationParams.lengthAdditionalText, /* number of additional info items*/ myNotificationAllocationParams.numAdditionalInfo, /* number of state changes */ myNotificationAllocationParams.numObjectAttributes, /* use default allocation size */ myNotificationAllocationParams.variableDataSize); if(rc != SA_AIS_ERR_BAD_HANDLE) { errors++; } rc = (errors == 0)? SA_AIS_OK: SA_AIS_ERR_BAD_HANDLE; test_validate(rc, SA_AIS_OK); }
/* Test already existing subscriptionId */ void saNtfNotificationSubscribe_04(void) { SaNtfHandleT ntfHandle; SaNtfAlarmNotificationFilterT myAlarmFilter; SaNtfNotificationTypeFilterHandlesT myNotificationFilterHandles; SaNtfSubscriptionIdT subscId = 0; saNotificationAllocationParamsT myNotificationAllocationParams; saNotificationFilterAllocationParamsT myNotificationFilterAllocationParams; saNotificationParamsT myNotificationParams; fillInDefaultValues(&myNotificationAllocationParams, &myNotificationFilterAllocationParams, &myNotificationParams); safassert(saNtfInitialize(&ntfHandle, &ntfCallbacks, &ntfVersion), SA_AIS_OK); safassert(saNtfAlarmNotificationFilterAllocate( ntfHandle, &myAlarmFilter, myNotificationFilterAllocationParams.numEventTypes, myNotificationFilterAllocationParams.numNotificationObjects, myNotificationFilterAllocationParams.numNotifyingObjects, myNotificationFilterAllocationParams.numNotificationClassIds, myNotificationFilterAllocationParams.numProbableCauses, myNotificationFilterAllocationParams.numPerceivedSeverities, myNotificationFilterAllocationParams.numTrends), SA_AIS_OK); /* Set perceived severities */ myAlarmFilter.perceivedSeverities[0] = SA_NTF_SEVERITY_WARNING; myAlarmFilter.perceivedSeverities[1] = SA_NTF_SEVERITY_CLEARED; /* Initialize filter handles */ myNotificationFilterHandles.alarmFilterHandle = myAlarmFilter.notificationFilterHandle; myNotificationFilterHandles.attributeChangeFilterHandle = 0; myNotificationFilterHandles.objectCreateDeleteFilterHandle = 0; myNotificationFilterHandles.securityAlarmFilterHandle = 0; myNotificationFilterHandles.stateChangeFilterHandle = 0; safassert(saNtfNotificationSubscribe(&myNotificationFilterHandles, subscId), SA_AIS_OK); rc = saNtfNotificationSubscribe(&myNotificationFilterHandles, subscId); /* No need to saNtfNotificationUnsubscribe since the subscribe failed */ safassert(saNtfNotificationUnsubscribe(subscId), SA_AIS_OK); safassert(saNtfNotificationFilterFree( myNotificationFilterHandles.alarmFilterHandle), SA_AIS_OK); safassert(saNtfFinalize(ntfHandle), SA_AIS_OK); free(myNotificationParams.additionalText); /* allocated in fillInDefaultValues */ test_validate(rc, SA_AIS_ERR_EXIST); }
/** * Test the content of an SecurityAlarmNotification * Strategy: Set up a subscription and send a notification. * Check it. */ void securityAlarmNotificationTest(void) { SaNtfSecurityAlarmNotificationFilterT myFilter; subscriptionId = 5; resetCounters(); safassert(saNtfInitialize(&ntfHandle, &ntfCbTest, &ntfVersion) , SA_AIS_OK); safassert(saNtfSelectionObjectGet(ntfHandle, &selectionObject) , SA_AIS_OK); if(!safassertNice((rc = saNtfSecurityAlarmNotificationFilterAllocate( ntfHandle, &myFilter, 0, 0, 0, 0, 0,0,0,0,0)), SA_AIS_OK)) { /* Initialize filter handles */ myNotificationFilterHandles.alarmFilterHandle = 0; myNotificationFilterHandles.attributeChangeFilterHandle = 0; myNotificationFilterHandles.objectCreateDeleteFilterHandle = 0; myNotificationFilterHandles.securityAlarmFilterHandle = myFilter.notificationFilterHandle; myNotificationFilterHandles.stateChangeFilterHandle = 0; /* subscribe */ safassert(saNtfNotificationSubscribe(&myNotificationFilterHandles, subscriptionId), SA_AIS_OK); createSecurityAlarmNotification(ntfHandle, &mySecAlarmNotification); safassert(saNtfNotificationSend(mySecAlarmNotification.notificationHandle), SA_AIS_OK); /* Delay to let the notification slip through */ poll_until_received(ntfHandle, *mySecAlarmNotification.notificationHeader.notificationId); if(ntfRecieved.alarmFilterHandle != 0 || ntfRecieved.attributeChangeFilterHandle != 0 || ntfRecieved.objectCreateDeleteFilterHandle !=0 || ntfRecieved.securityAlarmFilterHandle != 1 || ntfRecieved.stateChangeFilterHandle != 0) safassert(SA_AIS_ERR_BAD_FLAGS, SA_AIS_OK); safassert(saNtfNotificationFree(mySecAlarmNotification.notificationHandle), SA_AIS_OK); safassert(saNtfNotificationFilterFree(myFilter.notificationFilterHandle), SA_AIS_OK); } safassert(saNtfNotificationUnsubscribe(subscriptionId), SA_AIS_OK); safassert(saNtfFinalize(ntfHandle) , SA_AIS_OK); if(errors && rc == SA_AIS_OK) rc = SA_AIS_ERR_FAILED_OPERATION; test_validate(rc, SA_AIS_OK); }
/** * Test of NULL pointer exception. */ void saNtfNotificationReadInitialize_02(void) { SaNtfHandleT ntfHandle; SaNtfSearchCriteriaT searchCriteria; SaNtfNotificationTypeFilterHandlesT *myNotificationFilterHandles = NULL; SaNtfReadHandleT readHandle; searchCriteria.searchMode = SA_NTF_SEARCH_AT_OR_AFTER_TIME; safassert(saNtfInitialize(&ntfHandle, &ntfCallbacks, &ntfVersion), SA_AIS_OK); rc = saNtfNotificationReadInitialize(searchCriteria, myNotificationFilterHandles, &readHandle); safassert(saNtfFinalize(ntfHandle), SA_AIS_OK); test_validate(rc, SA_AIS_ERR_INVALID_PARAM); }
void saNtfObjectCreateDeleteNotificationFilterAllocate_04(void) { SaNtfHandleT ntfHandle; safassert(saNtfInitialize(&ntfHandle, &ntfCallbacks, &ntfVersion), SA_AIS_OK); rc = saNtfObjectCreateDeleteNotificationFilterAllocate( ntfHandle, NULL, 0, 0, 0, 1, 0); safassert(saNtfFinalize(ntfHandle), SA_AIS_OK); test_validate(rc, SA_AIS_ERR_INVALID_PARAM); }
/** * Test saNtfArrayValAllocate. * */ void saNtfArrayAllocateTest_06(void) { SaNtfAlarmNotificationT myAlarmNotification; safassert(saNtfInitialize(&ntfHandle, &ntfSendCallbacks, &ntfVersion) , SA_AIS_OK); rc =saNtfAlarmNotificationAllocate( ntfHandle, &myAlarmNotification, 0, 0, 0, 0, 0, 2, 32768); /* works for default value NTFA_VARIABLE_DATA_LIMIT = SHRT_MAX */ safassert(saNtfFinalize(ntfHandle), SA_AIS_OK); test_validate(rc, SA_AIS_ERR_TOO_BIG); }
/** * Test saNtfPtrValAllocate. * */ void saNtfPtrAllocateTest_06(void) { SaNtfAlarmNotificationT myAlarmNotification; safassert(saNtfInitialize(&ntfHandle, &ntfSendCallbacks, &ntfVersion) , SA_AIS_OK); rc = saNtfAlarmNotificationAllocate( ntfHandle, &myAlarmNotification, 0, 0, 0, 0, 0, 2, SA_NTF_ALLOC_SYSTEM_LIMIT -1); safassert(saNtfFinalize(ntfHandle), SA_AIS_OK); test_validate(rc, SA_AIS_ERR_TOO_BIG); }
void saNtfObjectCreateDeleteNotificationFilterAllocate_03(void) { SaNtfHandleT ntfHandle; SaNtfObjectCreateDeleteNotificationFilterT myObjCreDelFilter; safassert(saNtfInitialize(&ntfHandle, &ntfCallbacks, &ntfVersion), SA_AIS_OK); safassert(saNtfFinalize(ntfHandle), SA_AIS_OK); rc = saNtfObjectCreateDeleteNotificationFilterAllocate( ntfHandle, &myObjCreDelFilter, 0, 0, 0, 1, 0); test_validate(rc, SA_AIS_ERR_BAD_HANDLE); }
void saNtfObjectCreateDeleteNotificationFilterAllocate_01(void) { SaNtfHandleT ntfHandle; SaNtfObjectCreateDeleteNotificationFilterT myObjCreDelFilter; safassert(saNtfInitialize(&ntfHandle, &ntfCallbacks, &ntfVersion), SA_AIS_OK); if(!safassertNice((rc = saNtfObjectCreateDeleteNotificationFilterAllocate( ntfHandle, &myObjCreDelFilter, 0, 0, 0, 1, 0)), SA_AIS_OK)) { safassert(saNtfNotificationFilterFree(myObjCreDelFilter.notificationFilterHandle), SA_AIS_OK); } safassert(saNtfFinalize(ntfHandle), SA_AIS_OK); test_validate(rc, SA_AIS_OK); }
/* incomming notifications in the MDS thread discarding makes no sense */ void saNtfNotificationDiscardedCallbackT_01(void) { struct pollfd fds[1]; int ret,i; saNotificationAllocationParamsT myNotificationAllocationParams; saNotificationFilterAllocationParamsT myNotificationFilterAllocationParams; saNotificationParamsT myNotificationParams; AlarmNotificationParams myAlarmParams; SaNtfAlarmNotificationFilterT myAlarmFilter; SaNtfNotificationTypeFilterHandlesT myNotificationFilterHandles; SaNtfIdentifierT myNotId[NUM_NOTIF]; resetCounters(); fillInDefaultValues(&myNotificationAllocationParams, &myNotificationFilterAllocationParams, &myNotificationParams); if(verbose) { printf("num not to send: %d\n", NUM_NOTIF); } rc=SA_AIS_ERR_NOT_SUPPORTED; /* Not fully implemented */ test_validate(rc, SA_AIS_OK); /* See above */ return; /* */ safassert(saNtfInitialize(&ntfHandle, &ntfCbTest, &ntfVersion) , SA_AIS_OK); safassert(saNtfSelectionObjectGet(ntfHandle, &selectionObject) , SA_AIS_OK); safassert(saNtfAlarmNotificationFilterAllocate( ntfHandle, &myAlarmFilter, myNotificationFilterAllocationParams.numEventTypes, myNotificationFilterAllocationParams.numNotificationObjects, myNotificationFilterAllocationParams.numNotifyingObjects, myNotificationFilterAllocationParams.numNotificationClassIds, myNotificationFilterAllocationParams.numProbableCauses, myNotificationFilterAllocationParams.numPerceivedSeverities, myNotificationFilterAllocationParams.numTrends), SA_AIS_OK); /* Set perceived severities */ myAlarmFilter.perceivedSeverities[0] = SA_NTF_SEVERITY_WARNING; myAlarmFilter.perceivedSeverities[1] = SA_NTF_SEVERITY_CLEARED; /* Initialize filter handles */ myNotificationFilterHandles.alarmFilterHandle = myAlarmFilter.notificationFilterHandle; myNotificationFilterHandles.attributeChangeFilterHandle = 0; myNotificationFilterHandles.objectCreateDeleteFilterHandle = 0; myNotificationFilterHandles.securityAlarmFilterHandle = 0; myNotificationFilterHandles.stateChangeFilterHandle = 0; safassert(saNtfNotificationSubscribe(&myNotificationFilterHandles, my_subid), SA_AIS_OK); myAlarmParams.numCorrelatedNotifications = myNotificationAllocationParams.numCorrelatedNotifications; myAlarmParams.lengthAdditionalText = myNotificationAllocationParams.lengthAdditionalText; myAlarmParams.numAdditionalInfo = myNotificationAllocationParams.numAdditionalInfo; myAlarmParams.numSpecificProblems = myNotificationAllocationParams.numSpecificProblems; myAlarmParams.numMonitoredAttributes = myNotificationAllocationParams.numMonitoredAttributes; myAlarmParams.numProposedRepairActions = myNotificationAllocationParams.numProposedRepairActions; myAlarmParams.variableDataSize = myNotificationAllocationParams.variableDataSize; safassert(saNtfAlarmNotificationAllocate( ntfHandle, &myAlarmNotification, myAlarmParams.numCorrelatedNotifications, myAlarmParams.lengthAdditionalText, myAlarmParams.numAdditionalInfo, myAlarmParams.numSpecificProblems, myAlarmParams.numMonitoredAttributes, myAlarmParams.numProposedRepairActions, myAlarmParams.variableDataSize), SA_AIS_OK); myNotificationParams.eventType = myNotificationParams.alarmEventType; fill_header_part( &myAlarmNotification.notificationHeader, (saNotificationParamsT *)&myNotificationParams, myAlarmParams.lengthAdditionalText); /* determine perceived severity */ *(myAlarmNotification.perceivedSeverity) = myNotificationParams.perceivedSeverity; /* set probable cause*/ *(myAlarmNotification.probableCause) = myNotificationParams.probableCause; for(i=0; i<NUM_NOTIF;i++) { if((rc =saNtfNotificationSend(myAlarmNotification.notificationHandle)) != SA_AIS_OK) { if(verbose) { printf("send failed rc: %d\n", rc); } break; } myNotId[i] = *myAlarmNotification.notificationHeader.notificationId; } sleep(10); fds[0].fd = (int) selectionObject; fds[0].events = POLLIN; ret = poll(fds, 1, 10000); assert(ret > 0); safassert(saNtfDispatch(ntfHandle, SA_DISPATCH_ALL) , SA_AIS_OK); rc =SA_AIS_ERR_FAILED_OPERATION; for(i = 0; i < NUM_NOTIF; i++) { if(cb_notId[i] != myNotId[i]) { break; } } if(numDiscarded == 0) { rc =SA_AIS_ERR_FAILED_OPERATION; } else if(numDiscarded != (NUM_NOTIF - i)) { if(verbose) { printf("failed num of discarded: %d\n", numDiscarded); } rc =SA_AIS_ERR_FAILED_OPERATION; } if(verbose) { printf("Number of discarded: %d\n", numDiscarded); printf("Number of received not: %d\n", cb_index); } safassert(saNtfNotificationFree(myAlarmNotification.notificationHandle) , SA_AIS_OK); safassert(saNtfNotificationUnsubscribe(my_subid), SA_AIS_OK); safassert(saNtfFinalize(ntfHandle) , SA_AIS_OK); test_validate(rc, SA_AIS_OK); }
/** * Test the content of several notifications at once * Strategy: Set up a subscription and send a notification. * Check it. */ void allNotificationTest(void) { rc = SA_AIS_OK; saNotificationFilterAllocationParamsT myNotificationFilterAllocationParams; SaNtfAlarmNotificationFilterT myAlarmFilter; SaNtfObjectCreateDeleteNotificationFilterT myObjCrDeFilter; SaNtfAttributeChangeNotificationFilterT myAttrChangeFilter; SaNtfStateChangeNotificationFilterT myStateChangeFilter; SaNtfSecurityAlarmNotificationFilterT mySecAlarmFilter; subscriptionId = 7; resetCounters(); fillInDefaultValues(&myNotificationAllocationParams, &myNotificationFilterAllocationParams, &myNotificationParams); safassert(saNtfInitialize(&ntfHandle, &ntfCbTest, &ntfVersion) , SA_AIS_OK); if(!safassertNice(saNtfAlarmNotificationFilterAllocate( ntfHandle, &myAlarmFilter, myNotificationFilterAllocationParams.numEventTypes, myNotificationFilterAllocationParams.numNotificationObjects, myNotificationFilterAllocationParams.numNotifyingObjects, myNotificationFilterAllocationParams.numNotificationClassIds, myNotificationFilterAllocationParams.numProbableCauses, myNotificationFilterAllocationParams.numPerceivedSeverities, myNotificationFilterAllocationParams.numTrends), SA_AIS_OK)) { /* Set perceived severities */ myAlarmFilter.perceivedSeverities[0] = SA_NTF_SEVERITY_WARNING; myAlarmFilter.perceivedSeverities[1] = SA_NTF_SEVERITY_CLEARED; if(!safassertNice((rc = saNtfObjectCreateDeleteNotificationFilterAllocate( ntfHandle, &myObjCrDeFilter, myNotificationFilterAllocationParams.numEventTypes, myNotificationFilterAllocationParams.numNotificationObjects, myNotificationFilterAllocationParams.numNotifyingObjects, myNotificationFilterAllocationParams.numNotificationClassIds, myNotificationFilterAllocationParams.numSourceIndicators)), SA_AIS_OK)) { if(!safassertNice((rc = saNtfAttributeChangeNotificationFilterAllocate( ntfHandle, &myAttrChangeFilter, myNotificationFilterAllocationParams.numEventTypes, myNotificationFilterAllocationParams.numNotificationObjects, myNotificationFilterAllocationParams.numNotifyingObjects, myNotificationFilterAllocationParams.numNotificationClassIds, myNotificationFilterAllocationParams.numSourceIndicators)), SA_AIS_OK)) { if(!safassertNice((rc = saNtfSecurityAlarmNotificationFilterAllocate( ntfHandle, &mySecAlarmFilter, myNotificationFilterAllocationParams.numEventTypes, myNotificationFilterAllocationParams.numNotificationObjects, myNotificationFilterAllocationParams.numNotifyingObjects, myNotificationFilterAllocationParams.numNotificationClassIds, myNotificationFilterAllocationParams.numProbableCauses, myNotificationFilterAllocationParams.numSeverities, myNotificationFilterAllocationParams.numSecurityAlarmDetectos, myNotificationFilterAllocationParams.numServiceUsers, myNotificationFilterAllocationParams.numServiceProviders)), SA_AIS_OK)) { if(!safassertNice((rc = saNtfStateChangeNotificationFilterAllocate( ntfHandle, &myStateChangeFilter, myNotificationFilterAllocationParams.numEventTypes, myNotificationFilterAllocationParams.numNotificationObjects, myNotificationFilterAllocationParams.numNotifyingObjects, myNotificationFilterAllocationParams.numNotificationClassIds, myNotificationFilterAllocationParams.numSourceIndicators, myNotificationFilterAllocationParams.numChangedStates)), SA_AIS_OK)) { /* Initialize filter handles */ myNotificationFilterHandles.alarmFilterHandle = myAlarmFilter.notificationFilterHandle; myNotificationFilterHandles.attributeChangeFilterHandle = myAttrChangeFilter.notificationFilterHandle; myNotificationFilterHandles.objectCreateDeleteFilterHandle = myObjCrDeFilter.notificationFilterHandle; myNotificationFilterHandles.securityAlarmFilterHandle = mySecAlarmFilter.notificationFilterHandle; myNotificationFilterHandles.stateChangeFilterHandle = myStateChangeFilter.notificationFilterHandle; /* subscribe */ safassert(saNtfNotificationSubscribe(&myNotificationFilterHandles, subscriptionId), SA_AIS_OK); /* Create a couple of notifications and send them */ createAlarmNotification(ntfHandle, &myAlarmNotification); safassert(saNtfNotificationSend(myAlarmNotification.notificationHandle), SA_AIS_OK); createObjectCreateDeleteNotification(ntfHandle, &myObjCrDelNotfification); safassert(saNtfNotificationSend(myObjCrDelNotfification.notificationHandle), SA_AIS_OK); createAttributeChangeNotification(ntfHandle, &myAttrChangeNotification); safassert(saNtfNotificationSend(myAttrChangeNotification.notificationHandle), SA_AIS_OK); createStateChangeNotification(ntfHandle, &myStateChangeNotification); safassert(saNtfNotificationSend(myStateChangeNotification.notificationHandle), SA_AIS_OK); createSecurityAlarmNotification(ntfHandle, &mySecAlarmNotification); safassert(saNtfNotificationSend(mySecAlarmNotification.notificationHandle), SA_AIS_OK); /* TODO: add MiscellaneousNotification */ poll_until_received(ntfHandle, *mySecAlarmNotification.notificationHeader.notificationId); if(ntfRecieved.alarmFilterHandle != 1 || ntfRecieved.attributeChangeFilterHandle != 1 || ntfRecieved.objectCreateDeleteFilterHandle !=1 || ntfRecieved.securityAlarmFilterHandle != 1 || ntfRecieved.stateChangeFilterHandle != 1){ fprintf(stderr, "ntfreceived fh: a: %llu, att: %llu, o: %llu, se: %llu, st: %llu \n", ntfRecieved.alarmFilterHandle, ntfRecieved.attributeChangeFilterHandle, ntfRecieved.objectCreateDeleteFilterHandle, ntfRecieved.securityAlarmFilterHandle, ntfRecieved.stateChangeFilterHandle); safassertNice(SA_AIS_ERR_BAD_FLAGS, SA_AIS_OK); } safassert(saNtfNotificationFree(myAlarmNotification.notificationHandle) , SA_AIS_OK); safassert(saNtfNotificationFree(myObjCrDelNotfification.notificationHandle), SA_AIS_OK); safassert(saNtfNotificationFree(myAttrChangeNotification.notificationHandle), SA_AIS_OK); safassert(saNtfNotificationFree(myStateChangeNotification.notificationHandle), SA_AIS_OK); safassert(saNtfNotificationFree(mySecAlarmNotification.notificationHandle), SA_AIS_OK); /* TODO: add MiscellaneousNotification free */ safassert(saNtfNotificationUnsubscribe(subscriptionId), SA_AIS_OK); safassert(saNtfNotificationFilterFree(myStateChangeFilter.notificationFilterHandle), SA_AIS_OK); } safassert(saNtfNotificationFilterFree(mySecAlarmFilter.notificationFilterHandle), SA_AIS_OK); } safassert(saNtfNotificationFilterFree(myAttrChangeFilter.notificationFilterHandle), SA_AIS_OK); } safassert(saNtfNotificationFilterFree(myObjCrDeFilter.notificationFilterHandle), SA_AIS_OK); } safassert(saNtfNotificationFilterFree(myAlarmFilter.notificationFilterHandle), SA_AIS_OK); } safassert(saNtfFinalize(ntfHandle) , SA_AIS_OK); /* Allocated in fillInDefaultValues() */ free(myNotificationParams.additionalText); if(errors && rc == SA_AIS_OK) rc = SA_AIS_ERR_FAILED_OPERATION; test_validate(rc, SA_AIS_OK); }
void saNtfObjectCreateDeleteNotificationAllocate_01(void) { SaNtfObjectCreateDeleteNotificationT myNotification; saNotificationAllocationParamsT myNotificationAllocationParams; saNotificationFilterAllocationParamsT myNotificationFilterAllocationParams; saNotificationParamsT myNotificationParams; fillInDefaultValues(&myNotificationAllocationParams, &myNotificationFilterAllocationParams, &myNotificationParams); safassert(saNtfInitialize(&ntfHandle, &ntfCallbacks, &ntfVersion), SA_AIS_OK); rc = saNtfObjectCreateDeleteNotificationAllocate( ntfHandle, /* handle to Notification Service instance */ &myNotification, /* number of correlated notifications */ myNotificationAllocationParams.numCorrelatedNotifications, /* length of additional text */ myNotificationAllocationParams.lengthAdditionalText, /* number of additional info items*/ myNotificationAllocationParams.numAdditionalInfo, /* number of state changes */ myNotificationAllocationParams.numObjectAttributes, /* use default allocation size */ myNotificationAllocationParams.variableDataSize); /* Event type */ *(myNotification.notificationHeader.eventType) = SA_NTF_OBJECT_CREATION; /* event time to be set automatically to current time by saNtfNotificationSend */ *(myNotification.notificationHeader.eventTime) = myNotificationParams.eventTime; /* Set Notification Object */ myNotification.notificationHeader.notificationObject->length = myNotificationParams.notificationObject.length; (void)memcpy(myNotification.notificationHeader.notificationObject->value, myNotificationParams.notificationObject.value, myNotificationParams.notificationObject.length); /* Set Notifying Object */ myNotification.notificationHeader.notifyingObject->length = myNotificationParams.notifyingObject.length; (void)memcpy(myNotification.notificationHeader.notifyingObject->value, myNotificationParams.notifyingObject.value, myNotificationParams.notifyingObject.length); /* set Notification Class Identifier */ /* vendor id 33333 is not an existing SNMP enterprise number. Just an example */ myNotification.notificationHeader.notificationClassId->vendorId = myNotificationParams.notificationClassId.vendorId; /* sub id of this notification class within "name space" of vendor ID */ myNotification.notificationHeader.notificationClassId->majorId = myNotificationParams.notificationClassId.majorId; myNotification.notificationHeader.notificationClassId->minorId = myNotificationParams.notificationClassId.minorId; /* set additional text and additional info */ (void)strncpy(myNotification.notificationHeader.additionalText, myNotificationParams.additionalText, myNotificationAllocationParams.lengthAdditionalText); /* Set source indicator */ myNotification.sourceIndicator = &myNotificationParams.objectCreateDeleteSourceIndicator; /* Set objectAttibutes */ myNotification.objectAttributes[0].attributeId = myNotificationParams.objectAttributes[0].attributeId; myNotification.objectAttributes[0].attributeType = myNotificationParams.objectAttributes[0].attributeType; myNotification.objectAttributes[0].attributeValue.int32Val = myNotificationParams.objectAttributes[0].attributeValue.int32Val; free(myNotificationParams.additionalText); safassert(saNtfNotificationFree(myNotification.notificationHandle), SA_AIS_OK); safassert(saNtfFinalize(ntfHandle), SA_AIS_OK); test_validate(rc, SA_AIS_OK); }
/** * Test the content of an alarm notification * Strategy: Set up a subscription and send a notification. * Check it. */ void alarmNotificationTest2(void) { SaNtfAlarmNotificationFilterT myAlarmFilter; subscriptionId = 1; int i; rc = SA_AIS_OK; resetCounters(); safassert(saNtfInitialize(&ntfHandle, &ntfCbTest, &ntfVersion) , SA_AIS_OK); safassert(saNtfSelectionObjectGet(ntfHandle, &selectionObject) , SA_AIS_OK); /* Set up the filters and subscription */ safassert(saNtfAlarmNotificationFilterAllocate( ntfHandle, &myAlarmFilter, 0, 0, 0, 0, 0, 2, 0), SA_AIS_OK); /* Set perceived severities */ myAlarmFilter.perceivedSeverities[0] = SA_NTF_SEVERITY_WARNING; myAlarmFilter.perceivedSeverities[1] = SA_NTF_SEVERITY_CLEARED; /* Initialize filter handles */ myNotificationFilterHandles.alarmFilterHandle = myAlarmFilter.notificationFilterHandle; myNotificationFilterHandles.attributeChangeFilterHandle = 0; myNotificationFilterHandles.objectCreateDeleteFilterHandle = 0; myNotificationFilterHandles.securityAlarmFilterHandle = 0; myNotificationFilterHandles.stateChangeFilterHandle = 0; safassert(saNtfNotificationSubscribe(&myNotificationFilterHandles, subscriptionId), SA_AIS_OK); /* Create a notification and send it */ myAlarmNotification.notificationHeader.numCorrelatedNotifications = 2; myAlarmNotification.notificationHeader.numAdditionalInfo = 5; safassert(saNtfAlarmNotificationAllocate( ntfHandle, &myAlarmNotification, myAlarmNotification.notificationHeader.numCorrelatedNotifications, (SaUint16T)(strlen(DEFAULT_ADDITIONAL_TEXT) + 1), myAlarmNotification.notificationHeader.numAdditionalInfo, 3, /* SaUint16T numSpecificProblems, */ 2, /* SaUint16T numMonitoredAttributes, */ 2, /* SaUint16T numProposedRepairActions, */ SA_NTF_ALLOC_SYSTEM_LIMIT), /* SaInt16T variableDataSize */ SA_AIS_OK); fillHeader(&myAlarmNotification.notificationHeader); /* determine perceived severity */ *(myAlarmNotification.perceivedSeverity) = SA_NTF_SEVERITY_WARNING; /* set probable cause*/ *(myAlarmNotification.probableCause) = SA_NTF_BANDWIDTH_REDUCED; myAlarmNotification.specificProblems[0].problemClassId.vendorId = 23; myAlarmNotification.specificProblems[0].problemClassId.majorId = 22; myAlarmNotification.specificProblems[0].problemClassId.minorId = 21; myAlarmNotification.specificProblems[1].problemClassId.vendorId = 5; myAlarmNotification.specificProblems[1].problemClassId.majorId = 4; myAlarmNotification.specificProblems[1].problemClassId.minorId = 2; myAlarmNotification.specificProblems[2].problemClassId.vendorId = 2; myAlarmNotification.specificProblems[2].problemClassId.majorId = 3; myAlarmNotification.specificProblems[2].problemClassId.minorId = 4; myAlarmNotification.monitoredAttributes[0].attributeId = 1; myAlarmNotification.monitoredAttributes[0].attributeType = SA_NTF_VALUE_INT64; myAlarmNotification.monitoredAttributes[0].attributeValue.int64Val = 987654321; myAlarmNotification.monitoredAttributes[1].attributeId = 2; myAlarmNotification.monitoredAttributes[1].attributeType = SA_NTF_VALUE_INT8; myAlarmNotification.monitoredAttributes[1].attributeValue.int8Val = 88; myAlarmNotification.proposedRepairActions[0].actionId = 3; myAlarmNotification.proposedRepairActions[0].actionValueType = SA_NTF_VALUE_INT16; myAlarmNotification.proposedRepairActions[0].actionValue.int16Val = 456; myAlarmNotification.proposedRepairActions[1].actionId = 4; myAlarmNotification.proposedRepairActions[1].actionValueType = SA_NTF_VALUE_INT32; myAlarmNotification.proposedRepairActions[1].actionValue.int32Val = 456; for (i = 0; i < myAlarmNotification.numSpecificProblems; i++) { myAlarmNotification.specificProblems[i].problemId = i; myAlarmNotification.specificProblems[i].problemClassId.majorId = 1; myAlarmNotification.specificProblems[i].problemClassId.minorId = 2; myAlarmNotification.specificProblems[i].problemClassId.vendorId = 33; myAlarmNotification.specificProblems[i].problemType = SA_NTF_VALUE_UINT32; myAlarmNotification.specificProblems[i].problemValue.uint32Val = (SaUint32T)(600+i); } for (i = 0; i < myAlarmNotification.numProposedRepairActions; i++) { myAlarmNotification.proposedRepairActions[i].actionId = i; myAlarmNotification.proposedRepairActions[i].actionValueType = SA_NTF_VALUE_UINT32; myAlarmNotification.proposedRepairActions[i].actionValue.uint32Val = (SaUint32T)(700+i); } *myAlarmNotification.trend = SA_NTF_TREND_MORE_SEVERE; myAlarmNotification.thresholdInformation->thresholdValueType = SA_NTF_VALUE_UINT32; myAlarmNotification.thresholdInformation->thresholdValue.uint32Val = 600; myAlarmNotification.thresholdInformation->thresholdHysteresis.uint32Val = 100; myAlarmNotification.thresholdInformation->observedValue.uint32Val = 567; myAlarmNotification.thresholdInformation->armTime = SA_TIME_UNKNOWN; myAlarmNotification.notificationHeader.correlatedNotifications[0] = 1999; myAlarmNotification.notificationHeader.correlatedNotifications[1] = 1984; safassert(saNtfNotificationSend(myAlarmNotification.notificationHandle), SA_AIS_OK); poll_until_received(ntfHandle, *myAlarmNotification.notificationHeader.notificationId); if(ntfRecieved.alarmFilterHandle != 1 || ntfRecieved.attributeChangeFilterHandle != 0 || ntfRecieved.objectCreateDeleteFilterHandle !=0 || ntfRecieved.securityAlarmFilterHandle != 0 || ntfRecieved.stateChangeFilterHandle != 0) safassert(SA_AIS_ERR_BAD_FLAGS, SA_AIS_OK); safassert(saNtfNotificationFree(myAlarmNotification.notificationHandle) , SA_AIS_OK); safassert(saNtfNotificationFilterFree(myAlarmFilter.notificationFilterHandle), SA_AIS_OK); safassert(saNtfNotificationUnsubscribe(subscriptionId), SA_AIS_OK); safassert(saNtfFinalize(ntfHandle), SA_AIS_OK); /* Allocated in fillInDefaultValues() */ free(myNotificationParams.additionalText); if(errors) rc = SA_AIS_ERR_FAILED_OPERATION; test_validate(rc, SA_AIS_OK); }
/** * Test the content of an alarm notification * Strategy: Set up a subscription and send a notification. * Check it. */ void alarmNotificationTest(void) { SaNtfAlarmNotificationFilterT myAlarmFilter; subscriptionId = 1; rc = SA_AIS_OK; resetCounters(); safassert(saNtfInitialize(&ntfHandle, &ntfCbTest, &ntfVersion) , SA_AIS_OK); safassert(saNtfSelectionObjectGet(ntfHandle, &selectionObject) , SA_AIS_OK); /* Set up the filters and subscription */ safassert(saNtfAlarmNotificationFilterAllocate( ntfHandle, &myAlarmFilter, 0, 0, 0, 0, 0, 2, 0), SA_AIS_OK); /* Set perceived severities */ myAlarmFilter.perceivedSeverities[0] = SA_NTF_SEVERITY_WARNING; myAlarmFilter.perceivedSeverities[1] = SA_NTF_SEVERITY_CLEARED; /* Initialize filter handles */ myNotificationFilterHandles.alarmFilterHandle = myAlarmFilter.notificationFilterHandle; myNotificationFilterHandles.attributeChangeFilterHandle = 0; myNotificationFilterHandles.objectCreateDeleteFilterHandle = 0; myNotificationFilterHandles.securityAlarmFilterHandle = 0; myNotificationFilterHandles.stateChangeFilterHandle = 0; safassert(saNtfNotificationSubscribe(&myNotificationFilterHandles, subscriptionId), SA_AIS_OK); /* Create a notification and send it */ safassert(saNtfAlarmNotificationAllocate( ntfHandle, &myAlarmNotification, 0, (SaUint16T)(strlen(DEFAULT_ADDITIONAL_TEXT) + 1), 0, 0, 0, 0, SA_NTF_ALLOC_SYSTEM_LIMIT), SA_AIS_OK); fillHeader(&myAlarmNotification.notificationHeader); /* determine perceived severity */ *(myAlarmNotification.perceivedSeverity) = SA_NTF_SEVERITY_WARNING; /* set probable cause*/ *(myAlarmNotification.probableCause) = SA_NTF_BANDWIDTH_REDUCED; *myAlarmNotification.trend = SA_NTF_TREND_MORE_SEVERE; myAlarmNotification.thresholdInformation->thresholdValueType = SA_NTF_VALUE_UINT32; myAlarmNotification.thresholdInformation->thresholdValue.uint32Val = 600; myAlarmNotification.thresholdInformation->thresholdHysteresis.uint32Val = 100; myAlarmNotification.thresholdInformation->observedValue.uint32Val = 567; myAlarmNotification.thresholdInformation->armTime = SA_TIME_UNKNOWN; safassert(saNtfNotificationSend(myAlarmNotification.notificationHandle), SA_AIS_OK); poll_until_received(ntfHandle, *myAlarmNotification.notificationHeader.notificationId); if(ntfRecieved.alarmFilterHandle != 1 || ntfRecieved.attributeChangeFilterHandle != 0 || ntfRecieved.objectCreateDeleteFilterHandle !=0 || ntfRecieved.securityAlarmFilterHandle != 0 || ntfRecieved.stateChangeFilterHandle != 0) safassert(SA_AIS_ERR_BAD_FLAGS, SA_AIS_OK); safassert(saNtfNotificationFree(myAlarmNotification.notificationHandle) , SA_AIS_OK); safassert(saNtfNotificationFilterFree(myAlarmFilter.notificationFilterHandle), SA_AIS_OK); safassert(saNtfNotificationUnsubscribe(subscriptionId), SA_AIS_OK); safassert(saNtfFinalize(ntfHandle), SA_AIS_OK); /* Allocated in fillInDefaultValues() */ free(myNotificationParams.additionalText); if(errors) rc = SA_AIS_ERR_FAILED_OPERATION; test_validate(rc, SA_AIS_OK); }
int main(int argc, char *argv[]) { int c; SaAisErrorT error; int timeout = -1; /* block indefintively in poll */ saNotificationFilterAllocationParamsT notificationFilterAllocationParams = {0}; SaNtfSubscriptionIdT subscriptionId = 1; struct option long_options[] = { {"alarm", no_argument, 0, 'a'}, {"attributeChange", no_argument, 0, 'c'}, {"objectCreateDelete", no_argument, 0, 'o'}, {"stateChange", no_argument, 0, 's'}, {"securityAlarm", no_argument, 0, 'y'}, {"help", no_argument, 0, 'h'}, {"timeout", required_argument, 0, 't'}, {"verbose", no_argument, 0, 'v'}, {0, 0, 0, 0} }; progname = argv[0]; /* Check options */ while (1) { c = getopt_long(argc, argv, "acosyht:v", long_options, NULL); if (c == -1) break; switch (c) { case 'a': used_filters.all = 0; used_filters.alarm = 1; break; case 'o': used_filters.all = 0; used_filters.obj_cr_del = 1; break; case 'c': used_filters.all = 0; used_filters.att_ch = 1; break; case 's': used_filters.all = 0; used_filters.st_ch = 1; break; case 'y': used_filters.all = 0; used_filters.sec_al = 1; break; case 't': timeout = atoi(optarg) * 1000; break; case 'v': verbose = 1; break; case 'h': case '?': default: usage(); break; } } error = saNtfInitialize(&ntfHandle, &ntfCallbacks, &version); if (SA_AIS_OK != error) { fprintf(stderr, "saNtfInitialize failed - %s\n", error_output(error)); exit(EXIT_FAILURE); } error = saNtfSelectionObjectGet(ntfHandle, &selObj); if (SA_AIS_OK != error) { fprintf(stderr, "saNtfSelectionObjectGet failed - %s\n", error_output(error)); exit(EXIT_FAILURE); } error = subscribeForNotifications(¬ificationFilterAllocationParams, subscriptionId); if (SA_AIS_OK != error) { fprintf(stderr, "subscribeForNotifications failed - %s\n", error_output(error)); exit(EXIT_FAILURE); } error = waitForNotifications(ntfHandle, selObj, timeout); if (SA_AIS_OK != error) { fprintf(stderr, "subscribeForNotifications failed - %s\n", error_output(error)); exit(EXIT_FAILURE); } error = saNtfNotificationUnsubscribe(subscriptionId); if (SA_AIS_OK != error) { fprintf(stderr, "waitForNotifications failed - %s\n", error_output(error)); exit(EXIT_FAILURE); } error = saNtfFinalize(ntfHandle); if (SA_AIS_OK != error) { fprintf(stderr, "saNtfFinalize failed - %s\n", error_output(error)); exit(EXIT_FAILURE); } exit(EXIT_SUCCESS); }