ClRcT clDebugVersionCheck(ClVersionT *pVersion)
{
     ClRcT  rc = CL_OK;
     if(pVersion == NULL)
     {
        rc = CL_ERR_NULL_POINTER;
        return rc;
     }
     rc = clVersionVerify(&versionDatabase,pVersion);
     if(rc != CL_OK)
     {
          return rc;
     }
     return rc;
}
ClRcT clTxnVersionVerify(ClVersionT     *pVersion)
{
    ClRcT   rc  = CL_OK;

    CL_FUNC_ENTER();

    if (NULL == pVersion)
    {
        CL_FUNC_EXIT();
        return CL_TXN_RC(CL_ERR_NULL_POINTER);
    }

    rc = clVersionVerify (&clTxnMgmtVersionDb, pVersion);
    if (CL_OK != rc)
    {
        CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("Un-supported version. rc:0x%x\n", rc));
        rc = CL_TXN_RC(rc);
    }

    CL_FUNC_EXIT();
    return (rc);
}
ClRcT
clAmsSAInitialize(
        CL_OUT      ClAmsClientHandleT                      *amsHandle,
        CL_IN       const ClAmsSAClientCallbacksT           *amsClientCallbacks,
        CL_INOUT    ClVersionT                              *version )
{

    ClRcT                                       rc = CL_OK; 
    clAmsClientInitializeRequestT               req;
    clAmsClientInitializeResponseT              *res = NULL;
    struct ams_instance                         *ams_instance = NULL;


    if (amsHandle == NULL || version == NULL)
    {
        return CL_AMS_RC(CL_ERR_NULL_POINTER);
    }
   
    /* 
     * Initialize the library and database 
     */

    if ((rc = check_lib_init())
            != CL_OK)
        goto error;

    /* 
     * Verify the version information 
     */

    if (( rc = clVersionVerify (
                    &version_database,
                    version))
            != CL_OK)
        goto error;

    /* 
     * Create the handle  
     */

    if ((rc = clHandleCreate (
                    handle_database,
                    sizeof(struct ams_instance),
                    amsHandle))
            != CL_OK)
        goto error;

    /* 
     * Check-Out the handle 
     */

    if ((rc = clHandleCheckout(
                    handle_database,
                    *amsHandle,
                    (void *)&ams_instance))
            != CL_OK)
        goto error;


    /* 
     * Initialize instance entry 
     */

    if (amsClientCallbacks) 
    {
        memcpy(&ams_instance->callbacks, amsClientCallbacks, sizeof(ClAmsSAClientCallbacksT));
    } 
    else 
    {
        memset(&ams_instance->callbacks, 0, sizeof(ClAmsSAClientCallbacksT));
    }

     if ( ( rc = clOsalMutexCreate(&ams_instance->response_mutex)) != CL_OK )
         goto error;

    /* 
     * Inform the server 
     */

    req.handle = *amsHandle;
    if ( (rc = cl_ams_client_initialize(
                    &req,
                    &res))
            != CL_OK)
        goto error;

    /* 
     * Decrement handle use count and return 
     */

    if ((rc = clHandleCheckin(
                    handle_database,
                    *amsHandle))
            != CL_OK)
        goto error;
   
    clHeapFree((void*)res);
    res = NULL;
    return CL_OK;

error:

    clHeapFree((void*)res);
    res = NULL;
    return CL_AMS_RC(rc);
}
/*-----------------------------------------------------------------------------
 * Initialize API
 *---------------------------------------------------------------------------*/
ClRcT clGmsInitialize(
    CL_OUT   ClGmsHandleT* const    gmsHandle,
    CL_IN    const ClGmsCallbacksT* const gmsCallbacks,
    CL_INOUT ClVersionT*   const      version)
{
    struct gms_instance *gms_instance_ptr = NULL;
    ClRcT rc = CL_OK;
    ClGmsClientInitRequestT req = {{0}};
    ClGmsClientInitResponseT *res = NULL;

    /* Step 0: Check readiness of library */

    rc = check_lib_init();
    if (rc != CL_OK)
    {
        return CL_GMS_RC(CL_ERR_NOT_INITIALIZED);
    }
    
    /* Step 1: Checking inputs */
    CL_ASSERT(gmsHandle != NULL);
    CL_ASSERT(version != NULL);
#if 0    
    if ((gmsHandle == NULL) || (version == NULL))
    {
        return CL_GMS_RC(CL_ERR_NULL_POINTER);
    }
#endif    

    *gmsHandle = CL_HANDLE_INVALID_VALUE;

    /* Step 2: Verifying version match */
    
    rc = clVersionVerify (&version_database, version);
    if (rc != CL_OK)
    {
        return CL_GMS_RC(CL_ERR_VERSION_MISMATCH); 
    }

    /* Step 3: Obtain unique handle */
    rc = clHandleCreate(gmsHandleDb, sizeof(struct gms_instance), gmsHandle);
    CL_ASSERT(rc == CL_OK);
#if 0    
    if (rc != CL_OK)
    {
        rc = CL_GMS_RC(CL_ERR_NO_RESOURCE);
        goto error_no_destroy;
    }
#endif    
    clLogInfo("GMS","CLT","GMS client handle is [%llX]",*gmsHandle);
    
    rc = clHandleCheckout(gmsHandleDb, *gmsHandle, (void **)&gms_instance_ptr);
    CL_ASSERT(rc == CL_OK);
    CL_ASSERT(gms_instance_ptr != NULL);
#if 0    
    if(rc != CL_OK)
    {
        goto error_destroy;
    }
    if (gms_instance_ptr == NULL)
    {
        clHandleCheckin(gmsHandleDb, *gmsHandle);
        rc = CL_GMS_RC(CL_ERR_NULL_POINTER);
        goto error_destroy;
    }
#endif

    rc = clGmsMutexCreate(&gms_instance_ptr->response_mutex);
    CL_ASSERT(rc == CL_OK);
#if 0    
    if(rc != CL_OK)
    {
        clHandleCheckin(gmsHandleDb, *gmsHandle);
        goto error_destroy;
    }
#endif

    /* Step 4: Negotiate version with the server */
    req.clientVersion.releaseCode = version->releaseCode;
    req.clientVersion.majorVersion= version->majorVersion;
    req.clientVersion.minorVersion= version->minorVersion;

    rc = cl_gms_clientlib_initialize_rmd(&req, 0x0 ,&res );
    if(rc != CL_OK )
    {
        clLogError(GEN,NA,"cl_gms_clientlib_initialize_rmd failed with rc:0x%x ",rc);
        clGmsMutexDelete(gms_instance_ptr->response_mutex);
        gms_instance_ptr->response_mutex = 0;
        clHandleCheckin(gmsHandleDb, *gmsHandle);
        rc = CL_GMS_RC(rc);
        goto error_destroy;
    }
    
    /* Step 5: Initialize instance entry */
    if (gmsCallbacks) 
    {
        memcpy(&gms_instance_ptr->callbacks, gmsCallbacks, sizeof(ClGmsCallbacksT));
    } 
    else 
    {
        memset(&gms_instance_ptr->callbacks, 0, sizeof(ClGmsCallbacksT));
    }

    memset(&gms_instance_ptr->cluster_notification_buffer, 0, sizeof(ClGmsClusterNotificationBufferT));
    memset(&gms_instance_ptr->group_notification_buffer, 0, sizeof(ClGmsGroupNotificationBufferT));

    /* Step 6: Decrement handle use count and return */
    if ((clHandleCheckin(gmsHandleDb, *gmsHandle)) != CL_OK)
    {
        clLogError(GEN,DB, "\nclHandleCheckin failed");
    }
    clHeapFree(res);
    return CL_OK;

    error_destroy:
    clHandleDestroy(gmsHandleDb, *gmsHandle);
    *gmsHandle = CL_HANDLE_INVALID_VALUE;

    //error_no_destroy:
    return rc;
}
 * 	  closest value of the version supported filled in the version as out parameter.
 */
ClRcT 
clFaultVersionVerify(ClVersionT *version)
{
    ClRcT rc = CL_OK;
	if(version == NULL)
	{
		clLogError(FAULT_LOG_AREA_FAULT,FAULT_LOG_CTX_VERSION,"NULL pointer passed as version \
		           address.with rc: 0x%x", rc);
		return CL_ERR_NULL_POINTER;
	}

    CL_FUNC_ENTER();

	rc = clVersionVerify(&gFaultClientToServerVersionDb,version);
	if(rc != CL_OK)
	{
		clLogError(FAULT_LOG_AREA_FAULT,FAULT_LOG_CTX_VERSION,"The Cor Version is not supported. 0x%x", rc);
		return CL_FAULT_ERR_VERSION_UNSUPPORTED;
	}
    CL_FUNC_EXIT();
    return rc;
}


ClRcT
clFaultReport(SaNameT *compName,
                ClCorMOIdPtrT hMoId,
				ClAlarmStateT alarmState,
 				ClAlarmCategoryTypeT category, 
/**
 * This function receives control message from transaction-manager for coordinating
 * for a given transaction-job. Parameters identify transaction-job and the control
 * information necessary to execute the next step.
 */
ClRcT 
VDECL(clTxnAgentCntrlMsgReceive)(
        CL_IN   ClEoDataT               eoArg, 
        CL_IN   ClBufferHandleT  inMsg, 
        CL_IN   ClBufferHandleT  outMsg)
{
    ClRcT                   rc = CL_OK;
    ClTxnMessageHeaderT     msgHeader = {{0}};
    ClTxnMessageHeaderIDLT  msgHeadIDL = {{0}};
    
    CL_FUNC_ENTER();

    rc = VDECL_VER(clXdrUnmarshallClTxnMessageHeaderIDLT, 4, 0, 0)(inMsg, &msgHeadIDL);
    if(CL_OK != rc)
    {
        clLogError("AGT", NULL,
                "Error in unmarshalling msgHeadIDL, rc [0x%x]", rc);
        return rc;
    }

    _clTxnCopyIDLToMsgHead(&msgHeader, &msgHeadIDL);
    CL_ASSERT(msgHeader.msgCount);

    /* Check/Validate server version */
    rc = clVersionVerify (&clTxnMgmtVersionDb, &(msgHeader.version));
    if (CL_OK != rc)
    {
        CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("Un-supported version. rc:0x%x\n", rc));
        CL_FUNC_EXIT();
        return (CL_GET_ERROR_CODE(rc));
    }

    clLogDebug("AGT", NULL, "Receiving control-msg from txn-manager");

    /* 
       Based on msg-type, 
       - If this is TXN_DEFN, then extract the txn and job-defn and do initialize.
         Respond CL_OK, if everything is fine.

       - If this is TXN_CMD, then for each txn and job (if mentioned), execute 
         and intended operation

       - If TXN_STATUS_CHANGE, take action accordingly
    */

    switch (msgHeader.msgType)
    {
        case CL_TXN_MSG_MGR_CMD:
            rc = _clTxnAgentProcessMgrCmd(inMsg, outMsg, &msgHeader);
            break;

        case CL_TXN_MSG_CLIENT_REQ_TO_AGNT:
            rc = _clTxnAgentProcessClientCmd(inMsg, outMsg, &msgHeader);
            break;
        
        case CL_TXN_MSG_COMP_STATUS_UPDATE:
            rc = CL_ERR_NOT_IMPLEMENTED;
            break;

        default:
            CL_DEBUG_PRINT(CL_DEBUG_ERROR, 
                ("Invalid msg-type received 0x%x\n", msgHeader.msgType));
            rc = CL_ERR_INVALID_PARAMETER;
            break;
    }
/* This is to be replaced by clTxnCommIfcReadMessage(). clTxnCommIfcReadMessage()
 * writes to the outMsgHdl which is either received by the client or server depending
 * on where the async request came from 
 */
#if 0
    rc = clTxnCommIfcAllSessionClose();

    if (CL_OK != rc)
    {
        CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("Failed to process received msg. rc:0x%x\n", rc));
        /* FIXME: Do logging */
        rc = CL_GET_ERROR_CODE(rc);
    }
#endif

    CL_FUNC_EXIT();
    return (rc);
}
ClRcT VDECL(clDebugGetContext)(ClEoDataT        data,
                               ClBufferHandleT  inMsgHdl,
                               ClBufferHandleT  outMsgHdl)
{
    ClRcT        rc         = CL_OK;
    ClDebugObjT  *pDebugObj = (ClDebugObjT *) data;
    ClVersionT   version    = {0};
    ClIocPhysicalAddressT srcAddr = {0};

    if ((NULL == pDebugObj) || (0 == outMsgHdl) || (0 == inMsgHdl))
    {
        clLogWrite(CL_LOG_HANDLE_APP,CL_LOG_WARNING,CL_DEBUG_LIB_CLIENT,
                   CL_LOG_MESSAGE_1_INVALID_PARAMETER,"Invalid debugObj");
        return CL_DEBUG_RC(CL_ERR_INVALID_PARAMETER);
    }

    /*
     * Enable the comp status for the debug client to avoid
     * response failures from node representative in case the bit isnt enabled for cases when
     * the comp arrival from peer noderep. reaches late.
     */
    if(clRmdSourceAddressGet(&srcAddr) == CL_OK)
        clIocCompStatusEnable(srcAddr);
    
    rc = clXdrUnmarshallClVersionT(inMsgHdl,&version);
    if (CL_OK != rc)
    {
        return rc;
    }
    rc = clVersionVerify(&versionDatabase,&version);
    if (CL_OK != rc)
    {
        clXdrMarshallClVersionT(&version,outMsgHdl,0);
        return rc;
    }

    rc = clXdrMarshallArrayClCharT(pDebugObj->compName,
                                   CL_DEBUG_COMP_NAME_LEN,
                                   outMsgHdl,0);
    if (CL_OK != rc)
    {
        return rc;
    }

    rc = clXdrMarshallArrayClCharT(pDebugObj->compPrompt,
                                   CL_DEBUG_COMP_PROMPT_LEN,
                                   outMsgHdl,0);
    if (CL_OK != rc)
    {
        return rc;
    }

    rc = clXdrMarshallClUint32T((&pDebugObj->numFunc),
                                outMsgHdl,0);
    if (CL_OK != rc)
    {
        return rc;
    }

    rc = clHandleWalk(pDebugObj->hDebugFnDB, clDebugContexDetailsPack,
                      (ClPtrT) outMsgHdl);
    if( CL_OK != rc )
    {
        return rc;
    }

    return rc;
}
ClRcT VDECL(clDebugInvoke)(ClEoDataT        data,
                           ClBufferHandleT  inMsgHdl,
                           ClBufferHandleT  outMsgHdl)
{
    ClRcT 	              rc           = CL_OK;
    ClUint32T 	          i            = 0;
    ClUint32T 	          argc         = 0;
    ClCharT	              *argv[MAX_ARGS];
    ClCharT        	      argBuf[(MAX_ARG_BUF_LEN+1) * MAX_ARGS]; /* +1 for NULL termination */
    ClDebugObjT	          *pDebugObj   = (ClDebugObjT*) data;
    ClCharT   	          *resp        = NULL;
    ClVersionT            version      = {0};
    ClDebugInvokeCookieT  invokeCookie = {0};
    ClDebugDeferContextT  deferContext = {0};
    ClRcT                 retCode      = CL_OK;

    if ((NULL == pDebugObj) || (0 == outMsgHdl))
    {
        clLogWrite( CL_LOG_HANDLE_APP,CL_LOG_CRITICAL,CL_DEBUG_LIB_CLIENT,
                    CL_LOG_MESSAGE_0_MEMORY_ALLOCATION_FAILED);
        return CL_DEBUG_RC(CL_ERR_INVALID_PARAMETER);
    }

    rc = clXdrUnmarshallClVersionT(inMsgHdl,&version);
    if (CL_OK != rc)
    {
        return rc;
    }
    rc = clVersionVerify(&versionDatabase,&version);
    if (CL_OK != rc)
    {
        clXdrMarshallClVersionT(&version,outMsgHdl,0);
        return rc;
    }
    rc = clXdrUnmarshallClUint32T(inMsgHdl, &argc);
    if (CL_OK != rc)
    {
        return rc;
    }

    if (argc > MAX_ARGS)
    {
        DEBUG_CHECK("\r\n too many arguments");
        goto L1;
    }

    for (i = 0; i < argc; i++)
    {
        ClUint32T stringLength = 0;

        argv[i] = &argBuf[i * (MAX_ARG_BUF_LEN+1)];

        rc = clXdrUnmarshallClUint32T(inMsgHdl,&stringLength);
        if (CL_OK != rc)
        {
            return rc;
        }

        if (stringLength > MAX_ARG_BUF_LEN)
        {
            DEBUG_CHECK("\r\n argument too big");
            goto L1;
        }

        rc = clXdrUnmarshallArrayClCharT(inMsgHdl,argv[i],stringLength);
        if (CL_OK != rc)
        {
            return rc;
        }
        argv[i][stringLength] = '\0';
    }

    if (!strncasecmp(argv[0], "help", 4) && (argc > 1))
    {
        argv[0] = argv[1];
        argc = 0;
    }
    
    invokeCookie.pCommandName = argv[0];
    invokeCookie.pFuncEntry   = NULL;

    rc = clHandleWalk(pDebugObj->hDebugFnDB, clDebugFuncInvokeCallback, 
                      (void *) &invokeCookie);
    if( CL_DBG_INFO_CMD_FOUND == rc )
    {
        /* this is the indication for command found */
        rc = CL_OK;
    }
    if( CL_OK != rc )
    {
        DEBUG_CHECK("\r\ncommand not found");
        goto L1;
    }

    if (invokeCookie.pFuncEntry && invokeCookie.pFuncEntry->fpCallback)
    {
        deferContext.outMsgHdl = outMsgHdl;
        deferContext.defer = CL_FALSE;
        clOsalTaskDataSet(pDebugObj->debugTaskKey, (ClOsalTaskDataT)&deferContext);
        rc = invokeCookie.pFuncEntry->fpCallback(argc, argv, &resp);
    }
    else
    {
        DEBUG_CHECK("\r\ncommand not found");
    }

L1: 
    retCode = rc;
    rc      = CL_OK;
    if (!resp)
    {
        resp = clHeapAllocate(1);
        if (resp) resp[0]= '\0';
    }
    
    if (NULL != resp)
    {
        /*
         * Marshall the response to the out buffer if we aren't deferred.
         */
        if(!deferContext.defer)
            rc = clDebugResponseMarshall(resp, retCode, outMsgHdl);
        clHeapFree(resp);
        resp = NULL;
    }
    return rc;
}
static void gms_exec_message_handler (
                                      void *message,
                                      unsigned int nodeid)
{
    mar_req_header_t              header = {0};
    struct VDECL(req_exec_gms_nodejoin) req_exec_gms_nodejoin = {{0}};
    ClGmsViewNodeT               *node = NULL;
    ClRcT                         rc = CL_OK;
    ClGmsClusterMemberT           thisGmsClusterNode = {0};
    char                          nodeIp[256 * INTERFACE_MAX] = "";
    int                           isLocalMsg = 0;
    int                           verCode = 0;
    ClBufferHandleT               bufferHandle = NULL;

    /* Get the ip address string for the given nodeId */
    strncpy(nodeIp, get_node_ip(nodeid), (256 * INTERFACE_MAX)-1);
    if (strcmp(nodeIp, totemip_print(this_ip)) == 0)
    {
        isLocalMsg = 1;
    }

    /* Unmarshall the incoming message */
    rc = clBufferCreate(&bufferHandle);
    if (rc != CL_OK)
    {
        clLogError(OPN,AIS,
                   "Failed to create buffer while unmarshalling the received message. rc 0x%x",rc);
        return;
    }

    memcpy(&header, message, sizeof(mar_req_header_t));

    rc = clBufferNBytesWrite(bufferHandle, (ClUint8T *)message+sizeof(mar_req_header_t), header.size-sizeof(mar_req_header_t));
    if (rc != CL_OK)
    {
        clLogError(OPN,AIS,
                   "Failed to retrieve data from buffer. rc 0x%x",rc);
        goto out_delete;
    }

    rc = unmarshallReqExecGmsNodeJoin(bufferHandle, &req_exec_gms_nodejoin);
    if (rc != CL_OK)
    {
        clLogError(OPN,AIS,"Failed to unmarshall the data. rc 0x%x",rc);
        goto out_delete;
    }

    verCode = CL_VERSION_CODE(req_exec_gms_nodejoin.version.releaseCode, 
                              req_exec_gms_nodejoin.version.majorVersion,
                              req_exec_gms_nodejoin.version.minorVersion);
    clLog(DBG,OPN,AIS,
          "Received a %d message from version [%d.%d.%d].",req_exec_gms_nodejoin.gmsMessageType,
          req_exec_gms_nodejoin.version.releaseCode, req_exec_gms_nodejoin.version.majorVersion, 
          req_exec_gms_nodejoin.version.minorVersion);
    /* Verify version */
    if (verCode > CL_VERSION_CODE(curVer.releaseCode, curVer.majorVersion, curVer.minorVersion)) {
        /* I received a message from higher version and it dont know
         * how to decode it. So it discarding it. */
        clLog(NOTICE,OPN,AIS,
              "Version mismatch detected. Discarding the message ");
        goto out_delete;
    }

    // message type & message data
    clLog(DBG,OPN,AIS,"message type %d from groupId %d!\n", req_exec_gms_nodejoin.gmsMessageType, req_exec_gms_nodejoin.gmsGroupId);

    /* This message is from same version. So processing it */
    switch (req_exec_gms_nodejoin.gmsMessageType)
    {
    case CL_GMS_CLUSTER_JOIN_MSG:
        {
            ClUint32T minVersion = CL_VERSION_CODE(5, 0, 0);
            clLog(DBG,OPN,AIS,
                  "Received multicast message for cluster join from ioc node [%#x:%#x]",
                  req_exec_gms_nodejoin.specificMessage.gmsClusterNode.nodeAddress.iocPhyAddress.nodeAddress,
                  req_exec_gms_nodejoin.specificMessage.gmsClusterNode.nodeAddress.iocPhyAddress.portId);
            clNodeCacheMinVersionGet(NULL, &minVersion);
            if(minVersion >= CL_VERSION_CODE(5, 0, 0) && gAspNativeLeaderElection)
            {
                clLog(DBG, OPN, AIS,
                      "Skipping multicast join since node cache view is used to form the cluster ring");
                goto out_delete;
            }
            node = (ClGmsViewNodeT *) clHeapAllocate(sizeof(ClGmsViewNodeT));
            if (node == NULL)
            {
                clLog (ERROR,OPN,AIS, "clHeapAllocate failed");
                goto out_delete;
            }
            else {
                rc = clVersionVerify(
                                     &(gmsGlobalInfo.config.versionsSupported),
                                     &(req_exec_gms_nodejoin.specificMessage.gmsClusterNode.gmsVersion)
                                     );
                ringVersion.releaseCode =
                    req_exec_gms_nodejoin.specificMessage.gmsClusterNode.gmsVersion.releaseCode;
                ringVersion.majorVersion=
                    req_exec_gms_nodejoin.specificMessage.gmsClusterNode.gmsVersion.majorVersion;
                ringVersion.minorVersion=
                    req_exec_gms_nodejoin.specificMessage.gmsClusterNode.gmsVersion.minorVersion;
                if(rc != CL_OK)
                {
                    ringVersionCheckPassed = CL_FALSE;
                    /* copy the ring version */
                    clGmsCsLeave( &joinCs );
                    clLog (ERROR,OPN,AIS,
                           "Server Version Mismatch detected for this join message");
                    break;
                }

                _clGmsGetThisNodeInfo(&thisGmsClusterNode);
                if( thisGmsClusterNode.nodeId !=
                    req_exec_gms_nodejoin.specificMessage.gmsClusterNode.nodeId)
                {
                    /* TODO This will never happen... */
                    clGmsCsLeave( &joinCs );
                }

                node->viewMember.clusterMember =
                    req_exec_gms_nodejoin.specificMessage.gmsClusterNode;
                /* If this is local join, then update the IP address */
                if (thisGmsClusterNode.nodeId ==
                    req_exec_gms_nodejoin.specificMessage.gmsClusterNode.nodeId)
                {
                    memcpy(&node->viewMember.clusterMember.nodeIpAddress,
                           &myAddress, sizeof(ClGmsNodeAddressT));
                }

                rc = _clGmsEngineClusterJoin(req_exec_gms_nodejoin.gmsGroupId,
                                             req_exec_gms_nodejoin.specificMessage.gmsClusterNode.nodeId,
                                             node);
            }
        }
        break;
    case CL_GMS_CLUSTER_EJECT_MSG:
        clLog (DBG,OPN,AIS,
               "Received cluster eject multicast message from ioc node [%#x:%#x]",
               req_exec_gms_nodejoin.specificMessage.gmsClusterNode.nodeAddress.iocPhyAddress.nodeAddress,
               req_exec_gms_nodejoin.specificMessage.gmsClusterNode.nodeAddress.iocPhyAddress.portId);
        /* inform the member about the eject by invoking the ejection
         *  callback registered with the reason UKNOWN */
        /* The below logic is same for the leave as well so we just
         *  fall through the case */
        _clGmsGetThisNodeInfo(&thisGmsClusterNode);
        if( req_exec_gms_nodejoin.specificMessage.gmsClusterNode.nodeId ==
            thisGmsClusterNode.nodeId)
        {
            rc = _clGmsCallClusterMemberEjectCallBack(
                                                      req_exec_gms_nodejoin.ejectReason);
            if( rc != CL_OK )
            {
                clLog(ERROR,OPN,AIS,"_clGmsCallEjectCallBack failed with"
                      "rc:0x%x",rc);
            }
        }
    case CL_GMS_CLUSTER_LEAVE_MSG:
        clLog(DBG,OPN,AIS,
              "Received cluster leave multicast message from ioc node [%#x:%#x]",
              req_exec_gms_nodejoin.specificMessage.gmsClusterNode.nodeAddress.iocPhyAddress.nodeAddress,
              req_exec_gms_nodejoin.specificMessage.gmsClusterNode.nodeAddress.iocPhyAddress.portId);
        rc = _clGmsEngineClusterLeave(req_exec_gms_nodejoin.gmsGroupId,
                                      req_exec_gms_nodejoin.specificMessage.gmsClusterNode.nodeId);
        break;
    case CL_GMS_GROUP_CREATE_MSG:
        clLog(DBG,OPN,AIS,
              "Received group create multicast message from ioc node [%#x:%#x]",
              req_exec_gms_nodejoin.specificMessage.groupMessage.gmsGroupNode.memberAddress.iocPhyAddress.nodeAddress,
              req_exec_gms_nodejoin.specificMessage.groupMessage.gmsGroupNode.memberAddress.iocPhyAddress.portId);

        rc = _clGmsEngineGroupCreate(req_exec_gms_nodejoin.specificMessage.groupMessage.groupData.groupName,
                                     req_exec_gms_nodejoin.specificMessage.groupMessage.groupData.groupParams,
                                     req_exec_gms_nodejoin.contextHandle, isLocalMsg);
        break;
    case CL_GMS_GROUP_DESTROY_MSG:
        clLog(DBG,OPN,AIS,
              "Received group destroy multicast message from ioc node [%#x:%#x]",
              req_exec_gms_nodejoin.specificMessage.groupMessage.gmsGroupNode.memberAddress.iocPhyAddress.nodeAddress,
              req_exec_gms_nodejoin.specificMessage.groupMessage.gmsGroupNode.memberAddress.iocPhyAddress.portId);

        rc = _clGmsEngineGroupDestroy(req_exec_gms_nodejoin.specificMessage.groupMessage.groupData.groupId,
                                      req_exec_gms_nodejoin.specificMessage.groupMessage.groupData.groupName,
                                      req_exec_gms_nodejoin.contextHandle, isLocalMsg);
        break;
    case CL_GMS_GROUP_JOIN_MSG:
        clLog(DBG,OPN,AIS,
              "Received group join multicast message from ioc node [%#x:%#x]",
              req_exec_gms_nodejoin.specificMessage.groupMessage.gmsGroupNode.memberAddress.iocPhyAddress.nodeAddress,
              req_exec_gms_nodejoin.specificMessage.groupMessage.gmsGroupNode.memberAddress.iocPhyAddress.portId);

        node = (ClGmsViewNodeT *) clHeapAllocate(sizeof(ClGmsViewNodeT));
        if (!node)
        {
            log_printf (LOG_LEVEL_NOTICE, "clHeapAllocate failed");
            goto out_delete;
        }
        else {
            /* FIXME: Need to verify version */
            memcpy(&node->viewMember.groupMember,&req_exec_gms_nodejoin.specificMessage.groupMessage.gmsGroupNode,
                   sizeof(ClGmsGroupMemberT));
            memcpy(&node->viewMember.groupData, &req_exec_gms_nodejoin.specificMessage.groupMessage.groupData,
                   sizeof(ClGmsGroupInfoT));
            rc = _clGmsEngineGroupJoin(req_exec_gms_nodejoin.specificMessage.groupMessage.groupData.groupId,
                                       node, req_exec_gms_nodejoin.contextHandle, isLocalMsg);
        }
        break;
    case CL_GMS_GROUP_LEAVE_MSG:
        clLog(DBG,OPN,AIS,
              "Received group leave multicast message from ioc node [%#x:%#x]",
              req_exec_gms_nodejoin.specificMessage.groupMessage.gmsGroupNode.memberAddress.iocPhyAddress.nodeAddress,
              req_exec_gms_nodejoin.specificMessage.groupMessage.gmsGroupNode.memberAddress.iocPhyAddress.portId);

        rc = _clGmsEngineGroupLeave(req_exec_gms_nodejoin.specificMessage.groupMessage.groupData.groupId,
                                    req_exec_gms_nodejoin.specificMessage.groupMessage.gmsGroupNode.memberId,
                                    req_exec_gms_nodejoin.contextHandle, isLocalMsg);
        break;
    case CL_GMS_COMP_DEATH:
        clLog(DBG,OPN,AIS,
              "Received comp death multicast message");
        rc = _clGmsRemoveMemberOnCompDeath(req_exec_gms_nodejoin.specificMessage.groupMessage.gmsGroupNode.memberId);
        break;
    case CL_GMS_LEADER_ELECT_MSG:
        clLog(DBG,OPN,AIS,
              "Received leader elect multicast message from ioc node [%#x:%#x]",
              req_exec_gms_nodejoin.specificMessage.gmsClusterNode.nodeAddress.iocPhyAddress.nodeAddress,
              req_exec_gms_nodejoin.specificMessage.gmsClusterNode.nodeAddress.iocPhyAddress.portId);
        rc = _clGmsEnginePreferredLeaderElect(req_exec_gms_nodejoin.specificMessage.gmsClusterNode, 
                                              req_exec_gms_nodejoin.contextHandle,
                                              isLocalMsg);
        break;
    case CL_GMS_SYNC_MESSAGE:
        clLog(DBG,OPN,AIS,
              "Received gms synch multicast message");
        rc = _clGmsEngineGroupInfoSync((ClGmsGroupSyncNotificationT *)(req_exec_gms_nodejoin.dataPtr));
        clHeapFree(((ClGmsGroupSyncNotificationT *)req_exec_gms_nodejoin.dataPtr)->groupInfoList);
        clHeapFree(((ClGmsGroupSyncNotificationT *)req_exec_gms_nodejoin.dataPtr)->groupMemberList);
        clHeapFree(req_exec_gms_nodejoin.dataPtr);
        break;

    case CL_GMS_GROUP_MCAST_MSG:
        _clGmsEngineMcastMessageHandler(
                                        &(req_exec_gms_nodejoin.specificMessage.mcastMessage.groupInfo.gmsGroupNode),
                                        &(req_exec_gms_nodejoin.specificMessage.mcastMessage.groupInfo.groupData),
                                        req_exec_gms_nodejoin.specificMessage.mcastMessage.userDataSize,
                                        req_exec_gms_nodejoin.dataPtr);
        break;
    default:
        clLogMultiline(ERROR,OPN,AIS,
                       "Openais GMS wrapper received Message wih invalid [MsgType=%x]. \n"
                       "This could be because of multicast port clashes.",
                       req_exec_gms_nodejoin.gmsMessageType);
        goto out_delete;
    }
    clLog(TRACE,OPN,AIS,
          "Processed the received message. Returning");
    out_delete:
    clBufferDelete(&bufferHandle);
}