1 // Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) 2 // This Source Code Form is subject to the terms of the Mozilla Public 3 // License, v. 2.0. If a copy of the MPL was not distributed with this 4 // file, You can obtain one at http://mozilla.org/MPL/2.0/. 5 6 #ifndef VSOMEIP_V3_LOCAL_CLIENT_ENDPOINT_IMPL_HPP_ 7 #define VSOMEIP_V3_LOCAL_CLIENT_ENDPOINT_IMPL_HPP_ 8 9 #include <boost/asio/io_service.hpp> 10 #include <boost/asio/local/stream_protocol.hpp> 11 12 #ifdef _WIN32 13 #include <boost/asio/ip/tcp.hpp> 14 #endif 15 16 #include <vsomeip/defines.hpp> 17 18 #include "client_endpoint_impl.hpp" 19 20 namespace vsomeip_v3 { 21 22 #ifdef _WIN32 23 typedef client_endpoint_impl< 24 boost::asio::ip::tcp 25 > local_client_endpoint_base_impl; 26 #else 27 typedef client_endpoint_impl< 28 boost::asio::local::stream_protocol 29 > local_client_endpoint_base_impl; 30 #endif 31 32 class local_client_endpoint_impl: public local_client_endpoint_base_impl { 33 public: 34 local_client_endpoint_impl(const std::shared_ptr<endpoint_host>& _endpoint_host, 35 const std::shared_ptr<routing_host>& _routing_host, 36 const endpoint_type& _remote, 37 boost::asio::io_service &_io, 38 const std::shared_ptr<configuration>& _configuration); 39 40 virtual ~local_client_endpoint_impl(); 41 42 void start(); 43 void stop(); 44 45 bool is_local() const; 46 47 bool get_remote_address(boost::asio::ip::address &_address) const; 48 std::uint16_t get_remote_port() const; 49 50 void restart(bool _force); 51 void print_status(); 52 53 bool is_reliable() const; 54 55 // this overrides client_endpoint_impl::send to disable the pull method 56 // for local communication 57 bool send(const uint8_t *_data, uint32_t _size); 58 bool send(const std::vector<byte_t>& _cmd_header, const byte_t *_data, 59 uint32_t _size); 60 void get_configured_times_from_endpoint( 61 service_t _service, method_t _method, 62 std::chrono::nanoseconds *_debouncing, 63 std::chrono::nanoseconds *_maximum_retention) const; 64 private: 65 void send_queued(message_buffer_ptr_t _buffer); 66 67 void send_magic_cookie(); 68 69 void connect(); 70 void receive(); 71 void receive_cbk(boost::system::error_code const &_error, 72 std::size_t _bytes); 73 void set_local_port(); 74 std::string get_remote_information() const; 75 bool check_packetizer_space(std::uint32_t _size); 76 bool tp_segmentation_enabled(service_t _service, method_t _method) const; 77 std::uint32_t get_max_allowed_reconnects() const; 78 void max_allowed_reconnects_reached(); 79 80 message_buffer_t recv_buffer_; 81 82 // send data 83 message_buffer_ptr_t send_data_buffer_; 84 }; 85 86 } // namespace vsomeip_v3 87 88 #endif // VSOMEIP_V3_LOCAL_CLIENT_ENDPOINT_IMPL_HPP_ 89