diff options
-rw-r--r-- | Android.bp | 85 | ||||
-rw-r--r-- | implementation/configuration/include/configuration_plugin.hpp | 7 | ||||
-rw-r--r-- | implementation/configuration/include/internal_android.hpp | 4 | ||||
-rw-r--r-- | implementation/endpoints/include/client_endpoint.hpp | 7 | ||||
-rw-r--r-- | implementation/endpoints/include/endpoint.hpp | 7 | ||||
-rw-r--r-- | implementation/endpoints/src/client_endpoint_impl.cpp | 2 | ||||
-rw-r--r-- | implementation/endpoints/src/netlink_connector.cpp | 37 | ||||
-rw-r--r-- | implementation/endpoints/src/server_endpoint_impl.cpp | 3 | ||||
-rw-r--r-- | implementation/endpoints/src/udp_server_endpoint_impl.cpp | 3 | ||||
-rw-r--r-- | implementation/routing/src/routing_manager_proxy.cpp | 1 | ||||
-rw-r--r-- | implementation/runtime/src/runtime.cpp | 19 | ||||
-rwxr-xr-x | implementation/service_discovery/src/configuration_option_impl.cpp | 2 | ||||
-rw-r--r-- | implementation/service_discovery/src/service_discovery_impl.cpp | 16 | ||||
-rw-r--r-- | implementation/utility/include/utility.hpp | 8 | ||||
-rw-r--r-- | interface/vsomeip/plugin.hpp | 13 |
15 files changed, 181 insertions, 33 deletions
@@ -25,6 +25,18 @@ libvsomeip_sd_srcs = [ cc_defaults { name: "vsomeip_defaults", + + header_libs: [ + "libboost_headers", + ], + + local_include_dirs: [ + "interface", + "implementation/helper/1.70", + ], + + rtti: true, + cppflags: [ "-std=c++11", "-fexceptions", @@ -68,10 +80,13 @@ cc_library_shared { "interface" ], - shared_libs: [ + static_libs: [ "libboost_system", "libboost_thread", "libboost_filesystem", + ], + + shared_libs: [ "liblog", "libutils" ] @@ -119,7 +134,8 @@ cc_library_shared { ], shared_libs: [ - "libvsomeip3" + "libvsomeip3", + "liblog" ] } @@ -142,6 +158,71 @@ cc_library_shared { shared_libs: [ "libvsomeip3", + "liblog", "libboost_thread" ] } + +cc_defaults { + name: "vsomeip_example_defaults", + vendor: true, + owner: "ts", + + shared_libs: [ + "libvsomeip3" + ], +} + +cc_binary { + name: "vsomeip-helloworld-client", + defaults: ["vsomeip_example_defaults"], + + srcs: [ + "examples/hello_world/hello_world_client.cpp", + ], +} + +cc_binary { + name: "vsomeip-helloworld-service", + defaults: ["vsomeip_example_defaults"], + + srcs: [ + "examples/hello_world/hello_world_service.cpp", + ], +} + +cc_binary { + name: "vsomeip-notify-sample", + defaults: ["vsomeip_example_defaults"], + + srcs: [ + "examples/notify-sample.cpp", + ], +} + +cc_binary { + name: "vsomeip-request-sample", + defaults: ["vsomeip_example_defaults"], + + srcs: [ + "examples/request-sample.cpp", + ], +} + +cc_binary { + name: "vsomeip-response-sample", + defaults: ["vsomeip_example_defaults"], + + srcs: [ + "examples/response-sample.cpp", + ], +} + +cc_binary { + name: "vsomeip-subscribe-sample", + defaults: ["vsomeip_example_defaults"], + + srcs: [ + "examples/subscribe-sample.cpp", + ], +} diff --git a/implementation/configuration/include/configuration_plugin.hpp b/implementation/configuration/include/configuration_plugin.hpp index cbb4685..583c3d8 100644 --- a/implementation/configuration/include/configuration_plugin.hpp +++ b/implementation/configuration/include/configuration_plugin.hpp @@ -17,7 +17,12 @@ class configuration; class configuration_plugin { public: - virtual ~configuration_plugin() = default; + virtual ~configuration_plugin() +#ifndef ANDROID + {} +#else + ; +#endif virtual std::shared_ptr<configuration> get_configuration(const std::string &_name) = 0; }; diff --git a/implementation/configuration/include/internal_android.hpp b/implementation/configuration/include/internal_android.hpp index 28cbb5c..25ecb4e 100644 --- a/implementation/configuration/include/internal_android.hpp +++ b/implementation/configuration/include/internal_android.hpp @@ -19,11 +19,11 @@ #define VSOMEIP_ENV_CLIENTSIDELOGGING "VSOMEIP_CLIENTSIDELOGGING" #define VSOMEIP_ENV_BASE_PATH "VSOMEIP_BASE_PATH" -#define VSOMEIP_DEFAULT_CONFIGURATION_FILE "/etc/vsomeip.json" +#define VSOMEIP_DEFAULT_CONFIGURATION_FILE "/vendor/etc/vsomeip.json" #define VSOMEIP_LOCAL_CONFIGURATION_FILE "./vsomeip.json" #define VSOMEIP_MANDATORY_CONFIGURATION_FILES "vsomeip_std.json,vsomeip_app.json,vsomeip_plc.json,vsomeip_log.json,vsomeip_security.json,vsomeip_whitelist.json" -#define VSOMEIP_DEFAULT_CONFIGURATION_FOLDER "/etc/vsomeip" +#define VSOMEIP_DEFAULT_CONFIGURATION_FOLDER "/vendor/etc/vsomeip" #define VSOMEIP_DEBUG_CONFIGURATION_FOLDER "/var/opt/public/sin/vsomeip/" #define VSOMEIP_LOCAL_CONFIGURATION_FOLDER "./vsomeip" diff --git a/implementation/endpoints/include/client_endpoint.hpp b/implementation/endpoints/include/client_endpoint.hpp index ce872e8..3429a92 100644 --- a/implementation/endpoints/include/client_endpoint.hpp +++ b/implementation/endpoints/include/client_endpoint.hpp @@ -12,7 +12,12 @@ namespace vsomeip_v3 { class client_endpoint : public virtual endpoint { public: - virtual ~client_endpoint() {} + virtual ~client_endpoint() +#ifndef ANDROID + {} +#else + ; +#endif virtual bool get_remote_address(boost::asio::ip::address &_address) const = 0; virtual std::uint16_t get_remote_port() const = 0; diff --git a/implementation/endpoints/include/endpoint.hpp b/implementation/endpoints/include/endpoint.hpp index 452f92b..ccfe96b 100644 --- a/implementation/endpoints/include/endpoint.hpp +++ b/implementation/endpoints/include/endpoint.hpp @@ -22,7 +22,12 @@ public: typedef std::function<void()> error_handler_t; typedef std::function<void(const std::shared_ptr<endpoint>&, service_t)> prepare_stop_handler_t; - virtual ~endpoint() {} + virtual ~endpoint() +#ifndef ANDROID + {} +#else + ; +#endif virtual void start() = 0; virtual void prepare_stop(prepare_stop_handler_t _handler, diff --git a/implementation/endpoints/src/client_endpoint_impl.cpp b/implementation/endpoints/src/client_endpoint_impl.cpp index 434ed14..9b31cc1 100644 --- a/implementation/endpoints/src/client_endpoint_impl.cpp +++ b/implementation/endpoints/src/client_endpoint_impl.cpp @@ -612,7 +612,7 @@ typename endpoint_impl<Protocol>::cms_ret_e client_endpoint_impl<Protocol>::chec return endpoint_impl<Protocol>::cms_ret_e::MSG_WAS_SPLIT; } } - VSOMEIP_ERROR << "cei::check_message_size: Dropping to big message (" + VSOMEIP_ERROR << "cei::check_message_size: Dropping too big message (" << std::dec << _size << " Bytes). Maximum allowed message size is: " << endpoint_impl<Protocol>::max_message_size_ << " Bytes."; ret = endpoint_impl<Protocol>::cms_ret_e::MSG_TOO_BIG; diff --git a/implementation/endpoints/src/netlink_connector.cpp b/implementation/endpoints/src/netlink_connector.cpp index ce82e9f..ebd432d 100644 --- a/implementation/endpoints/src/netlink_connector.cpp +++ b/implementation/endpoints/src/netlink_connector.cpp @@ -17,6 +17,12 @@ namespace vsomeip_v3 { +namespace { + const std::uint32_t ifa_request_sequence = 1; + const std::uint32_t ifi_request_sequence = 2; + const std::uint32_t rt_request_sequence = 3; +} + void netlink_connector::register_net_if_changes_handler(const net_if_changed_handler_t& _handler) { handler_ = _handler; } @@ -181,9 +187,32 @@ void netlink_connector::receive_cbk(boost::system::error_code const &_error, } case NLMSG_ERROR: { struct nlmsgerr *errmsg = (nlmsgerr *)NLMSG_DATA(nlh); + if (errmsg->error == 0) { + // Ack from netlink + break; + } + VSOMEIP_ERROR << "netlink_connector::receive_cbk received " - "error message: " << std::dec << nlh->nlmsg_type + "error message: " << strerror(errmsg->error) + << " type " << std::dec << errmsg->msg.nlmsg_type << " seq " << errmsg->msg.nlmsg_seq; + + std::string request_type{}; + if (errmsg->msg.nlmsg_type == RTM_GETADDR && errmsg->msg.nlmsg_seq == ifa_request_sequence) { + request_type = "address request"; + send_ifa_request(); + } else if (errmsg->msg.nlmsg_type == RTM_GETLINK && errmsg->msg.nlmsg_seq == ifi_request_sequence) { + request_type = "link request"; + send_ifi_request(); + } else if (errmsg->msg.nlmsg_type == RTM_GETROUTE && errmsg->msg.nlmsg_seq == rt_request_sequence) { + request_type = "route request"; + send_rt_request(); + } + + if (!request_type.empty()) { + VSOMEIP_INFO << "Retrying netlink " << request_type; + } + break; } case NLMSG_DONE: @@ -251,7 +280,7 @@ void netlink_connector::send_ifa_request() { get_address_msg.nlhdr.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifaddrmsg)); get_address_msg.nlhdr.nlmsg_flags = NLM_F_REQUEST | NLM_F_ROOT; get_address_msg.nlhdr.nlmsg_type = RTM_GETADDR; - get_address_msg.nlhdr.nlmsg_seq = 1; + get_address_msg.nlhdr.nlmsg_seq = ifa_request_sequence; if (address_.is_v4()) { get_address_msg.addrmsg.ifa_family = AF_INET; } else { @@ -280,7 +309,7 @@ void netlink_connector::send_ifi_request() { get_link_msg.nlhdr.nlmsg_flags = NLM_F_REQUEST | NLM_F_ROOT; get_link_msg.nlhdr.nlmsg_type = RTM_GETLINK; get_link_msg.infomsg.ifi_family = AF_UNSPEC; - get_link_msg.nlhdr.nlmsg_seq = 2; + get_link_msg.nlhdr.nlmsg_seq = ifi_request_sequence; { std::lock_guard<std::mutex> its_lock(socket_mutex_); @@ -307,7 +336,7 @@ void netlink_connector::send_rt_request() { get_route_msg.nlhdr.nlmsg_len = NLMSG_LENGTH(sizeof(struct rtgenmsg)); get_route_msg.nlhdr.nlmsg_flags = NLM_F_REQUEST | NLM_F_DUMP; get_route_msg.nlhdr.nlmsg_type = RTM_GETROUTE; - get_route_msg.nlhdr.nlmsg_seq = 3; + get_route_msg.nlhdr.nlmsg_seq = rt_request_sequence; if (multicast_address_.is_v6()) { get_route_msg.routemsg.rtgen_family = AF_INET6; } else { diff --git a/implementation/endpoints/src/server_endpoint_impl.cpp b/implementation/endpoints/src/server_endpoint_impl.cpp index 90aea96..46e2397 100644 --- a/implementation/endpoints/src/server_endpoint_impl.cpp +++ b/implementation/endpoints/src/server_endpoint_impl.cpp @@ -466,7 +466,7 @@ typename endpoint_impl<Protocol>::cms_ret_e server_endpoint_impl<Protocol>::chec return endpoint_impl<Protocol>::cms_ret_e::MSG_WAS_SPLIT; } } - VSOMEIP_ERROR << "sei::send_intern: Dropping to big message (" << _size + VSOMEIP_ERROR << "sei::send_intern: Dropping too big message (" << _size << " Bytes). Maximum allowed message size is: " << endpoint_impl<Protocol>::max_message_size_ << " Bytes."; ret = endpoint_impl<Protocol>::cms_ret_e::MSG_TOO_BIG; @@ -632,6 +632,7 @@ void server_endpoint_impl<Protocol>::send_cbk( } if (found_service_msg) { ++stp_hndlr_iter; + found_service_msg = false; } else { // all messages of the to be stopped service have been sent auto handler = stp_hndlr_iter->second; auto ptr = this->shared_from_this(); diff --git a/implementation/endpoints/src/udp_server_endpoint_impl.cpp b/implementation/endpoints/src/udp_server_endpoint_impl.cpp index a89762f..7aadf3f 100644 --- a/implementation/endpoints/src/udp_server_endpoint_impl.cpp +++ b/implementation/endpoints/src/udp_server_endpoint_impl.cpp @@ -338,6 +338,9 @@ void udp_server_endpoint_impl::join_unlocked(const std::string &_address) { boost::asio::socket_base::reuse_address optionReuseAddress(true); multicast_socket_->set_option(optionReuseAddress, ec); boost::asio::detail::throw_error(ec, "reuse address in multicast"); + boost::asio::socket_base::broadcast optionBroadcast(true); + multicast_socket_->set_option(optionBroadcast, ec); + boost::asio::detail::throw_error(ec, "set broadcast option"); multicast_socket_->bind(*multicast_local_, ec); boost::asio::detail::throw_error(ec, "bind multicast"); diff --git a/implementation/routing/src/routing_manager_proxy.cpp b/implementation/routing/src/routing_manager_proxy.cpp index 3eba2a5..2af0eb5 100644 --- a/implementation/routing/src/routing_manager_proxy.cpp +++ b/implementation/routing/src/routing_manager_proxy.cpp @@ -154,6 +154,7 @@ bool routing_manager_proxy::offer_service(client_t _client, if(!routing_manager_base::offer_service(_client, _service, _instance, _major, _minor)) { VSOMEIP_WARNING << "routing_manager_proxy::offer_service," << "routing_manager_base::offer_service returned false"; + return false; } { std::lock_guard<std::mutex> its_lock(state_mutex_); diff --git a/implementation/runtime/src/runtime.cpp b/implementation/runtime/src/runtime.cpp index 9e79b79..40bb455 100644 --- a/implementation/runtime/src/runtime.cpp +++ b/implementation/runtime/src/runtime.cpp @@ -4,8 +4,12 @@ // file, You can obtain one at http://mozilla.org/MPL/2.0/. #include <vsomeip/runtime.hpp> +#include <vsomeip/plugin.hpp> #include "../include/runtime_impl.hpp" +#include "../../endpoints/include/endpoint.hpp" +#include "../../endpoints/include/client_endpoint.hpp" +#include "../../configuration/include/configuration_plugin.hpp" namespace vsomeip_v3 { @@ -21,4 +25,19 @@ std::shared_ptr<runtime> runtime::get() { return runtime_impl::get(); } +// non-inline destructors to make typeinfo of the type visible outside the shared library boundary +#ifdef ANDROID +plugin::~plugin() { +} + +endpoint::~endpoint() { +} + +client_endpoint::~client_endpoint() { +} + +configuration_plugin::~configuration_plugin() { +} +#endif + } // namespace vsomeip_v3 diff --git a/implementation/service_discovery/src/configuration_option_impl.cpp b/implementation/service_discovery/src/configuration_option_impl.cpp index 7f050f2..9666e5e 100755 --- a/implementation/service_discovery/src/configuration_option_impl.cpp +++ b/implementation/service_discovery/src/configuration_option_impl.cpp @@ -123,6 +123,8 @@ bool configuration_option_impl::deserialize(vsomeip_v3::deserializer *_from) { is_successful = false; } } + } else { + break; } } while (is_successful && _from->get_remaining() > 0); diff --git a/implementation/service_discovery/src/service_discovery_impl.cpp b/implementation/service_discovery/src/service_discovery_impl.cpp index 43e64c9..0fc6190 100644 --- a/implementation/service_discovery/src/service_discovery_impl.cpp +++ b/implementation/service_discovery/src/service_discovery_impl.cpp @@ -166,13 +166,8 @@ service_discovery_impl::start() { } if (endpoint_ && !reliable_) { // rejoin multicast group -#ifndef ANDROID - reinterpret_cast<udp_server_endpoint_impl*>( - endpoint_.get())->join(sd_multicast_); -#else dynamic_cast<udp_server_endpoint_impl*>( endpoint_.get())->join(sd_multicast_); -#endif } } is_suspended_ = false; @@ -2610,11 +2605,11 @@ service_discovery_impl::check_ipv4_address( //Check unallowed ipv4 address bool is_valid = true; - static const boost::asio::ip::address_v4::bytes_type its_unicast_address = + const boost::asio::ip::address_v4::bytes_type its_unicast_address = unicast_.to_v4().to_bytes(); const boost::asio::ip::address_v4::bytes_type endpoint_address = its_address.to_v4().to_bytes(); - static const boost::asio::ip::address_v4::bytes_type its_netmask = + const boost::asio::ip::address_v4::bytes_type its_netmask = configuration_->get_netmask().to_v4().to_bytes(); //same address as unicast address of DUT not allowed @@ -3351,13 +3346,8 @@ service_discovery_impl::on_last_msg_received_timer_expired( // Rejoin multicast group if (endpoint_ && !reliable_) { -#ifndef ANDROID - reinterpret_cast<udp_server_endpoint_impl*>( - endpoint_.get())->join(sd_multicast_); -#else dynamic_cast<udp_server_endpoint_impl*>( endpoint_.get())->join(sd_multicast_); -#endif } { boost::system::error_code ec; @@ -3742,8 +3732,10 @@ reliability_type_e service_discovery_impl::get_eventgroup_reliability( << std::hex << std::setw(4) << std::setfill('0') << _instance << "." << std::hex << std::setw(4) << std::setfill('0') << _eventgroup << "]"; } + return its_reliability; } + } // namespace sd } // namespace vsomeip_v3 diff --git a/implementation/utility/include/utility.hpp b/implementation/utility/include/utility.hpp index db54eb9..359bc7c 100644 --- a/implementation/utility/include/utility.hpp +++ b/implementation/utility/include/utility.hpp @@ -36,9 +36,7 @@ public: } static inline bool is_request(message_type_e _type) { - return ((_type < message_type_e::MT_NOTIFICATION) - || (_type >= message_type_e::MT_REQUEST_ACK - && _type <= message_type_e::MT_REQUEST_NO_RETURN_ACK)); + return (_type < message_type_e::MT_NOTIFICATION); } static inline bool is_request_no_return(std::shared_ptr<message> _message) { @@ -131,7 +129,9 @@ public: || _code == return_code_e::E_WRONG_PROTOCOL_VERSION || _code == return_code_e::E_WRONG_INTERFACE_VERSION || _code == return_code_e::E_MALFORMED_MESSAGE - || _code == return_code_e::E_WRONG_MESSAGE_TYPE); + || _code == return_code_e::E_WRONG_MESSAGE_TYPE + || (static_cast<std::uint8_t>(_code) >= 0x20 + && static_cast<std::uint8_t>(_code) <= 0x5E)); } private: diff --git a/interface/vsomeip/plugin.hpp b/interface/vsomeip/plugin.hpp index c7b73d9..33667a8 100644 --- a/interface/vsomeip/plugin.hpp +++ b/interface/vsomeip/plugin.hpp @@ -39,7 +39,12 @@ typedef create_plugin_func (*plugin_init_func)(); */ class VSOMEIP_IMPORT_EXPORT_PLUGIN plugin { public: - virtual ~plugin() {} + virtual ~plugin() +#ifndef ANDROID + {} +#else + ; +#endif virtual uint32_t get_plugin_version() const = 0; virtual const std::string &get_plugin_name() const = 0; @@ -60,15 +65,15 @@ public: type_ = _type; } - const std::string &get_plugin_name() const { + const std::string &get_plugin_name() const override { return name_; } - uint32_t get_plugin_version() const { + uint32_t get_plugin_version() const override { return version_; } - plugin_type_e get_plugin_type() const { + plugin_type_e get_plugin_type() const override { return type_; } |