summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--action.c3
-rw-r--r--plugins/imfile/imfile.c2
-rw-r--r--plugins/imklog/imklog.c2
-rw-r--r--runtime/msg.c30
-rw-r--r--runtime/msg.h5
-rw-r--r--tools/syslogd.c7
6 files changed, 33 insertions, 16 deletions
diff --git a/action.c b/action.c
index 08cdd6fd..4ab5b81f 100644
--- a/action.c
+++ b/action.c
@@ -674,7 +674,8 @@ actionWriteToAction(action_t *pAction)
*/
datetime.getCurrTime(&(pMsg->tRcvdAt), &(pMsg->ttGenTime));
memcpy(&pMsg->tTIMESTAMP, &pMsg->tRcvdAt, sizeof(struct syslogTime));
- MsgSetMSG(pMsg, (char*)szRepMsg);
+#pragma warn "need fix msg repeationg handling"
+ //MsgSetMSG(pMsg, (char*)szRepMsg);
MsgSetRawMsgWOSize(pMsg, (char*)szRepMsg);
pMsgSave = pAction->f_pMsg; /* save message pointer for later restoration */
diff --git a/plugins/imfile/imfile.c b/plugins/imfile/imfile.c
index 0dabc757..0f5f49dc 100644
--- a/plugins/imfile/imfile.c
+++ b/plugins/imfile/imfile.c
@@ -99,7 +99,7 @@ static rsRetVal enqLine(fileInfo_t *pInfo, cstr_t *cstrLine)
MsgSetFlowControlType(pMsg, eFLOWCTL_FULL_DELAY);
MsgSetInputName(pMsg, UCHAR_CONSTANT("imfile"), sizeof("imfile")-1);
MsgSetRawMsg(pMsg, (char*)rsCStrGetSzStr(cstrLine), cstrLen(cstrLine));
- MsgSetMSG(pMsg, (char*)rsCStrGetSzStr(cstrLine));
+ MsgSetMSGoffs(pMsg, 0); /* we do not have a header... */
MsgSetHOSTNAME(pMsg, glbl.GetLocalHostName());
MsgSetTAG(pMsg, pInfo->pszTag, pInfo->lenTag);
pMsg->iFacility = LOG_FAC(pInfo->iFacility);
diff --git a/plugins/imklog/imklog.c b/plugins/imklog/imklog.c
index bf60ebe5..67fdc8a3 100644
--- a/plugins/imklog/imklog.c
+++ b/plugins/imklog/imklog.c
@@ -97,7 +97,7 @@ enqMsg(uchar *msg, uchar* pszTag, int iFacility, int iSeverity)
MsgSetFlowControlType(pMsg, eFLOWCTL_LIGHT_DELAY);
MsgSetInputName(pMsg, UCHAR_CONSTANT("imklog"), sizeof("imklog")-1);
MsgSetRawMsgWOSize(pMsg, (char*)msg);
- MsgSetMSG(pMsg, (char*)msg);
+ MsgSetMSGoffs(pMsg, 0); /* we do not have a header... */
MsgSetRcvFrom(pMsg, glbl.GetLocalHostName());
MsgSetRcvFromIP(pMsg, (uchar*)"127.0.0.1");
MsgSetHOSTNAME(pMsg, glbl.GetLocalHostName());
diff --git a/runtime/msg.c b/runtime/msg.c
index 67aaf250..507d041e 100644
--- a/runtime/msg.c
+++ b/runtime/msg.c
@@ -438,6 +438,7 @@ static inline rsRetVal msgBaseConstruct(msg_t **ppThis)
pM->iRefCount = 1;
pM->iSeverity = -1;
pM->iFacility = -1;
+ pM->offMSG = -1;
objConstructSetObjInfo(pM);
/* DEV debugging only! dbgprintf("msgConstruct\t0x%x, ref 1\n", (int)pM);*/
@@ -527,7 +528,6 @@ CODESTARTobjDestruct(msg)
free(pThis->pszInputName);
free(pThis->pszRcvFrom);
free(pThis->pszRcvFromIP);
- free(pThis->pszMSG);
free(pThis->pszRcvdAt3164);
free(pThis->pszRcvdAt3339);
free(pThis->pszRcvdAt_SecFrac);
@@ -608,6 +608,7 @@ msg_t* MsgDup(msg_t* pOld)
pNew->msgFlags = pOld->msgFlags;
pNew->iProtocolVersion = pOld->iProtocolVersion;
pNew->ttGenTime = pOld->ttGenTime;
+ pNew->offMSG = pOld->offMSG;
/* enable this, if someone actually uses UxTradMsg, delete after some time has
* passed and nobody complained -- rgerhards, 2009-06-16
pNew->offAfterPRI = pOld->offAfterPRI;
@@ -624,7 +625,6 @@ msg_t* MsgDup(msg_t* pOld)
}
}
tmpCOPYSZ(RawMsg);
- tmpCOPYSZ(MSG);
tmpCOPYSZ(HOSTNAME);
tmpCOPYSZ(RcvFrom);
@@ -668,6 +668,7 @@ static rsRetVal MsgSerialize(msg_t *pThis, strm_t *pStrm)
objSerializeSCALAR(pStrm, iProtocolVersion, SHORT);
objSerializeSCALAR(pStrm, iSeverity, SHORT);
objSerializeSCALAR(pStrm, iFacility, SHORT);
+ objSerializeSCALAR(pStrm, offMSG, SHORT);
objSerializeSCALAR(pStrm, msgFlags, INT);
objSerializeSCALAR(pStrm, ttGenTime, INT);
objSerializeSCALAR(pStrm, tRcvdAt, SYSLOGTIME);
@@ -677,12 +678,10 @@ static rsRetVal MsgSerialize(msg_t *pThis, strm_t *pStrm)
objSerializeSCALAR(pStrm, offsAfterPRI, SHORT);
*/
- objSerializePTR(pStrm, pszRawMsg, PSZ);
- objSerializePTR(pStrm, pszMSG, PSZ);
-
CHKiRet(obj.SerializeProp(pStrm, UCHAR_CONSTANT("pszTAG"), PROPTYPE_PSZ, (void*)
((pThis->iLenTAG < CONF_TAG_BUFSIZE) ? pThis->TAG.szBuf : pThis->TAG.pszTAG)));
+ objSerializePTR(pStrm, pszRawMsg, PSZ);
objSerializePTR(pStrm, pszHOSTNAME, PSZ);
objSerializePTR(pStrm, pszInputName, PSZ);
objSerializePTR(pStrm, pszRcvFrom, PSZ);
@@ -911,10 +910,10 @@ char *getMSG(msg_t *pM)
if(pM == NULL)
return "";
else {
- if(pM->pszMSG == NULL)
+ if(pM->offMSG == -1)
return "";
else
- return (char*)pM->pszMSG;
+ return (char*)(pM->pszRawMsg + pM->offMSG);
}
}
@@ -1689,6 +1688,16 @@ void MsgSetHOSTNAME(msg_t *pMsg, uchar* pszHOSTNAME)
/* rgerhards 2004-11-09: set MSG in msg object
*/
+void MsgSetMSGoffs(msg_t *pMsg, short offs)
+{
+ assert(pMsg != NULL);
+
+ pMsg->iLenMSG = ustrlen(pMsg->pszRawMsg + offs);
+ pMsg->offMSG = offs;
+}
+#if 0
+/* rgerhards 2004-11-09: set MSG in msg object
+ */
void MsgSetMSG(msg_t *pMsg, char* pszMSG)
{
assert(pMsg != NULL);
@@ -1703,6 +1712,7 @@ void MsgSetMSG(msg_t *pMsg, char* pszMSG)
else
dbgprintf("MsgSetMSG could not allocate memory for pszMSG buffer.");
}
+#endif
/* set raw message in message object. Size of message is provided.
* rgerhards, 2009-06-16
@@ -2619,6 +2629,8 @@ rsRetVal MsgSetProperty(msg_t *pThis, var_t *pProp)
pThis->iFacility = pProp->val.num;
} else if(isProp("msgFlags")) {
pThis->msgFlags = pProp->val.num;
+ } else if(isProp("offMSG")) {
+ pThis->offMSG = pProp->val.num;
} else if(isProp("pszRawMsg")) {
MsgSetRawMsg(pThis, (char*) rsCStrGetSzStrNoNULL(pProp->val.pStr), cstrLen(pProp->val.pStr));
/* enable this, if someone actually uses UxTradMsg, delete after some time has
@@ -2626,8 +2638,6 @@ rsRetVal MsgSetProperty(msg_t *pThis, var_t *pProp)
} else if(isProp("offAfterPRI")) {
pThis->offAfterPRI = pProp->val.num;
*/
- } else if(isProp("pszMSG")) {
- MsgSetMSG(pThis, (char*) rsCStrGetSzStrNoNULL(pProp->val.pStr));
} else if(isProp("pszUxTradMsg")) {
/*IGNORE*/; /* this *was* a property, but does no longer exist */
} else if(isProp("pszTAG")) {
@@ -2654,6 +2664,8 @@ rsRetVal MsgSetProperty(msg_t *pThis, var_t *pProp)
memcpy(&pThis->tRcvdAt, &pProp->val.vSyslogTime, sizeof(struct syslogTime));
} else if(isProp("tTIMESTAMP")) {
memcpy(&pThis->tTIMESTAMP, &pProp->val.vSyslogTime, sizeof(struct syslogTime));
+ } else if(isProp("pszMSG")) {
+ dbgprintf("no longer supported property pszMSG silently ignored\n");
}
RETiRet;
diff --git a/runtime/msg.h b/runtime/msg.h
index 48c1090e..4cdb0762 100644
--- a/runtime/msg.h
+++ b/runtime/msg.h
@@ -73,7 +73,8 @@ struct msg {
* need to preserve cryptographic verifiers. */
int iLenRawMsg; /* length of raw message */
short offAfterPRI; /* offset, at which raw message WITHOUT PRI part starts in pszRawMsg */
- uchar *pszMSG; /* the MSG part itself */
+ short offMSG; /* offset at which the MSG part starts in pszRawMsg */
+ //uchar *pszMSG; /* the MSG part itself */
int iLenMSG; /* Length of the MSG part */
int iLenTAG; /* Length of the TAG part */
uchar *pszHOSTNAME; /* HOSTNAME from syslog message */
@@ -156,7 +157,7 @@ rsRetVal MsgSetRcvFromIP(msg_t *pMsg, uchar* pszRcvFromIP);
void MsgAssignHOSTNAME(msg_t *pMsg, char *pBuf);
void MsgSetHOSTNAME(msg_t *pMsg, uchar* pszHOSTNAME);
rsRetVal MsgSetAfterPRIOffs(msg_t *pMsg, short offs);
-void MsgSetMSG(msg_t *pMsg, char* pszMSG);
+void MsgSetMSGoffs(msg_t *pMsg, short offs);
void MsgSetRawMsgWOSize(msg_t *pMsg, char* pszRawMsg);
void MsgSetRawMsg(msg_t *pMsg, char* pszRawMsg, size_t lenMsg);
void moveHOSTNAMEtoTAG(msg_t *pM);
diff --git a/tools/syslogd.c b/tools/syslogd.c
index 8e804d8f..11f4ebd9 100644
--- a/tools/syslogd.c
+++ b/tools/syslogd.c
@@ -1146,7 +1146,8 @@ int parseRFCSyslogMsg(msg_t *pMsg, int flags)
}
/* MSG */
- MsgSetMSG(pMsg, (char*)p2parse);
+ MsgSetMSGoffs(pMsg, p2parse - pMsg->pszRawMsg);
+ //MsgSetMSG(pMsg, (char*)p2parse);
free(pBuf);
ENDfunc
@@ -1339,7 +1340,9 @@ int parseLegacySyslogMsg(msg_t *pMsg, int flags)
}
/* The rest is the actual MSG */
- MsgSetMSG(pMsg, (char*)p2parse);
+dbgprintf("XXX: msg set msg offset %d, str: '%s', prev '%s'\n", p2parse - pMsg->pszRawMsg, pMsg->pszRawMsg + (p2parse - pMsg->pszRawMsg), p2parse);
+// MsgSetMSG(pMsg, (char*)p2parse);
+ MsgSetMSGoffs(pMsg, p2parse - pMsg->pszRawMsg);
ENDfunc
return 0; /* all ok */