Problem adding and retrieving engine ids in snmp++ 4.0.1

Hello
This is about snmp++ 4.0.1. I have a question concerning calls to v3Mp::add_to_engine_id_table and v3MP::get_from_engine_id_table. We are using SNMPv3 USM with UDP as transport mechanism.
Changing our usage of snmp++ from version 3.6.6 to version 4.0.1 showed some errors. We are using Ipv4 addresses only and in some code that uses snmp++ we call v3MP::get_from_engine_id_table with host IPv4 addresses (example “172.16.1.1”) and default port 161.
As result, we got an error indicating that the engine id was not found. After some debugging I found:

  • At msgqueue.cpp, the call to m_snmpSession->get_mpv3()->add_to_engine_id_table at line 489 uses in line 492 (char*)addr.cast_ipaddress().get_printable() as “host” argument.
  • At uxsnmp.cpp, method int Snmp::discover_engine_id_5343, the call to v3MP::add_to_engine_id_table uses (char *) addr.cast_ipaddress().get_printable() as “host” argument in line 2180.
  • At uxsnmp.cpp, method int Snmp::snmp_engine the call to v3MP::get_from_engine_id_table uses
    (char *) gen_target_address.cast_ipaddress().get_printable() as “host” argument in line 1807.

As method get_printable is virtual, calling (char*)addr.cast_ipaddress().get_printable() led in our case to entries of type “172.16.1.1/161” in the “host” fields in the engine id table.
Thus a call to v3MP::get_from_engine_id_table could not find the host “172.16.1.1” in the engine id table.

I had to change the calls (char*)addr.cast_ipaddress().get_printable() to (char*)addr.cast_ipaddress().IpAddress::get_printable() in the three locations listed above as a fix for my problem.

Compared to snmp++ 3.6.6 this code is new. My question is: Is this a bug of do I have I overseen something?

regards, Thorsten

It is not a bug, it is a security feature. To include the port makes engine ID cache pollution more difficult.

I need to check if the documentation of that method you used needs to be improved to make the current contract more obvious.