Hello, I would like to use the SNMP++ library on an embedded Linux. I am developing in Ubuntu with QT 4.13.2 and I have a version that is compiled for my desktop and one for embedded linux. We would like to use v2c and not v3.
On the desktop I have installed my library (both version 3.4.6) under /usr/lib and /usr/include/snmp++. So far everything works in my test environment and I can receive information from my router with snmp->get(…).
Unfortunately it does not work via Embedded Linux. With snmp->get() there is a different return value (not negative) after each compilation. Here is an example:
`if ((m_status = m_snmp->get(m_pdu, m_cTarget)) != SNMP_CLASS_SUCCESS){
qDebug() << m_status;
qDebug() << “snmp get error” << m_snmp->error_msg(m_status);
}
16702848
snmp get error SNMPv3: USM: Could not read from file`
Is there a plausible explanation for this?
I set version with m_cTarget.set_version(snmp_version(1)) and it works fine with desktop version.
Here is the code
Oid m_id(oid_string, true);
m_ipAddress = IpAddress(ipAddress);
m_cTarget = CTarget(m_ipAddress, commuinity, commuinity); // SNMP++ community target
m_cTarget.set_version(snmp_version(1));
Vb m_vb; // SNMP++ Variable Binding Object
m_vb.set_oid(oid_string);
m_snmp = new Snmp(m_status, (m_ipAddress.get_ip_version() == Address::version_ipv4), 0);
if (m_status != SNMP_CLASS_SUCCESS) { // check creation status
std::cout << "snmp++ session not created" << m_snmp->error_msg(m_status); // if fail, print error string
return;
}
qDebug() << m_snmp->get_version();
m_pdu += m_vb; // add the variable binding to the PDU
// getValue();
int status = 0;
if ((m_status = m_snmp->get(m_pdu, m_cTarget)) != SNMP_CLASS_SUCCESS){
qDebug() << m_status << SNMP_CLASS_SUCCESS;
qDebug() << "snmp get error" << m_snmp->error_msg(m_status);
}
else {
m_pdu.get_vb(m_vb,0); // extract the variable binding from PDU
qDebug() << "System Descriptor = "<< m_vb.get_printable_value(); } // print out the value
m_vb.get_value(m_value);