summaryrefslogtreecommitdiff
path: root/plugins/imudp/imudp.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/imudp/imudp.c')
-rw-r--r--plugins/imudp/imudp.c62
1 files changed, 59 insertions, 3 deletions
diff --git a/plugins/imudp/imudp.c b/plugins/imudp/imudp.c
index 61dfc58..f087196 100644
--- a/plugins/imudp/imudp.c
+++ b/plugins/imudp/imudp.c
@@ -4,7 +4,7 @@
* NOTE: read comments in module-template.h to understand how this file
* works!
*
- * Copyright 2007-2012 Rainer Gerhards and Adiscon GmbH.
+ * Copyright 2007-2014 Rainer Gerhards and Adiscon GmbH.
*
* This file is part of rsyslog.
*
@@ -172,6 +172,8 @@ static struct cnfparamdescr inppdescr[] = {
{ "defaulttz", eCmdHdlrString, 0 },
{ "inputname", eCmdHdlrGetWord, 0 },
{ "inputname.appendport", eCmdHdlrBinary, 0 },
+ { "name", eCmdHdlrGetWord, 0 },
+ { "name.appendport", eCmdHdlrBinary, 0 },
{ "address", eCmdHdlrString, 0 },
{ "ratelimit.interval", eCmdHdlrInt, 0 },
{ "ratelimit.burst", eCmdHdlrInt, 0 },
@@ -287,7 +289,7 @@ addListner(instanceConf_t *inst)
/* we now need to add the new sockets to the existing set */
/* ready to copy */
for(iSrc = 1 ; iSrc <= newSocks[0] ; ++iSrc) {
- CHKmalloc(newlcnfinfo = (struct lstn_s*) MALLOC(sizeof(struct lstn_s)));
+ CHKmalloc(newlcnfinfo = (struct lstn_s*) calloc(1, sizeof(struct lstn_s)));
newlcnfinfo->next = NULL;
newlcnfinfo->sock = newSocks[iSrc];
newlcnfinfo->pRuleset = inst->pBindRuleset;
@@ -334,6 +336,23 @@ addListner(instanceConf_t *inst)
}
finalize_it:
+ if(iRet != RS_RET_OK) {
+ if(newlcnfinfo != NULL) {
+ if(newlcnfinfo->ratelimiter != NULL)
+ ratelimitDestruct(newlcnfinfo->ratelimiter);
+ if(newlcnfinfo->pInputName != NULL)
+ prop.Destruct(&newlcnfinfo->pInputName);
+ if(newlcnfinfo->stats != NULL)
+ statsobj.Destruct(&newlcnfinfo->stats);
+ free(newlcnfinfo);
+ }
+ /* close the rest of the open sockets as there's
+ nowhere to put them */
+ for(; iSrc <= newSocks[0]; iSrc++) {
+ close(newSocks[iSrc]);
+ }
+ }
+
free(newSocks);
RETiRet;
}
@@ -358,7 +377,7 @@ processPacket(thrdInfo_t *pThrd, struct lstn_s *lstn, struct sockaddr_storage *f
struct sockaddr_storage *frominet, socklen_t socklen, multi_submit_t *multiSub)
{
DEFiRet;
- msg_t *pMsg;
+ msg_t *pMsg = NULL;
assert(pThrd != NULL);
@@ -418,6 +437,12 @@ processPacket(thrdInfo_t *pThrd, struct lstn_s *lstn, struct sockaddr_storage *f
}
finalize_it:
+ if(iRet != RS_RET_OK) {
+ if(pMsg != NULL) {
+ msgDestruct(&pMsg);
+ }
+ }
+
RETiRet;
}
@@ -841,6 +866,7 @@ createListner(es_str_t *port, struct cnfparamvals *pvals)
{
instanceConf_t *inst;
int i;
+ int bAppendPortUsed = 0;
DEFiRet;
CHKiRet(createInstance(&inst));
@@ -850,9 +876,39 @@ createListner(es_str_t *port, struct cnfparamvals *pvals)
continue;
if(!strcmp(inppblk.descr[i].name, "port")) {
continue; /* array, handled by caller */
+ } else if(!strcmp(inppblk.descr[i].name, "name")) {
+ if(inst->inputname != NULL) {
+ errmsg.LogError(0, RS_RET_INVALID_PARAMS, "imudp: name and inputname "
+ "paramter specified - only one can be used");
+ ABORT_FINALIZE(RS_RET_INVALID_PARAMS);
+ }
+ inst->inputname = (uchar*)es_str2cstr(pvals[i].val.d.estr, NULL);
+ } else if(!strcmp(inppblk.descr[i].name, "name.appendport")) {
+ if(bAppendPortUsed) {
+ errmsg.LogError(0, RS_RET_INVALID_PARAMS, "imudp: name.appendport and "
+ "inputname.appendport paramter specified - only one can be used");
+ ABORT_FINALIZE(RS_RET_INVALID_PARAMS);
+ }
+ inst->bAppendPortToInpname = (int) pvals[i].val.d.n;
+ bAppendPortUsed = 1;
} else if(!strcmp(inppblk.descr[i].name, "inputname")) {
+ errmsg.LogError(0, RS_RET_DEPRECATED , "imudp: deprecated parameter inputname "
+ "used. Suggest to use name instead");
+ if(inst->inputname != NULL) {
+ errmsg.LogError(0, RS_RET_INVALID_PARAMS, "imudp: name and inputname "
+ "parameter specified - only one can be used");
+ ABORT_FINALIZE(RS_RET_INVALID_PARAMS);
+ }
inst->inputname = (uchar*)es_str2cstr(pvals[i].val.d.estr, NULL);
} else if(!strcmp(inppblk.descr[i].name, "inputname.appendport")) {
+ errmsg.LogError(0, RS_RET_DEPRECATED , "imudp: deprecated parameter inputname.appendport "
+ "used. Suggest to use name.appendport instead");
+ if(bAppendPortUsed) {
+ errmsg.LogError(0, RS_RET_INVALID_PARAMS, "imudp: name.appendport and "
+ "inputname.appendport parameter specified - only one can be used");
+ ABORT_FINALIZE(RS_RET_INVALID_PARAMS);
+ }
+ bAppendPortUsed = 1;
inst->bAppendPortToInpname = (int) pvals[i].val.d.n;
} else if(!strcmp(inppblk.descr[i].name, "defaulttz")) {
inst->dfltTZ = (uchar*)es_str2cstr(pvals[i].val.d.estr, NULL);