only called from the SD
| 1614 | |
| 1615 | // only called from the SD |
| 1616 | void routing_manager_impl::add_routing_info(service_t _service, instance_t _instance, major_version_t _major, minor_version_t _minor, |
| 1617 | ttl_t _ttl, const boost::asio::ip::address& _reliable_address, uint16_t _reliable_port, |
| 1618 | const boost::asio::ip::address& _unreliable_address, uint16_t _unreliable_port) { |
| 1619 | |
| 1620 | if (is_suspended()) { |
| 1621 | VSOMEIP_INFO_P << "We are suspended --> do nothing."; |
| 1622 | return; |
| 1623 | } |
| 1624 | |
| 1625 | // Create/Update service info |
| 1626 | std::shared_ptr<serviceinfo> its_info(find_service(_service, _instance)); |
| 1627 | if (!its_info) { |
| 1628 | boost::asio::ip::address its_unicast_address = configuration_->get_unicast_address(); |
| 1629 | bool is_local(false); |
| 1630 | if (_reliable_port != ILLEGAL_PORT && its_unicast_address == _reliable_address) |
| 1631 | is_local = true; |
| 1632 | else if (_unreliable_port != ILLEGAL_PORT && its_unicast_address == _unreliable_address) |
| 1633 | is_local = true; |
| 1634 | |
| 1635 | its_info = create_service_info(_service, _instance, _major, _minor, _ttl, is_local); |
| 1636 | init_service_info(_service, _instance, is_local); |
| 1637 | } else if (its_info->is_local()) { |
| 1638 | // We received a service info for a service which is already offered locally |
| 1639 | VSOMEIP_ERROR_P << "Rejecting routing info. Remote: " |
| 1640 | << ((_reliable_port != ILLEGAL_PORT) ? _reliable_address.to_string() : _unreliable_address.to_string()) |
| 1641 | << " is trying to offer [" << hex4(_service) << "." << hex4(_instance) << "." << static_cast<std::uint32_t>(_major) |
| 1642 | << "." << _minor << "] on port " << ((_reliable_port != ILLEGAL_PORT) ? _reliable_port : _unreliable_port) |
| 1643 | << " offered previously on this node: [" << hex4(_service) << "." << hex4(_instance) << "." |
| 1644 | << static_cast<std::uint32_t>(its_info->get_major()) << "." << its_info->get_minor() << "]"; |
| 1645 | return; |
| 1646 | } else { |
| 1647 | its_info->set_ttl(_ttl); |
| 1648 | } |
| 1649 | |
| 1650 | // Check whether remote services are unchanged |
| 1651 | bool is_reliable_known(false); |
| 1652 | bool is_unreliable_known(false); |
| 1653 | ep_mgr_impl_->is_remote_service_known(_service, _instance, _major, _minor, _reliable_address, _reliable_port, &is_reliable_known, |
| 1654 | _unreliable_address, _unreliable_port, &is_unreliable_known); |
| 1655 | |
| 1656 | bool udp_inserted(false); |
| 1657 | // Add endpoint(s) if necessary |
| 1658 | if (_reliable_port != ILLEGAL_PORT && !is_reliable_known) { |
| 1659 | std::shared_ptr<endpoint_definition> endpoint_def_tcp = |
| 1660 | endpoint_definition::get(_reliable_address, _reliable_port, true, _service, _instance); |
| 1661 | if (_unreliable_port != ILLEGAL_PORT && !is_unreliable_known) { |
| 1662 | std::shared_ptr<endpoint_definition> endpoint_def_udp = |
| 1663 | endpoint_definition::get(_unreliable_address, _unreliable_port, false, _service, _instance); |
| 1664 | ep_mgr_impl_->add_remote_service_info(_service, _instance, endpoint_def_tcp, endpoint_def_udp); |
| 1665 | udp_inserted = true; |
| 1666 | } else { |
| 1667 | ep_mgr_impl_->add_remote_service_info(_service, _instance, endpoint_def_tcp); |
| 1668 | } |
| 1669 | |
| 1670 | // check if service was requested and establish TCP connection if necessary |
| 1671 | { |
| 1672 | bool connected(false); |
| 1673 | std::scoped_lock its_lock_inner{requested_services_mutex_}; |
no test coverage detected