[AGENT++] SNMPv3 Trap not exiting

I’m writing an agent.
It currently works fine for v3 Get/Set (AuthNoPriv)
But traps, sent to the same User arn’t even sent on the network (Wiresherk does not show them).

NOTE: with v2c traps are fired fine

//... Trap sending code
Vbx* vbs = 0;
coldStartOid coldOid;
NotificationOriginator no;
 OctetStr eid(SnmpEngineID::create_engine_id(161));
no.set_local_engine_id(eid);
UdpAddress dest("127.0.0.1/162");

OctetStr name("defaultV3Trap");
OctetStr tag("v3trap");
OctetStr entOid("");
OctetStr secName("MySnmpRegisteredUser");
OctetStr ctx("MyContext");
r = no.add_v3_trap_destination(dest, name, tag, secName);
//generate a basic cold start trap
no.generate(vbs, 0, coldOid, entOid, ctx);

Hi,

does the call to add_v3_trap_destination() return TRUE?

In general, you should take the function as an example and set up the tables in your own code.

Kind regards,
Jochen

Please check the VACM authorisation on the trap OIDs too. This is often missed out.
You will find the reason in the DEBUG log if you activate it.

Also I can confirm that the add_v3_trap_destination() returns true.

How do I check the Auths on specific oid’s?

I can say the View I use is included for oids beginning from 1.3

Logs:

20220928.08:55:06: 2224: (1)DEBUG  : Initialized request_id to 1041.
20220928.08:55:06: 2224: (1)EVENT  : main: SNMP listen port: (161)
20220928.08:55:06: 2224: (3)DEBUG  : getBootCounter: found entry (file) (engine id) (boot counter): (./tmp/snmpv3_boot_counter), (  80 00 13 70 05 42 41 43 43 48 49 4E 42 00 A1       ...p.BACCHINB..), (205)
20220928.08:55:06: 2224: (5)INFO   : saveBootCounter: Saved counter (file) (engine id) (boot): (./tmp/snmpv3_boot_counter), (  80 00 13 70 05 42 41 43 43 48 49 4E 42 00 A1       ...p.BACCHINB..), (206)
20220928.08:55:06: 2224: (6)INFO   : AuthPriv: Added auth protocol (id): (3)
20220928.08:55:06: 2224: (6)INFO   : AuthPriv: Added auth protocol (id): (2)
20220928.08:55:06: 2224: (6)INFO   : AuthPriv: Added priv protocol (id): (2)
20220928.08:55:06: 2224: (3)INFO   : AuthPriv: Added default Auth and Priv protocols.
20220928.08:55:06: 2224: (3)DEBUG  : MibContext: adding MIB object (context)(oid): (), (1.3.6.1.2.1.1)
20220928.08:55:06: 2224: (3)DEBUG  : MibContext: adding MIB object (context)(oid): (), (1.3.6.1.2.1.11)
20220928.08:55:06: 2224: (3)DEBUG  : MibContext: adding MIB object (context)(oid): (), (1.3.6.1.6.3.1.1.6.1.0)
20220928.08:55:06: 2224: (3)DEBUG  : MibContext: adding MIB object (context)(oid): (), (1.3.6.1.6.3.12)
20220928.08:55:06: 2224: (3)DEBUG  : MibContext: adding MIB object (context)(oid): (), (1.3.6.1.6.3.13.1)
20220928.08:55:06: 2224: (7)INFO   : USMUserTable: Adding user (user name) (engine id) (auth) (priv): (UTENTE), (  80 00 13 70 05 42 41 43 43 48 49 4E 42 00 A1       ...p.BACCHINB..), (2), (1)
20220928.08:55:06: 2224: (1)DEBUG  : UsmUserTable: add row with index: (15.128.0.19.112.5.66.65.67.67.72.73.78.66.0.161.6.85.84.69.78.84.69)
20220928.08:55:06: 2224: (1)DEBUG  : USM::get_user: user (UTENTE) engine_id (  80 00 13 70 05 42 41 43 43 48 49 4E 42 00 A1       ...p.BACCHINB..)
20220928.08:55:06: 2224: (7)INFO   : USMUserTable: Adding user (user name) (engine id) (auth) (priv): (UTENTE), (  80 00 13 70 05 42 41 43 43 48 49 4E 42 00 A1       ...p.BACCHINB..), (2), (1)
20220928.08:55:06: 2224: (1)DEBUG  : Informing agent++ about newly created user
20220928.08:55:06: 2224: (3)DEBUG  : MibContext: adding MIB object (context)(oid): (), (1.3.6.1.6.3.15.1.1)
20220928.08:55:06: 2224: (3)DEBUG  : MibContext: adding MIB object (context)(oid): (), (1.3.6.1.6.3.15)
20220928.08:55:06: 2224: (3)DEBUG  : MibContext: adding MIB object (context)(oid): (), (1.3.6.1.6.3.10.2.1)
20220928.08:55:06: 2224: (3)DEBUG  : MibContext: adding MIB object (context)(oid): (), (1.3.6.1.6.3.11.2.1)
20220928.08:55:06: 2224: (3)DEBUG  : MibContext: adding MIB object (context)(oid): (), (1.3.6.1.4.1.7433)
20220928.08:55:06: 2224: (3)DEBUG  : MibContext: adding MIB object (context)(oid): (other), (1.3.6.1.4.1.7433)
20220928.08:55:06: 2224: (1)DEBUG  : TaskManager: thread started
20220928.08:55:06: 2224: (1)DEBUG  : Thread: started (tid): (22920)
20220928.08:55:06: 2224: (1)DEBUG  : TaskManager: thread started
20220928.08:55:06: 2224: (1)DEBUG  : Thread: started (tid): (24800)
20220928.08:55:06: 2224: (1)DEBUG  : TaskManager: thread started
20220928.08:55:06: 2224: (1)DEBUG  : Thread: started (tid): (23672)
20220928.08:55:06: 2224: (1)DEBUG  : TaskManager: thread started
20220928.08:55:06: 2224: (1)DEBUG  : Thread: started (tid): (20588)
20220928.08:55:06: 2224: (3)DEBUG  : MibContext: adding MIB object (context)(oid): (), (1.3.6.1.6.3.16.1)
20220928.08:55:06: 2224: (3)DEBUG  : MibContext: adding MIB object (context)(oid): (), (1.3.6.1.6.3.12.1.5.0)
20220928.08:55:06: 2224: (3)DEBUG  : MibContext: adding MIB object (context)(oid): (), (1.3.6.1.6.3.12.1.4.0)
20220928.08:55:07: 2224: (A)DEBUG  : SnmpTagList: contains: (taglist)(tag): (v3trap), (v3trap)
20220928.08:55:07: 2224: (7)DEBUG  : Vacm: Access requested for: (model) (name) (level) (type) (context) (oid): (3), (UTENTE), (1), (3), (other), (1.3.6.1.6.3.1.1.5.1)
20220928.08:55:07: 2224: (7)DEBUG  : Vacm: getGroupName: (model) (name): (3), (UTENTE), (1.3.6.1.6.3.16.1.2.1.3.3.6.85.84.69.78.84.69)
20220928.08:55:07: 2224: (7)DEBUG  : Vacm: getViewName: (group) (context) (model) (level) (type): (GRUPPO), (other), (3), (1), (3)
20220928.08:55:07: 2224: (7)DEBUG  : Vacm: getViewName: (matched group): (GRUPPO)
20220928.08:55:07: 2224: (2)EVENT  : Notification not sent (reason) (addr) (params): (no access), (  7F 00 00 01 00 A2                                  ......), (defaultV3Trap)

The last debug line says “no access”, so there is something missing in your VACM configuration. You could either post your VACM configuration or check with one of the example agents (e.g. examples/atm_mib/src/agent.cpp) which calls are needed.

1 Like

Solved:
I edited the add_v3_trap_destination() adding a sec_level parameter, because previously it was forced to 1 (but because I was using authNoPriv it failed the vacm checks)

Maybe you should update snmp++ and agent++ to a more recent version:

commit 1493288070793ac76476e1dc1d7e80aa5d344b5b
Date: Tue Dec 14 20:17:42 2010 +0000

Allow to set security level for add_v3_trap_destination() function.