summaryrefslogtreecommitdiffstats
path: root/tools/omfwd.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/omfwd.c')
-rw-r--r--tools/omfwd.c42
1 files changed, 28 insertions, 14 deletions
diff --git a/tools/omfwd.c b/tools/omfwd.c
index 719075c7..59245536 100644
--- a/tools/omfwd.c
+++ b/tools/omfwd.c
@@ -77,6 +77,8 @@ DEFobjCurrIf(tcpclt)
typedef struct _instanceData {
netstrms_t *pNS; /* netstream subsystem */
netstrm_t *pNetstrm; /* our output netstream */
+ uchar *pszStrmDrvr;
+ int iStrmDrvrMode;
char *f_hname;
int *pSockArray; /* sockets to use for UDP */
int bIsConnected; /* are we connected to remote host? 0 - no, 1 - yes, UDP means addr resolved */
@@ -91,7 +93,9 @@ typedef struct _instanceData {
} instanceData;
/* config data */
-static uchar *pszTplName = NULL; /* name of the default template to use */
+static uchar *pszTplName = NULL; /* name of the default template to use */
+static uchar *pszStrmDrvr = NULL; /* name of the stream driver to use */
+static int iStrmDrvrMode = 0; /* mode for stream driver, driver-dependent (0 mostly means plain tcp) */
/* get the syslog forward port from selector_t. The passed in
@@ -256,12 +260,14 @@ static rsRetVal TCPSendInit(void *pvData)
assert(pData != NULL);
if(pData->pNetstrm == NULL) {
CHKiRet(netstrms.Construct(&pData->pNS));
- /* here we may set another netstream driver (e.g. to do TLS) */
+ /* the stream driver must be set before the object is finalized! */
+ CHKiRet(netstrms.SetDrvrName(pData->pNS, pszStrmDrvr));
CHKiRet(netstrms.ConstructFinalize(pData->pNS));
/* now create the actual stream and connect to the server */
CHKiRet(netstrms.CreateStrm(pData->pNS, &pData->pNetstrm));
CHKiRet(netstrm.ConstructFinalize(pData->pNetstrm));
+ CHKiRet(netstrm.SetDrvrMode(pData->pNetstrm, pData->iStrmDrvrMode));
CHKiRet(netstrm.Connect(pData->pNetstrm, glbl.GetDefPFFamily(),
(uchar*)pData->port, (uchar*)pData->f_hname));
}
@@ -405,12 +411,9 @@ static rsRetVal
loadTCPSupport(void)
{
DEFiRet;
- if(!netstrms.ifIsLoaded)
- CHKiRet(objUse(netstrms, LM_NETSTRMS_FILENAME));
- if(!netstrm.ifIsLoaded)
- CHKiRet(objUse(netstrm, LM_NETSTRM_FILENAME));
- if(!tcpclt.ifIsLoaded)
- CHKiRet(objUse(tcpclt, LM_TCPCLT_FILENAME));
+ CHKiRet(objUse(netstrms, LM_NETSTRMS_FILENAME));
+ CHKiRet(objUse(netstrm, LM_NETSTRMS_FILENAME));
+ CHKiRet(objUse(tcpclt, LM_TCPCLT_FILENAME));
finalize_it:
RETiRet;
@@ -563,6 +566,9 @@ CODE_STD_STRING_REQUESTparseSelectorAct(1)
CHKiRet(tcpclt.SetSendFrame(pData->pTCPClt, TCPSendFrame));
CHKiRet(tcpclt.SetSendPrepRetry(pData->pTCPClt, TCPSendPrepRetry));
CHKiRet(tcpclt.SetFraming(pData->pTCPClt, tcp_framing));
+ pData->iStrmDrvrMode = iStrmDrvrMode;
+ if(pData->pszStrmDrvr != NULL)
+ CHKmalloc(pData->pszStrmDrvr = (uchar*)strdup((char*)pszStrmDrvr));
}
CODE_STD_FINALIZERparseSelectorAct
@@ -575,17 +581,18 @@ CODESTARTmodExit
objRelease(errmsg, CORE_COMPONENT);
objRelease(glbl, CORE_COMPONENT);
objRelease(net, LM_NET_FILENAME);
- if(netstrm.ifIsLoaded)
- objRelease(netstrm, LM_NETSTRM_FILENAME);
- if(netstrms.ifIsLoaded)
- objRelease(netstrms, LM_NETSTRMS_FILENAME);
- if(!tcpclt.ifIsLoaded)
- objRelease(tcpclt, LM_TCPCLT_FILENAME);
+ objRelease(netstrm, LM_NETSTRMS_FILENAME);
+ objRelease(netstrms, LM_NETSTRMS_FILENAME);
+ objRelease(tcpclt, LM_TCPCLT_FILENAME);
if(pszTplName != NULL) {
free(pszTplName);
pszTplName = NULL;
}
+ if(pszStrmDrvr != NULL) {
+ free(pszStrmDrvr);
+ pszStrmDrvr = NULL;
+ }
ENDmodExit
@@ -604,6 +611,11 @@ static rsRetVal resetConfigVariables(uchar __attribute__((unused)) *pp, void __a
free(pszTplName);
pszTplName = NULL;
}
+ if(pszStrmDrvr != NULL) {
+ free(pszStrmDrvr);
+ pszStrmDrvr = NULL;
+ }
+ iStrmDrvrMode = 0;
return RS_RET_OK;
}
@@ -618,6 +630,8 @@ CODEmodInit_QueryRegCFSLineHdlr
CHKiRet(objUse(net,LM_NET_FILENAME));
CHKiRet(regCfSysLineHdlr((uchar *)"actionforwarddefaulttemplate", 0, eCmdHdlrGetWord, NULL, &pszTplName, NULL));
+ CHKiRet(regCfSysLineHdlr((uchar *)"actionsendstreamdriver", 0, eCmdHdlrGetWord, NULL, &pszStrmDrvr, NULL));
+ CHKiRet(regCfSysLineHdlr((uchar *)"actionsendstreamdrivermode", 0, eCmdHdlrInt, NULL, &iStrmDrvrMode, NULL));
CHKiRet(omsdRegCFSLineHdlr((uchar *)"resetconfigvariables", 1, eCmdHdlrCustomHandler, resetConfigVariables, NULL, STD_LOADABLE_MODULE_ID));
ENDmodInit