summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/imtcp/imtcp.c9
-rw-r--r--runtime/msg.c10
-rw-r--r--runtime/msg.h4
-rw-r--r--tcps_sess.c2
-rw-r--r--tcpsrv.c12
-rw-r--r--tcpsrv.h4
-rw-r--r--tools/pmrfc3164.c1
7 files changed, 40 insertions, 2 deletions
diff --git a/plugins/imtcp/imtcp.c b/plugins/imtcp/imtcp.c
index d2a0e565..430c9745 100644
--- a/plugins/imtcp/imtcp.c
+++ b/plugins/imtcp/imtcp.c
@@ -4,7 +4,7 @@
* File begun on 2007-12-21 by RGerhards (extracted from syslogd.c,
* which at the time of the rsyslog fork was BSD-licensed)
*
- * Copyright 2007-2012 Adiscon GmbH.
+ * Copyright 2007-2013 Adiscon GmbH.
*
* This file is part of rsyslog.
*
@@ -105,6 +105,7 @@ struct instanceConf_s {
uchar *pszBindRuleset; /* name of ruleset to bind to */
ruleset_t *pBindRuleset; /* ruleset to bind listener to (use system default if unspecified) */
uchar *pszInputName; /* value for inputname property, NULL is OK and handled by core engine */
+ uchar *dfltTZ;
int ratelimitInterval;
int ratelimitBurst;
int bSuppOctetFram;
@@ -157,6 +158,7 @@ static struct cnfparamblk modpblk =
static struct cnfparamdescr inppdescr[] = {
{ "port", eCmdHdlrString, CNFPARAM_REQUIRED }, /* legacy: InputTCPServerRun */
{ "name", eCmdHdlrString, 0 },
+ { "defaulttz", eCmdHdlrString, 0 },
{ "ruleset", eCmdHdlrString, 0 },
{ "supportOctetCountedFraming", eCmdHdlrBinary, 0 },
{ "ratelimit.interval", eCmdHdlrInt, 0 },
@@ -255,6 +257,7 @@ createInstance(instanceConf_t **pinst)
inst->next = NULL;
inst->pszBindRuleset = NULL;
inst->pszInputName = NULL;
+ inst->dfltTZ = NULL;
inst->bSuppOctetFram = 1;
inst->ratelimitInterval = 0;
inst->ratelimitBurst = 10000;
@@ -341,6 +344,7 @@ addListner(modConfData_t *modConf, instanceConf_t *inst)
CHKiRet(tcpsrv.SetRuleset(pOurTcpsrv, inst->pBindRuleset));
CHKiRet(tcpsrv.SetInputName(pOurTcpsrv, inst->pszInputName == NULL ?
UCHAR_CONSTANT("imtcp") : inst->pszInputName));
+ CHKiRet(tcpsrv.SetDfltTZ(pOurTcpsrv, (inst->dfltTZ == NULL) ? (uchar*)"" : inst->dfltTZ));
CHKiRet(tcpsrv.SetLinuxLikeRatelimiters(pOurTcpsrv, inst->ratelimitInterval, inst->ratelimitBurst));
tcpsrv.configureTCPListen(pOurTcpsrv, inst->pszBindPort, inst->bSuppOctetFram);
@@ -380,6 +384,8 @@ CODESTARTnewInpInst
inst->pszBindPort = (uchar*)es_str2cstr(pvals[i].val.d.estr, NULL);
} else if(!strcmp(inppblk.descr[i].name, "name")) {
inst->pszInputName = (uchar*)es_str2cstr(pvals[i].val.d.estr, NULL);
+ } else if(!strcmp(inppblk.descr[i].name, "defaulttz")) {
+ inst->dfltTZ = (uchar*)es_str2cstr(pvals[i].val.d.estr, NULL);
} else if(!strcmp(inppblk.descr[i].name, "ruleset")) {
inst->pszBindRuleset = (uchar*)es_str2cstr(pvals[i].val.d.estr, NULL);
} else if(!strcmp(inppblk.descr[i].name, "supportOctetCountedFraming")) {
@@ -571,6 +577,7 @@ CODESTARTfreeCnf
for(inst = pModConf->root ; inst != NULL ; ) {
free(inst->pszBindPort);
free(inst->pszInputName);
+ free(inst->dfltTZ);
del = inst;
inst = inst->next;
free(del);
diff --git a/runtime/msg.c b/runtime/msg.c
index 67d957d1..426c80df 100644
--- a/runtime/msg.c
+++ b/runtime/msg.c
@@ -708,6 +708,7 @@ static inline rsRetVal msgBaseConstruct(msg_t **ppThis)
pM->rcvFrom.pRcvFrom = NULL;
pM->pRuleset = NULL;
pM->json = NULL;
+ pM->dfltTZ[0] = '\0';
memset(&pM->tRcvdAt, 0, sizeof(pM->tRcvdAt));
memset(&pM->tTIMESTAMP, 0, sizeof(pM->tTIMESTAMP));
pM->TAG.pszTAG = NULL;
@@ -2215,6 +2216,15 @@ void MsgSetInputName(msg_t *pThis, prop_t *inputName)
pThis->pInputName = inputName;
}
+/* Set default TZ. Note that at most 7 chars are set, as we would
+ * otherwise overrun our buffer!
+ */
+void MsgSetDfltTZ(msg_t *pThis, char *tz)
+{
+ strncpy(pThis->dfltTZ, tz, 7);
+ pThis->dfltTZ[7] = '\0'; /* ensure 0-Term in case of overflow! */
+}
+
/* Set the pfrominet socket store, so that we can obtain the peer at some
* later time. Note that we do not check if pRcvFrom is already set, so this
diff --git a/runtime/msg.h b/runtime/msg.h
index 6faf066a..5a54c116 100644
--- a/runtime/msg.h
+++ b/runtime/msg.h
@@ -125,7 +125,8 @@ struct msg {
char pszRcvdAt_SecFrac[7]; /* same as above. Both are fractional seconds for their respective timestamp */
char pszTIMESTAMP_Unix[12]; /* almost as small as a pointer! */
char pszRcvdAt_Unix[12];
- uchar *pszUUID; /* The message's UUID */
+ char dfltTZ[8]; /* 7 chars max, less overhead than ptr! */
+ uchar *pszUUID; /* The message's UUID */
};
@@ -155,6 +156,7 @@ msg_t* MsgDup(msg_t* pOld);
msg_t *MsgAddRef(msg_t *pM);
void setProtocolVersion(msg_t *pM, int iNewVersion);
void MsgSetInputName(msg_t *pMsg, prop_t*);
+void MsgSetDfltTZ(msg_t *pThis, char *tz);
rsRetVal MsgSetAPPNAME(msg_t *pMsg, char* pszAPPNAME);
rsRetVal MsgSetPROCID(msg_t *pMsg, char* pszPROCID);
rsRetVal MsgSetMSGID(msg_t *pMsg, char* pszMSGID);
diff --git a/tcps_sess.c b/tcps_sess.c
index 5821e443..96bb6a4b 100644
--- a/tcps_sess.c
+++ b/tcps_sess.c
@@ -253,6 +253,8 @@ defaultDoSubmitMessage(tcps_sess_t *pThis, struct syslogTime *stTime, time_t ttG
CHKiRet(msgConstructWithTime(&pMsg, stTime, ttGenTime));
MsgSetRawMsg(pMsg, (char*)pThis->pMsg, pThis->iMsg);
MsgSetInputName(pMsg, pThis->pLstnInfo->pInputName);
+ if(pThis->pLstnInfo->dfltTZ != NULL)
+ MsgSetDfltTZ(pMsg, (char*) pThis->pLstnInfo->dfltTZ);
MsgSetFlowControlType(pMsg, pThis->pSrv->bUseFlowControl
? eFLOWCTL_LIGHT_DELAY : eFLOWCTL_NO_DELAY);
pMsg->msgFlags = NEEDS_PARSING | PARSE_HOSTNAME;
diff --git a/tcpsrv.c b/tcpsrv.c
index c1033ef9..a0a35d13 100644
--- a/tcpsrv.c
+++ b/tcpsrv.c
@@ -134,6 +134,7 @@ addNewLstnPort(tcpsrv_t *pThis, uchar *pszPort, int bSuppOctetFram)
/* create entry */
CHKmalloc(pEntry = MALLOC(sizeof(tcpLstnPortList_t)));
CHKmalloc(pEntry->pszPort = ustrdup(pszPort));
+ strcpy((char*)pEntry->dfltTZ, (char*)pThis->dfltTZ);
pEntry->pSrv = pThis;
pEntry->pRuleset = pThis->pRuleset;
pEntry->bSuppOctetFram = bSuppOctetFram;
@@ -916,6 +917,7 @@ BEGINobjConstruct(tcpsrv) /* be sure to specify the object type also in END macr
pThis->addtlFrameDelim = TCPSRV_NO_ADDTL_DELIMITER;
pThis->bDisableLFDelim = 0;
pThis->OnMsgReceive = NULL;
+ pThis->dfltTZ[0] = '\0';
pThis->ratelimitInterval = 0;
pThis->ratelimitBurst = 10000;
pThis->bUseFlowControl = 1;
@@ -1107,6 +1109,15 @@ SetAddtlFrameDelim(tcpsrv_t *pThis, int iDelim)
}
+static rsRetVal
+SetDfltTZ(tcpsrv_t *pThis, uchar *tz)
+{
+ DEFiRet;
+ ISOBJ_TYPE_assert(pThis, tcpsrv);
+ strcpy((char*)pThis->dfltTZ, (char*)tz);
+ RETiRet;
+}
+
/* Set the input name to use -- rgerhards, 2008-12-10 */
static rsRetVal
SetInputName(tcpsrv_t *pThis, uchar *name)
@@ -1266,6 +1277,7 @@ CODESTARTobjQueryInterface(tcpsrv)
pIf->SetKeepAlive = SetKeepAlive;
pIf->SetUsrP = SetUsrP;
pIf->SetInputName = SetInputName;
+ pIf->SetDfltTZ = SetDfltTZ;
pIf->SetAddtlFrameDelim = SetAddtlFrameDelim;
pIf->SetbDisableLFDelim = SetbDisableLFDelim;
pIf->SetSessMax = SetSessMax;
diff --git a/tcpsrv.h b/tcpsrv.h
index c9d491db..7fe517a4 100644
--- a/tcpsrv.h
+++ b/tcpsrv.h
@@ -43,6 +43,7 @@ struct tcpLstnPortList_s {
statsobj_t *stats; /**< associated stats object */
sbool bSuppOctetFram; /**< do we support octect-counted framing? (if no->legay only!)*/
ratelimit_t *ratelimiter;
+ uchar dfltTZ[8]; /**< default TZ if none in timestamp; '\0' =No Default */
STATSCOUNTER_DEF(ctrSubmit, mutCtrSubmit)
tcpLstnPortList_t *pNext; /**< next port or NULL */
};
@@ -67,6 +68,7 @@ struct tcpsrv_s {
tcpLstnPortList_t **ppLstnPort; /**< pointer to relevant listen port description */
int iLstnMax; /**< max number of listeners supported */
int iSessMax; /**< max number of sessions supported */
+ uchar dfltTZ[8]; /**< default TZ if none in timestamp; '\0' =No Default */
tcpLstnPortList_t *pLstnPorts; /**< head pointer for listen ports */
int addtlFrameDelim; /**< additional frame delimiter for plain TCP syslog framing (e.g. to handle NetScreen) */
@@ -147,6 +149,8 @@ BEGINinterface(tcpsrv) /* name must also be changed in ENDinterface macro! */
rsRetVal (*SetKeepAlive)(tcpsrv_t*, int);
/* added v13 -- rgerhards, 2012-10-15 */
rsRetVal (*SetLinuxLikeRatelimiters)(tcpsrv_t *pThis, int interval, int burst);
+ /* added v14 -- rgerhards, 2013-07-28 */
+ rsRetVal (*SetDfltTZ)(tcpsrv_t *pThis, uchar *dfltTZ);
ENDinterface(tcpsrv)
#define tcpsrvCURR_IF_VERSION 13 /* increment whenever you change the interface structure! */
/* change for v4:
diff --git a/tools/pmrfc3164.c b/tools/pmrfc3164.c
index 5dfa74f0..23c8766c 100644
--- a/tools/pmrfc3164.c
+++ b/tools/pmrfc3164.c
@@ -95,6 +95,7 @@ CODESTARTparse
if(datetime.ParseTIMESTAMP3339(&(pMsg->tTIMESTAMP), &p2parse, &lenMsg) == RS_RET_OK) {
/* we are done - parse pointer is moved by ParseTIMESTAMP3339 */;
} else if(datetime.ParseTIMESTAMP3164(&(pMsg->tTIMESTAMP), &p2parse, &lenMsg) == RS_RET_OK) {
+dbgprintf("DDDD: timestamp parsed, dfltTZ '%s'\n", pMsg->dfltTZ);
/* we are done - parse pointer is moved by ParseTIMESTAMP3164 */;
} else if(*p2parse == ' ' && lenMsg > 1) { /* try to see if it is slighly malformed - HP procurve seems to do that sometimes */
++p2parse; /* move over space */