On 31-Jul-14 1:39 PM, Anders Widell wrote: > saAisNameLend() adds a terminating NUL character, so I think you would > still need strlen(saAisNameBorrow(&name)) + 2 + 1 even with Praveen's > patch, otherwise saAisNameLend() will write one byte past the end of > the allocated buffer when the string is shorter than 256 bytes.Another > concern is, can a notification be re-used and be sent multiple times? > The current version of the patch will not work in the (rare) case that > the string length is equal to kExtendedNameMagic. If string length is >= kExtendedNameMagic then NtfSend() API can return error as it is already doing it for other parameters. > Third concern: there is no check that the user has allocated enough > space. What if the user has by mistake allocated a buffer that is too > small, e.g. sizeof(SaNameT) bytes, when the string is longer than 256 > bytes? > This problem can come in any other service also. Does this require some extensions in saAis*.h in future. > The + 2 (or rather, + 2 + 1) will work, but it is a bit non-obvious. > It would need to be documented clearly since I see a potential for > user mistakes here. The user is not supposed to know or care about the > internal structure of SaNameT anymore; it is supposed to be opaque. My > proposal is that you instead handle extended SaNameT during encoding, > i.e. in encodeSaNtfValueT(). > > / Anders Widell > > On 07/31/2014 09:08 AM, minhchau wrote: >> Hi Anders, Praveen, >> >> sizeof(SaNameT) is not the right size to request the memory >> allocation any more. It should be the real size (length of string + 2 >> bytes of .length). It will looks like this >> >> saNtfPtrValAllocate(notHandle, strlen(saAisNameBorrow(&name)) + 2, >> (void**)&dest_ptr, >> &(head->additionalInfo[1].infoValue)); >> saAisNameLend((SaConstStringT)&test1_ext_notification_object, >> (SaNameT*) dest_ptr); >> >> @Praveen: I agree with you and can I take your patch for the next >> version? >> >> Thanks/Minh >> On 7/30/2014 10:53 PM, Anders Widell wrote: >>> Hi! >>> >>> This + 2 thing looks a bit hairy to me. The size of the SaNameT type >>> has not changed; it is exactly 258 bytes. Wouldn't it be more >>> natural if the client, when using the SA_NTF_VALUE_LDAP_NAME data >>> type, requests to allocate sizeof(SaNameT) bytes, and then stores a >>> pointer to the string in this allocated data by calling >>> saAisNameLend() ? >>> >>> Not sure how this code used to work before. What happened if the >>> user uses SA_NTF_VALUE_LDAP_NAME and requests to allocate space that >>> is smaller than sizeof(SaNameT)? I guess it would be OK, as long as >>> the size is large enough to hold the entire string as indicated by >>> the SaNameT.length field. But what happens if the allocated memory >>> is not large enough to hold the entire string? The NTF agent should >>> have a check for this, I guess... >>> >>> / Anders Widell >>> >>> On 07/30/2014 11:26 AM, praveen malviya wrote: >>>> >>>> On 30-Jul-14 7:17 AM, minhchau wrote: >>>>> Hi Praveen, >>>>> >>>>> I think the main purpose in your patch is to let the Send() API >>>>> takes care the variable_data and the client just simply uses >>>>> saAisNameLend() >>>>> >>>>> + saAisNameLend((SaConstStringT)&test1_ext_notification_object, >>>>> (SaNameT*) dest_ptr); >>>>> >>>>> Instead of: >>>>> >>>>> - *((SaUint16T*)dest_ptr) = *((SaUint16T*)&name); >>>>> - memcpy(dest_ptr + 2, saAisNameBorrow(&name), >>>>> strlen(saAisNameBorrow(&name))); >>>>> >>>>> Looks good, but it's risky because the >>>>> test1_ext_notification_object must not be changed/deallocated >>>>> before calling the Send() API. We can't stop the client doing >>>>> that, since test1_ext_notification_object could be reused for >>>>> other purpose, unless the client must have N string variables >>>>> (like this test1_ext_notification_object) if it wants to add >>>>> respectively N SA_NTF_VALUE_LDAP_NAME into AdditionalInfo >>>>> >>>> But, description of the SaAisNameLend() API says: >>>> " If length of the string >>>> is greater than or equal to >>>> SA_MAX_UNEXTENDED_NAME_LENGTH, no >>>> copying is performed. Instead, a reference to >>>> the original >>>> string is stored in the SaNameT type. In this >>>> case, it is >>>> therefore important that the original string is >>>> not modified >>>> or freed for as long as the SaNameT type may >>>> still used. >>>> " >>>> So a user should not reuse the same memory or should not modified >>>> till SaNameT is in use. >>>> Referring to this, I think, in the NTFsv case, we can change the >>>> test1_ext_notification_object only after calling Send() API. >>>> At the same time it is aligned with NTF service saNtf*Allocate() >>>> API also. A user calls saNtf*Allocate() API and fills the parameter >>>> and sends notification, then >>>> again refills the values and send the notification on same call of >>>> saNtf*Allocate() API. >>>> >>>> What do you think? >>>> >>>> Thanks, >>>> Praveen >>>> >>>> >>>>> Thanks, >>>>> Minh >>>>> On 7/28/2014 6:56 PM, praveen malviya wrote: >>>>>> Re: [PATCH 6 of 7] NTF: Add ntftest test cases for notification, >>>>>> with long dn objects [#873] v2 Hi Minh, >>>>>> >>>>>> I have tried a small patch to use saAisNameLend() for extended >>>>>> name in saNtfPtrValAllocate() for the discussed case. >>>>>> It is handled in Send() API. Patch is generated on top of V3 >>>>>> patchs and also includes relevant test changes in >>>>>> extFillHeaderAddInfo() in tet_longDnObject_notification.c. >>>>>> Please review it. >>>>>> >>>>>> Thanks >>>>>> Praveen >>>>>> On 18-Jul-14 5:22 AM, minhchau wrote: >>>>>>> Hi Praveen, >>>>>>> >>>>>>> Please find my comments inline >>>>>>> >>>>>>> Thanks, >>>>>>> Minh >>>>>>> On 7/17/2014 5:02 PM, praveen malviya wrote: >>>>>>>> Hi Minh, >>>>>>>> >>>>>>>> I saw the test and the way long DN is being used in the API. >>>>>>>> I tried to modified that in one way for short DN(below is the >>>>>>>> patch/diff on top this patch). >>>>>>>> >>>>>>>> But I have certain doubts: >>>>>>>> In case ldap_name is less the 256, it can be set directly using >>>>>>>> saAisNameLend(),below diff, and ntfsubscribe successfully >>>>>>>> receives it. >>>>>>>> This goes by the description of saAisNameLend() as in such a >>>>>>>> case the contents of the string is copied into the SaNameT type >>>>>>>> and can be read in a >>>>>>>> backwards compatible way by legacy applications that do not >>>>>>>> support the extended SaNameT format". >>>>>>>> Because of this I was able to set ldap_name directly using >>>>>>>> saAisNameLend(). >>>>>>>> >>>>>>>> But in case ldap_name is greater than 256 then saAisNameLend() >>>>>>>> description says "if length of the string >>>>>>>> is greater than or equal to SA_MAX_UNEXTENDED_NAME_LENGTH, no >>>>>>>> copying is performed. Instead, a reference to the original >>>>>>>> string is stored in the SaNameT type." >>>>>>>> So for long DN the same does not work and ntfsubscribe receives >>>>>>>> the garbage value because the buffer contains the reference and >>>>>>>> not the original value. >>>>>>>> But above description we know what saAisNanmeLend() has done. >>>>>>>> So I think we need to decide: this should be considered >>>>>>>> internally in the Send () API or let it to user to >>>>>>>> set the longDn as in the example test case. For >>>>>>>> notificationObject and NotifyingObject we are setting longDn by >>>>>>>> directly using saAisNameLend(). >>>>>>>> >>>>>>> [Minh]: I did think about "this should be considered internally >>>>>>> in the Send () API" in order that user can do the same way short >>>>>>> long dn has been specified. >>>>>>> And inside the Send() API, before sending the notification, we >>>>>>> have to re-package variable_data (reason that >>>>>>> *sizeof(SaNameT)+1* is not the right size any more). But this is >>>>>>> really inefficient >>>>>>> >>>>>>> In the other hands, the description of >>>>>>> saNtfPtrValAllocate(SaNtfNotificationHandleT notificationHandle, >>>>>>> SaUint16T dataSize, void **dataPtr, SaNtfValueT *value): >>>>>>> /*dataSize - [in] The number of bytes to be reserved.*//* >>>>>>> *//*dataPtr - [out] A pointer to a pointer to the memory >>>>>>> location that will be reserved with this function.*/ >>>>>>> >>>>>>> Thus, the dataSize is the number of bytes that user wants to put >>>>>>> the content of SaNameT (both short or long dn) into a chunk >>>>>>> inside variable_data which will be sent as part of notification >>>>>>> message. >>>>>>> The app built with extended name, using saAisNameXXX, should >>>>>>> understand that *sizeof(SaNameT)* is not the real size of >>>>>>> SaNameT's content any more. The way that user setting longdn is >>>>>>> upon the description of saNtfPtrValAllocate plus saAisNameXXX. >>>>>>> I wish to have: >>>>>>> *saAisNameEncode(SaNameT* name, char* bytes), which pours the >>>>>>> content of @.name into @.bytes. It is bit more *friendly*, and >>>>>>> keep user not to make the endian mistake, since user has to set >>>>>>> the length of string as well: >>>>>>> */ *((SaUint16T*)dest_ptr) = *((SaUint16T*)&name); /**/ >>>>>>> /**/ memcpy(dest_ptr + 2, saAisNameBorrow(&name), >>>>>>> strlen(saAisNameBorrow(&name)) + 1); /* >>>>>> But here, as in the test case, a user always have to keep in mind >>>>>> this "+2 " logic while setting the DN name and its length and >>>>>> while retreving it (we are doing it in ntfclient.c). >>>>>> >>>>>> >>>>>>> *saAisNameDecode(...) does in reverse. >>>>>>> These above functions can be done by user, but it'd be good to >>>>>>> have it as api that every user doesn't have to create it. >>>>>>> Above all of things, there's an exception that the legacy >>>>>>> application by somehow receives the longDn object, then it uses >>>>>>> the saNtfPtrValAllocate in the *legacy* way, that would be a >>>>>>> problem. But for now, I can't imagine which situation happening >>>>>>> >>>>>>>> What do you think? >>>>>>>> >>>>>>>> Thanks, >>>>>>>> Praveen >>>>>>>> >>>>>>>> Here is the modified test case of ldap_name less than 256: >>>>>>>> diff --git a/tests/ntfsv/tet_longDnObject_notification.c >>>>>>>> b/tests/ntfsv/tet_longDnObject_notification.c >>>>>>>> --- a/tests/ntfsv/tet_longDnObject_notification.c >>>>>>>> +++ b/tests/ntfsv/tet_longDnObject_notification.c >>>>>>>> @@ -359,15 +359,15 @@ void extFillHeader(SaNtfNotificationHead >>>>>>>> /* Fill fourth additionalInfo as unextended SaNameT */ >>>>>>>> head->additionalInfo[3].infoType = SA_NTF_VALUE_LDAP_NAME; >>>>>>>> head->additionalInfo[3].infoId = 1; >>>>>>>> - saAisNameLend(DEFAULT_UNEXT_NAME_STRING, &name); >>>>>>>> - >>>>>>>> + SaNameT *name_buffer; >>>>>>>> safassert(saNtfPtrValAllocate(notHandle, >>>>>>>> - strlen(saAisNameBorrow(&name)) + 2 + 1, >>>>>>>> - (void**)&dest_ptr, >>>>>>>> + sizeof(SaNameT)+ 1, >>>>>>>> + (void**)&name_buffer, >>>>>>>> &(head->additionalInfo[3].infoValue)), SA_AIS_OK); >>>>>>>> + saAisNameLend(DEFAULT_UNEXT_NAME_STRING, name_buffer); >>>>>>>> + //Comment log DN setting >>>>>>>> + >>>>>>>> //saAisNameLend((SaConstStringT)&test1_ext_notification_object, >>>>>>>> name_buffer); >>>>>>>> >>>>>>>> - *((SaUint16T*)dest_ptr) = *((SaUint16T*)&name); >>>>>>>> - memcpy(dest_ptr + 2, saAisNameBorrow(&name), >>>>>>>> strlen(saAisNameBorrow(&name)) + 1); >>>>>>>> } >>>>>>>> >>>>>>>> /** >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> On 17-Jul-14 5:55 AM, minhchau wrote: >>>>>>>>> Hi Praveen, >>>>>>>>> >>>>>>>>> Regarding extended name in AdditionalInfo, I have added the >>>>>>>>> test for it, as in extFillHeaderAddInfo() and >>>>>>>>> extAdditionalInfoTest(). >>>>>>>>> If the app built with extended name and using SaNameT in >>>>>>>>> AdditionalInfo, it certainly knows how the extented name >>>>>>>>> shaping, thus it has to change the way it specifies dataSize >>>>>>>>> and dataPtr (there's one example in extFillHeaderAddInfo) >>>>>>>>> osaf/tools/safntf/src/ntfclient.c has also fixed the crash >>>>>>>>> problem when ntfread/ntfsubscribe print extended name in >>>>>>>>> AdditionalInfo. >>>>>>>>> >>>>>>>>> Thanks, >>>>>>>>> Minh >>>>>>>>> >>>>>>>>> tests/ntfsv/Makefile.am | 3 +- >>>>>>>>> tests/ntfsv/tet_longDnObject_notification.c | 957 >>>>>>>>> ++++++++++++++++++++++++++++ >>>>>>>>> tests/unit_test_fw/inc/util.h | 5 +- >>>>>>>>> tests/unit_test_fw/src/Makefile.am | 1 + >>>>>>>>> tests/unit_test_fw/src/util.c | 14 +- >>>>>>>>> 5 files changed, 963 insertions(+), 17 deletions(-) >>>>>>>>> >>>>>>>>> >>>>>>>>> (1) Add testcase for AdditionalInfo with extended SaNameT >>>>>>>>> >>>>>>>>> diff --git a/tests/ntfsv/Makefile.am b/tests/ntfsv/Makefile.am >>>>>>>>> --- a/tests/ntfsv/Makefile.am >>>>>>>>> +++ b/tests/ntfsv/Makefile.am >>>>>>>>> @@ -64,7 +64,8 @@ ntftest_SOURCES = \ >>>>>>>>> tet_saNtfPtrValAllocate.c \ >>>>>>>>> tet_saNtfArrayValGet.c \ >>>>>>>>> tet_saNtfPtrValGet.c \ >>>>>>>>> - test_ntfFilterVerification.c >>>>>>>>> + test_ntfFilterVerification.c \ >>>>>>>>> + tet_longDnObject_notification.c >>>>>>>>> >>>>>>>>> ntftest_LDADD = \ >>>>>>>>> $(top_builddir)/tests/unit_test_fw/src/libutest.la >>>>>>>>> diff --git a/tests/ntfsv/tet_longDnObject_notification.c >>>>>>>>> b/tests/ntfsv/tet_longDnObject_notification.c >>>>>>>>> new file mode 100644 >>>>>>>>> --- /dev/null >>>>>>>>> +++ b/tests/ntfsv/tet_longDnObject_notification.c >>>>>>>>> @@ -0,0 +1,957 @@ >>>>>>>>> +/* -*- OpenSAF -*- >>>>>>>>> + * >>>>>>>>> + * (C) Copyright 2009 The OpenSAF Foundation >>>>>>>>> + * >>>>>>>>> + * This program is distributed in the hope that it will be >>>>>>>>> useful, but >>>>>>>>> + * WITHOUT ANY WARRANTY; without even the implied warranty of >>>>>>>>> MERCHANTABILITY >>>>>>>>> + * or FITNESS FOR A PARTICULAR PURPOSE. This file and program >>>>>>>>> are licensed >>>>>>>>> + * under the GNU Lesser General Public License Version 2.1, >>>>>>>>> February 1999. >>>>>>>>> + * The complete license can be accessed from the following >>>>>>>>> location: >>>>>>>>> + *http://opensource.org/licenses/lgpl-license.php >>>>>>>>> + * See the Copying file included with the OpenSAF >>>>>>>>> distribution for full >>>>>>>>> + * licensing terms. >>>>>>>>> + * >>>>>>>>> + * Author(s): Ericsson AB >>>>>>>>> + * >>>>>>>>> + */ >>>>>>>>> +/** >>>>>>>>> + >>>>>>>>> + */ >>>>>>>>> +#include <utest.h> >>>>>>>>> +#include <util.h> >>>>>>>>> +#include "tet_ntf.h" >>>>>>>>> +#include "tet_ntf_common.h" >>>>>>>>> +//#include "util.h" >>>>>>>>> +#define NOTIFYING_OBJECT_TEST "AVND" >>>>>>>>> +#define NTF_REST_MAX_IDS 30 >>>>>>>>> + >>>>>>>>> +#define DEFAULT_EXT_NAME_LENGTH 300 >>>>>>>>> +#define DEFAULT_UNEXT_NAME_STRING "This is unextended SaNameT >>>>>>>>> string (<256)" >>>>>>>>> +struct not_idsT { >>>>>>>>> + int length; >>>>>>>>> + SaNtfIdentifierT ids[NTF_REST_MAX_IDS]; >>>>>>>>> +}; >>>>>>>>> + >>>>>>>>> +static struct not_idsT received_ids = {0,}; >>>>>>>>> +static struct not_idsT ok_ids = {0,}; >>>>>>>>> + >>>>>>>>> +static char >>>>>>>>> default_ext_notification_object[DEFAULT_EXT_NAME_LENGTH]; >>>>>>>>> +static char >>>>>>>>> default_ext_notifying_object[DEFAULT_EXT_NAME_LENGTH]; >>>>>>>>> +static char >>>>>>>>> test1_ext_notification_object[DEFAULT_EXT_NAME_LENGTH]; >>>>>>>>> +static char test1_ext_notifying_object[DEFAULT_EXT_NAME_LENGTH]; >>>>>>>>> + >>>>>>>>> +static SaNtfNotificationTypeFilterHandlesT >>>>>>>>> myNotificationFilterHandles; >>>>>>>>> + >>>>>>>>> +/* Used to keep track of which ntf we got */ >>>>>>>>> +static SaNtfNotificationTypeFilterHandlesT ntfRecieved; >>>>>>>>> + >>>>>>>>> +static int errors; >>>>>>>>> +static SaNtfSubscriptionIdT subscriptionId; >>>>>>>>> +static SaNtfAlarmNotificationT myAlarmNotification; >>>>>>>>> +static SaNtfObjectCreateDeleteNotificationT >>>>>>>>> myObjCrDelNotification; >>>>>>>>> +static SaNtfAttributeChangeNotificationT >>>>>>>>> myAttrChangeNotification; >>>>>>>>> +static SaNtfStateChangeNotificationT myStateChangeNotification; >>>>>>>>> +static SaNtfSecurityAlarmNotificationT mySecAlarmNotification; >>>>>>>>> + >>>>>>>>> +extern void saAisNameLend(SaConstStringT value, SaNameT* name); >>>>>>>>> +extern SaConstStringT saAisNameBorrow(const SaNameT* name); >>>>>>>>> + >>>>>>>>> +/** >>>>>>>>> + * Init default long dn objects >>>>>>>>> + */ >>>>>>>>> +static void init_ext_object() >>>>>>>>> +{ >>>>>>>>> + safassert(setenv("SA_ENABLE_EXTENDED_NAMES", "1", 1), 0); >>>>>>>>> + >>>>>>>>> + memset(&default_ext_notification_object, 'A', >>>>>>>>> DEFAULT_EXT_NAME_LENGTH - 1); >>>>>>>>> + default_ext_notification_object[DEFAULT_EXT_NAME_LENGTH - 1] >>>>>>>>> = '\0'; >>>>>>>>> + >>>>>>>>> + memset(&default_ext_notifying_object, 'B', >>>>>>>>> DEFAULT_EXT_NAME_LENGTH - 1); >>>>>>>>> + default_ext_notifying_object[DEFAULT_EXT_NAME_LENGTH - 1] = >>>>>>>>> '\0'; >>>>>>>>> + >>>>>>>>> + memset(&test1_ext_notification_object, 'C', >>>>>>>>> DEFAULT_EXT_NAME_LENGTH - 1); >>>>>>>>> + test1_ext_notification_object[DEFAULT_EXT_NAME_LENGTH - 1] = >>>>>>>>> '\0'; >>>>>>>>> + >>>>>>>>> + memcpy(&test1_ext_notifying_object, >>>>>>>>> NOTIFYING_OBJECT_TEST, sizeof(NOTIFYING_OBJECT_TEST)); >>>>>>>>> +} >>>>>>>>> + >>>>>>>>> +/** >>>>>>>>> + * Store all recieved notificationIds >>>>>>>>> + */ >>>>>>>>> +static void ntf_id_store(SaNtfIdentifierT n_id) >>>>>>>>> +{ >>>>>>>>> + assert(NTF_REST_MAX_IDS > received_ids.length); >>>>>>>>> + received_ids.ids[received_ids.length++] = n_id; >>>>>>>>> +} >>>>>>>>> + >>>>>>>>> +/** >>>>>>>>> + * Post process all recived notificationIds towards the ids that >>>>>>>>> + * are expected to be received. >>>>>>>>> + */ >>>>>>>>> +static SaAisErrorT check_errors() >>>>>>>>> +{ >>>>>>>>> + int i, j, found; >>>>>>>>> + SaAisErrorT rc = SA_AIS_OK; >>>>>>>>> + >>>>>>>>> + for (i = 0; i< received_ids.length; i++) { >>>>>>>>> + found=0; >>>>>>>>> + for (j= 0; j< ok_ids.length; j++) { >>>>>>>>> + if (received_ids.ids[i] == ok_ids.ids[j]){ >>>>>>>>> + found = 1; >>>>>>>>> + break; >>>>>>>>> + } >>>>>>>>> + } >>>>>>>>> + if(!found) >>>>>>>>> + errors++; >>>>>>>>> + } >>>>>>>>> + if(errors) >>>>>>>>> + { >>>>>>>>> + rc = SA_AIS_ERR_FAILED_OPERATION; >>>>>>>>> + printf("num of failed notifications: %d\n", errors); >>>>>>>>> + } >>>>>>>>> + return rc; >>>>>>>>> +} >>>>>>>>> + >>>>>>>>> +static void resetCounters() >>>>>>>>> +{ >>>>>>>>> + errors = 0; >>>>>>>>> + received_ids.length = 0; >>>>>>>>> + ok_ids.length = 0; >>>>>>>>> + ntfRecieved.alarmFilterHandle = 0; >>>>>>>>> + ntfRecieved.attributeChangeFilterHandle = 0; >>>>>>>>> + ntfRecieved.objectCreateDeleteFilterHandle = 0; >>>>>>>>> + ntfRecieved.securityAlarmFilterHandle = 0; >>>>>>>>> + ntfRecieved.stateChangeFilterHandle = 0; >>>>>>>>> +} >>>>>>>>> + >>>>>>>>> +/** >>>>>>>>> + * Creates an ObjectCreateDeleteNotification with default >>>>>>>>> values. >>>>>>>>> + * >>>>>>>>> + * @param ntfHandle >>>>>>>>> + * @param myObjCreDelNotification >>>>>>>>> + */ >>>>>>>>> +void extCreateObjectCreateDeleteNotification(SaNtfHandleT >>>>>>>>> ntfHandle, >>>>>>>>> + SaNtfObjectCreateDeleteNotificationT >>>>>>>>> *myObjCrDelNotification) >>>>>>>>> +{ >>>>>>>>> + SaNtfNotificationHeaderT *head; >>>>>>>>> + >>>>>>>>> + createObjectCreateDeleteNotification(ntfHandle, >>>>>>>>> myObjCrDelNotification); >>>>>>>>> + head = &myObjCrDelNotification->notificationHeader; >>>>>>>>> + /* Overwrite with long dn object */ >>>>>>>>> + >>>>>>>>> saAisNameLend((SaConstStringT)&default_ext_notification_object, >>>>>>>>> head->notificationObject); >>>>>>>>> >>>>>>>>> + saAisNameLend((SaConstStringT)&default_ext_notifying_object, >>>>>>>>> head->notifyingObject); >>>>>>>>> +} >>>>>>>>> + >>>>>>>>> +/** >>>>>>>>> + * Creates an AttributeChangeNotification with default values. >>>>>>>>> + * >>>>>>>>> + * @param ntfhandle >>>>>>>>> + * @param myAttrChangeNotification >>>>>>>>> + */ >>>>>>>>> +void extCreateAttributeChangeNotification(SaNtfHandleT >>>>>>>>> ntfHandle, >>>>>>>>> + SaNtfAttributeChangeNotificationT >>>>>>>>> *myAttrChangeNotification) >>>>>>>>> +{ >>>>>>>>> + SaNtfNotificationHeaderT *head; >>>>>>>>> + >>>>>>>>> + createAttributeChangeNotification(ntfHandle, >>>>>>>>> myAttrChangeNotification); >>>>>>>>> + head = &myAttrChangeNotification->notificationHeader; >>>>>>>>> + /* Overwrite with long dn object */ >>>>>>>>> + >>>>>>>>> saAisNameLend((SaConstStringT)&default_ext_notification_object, >>>>>>>>> head->notificationObject); >>>>>>>>> >>>>>>>>> + saAisNameLend((SaConstStringT)&default_ext_notifying_object, >>>>>>>>> head->notifyingObject); >>>>>>>>> +} >>>>>>>>> + >>>>>>>>> +/** >>>>>>>>> + * Create a StateChangeNotification with default values. >>>>>>>>> + * >>>>>>>>> + * @param ntfHandle >>>>>>>>> + * @param myStateChangeNotification >>>>>>>>> + */ >>>>>>>>> +void extCreateStateChangeNotification(SaNtfHandleT ntfHandle, >>>>>>>>> + SaNtfStateChangeNotificationT >>>>>>>>> *myStateChangeNotification) >>>>>>>>> +{ >>>>>>>>> + SaNtfNotificationHeaderT *head; >>>>>>>>> + >>>>>>>>> + createStateChangeNotification(ntfHandle, >>>>>>>>> myStateChangeNotification); >>>>>>>>> + head = &myStateChangeNotification->notificationHeader; >>>>>>>>> + /* Overwrite with long dn object */ >>>>>>>>> + >>>>>>>>> saAisNameLend((SaConstStringT)&default_ext_notification_object, >>>>>>>>> head->notificationObject); >>>>>>>>> >>>>>>>>> + saAisNameLend((SaConstStringT)&default_ext_notifying_object, >>>>>>>>> head->notifyingObject); >>>>>>>>> +} >>>>>>>>> + >>>>>>>>> +/** >>>>>>>>> + * Create a SecurityAlarmNotification with default values. >>>>>>>>> + * >>>>>>>>> + * @param ntfHandle >>>>>>>>> + * @param mySecAlarmNotification >>>>>>>>> + */ >>>>>>>>> +void extCreateSecurityAlarmNotification(SaNtfHandleT ntfHandle, >>>>>>>>> + SaNtfSecurityAlarmNotificationT *mySecAlarmNotification) >>>>>>>>> +{ >>>>>>>>> + SaNtfNotificationHeaderT *head; >>>>>>>>> + >>>>>>>>> + createSecurityAlarmNotification(ntfHandle, >>>>>>>>> mySecAlarmNotification); >>>>>>>>> + head = &mySecAlarmNotification->notificationHeader; >>>>>>>>> + /* Overwrite with long dn object */ >>>>>>>>> + >>>>>>>>> saAisNameLend((SaConstStringT)&default_ext_notification_object, >>>>>>>>> head->notificationObject); >>>>>>>>> >>>>>>>>> + saAisNameLend((SaConstStringT)&default_ext_notifying_object, >>>>>>>>> head->notifyingObject); >>>>>>>>> +} >>>>>>>>> + >>>>>>>>> +/** >>>>>>>>> + * Verify the contents in the notification. >>>>>>>>> + * We use the myNotificationFilterHandles to know which >>>>>>>>> notifications to expect. >>>>>>>>> + */ >>>>>>>>> +static void saNtfNotificationCallbackT( >>>>>>>>> + SaNtfSubscriptionIdT subscriptionId, >>>>>>>>> + const SaNtfNotificationsT *notification) >>>>>>>>> +{ >>>>>>>>> + SaNtfNotificationHandleT notificationHandle = 0; >>>>>>>>> + switch(notification->notificationType) >>>>>>>>> + { >>>>>>>>> + case SA_NTF_TYPE_OBJECT_CREATE_DELETE: >>>>>>>>> + notificationHandle = >>>>>>>>> notification->notification.objectCreateDeleteNotification.notificationHandle; >>>>>>>>> + ntfRecieved.objectCreateDeleteFilterHandle += 1; >>>>>>>>> + >>>>>>>>> if(myNotificationFilterHandles.objectCreateDeleteFilterHandle >>>>>>>>> == 0) >>>>>>>>> + errors +=1; >>>>>>>>> + else >>>>>>>>> + >>>>>>>>> ntf_id_store(*notification->notification.objectCreateDeleteNotification.notificationHeader.notificationId); >>>>>>>>> + break; >>>>>>>>> + >>>>>>>>> + case SA_NTF_TYPE_ATTRIBUTE_CHANGE: >>>>>>>>> + notificationHandle = >>>>>>>>> notification->notification.attributeChangeNotification.notificationHandle; >>>>>>>>> + ntfRecieved.attributeChangeFilterHandle += 1; >>>>>>>>> + if(myNotificationFilterHandles.attributeChangeFilterHandle >>>>>>>>> == 0) >>>>>>>>> + errors += 1; >>>>>>>>> + else >>>>>>>>> + >>>>>>>>> ntf_id_store(*notification->notification.attributeChangeNotification.notificationHeader.notificationId); >>>>>>>>> + break; >>>>>>>>> + >>>>>>>>> + case SA_NTF_TYPE_STATE_CHANGE: >>>>>>>>> + notificationHandle = >>>>>>>>> notification->notification.stateChangeNotification.notificationHandle; >>>>>>>>> + ntfRecieved.stateChangeFilterHandle += 1; >>>>>>>>> + if(myNotificationFilterHandles.stateChangeFilterHandle == 0) >>>>>>>>> + errors += 1; >>>>>>>>> + else >>>>>>>>> + >>>>>>>>> ntf_id_store(*notification->notification.stateChangeNotification.notificationHeader.notificationId); >>>>>>>>> + break; >>>>>>>>> + >>>>>>>>> + case SA_NTF_TYPE_ALARM: >>>>>>>>> + notificationHandle = >>>>>>>>> notification->notification.alarmNotification.notificationHandle; >>>>>>>>> + ntfRecieved.alarmFilterHandle += 1; >>>>>>>>> + if(myNotificationFilterHandles.alarmFilterHandle == 0) { >>>>>>>>> + printf("alarmFilterHandle == 0\n"); >>>>>>>>> + errors +=1; >>>>>>>>> + } else >>>>>>>>> + >>>>>>>>> ntf_id_store(*notification->notification.alarmNotification.notificationHeader.notificationId); >>>>>>>>> + break; >>>>>>>>> + >>>>>>>>> + case SA_NTF_TYPE_SECURITY_ALARM: >>>>>>>>> + notificationHandle = >>>>>>>>> notification->notification.securityAlarmNotification.notificationHandle; >>>>>>>>> + ntfRecieved.securityAlarmFilterHandle += 1; >>>>>>>>> + if(myNotificationFilterHandles.securityAlarmFilterHandle == 0) >>>>>>>>> + errors += 1; >>>>>>>>> + else >>>>>>>>> + >>>>>>>>> ntf_id_store(*notification->notification.securityAlarmNotification.notificationHeader.notificationId); >>>>>>>>> + break; >>>>>>>>> + >>>>>>>>> + default: >>>>>>>>> + errors +=1; >>>>>>>>> + assert(0); >>>>>>>>> + break; >>>>>>>>> + } >>>>>>>>> + last_not_id = get_ntf_id(notification); >>>>>>>>> + if (notificationHandle != 0) >>>>>>>>> + safassert(saNtfNotificationFree(notificationHandle), >>>>>>>>> SA_AIS_OK); >>>>>>>>> +} >>>>>>>>> + >>>>>>>>> + >>>>>>>>> +static SaNtfCallbacksT ntfCbTest = { >>>>>>>>> + saNtfNotificationCallbackT, >>>>>>>>> + NULL >>>>>>>>> +}; >>>>>>>>> + >>>>>>>>> +/** >>>>>>>>> + * Fill the filter header with long dn objects >>>>>>>>> + */ >>>>>>>>> +void extFillFilterHeader(SaNtfNotificationFilterHeaderT *head) >>>>>>>>> +{ >>>>>>>>> + fillFilterHeader(head); >>>>>>>>> + /* Overwrite the objects with long dn */ >>>>>>>>> + >>>>>>>>> saAisNameLend((SaConstStringT)&default_ext_notification_object, >>>>>>>>> &head->notificationObjects[0]); >>>>>>>>> >>>>>>>>> + saAisNameLend((SaConstStringT)&default_ext_notifying_object, >>>>>>>>> &head->notifyingObjects[0]); >>>>>>>>> +} >>>>>>>>> + >>>>>>>>> +/** >>>>>>>>> + * Fill the header with long dn objects >>>>>>>>> + */ >>>>>>>>> +void extFillHeader(SaNtfNotificationHeaderT *head) >>>>>>>>> +{ >>>>>>>>> + fillHeader(head); >>>>>>>>> + /* Overwrite the objects with long dn */ >>>>>>>>> + >>>>>>>>> saAisNameLend((SaConstStringT)&default_ext_notification_object, >>>>>>>>> head->notificationObject); >>>>>>>>> >>>>>>>>> + saAisNameLend((SaConstStringT)&default_ext_notifying_object, >>>>>>>>> head->notifyingObject); >>>>>>>>> +} >>>>>>>>> + >>>>>>>>> + >>>>>>>>> +/** >>>>>>>>> + * Fill header with extended SaNameT in additionalInfo >>>>>>>>> + */ >>>>>>>>> + void extFillHeaderAddInfo(SaNtfNotificationHeaderT *head, >>>>>>>>> SaNtfNotificationHandleT notHandle) >>>>>>>>> + { >>>>>>>>> + int i; >>>>>>>>> + SaStringT dest_ptr; >>>>>>>>> + SaNameT name; >>>>>>>>> + *(head->eventType) = SA_NTF_ALARM_COMMUNICATION; >>>>>>>>> + *(head->eventTime) = SA_TIME_UNKNOWN; >>>>>>>>> + >>>>>>>>> + >>>>>>>>> saAisNameLend((SaConstStringT)&default_ext_notification_object, >>>>>>>>> head->notificationObject); >>>>>>>>> >>>>>>>>> + saAisNameLend((SaConstStringT)&default_ext_notifying_object, >>>>>>>>> head->notifyingObject); >>>>>>>>> + >>>>>>>>> + head->notificationClassId->vendorId = ERICSSON_VENDOR_ID; >>>>>>>>> + head->notificationClassId->majorId = 92; >>>>>>>>> + head->notificationClassId->minorId = 12; >>>>>>>>> + >>>>>>>>> + /* set additional text */ >>>>>>>>> + (void)strncpy(head->additionalText, >>>>>>>>> + DEFAULT_ADDITIONAL_TEXT, >>>>>>>>> + (SaUint16T)(strlen(DEFAULT_ADDITIONAL_TEXT) + 1)); >>>>>>>>> + >>>>>>>>> + for (i = 0; i < head->numCorrelatedNotifications; i++) >>>>>>>>> + head->correlatedNotifications[i] = (SaNtfIdentifierT) >>>>>>>>> (i + 400); >>>>>>>>> + >>>>>>>>> + /* Fill first additionalInfo as extended SaNameT >>>>>>>>> including NULL character */ >>>>>>>>> + head->additionalInfo[0].infoType = SA_NTF_VALUE_LDAP_NAME; >>>>>>>>> + head->additionalInfo[0].infoId = 1; >>>>>>>>> + >>>>>>>>> saAisNameLend((SaConstStringT)&test1_ext_notification_object, >>>>>>>>> &name); >>>>>>>>> + >>>>>>>>> + safassert(saNtfPtrValAllocate(notHandle, >>>>>>>>> + strlen(saAisNameBorrow(&name)) + 2 + 1, >>>>>>>>> + (void**)&dest_ptr, >>>>>>>>> + &(head->additionalInfo[0].infoValue)), SA_AIS_OK); >>>>>>>>> + >>>>>>>>> + *((SaUint16T*)dest_ptr) = *((SaUint16T*)&name); >>>>>>>>> + memcpy(dest_ptr + 2, saAisNameBorrow(&name), >>>>>>>>> strlen(saAisNameBorrow(&name)) + 1); >>>>>>>>> + >>>>>>>>> + /* Fill first additionalInfo as extended SaNameT >>>>>>>>> excluding NULL character */ >>>>>>>>> + head->additionalInfo[1].infoType = SA_NTF_VALUE_LDAP_NAME; >>>>>>>>> + head->additionalInfo[1].infoId = 1; >>>>>>>>> + >>>>>>>>> saAisNameLend((SaConstStringT)&test1_ext_notification_object, >>>>>>>>> &name); >>>>>>>>> + >>>>>>>>> + safassert(saNtfPtrValAllocate(notHandle, >>>>>>>>> + strlen(saAisNameBorrow(&name)) + 2, >>>>>>>>> + (void**)&dest_ptr, >>>>>>>>> + &(head->additionalInfo[1].infoValue)), SA_AIS_OK); >>>>>>>>> + >>>>>>>>> + *((SaUint16T*)dest_ptr) = *((SaUint16T*)&name); >>>>>>>>> + memcpy(dest_ptr + 2, saAisNameBorrow(&name), >>>>>>>>> strlen(saAisNameBorrow(&name))); >>>>>>>>> + >>>>>>>>> + /* Fill third additionalInfo as unextended SaNameT as >>>>>>>>> legacy code */ >>>>>>>>> + head->additionalInfo[2].infoType = SA_NTF_VALUE_LDAP_NAME; >>>>>>>>> + head->additionalInfo[2].infoId = 1; >>>>>>>>> + saAisNameLend(DEFAULT_UNEXT_NAME_STRING, &name); >>>>>>>>> + >>>>>>>>> + safassert(saNtfPtrValAllocate(notHandle, >>>>>>>>> + sizeof(name), >>>>>>>>> + (void**)&dest_ptr, >>>>>>>>> + &(head->additionalInfo[2].infoValue)), SA_AIS_OK); >>>>>>>>> + >>>>>>>>> + memcpy(dest_ptr, &name, sizeof(name)); >>>>>>>>> + >>>>>>>>> + /* Fill fourth additionalInfo as unextended SaNameT */ >>>>>>>>> + head->additionalInfo[3].infoType = SA_NTF_VALUE_LDAP_NAME; >>>>>>>>> + head->additionalInfo[3].infoId = 1; >>>>>>>>> + saAisNameLend(DEFAULT_UNEXT_NAME_STRING, &name); >>>>>>>>> + >>>>>>>>> + safassert(saNtfPtrValAllocate(notHandle, >>>>>>>>> + strlen(saAisNameBorrow(&name)) + 2 + 1, >>>>>>>>> + (void**)&dest_ptr, >>>>>>>>> + &(head->additionalInfo[3].infoValue)), SA_AIS_OK); >>>>>>>>> + >>>>>>>>> + *((SaUint16T*)dest_ptr) = *((SaUint16T*)&name); >>>>>>>>> + memcpy(dest_ptr + 2, saAisNameBorrow(&name), >>>>>>>>> strlen(saAisNameBorrow(&name)) + 1); >>>>>>>>> + } >>>>>>>>> + >>>>>>>>> + /** >>>>>>>>> + * Test AdditionalInfo with extended SaNameT type >>>>>>>>> + */ >>>>>>>>> + void extAdditionalInfoTest(void) >>>>>>>>> + { >>>>>>>>> + SaNtfAlarmNotificationFilterT myAlarmFilter; >>>>>>>>> + subscriptionId = 1; >>>>>>>>> + SaNtfNotificationHeaderT *head; >>>>>>>>> + >>>>>>>>> + rc = SA_AIS_OK; >>>>>>>>> + >>>>>>>>> + resetCounters(); >>>>>>>>> + >>>>>>>>> + safassert(saNtfInitialize(&ntfHandle, &ntfCbTest, >>>>>>>>> &ntfVersion) , SA_AIS_OK); >>>>>>>>> + safassert(saNtfSelectionObjectGet(ntfHandle, >>>>>>>>> &selectionObject) , SA_AIS_OK); >>>>>>>>> + >>>>>>>>> + /* specify complex filter */ >>>>>>>>> + safassert(saNtfAlarmNotificationFilterAllocate( >>>>>>>>> + ntfHandle, >>>>>>>>> + &myAlarmFilter, >>>>>>>>> + 1, >>>>>>>>> + 1, >>>>>>>>> + 1, >>>>>>>>> + 1, >>>>>>>>> + 0, >>>>>>>>> + 0, >>>>>>>>> + 0), SA_AIS_OK); >>>>>>>>> + /* set header filter specific fields */ >>>>>>>>> + extFillFilterHeader(&myAlarmFilter.notificationFilterHeader); >>>>>>>>> + >>>>>>>>> + /* 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), >>>>>>>>> + 4, >>>>>>>>> + 0, >>>>>>>>> + 0, >>>>>>>>> + 0, >>>>>>>>> + SA_NTF_ALLOC_SYSTEM_LIMIT), SA_AIS_OK); >>>>>>>>> + >>>>>>>>> + head = &myAlarmNotification.notificationHeader; >>>>>>>>> + extFillHeaderAddInfo(head, >>>>>>>>> myAlarmNotification.notificationHandle); >>>>>>>>> + /* These 3 fields is alarm filter items */ >>>>>>>>> + *(myAlarmNotification.perceivedSeverity) = >>>>>>>>> SA_NTF_SEVERITY_WARNING; >>>>>>>>> + *(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); >>>>>>>>> + >>>>>>>>> + /* only this notification should be caught */ >>>>>>>>> + ok_ids.ids[ok_ids.length++] = >>>>>>>>> *myAlarmNotification.notificationHeader.notificationId; >>>>>>>>> + 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); >>>>>>>>> + rc = check_errors(); >>>>>>>>> + test_validate(rc, SA_AIS_OK); >>>>>>>>> + } >>>>>>>>> + >>>>>>>>> +/** >>>>>>>>> + * Test all filter header fields >>>>>>>>> + */ >>>>>>>>> +void extFilterNotificationTest(void) >>>>>>>>> +{ >>>>>>>>> + SaNtfAlarmNotificationFilterT myAlarmFilter; >>>>>>>>> + subscriptionId = 1; >>>>>>>>> + SaNtfNotificationHeaderT *head; >>>>>>>>> + >>>>>>>>> + rc = SA_AIS_OK; >>>>>>>>> + >>>>>>>>> + resetCounters(); >>>>>>>>> + >>>>>>>>> + safassert(saNtfInitialize(&ntfHandle, &ntfCbTest, >>>>>>>>> &ntfVersion) , SA_AIS_OK); >>>>>>>>> + safassert(saNtfSelectionObjectGet(ntfHandle, >>>>>>>>> &selectionObject) , SA_AIS_OK); >>>>>>>>> + >>>>>>>>> + /* specify complex filter */ >>>>>>>>> + safassert(saNtfAlarmNotificationFilterAllocate( >>>>>>>>> + ntfHandle, >>>>>>>>> + &myAlarmFilter, >>>>>>>>> + 1, >>>>>>>>> + 1, >>>>>>>>> + 1, >>>>>>>>> + 1, >>>>>>>>> + 0, >>>>>>>>> + 0, >>>>>>>>> + 0), SA_AIS_OK); >>>>>>>>> + /* set header filter specific fields */ >>>>>>>>> + extFillFilterHeader(&myAlarmFilter.notificationFilterHeader); >>>>>>>>> + >>>>>>>>> + /* 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); >>>>>>>>> + >>>>>>>>> + head = &myAlarmNotification.notificationHeader; >>>>>>>>> + extFillHeader(head); >>>>>>>>> + >>>>>>>>> + /* These 3 fields is alarm filter items */ >>>>>>>>> + *(myAlarmNotification.perceivedSeverity) = >>>>>>>>> SA_NTF_SEVERITY_WARNING; >>>>>>>>> + *(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; >>>>>>>>> + >>>>>>>>> + *(head->eventType) = SA_NTF_ALARM_EQUIPMENT; >>>>>>>>> + >>>>>>>>> safassert(saNtfNotificationSend(myAlarmNotification.notificationHandle), >>>>>>>>> >>>>>>>>> SA_AIS_OK); >>>>>>>>> + >>>>>>>>> + >>>>>>>>> saAisNameLend((SaConstStringT)&test1_ext_notification_object, >>>>>>>>> head->notificationObject); >>>>>>>>> + >>>>>>>>> safassert(saNtfNotificationSend(myAlarmNotification.notificationHandle), >>>>>>>>> >>>>>>>>> SA_AIS_OK); >>>>>>>>> + >>>>>>>>> + extFillHeader(head); >>>>>>>>> + saAisNameLend((SaConstStringT)&test1_ext_notifying_object, >>>>>>>>> head->notifyingObject); >>>>>>>>> + >>>>>>>>> safassert(saNtfNotificationSend(myAlarmNotification.notificationHandle), >>>>>>>>> >>>>>>>>> SA_AIS_OK); >>>>>>>>> + >>>>>>>>> + extFillHeader(head); >>>>>>>>> + head->notificationClassId->vendorId = 199; >>>>>>>>> + >>>>>>>>> safassert(saNtfNotificationSend(myAlarmNotification.notificationHandle), >>>>>>>>> >>>>>>>>> SA_AIS_OK); >>>>>>>>> + >>>>>>>>> + extFillHeader(head); >>>>>>>>> + head->notificationClassId->majorId = 89; >>>>>>>>> + >>>>>>>>> safassert(saNtfNotificationSend(myAlarmNotification.notificationHandle), >>>>>>>>> >>>>>>>>> SA_AIS_OK); >>>>>>>>> + >>>>>>>>> + extFillHeader(head); >>>>>>>>> + head->notificationClassId->minorId = 24; >>>>>>>>> + >>>>>>>>> safassert(saNtfNotificationSend(myAlarmNotification.notificationHandle), >>>>>>>>> >>>>>>>>> SA_AIS_OK); >>>>>>>>> + >>>>>>>>> + extFillHeader(head); >>>>>>>>> + >>>>>>>>> safassert(saNtfNotificationSend(myAlarmNotification.notificationHandle), >>>>>>>>> >>>>>>>>> SA_AIS_OK); >>>>>>>>> + >>>>>>>>> + /* only this notification should be caught */ >>>>>>>>> + ok_ids.ids[ok_ids.length++] = >>>>>>>>> *myAlarmNotification.notificationHeader.notificationId; >>>>>>>>> + 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); >>>>>>>>> + rc = check_errors(); >>>>>>>>> + test_validate(rc, SA_AIS_OK); >>>>>>>>> +} >>>>>>>>> + >>>>>>>>> +/** >>>>>>>>> + * Test Alarm notification with long dn objects >>>>>>>>> + */ >>>>>>>>> +void extAlarmNotificationTest(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); >>>>>>>>> + >>>>>>>>> + safassert(saNtfAlarmNotificationFilterAllocate( >>>>>>>>> + ntfHandle, >>>>>>>>> + &myAlarmFilter, >>>>>>>>> + 0, >>>>>>>>> + 0, >>>>>>>>> + 0, >>>>>>>>> + 0, >>>>>>>>> + 1, >>>>>>>>> + 1, >>>>>>>>> + 1), SA_AIS_OK); >>>>>>>>> + /* Set perceived severities */ >>>>>>>>> + myAlarmFilter.perceivedSeverities[0] = >>>>>>>>> SA_NTF_SEVERITY_WARNING; >>>>>>>>> + myAlarmFilter.probableCauses[0] = SA_NTF_BANDWIDTH_REDUCED; >>>>>>>>> + myAlarmFilter.trends[0] = SA_NTF_TREND_MORE_SEVERE; >>>>>>>>> + >>>>>>>>> + /* 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); >>>>>>>>> + extFillHeader(&myAlarmNotification.notificationHeader); >>>>>>>>> + >>>>>>>>> + *(myAlarmNotification.perceivedSeverity) = >>>>>>>>> SA_NTF_SEVERITY_CRITICAL; >>>>>>>>> + *(myAlarmNotification.probableCause) = >>>>>>>>> SA_NTF_CALL_ESTABLISHMENT_ERROR; >>>>>>>>> + *myAlarmNotification.trend = SA_NTF_TREND_NO_CHANGE; >>>>>>>>> + >>>>>>>>> safassert(saNtfNotificationSend(myAlarmNotification.notificationHandle), >>>>>>>>> >>>>>>>>> SA_AIS_OK); >>>>>>>>> + >>>>>>>>> + *(myAlarmNotification.perceivedSeverity) = >>>>>>>>> SA_NTF_SEVERITY_WARNING; >>>>>>>>> + *(myAlarmNotification.probableCause) = >>>>>>>>> SA_NTF_PRESSURE_UNACCEPTABLE; >>>>>>>>> + >>>>>>>>> safassert(saNtfNotificationSend(myAlarmNotification.notificationHandle), >>>>>>>>> >>>>>>>>> SA_AIS_OK); >>>>>>>>> + >>>>>>>>> + *(myAlarmNotification.perceivedSeverity) = >>>>>>>>> SA_NTF_SEVERITY_WARNING; >>>>>>>>> + *(myAlarmNotification.probableCause) = >>>>>>>>> SA_NTF_BANDWIDTH_REDUCED; >>>>>>>>> + *myAlarmNotification.trend = SA_NTF_TREND_NO_CHANGE; >>>>>>>>> + >>>>>>>>> safassert(saNtfNotificationSend(myAlarmNotification.notificationHandle), >>>>>>>>> >>>>>>>>> SA_AIS_OK); >>>>>>>>> + >>>>>>>>> + extFillHeader(&myAlarmNotification.notificationHeader); >>>>>>>>> + /* These 3 fields is filter items */ >>>>>>>>> + *(myAlarmNotification.perceivedSeverity) = >>>>>>>>> SA_NTF_SEVERITY_WARNING; >>>>>>>>> + *(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); >>>>>>>>> + /* only this notification should be caught*/ >>>>>>>>> + ok_ids.ids[ok_ids.length++] = >>>>>>>>> *myAlarmNotification.notificationHeader.notificationId; >>>>>>>>> + 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); >>>>>>>>> + rc = check_errors(); >>>>>>>>> + test_validate(rc, SA_AIS_OK); >>>>>>>>> +} >>>>>>>>> + >>>>>>>>> +/** >>>>>>>>> + * Test Object Create/Delete notification with long dn objects >>>>>>>>> + */ >>>>>>>>> +void extObjectCreateDeleteNotificationTest(void) >>>>>>>>> +{ >>>>>>>>> + SaNtfObjectCreateDeleteNotificationFilterT myFilter; >>>>>>>>> + >>>>>>>>> + subscriptionId = 2; >>>>>>>>> + >>>>>>>>> + resetCounters(); >>>>>>>>> + >>>>>>>>> + safassert(saNtfInitialize(&ntfHandle, &ntfCbTest, >>>>>>>>> &ntfVersion) , SA_AIS_OK); >>>>>>>>> + safassert(saNtfSelectionObjectGet(ntfHandle, >>>>>>>>> &selectionObject) , SA_AIS_OK); >>>>>>>>> + >>>>>>>>> + safassert(saNtfObjectCreateDeleteNotificationFilterAllocate( >>>>>>>>> + ntfHandle, >>>>>>>>> + &myFilter, >>>>>>>>> + 1, >>>>>>>>> + 1, >>>>>>>>> + 1, >>>>>>>>> + 1, >>>>>>>>> + 2), SA_AIS_OK); >>>>>>>>> + myFilter.sourceIndicators[0] = SA_NTF_OBJECT_OPERATION; >>>>>>>>> + myFilter.sourceIndicators[1] = SA_NTF_MANAGEMENT_OPERATION; >>>>>>>>> + extFillFilterHeader(&myFilter.notificationFilterHeader); >>>>>>>>> + myFilter.notificationFilterHeader.eventTypes[0] = >>>>>>>>> SA_NTF_OBJECT_CREATION; >>>>>>>>> + /* Initialize filter handles */ >>>>>>>>> + myNotificationFilterHandles.alarmFilterHandle = 0; >>>>>>>>> + myNotificationFilterHandles.attributeChangeFilterHandle = 0; >>>>>>>>> + myNotificationFilterHandles.objectCreateDeleteFilterHandle = >>>>>>>>> + myFilter.notificationFilterHandle; >>>>>>>>> + myNotificationFilterHandles.securityAlarmFilterHandle = 0; >>>>>>>>> + myNotificationFilterHandles.stateChangeFilterHandle = 0; >>>>>>>>> + >>>>>>>>> safassert(saNtfNotificationSubscribe(&myNotificationFilterHandles, >>>>>>>>> >>>>>>>>> + subscriptionId), SA_AIS_OK); >>>>>>>>> + extCreateObjectCreateDeleteNotification(ntfHandle, >>>>>>>>> &myObjCrDelNotification); >>>>>>>>> + *(myObjCrDelNotification.sourceIndicator) = >>>>>>>>> SA_NTF_OBJECT_OPERATION; >>>>>>>>> + >>>>>>>>> safassert(saNtfNotificationSend(myObjCrDelNotification.notificationHandle), >>>>>>>>> >>>>>>>>> SA_AIS_OK); >>>>>>>>> + /* this notification should be caught*/ >>>>>>>>> + ok_ids.ids[ok_ids.length++] = >>>>>>>>> *myObjCrDelNotification.notificationHeader.notificationId; >>>>>>>>> + >>>>>>>>> + *(myObjCrDelNotification.sourceIndicator) = >>>>>>>>> SA_NTF_UNKNOWN_OPERATION; >>>>>>>>> + >>>>>>>>> safassert(saNtfNotificationSend(myObjCrDelNotification.notificationHandle), >>>>>>>>> >>>>>>>>> SA_AIS_OK); >>>>>>>>> + >>>>>>>>> + *(myObjCrDelNotification.sourceIndicator) = >>>>>>>>> SA_NTF_MANAGEMENT_OPERATION; >>>>>>>>> + >>>>>>>>> safassert(saNtfNotificationSend(myObjCrDelNotification.notificationHandle), >>>>>>>>> >>>>>>>>> SA_AIS_OK); >>>>>>>>> + /* this notification should be caught*/ >>>>>>>>> + ok_ids.ids[ok_ids.length++] = >>>>>>>>> *myObjCrDelNotification.notificationHeader.notificationId; >>>>>>>>> + poll_until_received(ntfHandle, >>>>>>>>> *myObjCrDelNotification.notificationHeader.notificationId); >>>>>>>>> + if(ntfRecieved.alarmFilterHandle != 0 || >>>>>>>>> + ntfRecieved.attributeChangeFilterHandle != 0 || >>>>>>>>> + ntfRecieved.objectCreateDeleteFilterHandle != ok_ids.length|| >>>>>>>>> + ntfRecieved.securityAlarmFilterHandle != 0 || >>>>>>>>> + ntfRecieved.stateChangeFilterHandle != 0) >>>>>>>>> safassert(SA_AIS_ERR_BAD_FLAGS, SA_AIS_OK); >>>>>>>>> + >>>>>>>>> safassert(saNtfNotificationFree(myObjCrDelNotification.notificationHandle), >>>>>>>>> >>>>>>>>> SA_AIS_OK); >>>>>>>>> + >>>>>>>>> safassert(saNtfNotificationFilterFree(myFilter.notificationFilterHandle), >>>>>>>>> >>>>>>>>> SA_AIS_OK); >>>>>>>>> + >>>>>>>>> + safassert(saNtfNotificationUnsubscribe(subscriptionId), >>>>>>>>> SA_AIS_OK); >>>>>>>>> + safassert(saNtfFinalize(ntfHandle) , SA_AIS_OK); >>>>>>>>> + rc = check_errors(); >>>>>>>>> + test_validate(rc, SA_AIS_OK); >>>>>>>>> +} >>>>>>>>> + >>>>>>>>> +/** >>>>>>>>> + * Test Attribute Change notification with long dn objects >>>>>>>>> + */ >>>>>>>>> +void extAttributeChangeNotificationTest(void) >>>>>>>>> +{ >>>>>>>>> + SaNtfAttributeChangeNotificationFilterT myFilter; >>>>>>>>> + >>>>>>>>> + subscriptionId = 2; >>>>>>>>> + >>>>>>>>> + resetCounters(); >>>>>>>>> + >>>>>>>>> + safassert(saNtfInitialize(&ntfHandle, &ntfCbTest, >>>>>>>>> &ntfVersion) , SA_AIS_OK); >>>>>>>>> + safassert(saNtfSelectionObjectGet(ntfHandle, >>>>>>>>> &selectionObject) , SA_AIS_OK); >>>>>>>>> + >>>>>>>>> + safassert(saNtfAttributeChangeNotificationFilterAllocate( >>>>>>>>> + ntfHandle, >>>>>>>>> + &myFilter, >>>>>>>>> + 1, >>>>>>>>> + 1, >>>>>>>>> + 1, >>>>>>>>> + 1, >>>>>>>>> + 2), SA_AIS_OK); >>>>>>>>> + >>>>>>>>> + myFilter.sourceIndicators[0] = SA_NTF_OBJECT_OPERATION; >>>>>>>>> + myFilter.sourceIndicators[1] = SA_NTF_MANAGEMENT_OPERATION; >>>>>>>>> + extFillFilterHeader(&myFilter.notificationFilterHeader); >>>>>>>>> + myFilter.notificationFilterHeader.eventTypes[0] = >>>>>>>>> SA_NTF_ATTRIBUTE_CHANGED; >>>>>>>>> + /* Initialize filter handles */ >>>>>>>>> + myNotificationFilterHandles.alarmFilterHandle = 0; >>>>>>>>> + myNotificationFilterHandles.attributeChangeFilterHandle = >>>>>>>>> + myFilter.notificationFilterHandle; >>>>>>>>> + myNotificationFilterHandles.objectCreateDeleteFilterHandle = 0; >>>>>>>>> + myNotificationFilterHandles.securityAlarmFilterHandle = 0; >>>>>>>>> + myNotificationFilterHandles.stateChangeFilterHandle = 0; >>>>>>>>> + >>>>>>>>> safassert(saNtfNotificationSubscribe(&myNotificationFilterHandles, >>>>>>>>> >>>>>>>>> + subscriptionId), SA_AIS_OK); >>>>>>>>> + extCreateAttributeChangeNotification(ntfHandle, >>>>>>>>> &myAttrChangeNotification); >>>>>>>>> + *(myAttrChangeNotification.sourceIndicator) = >>>>>>>>> SA_NTF_OBJECT_OPERATION; >>>>>>>>> + >>>>>>>>> safassert(saNtfNotificationSend(myAttrChangeNotification.notificationHandle), >>>>>>>>> >>>>>>>>> SA_AIS_OK); >>>>>>>>> + /* this notification should be caught*/ >>>>>>>>> + ok_ids.ids[ok_ids.length++] = >>>>>>>>> *myAttrChangeNotification.notificationHeader.notificationId; >>>>>>>>> + >>>>>>>>> + *(myAttrChangeNotification.sourceIndicator) = >>>>>>>>> SA_NTF_UNKNOWN_OPERATION; >>>>>>>>> + >>>>>>>>> safassert(saNtfNotificationSend(myAttrChangeNotification.notificationHandle), >>>>>>>>> >>>>>>>>> SA_AIS_OK); >>>>>>>>> + >>>>>>>>> + *(myAttrChangeNotification.sourceIndicator) = >>>>>>>>> SA_NTF_MANAGEMENT_OPERATION; >>>>>>>>> + >>>>>>>>> safassert(saNtfNotificationSend(myAttrChangeNotification.notificationHandle), >>>>>>>>> >>>>>>>>> SA_AIS_OK); >>>>>>>>> + /* this notification should be caught*/ >>>>>>>>> + ok_ids.ids[ok_ids.length++] = >>>>>>>>> *myAttrChangeNotification.notificationHeader.notificationId; >>>>>>>>> + poll_until_received(ntfHandle, >>>>>>>>> *myAttrChangeNotification.notificationHeader.notificationId); >>>>>>>>> + if(ntfRecieved.alarmFilterHandle != 0 || >>>>>>>>> + ntfRecieved.attributeChangeFilterHandle != ok_ids.length || >>>>>>>>> + ntfRecieved.objectCreateDeleteFilterHandle != 0|| >>>>>>>>> + ntfRecieved.securityAlarmFilterHandle != 0 || >>>>>>>>> + ntfRecieved.stateChangeFilterHandle != 0) >>>>>>>>> safassert(SA_AIS_ERR_BAD_FLAGS, SA_AIS_OK); >>>>>>>>> + >>>>>>>>> safassert(saNtfNotificationFree(myAttrChangeNotification.notificationHandle), >>>>>>>>> >>>>>>>>> SA_AIS_OK); >>>>>>>>> + >>>>>>>>> safassert(saNtfNotificationFilterFree(myFilter.notificationFilterHandle), >>>>>>>>> >>>>>>>>> SA_AIS_OK); >>>>>>>>> + >>>>>>>>> + >>>>>>>>> + safassert(saNtfNotificationUnsubscribe(subscriptionId), >>>>>>>>> SA_AIS_OK); >>>>>>>>> + safassert(saNtfFinalize(ntfHandle) , SA_AIS_OK); >>>>>>>>> + rc = check_errors(); >>>>>>>>> + test_validate(rc, SA_AIS_OK); >>>>>>>>> +} >>>>>>>>> + >>>>>>>>> +/** >>>>>>>>> + * Test State Change notification with long dn objects >>>>>>>>> + */ >>>>>>>>> +void extStateChangeNotificationTest(void) >>>>>>>>> +{ >>>>>>>>> + SaNtfStateChangeNotificationFilterT myFilter; >>>>>>>>> + >>>>>>>>> + subscriptionId = 2; >>>>>>>>> + >>>>>>>>> + resetCounters(); >>>>>>>>> + >>>>>>>>> + safassert(saNtfInitialize(&ntfHandle, &ntfCbTest, >>>>>>>>> &ntfVersion) , SA_AIS_OK); >>>>>>>>> + safassert(saNtfSelectionObjectGet(ntfHandle, >>>>>>>>> &selectionObject) , SA_AIS_OK); >>>>>>>>> + >>>>>>>>> + safassert(saNtfStateChangeNotificationFilterAllocate( >>>>>>>>> + ntfHandle, >>>>>>>>> + &myFilter, >>>>>>>>> + 1, >>>>>>>>> + 1, >>>>>>>>> + 1, >>>>>>>>> + 1, >>>>>>>>> + 2, >>>>>>>>> + 0), SA_AIS_OK); >>>>>>>>> + >>>>>>>>> + myFilter.sourceIndicators[0] = SA_NTF_OBJECT_OPERATION; >>>>>>>>> + myFilter.sourceIndicators[1] = SA_NTF_MANAGEMENT_OPERATION; >>>>>>>>> + extFillFilterHeader(&myFilter.notificationFilterHeader); >>>>>>>>> + myFilter.notificationFilterHeader.eventTypes[0] = >>>>>>>>> SA_NTF_OBJECT_STATE_CHANGE; >>>>>>>>> + /* Initialize filter handles */ >>>>>>>>> + myNotificationFilterHandles.alarmFilterHandle = 0; >>>>>>>>> + myNotificationFilterHandles.attributeChangeFilterHandle = 0; >>>>>>>>> + myNotificationFilterHandles.objectCreateDeleteFilterHandle = 0; >>>>>>>>> + myNotificationFilterHandles.securityAlarmFilterHandle = 0; >>>>>>>>> + myNotificationFilterHandles.stateChangeFilterHandle = >>>>>>>>> myFilter.notificationFilterHandle; >>>>>>>>> + >>>>>>>>> safassert(saNtfNotificationSubscribe(&myNotificationFilterHandles, >>>>>>>>> >>>>>>>>> + subscriptionId), SA_AIS_OK); >>>>>>>>> + >>>>>>>>> + extCreateStateChangeNotification(ntfHandle, >>>>>>>>> &myStateChangeNotification); >>>>>>>>> + *(myStateChangeNotification.sourceIndicator) = >>>>>>>>> SA_NTF_OBJECT_OPERATION; >>>>>>>>> + >>>>>>>>> safassert(saNtfNotificationSend(myStateChangeNotification.notificationHandle), >>>>>>>>> >>>>>>>>> SA_AIS_OK); >>>>>>>>> + /* this notification should be caught*/ >>>>>>>>> + ok_ids.ids[ok_ids.length++] = >>>>>>>>> *myStateChangeNotification.notificationHeader.notificationId; >>>>>>>>> + >>>>>>>>> + *(myStateChangeNotification.sourceIndicator) = >>>>>>>>> SA_NTF_UNKNOWN_OPERATION; >>>>>>>>> + >>>>>>>>> safassert(saNtfNotificationSend(myStateChangeNotification.notificationHandle), >>>>>>>>> >>>>>>>>> SA_AIS_OK); >>>>>>>>> + >>>>>>>>> + *(myStateChangeNotification.sourceIndicator) = >>>>>>>>> SA_NTF_MANAGEMENT_OPERATION; >>>>>>>>> + >>>>>>>>> safassert(saNtfNotificationSend(myStateChangeNotification.notificationHandle), >>>>>>>>> >>>>>>>>> SA_AIS_OK); >>>>>>>>> + /* this notification should be caught*/ >>>>>>>>> + ok_ids.ids[ok_ids.length++] = >>>>>>>>> *myStateChangeNotification.notificationHeader.notificationId; >>>>>>>>> + poll_until_received(ntfHandle, >>>>>>>>> *myStateChangeNotification.notificationHeader.notificationId); >>>>>>>>> + if(ntfRecieved.alarmFilterHandle != 0 || >>>>>>>>> + ntfRecieved.attributeChangeFilterHandle != 0 || >>>>>>>>> + ntfRecieved.objectCreateDeleteFilterHandle != 0|| >>>>>>>>> + ntfRecieved.securityAlarmFilterHandle != 0 || >>>>>>>>> + ntfRecieved.stateChangeFilterHandle != >>>>>>>>> ok_ids.length) safassert(SA_AIS_ERR_BAD_FLAGS, SA_AIS_OK); >>>>>>>>> + >>>>>>>>> safassert(saNtfNotificationFree(myStateChangeNotification.notificationHandle), >>>>>>>>> >>>>>>>>> SA_AIS_OK); >>>>>>>>> + >>>>>>>>> safassert(saNtfNotificationFilterFree(myFilter.notificationFilterHandle), >>>>>>>>> >>>>>>>>> SA_AIS_OK); >>>>>>>>> + >>>>>>>>> + safassert(saNtfNotificationUnsubscribe(subscriptionId), >>>>>>>>> SA_AIS_OK); >>>>>>>>> + safassert(saNtfFinalize(ntfHandle), SA_AIS_OK); >>>>>>>>> + rc = check_errors(); >>>>>>>>> + test_validate(rc, SA_AIS_OK); >>>>>>>>> +} >>>>>>>>> + >>>>>>>>> +/** >>>>>>>>> + * Test Security Alarm notification with long dn objects >>>>>>>>> + */ >>>>>>>>> +void extSecurityAlarmNotificationTest(void) >>>>>>>>> +{ >>>>>>>>> + SaNtfSecurityAlarmNotificationFilterT myFilter; >>>>>>>>> + >>>>>>>>> + subscriptionId = 5; >>>>>>>>> + >>>>>>>>> + resetCounters(); >>>>>>>>> + safassert(saNtfInitialize(&ntfHandle, &ntfCbTest, >>>>>>>>> &ntfVersion) , SA_AIS_OK); >>>>>>>>> + safassert(saNtfSelectionObjectGet(ntfHandle, >>>>>>>>> &selectionObject) , SA_AIS_OK); >>>>>>>>> + >>>>>>>>> + safassert(saNtfSecurityAlarmNotificationFilterAllocate( >>>>>>>>> + ntfHandle, >>>>>>>>> + &myFilter, >>>>>>>>> + 0, >>>>>>>>> + 0, >>>>>>>>> + 0, >>>>>>>>> + 0, >>>>>>>>> + 3, >>>>>>>>> + 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; >>>>>>>>> + myFilter.probableCauses[0] = SA_NTF_ADAPTER_ERROR; >>>>>>>>> + myFilter.probableCauses[1] = SA_NTF_EQUIPMENT_MALFUNCTION; >>>>>>>>> + myFilter.probableCauses[2] = SA_NTF_VERSION_MISMATCH; >>>>>>>>> + >>>>>>>>> + /* subscribe */ >>>>>>>>> + >>>>>>>>> safassert(saNtfNotificationSubscribe(&myNotificationFilterHandles, >>>>>>>>> >>>>>>>>> + subscriptionId), SA_AIS_OK); >>>>>>>>> + extCreateSecurityAlarmNotification(ntfHandle, >>>>>>>>> &mySecAlarmNotification); >>>>>>>>> + >>>>>>>>> safassert(saNtfNotificationSend(mySecAlarmNotification.notificationHandle), >>>>>>>>> >>>>>>>>> SA_AIS_OK); >>>>>>>>> + >>>>>>>>> + *mySecAlarmNotification.probableCause = >>>>>>>>> SA_NTF_VERSION_MISMATCH; >>>>>>>>> + >>>>>>>>> safassert(saNtfNotificationSend(mySecAlarmNotification.notificationHandle), >>>>>>>>> >>>>>>>>> SA_AIS_OK); >>>>>>>>> + ok_ids.ids[ok_ids.length++] = >>>>>>>>> *mySecAlarmNotification.notificationHeader.notificationId; >>>>>>>>> + >>>>>>>>> + *mySecAlarmNotification.probableCause = >>>>>>>>> SA_NTF_RESPONSE_TIME_EXCESSIVE; >>>>>>>>> + >>>>>>>>> safassert(saNtfNotificationSend(mySecAlarmNotification.notificationHandle), >>>>>>>>> >>>>>>>>> SA_AIS_OK); >>>>>>>>> + >>>>>>>>> + *mySecAlarmNotification.probableCause = >>>>>>>>> SA_NTF_NON_REPUDIATION_FAILURE; >>>>>>>>> + >>>>>>>>> safassert(saNtfNotificationSend(mySecAlarmNotification.notificationHandle), >>>>>>>>> >>>>>>>>> SA_AIS_OK); >>>>>>>>> + >>>>>>>>> + *mySecAlarmNotification.probableCause = >>>>>>>>> SA_NTF_EQUIPMENT_MALFUNCTION; >>>>>>>>> + >>>>>>>>> safassert(saNtfNotificationSend(mySecAlarmNotification.notificationHandle), >>>>>>>>> >>>>>>>>> SA_AIS_OK); >>>>>>>>> + ok_ids.ids[ok_ids.length++] = >>>>>>>>> *mySecAlarmNotification.notificationHeader.notificationId; >>>>>>>>> + *mySecAlarmNotification.probableCause = >>>>>>>>> SA_NTF_STORAGE_CAPACITY_PROBLEM; >>>>>>>>> + >>>>>>>>> safassert(saNtfNotificationSend(mySecAlarmNotification.notificationHandle), >>>>>>>>> >>>>>>>>> SA_AIS_OK); >>>>>>>>> + *mySecAlarmNotification.probableCause = >>>>>>>>> SA_NTF_DENIAL_OF_SERVICE; >>>>>>>>> + >>>>>>>>> safassert(saNtfNotificationSend(mySecAlarmNotification.notificationHandle), >>>>>>>>> >>>>>>>>> SA_AIS_OK); >>>>>>>>> + *mySecAlarmNotification.probableCause = >>>>>>>>> SA_NTF_ADAPTER_ERROR; >>>>>>>>> + >>>>>>>>> safassert(saNtfNotificationSend(mySecAlarmNotification.notificationHandle), >>>>>>>>> >>>>>>>>> SA_AIS_OK); >>>>>>>>> + ok_ids.ids[ok_ids.length++] = >>>>>>>>> *mySecAlarmNotification.notificationHeader.notificationId; >>>>>>>>> + poll_until_received(ntfHandle, >>>>>>>>> *mySecAlarmNotification.notificationHeader.notificationId); >>>>>>>>> + if(ntfRecieved.alarmFilterHandle != 0 || >>>>>>>>> + ntfRecieved.attributeChangeFilterHandle != 0 || >>>>>>>>> + ntfRecieved.objectCreateDeleteFilterHandle !=0 || >>>>>>>>> + ntfRecieved.securityAlarmFilterHandle != >>>>>>>>> ok_ids.length || >>>>>>>>> + 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); >>>>>>>>> + rc = check_errors(); >>>>>>>>> + test_validate(rc, SA_AIS_OK); >>>>>>>>> +} >>>>>>>>> + >>>>>>>>> +__attribute__ ((constructor)) static void >>>>>>>>> longDnObject_notification_constructor(void) >>>>>>>>> +{ >>>>>>>>> + init_ext_object(); >>>>>>>>> + test_suite_add(35, "Long DNs Test"); >>>>>>>>> + test_case_add(35, extAdditionalInfoTest >>>>>>>>> + , "Test additional info with extended >>>>>>>>> SaNameT type"); >>>>>>>>> + test_case_add(35, extFilterNotificationTest >>>>>>>>> + , "Test filter with longDn objects"); >>>>>>>>> + test_case_add(35, extAlarmNotificationTest >>>>>>>>> + , "Test Alarm notification with longDn >>>>>>>>> objects"); >>>>>>>>> + test_case_add(35, extObjectCreateDeleteNotificationTest >>>>>>>>> + , "Test Object Create/Delete notification >>>>>>>>> with longDn objects"); >>>>>>>>> + test_case_add(35, extAttributeChangeNotificationTest >>>>>>>>> + , "Test Attribute Change notification >>>>>>>>> with longDn objects"); >>>>>>>>> + test_case_add(35, extStateChangeNotificationTest >>>>>>>>> + , "Test State Change notification with >>>>>>>>> longDn objects"); >>>>>>>>> + test_case_add(35, extSecurityAlarmNotificationTest >>>>>>>>> + , "Test Security Alarm notification with >>>>>>>>> longDn objects"); >>>>>>>>> +} >>>>>>>>> diff --git a/tests/unit_test_fw/inc/util.h >>>>>>>>> b/tests/unit_test_fw/inc/util.h >>>>>>>>> --- a/tests/unit_test_fw/inc/util.h >>>>>>>>> +++ b/tests/unit_test_fw/inc/util.h >>>>>>>>> @@ -19,11 +19,10 @@ >>>>>>>>> #ifndef util_h >>>>>>>>> #define util_h >>>>>>>>> >>>>>>>>> +#include <saAis.h> >>>>>>>>> + >>>>>>>>> extern SaTimeT getSaTimeT(void); >>>>>>>>> -extern void create_dn(char *rdn, char *parent, SaNameT *dn); >>>>>>>>> -extern void sa_namet_init(char *value, SaNameT *namet); >>>>>>>>> extern const char *get_saf_error(SaAisErrorT rc); >>>>>>>>> - >>>>>>>>> extern void safassert_impl(const char* file, unsigned int >>>>>>>>> line, SaAisErrorT actual, SaAisErrorT expected); >>>>>>>>> >>>>>>>>> /** >>>>>>>>> diff --git a/tests/unit_test_fw/src/Makefile.am >>>>>>>>> b/tests/unit_test_fw/src/Makefile.am >>>>>>>>> --- a/tests/unit_test_fw/src/Makefile.am >>>>>>>>> +++ b/tests/unit_test_fw/src/Makefile.am >>>>>>>>> @@ -22,6 +22,7 @@ noinst_LTLIBRARIES = libutest.la >>>>>>>>> >>>>>>>>> libutest_la_CPPFLAGS = \ >>>>>>>>> $(AM_CPPFLAGS) \ >>>>>>>>> + -DSA_EXTENDED_NAME_SOURCE \ >>>>>>>>> -I$(top_srcdir)/tests/unit_test_fw/inc \ >>>>>>>>> -I$(top_srcdir)/osaf/libs/saf/include >>>>>>>>> >>>>>>>>> diff --git a/tests/unit_test_fw/src/util.c >>>>>>>>> b/tests/unit_test_fw/src/util.c >>>>>>>>> --- a/tests/unit_test_fw/src/util.c >>>>>>>>> +++ b/tests/unit_test_fw/src/util.c >>>>>>>>> @@ -21,8 +21,7 @@ >>>>>>>>> #include <sys/time.h> >>>>>>>>> #include <unistd.h> >>>>>>>>> #include <assert.h> >>>>>>>>> -#include <saAis.h> >>>>>>>>> - >>>>>>>>> +#include "util.h" >>>>>>>>> static const char *saf_error[] = >>>>>>>>> { >>>>>>>>> "SA_AIS_NOT_VALID", >>>>>>>>> @@ -65,17 +64,6 @@ SaTimeT getSaTimeT(void) >>>>>>>>> (tp.tv_usec * SA_TIME_ONE_MICROSECOND); >>>>>>>>> } >>>>>>>>> >>>>>>>>> -void create_dn(char *rdn, char *parent, SaNameT *dn) >>>>>>>>> -{ >>>>>>>>> - dn->length = sprintf((char*)dn->value, "%s,%s", rdn, >>>>>>>>> parent); >>>>>>>>> - assert(dn->length < SA_MAX_NAME_LENGTH); >>>>>>>>> -} >>>>>>>>> - >>>>>>>>> -void sa_namet_init(char *value, SaNameT *namet) >>>>>>>>> -{ >>>>>>>>> - namet->length = sprintf((char*)namet->value, "%s", value); >>>>>>>>> -} >>>>>>>>> - >>>>>>>>> const char *get_saf_error(SaAisErrorT rc) >>>>>>>>> { >>>>>>>>> if (rc <= SA_AIS_ERR_UNAVAILABLE) >>>>>>>>> >>>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>> >>>>>> >>>>> >>>> >>> >> >
------------------------------------------------------------------------------ Infragistics Professional Build stunning WinForms apps today! Reboot your WinForms applications with our WinForms controls. Build a bridge from your legacy apps to the future. http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk _______________________________________________ Opensaf-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/opensaf-devel
