diff options
author | Lutz Bichler <Lutz.Bichler@bmw.de> | 2020-02-12 13:04:15 +0100 |
---|---|---|
committer | Lutz Bichler <Lutz.Bichler@bmw.de> | 2020-02-12 13:04:15 +0100 |
commit | 8371cdca9463a75220c4de92b47c8df9d3bbe346 (patch) | |
tree | 16b4bf73c284b026b0ac032171110dafd1752196 /implementation/endpoints/include/tcp_client_endpoint_impl.hpp | |
parent | ee44d19e0a3773adcda3bace073c66e334a3e6a7 (diff) | |
download | vSomeIP-8371cdca9463a75220c4de92b47c8df9d3bbe346.tar.gz |
vsomeip 3.1.7.13.1.7.1
Diffstat (limited to 'implementation/endpoints/include/tcp_client_endpoint_impl.hpp')
-rw-r--r-- | implementation/endpoints/include/tcp_client_endpoint_impl.hpp | 199 |
1 files changed, 101 insertions, 98 deletions
diff --git a/implementation/endpoints/include/tcp_client_endpoint_impl.hpp b/implementation/endpoints/include/tcp_client_endpoint_impl.hpp index 77cbd39..4765bd8 100644 --- a/implementation/endpoints/include/tcp_client_endpoint_impl.hpp +++ b/implementation/endpoints/include/tcp_client_endpoint_impl.hpp @@ -1,98 +1,101 @@ -// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
-// This Source Code Form is subject to the terms of the Mozilla Public
-// License, v. 2.0. If a copy of the MPL was not distributed with this
-// file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-#ifndef VSOMEIP_TCP_CLIENT_ENDPOINT_IMPL_HPP
-#define VSOMEIP_TCP_CLIENT_ENDPOINT_IMPL_HPP
-
-#include <boost/asio/ip/tcp.hpp>
-#include <chrono>
-
-#include <vsomeip/defines.hpp>
-#include "client_endpoint_impl.hpp"
-
-namespace vsomeip {
-
-typedef client_endpoint_impl<
- boost::asio::ip::tcp
- > tcp_client_endpoint_base_impl;
-
-class tcp_client_endpoint_impl: public tcp_client_endpoint_base_impl {
-public:
- tcp_client_endpoint_impl(std::shared_ptr<endpoint_host> _host,
- endpoint_type _local,
- endpoint_type _remote,
- boost::asio::io_service &_io,
- std::uint32_t _max_message_size,
- std::uint32_t _buffer_shrink_threshold,
- std::chrono::milliseconds _send_timeout,
- configuration::endpoint_queue_limit_t _queue_limit,
- std::uint32_t _tcp_restart_aborts_max,
- std::uint32_t _tcp_connect_time_max);
- virtual ~tcp_client_endpoint_impl();
-
- void start();
- void restart(bool _force);
-
- bool get_remote_address(boost::asio::ip::address &_address) const;
- std::uint16_t get_remote_port() const;
- bool is_reliable() const;
- bool is_local() const;
- void print_status();
-
- void send_cbk(boost::system::error_code const &_error, std::size_t _bytes,
- message_buffer_ptr_t _sent_msg);
-private:
- void send_queued();
- bool is_magic_cookie(const message_buffer_ptr_t& _recv_buffer,
- size_t _offset) const;
- void send_magic_cookie(message_buffer_ptr_t &_buffer);
-
- void receive_cbk(boost::system::error_code const &_error,
- std::size_t _bytes,
- message_buffer_ptr_t _recv_buffer,
- std::size_t _recv_buffer_size);
-
- void connect();
- void receive();
- void receive(message_buffer_ptr_t _recv_buffer,
- std::size_t _recv_buffer_size,
- std::size_t _missing_capacity);
- void calculate_shrink_count(const message_buffer_ptr_t& _recv_buffer,
- std::size_t _recv_buffer_size);
- const std::string get_address_port_remote() const;
- const std::string get_address_port_local() const;
- void handle_recv_buffer_exception(const std::exception &_e,
- const message_buffer_ptr_t& _recv_buffer,
- std::size_t _recv_buffer_size);
- void set_local_port();
- std::size_t write_completion_condition(
- const boost::system::error_code& _error,
- std::size_t _bytes_transferred, std::size_t _bytes_to_send,
- service_t _service, method_t _method, client_t _client, session_t _session,
- std::chrono::steady_clock::time_point _start);
- std::string get_remote_information() const;
- std::uint32_t get_max_allowed_reconnects() const;
- void max_allowed_reconnects_reached();
-
- const std::uint32_t recv_buffer_size_initial_;
- message_buffer_ptr_t recv_buffer_;
- std::uint32_t shrink_count_;
- const std::uint32_t buffer_shrink_threshold_;
-
- const boost::asio::ip::address remote_address_;
- const std::uint16_t remote_port_;
- std::chrono::steady_clock::time_point last_cookie_sent_;
- const std::chrono::milliseconds send_timeout_;
- const std::chrono::milliseconds send_timeout_warning_;
-
- std::uint32_t tcp_restart_aborts_max_;
- std::uint32_t tcp_connect_time_max_;
- std::atomic<uint32_t> aborted_restart_count_;
- std::chrono::steady_clock::time_point connect_timepoint_;
-};
-
-} // namespace vsomeip
-
-#endif // VSOMEIP_TCP_CLIENT_ENDPOINT_IMPL_HPP
+// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef VSOMEIP_V3_TCP_CLIENT_ENDPOINT_IMPL_HPP_ +#define VSOMEIP_V3_TCP_CLIENT_ENDPOINT_IMPL_HPP_ + +#include <boost/asio/ip/tcp.hpp> +#include <chrono> + +#include <vsomeip/defines.hpp> +#include "client_endpoint_impl.hpp" + +namespace vsomeip_v3 { + +typedef client_endpoint_impl< + boost::asio::ip::tcp + > tcp_client_endpoint_base_impl; + +class tcp_client_endpoint_impl: public tcp_client_endpoint_base_impl { +public: + tcp_client_endpoint_impl(const std::shared_ptr<endpoint_host>& _endpoint_host, + const std::shared_ptr<routing_host>& _routing_host, + const endpoint_type& _local, + const endpoint_type& _remote, + boost::asio::io_service &_io, + const std::shared_ptr<configuration>& _configuration); + virtual ~tcp_client_endpoint_impl(); + + void start(); + void restart(bool _force); + + bool get_remote_address(boost::asio::ip::address &_address) const; + std::uint16_t get_remote_port() const; + bool is_reliable() const; + bool is_local() const; + void print_status(); + + void send_cbk(boost::system::error_code const &_error, std::size_t _bytes, + const message_buffer_ptr_t& _sent_msg); +private: + void send_queued(); + void get_configured_times_from_endpoint( + service_t _service, method_t _method, + std::chrono::nanoseconds *_debouncing, + std::chrono::nanoseconds *_maximum_retention) const; + bool is_magic_cookie(const message_buffer_ptr_t& _recv_buffer, + size_t _offset) const; + void send_magic_cookie(message_buffer_ptr_t &_buffer); + + void receive_cbk(boost::system::error_code const &_error, + std::size_t _bytes, + const message_buffer_ptr_t& _recv_buffer, + std::size_t _recv_buffer_size); + + void connect(); + void receive(); + void receive(message_buffer_ptr_t _recv_buffer, + std::size_t _recv_buffer_size, + std::size_t _missing_capacity); + void calculate_shrink_count(const message_buffer_ptr_t& _recv_buffer, + std::size_t _recv_buffer_size); + const std::string get_address_port_remote() const; + const std::string get_address_port_local() const; + void handle_recv_buffer_exception(const std::exception &_e, + const message_buffer_ptr_t& _recv_buffer, + std::size_t _recv_buffer_size); + void set_local_port(); + std::size_t write_completion_condition( + const boost::system::error_code& _error, + std::size_t _bytes_transferred, std::size_t _bytes_to_send, + service_t _service, method_t _method, client_t _client, session_t _session, + const std::chrono::steady_clock::time_point _start); + std::string get_remote_information() const; + std::shared_ptr<struct timing> get_timing( + const service_t& _service, const instance_t& _instance) const; + bool tp_segmentation_enabled(service_t _service, method_t _method) const; + std::uint32_t get_max_allowed_reconnects() const; + void max_allowed_reconnects_reached(); + + const std::uint32_t recv_buffer_size_initial_; + message_buffer_ptr_t recv_buffer_; + std::uint32_t shrink_count_; + const std::uint32_t buffer_shrink_threshold_; + + const boost::asio::ip::address remote_address_; + const std::uint16_t remote_port_; + std::chrono::steady_clock::time_point last_cookie_sent_; + const std::chrono::milliseconds send_timeout_; + const std::chrono::milliseconds send_timeout_warning_; + + std::uint32_t tcp_restart_aborts_max_; + std::uint32_t tcp_connect_time_max_; + std::atomic<uint32_t> aborted_restart_count_; + std::chrono::steady_clock::time_point connect_timepoint_; +}; + +} // namespace vsomeip_v3 + +#endif // VSOMEIP_V3_TCP_CLIENT_ENDPOINT_IMPL_HPP_ |