///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
| 85 | |
| 86 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 87 | void FSecure::C3::Core::GateRelay::PostCommandToPeripheral(ByteView command, RouteId routeId) |
| 88 | { |
| 89 | // Check if Peripheral is attached to Gateway. |
| 90 | if (routeId.GetAgentId() == GetAgentId()) |
| 91 | { |
| 92 | if (auto peripheral = m_Devices.Find([&](auto const& e) {auto sp = e.lock(); return sp && sp->GetDid() == routeId.GetInterfaceId(); }).lock(); peripheral) |
| 93 | return peripheral->OnCommandFromConnector(command); |
| 94 | else |
| 95 | throw std::runtime_error{ "Couldn't find Gateway's recipient Peripheral." }; |
| 96 | } |
| 97 | |
| 98 | auto route = FindRoute(routeId.GetAgentId()); |
| 99 | if (!route) |
| 100 | throw std::runtime_error{ "Unknown route." }; |
| 101 | |
| 102 | auto device = route->m_Channel.lock(); |
| 103 | if (!device) |
| 104 | throw std::runtime_error{ "Route was unexpectedly closed." }; |
| 105 | |
| 106 | auto agent = m_Profiler->Get().m_Gateway.m_Agents.Find(routeId.GetAgentId()); |
| 107 | if (!agent) |
| 108 | throw std::runtime_error{ "Unknown agent." }; |
| 109 | |
| 110 | auto query = ProceduresG2X::DeliverToBinder::Create(route->m_RouteId, m_Signature, agent->m_EncryptionKey, m_DecryptionKey, routeId.GetInterfaceId(), command); |
| 111 | LockAndSendPacket(query->ComposeQueryPacket(), device); |
| 112 | } |
| 113 | |
| 114 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 115 | void FSecure::C3::Core::GateRelay::RunApiBrige(std::string_view apiBrigdeIp, std::uint16_t apiBrigdePort) noexcept |
no test coverage detected