/** Construct a RELP sess instance * the pSrv parameter may be set to NULL if the session object is for a client. */ relpRetVal relpSessConstruct(relpSess_t **ppThis, relpEngine_t *pEngine, int connType, void *pParent) { relpSess_t *pThis; ENTER_RELPFUNC; assert(ppThis != NULL); RELPOBJ_assert(pEngine, Engine); if((pThis = calloc(1, sizeof(relpSess_t))) == NULL) { ABORT_FINALIZE(RELP_RET_OUT_OF_MEMORY); } RELP_CORE_CONSTRUCTOR(pThis, Sess); pThis->pEngine = pEngine; /* use Engine's command enablement states as default */ pThis->stateCmdSyslog = pEngine->stateCmdSyslog; if(connType == RELP_SRV_CONN) { pThis->pSrv = (relpSrv_t*) pParent; } else { pThis->pClt = (relpClt_t*) pParent; } pThis->txnr = 1; /* txnr start at 1 according to spec */ pThis->timeout = 90; pThis->pUsr = NULL; pThis->sizeWindow = RELP_DFLT_WINDOW_SIZE; pThis->maxDataSize = RELP_DFLT_MAX_DATA_SIZE; pThis->authmode = eRelpAuthMode_None; pThis->pristring = NULL; pThis->caCertFile = NULL; pThis->ownCertFile = NULL; pThis->privKeyFile = NULL; pThis->permittedPeers.nmemb = 0; CHKRet(relpSendqConstruct(&pThis->pSendq, pThis->pEngine)); pthread_mutex_init(&pThis->mutSend, NULL); *ppThis = pThis; finalize_it: if(iRet != RELP_RET_OK) { if(pThis != NULL) { relpSessDestruct(&pThis); } } LEAVE_RELPFUNC; }
/** Construct a RELP offer instance * rgerhards, 2008-03-24 */ static relpRetVal relpOfferConstruct(relpOffer_t **ppThis, relpEngine_t *pEngine) { relpOffer_t *pThis; ENTER_RELPFUNC; assert(ppThis != NULL); if((pThis = calloc(1, sizeof(relpOffer_t))) == NULL) { ABORT_FINALIZE(RELP_RET_OUT_OF_MEMORY); } RELP_CORE_CONSTRUCTOR(pThis, Offer); pThis->pEngine = pEngine; *ppThis = pThis; finalize_it: LEAVE_RELPFUNC; }
/** Construct a RELP sendbuf instance * This is the first thing that a caller must do before calling any * RELP function. The relp sendbuf must only destructed after all RELP * operations have been finished. */ relpRetVal relpSendbufConstruct(relpSendbuf_t **ppThis, relpSess_t *pSess) { relpSendbuf_t *pThis; ENTER_RELPFUNC; assert(ppThis != NULL); if((pThis = calloc(1, sizeof(relpSendbuf_t))) == NULL) { ABORT_FINALIZE(RELP_RET_OUT_OF_MEMORY); } RELP_CORE_CONSTRUCTOR(pThis, Sendbuf); pThis->pSess = pSess; *ppThis = pThis; finalize_it: LEAVE_RELPFUNC; }
/** Construct a RELP sess instance * the pSrv parameter may be set to NULL if the session object is for a client. */ relpRetVal relpSessConstruct(relpSess_t **ppThis, relpEngine_t *pEngine, relpSrv_t *pSrv) { relpSess_t *pThis; ENTER_RELPFUNC; assert(ppThis != NULL); RELPOBJ_assert(pEngine, Engine); if((pThis = calloc(1, sizeof(relpSess_t))) == NULL) { ABORT_FINALIZE(RELP_RET_OUT_OF_MEMORY); } RELP_CORE_CONSTRUCTOR(pThis, Sess); pThis->pEngine = pEngine; /* use Engine's command enablement states as default */ pThis->stateCmdSyslog = pEngine->stateCmdSyslog; pThis->pSrv = pSrv; pThis->txnr = 1; /* txnr start at 1 according to spec */ pThis->timeout = 10; /* TODO: make configurable */ pThis->sizeWindow = RELP_DFLT_WINDOW_SIZE; /* TODO: make configurable */ pThis->maxDataSize = RELP_DFLT_MAX_DATA_SIZE; CHKRet(relpSendqConstruct(&pThis->pSendq, pThis->pEngine)); pthread_mutex_init(&pThis->mutSend, NULL); *ppThis = pThis; finalize_it: if(iRet != RELP_RET_OK) { if(pThis != NULL) { relpSessDestruct(&pThis); } } LEAVE_RELPFUNC; }