/**
 * initializes the test client session structure.
 *
 * @function   testClntSessionInit
 *
 * @date       2015-02-09
 *
 * @revision   none
 *
 * @designer   Eric Tsang
 *
 * @programmer Eric Tsang
 *
 * @note
 *
 * assigns the user pointer of the session, and the callbacks to the appropriate
 *   callbacks of the client side test session.
 *
 * @signature  void testClntSessionInit(Session* session, CtrlClnt* CtrlClnt,
 *   SOCKET clientSock, sockaddr_in clientAddr)
 *
 * @param      session pointer to the session structure
 * @param      CtrlClnt pointer to the control client structure that this test
 *   is for
 * @param      clientSock socket representing the connection
 * @param      clientAddr address of the remote
 */
void testClntSessionInit(Session* session, CtrlClnt* CtrlClnt, SOCKET clientSock, sockaddr_in clientAddr)
{
    sessionInit(session, &clientSock, &clientAddr);
    session->usrPtr     = malloc(sizeof(TestClntSession));
    session->onMessage  = onMessage;
    session->onError    = onError;
    session->onClose    = onClose;

    TestClntSession* testClntSession = (TestClntSession*) session->usrPtr;
    testClntSession->ctrlClnt = CtrlClnt;
    sessionSetBufLen(session, testClntSession->ctrlClnt->testPacketSize);
}
예제 #2
0
파일: session.c 프로젝트: Quinchu/R1EMU
Session *sessionNew (RouterId_t routerId, uint8_t *sessionKey) {
    Session *self;

    if ((self = calloc(1, sizeof(Session))) == NULL) {
        return NULL;
    }

    if (!sessionInit(self, routerId, sessionKey)) {
        sessionDestroy(&self);
        error("Session failed to initialize.");
        return NULL;
    }

    return self;
}
/*******************************************************************************
Feature API: alarmClockCkptInitialize

*******************************************************************************/
SaAisErrorT
alarmClockCkptInitialize (void)
{
    SaAisErrorT  ret_code = SA_AIS_OK;

    if (ckpt_svc_hdl == 0)
    {
        ret_code = saCkptInitialize(&ckpt_svc_hdl, NULL, &ckpt_version);    
        if (ret_code != SA_AIS_OK)
        {
            alarmClockLogWrite(CL_LOG_SEV_ERROR,
                    "alarmClockCkptInitialize(pid=%d): Failed %x\n", 
                    getpid(), ret_code);
        }
    }    
    sessionInit();
    ClRcT rc = clOsalMutexInit(&alarmClockCkptMutex);
    CL_ASSERT(rc == CL_OK);
    ioVecs = clHeapCalloc(MAX_NUM_IOVECS, sizeof(*ioVecs));
    CL_ASSERT(ioVecs != NULL);
    return ret_code;
}