/**************************************************************************** * Name : amf_standby_state_handler * * Description : This function is called upon receving an standby state * assignment from AMF. * * Arguments : invocation - Designates a particular invocation. * cb - A pointer to the LGS control block. * * Return Values : None * * Notes : None *****************************************************************************/ static SaAisErrorT amf_standby_state_handler(lgs_cb_t *cb, SaInvocationT invocation) { SaAisErrorT error = SA_AIS_OK; TRACE_ENTER2("HA STANDBY request"); cb->ha_state = SA_AMF_HA_STANDBY; cb->mds_role = V_DEST_RL_STANDBY; TRACE_LEAVE(); return error; }
/** * Function to prepare the data message * * @param buffer len * * @return NCSCC_RC_SUCCESS * @return NCSCC_RC_FAILURE * */ uint32_t dtm_prepare_data_msg(uint8_t *buffer, uint16_t len) { uint8_t *data = buffer; TRACE_ENTER(); ncs_encode_16bit(&data, (len - 2)); ncs_encode_32bit(&data, (uint32_t)DTM_INTERNODE_SND_MSG_IDENTIFIER); ncs_encode_8bit(&data, (uint8_t)DTM_INTERNODE_SND_MSG_VER); ncs_encode_8bit(&data, DTM_MESSAGE_MSG_TYPE); /* Remaining data already in buffer */ TRACE_LEAVE(); return NCSCC_RC_SUCCESS; }
/*************************************************************************** @brief : saSmfCallbackScopeUnregister. No cbk will be called for the client after successful retutn of this api. @param[in] : smfHandle - Handle returned by successful intialize. @param[in] : scopeId - Filters for this scope id will be unregistered. inv id is to be passed in the response. @return : SA_AIS_OK if successful otherwise appropiate err code. *****************************************************************************/ SaAisErrorT saSmfCallbackScopeUnregister( SaSmfHandleT smfHandle, SaSmfCallbackScopeIdT scopeId) { SMFA_CB *cb = &_smfa_cb; SMFA_CLIENT_INFO *client_info; TRACE_ENTER2("Handle: %llu, Scope: %u.",smfHandle,scopeId); if (cb->is_finalized){ LOG_ER("SMFA: Already finalized, Bad handle %llu.",smfHandle); TRACE_LEAVE(); return SA_AIS_ERR_BAD_HANDLE; } if (NCSCC_RC_SUCCESS != m_NCS_LOCK(&cb->cb_lock,NCS_LOCK_WRITE)){ LOG_ER("SMFA: Cb lock acquire FAILED."); TRACE_LEAVE(); return SA_AIS_ERR_NO_RESOURCES; } /* Get the client info structure for the handle.*/ client_info = smfa_client_info_get(smfHandle); if (NULL == client_info){ LOG_ER("SMFA: Bad handle."); m_NCS_UNLOCK(&cb->cb_lock, NCS_LOCK_WRITE); TRACE_LEAVE(); return SA_AIS_ERR_BAD_HANDLE; } /* Check if the scope id exists. Remove if exists otherwise return NOT_EXIST.*/ if (NCSCC_RC_FAILURE == smfa_scope_info_rmv(client_info,scopeId)){ LOG_ER("SMFA: Scope id %x does not exist",scopeId); m_NCS_UNLOCK(&cb->cb_lock, NCS_LOCK_WRITE); TRACE_LEAVE(); return SA_AIS_ERR_NOT_EXIST; } m_NCS_UNLOCK(&cb->cb_lock, NCS_LOCK_WRITE); TRACE_LEAVE(); return SA_AIS_OK; }
/**************************************************************************** * Name : amf_active_state_handler * * Description : This function is called upon receiving an active state * assignment from AMF. * * Arguments : invocation - Designates a particular invocation. * cb - A pointer to the LGS control block. * * Return Values : None * * Notes : None *****************************************************************************/ static SaAisErrorT amf_active_state_handler(lgs_cb_t *cb, SaInvocationT invocation) { log_stream_t *stream; SaAisErrorT error = SA_AIS_OK; TRACE_ENTER2("HA ACTIVE request"); if (cb->ha_state == SA_AMF_HA_ACTIVE) { /* State change was already processed in RDA callback */ goto done; } /* switch over, become implementer */ immutilWrapperProfile.nTries = 250; /* LOG will be blocked until IMM responds */ immutilWrapperProfile.errorsAreFatal = 0; if ((error = immutil_saImmOiImplementerSet(lgs_cb->immOiHandle, "safLogService")) != SA_AIS_OK) { LOG_ER("saImmOiClassImplementerSet (safLogService) failed: %d", error); goto done; } if ((error = immutil_saImmOiClassImplementerSet(lgs_cb->immOiHandle, "SaLogStreamConfig")) != SA_AIS_OK) { LOG_ER("saImmOiClassImplementerSet (SaLogStreamConfig) failed: %d", error); goto done; } /* Do this only if the class exists */ if (*(bool*) lgs_imm_logconf_get(LGS_IMM_LOG_OPENSAFLOGCONFIG_CLASS_EXIST, NULL)) { if ((error = immutil_saImmOiClassImplementerSet(cb->immOiHandle, "OpenSafLogConfig")) != SA_AIS_OK) { LOG_ER("saImmOiClassImplementerSet (OpenSafLogConfig) failed: %d", error); goto done; } } /* check existing streams */ stream = log_stream_getnext_by_name(NULL); if (!stream) LOG_ER("No streams exist!"); while (stream != NULL) { *stream->p_fd = -1; /* First Initialize fd */ stream = log_stream_getnext_by_name(stream->name); } done: immutilWrapperProfile.nTries = 20; /* Reset retry time to more normal value. */ immutilWrapperProfile.errorsAreFatal = 1; /* Update role independent of stream processing */ lgs_cb->mds_role = V_DEST_RL_ACTIVE; TRACE_LEAVE(); return error; }
/**************************************************************************** * Name : cpnd_ckpt_sec_get * * Description : Function to Find the section in a checkpoint. * * Arguments : CPND_CKPT_NODE *cp_node - Check point node. * : SaCkptSectionIdT id - Section Identifier * * Return Values : NULL/CPND_CKPT_SECTION_INFO * * Notes : None. *****************************************************************************/ CPND_CKPT_SECTION_INFO *cpnd_ckpt_sec_get(CPND_CKPT_NODE *cp_node, SaCkptSectionIdT *id) { CPND_CKPT_SECTION_INFO *pSecPtr = NULL; TRACE_ENTER(); if (cp_node->replica_info.n_secs == 0) { TRACE_4("cpnd replica has no section for ckpt_id:%llx",cp_node->ckpt_id); TRACE_LEAVE(); return NULL; } pSecPtr = cp_node->replica_info.section_info; while (pSecPtr != NULL) { if ((pSecPtr->sec_id.idLen == id->idLen) && (memcmp(pSecPtr->sec_id.id, id->id, id->idLen) == 0)) { return pSecPtr; } pSecPtr = pSecPtr->next; } TRACE_LEAVE(); return NULL; }
/**************************************************************************** * Name : eds_process_api_evt * * Description : This is the function which is called when eds receives an * event either because of an API Invocation or other internal * messages from EDA clients * * Arguments : evt - Message that was posted to the EDS Mail box. * * Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE * * Notes : None. *****************************************************************************/ static uint32_t eds_process_api_evt(EDSV_EDS_EVT *evt) { TRACE_ENTER(); if (evt->evt_type == EDSV_EDS_EDSV_MSG) { if ((evt->info.msg.type >= EDSV_BASE_MSG) && (evt->info.msg.type < EDSV_MSG_MAX)) { if (eds_edsv_evt_dispatch_tbl[evt->info.msg.type] (evt) != NCSCC_RC_SUCCESS) { } } } TRACE_LEAVE(); return NCSCC_RC_SUCCESS; }
/** * Fucntion to send internode message * * @param node_id buffer len * * @return NCSCC_RC_SUCCESS * @return NCSCC_RC_FAILURE * */ uns32 dtm_internode_snd_msg_to_node(uns8 *buffer, uns16 len, NODE_ID node_id) { DTM_NODE_DB *node = NULL; TRACE_ENTER(); node = dtm_node_get_by_id(node_id); if (NULL != node) { if (NCSCC_RC_SUCCESS != dtm_internode_snd_msg_common(node, buffer, len)) { free(buffer); TRACE_LEAVE(); return NCSCC_RC_FAILURE; } } else { free(buffer); TRACE_LEAVE(); return NCSCC_RC_FAILURE; } /* Get the node entry and send message */ TRACE_LEAVE(); return NCSCC_RC_SUCCESS; }
void sendLoggedConfirmUpdate(SaNtfIdentifierT notificationId) { ntfsv_ckpt_msg_t ckpt; TRACE_ENTER2("notId: %llu", notificationId); memset(&ckpt, 0, sizeof(ckpt)); ckpt.header.ckpt_rec_type = NTFS_CKPT_NOT_LOG_CONFIRM; ckpt.header.num_ckpt_records = 1; ckpt.header.data_len = 1; ckpt.ckpt_rec.log_confirm.notificationId = notificationId; update_standby(&ckpt, NCS_MBCSV_ACT_ADD); TRACE_LEAVE(); }
/**************************************************************************** * Name : amf_csi_set_callback * * Description : AMF callback function called * when there is any change in the HA state. * * Arguments : invocation - This parameter designated a particular * invocation of this callback function. The * invoke process return invocation when it * responds to the Avilability Management * FrameWork using the saAmfResponse() * function. * compName - A pointer to the name of the component * whose readiness stae the Availability * Management Framework is setting. * haState - The new HA state to be assumeb by the * component service instance identified by * csiName. * csiDescriptor - This will indicate whether or not the * component service instance for * ativeCompName went through quiescing. * * Return Values : None. * * Notes : None. *****************************************************************************/ static void amf_csi_set_callback(SaInvocationT invocation, const SaNameT * compName, SaAmfHAStateT new_haState, SaAmfCSIDescriptorT csiDescriptor) { SaAisErrorT result = SA_AIS_OK; TRACE_ENTER(); /* Nothing to be done. We are always active */ smfnd_cb->ha_state = new_haState; saAmfResponse(smfnd_cb->amf_hdl, invocation, result); TRACE_LEAVE(); }
/****************************************************************************** Name : avnd_int_ext_comp_val Description : This routine checks for int/ext comp. Arguments : cb - ptr to the AvND control block. api_info - ptr to the api info structure. ctxt - ptr to mds context information. o_amf_rc - ptr to the amf-rc (o/p). Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE Notes : None ******************************************************************************/ uns32 avnd_int_ext_comp_val(AVND_CB *cb, SaNameT *comp_name, AVND_COMP **o_comp, SaAisErrorT *o_amf_rc) { uns32 res = NCSCC_RC_SUCCESS; *o_amf_rc = SA_AIS_OK; TRACE_ENTER2("%s",comp_name->value); if (0 == (*o_comp = m_AVND_INT_EXT_COMPDB_REC_GET(cb->internode_avail_comp_db, *comp_name))) { return NCSCC_RC_FAILURE; } else { /* This means that this is an internode component. But need to check wether it is a proxy for external component. If it is, then we shouldn't treat it as an external component though it is in internode DB. This is bz of a proxy on Ctrl is proxying external component. */ if (m_AVND_PROXY_IS_FOR_EXT_COMP(*o_comp)){ TRACE_LEAVE(); return NCSCC_RC_FAILURE; } } TRACE_LEAVE(); return res; }
/***********************************************************************//** * @brief This routine registers the PLMA with MDS. * * @return NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE. ***************************************************************************/ uint32_t plma_mds_register() { uint32_t rc = NCSCC_RC_SUCCESS; NCSMDS_INFO svc_info; MDS_SVC_ID svc_id[1] = { NCSMDS_SVC_ID_PLMS}; PLMA_CB *plma_cb = plma_ctrlblk; TRACE_ENTER(); /* STEP 1: the MDS handle for PLMA*/ rc = plma_mds_get_handle(); if (NCSCC_RC_SUCCESS != rc) { LOG_ER("PLMA - mds get handle failed"); return rc; } /* STEP 2 : Install with MDS with service ID NCSMDS_SVC_ID_PLMA. */ memset(&svc_info, 0, sizeof(NCSMDS_INFO)); svc_info.i_mds_hdl = plma_cb->mds_hdl; svc_info.i_svc_id = NCSMDS_SVC_ID_PLMA; svc_info.i_op = MDS_INSTALL; svc_info.info.svc_install.i_yr_svc_hdl = 0; svc_info.info.svc_install.i_install_scope = NCSMDS_SCOPE_NONE; /*node specific */ svc_info.info.svc_install.i_svc_cb = plma_mds_callback; /* callback */ svc_info.info.svc_install.i_mds_q_ownership = false; /***************************FIXME : MDS svc private sub part ver no?.**/ svc_info.info.svc_install.i_mds_svc_pvt_ver = PLMA_MDS_PVT_SUBPART_VERSION; if (ncsmds_api(&svc_info) == NCSCC_RC_FAILURE) { LOG_ER("PLMA - MDS Install Failed"); return NCSCC_RC_FAILURE; } /* STEP 3 : Subscribe to PLMS up/down events */ memset(&svc_info, 0, sizeof(NCSMDS_INFO)); svc_info.i_mds_hdl = plma_cb->mds_hdl; svc_info.i_svc_id = NCSMDS_SVC_ID_PLMA; svc_info.i_op = MDS_SUBSCRIBE; svc_info.info.svc_subscribe.i_num_svcs = 1; svc_info.info.svc_subscribe.i_scope = NCSMDS_SCOPE_NONE; svc_info.info.svc_subscribe.i_svc_ids = svc_id; if (ncsmds_api(&svc_info) == NCSCC_RC_FAILURE) { LOG_ER("PLMA - MDS Subscribe for PLMS up/down Failed"); plma_mds_unregister(); return NCSCC_RC_FAILURE; } TRACE_LEAVE(); return rc; }
/*********************************************************************** * Name : plms_hrb_initialize * * Description : This function initializes the HRB control block * and creates plms_hrb thread, It registers to MDS * to receive requests from PLMS * * Arguments : * * Return Values : NCSCC_RC_SUCCESS * NCSCC_RC_FAILURE ***********************************************************************/ SaUint32T plms_hrb_initialize() { PLMS_HRB_CB *cb = hrb_cb; pthread_t thread_id; pthread_attr_t attr; struct sched_param thread_priority; SaUint32T policy; SaUint32T rc; TRACE_ENTER(); /* create the mail box and attach it */ if ((rc = m_NCS_IPC_CREATE(&cb->mbx)) != NCSCC_RC_SUCCESS){ LOG_ER("error creating mail box err val:%d",rc); return NCSCC_RC_FAILURE; } if ((rc = m_NCS_IPC_ATTACH(&cb->mbx)) != NCSCC_RC_SUCCESS){ LOG_ER("error attaching mail box err val:%d",rc); return NCSCC_RC_FAILURE; } /* Initialize with the MDS */ if(hrb_mds_initialize() != NCSCC_RC_SUCCESS){ LOG_ER("HRB: mds initialization failed"); return NCSCC_RC_FAILURE; } /* Initialize thread attribute */ pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); pthread_attr_setstacksize(&attr, PLMS_HRB_STACKSIZE); /* Create PLMS_HRB thread */ rc = pthread_create(&thread_id, &attr, plms_hrb, NULL); if(rc){ LOG_ER("pthread_create FAILED ret code:%d error:%s", rc,strerror(errno)); return NCSCC_RC_FAILURE; } /*scheduling parameters of the thread */ memset(&thread_priority, 0, sizeof(thread_priority)); thread_priority.sched_priority = PLMS_HRB_TASK_PRIORITY; policy = SCHED_OTHER; pthread_setschedparam(thread_id, policy, &thread_priority); TRACE_LEAVE(); return NCSCC_RC_SUCCESS; }
/**************************************************************************** Name : avnd_pgdb_mem_rec_add Description : This routine adds/modifies a PG member record to/in the PG record. Arguments : cb - ptr to the AvND control block pg - ptr to the pg rec mem_info - ptr to the member info Return Values : ptr to the pg member rec, if successful 0, otherwise Notes : None. ******************************************************************************/ AVND_PG_MEM *avnd_pgdb_mem_rec_add(AVND_CB *cb, AVND_PG *pg, SaAmfProtectionGroupNotificationT *mem_info) { AVND_PG_MEM *pg_mem = 0; TRACE_ENTER(); /* get the mem rec */ pg_mem = m_AVND_PGDB_MEM_REC_GET(*pg, mem_info->member.compName); if (!pg_mem) { /* a new record.. alloc & link it to the dll */ pg_mem = calloc(1, sizeof(AVND_PG_MEM)); if (!pg_mem) goto err; /* a fresh rec.. mark this member as a new addition */ pg_mem->info.change = mem_info->change; /* update the record key */ pg_mem->info.member.compName = mem_info->member.compName; pg_mem->pg_dll_node.key = (uns8 *)&pg_mem->info.member.compName; /* add to the dll */ if (NCSCC_RC_SUCCESS != ncs_db_link_list_add(&pg->mem_list, &pg_mem->pg_dll_node)) goto err; } else pg_mem->info.change = SA_AMF_PROTECTION_GROUP_STATE_CHANGE; /* update other params */ pg_mem->info.member = mem_info->member; TRACE_LEAVE(); return pg_mem; err: if (pg_mem) free(pg_mem); TRACE_LEAVE(); return 0; }
/**************************************************************************** * Name : cpnd_ckpt_sec_del * * Description : Function to remove the section from a checkpoint. * * Arguments : CPND_CKPT_NODE *cp_node - Check point node. * : SaCkptSectionIdT id - Section Identifier * * Return Values : ptr to CPND_CKPT_SECTION_INFO/NULL; * * Notes : None. *****************************************************************************/ CPND_CKPT_SECTION_INFO *cpnd_ckpt_sec_del(CPND_CKPT_NODE *cp_node, SaCkptSectionIdT *id) { CPND_CKPT_SECTION_INFO *pSecPtr = NULL; uint32_t rc = NCSCC_RC_SUCCESS; TRACE_ENTER(); pSecPtr = cp_node->replica_info.section_info; while (pSecPtr != NULL) { if ((pSecPtr->sec_id.idLen == id->idLen) && (memcmp(pSecPtr->sec_id.id, id->id, id->idLen) == 0)) { /* delete it from the list and return the pointer */ if (cp_node->replica_info.section_info == pSecPtr) cp_node->replica_info.section_info = cp_node->replica_info.section_info->next; if (pSecPtr->prev) pSecPtr->prev->next = pSecPtr->next; if (pSecPtr->next) pSecPtr->next->prev = pSecPtr->prev; cp_node->replica_info.n_secs--; cp_node->replica_info.mem_used = cp_node->replica_info.mem_used - (pSecPtr->sec_size); /* UPDATE THE SECTION HEADER */ rc = cpnd_sec_hdr_update(pSecPtr, cp_node); if (rc == NCSCC_RC_FAILURE) { TRACE_4("cpnd sect hdr update failed"); } /* UPDATE THE CHECKPOINT HEADER */ rc = cpnd_ckpt_hdr_update(cp_node); if (rc == NCSCC_RC_FAILURE) { TRACE_4("cpnd ckpt hdr update failed"); } TRACE_LEAVE(); return pSecPtr; } pSecPtr = pSecPtr->next; } TRACE_LEAVE(); return NULL; }
/**************************************************************************** * Name : cpd_amf_comp_terminate_callback * * Description : This function SAF callback function which will be called * when the AMF framework needs to terminate GLSV. This does * all required to destroy GLSV(except to unregister from AMF) * * Arguments : invocation - This parameter designated a particular * invocation of this callback function. The * invoke process return invocation when it * responds to the Avilability Management * FrameWork using the saAmfResponse() * function. * compName - A pointer to the name of the component * whose readiness stae the Availability * Management Framework is setting. * * Return Values : None * * Notes : At present we are just support a simple liveness check. *****************************************************************************/ void cpd_amf_comp_terminate_callback(SaInvocationT invocation, const SaNameT *compName) { CPD_CB *cb = 0; SaAisErrorT saErr = SA_AIS_OK; TRACE_ENTER(); cb = ncshm_take_hdl(NCS_SERVICE_ID_CPD, gl_cpd_cb_hdl); if (cb) { saAmfResponse(cb->amf_hdl, invocation, saErr); ncshm_give_hdl(cb->cpd_hdl); } LOG_NO("Received AMF component terminate callback, exiting"); TRACE_LEAVE(); exit(0); }
/** * Free saved (allocated) CCB data * */ static void saImmOiCcbAbortCallback(SaImmOiHandleT immOiHandle, SaImmOiCcbIdT ccbId) { struct CcbUtilCcbData *ccbUtilCcbData; TRACE_ENTER(); if ((ccbUtilCcbData = ccbutil_findCcbData(ccbId)) != NULL) { ccbutil_deleteCcbData(ccbUtilCcbData); } else { LOG_ER("%s: Failed to find CCB object for ccb Id %llu",__FUNCTION__, ccbId); } TRACE_LEAVE(); }
/************************************************************ Function that allows to perform a query on a network driver or to set the parameters of an adapter. ************************************************************/ DWORD PacketRequest( POPEN_INSTANCE Open, DWORD FunctionCode, DWORD dwDDB, DWORD hDevice, PDIOCPARAMETERS pDiocParms ) { PLIST_ENTRY RequestListEntry; PINTERNAL_REQUEST pRequest; PPACKET_RESERVED pReserved; PPACKET_OID_DATA OidData; NDIS_STATUS Status; TRACE_ENTER( "Request Packet" ); /*extract a request from the list*/ NdisAcquireSpinLock( &Open->RequestSpinLock ); RequestListEntry = PacketRemoveHeadList(&Open->RequestList); NdisReleaseSpinLock( &Open->RequestSpinLock ); if ( RequestListEntry == NULL ) { IF_TRACE( "Request List Error" ); *(DWORD *)(pDiocParms->lpcbBytesReturned) = 0; TRACE_LEAVE( "Request Packet" ); return NDIS_STATUS_FAILURE/*NDIS_STATUS_SUCCESS*/; } pReserved = CONTAINING_RECORD( RequestListEntry, PACKET_RESERVED, ListElement ); pRequest = CONTAINING_RECORD( pReserved, INTERNAL_REQUEST, Reserved ); OidData = (PPACKET_OID_DATA)(pDiocParms->lpvInBuffer); if ( ( pDiocParms->cbInBuffer == pDiocParms->cbOutBuffer ) && ( pDiocParms->cbInBuffer >= sizeof(PACKET_OID_DATA) - 1 + OidData->Length) ) { pReserved->lpBuffer = (PVOID)PacketPageLock( pDiocParms->lpvInBuffer, pDiocParms->cbInBuffer ); pReserved->lpcbBytesReturned= (PVOID)PacketPageLock( (PVOID)pDiocParms->lpcbBytesReturned, sizeof(DWORD) ); pReserved->lpoOverlapped = (PVOID)PacketPageLock( (PVOID)pDiocParms->lpoOverlapped, sizeof(OVERLAPPED) ); pReserved->cbBuffer = pDiocParms->cbInBuffer; if ( FunctionCode == BIOCSETOID ) { pRequest->Request.RequestType = NdisRequestSetInformation; pRequest->Request.DATA.SET_INFORMATION.Oid = OidData->Oid; pRequest->Request.DATA.SET_INFORMATION.InformationBufferLength = OidData->Length; pRequest->Request.DATA.SET_INFORMATION.InformationBuffer = OidData->Data; IF_PACKETDEBUG( PACKET_DEBUG_VERY_LOUD ) { IF_TRACE_MSG2( "Request Set: Oid=%08lx, Length=%08lx", OidData->Oid, OidData->Length ); } }
void immd_db_purge_fevs(IMMD_CB *cb) { TRACE_ENTER(); while (cb->saved_msgs) { IMMD_SAVED_FEVS_MSG *old = cb->saved_msgs; cb->saved_msgs = cb->saved_msgs->next; TRACE_5("Message no %llu discarded", old->fevsMsg.sender_count); free(old->fevsMsg.msg.buf); old->fevsMsg.msg.buf = NULL; old->fevsMsg.msg.size = 0; free(old); } TRACE_LEAVE(); }
/**************************************************************************** * Name : amf_standby_state_handler * * Description : This function is called upon receving an standby state * assignment from AMF. * * Arguments : invocation - Designates a particular invocation. * cb - A pointer to the SMFD control block. * * Return Values : None * * Notes : None *****************************************************************************/ static SaAisErrorT amf_standby_state_handler(smfd_cb_t * cb, SaInvocationT invocation) { SaAisErrorT result = SA_AIS_OK; TRACE_ENTER2("HA STANDBY request"); cb->mds_role = V_DEST_RL_STANDBY; goto done; done: TRACE_LEAVE(); return result; }
/**************************************************************************** * Name : plms_amf_csi_rmv_callback * * Description : This callback routine is invoked by AMF during a * CSI set removal operation. * * Arguments : invocation - This parameter designated a particular * invocation of this callback function. The * invoke process return invocation when it * responds to the Avilability Management * FrameWork using the saAmfResponse() * function. * compName - A pointer to the name of the component * whose readiness state the Availability * Management Framework is setting. * csiName - A const pointer to csiName * csiFlags - csi Flags * Return Values : None *****************************************************************************/ void plms_amf_csi_rmv_callback(SaInvocationT invocation, const SaNameT *compName, const SaNameT *csiName, const SaAmfCSIFlagsT csiFlags) { PLMS_CB *cb = plms_cb; SaAisErrorT error = SA_AIS_OK; TRACE_ENTER(); m_NCS_LOCK(&cb->cb_lock,NCS_LOCK_READ); saAmfResponse(plms_cb->amf_hdl, invocation, error); m_NCS_UNLOCK(&cb->cb_lock,NCS_LOCK_READ); TRACE_LEAVE(); return; }
/** * Delete the node from the nodedb * * @param node * * @return NCSCC_RC_SUCCESS * @return NCSCC_RC_FAILURE * */ uns32 dtm_node_delete(DTM_NODE_DB * node, int i) { uns32 rc = NCSCC_RC_SUCCESS; DTM_INTERNODE_CB *dtms_cb = dtms_gl_cb; TRACE_ENTER2("DTM:value of i %d", i); assert(node != NULL); switch (i) { case 0: if (node->node_id != 0) { if ((rc = ncs_patricia_tree_del(&dtms_cb->nodeid_tree, &node->pat_nodeid)) != NCSCC_RC_SUCCESS) { TRACE("DTM:ncs_patricia_tree_del FAILED for nodename :%s rc :%u", node->node_name, rc); goto done; } } break; case 1: if (node->comm_socket != 0) { if ((rc = ncs_patricia_tree_del(&dtms_cb->comm_sock_tree, &node->pat_comm_socket)) != NCSCC_RC_SUCCESS) { TRACE("DTM:ncs_patricia_tree_del FAILED for nodename :%s rc :%u", node->node_name, rc); goto done; } } break; case 2: if (node->node_ip != NULL) { if ((rc = ncs_patricia_tree_del(&dtms_cb->ip_addr_tree, &node->pat_ip_address)) != NCSCC_RC_SUCCESS) { TRACE("DTM:ncs_patricia_tree_del FAILED for nodename :%s rc :%u", node->node_name, rc); goto done; } } break; default: assert(0); } done: TRACE_LEAVE(); return rc; }
static void app_ccb_apply_cb(CcbUtilOperationData_t *opdata) { AVD_APP *app; int i = 0; TRACE_ENTER2("CCB ID %llu, '%s'", opdata->ccbId, opdata->objectName.value); switch (opdata->operationType) { case CCBUTIL_CREATE: app = avd_app_create(&opdata->objectName, opdata->param.create.attrValues); assert(app); app_add_to_model(app); break; case CCBUTIL_MODIFY: { const SaImmAttrModificationT_2 *attr_mod; app = avd_app_get(&opdata->objectName); while ((attr_mod = opdata->param.modify.attrMods[i++]) != NULL) { const SaImmAttrValuesT_2 *attribute = &attr_mod->modAttr; if (!strcmp(attribute->attrName, "saAmfAppType")) { avd_apptype_remove_app(app); app->saAmfAppType = *((SaNameT*)attribute->attrValues[0]); app->app_type = avd_apptype_get(&app->saAmfAppType); avd_apptype_add_app(app); LOG_NO("Changed saAmfAppType to '%s' for '%s'", app->saAmfAppType.value, app->name.value); break; } else assert(0); } break; } case CCBUTIL_DELETE: app = avd_app_get(&opdata->objectName); /* by this time all the SGs and SIs under this * app object should have been *DELETED* just * do a sanity check here */ assert(app->list_of_sg == NULL); assert(app->list_of_si == NULL); avd_app_delete(app); break; default: assert(0); } TRACE_LEAVE(); }
/***********************************************************************//** * @brief MDS will call this function on receiving PLMA messages. * * @param[in] rcv_info - MDS Receive information. * * @return NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE. ***************************************************************************/ static uint32_t plma_mds_rcv(MDS_CALLBACK_RECEIVE_INFO *rcv_info) { uint32_t rc = NCSCC_RC_SUCCESS; PLMA_ENTITY_GROUP_INFO *grp_info; PLMA_CB *plma_cb = plma_ctrlblk; PLMS_EVT *pEvt = (PLMS_EVT *)rcv_info->i_msg; TRACE_ENTER(); if(pEvt->req_res == PLMS_REQ){ if(pEvt->req_evt.req_type == PLMS_AGENT_TRACK_EVT_T){ if(pEvt->req_evt.agent_track.evt_type == PLMS_AGENT_TRACK_CBK_EVT){ SaPlmEntityGroupHandleT grp_hdl = pEvt->req_evt.agent_track.grp_handle; grp_info = (PLMA_ENTITY_GROUP_INFO *)ncs_patricia_tree_get(&plma_cb->entity_group_info, (uint8_t *)&grp_hdl); if(!grp_info){ /** FIXME : free the evt structure */ return NCSCC_RC_SUCCESS; } if(!grp_info->client_info){ /** FIXME : free the evt structure */ return NCSCC_RC_SUCCESS; } pEvt->sinfo.ctxt = rcv_info->i_msg_ctxt; pEvt->sinfo.dest = rcv_info->i_fr_dest; pEvt->sinfo.to_svc = rcv_info->i_fr_svc_id; if (rcv_info->i_rsp_reqd) { pEvt->sinfo.stype = MDS_SENDTYPE_RSP; } /* Put it in PLMA's Event Queue */ rc = m_NCS_IPC_SEND(&grp_info->client_info->callbk_mbx, (NCSCONTEXT)pEvt, NCS_IPC_PRIORITY_NORMAL); if (NCSCC_RC_SUCCESS != rc) { LOG_ER("PLMA - IPC SEND FAILED"); } } } } TRACE_LEAVE(); return rc; }
/** * Function to process the incoming connection request * * * @return NCSCC_RC_SUCCESS * @return NCSCC_RC_FAILURE * */ static uint32_t dtm_intranode_process_incoming_conn(void) { int flags; /* Accept processing */ int accept_fd = 0, retry_count = 0, size = DTM_INTRANODE_SOCK_SIZE; socklen_t len = sizeof(struct sockaddr_un); struct sockaddr_un cli_addr; /* Accept should be non_block */ TRACE_ENTER(); accept_fd = accept(dtm_intranode_cb->server_sockfd, (struct sockaddr *)&cli_addr, &len); /* Error Checking */ if (accept_fd < 0) { LOG_ER("DTM: Connection accept fail"); return NCSCC_RC_FAILURE; } tryagain: /*Make the socket Non-Blocking for accepting */ if ((flags = fcntl(accept_fd, F_GETFL, NULL)) < 0) { LOG_ER("DTM :fcntl(F_SETFL, O_NONBLOCK) err :%s ", strerror(errno)); return false; } flags |= O_NONBLOCK; if (fcntl(accept_fd, F_SETFL, flags) < 0) { LOG_ER("DTM: accept_fd Non-Blocking hasnt been Set"); retry_count++; /* Non-Blocking Options hasnt been set */ if (retry_count > 3) { osafassert(0); } else { goto tryagain; } } if (setsockopt(accept_fd, SOL_SOCKET, SO_RCVBUF, &size, sizeof(size)) != 0) { LOG_ER("DTM: Unable to set the SO_RCVBUF "); close(accept_fd); return NCSCC_RC_FAILURE; } if (setsockopt(accept_fd, SOL_SOCKET, SO_SNDBUF, &size, sizeof(size)) != 0) { LOG_ER("DTM: Unable to set the SO_SNDBUF "); close(accept_fd); return NCSCC_RC_FAILURE; } dtm_intranode_add_poll_fdlist(accept_fd, POLLIN); dtm_intranode_create_pid_info(accept_fd); TRACE_LEAVE(); return NCSCC_RC_SUCCESS; }
static uint32_t eds_proc_chan_open_sync_msg(EDS_CB *cb, EDSV_EDS_EVT *evt) { uint32_t rc = NCSCC_RC_SUCCESS, rs = NCSCC_RC_SUCCESS, async_rc = NCSCC_RC_SUCCESS; uint32_t chan_id; uint32_t chan_open_id; EDSV_MSG msg; time_t time_of_day; SaTimeT chan_create_time = 0; EDSV_EDA_CHAN_OPEN_SYNC_PARAM *open_sync_param; EDS_CKPT_DATA ckpt; TRACE_ENTER2("agent dest: %" PRIx64, evt->fr_dest); open_sync_param = &(evt->info.msg.info.api_info.param.chan_open_sync); /* Set the open time here */ m_NCS_OS_GET_TIME_STAMP(time_of_day); /* convert time_t to SaTimeT */ chan_create_time = (SaTimeT)time_of_day *SA_TIME_ONE_SECOND; rs = eds_channel_open(cb, open_sync_param->reg_id, open_sync_param->chan_open_flags, open_sync_param->chan_name.length, open_sync_param->chan_name.value, evt->fr_dest, &chan_id, &chan_open_id, chan_create_time); if (rs != SA_AIS_OK) TRACE("Channel Open failed for agent destination: %" PRIx64, evt->fr_dest); /* Send response back */ m_EDS_EDSV_CHAN_OPEN_SYNC_MSG_FILL(msg, rs, chan_id, chan_open_id) rc = eds_mds_msg_send(cb, &msg, &evt->fr_dest, &evt->mds_ctxt, MDS_SEND_PRIORITY_HIGH); if (rc != SA_AIS_OK) LOG_ER("MDS send to %" PRIx64 " failed for saEvtChannelOpen()", evt->fr_dest); if (rs == SA_AIS_OK) { /* Send an Async update to STANDBY EDS peer */ if (cb->ha_state == SA_AMF_HA_ACTIVE) { memset(&ckpt, 0, sizeof(ckpt)); m_EDSV_FILL_ASYNC_UPDATE_CHAN(ckpt, open_sync_param, chan_id, chan_open_id, evt->fr_dest, chan_create_time) async_rc = send_async_update(cb, &ckpt, NCS_MBCSV_ACT_ADD); if (async_rc != NCSCC_RC_SUCCESS) TRACE("Async Update Send failed for chan open sync msg"); } } TRACE_LEAVE(); return rc; }
/**************************************************************************** Name : ava_destroy Description : This routine destroys the AvA control block. Arguments : destroy_info - ptr to the destroy info Return Values : None Notes : None ******************************************************************************/ void ava_destroy(NCS_LIB_DESTROY *destroy_info) { AVA_CB *cb = 0; uns32 rc = NCSCC_RC_SUCCESS; TRACE_ENTER(); /* retrieve AvA CB */ cb = (AVA_CB *)ncshm_take_hdl(NCS_SERVICE_ID_AVA, gl_ava_hdl); if (!cb) { LOG_ER("Unable to take handle for control block"); goto done; } /* delete the hdl db */ ava_hdl_del(cb); TRACE_1("Deleted the handles DB"); /* unregister with MDS */ rc = ava_mds_unreg(cb); if (NCSCC_RC_SUCCESS != rc) TRACE_4("MDS unregistration failed"); else TRACE_1("MDS unregistration success"); /* EDU cleanup */ m_NCS_EDU_HDL_FLUSH(&cb->edu_hdl); TRACE_1("EDU cleanup failed"); /* destroy the lock */ m_NCS_LOCK_DESTROY(&cb->lock); TRACE_1("Destroying lock for control block failed"); /* return AvA CB */ ncshm_give_hdl(gl_ava_hdl); /* remove the association with hdl-mngr */ ncshm_destroy_hdl(NCS_SERVICE_ID_AVA, cb->cb_hdl); TRACE_1("Removing association with handle manager failed"); /* free the control block */ free(cb); /* reset the global cb handle */ gl_ava_hdl = 0; done: TRACE_LEAVE(); return; }
BOOL CKsIrpTarget::SafeCloseHandle(HANDLE &handle) { TRACE_ENTER(); BOOL bRet; bRet = TRUE; if (IsValidHandle(handle)) { bRet = CloseHandle(handle); handle = INVALID_HANDLE_VALUE; } TRACE_LEAVE(); return bRet; }
/** * Rename a file * * @param indata[in] old_path[], new_path[] * @param outdata[out] Not used * @param max_outsize[in] Must be 0 * @return (-1) on error, errno is logged */ int rename_file_hdl(void *indata, void *outdata, size_t max_outsize) { int rc = 0; TRACE_ENTER(); size_t old_path_size = *((size_t *) indata); char *old_path = (char *) indata + sizeof(size_t); char *new_path = old_path + old_path_size; if ((rc = rename(old_path, new_path)) == -1) LOG_NO("rename: FAILED - %s", strerror(errno)); TRACE_LEAVE(); return rc; }
/**************************************************************************** Name : mqa_queue_tree_init Description : This routine is used to initialize the queue tree Arguments : cb - pointer to the MQA Control Block Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE Notes : None ******************************************************************************/ static uint32_t mqa_queue_tree_init(MQA_CB *cb) { NCS_PATRICIA_PARAMS param; TRACE_ENTER(); uint32_t rc = NCSCC_RC_SUCCESS; memset(¶m, 0, sizeof(NCS_PATRICIA_PARAMS)); param.key_size = sizeof(SaMsgQueueHandleT); if ((rc = ncs_patricia_tree_init(&cb->mqa_queue_tree, ¶m)) != NCSCC_RC_SUCCESS) { TRACE_2("Initialization of the queue tree failed"); return rc; } TRACE_LEAVE(); return NCSCC_RC_SUCCESS; }
/**************************************************************************** Name : mqa_client_tree_init Description : This routine is used to initialize the client tree Arguments : cb - pointer to the MQA Control Block Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE Notes : None ******************************************************************************/ static uint32_t mqa_client_tree_init(MQA_CB *cb) { NCS_PATRICIA_PARAMS param; TRACE_ENTER(); memset(¶m, 0, sizeof(NCS_PATRICIA_PARAMS)); param.key_size = sizeof(SaMsgHandleT); if (ncs_patricia_tree_init(&cb->mqa_client_tree, ¶m) != NCSCC_RC_SUCCESS) { TRACE_2("FAILURE: initialization of the client tree failed"); return NCSCC_RC_FAILURE; } TRACE_LEAVE(); return NCSCC_RC_SUCCESS; }