mirror of
https://github.com/rsyslog/rsyslog.git
synced 2025-12-20 09:40:42 +01:00
done a bit to support librelp testing
This commit is contained in:
parent
bfb9a77d69
commit
41fe6b8c53
@ -36,28 +36,28 @@
|
||||
#include <netdb.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <relp.h>
|
||||
#include "rsyslog.h"
|
||||
#include "syslogd.h"
|
||||
#include "cfsysline.h"
|
||||
#include "module-template.h"
|
||||
#include "net.h"
|
||||
#include "tcpsrv.h"
|
||||
|
||||
MODULE_TYPE_INPUT
|
||||
|
||||
/* static data */
|
||||
DEF_IMOD_STATIC_DATA
|
||||
DEFobjCurrIf(tcpsrv)
|
||||
DEFobjCurrIf(tcps_sess)
|
||||
DEFobjCurrIf(net)
|
||||
|
||||
/* Module static data */
|
||||
static tcpsrv_t *pOurTcpsrv = NULL; /* our TCP server(listener) TODO: change for multiple instances */
|
||||
static relpEngine_t *pRelpEngine; /* our relp engine */
|
||||
|
||||
|
||||
/* config settings */
|
||||
static int iTCPSessMax = 200; /* max number of sessions */
|
||||
|
||||
|
||||
#if 0
|
||||
/* callbacks */
|
||||
/* this shall go into a specific ACL module! */
|
||||
static int
|
||||
@ -111,22 +111,19 @@ onErrClose(tcps_sess_t *pSess)
|
||||
}
|
||||
|
||||
/* ------------------------------ end callbacks ------------------------------ */
|
||||
#endif // #if 0
|
||||
|
||||
|
||||
static rsRetVal addTCPListener(void __attribute__((unused)) *pVal, uchar *pNewVal)
|
||||
static rsRetVal addListener(void __attribute__((unused)) *pVal, uchar *pNewVal)
|
||||
{
|
||||
DEFiRet;
|
||||
if(pOurTcpsrv == NULL) {
|
||||
CHKiRet(tcpsrv.Construct(&pOurTcpsrv));
|
||||
CHKiRet(tcpsrv.SetCBIsPermittedHost(pOurTcpsrv, isPermittedHost));
|
||||
CHKiRet(tcpsrv.SetCBRcvData(pOurTcpsrv, doRcvData));
|
||||
CHKiRet(tcpsrv.SetCBOpenLstnSocks(pOurTcpsrv, doOpenLstnSocks));
|
||||
CHKiRet(tcpsrv.SetCBOnRegularClose(pOurTcpsrv, onRegularClose));
|
||||
CHKiRet(tcpsrv.SetCBOnErrClose(pOurTcpsrv, onErrClose));
|
||||
tcpsrv.configureTCPListen(pOurTcpsrv, (char *) pNewVal);
|
||||
CHKiRet(tcpsrv.ConstructFinalize(pOurTcpsrv));
|
||||
if(pRelpEngine == NULL) {
|
||||
CHKiRet(relpEngineConstruct(&pRelpEngine));
|
||||
CHKiRet(relpEngineSetDbgprint(pRelpEngine, dbgprintf));
|
||||
}
|
||||
|
||||
CHKiRet(relpEngineAddListner(pRelpEngine, pNewVal));
|
||||
|
||||
finalize_it:
|
||||
RETiRet;
|
||||
}
|
||||
@ -138,7 +135,7 @@ CODESTARTrunInput
|
||||
/* TODO: we must be careful to start the listener here. Currently, tcpsrv.c seems to
|
||||
* do that in ConstructFinalize
|
||||
*/
|
||||
iRet = tcpsrv.Run(pOurTcpsrv);
|
||||
iRet = relpEngineRun(pRelpEngine);
|
||||
ENDrunInput
|
||||
|
||||
|
||||
@ -146,8 +143,8 @@ ENDrunInput
|
||||
BEGINwillRun
|
||||
CODESTARTwillRun
|
||||
/* first apply some config settings */
|
||||
net.PrintAllowedSenders(2); /* TCP */
|
||||
if(pOurTcpsrv == NULL)
|
||||
//net.PrintAllowedSenders(2); /* TCP */
|
||||
if(pRelpEngine == NULL)
|
||||
ABORT_FINALIZE(RS_RET_NO_RUN);
|
||||
finalize_it:
|
||||
ENDwillRun
|
||||
@ -156,22 +153,22 @@ ENDwillRun
|
||||
BEGINafterRun
|
||||
CODESTARTafterRun
|
||||
/* do cleanup here */
|
||||
#if 0
|
||||
if(net.pAllowedSenders_TCP != NULL) {
|
||||
net.clearAllowedSenders(net.pAllowedSenders_TCP);
|
||||
net.pAllowedSenders_TCP = NULL;
|
||||
}
|
||||
#endif
|
||||
ENDafterRun
|
||||
|
||||
|
||||
BEGINmodExit
|
||||
CODESTARTmodExit
|
||||
if(pOurTcpsrv != NULL)
|
||||
iRet = tcpsrv.Destruct(&pOurTcpsrv);
|
||||
if(pRelpEngine != NULL)
|
||||
iRet = relpEngineDestruct(&pRelpEngine);
|
||||
|
||||
/* release objects we used */
|
||||
objRelease(net, LM_NET_FILENAME);
|
||||
objRelease(tcps_sess, LM_TCPSRV_FILENAME);
|
||||
objRelease(tcpsrv, LM_TCPSRV_FILENAME);
|
||||
ENDmodExit
|
||||
|
||||
|
||||
@ -194,15 +191,13 @@ BEGINmodInit()
|
||||
CODESTARTmodInit
|
||||
*ipIFVersProvided = CURR_MOD_IF_VERSION; /* we only support the current interface specification */
|
||||
CODEmodInit_QueryRegCFSLineHdlr
|
||||
pOurTcpsrv = NULL;
|
||||
pRelpEngine = NULL;
|
||||
/* request objects we use */
|
||||
CHKiRet(objUse(net, LM_NET_FILENAME));
|
||||
CHKiRet(objUse(tcps_sess, LM_TCPSRV_FILENAME));
|
||||
CHKiRet(objUse(tcpsrv, LM_TCPSRV_FILENAME));
|
||||
|
||||
/* register config file handlers */
|
||||
CHKiRet(omsdRegCFSLineHdlr((uchar *)"inputrelpserverrun", 0, eCmdHdlrGetWord,
|
||||
addTCPListener, NULL, STD_LOADABLE_MODULE_ID));
|
||||
addListener, NULL, STD_LOADABLE_MODULE_ID));
|
||||
CHKiRet(omsdRegCFSLineHdlr((uchar *)"inputrelpmaxsessions", 0, eCmdHdlrInt,
|
||||
NULL, &iTCPSessMax, STD_LOADABLE_MODULE_ID));
|
||||
CHKiRet(omsdRegCFSLineHdlr((uchar *)"resetconfigvariables", 1, eCmdHdlrCustomHandler,
|
||||
|
||||
@ -42,7 +42,6 @@
|
||||
#include <unistd.h>
|
||||
#include <relp.h>
|
||||
#include <relpclt.h>
|
||||
#include <pthread.h>
|
||||
#include "syslogd.h"
|
||||
#include "syslogd-types.h"
|
||||
#include "srUtils.h"
|
||||
@ -462,7 +461,7 @@ CODE_STD_STRING_REQUESTparseSelectorAct(1)
|
||||
*/
|
||||
|
||||
/* create our relp client */
|
||||
CHKiRet(relpCltConstruct(&pData->pRelpClt)); /* we use CHKiRet as librelp has a similar return value range */
|
||||
CHKiRet(relpCltConstruct(&pData->pRelpClt, pRelpEngine)); /* we use CHKiRet as librelp has a similar return value range */
|
||||
/* and set callbacks */
|
||||
#if 0 // TODO: the same for relp
|
||||
CHKiRet(tcpclt.SetSendInit(pData->pTCPClt, openConn));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user