[AGENT++] [SNMP++] how to handle SNMPv3 authentication error in callback function?

Jochen Katz katz at agentpp.com
Sat Nov 13 21:24:20 CET 2010


Hi,

> Would u be so kind to explain to me SNMPv3 authentication errors (like 
> wrong security name or wrong authentication password) handling mechanism 
> in callback function?
> 
> if (pdu.get_type() == sNMP_PDU_REPORT)
>      {
>          QString errstr(Snmp::error_msg(pdu.get_vb(0).get_oid()));
> 
>          if (errstr == QString("SNMPv3: USM: Unknown SecurityName"))
>              status = 1;    //    We detect "wrong user name" error
>          if (errstr == QString("SNMPv3: USM: Authentication failure"))
>              status = 2;    //    We detect "wrong password" error
>      }
> ....
> }
> Is that only one method to handle this kind of error or there are some 
> other mechanisms?

At the moment, this is the only way to check reports. But you should
compare the Oids, not the error strings, as strings can change.

> For example, in NET-SNMP library such error codes can be obtained 
> directly from SNMP session structure but in SNMP++ I've not found other 
> methods except listed above.

I think you want to have a function like

int Snmp::error_code(const Oid& v3Oid)
{
  // UsmStats
  if (v3Oid == oidUsmStatsUnsupportedSecLevels)
    return SNMPv3_USM_UNSUPPORTED_SECURITY_LEVEL;

  if (v3Oid == oidUsmStatsNotInTimeWindows)
    return SNMPv3_USM_NOT_IN_TIME_WINDOW;
...
}

I just have added it for the next release.

Regards,
  Jochen



More information about the AGENTPP mailing list