diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2008-05-16 13:36:41 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2008-05-16 13:36:41 +0200 |
commit | 09afe64f29bae5af8ea1749373e8c8b6586b70d1 (patch) | |
tree | ffb0034512375ede89f0d3611db0550ad58e65a9 /tcps_sess.c | |
parent | a58ad72051a73b8a26e792507544ad4b41283ca7 (diff) | |
download | rsyslog-09afe64f29bae5af8ea1749373e8c8b6586b70d1.tar.gz rsyslog-09afe64f29bae5af8ea1749373e8c8b6586b70d1.tar.xz rsyslog-09afe64f29bae5af8ea1749373e8c8b6586b70d1.zip |
added fromhost-ip properties and some bugfixes
- bugfix: TCP input modules did incorrectly set fromhost property
(always blank)
- bugfix: imklog did not set fromhost property
- added "fromhost-ip" property
- added "RSYSLOG_DebugFormat" canned template
- bugfix: hostname and fromhost were swapped when a persisted message
(in queued mode) was read in
Diffstat (limited to 'tcps_sess.c')
-rw-r--r-- | tcps_sess.c | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/tcps_sess.c b/tcps_sess.c index 1a57c8cb..6243d91f 100644 --- a/tcps_sess.c +++ b/tcps_sess.c @@ -90,6 +90,8 @@ CODESTARTobjDestruct(tcps_sess) /* now destruct our own properties */ if(pThis->fromHost != NULL) free(pThis->fromHost); + if(pThis->fromHostIP != NULL) + free(pThis->fromHostIP); ENDobjDestruct(tcps_sess) @@ -102,7 +104,7 @@ ENDobjDebugPrint(tcps_sess) /* set property functions */ /* set the hostname. Note that the caller *hands over* the string. That is, * the caller no longer controls it once SetHost() has received it. Most importantly, - * the caller must not free it. -- gerhards, 2008-04-24 + * the caller must not free it. -- rgerhards, 2008-04-24 */ static rsRetVal SetHost(tcps_sess_t *pThis, uchar *pszHost) @@ -120,6 +122,26 @@ SetHost(tcps_sess_t *pThis, uchar *pszHost) RETiRet; } +/* set the remote host's IP. Note that the caller *hands over* the string. That is, + * the caller no longer controls it once SetHostIP() has received it. Most importantly, + * the caller must not free it. -- rgerhards, 2008-05-16 + */ +static rsRetVal +SetHostIP(tcps_sess_t *pThis, uchar *pszHostIP) +{ + DEFiRet; + + ISOBJ_TYPE_assert(pThis, tcps_sess); + + if(pThis->fromHostIP != NULL) { + free(pThis->fromHostIP); + } + + pThis->fromHostIP = pszHostIP; + + RETiRet; +} + static rsRetVal SetStrm(tcps_sess_t *pThis, netstrm_t *pStrm) { @@ -140,7 +162,7 @@ SetMsgIdx(tcps_sess_t *pThis, int idx) } -/* set out parent, the tcpsrv object */ +/* set our parent, the tcpsrv object */ static rsRetVal SetTcpsrv(tcps_sess_t *pThis, tcpsrv_t *pSrv) { @@ -200,7 +222,7 @@ PrepareClose(tcps_sess_t *pThis) * this case. */ dbgprintf("Extra data at end of stream in legacy syslog/tcp message - processing\n"); - parseAndSubmitMessage(pThis->fromHost, pThis->msg, pThis->iMsg, MSG_PARSE_HOSTNAME, NOFLAG, eFLOWCTL_LIGHT_DELAY); + parseAndSubmitMessage(pThis->fromHost, pThis->fromHostIP, pThis->msg, pThis->iMsg, MSG_PARSE_HOSTNAME, NOFLAG, eFLOWCTL_LIGHT_DELAY); pThis->bAtStrtOfFram = 1; } @@ -222,6 +244,8 @@ Close(tcps_sess_t *pThis) netstrm.Destruct(&pThis->pStrm); free(pThis->fromHost); pThis->fromHost = NULL; /* not really needed, but... */ + free(pThis->fromHostIP); + pThis->fromHostIP = NULL; /* not really needed, but... */ RETiRet; } @@ -280,7 +304,7 @@ processDataRcvd(tcps_sess_t *pThis, char c) if(pThis->iMsg >= MAXLINE) { /* emergency, we now need to flush, no matter if we are at end of message or not... */ dbgprintf("error: message received is larger than MAXLINE, we split it\n"); - parseAndSubmitMessage(pThis->fromHost, pThis->msg, pThis->iMsg, MSG_PARSE_HOSTNAME, NOFLAG, eFLOWCTL_LIGHT_DELAY); + parseAndSubmitMessage(pThis->fromHost, pThis->fromHostIP, pThis->msg, pThis->iMsg, MSG_PARSE_HOSTNAME, NOFLAG, eFLOWCTL_LIGHT_DELAY); pThis->iMsg = 0; /* we might think if it is better to ignore the rest of the * message than to treat it as a new one. Maybe this is a good @@ -290,7 +314,7 @@ processDataRcvd(tcps_sess_t *pThis, char c) } if(c == '\n' && pThis->eFraming == TCP_FRAMING_OCTET_STUFFING) { /* record delemiter? */ - parseAndSubmitMessage(pThis->fromHost, pThis->msg, pThis->iMsg, MSG_PARSE_HOSTNAME, NOFLAG, eFLOWCTL_LIGHT_DELAY); + parseAndSubmitMessage(pThis->fromHost, pThis->fromHostIP, pThis->msg, pThis->iMsg, MSG_PARSE_HOSTNAME, NOFLAG, eFLOWCTL_LIGHT_DELAY); pThis->iMsg = 0; pThis->inputState = eAtStrtFram; } else { @@ -308,7 +332,7 @@ processDataRcvd(tcps_sess_t *pThis, char c) pThis->iOctetsRemain--; if(pThis->iOctetsRemain < 1) { /* we have end of frame! */ - parseAndSubmitMessage(pThis->fromHost, pThis->msg, pThis->iMsg, MSG_PARSE_HOSTNAME, NOFLAG, eFLOWCTL_LIGHT_DELAY); + parseAndSubmitMessage(pThis->fromHost, pThis->fromHostIP, pThis->msg, pThis->iMsg, MSG_PARSE_HOSTNAME, NOFLAG, eFLOWCTL_LIGHT_DELAY); pThis->iMsg = 0; pThis->inputState = eAtStrtFram; } @@ -379,6 +403,7 @@ CODESTARTobjQueryInterface(tcps_sess) pIf->SetUsrP = SetUsrP; pIf->SetTcpsrv = SetTcpsrv; pIf->SetHost = SetHost; + pIf->SetHostIP = SetHostIP; pIf->SetStrm = SetStrm; pIf->SetMsgIdx = SetMsgIdx; finalize_it: |