blob: c2783b7fdc1dc8806ea49735fc2884a0b8c271b7 [file] [log] [blame]
Qiang XUe28d1fa2019-02-27 13:50:56 +08001/*
2// Copyright (c) 2018 Intel Corporation
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15*/
16
Andrew Jefferye73bd0a2023-01-25 10:39:57 +103017#include "ChassisIntrusionSensor.hpp"
18#include "Utils.hpp"
19
Ed Tanous1f978632023-02-28 18:16:39 -080020#include <boost/asio/io_context.hpp>
Patrick Venture96e97db2019-10-31 13:44:38 -070021#include <boost/container/flat_map.hpp>
Patrick Williams0c42f402021-08-27 16:05:45 -050022#include <phosphor-logging/lg2.hpp>
Qiang XUe28d1fa2019-02-27 13:50:56 +080023#include <sdbusplus/asio/connection.hpp>
24#include <sdbusplus/asio/object_server.hpp>
Qiang XUe28d1fa2019-02-27 13:50:56 +080025#include <sdbusplus/bus.hpp>
Patrick Venture96e97db2019-10-31 13:44:38 -070026#include <sdbusplus/bus/match.hpp>
Qiang XUe28d1fa2019-02-27 13:50:56 +080027#include <sdbusplus/exception.hpp>
28#include <sdbusplus/server.hpp>
29#include <sdbusplus/timer.hpp>
James Feist38fb5982020-05-28 10:09:54 -070030
31#include <array>
Ed Tanous8a57ec02020-10-09 12:46:52 -070032#include <charconv>
James Feist38fb5982020-05-28 10:09:54 -070033#include <chrono>
34#include <ctime>
35#include <fstream>
36#include <functional>
37#include <iostream>
38#include <memory>
Patrick Venture96e97db2019-10-31 13:44:38 -070039#include <stdexcept>
40#include <string>
41#include <utility>
42#include <vector>
Qiang XUe28d1fa2019-02-27 13:50:56 +080043
Ed Tanous8a57ec02020-10-09 12:46:52 -070044static constexpr bool debug = false;
Qiang XUe28d1fa2019-02-27 13:50:56 +080045
Zev Weiss054aad82022-08-18 01:37:34 -070046static constexpr const char* sensorType = "ChassisIntrusionSensor";
47static constexpr const char* nicType = "NIC";
Brandon Kim66558232021-11-09 16:53:08 -080048static constexpr auto nicTypes{std::to_array<const char*>({nicType})};
Qiang XUe28d1fa2019-02-27 13:50:56 +080049
Chau Lycebb28c2022-10-21 10:01:52 +000050static void createSensorsFromConfig(
51 boost::asio::io_context& io, sdbusplus::asio::object_server& objServer,
Lei YUba637932021-03-17 10:35:00 +080052 const std::shared_ptr<sdbusplus::asio::connection>& dbusConnection,
Chau Lycebb28c2022-10-21 10:01:52 +000053 std::shared_ptr<ChassisIntrusionSensor>& pSensor)
Qiang XUe28d1fa2019-02-27 13:50:56 +080054{
55 // find matched configuration according to sensor type
56 ManagedObjectType sensorConfigurations;
57 bool useCache = false;
58
59 if (!getSensorConfiguration(sensorType, dbusConnection,
60 sensorConfigurations, useCache))
61 {
62 std::cerr << "error communicating to entity manager\n";
Chau Lycebb28c2022-10-21 10:01:52 +000063 return;
Qiang XUe28d1fa2019-02-27 13:50:56 +080064 }
65
66 const SensorData* sensorData = nullptr;
Zev Weissafd15042022-07-18 12:28:40 -070067 const std::pair<std::string, SensorBaseConfigMap>* baseConfiguration =
68 nullptr;
Qiang XUe28d1fa2019-02-27 13:50:56 +080069
70 // Get bus and addr of matched configuration
Zev Weissf343b8a2022-08-12 18:21:01 -070071 for (const auto& [path, cfgData] : sensorConfigurations)
Qiang XUe28d1fa2019-02-27 13:50:56 +080072 {
73 baseConfiguration = nullptr;
Zev Weissf343b8a2022-08-12 18:21:01 -070074 sensorData = &cfgData;
Qiang XUe28d1fa2019-02-27 13:50:56 +080075
76 // match sensor type
Zev Weiss054aad82022-08-18 01:37:34 -070077 auto sensorBase = sensorData->find(configInterfaceName(sensorType));
Qiang XUe28d1fa2019-02-27 13:50:56 +080078 if (sensorBase == sensorData->end())
79 {
80 std::cerr << "error finding base configuration \n";
81 continue;
82 }
83
84 baseConfiguration = &(*sensorBase);
85
86 // judge class, "Gpio" or "I2C"
87 auto findClass = baseConfiguration->second.find("Class");
88 if (findClass != baseConfiguration->second.end() &&
Patrick Williams94733252020-05-13 11:44:58 -050089 std::get<std::string>(findClass->second) == "Gpio")
Qiang XUe28d1fa2019-02-27 13:50:56 +080090 {
ZhikuiRenba8a8bf2020-01-09 15:55:43 -080091 auto findGpioPolarity =
92 baseConfiguration->second.find("GpioPolarity");
Qiang XUe28d1fa2019-02-27 13:50:56 +080093
ZhikuiRenba8a8bf2020-01-09 15:55:43 -080094 if (findGpioPolarity == baseConfiguration->second.end())
Qiang XUe28d1fa2019-02-27 13:50:56 +080095 {
ZhikuiRenba8a8bf2020-01-09 15:55:43 -080096 std::cerr << "error finding gpio polarity in configuration \n";
Qiang XUe28d1fa2019-02-27 13:50:56 +080097 continue;
98 }
99
100 try
101 {
Chau Lycebb28c2022-10-21 10:01:52 +0000102 bool gpioInverted =
Patrick Williams94733252020-05-13 11:44:58 -0500103 (std::get<std::string>(findGpioPolarity->second) == "Low");
Chau Lycebb28c2022-10-21 10:01:52 +0000104 pSensor = std::make_shared<ChassisIntrusionGpioSensor>(
105 io, objServer, gpioInverted);
106 pSensor->start();
107 if (debug)
108 {
109 std::cout
110 << "find chassis intrusion sensor polarity inverted "
111 "flag is "
112 << gpioInverted << "\n";
113 }
114 return;
Qiang XUe28d1fa2019-02-27 13:50:56 +0800115 }
116 catch (const std::bad_variant_access& e)
117 {
118 std::cerr << "invalid value for gpio info in config. \n";
119 continue;
120 }
Chau Lycebb28c2022-10-21 10:01:52 +0000121 catch (const std::exception& e)
Qiang XUe28d1fa2019-02-27 13:50:56 +0800122 {
Chau Lycebb28c2022-10-21 10:01:52 +0000123 std::cerr << e.what() << std::endl;
124 continue;
Qiang XUe28d1fa2019-02-27 13:50:56 +0800125 }
Qiang XUe28d1fa2019-02-27 13:50:56 +0800126 }
Chau Lycebb28c2022-10-21 10:01:52 +0000127 else
Qiang XUe28d1fa2019-02-27 13:50:56 +0800128 {
129 auto findBus = baseConfiguration->second.find("Bus");
130 auto findAddress = baseConfiguration->second.find("Address");
131 if (findBus == baseConfiguration->second.end() ||
132 findAddress == baseConfiguration->second.end())
133 {
134 std::cerr << "error finding bus or address in configuration \n";
135 continue;
136 }
Qiang XUe28d1fa2019-02-27 13:50:56 +0800137 try
138 {
Chau Lycebb28c2022-10-21 10:01:52 +0000139 int busId = std::get<uint64_t>(findBus->second);
140 int slaveAddr = std::get<uint64_t>(findAddress->second);
141 pSensor = std::make_shared<ChassisIntrusionPchSensor>(
142 io, objServer, busId, slaveAddr);
143 pSensor->start();
144 if (debug)
145 {
146 std::cout << "find matched bus " << busId
147 << ", matched slave addr " << slaveAddr << "\n";
148 }
149 return;
Qiang XUe28d1fa2019-02-27 13:50:56 +0800150 }
151 catch (const std::bad_variant_access& e)
152 {
153 std::cerr << "invalid value for bus or address in config. \n";
154 continue;
155 }
Chau Lycebb28c2022-10-21 10:01:52 +0000156 catch (const std::exception& e)
Qiang XUe28d1fa2019-02-27 13:50:56 +0800157 {
Chau Lycebb28c2022-10-21 10:01:52 +0000158 std::cerr << e.what() << std::endl;
159 continue;
Qiang XUe28d1fa2019-02-27 13:50:56 +0800160 }
Qiang XUe28d1fa2019-02-27 13:50:56 +0800161 }
162 }
163
Chau Lycebb28c2022-10-21 10:01:52 +0000164 std::cerr << " Can't find matched I2C, GPIO configuration\n";
165
166 // Make sure nothing runs when there's failure in configuration for the
167 // sensor after rescan
168 if (pSensor)
169 {
170 std::cerr << " Reset the occupied sensor pointer\n";
171 pSensor = nullptr;
172 }
Qiang XUe28d1fa2019-02-27 13:50:56 +0800173}
174
Qiang XU88b7f282019-08-14 22:51:43 +0800175static constexpr bool debugLanLeash = false;
176boost::container::flat_map<int, bool> lanStatusMap;
Qiang XU74ddf862019-09-12 17:12:13 +0800177boost::container::flat_map<int, std::string> lanInfoMap;
Qiang XU88b7f282019-08-14 22:51:43 +0800178boost::container::flat_map<std::string, int> pathSuffixMap;
179
Lei YUba637932021-03-17 10:35:00 +0800180static void getNicNameInfo(
181 const std::shared_ptr<sdbusplus::asio::connection>& dbusConnection)
Qiang XU74ddf862019-09-12 17:12:13 +0800182{
183 auto getter = std::make_shared<GetSensorConfiguration>(
Patrick Williams779c96a2023-05-10 07:50:42 -0500184 dbusConnection,
185 [](const ManagedObjectType& sensorConfigurations) {
186 // Get NIC name and save to map
187 lanInfoMap.clear();
188 for (const auto& [path, cfgData] : sensorConfigurations)
189 {
190 const std::pair<std::string, SensorBaseConfigMap>*
191 baseConfiguration = nullptr;
192
193 // find base configuration
194 auto sensorBase = cfgData.find(configInterfaceName(nicType));
195 if (sensorBase == cfgData.end())
Qiang XU74ddf862019-09-12 17:12:13 +0800196 {
Patrick Williams779c96a2023-05-10 07:50:42 -0500197 continue;
198 }
199 baseConfiguration = &(*sensorBase);
Qiang XU74ddf862019-09-12 17:12:13 +0800200
Patrick Williams779c96a2023-05-10 07:50:42 -0500201 auto findEthIndex = baseConfiguration->second.find("EthIndex");
202 auto findName = baseConfiguration->second.find("Name");
203
204 if (findEthIndex != baseConfiguration->second.end() &&
205 findName != baseConfiguration->second.end())
206 {
207 const auto* pEthIndex =
208 std::get_if<uint64_t>(&findEthIndex->second);
209 const auto* pName = std::get_if<std::string>(&findName->second);
210 if (pEthIndex != nullptr && pName != nullptr)
Qiang XU74ddf862019-09-12 17:12:13 +0800211 {
Patrick Williams779c96a2023-05-10 07:50:42 -0500212 lanInfoMap[*pEthIndex] = *pName;
213 if (debugLanLeash)
Qiang XU74ddf862019-09-12 17:12:13 +0800214 {
Patrick Williams779c96a2023-05-10 07:50:42 -0500215 std::cout << "find name of eth" << *pEthIndex << " is "
216 << *pName << "\n";
Qiang XU74ddf862019-09-12 17:12:13 +0800217 }
218 }
219 }
Patrick Williams779c96a2023-05-10 07:50:42 -0500220 }
Qiang XU74ddf862019-09-12 17:12:13 +0800221
Patrick Williams779c96a2023-05-10 07:50:42 -0500222 if (lanInfoMap.empty())
223 {
224 std::cerr << "can't find matched NIC name. \n";
225 }
Ed Tanous8a17c302021-09-02 15:07:11 -0700226 });
Qiang XU74ddf862019-09-12 17:12:13 +0800227
228 getter->getConfiguration(
229 std::vector<std::string>{nicTypes.begin(), nicTypes.end()});
230}
231
Patrick Williams92f8f512022-07-22 19:26:55 -0500232static void processLanStatusChange(sdbusplus::message_t& message)
Qiang XU88b7f282019-08-14 22:51:43 +0800233{
234 const std::string& pathName = message.get_path();
235 std::string interfaceName;
Zev Weissafd15042022-07-18 12:28:40 -0700236 SensorBaseConfigMap properties;
Qiang XU88b7f282019-08-14 22:51:43 +0800237 message.read(interfaceName, properties);
238
239 auto findStateProperty = properties.find("OperationalState");
240 if (findStateProperty == properties.end())
241 {
242 return;
243 }
Qiang XU74ddf862019-09-12 17:12:13 +0800244 std::string* pState =
245 std::get_if<std::string>(&(findStateProperty->second));
Qiang XU88b7f282019-08-14 22:51:43 +0800246 if (pState == nullptr)
247 {
248 std::cerr << "invalid OperationalState \n";
249 return;
250 }
251
252 bool newLanConnected = (*pState == "routable" || *pState == "carrier" ||
253 *pState == "degraded");
254
255 // get ethNum from path. /org/freedesktop/network1/link/_32 for eth0
Brad Bishopfbb44ad2019-11-08 09:42:37 -0500256 size_t pos = pathName.find("/_");
Qiang XU88b7f282019-08-14 22:51:43 +0800257 if (pos == std::string::npos || pathName.length() <= pos + 2)
258 {
259 std::cerr << "unexpected path name " << pathName << "\n";
260 return;
261 }
262 std::string suffixStr = pathName.substr(pos + 2);
263
264 auto findEthNum = pathSuffixMap.find(suffixStr);
265 if (findEthNum == pathSuffixMap.end())
266 {
267 std::cerr << "unexpected eth for suffixStr " << suffixStr << "\n";
268 return;
269 }
270 int ethNum = findEthNum->second;
Qiang XU74ddf862019-09-12 17:12:13 +0800271
272 // get lan status from map
Qiang XU88b7f282019-08-14 22:51:43 +0800273 auto findLanStatus = lanStatusMap.find(ethNum);
274 if (findLanStatus == lanStatusMap.end())
275 {
276 std::cerr << "unexpected eth " << ethNum << " in lanStatusMap \n";
277 return;
278 }
279 bool oldLanConnected = findLanStatus->second;
280
Qiang XU74ddf862019-09-12 17:12:13 +0800281 // get lan info from map
Ed Tanous2049bd22022-07-09 07:20:26 -0700282 std::string lanInfo;
283 if (!lanInfoMap.empty())
Qiang XU74ddf862019-09-12 17:12:13 +0800284 {
285 auto findLanInfo = lanInfoMap.find(ethNum);
286 if (findLanInfo == lanInfoMap.end())
287 {
288 std::cerr << "unexpected eth " << ethNum << " in lanInfoMap \n";
289 }
290 else
291 {
292 lanInfo = "(" + findLanInfo->second + ")";
293 }
294 }
295
Qiang XU88b7f282019-08-14 22:51:43 +0800296 if (debugLanLeash)
297 {
298 std::cout << "ethNum = " << ethNum << ", state = " << *pState
299 << ", oldLanConnected = "
300 << (oldLanConnected ? "true" : "false")
301 << ", newLanConnected = "
302 << (newLanConnected ? "true" : "false") << "\n";
303 }
304
305 if (oldLanConnected != newLanConnected)
306 {
Qiang XU74ddf862019-09-12 17:12:13 +0800307 std::string strEthNum = "eth" + std::to_string(ethNum) + lanInfo;
Ed Tanous2049bd22022-07-09 07:20:26 -0700308 const auto* strState = newLanConnected ? "connected" : "lost";
Patrick Williams779c96a2023-05-10 07:50:42 -0500309 const auto* strMsgId = newLanConnected ? "OpenBMC.0.1.LanRegained"
310 : "OpenBMC.0.1.LanLost";
Patrick Williams0c42f402021-08-27 16:05:45 -0500311
312 lg2::info("{ETHDEV} LAN leash {STATE}", "ETHDEV", strEthNum, "STATE",
313 strState, "REDFISH_MESSAGE_ID", strMsgId,
314 "REDFISH_MESSAGE_ARGS", strEthNum);
315
Qiang XU88b7f282019-08-14 22:51:43 +0800316 lanStatusMap[ethNum] = newLanConnected;
Qiang XU88b7f282019-08-14 22:51:43 +0800317 }
318}
319
Lei YUdd68d4a2021-03-16 22:17:23 +0800320/** @brief Initialize the lan status.
321 *
322 * @return true on success and false on failure
323 */
Lei YUba637932021-03-17 10:35:00 +0800324static bool initializeLanStatus(
325 const std::shared_ptr<sdbusplus::asio::connection>& conn)
Qiang XU88b7f282019-08-14 22:51:43 +0800326{
Qiang XU74ddf862019-09-12 17:12:13 +0800327 // init lan port name from configuration
328 getNicNameInfo(conn);
329
330 // get eth info from sysfs
Qiang XU88b7f282019-08-14 22:51:43 +0800331 std::vector<fs::path> files;
332 if (!findFiles(fs::path("/sys/class/net/"), R"(eth\d+/ifindex)", files))
333 {
334 std::cerr << "No eth in system\n";
Lei YUdd68d4a2021-03-16 22:17:23 +0800335 return false;
Qiang XU88b7f282019-08-14 22:51:43 +0800336 }
337
338 // iterate through all found eth files, and save ifindex
Ed Tanous8a57ec02020-10-09 12:46:52 -0700339 for (const fs::path& fileName : files)
Qiang XU88b7f282019-08-14 22:51:43 +0800340 {
341 if (debugLanLeash)
342 {
343 std::cout << "Reading " << fileName << "\n";
344 }
345 std::ifstream sysFile(fileName);
346 if (!sysFile.good())
347 {
348 std::cerr << "Failure reading " << fileName << "\n";
349 continue;
350 }
351 std::string line;
352 getline(sysFile, line);
353 const uint8_t ifindex = std::stoi(line);
354 // pathSuffix is ASCII of ifindex
355 const std::string& pathSuffix = std::to_string(ifindex + 30);
356
357 // extract ethNum
358 const std::string& fileStr = fileName.string();
359 const int pos = fileStr.find("eth");
360 const std::string& ethNumStr = fileStr.substr(pos + 3);
361 int ethNum = 0;
Ed Tanous8a57ec02020-10-09 12:46:52 -0700362 std::from_chars_result r = std::from_chars(
363 ethNumStr.data(), ethNumStr.data() + ethNumStr.size(), ethNum);
364 if (r.ec != std::errc())
Qiang XU88b7f282019-08-14 22:51:43 +0800365 {
366 std::cerr << "invalid ethNum string: " << ethNumStr << "\n";
367 continue;
368 }
369
370 // save pathSuffix
371 pathSuffixMap[pathSuffix] = ethNum;
372 if (debugLanLeash)
373 {
374 std::cout << "ethNum = " << std::to_string(ethNum)
375 << ", ifindex = " << line
376 << ", pathSuffix = " << pathSuffix << "\n";
377 }
378
Qiang XU74ddf862019-09-12 17:12:13 +0800379 // init lan connected status from networkd
Qiang XU88b7f282019-08-14 22:51:43 +0800380 conn->async_method_call(
381 [ethNum](boost::system::error_code ec,
382 const std::variant<std::string>& property) {
Ed Tanousbb679322022-05-16 16:10:00 -0700383 lanStatusMap[ethNum] = false;
384 if (ec)
385 {
386 std::cerr << "Error reading init status of eth" << ethNum
387 << "\n";
388 return;
389 }
390 const std::string* pState = std::get_if<std::string>(&property);
391 if (pState == nullptr)
392 {
393 std::cerr << "Unable to read lan status value\n";
394 return;
395 }
Patrick Williams779c96a2023-05-10 07:50:42 -0500396 bool isLanConnected = (*pState == "routable" ||
397 *pState == "carrier" ||
398 *pState == "degraded");
Ed Tanousbb679322022-05-16 16:10:00 -0700399 if (debugLanLeash)
400 {
401 std::cout << "ethNum = " << std::to_string(ethNum)
402 << ", init LAN status = "
403 << (isLanConnected ? "true" : "false") << "\n";
404 }
405 lanStatusMap[ethNum] = isLanConnected;
Qiang XU88b7f282019-08-14 22:51:43 +0800406 },
407 "org.freedesktop.network1",
408 "/org/freedesktop/network1/link/_" + pathSuffix,
409 "org.freedesktop.DBus.Properties", "Get",
410 "org.freedesktop.network1.Link", "OperationalState");
411 }
Lei YUdd68d4a2021-03-16 22:17:23 +0800412 return true;
Qiang XU88b7f282019-08-14 22:51:43 +0800413}
414
Qiang XUe28d1fa2019-02-27 13:50:56 +0800415int main()
416{
Chau Lycebb28c2022-10-21 10:01:52 +0000417 std::shared_ptr<ChassisIntrusionSensor> intrusionSensor;
Qiang XUe28d1fa2019-02-27 13:50:56 +0800418
419 // setup connection to dbus
Ed Tanous1f978632023-02-28 18:16:39 -0800420 boost::asio::io_context io;
Qiang XUe28d1fa2019-02-27 13:50:56 +0800421 auto systemBus = std::make_shared<sdbusplus::asio::connection>(io);
Qiang XUe28d1fa2019-02-27 13:50:56 +0800422
423 // setup object server, define interface
424 systemBus->request_name("xyz.openbmc_project.IntrusionSensor");
425
Ed Tanous14ed5e92022-07-12 15:50:23 -0700426 sdbusplus::asio::object_server objServer(systemBus, true);
427
Chau Ly889af822023-02-20 07:13:52 +0000428 objServer.add_manager("/xyz/openbmc_project/Chassis");
Ed Tanous14ed5e92022-07-12 15:50:23 -0700429
Chau Lycebb28c2022-10-21 10:01:52 +0000430 createSensorsFromConfig(io, objServer, systemBus, intrusionSensor);
Qiang XUe28d1fa2019-02-27 13:50:56 +0800431
432 // callback to handle configuration change
Patrick Williams92f8f512022-07-22 19:26:55 -0500433 std::function<void(sdbusplus::message_t&)> eventHandler =
434 [&](sdbusplus::message_t& message) {
Ed Tanousbb679322022-05-16 16:10:00 -0700435 if (message.is_method_error())
436 {
437 std::cerr << "callback method error\n";
438 return;
439 }
Qiang XUe28d1fa2019-02-27 13:50:56 +0800440
Ed Tanousbb679322022-05-16 16:10:00 -0700441 std::cout << "rescan due to configuration change \n";
Chau Lycebb28c2022-10-21 10:01:52 +0000442 createSensorsFromConfig(io, objServer, systemBus, intrusionSensor);
Ed Tanousbb679322022-05-16 16:10:00 -0700443 };
Qiang XUe28d1fa2019-02-27 13:50:56 +0800444
Zev Weiss214d9712022-08-12 12:54:31 -0700445 std::vector<std::unique_ptr<sdbusplus::bus::match_t>> matches =
446 setupPropertiesChangedMatches(
447 *systemBus, std::to_array<const char*>({sensorType}), eventHandler);
Qiang XUe28d1fa2019-02-27 13:50:56 +0800448
Lei YUdd68d4a2021-03-16 22:17:23 +0800449 if (initializeLanStatus(systemBus))
450 {
451 // add match to monitor lan status change
Patrick Williams92f8f512022-07-22 19:26:55 -0500452 sdbusplus::bus::match_t lanStatusMatch(
453 static_cast<sdbusplus::bus_t&>(*systemBus),
Lei YUdd68d4a2021-03-16 22:17:23 +0800454 "type='signal', member='PropertiesChanged',"
455 "arg0namespace='org.freedesktop.network1.Link'",
Patrick Williams92f8f512022-07-22 19:26:55 -0500456 [](sdbusplus::message_t& msg) { processLanStatusChange(msg); });
Lei YUdd68d4a2021-03-16 22:17:23 +0800457
458 // add match to monitor entity manager signal about nic name config
459 // change
Patrick Williams92f8f512022-07-22 19:26:55 -0500460 sdbusplus::bus::match_t lanConfigMatch(
461 static_cast<sdbusplus::bus_t&>(*systemBus),
Lei YUdd68d4a2021-03-16 22:17:23 +0800462 "type='signal', member='PropertiesChanged',path_namespace='" +
Zev Weiss054aad82022-08-18 01:37:34 -0700463 std::string(inventoryPath) + "',arg0namespace='" +
464 configInterfaceName(nicType) + "'",
Patrick Williams92f8f512022-07-22 19:26:55 -0500465 [&systemBus](sdbusplus::message_t& msg) {
Ed Tanousbb679322022-05-16 16:10:00 -0700466 if (msg.is_method_error())
467 {
468 std::cerr << "callback method error\n";
469 return;
470 }
471 getNicNameInfo(systemBus);
Lei YUdd68d4a2021-03-16 22:17:23 +0800472 });
473 }
Qiang XU88b7f282019-08-14 22:51:43 +0800474
Qiang XUe28d1fa2019-02-27 13:50:56 +0800475 io.run();
476
477 return 0;
478}