From 7ddc2511193930c1f9aa755904cef6f3b860a670 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Mon, 28 Jan 2008 16:38:05 +0000 Subject: provided sample for integer config variable --- plugins/omsnmp/omsnmp.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'plugins') diff --git a/plugins/omsnmp/omsnmp.c b/plugins/omsnmp/omsnmp.c index 0328d851..f8711ac5 100644 --- a/plugins/omsnmp/omsnmp.c +++ b/plugins/omsnmp/omsnmp.c @@ -58,9 +58,12 @@ MODULE_TYPE_OUTPUT DEF_OMOD_STATIC_DATA static uchar* pszTarget = NULL; +/* note using an unsigned for a port number is not a good idea from an IPv6 point of view */ +static int iPort = 0; typedef struct _instanceData { uchar szTarget[MAXHOSTNAMELEN+1]; /* IP or hostname of Snmp Target*/ + int iPort; } instanceData; @@ -130,6 +133,7 @@ CODE_STD_STRING_REQUESTparseSelectorAct(0) /* Copy Target */ strncpy( (char*) pData->szTarget, (char*) pszTarget, sizeof( pData->szTarget -1 ) ); } + pThis->iPort = iPort; CODE_STD_FINALIZERparseSelectorAct ENDparseSelectorAct @@ -146,6 +150,7 @@ static rsRetVal resetConfigVariables(uchar __attribute__((unused)) *pp, void __a if (pszTarget != NULL) free(pszTarget); pszTarget = NULL; + iPort = 0; return RS_RET_OK; } @@ -169,6 +174,7 @@ CODESTARTmodInit *ipIFVersProvided = 1; /* so far, we only support the initial definition */ CODEmodInit_QueryRegCFSLineHdlr CHKiRet(omsdRegCFSLineHdlr((uchar *)"actionsnmptarget", 0, eCmdHdlrGetWord, NULL, &pszTarget, STD_LOADABLE_MODULE_ID)); + CHKiRet(regCfSysLineHdlr((uchar *)"actionsnmptargetport", 0, eCmdHdlrInt, NULL, &iPort, NULL)); CHKiRet(omsdRegCFSLineHdlr((uchar *)"resetconfigvariables", 1, eCmdHdlrCustomHandler, resetConfigVariables, NULL, STD_LOADABLE_MODULE_ID)); ENDmodInit /* -- cgit