3 * Copyright (c) 2002-2005 MontaVista Software, Inc.
7 * Author: Steven Dake (sdake@mvista.com)
9 * This software licensed under BSD license, the text of which follows:
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions are met:
14 * - Redistributions of source code must retain the above copyright notice,
15 * this list of conditions and the following disclaimer.
16 * - Redistributions in binary form must reproduce the above copyright notice,
17 * this list of conditions and the following disclaimer in the documentation
18 * and/or other materials provided with the distribution.
19 * - Neither the name of the MontaVista Software, Inc. nor the names of its
20 * contributors may be used to endorse or promote products derived from this
21 * software without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
33 * THE POSSIBILITY OF SUCH DAMAGE.
43 #include <sys/types.h>
44 #include <sys/socket.h>
45 #include <sys/select.h>
56 mar_res_header_t header
__attribute__((aligned(8)));
61 * Data structure for instance data
66 SaAmfCallbacksT callbacks
;
70 pthread_mutex_t response_mutex
;
71 pthread_mutex_t dispatch_mutex
;
74 static void amfHandleInstanceDestructor (void *);
77 * All instances in one database
79 static struct saHandleDatabase amfHandleDatabase
= {
82 .mutex
= PTHREAD_MUTEX_INITIALIZER
,
83 .handleInstanceDestructor
= amfHandleInstanceDestructor
89 static SaVersionT amfVersionsSupported
[] = {
93 static struct saVersionDatabase amfVersionDatabase
= {
94 sizeof (amfVersionsSupported
) / sizeof (SaVersionT
),
102 void amfHandleInstanceDestructor (void *instance
)
104 struct amfInstance
*amfInstance
= instance
;
106 pthread_mutex_destroy (&amfInstance
->response_mutex
);
107 pthread_mutex_destroy (&amfInstance
->dispatch_mutex
);
112 SaAmfHandleT
*amfHandle
,
113 const SaAmfCallbacksT
*amfCallbacks
,
116 struct amfInstance
*amfInstance
;
117 SaAisErrorT error
= SA_AIS_OK
;
119 error
= saVersionVerify (&amfVersionDatabase
, (SaVersionT
*)version
);
120 if (error
!= SA_AIS_OK
) {
121 goto error_no_destroy
;
124 error
= saHandleCreate (&amfHandleDatabase
, sizeof (struct amfInstance
), amfHandle
);
125 if (error
!= SA_AIS_OK
) {
126 goto error_no_destroy
;
129 error
= saHandleInstanceGet (&amfHandleDatabase
, *amfHandle
, (void *)&amfInstance
);
130 if (error
!= SA_AIS_OK
) {
134 amfInstance
->response_fd
= -1;
136 amfInstance
->dispatch_fd
= -1;
138 error
= saServiceConnect (&amfInstance
->response_fd
,
139 &amfInstance
->dispatch_fd
, AMF_SERVICE
);
140 if (error
!= SA_AIS_OK
) {
141 goto error_put_destroy
;
144 memcpy (&amfInstance
->callbacks
, amfCallbacks
, sizeof (SaAmfCallbacksT
));
146 pthread_mutex_init (&amfInstance
->response_mutex
, NULL
);
148 pthread_mutex_init (&amfInstance
->dispatch_mutex
, NULL
);
150 saHandleInstancePut (&amfHandleDatabase
, *amfHandle
);
155 saHandleInstancePut (&amfHandleDatabase
, *amfHandle
);
157 saHandleDestroy (&amfHandleDatabase
, *amfHandle
);
163 saAmfSelectionObjectGet (
164 SaAmfHandleT amfHandle
,
165 SaSelectionObjectT
*selectionObject
)
167 struct amfInstance
*amfInstance
;
170 error
= saHandleInstanceGet (&amfHandleDatabase
, amfHandle
, (void *)&amfInstance
);
171 if (error
!= SA_AIS_OK
) {
175 *selectionObject
= amfInstance
->dispatch_fd
;
177 saHandleInstancePut (&amfHandleDatabase
, amfHandle
);
184 SaAmfHandleT amfHandle
,
185 SaDispatchFlagsT dispatchFlags
)
190 int cont
= 1; /* always continue do loop except when set to 0 */
192 struct amfInstance
*amfInstance
;
193 struct res_lib_amf_csisetcallback
*res_lib_amf_csisetcallback
;
195 struct res_lib_amf_healthcheckcallback
*res_lib_amf_healthcheckcallback
;
196 struct res_lib_amf_csiremovecallback
*res_lib_amf_csiremovecallback
;
197 struct res_lib_amf_componentterminatecallback
*res_lib_amf_componentterminatecallback
;
198 SaAmfCallbacksT callbacks
;
199 struct res_overlay dispatch_data
;
201 if (dispatchFlags
!= SA_DISPATCH_ONE
&&
202 dispatchFlags
!= SA_DISPATCH_ALL
&&
203 dispatchFlags
!= SA_DISPATCH_BLOCKING
) {
205 return (SA_AIS_ERR_INVALID_PARAM
);
208 error
= saHandleInstanceGet (&amfHandleDatabase
, amfHandle
,
209 (void *)&amfInstance
);
210 if (error
!= SA_AIS_OK
) {
215 * Timeout instantly for SA_DISPATCH_ALL
217 if (dispatchFlags
== SA_DISPATCH_ALL
) {
223 * Read data directly from socket
225 ufds
.fd
= amfInstance
->dispatch_fd
;
226 ufds
.events
= POLLIN
;
229 error
= saPollRetry (&ufds
, 1, timeout
);
230 if (error
!= SA_AIS_OK
) {
234 pthread_mutex_lock (&amfInstance
->dispatch_mutex
);
237 * Handle has been finalized in another thread
239 if (amfInstance
->finalize
== 1) {
244 if ((ufds
.revents
& (POLLERR
|POLLHUP
|POLLNVAL
)) != 0) {
245 error
= SA_AIS_ERR_BAD_HANDLE
;
249 dispatch_avail
= ufds
.revents
& POLLIN
;
250 if (dispatch_avail
== 0 && dispatchFlags
== SA_DISPATCH_ALL
) {
251 pthread_mutex_unlock (&amfInstance
->dispatch_mutex
);
252 break; /* exit do while cont is 1 loop */
254 if (dispatch_avail
== 0) {
255 pthread_mutex_unlock (&amfInstance
->dispatch_mutex
);
256 continue; /* next poll */
259 if (ufds
.revents
& POLLIN
) {
261 * Queue empty, read response from socket
263 error
= saRecvRetry (amfInstance
->dispatch_fd
, &dispatch_data
.header
,
264 sizeof (mar_res_header_t
));
266 if (error
!= SA_AIS_OK
) {
270 if (dispatch_data
.header
.size
> sizeof (mar_res_header_t
)) {
272 error
= saRecvRetry (amfInstance
->dispatch_fd
, &dispatch_data
.data
,
273 dispatch_data
.header
.size
- sizeof (mar_res_header_t
));
275 if (error
!= SA_AIS_OK
) {
281 pthread_mutex_unlock (&amfInstance
->dispatch_mutex
);
287 * Make copy of callbacks, message data, unlock instance, and call callback
288 * A risk of this dispatch method is that the callback routines may
289 * operate at the same time that amfFinalize has been called in another thread.
292 memcpy (&callbacks
, &amfInstance
->callbacks
, sizeof (SaAmfCallbacksT
));
293 pthread_mutex_unlock (&amfInstance
->dispatch_mutex
);
296 * Dispatch incoming response
299 switch (dispatch_data
.header
.id
) {
301 case MESSAGE_RES_AMF_HEALTHCHECKCALLBACK
:
302 res_lib_amf_healthcheckcallback
= (struct res_lib_amf_healthcheckcallback
*)&dispatch_data
;
304 callbacks
.saAmfHealthcheckCallback (
305 res_lib_amf_healthcheckcallback
->invocation
,
306 &res_lib_amf_healthcheckcallback
->compName
,
307 &res_lib_amf_healthcheckcallback
->key
);
310 case MESSAGE_RES_AMF_CSISETCALLBACK
:
312 SaAmfCSIDescriptorT csi_descriptor
;
313 SaAmfCSIAttributeT
*csi_attribute_array
;
317 res_lib_amf_csisetcallback
= (struct res_lib_amf_csisetcallback
*)&dispatch_data
;
320 csi_descriptor
.csiFlags
= res_lib_amf_csisetcallback
->csiFlags
;
321 memcpy(&csi_descriptor
.csiName
, &res_lib_amf_csisetcallback
->csiName
,
323 csi_descriptor
.csiStateDescriptor
= res_lib_amf_csisetcallback
->csiStateDescriptor
;
324 csi_descriptor
.csiAttr
.number
= res_lib_amf_csisetcallback
->number
;
326 csi_attribute_array
= malloc (sizeof (SaAmfCSIAttributeT
) *
327 csi_descriptor
.csiAttr
.number
);
329 if (csi_attribute_array
== 0) {
330 return SA_AIS_ERR_LIBRARY
;
332 csi_descriptor
.csiAttr
.attr
= csi_attribute_array
;
334 attr_buf
= res_lib_amf_csisetcallback
->csi_attr_buf
;
336 for (i
= 0; i
< csi_descriptor
.csiAttr
.number
; i
++) {
337 csi_attribute_array
[i
].attrName
= (SaUint8T
*)attr_buf
;
339 attr_buf
+= strlen(attr_buf
) + 1;
340 csi_attribute_array
[i
].attrValue
= (SaUint8T
*)attr_buf
;
342 attr_buf
+= strlen(attr_buf
) + 1;
345 callbacks
.saAmfCSISetCallback (
346 res_lib_amf_csisetcallback
->invocation
,
347 &res_lib_amf_csisetcallback
->compName
,
348 res_lib_amf_csisetcallback
->haState
,
351 if (csi_attribute_array
!= NULL
) {
352 free(csi_attribute_array
);
356 case MESSAGE_RES_AMF_CSIREMOVECALLBACK
:
357 res_lib_amf_csiremovecallback
= (struct res_lib_amf_csiremovecallback
*)&dispatch_data
;
358 callbacks
.saAmfCSIRemoveCallback (
359 res_lib_amf_csiremovecallback
->invocation
,
360 &res_lib_amf_csiremovecallback
->compName
,
361 &res_lib_amf_csiremovecallback
->csiName
,
362 res_lib_amf_csiremovecallback
->csiFlags
);
365 case MESSAGE_RES_AMF_COMPONENTTERMINATECALLBACK
:
366 res_lib_amf_componentterminatecallback
= (struct res_lib_amf_componentterminatecallback
*)&dispatch_data
;
367 callbacks
.saAmfComponentTerminateCallback (
368 res_lib_amf_componentterminatecallback
->invocation
,
369 &res_lib_amf_componentterminatecallback
->compName
);
373 case MESSAGE_RES_AMF_PROTECTIONGROUPTRACKCALLBACK
:
374 res_lib_amf_protectiongrouptrackcallback
= (struct res_lib_amf_protectiongrouptrackcallback
*)&dispatch_data
;
375 memcpy (res_lib_amf_protectiongrouptrackcallback
->notificationBufferAddress
,
376 res_lib_amf_protectiongrouptrackcallback
->notificationBuffer
,
377 res_lib_amf_protectiongrouptrackcallback
->numberOfItems
* sizeof (SaAmfProtectionGroupNotificationT
));
378 callbacks
.saAmfProtectionGroupTrackCallback(
379 &res_lib_amf_protectiongrouptrackcallback
->csiName
,
380 res_lib_amf_protectiongrouptrackcallback
->notificationBufferAddress
,
381 res_lib_amf_protectiongrouptrackcallback
->numberOfItems
,
382 res_lib_amf_protectiongrouptrackcallback
->numberOfMembers
,
383 res_lib_amf_protectiongrouptrackcallback
->error
);
387 error
= SA_AIS_ERR_LIBRARY
;
393 * Determine if more messages should be processed
395 switch (dispatchFlags
) {
396 case SA_DISPATCH_ONE
:
399 case SA_DISPATCH_ALL
:
401 case SA_DISPATCH_BLOCKING
:
407 pthread_mutex_unlock (&amfInstance
->dispatch_mutex
);
409 saHandleInstancePut (&amfHandleDatabase
, amfHandle
);
416 SaAmfHandleT amfHandle
)
418 struct amfInstance
*amfInstance
;
421 error
= saHandleInstanceGet (&amfHandleDatabase
, amfHandle
, (void *)&amfInstance
);
422 if (error
!= SA_AIS_OK
) {
426 pthread_mutex_lock (&amfInstance
->dispatch_mutex
);
428 pthread_mutex_lock (&amfInstance
->response_mutex
);
431 * Another thread has already started finalizing
433 if (amfInstance
->finalize
) {
434 pthread_mutex_unlock (&amfInstance
->response_mutex
);
435 pthread_mutex_unlock (&amfInstance
->dispatch_mutex
);
436 saHandleInstancePut (&amfHandleDatabase
, amfHandle
);
437 return (SA_AIS_ERR_BAD_HANDLE
);
440 amfInstance
->finalize
= 1;
442 pthread_mutex_unlock (&amfInstance
->response_mutex
);
444 pthread_mutex_unlock (&amfInstance
->dispatch_mutex
);
446 saHandleDestroy (&amfHandleDatabase
, amfHandle
);
448 if (amfInstance
->response_fd
!= -1) {
449 shutdown (amfInstance
->response_fd
, 0);
450 close (amfInstance
->response_fd
);
452 if (amfInstance
->dispatch_fd
!= -1) {
453 shutdown (amfInstance
->dispatch_fd
, 0);
454 close (amfInstance
->dispatch_fd
);
457 saHandleInstancePut (&amfHandleDatabase
, amfHandle
);
463 saAmfComponentRegister (
464 SaAmfHandleT amfHandle
,
465 const SaNameT
*compName
,
466 const SaNameT
*proxyCompName
)
468 struct amfInstance
*amfInstance
;
470 struct req_lib_amf_componentregister req_lib_amf_componentregister
;
471 struct res_lib_amf_componentregister res_lib_amf_componentregister
;
473 error
= saHandleInstanceGet (&amfHandleDatabase
, amfHandle
,
474 (void *)&amfInstance
);
475 if (error
!= SA_AIS_OK
) {
479 req_lib_amf_componentregister
.header
.size
= sizeof (struct req_lib_amf_componentregister
);
480 req_lib_amf_componentregister
.header
.id
= MESSAGE_REQ_AMF_COMPONENTREGISTER
;
481 memcpy (&req_lib_amf_componentregister
.compName
, compName
,
484 memcpy (&req_lib_amf_componentregister
.proxyCompName
,
485 proxyCompName
, sizeof (SaNameT
));
487 memset (&req_lib_amf_componentregister
.proxyCompName
, 0,
491 pthread_mutex_lock (&amfInstance
->response_mutex
);
493 error
= saSendReceiveReply (amfInstance
->response_fd
,
494 &req_lib_amf_componentregister
,
495 sizeof (struct req_lib_amf_componentregister
),
496 &res_lib_amf_componentregister
,
497 sizeof (struct res_lib_amf_componentregister
));
499 pthread_mutex_unlock (&amfInstance
->response_mutex
);
501 saHandleInstancePut (&amfHandleDatabase
, amfHandle
);
503 if (res_lib_amf_componentregister
.header
.error
== SA_AIS_OK
) {
504 amfInstance
->compRegistered
= 1;
505 memcpy (&amfInstance
->compName
, compName
, sizeof (SaNameT
));
507 return (error
== SA_AIS_OK
? res_lib_amf_componentregister
.header
.error
: error
);
511 saAmfComponentUnregister (
512 SaAmfHandleT amfHandle
,
513 const SaNameT
*compName
,
514 const SaNameT
*proxyCompName
)
516 struct req_lib_amf_componentunregister req_lib_amf_componentunregister
;
517 struct res_lib_amf_componentunregister res_lib_amf_componentunregister
;
518 struct amfInstance
*amfInstance
;
521 error
= saHandleInstanceGet (&amfHandleDatabase
, amfHandle
,
522 (void *)&amfInstance
);
523 if (error
!= SA_AIS_OK
) {
527 req_lib_amf_componentunregister
.header
.size
= sizeof (struct req_lib_amf_componentunregister
);
528 req_lib_amf_componentunregister
.header
.id
= MESSAGE_REQ_AMF_COMPONENTUNREGISTER
;
529 memcpy (&req_lib_amf_componentunregister
.compName
, compName
,
532 memcpy (&req_lib_amf_componentunregister
.proxyCompName
,
533 proxyCompName
, sizeof (SaNameT
));
535 memset (&req_lib_amf_componentunregister
.proxyCompName
, 0,
539 pthread_mutex_lock (&amfInstance
->response_mutex
);
541 error
= saSendReceiveReply (amfInstance
->response_fd
,
542 &req_lib_amf_componentunregister
,
543 sizeof (struct req_lib_amf_componentunregister
),
544 &res_lib_amf_componentunregister
,
545 sizeof (struct res_lib_amf_componentunregister
));
547 pthread_mutex_unlock (&amfInstance
->response_mutex
);
549 saHandleInstancePut (&amfHandleDatabase
, amfHandle
);
551 return (error
== SA_AIS_OK
? res_lib_amf_componentunregister
.header
.error
: error
);
555 saAmfComponentNameGet (
556 SaAmfHandleT amfHandle
,
559 struct amfInstance
*amfInstance
;
563 error
= saHandleInstanceGet (&amfHandleDatabase
, amfHandle
,
564 (void *)&amfInstance
);
565 if (error
!= SA_AIS_OK
) {
569 pthread_mutex_lock (&amfInstance
->response_mutex
);
573 env_value
= getenv ("SA_AMF_COMPONENT_NAME");
574 if (env_value
== 0) {
575 error
= SA_AIS_ERR_NOT_EXIST
;
579 strncpy ((char *)compName
->value
, env_value
, SA_MAX_NAME_LENGTH
-1);
580 compName
->value
[SA_MAX_NAME_LENGTH
-1] = '\0';
581 compName
->length
= strlen (env_value
);
584 pthread_mutex_unlock (&amfInstance
->response_mutex
);
586 saHandleInstancePut (&amfHandleDatabase
, amfHandle
);
593 SaAmfHandleT amfHandle
,
594 const SaNameT
*compName
,
596 SaInt32T descendentsTreeDepth
,
597 SaAmfPmErrorsT pmErrors
,
598 SaAmfRecommendedRecoveryT recommendedRecovery
)
600 struct req_lib_amf_pmstart req_lib_amf_pmstart
;
601 struct res_lib_amf_pmstart res_lib_amf_pmstart
;
602 struct amfInstance
*amfInstance
;
605 error
= saHandleInstanceGet (&amfHandleDatabase
, amfHandle
,
606 (void *)&amfInstance
);
607 if (error
!= SA_AIS_OK
) {
611 req_lib_amf_pmstart
.header
.size
= sizeof (struct req_lib_amf_pmstart
);
612 req_lib_amf_pmstart
.header
.id
= MESSAGE_REQ_AMF_PMSTART
;
613 memcpy (&req_lib_amf_pmstart
.compName
, compName
,
615 req_lib_amf_pmstart
.processId
= processId
;
616 req_lib_amf_pmstart
.descendentsTreeDepth
= descendentsTreeDepth
;
617 req_lib_amf_pmstart
.pmErrors
= pmErrors
;
618 req_lib_amf_pmstart
.recommendedRecovery
= recommendedRecovery
;
620 pthread_mutex_lock (&amfInstance
->response_mutex
);
622 error
= saSendReceiveReply (amfInstance
->response_fd
,
623 &req_lib_amf_pmstart
,
624 sizeof (struct req_lib_amf_pmstart
),
625 &res_lib_amf_pmstart
,
626 sizeof (struct res_lib_amf_pmstart
));
628 pthread_mutex_unlock (&amfInstance
->response_mutex
);
630 saHandleInstancePut (&amfHandleDatabase
, amfHandle
);
632 return (error
== SA_AIS_OK
? res_lib_amf_pmstart
.header
.error
: error
);
637 SaAmfHandleT amfHandle
,
638 const SaNameT
*compName
,
639 SaAmfPmStopQualifierT stopQualifier
,
641 SaAmfPmErrorsT pmErrors
)
643 struct req_lib_amf_pmstop req_lib_amf_pmstop
;
644 struct res_lib_amf_pmstop res_lib_amf_pmstop
;
645 struct amfInstance
*amfInstance
;
648 error
= saHandleInstanceGet (&amfHandleDatabase
, amfHandle
,
649 (void *)&amfInstance
);
650 if (error
!= SA_AIS_OK
) {
654 req_lib_amf_pmstop
.header
.size
= sizeof (struct req_lib_amf_pmstop
);
655 req_lib_amf_pmstop
.header
.id
= MESSAGE_REQ_AMF_PMSTOP
;
656 memcpy (&req_lib_amf_pmstop
.compName
, compName
, sizeof (SaNameT
));
657 req_lib_amf_pmstop
.stopQualifier
= stopQualifier
;
658 req_lib_amf_pmstop
.processId
= processId
;
659 req_lib_amf_pmstop
.pmErrors
= pmErrors
;
661 pthread_mutex_lock (&amfInstance
->response_mutex
);
663 error
= saSendReceiveReply (amfInstance
->response_fd
,
665 sizeof (struct req_lib_amf_pmstop
),
667 sizeof (struct res_lib_amf_pmstop
));
669 pthread_mutex_unlock (&amfInstance
->response_mutex
);
671 saHandleInstancePut (&amfHandleDatabase
, amfHandle
);
673 return (error
== SA_AIS_OK
? res_lib_amf_pmstop
.header
.error
: error
);
678 saAmfHealthcheckStart (
679 SaAmfHandleT amfHandle
,
680 const SaNameT
*compName
,
681 const SaAmfHealthcheckKeyT
*healthcheckKey
,
682 SaAmfHealthcheckInvocationT invocationType
,
683 SaAmfRecommendedRecoveryT recommendedRecovery
)
685 struct req_lib_amf_healthcheckstart req_lib_amf_healthcheckstart
;
686 struct res_lib_amf_healthcheckstart res_lib_amf_healthcheckstart
;
687 struct amfInstance
*amfInstance
;
690 error
= saHandleInstanceGet (&amfHandleDatabase
, amfHandle
,
691 (void *)&amfInstance
);
692 if (error
!= SA_AIS_OK
) {
696 req_lib_amf_healthcheckstart
.header
.size
= sizeof (struct req_lib_amf_healthcheckstart
);
697 req_lib_amf_healthcheckstart
.header
.id
= MESSAGE_REQ_AMF_HEALTHCHECKSTART
;
698 memcpy (&req_lib_amf_healthcheckstart
.compName
, compName
,
700 memcpy (&req_lib_amf_healthcheckstart
.healthcheckKey
,
701 healthcheckKey
, sizeof (SaAmfHealthcheckKeyT
));
702 req_lib_amf_healthcheckstart
.invocationType
= invocationType
;
703 req_lib_amf_healthcheckstart
.recommendedRecovery
= recommendedRecovery
;
705 pthread_mutex_lock (&amfInstance
->response_mutex
);
707 error
= saSendReceiveReply (amfInstance
->response_fd
,
708 &req_lib_amf_healthcheckstart
,
709 sizeof (struct req_lib_amf_healthcheckstart
),
710 &res_lib_amf_healthcheckstart
,
711 sizeof (struct res_lib_amf_healthcheckstart
));
713 pthread_mutex_unlock (&amfInstance
->response_mutex
);
715 saHandleInstancePut (&amfHandleDatabase
, amfHandle
);
717 return (error
== SA_AIS_OK
? res_lib_amf_healthcheckstart
.header
.error
: error
);
721 saAmfHealthcheckConfirm (
722 SaAmfHandleT amfHandle
,
723 const SaNameT
*compName
,
724 const SaAmfHealthcheckKeyT
*healthcheckKey
,
725 SaAisErrorT healthcheckResult
)
727 struct req_lib_amf_healthcheckconfirm req_lib_amf_healthcheckconfirm
;
728 struct res_lib_amf_healthcheckconfirm res_lib_amf_healthcheckconfirm
;
729 struct amfInstance
*amfInstance
;
732 error
= saHandleInstanceGet (&amfHandleDatabase
, amfHandle
,
733 (void *)&amfInstance
);
734 if (error
!= SA_AIS_OK
) {
738 req_lib_amf_healthcheckconfirm
.header
.size
= sizeof (struct req_lib_amf_healthcheckconfirm
);
739 req_lib_amf_healthcheckconfirm
.header
.id
= MESSAGE_REQ_AMF_HEALTHCHECKCONFIRM
;
740 memcpy (&req_lib_amf_healthcheckconfirm
.compName
, compName
,
742 memcpy (&req_lib_amf_healthcheckconfirm
.healthcheckKey
,
743 healthcheckKey
, sizeof (SaAmfHealthcheckKeyT
));
744 req_lib_amf_healthcheckconfirm
.healthcheckResult
= healthcheckResult
;
746 pthread_mutex_lock (&amfInstance
->response_mutex
);
748 error
= saSendReceiveReply (amfInstance
->response_fd
,
749 &req_lib_amf_healthcheckconfirm
,
750 sizeof (struct req_lib_amf_healthcheckconfirm
),
751 &res_lib_amf_healthcheckconfirm
,
752 sizeof (struct res_lib_amf_healthcheckconfirm
));
754 pthread_mutex_unlock (&amfInstance
->response_mutex
);
756 saHandleInstancePut (&amfHandleDatabase
, amfHandle
);
758 return (error
== SA_AIS_OK
? res_lib_amf_healthcheckconfirm
.header
.error
: error
);
762 saAmfHealthcheckStop (
763 SaAmfHandleT amfHandle
,
764 const SaNameT
*compName
,
765 const SaAmfHealthcheckKeyT
*healthcheckKey
)
767 struct req_lib_amf_healthcheckstop req_lib_amf_healthcheckstop
;
768 struct res_lib_amf_healthcheckstop res_lib_amf_healthcheckstop
;
769 struct amfInstance
*amfInstance
;
772 error
= saHandleInstanceGet (&amfHandleDatabase
, amfHandle
,
773 (void *)&amfInstance
);
774 if (error
!= SA_AIS_OK
) {
778 req_lib_amf_healthcheckstop
.header
.size
= sizeof (struct req_lib_amf_healthcheckstop
);
779 req_lib_amf_healthcheckstop
.header
.id
= MESSAGE_REQ_AMF_HEALTHCHECKSTOP
;
780 memcpy (&req_lib_amf_healthcheckstop
.compName
, compName
,
782 memcpy (&req_lib_amf_healthcheckstop
.healthcheckKey
,
783 healthcheckKey
, sizeof (SaAmfHealthcheckKeyT
));
785 pthread_mutex_lock (&amfInstance
->response_mutex
);
787 error
= saSendReceiveReply (amfInstance
->response_fd
,
788 &req_lib_amf_healthcheckstop
,
789 sizeof (struct req_lib_amf_healthcheckstop
),
790 &res_lib_amf_healthcheckstop
,
791 sizeof (struct res_lib_amf_healthcheckstop
));
793 pthread_mutex_unlock (&amfInstance
->response_mutex
);
795 saHandleInstancePut (&amfHandleDatabase
, amfHandle
);
797 return (error
== SA_AIS_OK
? res_lib_amf_healthcheckstop
.header
.error
: error
);
803 SaAmfHandleT amfHandle
,
804 const SaNameT
*compName
,
805 const SaNameT
*csiName
,
806 SaAmfHAStateT
*haState
)
808 struct amfInstance
*amfInstance
;
809 struct req_lib_amf_hastateget req_lib_amf_hastateget
;
810 struct res_lib_amf_hastateget res_lib_amf_hastateget
;
813 error
= saHandleInstanceGet (&amfHandleDatabase
, amfHandle
,
814 (void *)&amfInstance
);
815 if (error
!= SA_AIS_OK
) {
819 pthread_mutex_lock (&amfInstance
->response_mutex
);
821 req_lib_amf_hastateget
.header
.id
= MESSAGE_REQ_AMF_HASTATEGET
;
822 req_lib_amf_hastateget
.header
.size
= sizeof (struct req_lib_amf_hastateget
);
823 memcpy (&req_lib_amf_hastateget
.compName
, compName
, sizeof (SaNameT
));
824 memcpy (&req_lib_amf_hastateget
.csiName
, csiName
, sizeof (SaNameT
));
826 error
= saSendReceiveReply (amfInstance
->response_fd
,
827 &req_lib_amf_hastateget
, sizeof (struct req_lib_amf_hastateget
),
828 &res_lib_amf_hastateget
, sizeof (struct res_lib_amf_hastateget
));
830 pthread_mutex_unlock (&amfInstance
->response_mutex
);
832 saHandleInstancePut (&amfHandleDatabase
, amfHandle
);
834 if (res_lib_amf_hastateget
.header
.error
== SA_AIS_OK
) {
835 memcpy (haState
, &res_lib_amf_hastateget
.haState
,
836 sizeof (SaAmfHAStateT
));
838 return (error
== SA_AIS_OK
? res_lib_amf_hastateget
.header
.error
: error
);
842 saAmfCSIQuiescingComplete (
843 SaAmfHandleT amfHandle
,
844 SaInvocationT invocation
,
847 struct req_lib_amf_csiquiescingcomplete req_lib_amf_csiquiescingcomplete
;
848 struct res_lib_amf_csiquiescingcomplete res_lib_amf_csiquiescingcomplete
;
849 struct amfInstance
*amfInstance
;
850 SaAisErrorT errorResult
;
852 error
= saHandleInstanceGet (&amfHandleDatabase
, amfHandle
,
853 (void *)&amfInstance
);
854 if (error
!= SA_AIS_OK
) {
858 req_lib_amf_csiquiescingcomplete
.header
.size
= sizeof (struct req_lib_amf_csiquiescingcomplete
);
859 req_lib_amf_csiquiescingcomplete
.header
.id
= MESSAGE_REQ_AMF_CSIQUIESCINGCOMPLETE
;
860 req_lib_amf_csiquiescingcomplete
.invocation
= invocation
;
861 req_lib_amf_csiquiescingcomplete
.error
= error
;
863 pthread_mutex_lock (&amfInstance
->response_mutex
);
865 errorResult
= saSendReceiveReply (amfInstance
->response_fd
,
866 &req_lib_amf_csiquiescingcomplete
,
867 sizeof (struct req_lib_amf_csiquiescingcomplete
),
868 &res_lib_amf_csiquiescingcomplete
,
869 sizeof (struct res_lib_amf_csiquiescingcomplete
));
871 pthread_mutex_unlock (&amfInstance
->response_mutex
);
873 saHandleInstancePut (&amfHandleDatabase
, amfHandle
);
875 return (errorResult
== SA_AIS_OK
? res_lib_amf_csiquiescingcomplete
.header
.error
: errorResult
);
879 saAmfProtectionGroupTrack (
880 SaAmfHandleT amfHandle
,
881 const SaNameT
*csiName
,
883 SaAmfProtectionGroupNotificationBufferT
*notificationBuffer
)
885 struct amfInstance
*amfInstance
;
886 struct req_lib_amf_protectiongrouptrack req_lib_amf_protectiongrouptrack
;
887 struct res_lib_amf_protectiongrouptrack res_lib_amf_protectiongrouptrack
;
890 req_lib_amf_protectiongrouptrack
.header
.size
= sizeof (struct req_lib_amf_protectiongrouptrack
);
891 req_lib_amf_protectiongrouptrack
.header
.id
= MESSAGE_REQ_AMF_PROTECTIONGROUPTRACK
;
892 memcpy (&req_lib_amf_protectiongrouptrack
.csiName
, csiName
,
894 req_lib_amf_protectiongrouptrack
.trackFlags
= trackFlags
;
895 req_lib_amf_protectiongrouptrack
.notificationBufferAddress
= (SaAmfProtectionGroupNotificationBufferT
*)notificationBuffer
;
897 error
= saHandleInstanceGet (&amfHandleDatabase
, amfHandle
,
898 (void *)&amfInstance
);
899 if (error
!= SA_AIS_OK
) {
903 pthread_mutex_lock (&amfInstance
->response_mutex
);
905 error
= saSendReceiveReply (amfInstance
->response_fd
,
906 &req_lib_amf_protectiongrouptrack
,
907 sizeof (struct req_lib_amf_protectiongrouptrack
),
908 &res_lib_amf_protectiongrouptrack
,
909 sizeof (struct res_lib_amf_protectiongrouptrack
));
911 pthread_mutex_unlock (&amfInstance
->response_mutex
);
913 saHandleInstancePut (&amfHandleDatabase
, amfHandle
);
915 return (error
== SA_AIS_OK
? res_lib_amf_protectiongrouptrack
.header
.error
: error
);
919 saAmfProtectionGroupTrackStop (
920 SaAmfHandleT amfHandle
,
921 const SaNameT
*csiName
)
923 struct amfInstance
*amfInstance
;
924 struct req_lib_amf_protectiongrouptrackstop req_lib_amf_protectiongrouptrackstop
;
925 struct res_lib_amf_protectiongrouptrackstop res_lib_amf_protectiongrouptrackstop
;
928 error
= saHandleInstanceGet (&amfHandleDatabase
, amfHandle
,
929 (void *)&amfInstance
);
930 if (error
!= SA_AIS_OK
) {
934 req_lib_amf_protectiongrouptrackstop
.header
.size
= sizeof (struct req_lib_amf_protectiongrouptrackstop
);
935 req_lib_amf_protectiongrouptrackstop
.header
.id
= MESSAGE_REQ_AMF_PROTECTIONGROUPTRACKSTOP
;
936 memcpy (&req_lib_amf_protectiongrouptrackstop
.csiName
, csiName
, sizeof (SaNameT
));
938 pthread_mutex_lock (&amfInstance
->response_mutex
);
940 error
= saSendReceiveReply (amfInstance
->response_fd
,
941 &req_lib_amf_protectiongrouptrackstop
,
942 sizeof (struct req_lib_amf_protectiongrouptrackstop
),
943 &res_lib_amf_protectiongrouptrackstop
,
944 sizeof (struct res_lib_amf_protectiongrouptrackstop
));
946 pthread_mutex_unlock (&amfInstance
->response_mutex
);
948 saHandleInstancePut (&amfHandleDatabase
, amfHandle
);
950 return (error
== SA_AIS_OK
? res_lib_amf_protectiongrouptrackstop
.header
.error
: error
);
954 saAmfComponentErrorReport (
955 SaAmfHandleT amfHandle
,
956 const SaNameT
*erroneousComponent
,
957 SaTimeT errorDetectionTime
,
958 SaAmfRecommendedRecoveryT recommendedRecovery
,
959 SaNtfIdentifierT ntfIdentifier
)
961 struct amfInstance
*amfInstance
;
962 struct req_lib_amf_componenterrorreport req_lib_amf_componenterrorreport
;
963 struct res_lib_amf_componenterrorreport res_lib_amf_componenterrorreport
;
966 error
= saHandleInstanceGet (&amfHandleDatabase
, amfHandle
,
967 (void *)&amfInstance
);
968 if (error
!= SA_AIS_OK
) {
972 req_lib_amf_componenterrorreport
.header
.id
= MESSAGE_REQ_AMF_COMPONENTERRORREPORT
;
973 req_lib_amf_componenterrorreport
.header
.size
= sizeof (struct req_lib_amf_componenterrorreport
);
974 memcpy (&req_lib_amf_componenterrorreport
.erroneousComponent
, erroneousComponent
,
976 req_lib_amf_componenterrorreport
.errorDetectionTime
= errorDetectionTime
;
977 req_lib_amf_componenterrorreport
.recommendedRecovery
= recommendedRecovery
;
978 DPRINT (("start error report\n"));
979 error
= saSendReceiveReply (amfInstance
->response_fd
,
980 &req_lib_amf_componenterrorreport
,
981 sizeof (struct req_lib_amf_componenterrorreport
),
982 &res_lib_amf_componenterrorreport
,
983 sizeof (struct res_lib_amf_componenterrorreport
));
984 DPRINT (("end error report\n"));
986 error
= res_lib_amf_componenterrorreport
.header
.error
;
988 pthread_mutex_unlock (&amfInstance
->response_mutex
);
990 saHandleInstancePut (&amfHandleDatabase
, amfHandle
);
992 return (error
== SA_AIS_OK
? res_lib_amf_componenterrorreport
.header
.error
: error
);
996 saAmfComponentErrorClear (
997 SaAmfHandleT amfHandle
,
998 const SaNameT
*compName
,
999 SaNtfIdentifierT ntfIdentifier
)
1001 struct amfInstance
*amfInstance
;
1002 struct req_lib_amf_componenterrorclear req_lib_amf_componenterrorclear
;
1003 struct res_lib_amf_componenterrorclear res_lib_amf_componenterrorclear
;
1006 error
= saHandleInstanceGet (&amfHandleDatabase
, amfHandle
,
1007 (void *)&amfInstance
);
1008 if (error
!= SA_AIS_OK
) {
1012 req_lib_amf_componenterrorclear
.header
.id
= MESSAGE_REQ_AMF_COMPONENTERRORCLEAR
;
1013 req_lib_amf_componenterrorclear
.header
.size
= sizeof (struct req_lib_amf_componenterrorclear
);
1014 memcpy (&req_lib_amf_componenterrorclear
.compName
, compName
, sizeof (SaNameT
));
1016 error
= saSendReceiveReply (amfInstance
->response_fd
,
1017 &req_lib_amf_componenterrorclear
,
1018 sizeof (struct req_lib_amf_componenterrorclear
),
1019 &res_lib_amf_componenterrorclear
,
1020 sizeof (struct res_lib_amf_componenterrorclear
));
1022 pthread_mutex_unlock (&amfInstance
->response_mutex
);
1024 saHandleInstancePut (&amfHandleDatabase
, amfHandle
);
1026 return (error
== SA_AIS_OK
? res_lib_amf_componenterrorclear
.header
.error
: error
);
1031 SaAmfHandleT amfHandle
,
1032 SaInvocationT invocation
,
1035 struct amfInstance
*amfInstance
;
1036 struct req_lib_amf_response req_lib_amf_response
;
1037 struct res_lib_amf_response res_lib_amf_response
;
1038 SaAisErrorT errorResult
;
1040 errorResult
= saHandleInstanceGet (&amfHandleDatabase
, amfHandle
,
1041 (void *)&amfInstance
);
1042 if (errorResult
!= SA_AIS_OK
) {
1043 return (errorResult
);
1046 req_lib_amf_response
.header
.id
= MESSAGE_REQ_AMF_RESPONSE
;
1047 req_lib_amf_response
.header
.size
= sizeof (struct req_lib_amf_response
);
1048 req_lib_amf_response
.invocation
= invocation
;
1049 req_lib_amf_response
.error
= error
;
1051 pthread_mutex_lock (&amfInstance
->response_mutex
);
1053 errorResult
= saSendReceiveReply (amfInstance
->response_fd
,
1054 &req_lib_amf_response
, sizeof (struct req_lib_amf_response
),
1055 &res_lib_amf_response
, sizeof (struct res_lib_amf_response
));
1057 pthread_mutex_unlock (&amfInstance
->response_mutex
);
1059 saHandleInstancePut (&amfHandleDatabase
, amfHandle
);
1061 return (errorResult
== SA_AIS_OK
? res_lib_amf_response
.header
.error
: errorResult
);