| 1039 | } |
| 1040 | |
| 1041 | std::shared_ptr<boardnet_endpoint> endpoint_manager_impl::create_remote_client(service_t _service, instance_t _instance, bool _reliable) { |
| 1042 | std::shared_ptr<boardnet_endpoint> its_endpoint; |
| 1043 | std::shared_ptr<endpoint_definition> its_endpoint_def; |
| 1044 | uint16_t its_local_port; |
| 1045 | |
| 1046 | boost::asio::ip::address its_remote_address; |
| 1047 | uint16_t its_remote_port = ILLEGAL_PORT; |
| 1048 | |
| 1049 | if (auto found_si = remote_service_info_.find({_service, _instance}); found_si != remote_service_info_.end()) { |
| 1050 | if (auto found_reliability = found_si->second.find(_reliable); found_reliability != found_si->second.end()) { |
| 1051 | its_endpoint_def = found_reliability->second; |
| 1052 | its_remote_address = its_endpoint_def->get_address(); |
| 1053 | its_remote_port = its_endpoint_def->get_port(); |
| 1054 | } |
| 1055 | } |
| 1056 | |
| 1057 | if (its_remote_port != ILLEGAL_PORT) { |
| 1058 | // if client port range for remote service port range is configured |
| 1059 | // and remote port is in range, determine unused client port |
| 1060 | std::map<bool, std::set<port_t>> its_used_client_ports; |
| 1061 | get_used_client_ports(its_remote_address, its_remote_port, its_used_client_ports); |
| 1062 | if (configuration_->get_client_port(_service, _instance, its_remote_port, _reliable, its_used_client_ports, its_local_port)) { |
| 1063 | if (its_endpoint_def) { |
| 1064 | its_endpoint = create_client_endpoint(its_remote_address, its_local_port, its_remote_port, _reliable); |
| 1065 | } |
| 1066 | |
| 1067 | if (its_endpoint) { |
| 1068 | request_used_client_port(its_remote_address, its_remote_port, _reliable, its_local_port); |
| 1069 | |
| 1070 | service_instances_[_service][its_endpoint.get()] = _instance; |
| 1071 | remote_services_[{_service, _instance}][_reliable] = its_endpoint; |
| 1072 | |
| 1073 | partition_id_t its_partition = configuration_->get_partition_id(_service, _instance); |
| 1074 | client_endpoints_[its_endpoint_def->get_address()][its_endpoint_def->get_port()][_reliable][its_partition] = its_endpoint; |
| 1075 | // Set the basic route to the service in the service info |
| 1076 | auto found_service_info = router_->find_service(_service, _instance); |
| 1077 | if (found_service_info) { |
| 1078 | found_service_info->set_endpoint(its_endpoint, _reliable); |
| 1079 | } |
| 1080 | VSOMEIP_INFO_P << its_endpoint_def->get_address().to_string() << ":" << its_endpoint_def->get_port() |
| 1081 | << " reliable: " << _reliable << " using local port: " << its_local_port; |
| 1082 | } |
| 1083 | } |
| 1084 | } |
| 1085 | return its_endpoint; |
| 1086 | } |
| 1087 | |
| 1088 | std::shared_ptr<boardnet_endpoint> endpoint_manager_impl::create_client_endpoint(const boost::asio::ip::address& _address, |
| 1089 | uint16_t _local_port, uint16_t _remote_port, |
nothing calls this directly
no test coverage detected