Receive traps
Corrado Giacomini
c.giacomini____acresearch.com
Fri Apr 6 10:55:19 CEST 2001
Arend Melissant wrote:
> Hello,
>
> Is it possible to receive SNMP traps with Agent++/Snmp++?? If yes, can
> someone give me some pointers where to start.
>
> Arend Melissant
In order to receive traps you should use snmp++; I have implemented a
snmptrapd which make use of snmp::notify_register()
method to register a collection of traps OIDs I am intereste in to
receive and a collection of trap senders which I listen
for incomming traps. Once a traps is received the myCallback method is
invoked to handle it. You can find more inf on the SNMP++
documentation.
'Hope it help,
-Corrado
myCallback(int reason, Snmp *snmp,
Pdu &pdu, SnmpTarget &target, void *data)
{
// handle the received trap pdu here..
}
void
listen(int portNumber)
{
int status;
Snmp snmp(status);
if(status != SNMP_CLASS_SUCCESS) {
//handle error here
}
CNotifyEventQueue::set_listen_port(portNumber);
status = snmp.notify_register(trapOidCollection, trapSenderCollection,
myCallback, NULL);
if (status != SNMP_CLASS_SUCCESS) {
//handle error here
}
while (true)
SNMPProcessEvents();
}
More information about the AGENTPP
mailing list