Beispiel #1
0
/* Send a command to the server.
 * The is the "regular" function which ensures that server messages are received
 * and messages are only sent when we have space left in our window. This function
 * must only be called after the session is fully initialized. Calling it before
 * initialization is finished will probably hang the client.
 * rgerhards, 2008-03-19
 */
relpRetVal
relpSessSendCommand(relpSess_t *pThis, unsigned char *pCmd, size_t lenCmd,
		    unsigned char *pData, size_t lenData, relpRetVal (*rspHdlr)(relpSess_t*,relpFrame_t*))
{
	ENTER_RELPFUNC;
	RELPOBJ_assert(pThis, Sess);

	/* this both reads server responses as well as makes sure we have space
	 * left in our window.
	 */
	CHKRet(relpSessWaitState(pThis, eRelpSessState_READY_TO_SEND,
		pThis->timeout));

	/* re-try once if automatic retry mode is set */
	if(pThis->bAutoRetry && pThis->sessState == eRelpSessState_BROKEN) {
		CHKRet(relpSessTryReestablish(pThis));
	}

	/* then send our data */
	if(pThis->sessState == eRelpSessState_BROKEN)
		ABORT_FINALIZE(RELP_RET_SESSION_BROKEN);

	CHKRet(relpSessRawSendCommand(pThis, pCmd, lenCmd, pData, lenData, rspHdlr));

finalize_it:
	LEAVE_RELPFUNC;
}
Beispiel #2
0
/* Send a command to the server.
 * The is the "regular" function which ensures that server messages are received
 * and messages are only sent when we have space left in our window. This function
 * must only be called after the session is fully initialized. Calling it before
 * initialization is finished will probably hang the client.
 * rgerhards, 2008-03-19
 */
relpRetVal
relpSessSendCommand(relpSess_t *pThis, unsigned char *pCmd, size_t lenCmd,
		    unsigned char *pData, size_t lenData, relpRetVal (*rspHdlr)(relpSess_t*,relpFrame_t*))
{
	ENTER_RELPFUNC;
	RELPOBJ_assert(pThis, Sess);

	/* this both reads server responses as well as makes sure we have space left
	 * in our window. We provide a nearly eternal timeout (3 minutes). If we are not
	 * ready to send in that period, something is awfully wrong. TODO: we may want
	 * to make this timeout configurable, but I don't think it is a priority.
	 */
	//CHKRet(relpSessWaitState(pThis, eRelpSessState_READY_TO_SEND, 2));
	CHKRet(relpSessWaitState(pThis, eRelpSessState_READY_TO_SEND, 180));

	/* re-try once if automatic retry mode is set */
pThis->pEngine->dbgprint("send command relp sess state %d\n", pThis->sessState);
	if(pThis->bAutoRetry && pThis->sessState == eRelpSessState_BROKEN) {
pThis->pEngine->dbgprint("SendCommand does auto-retry\n");
		CHKRet(relpSessTryReestablish(pThis));
	}

pThis->pEngine->dbgprint("sendcommand ready to send, relp sess state %d\n", pThis->sessState);
	/* then send our data */
	if(pThis->sessState == eRelpSessState_BROKEN)
		ABORT_FINALIZE(RELP_RET_SESSION_BROKEN);

	CHKRet(relpSessRawSendCommand(pThis, pCmd, lenCmd, pData, lenData, rspHdlr));

finalize_it:
	LEAVE_RELPFUNC;
}
Beispiel #3
0
/** Try to reconnect a broken session to the remote
 * server. The main difference to relpCltConnect() is that the
 * session object is already existing and session parameters (like
 * remote host) can not be changed.
 * rgerhards, 2008-03-23
 */
relpRetVal
relpCltReconnect(relpClt_t *pThis)
{
	ENTER_RELPFUNC;
	RELPOBJ_assert(pThis, Clt);
	RELPOBJ_assert(pThis->pSess, Sess);

	CHKRet(relpSessTryReestablish(pThis->pSess));

finalize_it:
	LEAVE_RELPFUNC;
}