| 1165 | } |
| 1166 | |
| 1167 | void routing_manager_stub::handle_requests(const client_t _client, std::set<protocol::service>& _requests) { |
| 1168 | |
| 1169 | if (_requests.empty()) |
| 1170 | return; |
| 1171 | |
| 1172 | boost::asio::ip::address its_address; |
| 1173 | port_t its_port; |
| 1174 | |
| 1175 | std::vector<protocol::routing_info_entry> its_entries; |
| 1176 | std::scoped_lock its_guard{routing_info_mutex_}; |
| 1177 | |
| 1178 | for (auto const& request : _requests) { |
| 1179 | service_requests_[_client][{request.service_, request.instance_}] = std::make_pair(request.major_, request.minor_); |
| 1180 | if (_client == VSOMEIP_ROUTING_CLIENT) { |
| 1181 | continue; |
| 1182 | } |
| 1183 | std::set<client_t> its_clients = host_->find_local_clients(request.service_, request.instance_); |
| 1184 | // insert VSOMEIP_ROUTING_CLIENT to check whether service is remotely offered |
| 1185 | its_clients.insert(VSOMEIP_ROUTING_CLIENT); |
| 1186 | for (const client_t c : its_clients) { |
| 1187 | if (const auto found_client = routing_info_.find(c); found_client != routing_info_.end()) { |
| 1188 | if (request.instance_ == ANY_INSTANCE) { |
| 1189 | for (const auto& [si, version] : found_client->second) { |
| 1190 | if (si.service() == request.service_) { |
| 1191 | protocol::routing_info_entry its_entry; |
| 1192 | its_entry.set_type(protocol::routing_info_entry_type_e::RIE_ADD_SERVICE_INSTANCE); |
| 1193 | its_entry.set_client(c); |
| 1194 | if (host_->get_endpoint_manager()->get_guest(c, its_address, its_port)) { |
| 1195 | its_entry.set_address(its_address); |
| 1196 | its_entry.set_port(its_port); |
| 1197 | } |
| 1198 | its_entry.add_service({request.service_, si.instance(), version.first, version.second}); |
| 1199 | its_entries.emplace_back(its_entry); |
| 1200 | } |
| 1201 | } |
| 1202 | } else { |
| 1203 | if (auto found_si = found_client->second.find({request.service_, request.instance_}); |
| 1204 | found_si != found_client->second.end()) { |
| 1205 | protocol::routing_info_entry its_entry; |
| 1206 | its_entry.set_type(protocol::routing_info_entry_type_e::RIE_ADD_SERVICE_INSTANCE); |
| 1207 | its_entry.set_client(c); |
| 1208 | if (host_->get_endpoint_manager()->get_guest(c, its_address, its_port)) { |
| 1209 | its_entry.set_address(its_address); |
| 1210 | its_entry.set_port(its_port); |
| 1211 | } |
| 1212 | its_entry.add_service({request.service_, request.instance_, found_si->second.first, found_si->second.second}); |
| 1213 | its_entries.emplace_back(its_entry); |
| 1214 | } |
| 1215 | } |
| 1216 | } |
| 1217 | } |
| 1218 | } |
| 1219 | |
| 1220 | if (!its_entries.empty()) { |
| 1221 | send_client_routing_info(_client, std::move(its_entries)); |
| 1222 | } |
| 1223 | } |
| 1224 |
no test coverage detected