summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-03-21 15:02:41 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2008-03-21 15:02:41 +0000
commit3e4da6f1cc1e462c3a2f58b0587cef4e0028b137 (patch)
tree1ca808f09d03fce33dbbf9e3d01c42266ab7d95c
parent05c6fdb27f98e4d8ad8f94d4de1ff0e8a543e5a2 (diff)
downloadrsyslog-3e4da6f1cc1e462c3a2f58b0587cef4e0028b137.tar.gz
rsyslog-3e4da6f1cc1e462c3a2f58b0587cef4e0028b137.tar.xz
rsyslog-3e4da6f1cc1e462c3a2f58b0587cef4e0028b137.zip
added capability to receive RELP messages and forward them to the main
message queue to imrelp (not yet fully finished)
-rw-r--r--plugins/imrelp/imrelp.c51
-rw-r--r--plugins/omrelp/omrelp.c29
2 files changed, 17 insertions, 63 deletions
diff --git a/plugins/imrelp/imrelp.c b/plugins/imrelp/imrelp.c
index 01d1eae8..371de737 100644
--- a/plugins/imrelp/imrelp.c
+++ b/plugins/imrelp/imrelp.c
@@ -57,8 +57,8 @@ static relpEngine_t *pRelpEngine; /* our relp engine */
static int iTCPSessMax = 200; /* max number of sessions */
+/* ------------------------------ callbacks ------------------------------ */
#if 0
-/* callbacks */
/* this shall go into a specific ACL module! */
static int
isPermittedHost(struct sockaddr *addr, char *fromHostFQDN, void __attribute__((unused)) *pUsrSrv,
@@ -67,51 +67,27 @@ isPermittedHost(struct sockaddr *addr, char *fromHostFQDN, void __attribute__((u
return net.isAllowedSender(net.pAllowedSenders_TCP, addr, fromHostFQDN);
}
+#endif // #if 0
-static int*
-doOpenLstnSocks(tcpsrv_t *pSrv)
-{
- ISOBJ_TYPE_assert(pSrv, tcpsrv);
- return tcpsrv.create_tcp_socket(pSrv);
-}
-
-
-static int
-doRcvData(tcps_sess_t *pSess, char *buf, size_t lenBuf)
-{
- int state;
- assert(pSess != NULL);
-
- state = recv(pSess->sock, buf, lenBuf, 0);
- return state;
-}
-
-static rsRetVal
-onRegularClose(tcps_sess_t *pSess)
+/* callback for receiving syslog messages. This function is invoked from the
+ * RELP engine when a syslog message arrived. It must return a relpRetVal,
+ * with anything else but RELP_RET_OK terminating the relp session. Please note
+ * that RELP_RE_OK is equal to RS_RET_OK and the other libRELP error codes
+ * are different from our rsRetVal. So we can simply use our own iRet system
+ * to fulfill the requirement.
+ * rgerhards, 2008-03-21
+ */
+static relpRetVal
+onSyslogRcv(uchar *pMsg, size_t lenMsg)
{
DEFiRet;
- assert(pSess != NULL);
+ parseAndSubmitMessage("TODO:HOSTNAME", pMsg, lenMsg, MSG_PARSE_HOSTNAME, NOFLAG, eFLOWCTL_LIGHT_DELAY);
- /* process any incomplete frames left over */
- tcps_sess.PrepareClose(pSess);
- /* Session closed */
- tcps_sess.Close(pSess);
RETiRet;
}
-static rsRetVal
-onErrClose(tcps_sess_t *pSess)
-{
- DEFiRet;
- assert(pSess != NULL);
-
- tcps_sess.Close(pSess);
- RETiRet;
-}
-
/* ------------------------------ end callbacks ------------------------------ */
-#endif // #if 0
static rsRetVal addListener(void __attribute__((unused)) *pVal, uchar *pNewVal)
@@ -120,6 +96,7 @@ static rsRetVal addListener(void __attribute__((unused)) *pVal, uchar *pNewVal)
if(pRelpEngine == NULL) {
CHKiRet(relpEngineConstruct(&pRelpEngine));
CHKiRet(relpEngineSetDbgprint(pRelpEngine, dbgprintf));
+ CHKiRet(relpEngineSetSyslogRcv(pRelpEngine, dbgprintf));
}
CHKiRet(relpEngineAddListner(pRelpEngine, pNewVal));
diff --git a/plugins/omrelp/omrelp.c b/plugins/omrelp/omrelp.c
index 767b3f85..ed3a73c2 100644
--- a/plugins/omrelp/omrelp.c
+++ b/plugins/omrelp/omrelp.c
@@ -158,33 +158,12 @@ static rsRetVal TCPSendPrepRetry(void *pvData)
}
-/* open a connection to the remote peer (transport level)
- * rgerhards, 2007-12-28
- */
-static rsRetVal openConn(void *pvData)
-{
- DEFiRet;
- instanceData *pData = (instanceData *) pvData;
-
- assert(pData != NULL);
- if(pData->sock < 0) {
- if((pData->sock = tcpclt.CreateSocket(pData->f_addr)) < 0)
- iRet = RS_RET_TCP_SOCKCREATE_ERR;
- }
-
- RETiRet;
-}
-
-
/* try to resume connection if it is not ready
* rgerhards, 2007-08-02
*/
static rsRetVal doTryResume(instanceData *pData)
{
DEFiRet;
- struct addrinfo *res;
- struct addrinfo hints;
- unsigned e;
switch (pData->eDestState) {
case eDestFORW_SUSP:
@@ -195,8 +174,8 @@ static rsRetVal doTryResume(instanceData *pData)
case eDestFORW_UNKN:
/* The remote address is not yet known and needs to be obtained */
dbgprintf(" %s\n", pData->f_hname);
- iRet = relpCltConnect(pData->pRelpClt, family, pData->port, pData->f_hname);
- if(iRet = RELP_RET_OK)
+ iRet = relpCltConnect(pData->pRelpClt, family, (uchar*) pData->port, (uchar*) pData->f_hname);
+ if(iRet == RELP_RET_OK)
pData->eDestState = eDestFORW;
break;
case eDestFORW:
@@ -244,7 +223,7 @@ RUNLOG_VAR("%d", pData->eDestState);
/* forward */
relpRetVal ret;
RUNLOG;
- ret = relpCltSendSyslog(pData->pRelpClt, psz, l);
+ ret = relpCltSendSyslog(pData->pRelpClt, (uchar*) psz, l);
RUNLOG_VAR("%d", ret);
if(ret != RS_RET_OK) {
/* error! */
@@ -260,9 +239,7 @@ ENDdoAction
BEGINparseSelectorAct
uchar *q;
int i;
- int error;
int bErr;
- struct addrinfo hints, *res;
TCPFRAMINGMODE tcp_framing;
CODESTARTparseSelectorAct
CODE_STD_STRING_REQUESTparseSelectorAct(1)