74
74
static int iTrapType = SNMP_TRAP_ENTERPRISESPECIFIC;/*Default is SNMP_TRAP_ENTERPRISESPECIFIC */
77
SNMP_TRAP_COLDSTART (0)
78
SNMP_TRAP_WARMSTART (1)
79
SNMP_TRAP_LINKDOWN (2)
81
SNMP_TRAP_AUTHFAIL (4)
82
SNMP_TRAP_EGPNEIGHBORLOSS (5)
77
SNMP_TRAP_COLDSTART (0)
78
SNMP_TRAP_WARMSTART (1)
79
SNMP_TRAP_LINKDOWN (2)
81
SNMP_TRAP_AUTHFAIL (4)
82
SNMP_TRAP_EGPNEIGHBORLOSS (5)
83
83
SNMP_TRAP_ENTERPRISESPECIFIC (6)
86
86
typedef struct _instanceData {
87
87
uchar szTransport[OMSNMP_MAXTRANSPORLENGTH+1]; /* Transport - Can be udp, tcp, udp6, tcp6 and other types supported by NET-SNMP */
88
uchar szTarget[MAXHOSTNAMELEN+1]; /* IP/hostname of Snmp Target*/
89
uchar szTargetAndPort[MAXHOSTNAMELEN+1]; /* IP/hostname + Port,needed format for SNMP LIB */
88
uchar *szTarget; /* IP/hostname of Snmp Target*/
89
uchar *szTargetAndPort; /* IP/hostname + Port,needed format for SNMP LIB */
90
90
uchar szCommunity[OMSNMP_MAXCOMMUNITYLENGHT+1]; /* Snmp Community */
91
91
uchar szEnterpriseOID[OMSNMP_MAXOIDLENGHT+1]; /* Snmp Enterprise OID - default is (1.3.6.1.4.1.3.1.1 = enterprises.cmu.1.1) */
92
92
uchar szSnmpTrapOID[OMSNMP_MAXOIDLENGHT+1]; /* Snmp Trap OID - default is (1.3.6.1.4.1.19406.1.2.1 = ADISCON-MONITORWARE-MIB::syslogtrap) */
93
uchar szSyslogMessageOID[OMSNMP_MAXOIDLENGHT+1]; /* Snmp OID used for the Syslog Message - default is 1.3.6.1.4.1.19406.1.1.2.1 - ADISCON-MONITORWARE-MIB::syslogMsg
94
* You will need the ADISCON-MONITORWARE-MIB and ADISCON-MIB mibs installed on the receiver side in order to decode this mib.
95
* Downloads of these mib files can be found here:
96
* http://www.adiscon.org/download/ADISCON-MONITORWARE-MIB.txt
97
* http://www.adiscon.org/download/ADISCON-MIB.txt
99
int iPort; /* Target Port */
100
int iSNMPVersion; /* SNMP Version to use */
101
int iTrapType; /* Snmp TrapType or GenericType */
102
int iSpecificType; /* Snmp Specific Type */
93
uchar szSyslogMessageOID[OMSNMP_MAXOIDLENGHT+1]; /* Snmp OID used for the Syslog Message:
94
* default is 1.3.6.1.4.1.19406.1.1.2.1 - ADISCON-MONITORWARE-MIB::syslogMsg
95
* You will need the ADISCON-MONITORWARE-MIB and ADISCON-MIB mibs installed on the receiver
96
* side in order to decode this mib.
97
* Downloads of these mib files can be found here:
98
* http://www.adiscon.org/download/ADISCON-MONITORWARE-MIB.txt
99
* http://www.adiscon.org/download/ADISCON-MIB.txt
101
int iPort; /* Target Port */
102
int iSNMPVersion; /* SNMP Version to use */
103
int iTrapType; /* Snmp TrapType or GenericType */
104
int iSpecificType; /* Snmp Specific Type */
104
106
netsnmp_session *snmpsession; /* Holds to SNMP Session, NULL if not initialized */
327
328
CODESTARTfreeInstance
328
329
/* free snmp Session here */
329
330
omsnmp_exitSession(pData);
332
if(pData->szTarget != NULL)
333
free(pData->szTarget);
334
if(pData->szTargetAndPort != NULL)
335
free(pData->szTargetAndPort);
333
340
BEGINparseSelectorAct
341
uchar szTargetAndPort[MAXHOSTNAMELEN+128]; /* work buffer for specifying a full target and port string */
334
342
CODESTARTparseSelectorAct
335
343
CODE_STD_STRING_REQUESTparseSelectorAct(1)
336
344
if(!strncmp((char*) p, ":omsnmp:", sizeof(":omsnmp:") - 1)) {
412
420
pData->iTrapType = iTrapType;
414
422
/* Create string for session peername! */
415
snprintf( (char*) pData->szTargetAndPort, sizeof(pData->szTargetAndPort) / sizeof(char), "%s:%s:%d", pData->szTransport, pData->szTarget, pData->iPort );
423
snprintf((char*)szTargetAndPort, sizeof(szTargetAndPort), "%s:%s:%d", pData->szTransport, pData->szTarget, pData->iPort);
424
CHKmalloc(pData->szTargetAndPort = (uchar*)strdup((char*)szTargetAndPort));
417
426
/* Print Debug info */
418
427
dbgprintf("SNMPTransport: %s\n", pData->szTransport);