This repository has been archived by the owner on Oct 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
mctp_impl.cpp
722 lines (667 loc) · 26.3 KB
/
mctp_impl.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
/*
// Copyright (c) 2021 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
*/
#include "mctp_impl.hpp"
#include "dbus_cb.hpp"
#include "service_monitor.hpp"
#include <boost/algorithm/string.hpp>
#include <boost/container/flat_map.hpp>
#include <phosphor-logging/log.hpp>
#include <sdbusplus/asio/connection.hpp>
#include <sdbusplus/bus/match.hpp>
#include <unordered_set>
template <typename T1, typename T2>
using DictType = boost::container::flat_map<T1, T2>;
using MctpPropertiesVariantType =
std::variant<uint16_t, int16_t, int32_t, uint32_t, bool, std::string,
uint8_t, std::vector<uint8_t>>;
template <typename Property>
static auto
readPropertyValue(sdbusplus::bus::bus& bus, const std::string& service,
const std::string& path, const std::string& interface,
const std::string& property)
{
phosphor::logging::log<phosphor::logging::level::DEBUG>(
(std::string("Reading ") + service + " " + path + " " + interface +
" " + property)
.c_str());
auto msg = bus.new_method_call(service.c_str(), path.c_str(),
"org.freedesktop.DBus.Properties", "Get");
msg.append(interface.c_str(), property.c_str());
auto reply = bus.call(msg);
std::variant<Property> v;
reply.read(v);
return std::get<Property>(v);
}
static auto registerSignalHandler(sdbusplus::bus::bus& bus,
sd_bus_message_handler_t handler, void* ctx,
const std::string& interface,
const std::string& name,
const std::string& sender,
const std::string& arg0)
{
std::string matcherString = sdbusplus::bus::match::rules::type::signal();
matcherString += sdbusplus::bus::match::rules::interface(interface);
matcherString += sdbusplus::bus::match::rules::member(name);
if (!sender.empty())
{
matcherString += sdbusplus::bus::match::rules::sender(sender);
}
if (!arg0.empty())
{
matcherString += sdbusplus::bus::match::rules::argN(0, arg0);
}
return std::make_unique<sdbusplus::bus::match::match>(bus, matcherString,
handler, ctx);
}
namespace mctpw
{
void MCTPImpl::detectMctpEndpointsAsync(StatusCallback&& registerCB)
{
boost::asio::spawn(connection->get_io_context(),
[&, this](boost::asio::yield_context yield) {
auto ec = detectMctpEndpoints(yield);
if (registerCB)
{
registerCB(ec, this);
}
});
}
void MCTPImpl::triggerMCTPDeviceDiscovery(const eid_t dstEId)
{
auto it = this->endpointMap.find(dstEId);
if (this->endpointMap.end() == it)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"triggerMCTPDeviceDiscovery: EID not found in end point map",
phosphor::logging::entry("EID=%d", dstEId));
return;
}
connection->async_method_call(
[](boost::system::error_code ec) {
if (ec)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
("MCTP device discovery error: " + ec.message()).c_str());
}
},
it->second.second, "/xyz/openbmc_project/mctp",
"xyz.openbmc_project.MCTP.Base", "TriggerDeviceDiscovery");
}
int MCTPImpl::reserveBandwidth(boost::asio::yield_context yield,
const eid_t dstEId, const uint16_t timeout)
{
auto it = this->endpointMap.find(dstEId);
if (this->endpointMap.end() == it)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
("reserveBandwidth: EID not found in end point map" +
std::to_string(dstEId))
.c_str());
return -1;
}
boost::system::error_code ec;
int status = connection->yield_method_call<int>(
yield, ec, it->second.second, "/xyz/openbmc_project/mctp",
"xyz.openbmc_project.MCTP.Base", "ReserveBandwidth", dstEId, timeout);
if (ec)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
("ReserveBandwidth: failed for EID: " + std::to_string(dstEId) +
" " + ec.message())
.c_str());
return -1;
}
else if (status < 0)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
("ReserveBandwidth: failed for EID: " + std::to_string(dstEId) +
" rc: " + std::to_string(status))
.c_str());
}
return status;
}
int MCTPImpl::releaseBandwidth(boost::asio::yield_context yield,
const eid_t dstEId)
{
auto it = this->endpointMap.find(dstEId);
if (this->endpointMap.end() == it)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
("ReleaseBandwidth: EID not found in end point map" +
std::to_string(dstEId))
.c_str());
return -1;
}
boost::system::error_code ec;
int status = connection->yield_method_call<int>(
yield, ec, it->second.second, "/xyz/openbmc_project/mctp",
"xyz.openbmc_project.MCTP.Base", "ReleaseBandwidth", dstEId);
if (ec)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
("ReleaseBandwidth: failed for EID: " + std::to_string(dstEId) +
" " + ec.message())
.c_str());
return -1;
}
else if (status < 0)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
("ReleaseBandwidth: failed for EID: " + std::to_string(dstEId) +
" rc: " + std::to_string(status))
.c_str());
}
return status;
}
void MCTPImpl::unRegisterListeners(const std::string& serviceName)
{
auto itr = matchers.find(serviceName);
if (itr != matchers.end())
{
matchers.erase(itr);
phosphor::logging::log<phosphor::logging::level::INFO>(
(std::string("unRegisterListeners: ") + serviceName).c_str());
}
else
{
phosphor::logging::log<phosphor::logging::level::INFO>(
(std::string("unRegisterListeners: ") + serviceName +
" not present")
.c_str());
}
}
void MCTPImpl::registerListeners(const std::string& serviceName)
{
std::vector<std::unique_ptr<sdbusplus::bus::match::match>> signalMatchers;
signalMatchers.push_back(registerSignalHandler(
static_cast<sdbusplus::bus::bus&>(*connection),
mctpw::onPropertiesChanged, static_cast<void*>(this),
"org.freedesktop.DBus.Properties", "PropertiesChanged", serviceName,
""));
signalMatchers.push_back(registerSignalHandler(
static_cast<sdbusplus::bus::bus&>(*connection),
mctpw::onInterfacesAdded, static_cast<void*>(this),
"org.freedesktop.DBus.ObjectManager", "InterfacesAdded", serviceName,
""));
signalMatchers.push_back(registerSignalHandler(
static_cast<sdbusplus::bus::bus&>(*connection),
mctpw::onInterfacesRemoved, static_cast<void*>(this),
"org.freedesktop.DBus.ObjectManager", "InterfacesRemoved", serviceName,
""));
signalMatchers.push_back(registerSignalHandler(
static_cast<sdbusplus::bus::bus&>(*connection),
mctpw::onMessageReceivedSignal, static_cast<void*>(this),
"xyz.openbmc_project.MCTP.Base", "MessageReceivedSignal", serviceName,
""));
// Saving all matchers using key as servicename
matchers.emplace(serviceName, std::move(signalMatchers));
}
boost::system::error_code
MCTPImpl::detectMctpEndpoints(boost::asio::yield_context yield)
{
boost::system::error_code ec =
boost::system::errc::make_error_code(boost::system::errc::success);
auto bus_vector = findBusByBindingType(yield);
if (bus_vector)
{
endpointMap = buildMatchingEndpointMap(yield, bus_vector.value());
for (auto& [busId, serviceName] : bus_vector.value())
{
registerListeners(serviceName);
}
}
listenForNewMctpServices();
listenForRemovedMctpServices();
return ec;
}
int MCTPImpl::getBusId(const std::string& serviceName)
{
try
{
int bus = -1;
if (config.bindingType == mctpw::BindingType::mctpOverSmBus)
{
std::string pv = readPropertyValue<std::string>(
static_cast<sdbusplus::bus::bus&>(*connection), serviceName,
"/xyz/openbmc_project/mctp",
mctpw::MCTPWrapper::bindingToInterface.at(config.bindingType),
"BusPath");
// sample buspath like /dev/i2c-2
/* format of BusPath:path-bus */
std::vector<std::string> splitted;
boost::split(splitted, pv, boost::is_any_of("-"));
if (splitted.size() == 2)
{
try
{
bus = std::stoi(splitted[1]);
}
catch (std::exception& e)
{
throw std::runtime_error(
std::string("Invalid buspath on ") + pv);
}
}
}
else if (config.bindingType == mctpw::BindingType::mctpOverPcieVdm)
{
bus = readPropertyValue<uint16_t>(
static_cast<sdbusplus::bus::bus&>(*connection), serviceName,
"/xyz/openbmc_project/mctp",
mctpw::MCTPWrapper::bindingToInterface.at(config.bindingType),
"BDF");
}
else
{
throw std::invalid_argument("Unsupported binding type");
}
return bus;
}
catch (const std::exception& e)
{
throw boost::system::system_error(
boost::system::errc::make_error_code(boost::system::errc::io_error),
(std::string("Error in getting Bus property from ") + serviceName +
". " + e.what()));
}
}
std::optional<std::vector<std::pair<unsigned, std::string>>>
MCTPImpl::findBusByBindingType(boost::asio::yield_context yield)
{
boost::system::error_code ec;
std::vector<std::pair<unsigned, std::string>> buses;
DictType<std::string, std::vector<std::string>> services;
std::vector<std::string> interfaces;
try
{
interfaces.push_back(
mctpw::MCTPWrapper::bindingToInterface.at(config.bindingType));
// find the services, with their interfaces, that implement a
// certain object path
services = connection->yield_method_call<decltype(services)>(
yield, ec, "xyz.openbmc_project.ObjectMapper",
"/xyz/openbmc_project/object_mapper",
"xyz.openbmc_project.ObjectMapper", "GetObject",
"/xyz/openbmc_project/mctp", interfaces);
if (ec)
{
throw std::runtime_error(
(std::string("Error getting mctp services. ") + ec.message())
.c_str());
}
for (const auto& [service, intfs] : services)
{
try
{
int bus = this->getBusId(service);
buses.emplace_back(bus, service);
}
catch (const std::exception& e)
{
phosphor::logging::log<phosphor::logging::level::WARNING>(
e.what());
}
}
// buses will contain list of {busid servicename}. Sample busid may
// be from i2cdev-2
return buses;
}
catch (const std::exception& e)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
(std::string("findBusByBindingType: ") + e.what()).c_str());
return std::nullopt;
}
}
/* Return format:
* map<Eid, pair<bus, service_name_string>>
*/
MCTPImpl::EndpointMap MCTPImpl::buildMatchingEndpointMap(
boost::asio::yield_context yield,
std::vector<std::pair<unsigned, std::string>>& buses)
{
std::unordered_map<uint8_t, std::pair<unsigned, std::string>> eids;
for (auto& bus : buses)
{
boost::system::error_code ec;
DictType<sdbusplus::message::object_path,
DictType<std::string,
DictType<std::string, MctpPropertiesVariantType>>>
values;
// get all objects, interfaces and properties in a single method
// call DICT<OBJPATH,DICT<STRING,DICT<STRING,VARIANT>>>
// objpath_interfaces_and_properties
values = connection->yield_method_call<decltype(values)>(
yield, ec, bus.second.c_str(), "/xyz/openbmc_project/mctp",
"org.freedesktop.DBus.ObjectManager", "GetManagedObjects");
if (ec)
{
phosphor::logging::log<phosphor::logging::level::WARNING>(
(std::string("Error getting managed objects on ") + bus.second +
". Bus " + std::to_string(bus.first))
.c_str());
continue;
}
for (const auto& [objectPath, interfaces] : values)
{
DictType<std::string,
DictType<std::string, MctpPropertiesVariantType>>
interface;
if (interfaces.find("xyz.openbmc_project.MCTP.Endpoint") ==
interfaces.end())
{
continue;
}
try
{
/*SupportedMessageTypes interface is mandatory*/
auto& msgIf = interfaces.at(
"xyz.openbmc_project.MCTP.SupportedMessageTypes");
MctpPropertiesVariantType pv;
pv = msgIf.at(msgTypeToPropertyName.at(config.type));
if (std::get<bool>(pv) == false)
{
continue;
}
if (mctpw::MessageType::vdpci == config.type)
{
if (config.vendorId)
{
static const char* vdMsgTypeInterface =
"xyz.openbmc_project.MCTP.PCIVendorDefined";
auto vendorIdStr = readPropertyValue<std::string>(
*connection, bus.second.c_str(), objectPath.str,
vdMsgTypeInterface, "VendorID");
uint16_t vendorId = static_cast<uint16_t>(
std::stoi(vendorIdStr, nullptr, 16));
if (vendorId != be16toh(*config.vendorId))
{
phosphor::logging::log<
phosphor::logging::level::INFO>(
("VendorID not matching for " + objectPath.str)
.c_str());
continue;
}
if (config.vendorMessageType)
{
auto msgTypes =
readPropertyValue<std::vector<uint16_t>>(
*connection, bus.second.c_str(),
objectPath.str, vdMsgTypeInterface,
"MessageTypeProperty");
auto itMsgType = std::find(
msgTypes.begin(), msgTypes.end(),
be16toh(config.vendorMessageType->value));
if (msgTypes.end() == itMsgType)
{
phosphor::logging::log<
phosphor::logging::level::INFO>(
("Vendor Message Type not matching for " +
objectPath.str)
.c_str());
continue;
}
}
}
else
{
if (config.vendorMessageType)
{
phosphor::logging::log<
phosphor::logging::level::ERR>(
"Vendor Message Type matching is not allowed "
"when Vendor ID is not set");
continue;
}
}
}
/* format of of endpoint path: path/Eid */
std::vector<std::string> splitted;
boost::split(splitted, objectPath.str, boost::is_any_of("/"));
if (splitted.size())
{
/* take the last element and convert it to eid */
uint8_t eid = static_cast<eid_t>(
std::stoi(splitted[splitted.size() - 1]));
eids[eid] = bus;
}
}
catch (std::exception& e)
{
phosphor::logging::log<phosphor::logging::level::ERR>(e.what());
}
}
}
return eids;
}
void MCTPImpl::sendReceiveAsync(ReceiveCallback callback, eid_t dstEId,
const ByteArray& request,
std::chrono::milliseconds timeout)
{
ByteArray response;
auto it = this->endpointMap.find(dstEId);
if (this->endpointMap.end() == it)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"SendReceiveAsync: Eid not found in end point map",
phosphor::logging::entry("EID=%d", dstEId));
boost::system::error_code ec =
boost::system::errc::make_error_code(boost::system::errc::io_error);
if (callback)
{
callback(ec, response);
}
return;
}
connection->async_method_call(
callback, it->second.second, "/xyz/openbmc_project/mctp",
"xyz.openbmc_project.MCTP.Base", "SendReceiveMctpMessagePayload",
dstEId, request, static_cast<uint16_t>(timeout.count()));
}
std::pair<boost::system::error_code, ByteArray>
MCTPImpl::sendReceiveYield(boost::asio::yield_context yield, eid_t dstEId,
const ByteArray& request,
std::chrono::milliseconds timeout)
{
auto receiveResult = std::make_pair(
boost::system::errc::make_error_code(boost::system::errc::success),
ByteArray());
auto it = this->endpointMap.find(dstEId);
if (this->endpointMap.end() == it)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"SendReceiveYield: Eid not found in end point map",
phosphor::logging::entry("EID=%d", dstEId));
receiveResult.first =
boost::system::errc::make_error_code(boost::system::errc::io_error);
return receiveResult;
}
receiveResult.second = connection->yield_method_call<ByteArray>(
yield, receiveResult.first, it->second.second,
"/xyz/openbmc_project/mctp", "xyz.openbmc_project.MCTP.Base",
"SendReceiveMctpMessagePayload", dstEId, request,
static_cast<uint16_t>(timeout.count()));
return receiveResult;
}
std::pair<boost::system::error_code, ByteArray>
MCTPImpl::sendReceiveBlocked(eid_t dstEId, const ByteArray& request,
std::chrono::milliseconds timeout)
{
auto receiveResult = std::make_pair(
boost::system::errc::make_error_code(boost::system::errc::success),
ByteArray());
auto it = this->endpointMap.find(dstEId);
if (this->endpointMap.end() == it)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"SendReceiveBlocked: Eid not found in end point map",
phosphor::logging::entry("EID=%d", dstEId));
receiveResult.first =
boost::system::errc::make_error_code(boost::system::errc::io_error);
return receiveResult;
}
auto msg = connection->new_method_call(
it->second.second.c_str(), "/xyz/openbmc_project/mctp",
"xyz.openbmc_project.MCTP.Base", "SendReceiveMctpMessagePayload");
msg.append(dstEId);
msg.append(request);
msg.append(static_cast<uint16_t>(timeout.count()));
auto reply = connection->call(msg);
if (reply.is_method_error())
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"SendReceiveBlocked: Error in method call ",
phosphor::logging::entry("EID=%d", dstEId));
receiveResult.first =
boost::system::errc::make_error_code(boost::system::errc::io_error);
return receiveResult;
}
reply.read(receiveResult.second);
return receiveResult;
}
void MCTPImpl::sendAsync(const SendCallback& callback, const eid_t dstEId,
const uint8_t msgTag, const bool tagOwner,
const ByteArray& request)
{
auto it = this->endpointMap.find(dstEId);
if (this->endpointMap.end() == it)
{
boost::system::error_code ec =
boost::system::errc::make_error_code(boost::system::errc::io_error);
phosphor::logging::log<phosphor::logging::level::ERR>(
"sendAsync: Eid not found in end point map",
phosphor::logging::entry("EID=%d", dstEId));
if (callback)
{
callback(ec, -1);
}
return;
}
connection->async_method_call(
callback, it->second.second, "/xyz/openbmc_project/mctp",
"xyz.openbmc_project.MCTP.Base", "SendMctpMessagePayload", dstEId,
msgTag, tagOwner, request);
}
std::pair<boost::system::error_code, int>
MCTPImpl::sendYield(boost::asio::yield_context& yield, const eid_t dstEId,
const uint8_t msgTag, const bool tagOwner,
const ByteArray& request)
{
auto it = this->endpointMap.find(dstEId);
if (this->endpointMap.end() == it)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"sendYield: Eid not found in end point map",
phosphor::logging::entry("EID=%d", dstEId));
return std::make_pair(
boost::system::errc::make_error_code(boost::system::errc::io_error),
-1);
}
boost::system::error_code ec =
boost::system::errc::make_error_code(boost::system::errc::success);
int status = connection->yield_method_call<int>(
yield, ec, it->second.second, "/xyz/openbmc_project/mctp",
"xyz.openbmc_project.MCTP.Base", "SendMctpMessagePayload", dstEId,
msgTag, tagOwner, request);
return std::make_pair(ec, status);
}
void MCTPImpl::addToEidMap(boost::asio::yield_context yield,
const std::string& serviceName)
{
int busID = getBusId(serviceName);
std::vector<std::pair<unsigned, std::string>> buses;
buses.emplace_back(busID, serviceName);
auto eidMap = buildMatchingEndpointMap(yield, buses);
this->endpointMap.insert(eidMap.begin(), eidMap.end());
}
size_t MCTPImpl::eraseDevice(eid_t eid)
{
return endpointMap.erase(eid);
}
std::optional<std::string> MCTPImpl::getDeviceLocation(const eid_t eid)
{
auto it = this->endpointMap.find(eid);
if (it == this->endpointMap.end())
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"getDeviceLocation: Eid not found in end point map",
phosphor::logging::entry("EID=%d", eid));
return std::nullopt;
}
try
{
auto locationCode = readPropertyValue<std::string>(
static_cast<sdbusplus::bus::bus&>(*connection), it->second.second,
"/xyz/openbmc_project/mctp/device/" + std::to_string(eid),
"xyz.openbmc_project.Inventory.Decorator.LocationCode",
"LocationCode");
return locationCode.empty() ? std::nullopt
: std::make_optional(locationCode);
}
catch (const std::exception& e)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
("Error in getting Physical.Location property from " +
it->second.second + ". " + e.what())
.c_str());
return std::nullopt;
}
}
void MCTPImpl::listenForNewMctpServices()
{
static const std::string matchRule =
"type='signal',member='InterfacesAdded',interface='org.freedesktop."
"DBus.ObjectManager',path='/xyz/openbmc_project/"
"mctp'";
this->monitorServiceMatchers.emplace(
"InterfacesAdded",
std::make_unique<sdbusplus::bus::match::match>(
*connection, matchRule, internal::NewServiceCallback(*this)));
phosphor::logging::log<phosphor::logging::level::DEBUG>(
"Wrapper: Listening for new MCTP services");
}
void MCTPImpl::listenForRemovedMctpServices()
{
static const std::string rule =
"type='signal',member='InterfacesRemoved',interface='org.freedesktop."
"DBus.ObjectManager',path='/xyz/openbmc_project/"
"mctp'";
this->monitorServiceMatchers.emplace(
"InterfacesRemoved",
std::make_unique<sdbusplus::bus::match::match>(
*connection, rule, internal::DeleteServiceCallback(*this)));
phosphor::logging::log<phosphor::logging::level::DEBUG>(
"Wrapper: Listening for Removed MCTP services");
}
MCTPImpl::MCTPImpl(boost::asio::io_context& ioContext,
const MCTPConfiguration& configIn,
const ReconfigurationCallback& networkChangeCb,
const ReceiveMessageCallback& rxCb) :
connection(std::make_shared<sdbusplus::asio::connection>(ioContext)),
config(configIn), networkChangeCallback(networkChangeCb),
receiveCallback(rxCb)
{
}
MCTPImpl::MCTPImpl(std::shared_ptr<sdbusplus::asio::connection> conn,
const MCTPConfiguration& configIn,
const ReconfigurationCallback& networkChangeCb,
const ReceiveMessageCallback& rxCb) :
connection(conn),
config(configIn), networkChangeCallback(networkChangeCb),
receiveCallback(rxCb)
{
}
} // namespace mctpw