summaryrefslogtreecommitdiff
path: root/redfish-core
diff options
context:
space:
mode:
authorRavi Teja <raviteja28031990@gmail.com>2023-10-17 18:59:33 +0300
committerGunnar Mills <gmills@us.ibm.com>2023-11-06 17:31:27 +0300
commit63509dd54c3290750961899125d588ea5f339023 (patch)
tree5785ea3169285b7cb18000e24bb98f54fcebb468 /redfish-core
parent931edc79bc0c3d6bc90019718190cc345edbd696 (diff)
downloadbmcweb-63509dd54c3290750961899125d588ea5f339023.tar.xz
Fix SNMP invalid Destination error
This commit handles invalid SNMP destination error Tested by: Configure SNMP with invalid destination IP address '{"Destination": "snmp://10.6.6.256:162", "SubscriptionType": "SNMPTrap", "Protocol": "SNMPv2c"}' Change-Id: I88f81a79a6665a7adc654e138b4f07ce321898a4 Signed-off-by: Ravi Teja <raviteja28031990@gmail.com>
Diffstat (limited to 'redfish-core')
-rw-r--r--redfish-core/include/snmp_trap_event_clients.hpp38
1 files changed, 25 insertions, 13 deletions
diff --git a/redfish-core/include/snmp_trap_event_clients.hpp b/redfish-core/include/snmp_trap_event_clients.hpp
index 5660fbc50c..6cc96a62b5 100644
--- a/redfish-core/include/snmp_trap_event_clients.hpp
+++ b/redfish-core/include/snmp_trap_event_clients.hpp
@@ -129,24 +129,35 @@ inline void
"org.freedesktop.DBus.ObjectManager", "GetManagedObjects");
}
-inline void
- afterSnmpClientCreate(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const boost::system::error_code& ec,
- const std::string& dbusSNMPid)
+inline void afterSnmpClientCreate(
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const boost::system::error_code& ec, const sdbusplus::message_t& msg,
+ const std::string& host, const std::string& dbusSNMPid)
{
if (ec)
{
- if (ec.value() != EBADR)
+ const sd_bus_error* dbusError = msg.get_error();
+ if (dbusError != nullptr)
{
- // SNMP not installed
- messages::propertyValueOutOfRange(asyncResp->res, "SNMPv2c",
- "Protocol");
- return;
+ if (std::string_view(
+ "xyz.openbmc_project.Common.Error.InvalidArgument") ==
+ dbusError->name)
+ {
+ messages::propertyValueIncorrect(asyncResp->res, "Destination",
+ host);
+ return;
+ }
+ if (ec.value() != EBADR)
+ {
+ // SNMP not installed
+ messages::propertyValueOutOfRange(asyncResp->res, "SNMPv2c",
+ "Protocol");
+ return;
+ }
}
messages::internalError(asyncResp->res);
return;
}
-
sdbusplus::message::object_path path(dbusSNMPid);
const std::string snmpId = path.filename();
if (snmpId.empty())
@@ -168,9 +179,10 @@ inline void
const std::string& host, uint16_t snmpTrapPort)
{
crow::connections::systemBus->async_method_call(
- [asyncResp](const boost::system::error_code& ec,
- const std::string& dbusSNMPid) {
- afterSnmpClientCreate(asyncResp, ec, dbusSNMPid);
+ [asyncResp, host](const boost::system::error_code& ec,
+ const sdbusplus::message_t& msg,
+ const std::string& dbusSNMPid) {
+ afterSnmpClientCreate(asyncResp, ec, msg, host, dbusSNMPid);
},
"xyz.openbmc_project.Network.SNMP",
"/xyz/openbmc_project/network/snmp/manager",