From 9182548d64cdfc6be9a0cb92aea810f65f29b299 Mon Sep 17 00:00:00 2001 From: Maxim Mamontov Date: Wed, 23 Nov 2011 20:11:58 +0200 Subject: [PATCH] Extra error messages added --- src/snmptable.cpp | 4 ++-- src/switch.cpp | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/snmptable.cpp b/src/snmptable.cpp index b0aaba3..5937270 100644 --- a/src/snmptable.cpp +++ b/src/snmptable.cpp @@ -11,8 +11,8 @@ SNMPTable::SNMPTable(Snmp & snmp, Vb vb(oid); Pdu pdu(&vb, 1); while (true) { - if (snmp.get_next(pdu, target) != SNMP_CLASS_SUCCESS) { - logger << "SNMPTable::SNMPTable() - failed to invoke Snmp::get_next (oid: '" << oid.get_printable() << "')" << std::endl; + if (int c = snmp.get_next(pdu, target) != SNMP_CLASS_SUCCESS) { + logger << "SNMPTable::SNMPTable() - failed to invoke Snmp::get_next (oid: '" << oid.get_printable() << "'). Error message: '" << Snmp::error_msg(c) << "'" << std::endl; return; } if (pdu.get_vb(0).get_oid().nCompare(oid.len(), oid) != 0) { diff --git a/src/switch.cpp b/src/switch.cpp index 43c83da..b705402 100644 --- a/src/switch.cpp +++ b/src/switch.cpp @@ -178,7 +178,8 @@ bool Switch::dropACLsByTable(const CTarget & target, unsigned profileId, const S SNMPList::const_iterator it; for (it = aclsList.begin(); it != aclsList.end(); ++it) { int id; - if (it->get_value(id) != SNMP_CLASS_SUCCESS) { + if (int c = it->get_value(id) != SNMP_CLASS_SUCCESS) { + logger << "Switch::dropACLsByTable() - failed to get ACL id for the switch '" << _ip << "'. Error message: '" << Snmp::error_msg(c) << "'" << std::endl; return false; } std::string dropACLOid(dropACLOidPrefix); @@ -188,8 +189,8 @@ bool Switch::dropACLsByTable(const CTarget & target, unsigned profileId, const S vb.set_value(int(6)); pdu += vb; } - if (_snmp.set(pdu, target) != SNMP_CLASS_SUCCESS) { - logger << "Switch::dropACLsByTable() - failed to invoke Snmp::set for the switch '" << _ip << "'" << std::endl; + if (int c = _snmp.set(pdu, target) != SNMP_CLASS_SUCCESS) { + logger << "Switch::dropACLsByTable() - failed to invoke Snmp::set for the switch '" << _ip << "'. Error message: '" << Snmp::error_msg(c) << "'" << std::endl; return false; } return true; @@ -201,8 +202,8 @@ bool Switch::createACLs(const CTarget & target) for (it = _acls.begin(); it != _acls.end(); ++it) { Pdu pdu; it->appendPdu(pdu); - if (_snmp.set(pdu, target) != SNMP_CLASS_SUCCESS) { - logger << "Switch::createACLs() - failed to invoke Snmp::set for the switch '" << _ip << "'" << std::endl; + if (int c = _snmp.set(pdu, target) != SNMP_CLASS_SUCCESS) { + logger << "Switch::createACLs() - failed to invoke Snmp::set for the switch '" << _ip << "'. Error message: '" << Snmp::error_msg(c) << "'" << std::endl; return false; } } -- 2.43.2