sending v2 traps

Jochen Katz katz____agentpp.com
Fri Aug 2 23:30:33 CEST 2002


Hi Wayne,

 > 	How do you send snmpv2c traps using agent++, currently all my 
generated traps
 > are version 1, even though I have defined my mib according to SMIv2 ?

you could do the NotificationOriginator to send v2 traps. This class has
a method add_v1_trap_destination to show how to configure it for v1
traps. The code below woll configure it to send out v2 traps.

Kind regards,
    Jochen

boolean NotificationOriginator::add_v2_trap_destination(const
UdpAddress& addr)
{
	OctetStr name("defaultV2Trap");
	OctetStr tag("v2trap");
	OctetStr address;
	IpAddress ip(addr);
	for (int i=0; i<4; i++) {
		address += (unsigned char)ip[i];
	}
	address += (addr.get_port() >> 8);
	address += (addr.get_port() & 0x00FF);

	if (snmpTargetParamsEntry::instance->add_entry(
		name, // row index
		mpV2c,    // mpModel
		SecurityModel_v2, // securityModel
		"public", // secName
		1)) { // secLevel
	    snmpNotifyEntry::instance->add_entry(name, // row index
						 tag,  // tag
						 1);   // type (trap)
	}
	if (snmpTargetAddrEntry::instance->
		add_entry(UdpAddress(addr).get_printable(),
			  // row index
			  Oidx("1.3.6.1.6.1.1"),// UDP domain
			  address,              // target address
			  tag,                  // tag
			  name))                / params entry
		return TRUE;
	return FALSE;
}





More information about the AGENTPP mailing list