diff options
author | Xo Wang <xow@google.com> | 2017-08-11 10:17:59 -0700 |
---|---|---|
committer | Patrick Venture <venture@google.com> | 2018-09-25 10:04:43 -0700 |
commit | 87651333c451cfa8090273366be5ec62bd1a9eea (patch) | |
tree | b2085125fdcd79654c96e1f956ba8ce9cf3184c2 /apphandler.cpp | |
parent | f542e8b0ecedb54fd4e1fbd7a8c2a9f73098dcec (diff) | |
download | phosphor-host-ipmid-87651333c451cfa8090273366be5ec62bd1a9eea.tar.gz phosphor-host-ipmid-87651333c451cfa8090273366be5ec62bd1a9eea.zip |
apphandler: Add "System Name" System Info parameter
Use the BMC's hostname to respond to requests for the "System Name"
parameter.
Signed-off-by: Xo Wang <xow@google.com>
Change-Id: I23845aab6091a0d003b6f8370d2b67fc11e580e8
Signed-off-by: Patrick Venture <venture@google.com>
Diffstat (limited to 'apphandler.cpp')
-rw-r--r-- | apphandler.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/apphandler.cpp b/apphandler.cpp index 7f16b1f..4a2f2da 100644 --- a/apphandler.cpp +++ b/apphandler.cpp @@ -10,10 +10,12 @@ #include "utils.hpp" #include <arpa/inet.h> +#include <limits.h> #include <mapper.h> #include <stdint.h> #include <stdio.h> #include <systemd/sd-bus.h> +#include <unistd.h> #include "host-ipmid/ipmid-api.h" @@ -635,6 +637,17 @@ ipmi_ret_t ipmi_app_get_sys_guid(ipmi_netfn_t netfn, ipmi_cmd_t cmd, static std::unique_ptr<SysInfoParamStore> sysInfoParamStore; +static std::string sysInfoReadSystemName() +{ + // Use the BMC hostname as the "System Name." + char hostname[HOST_NAME_MAX + 1] = {}; + if (gethostname(hostname, HOST_NAME_MAX) != 0) + { + perror("System info parameter: system name"); + } + return hostname; +} + struct IpmiSysInfoResp { uint8_t paramRevision; @@ -764,6 +777,8 @@ ipmi_ret_t ipmi_app_get_system_info(ipmi_netfn_t netfn, ipmi_cmd_t cmd, if (sysInfoParamStore == nullptr) { sysInfoParamStore = std::make_unique<SysInfoParamStore>(); + sysInfoParamStore->update(IPMI_SYSINFO_SYSTEM_NAME, + sysInfoReadSystemName); } // Parameters other than Set In Progress are assumed to be strings. |