/* This accepts a new session, and, if all goes well, constructs a new * session object and adds it to the engine's list of sessions. * rgerhards, 2008-03-17 */ relpRetVal relpSessAcceptAndConstruct(relpSess_t **ppThis, relpSrv_t *pSrv, int sock) { relpSess_t *pThis; ENTER_RELPFUNC; assert(ppThis != NULL); RELPOBJ_assert(pSrv, Srv); assert(sock >= 0); CHKRet(relpSessConstruct(&pThis, pSrv->pEngine, pSrv)); CHKRet(relpTcpAcceptConnReq(&pThis->pTcp, sock, pThis->pEngine)); /* TODO: check hostname against ACL (callback?) */ /* TODO: check against max# sessions */ *ppThis = pThis; finalize_it: pSrv->pEngine->dbgprint("relp session accepted with state %d\n", iRet); if(iRet != RELP_RET_OK) { if(pThis != NULL) relpSessDestruct(&pThis); } LEAVE_RELPFUNC; }
/** open a relp session to a remote peer * remote servers parameters must already have been set. * rgerhards, 2008-03-19 */ relpRetVal relpCltConnect(relpClt_t *pThis, int protFamily, unsigned char *port, unsigned char *host) { ENTER_RELPFUNC; RELPOBJ_assert(pThis, Clt); CHKRet(relpSessConstruct(&pThis->pSess, pThis->pEngine, NULL)); CHKRet(relpSessConnect(pThis->pSess, protFamily, port, host)); finalize_it: if(iRet != RELP_RET_OK) { if(pThis->pSess != NULL) { relpSessDestruct(&pThis->pSess); } } LEAVE_RELPFUNC; }
/* This accepts a new session, and, if all goes well, constructs a new * session object and adds it to the engine's list of sessions. * rgerhards, 2008-03-17 */ relpRetVal relpSessAcceptAndConstruct(relpSess_t **ppThis, relpSrv_t *pSrv, int sock) { relpSess_t *pThis; ENTER_RELPFUNC; assert(ppThis != NULL); RELPOBJ_assert(pSrv, Srv); assert(sock >= 0); CHKRet(relpSessConstruct(&pThis, pSrv->pEngine, RELP_SRV_CONN, pSrv)); CHKRet(relpTcpAcceptConnReq(&pThis->pTcp, sock, pSrv)); *ppThis = pThis; finalize_it: if(iRet != RELP_RET_OK) { if(pThis != NULL) relpSessDestruct(&pThis); } LEAVE_RELPFUNC; }