diff options
Diffstat (limited to 'plugins/mmsnmptrapd/mmsnmptrapd.c')
-rw-r--r-- | plugins/mmsnmptrapd/mmsnmptrapd.c | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/plugins/mmsnmptrapd/mmsnmptrapd.c b/plugins/mmsnmptrapd/mmsnmptrapd.c index b79a311..de63cce 100644 --- a/plugins/mmsnmptrapd/mmsnmptrapd.c +++ b/plugins/mmsnmptrapd/mmsnmptrapd.c @@ -68,11 +68,15 @@ struct severMap_s { typedef struct _instanceData { uchar *pszTagName; - uchar *pszTagID; /* chaced: name plus trailing shlash (for compares) */ - int lenTagID; /* cached length of tag ID, for performance reasons */ + uchar *pszTagID; /* cached: name plus trailing shlash (for compares) */ + int lenTagID; /* cached: length of tag ID, for performance reasons */ struct severMap_s *severMap; } instanceData; +typedef struct wrkrInstanceData { + instanceData *pData; +} wrkrInstanceData_t; + typedef struct configSettings_s { uchar *pszTagName; /**< name of tag start value that indicates snmptrapd initiated message */ uchar *pszSeverityMapping; /**< severitystring to numerical code mapping for snmptrapd string */ @@ -92,6 +96,10 @@ CODESTARTcreateInstance ENDcreateInstance +BEGINcreateWrkrInstance +CODESTARTcreateWrkrInstance +ENDcreateWrkrInstance + BEGINisCompatibleWithFeature CODESTARTisCompatibleWithFeature ENDisCompatibleWithFeature @@ -110,6 +118,10 @@ CODESTARTfreeInstance free(pData->pszTagID); ENDfreeInstance +BEGINfreeWrkrInstance +CODESTARTfreeWrkrInstance +ENDfreeWrkrInstance + BEGINdbgPrintInstInfo CODESTARTdbgPrintInstInfo @@ -190,7 +202,6 @@ getTagComponent(uchar *tag, uchar *dst, int *lenDst) ++i; } dst[i] = '\0'; -dbgprintf("XXXX: getTagComponent dst on output: '%s', len %d\n", dst, i); *lenDst = i; done: return i; @@ -225,9 +236,10 @@ BEGINdoAction uchar *pszTag; uchar pszSever[512]; uchar pszHost[512]; + instanceData *pData; CODESTARTdoAction + pData = pWrkrData->pData; pMsg = (msg_t*) ppString[0]; - dbgprintf("XXXX: mmsnmptrapd called with pMsg %p\n", pMsg); getTAG(pMsg, &pszTag, &lenTAG); if(strncmp((char*)pszTag, (char*)pData->pszTagID, pData->lenTagID)) { DBGPRINTF("tag '%s' not matching, mmsnmptrapd ignoring this message\n", @@ -236,18 +248,16 @@ CODESTARTdoAction } lenSever = sizeof(pszSever); -dbgprintf("XXXX: pszTag: '%s', lenID %d\n", pszTag, pData->lenTagID); getTagComponent(pszTag+pData->lenTagID-1, pszSever, &lenSever); lenHost = sizeof(pszHost); getTagComponent(pszTag+pData->lenTagID+lenSever, pszHost, &lenHost); - dbgprintf("XXXX: mmsnmptrapd sever '%s'(%d), host '%s'(%d)\n", pszSever, lenSever, pszHost,lenHost); + DBGPRINTF("mmsnmptrapd: sever '%s'(%d), host '%s'(%d)\n", pszSever, lenSever, pszHost,lenHost); if(pszHost[lenHost-1] == ':') { pszHost[lenHost-1] = '\0'; --lenHost; } sevCode = lookupSeverityCode(pData, pszSever); -dbgprintf("XXXX: severity for message is %d\n", sevCode); /* now apply new settings */ MsgSetTAG(pMsg, pData->pszTagName, pData->lenTagID); MsgSetHOSTNAME(pMsg, pszHost, lenHost); @@ -267,7 +277,7 @@ buildSeverityMapping(instanceData *pData) uchar pszSevCode[512]; int sevCode; uchar *mapping; - struct severMap_s *node; + struct severMap_s *node = NULL; DEFiRet; mapping = cs.pszSeverityMapping; @@ -300,6 +310,10 @@ buildSeverityMapping(instanceData *pData) } finalize_it: + if(iRet != RS_RET_OK) { + if(node != NULL) + free(node); + } RETiRet; } @@ -362,6 +376,7 @@ ENDmodExit BEGINqueryEtryPt CODESTARTqueryEtryPt CODEqueryEtryPt_STD_OMOD_QUERIES +CODEqueryEtryPt_STD_OMOD8_QUERIES CODEqueryEtryPt_STD_CONF2_CNFNAME_QUERIES ENDqueryEtryPt |