diff options
author | Jürgen Gehring <Juergen.Gehring@bmw.de> | 2016-12-12 03:57:25 -0800 |
---|---|---|
committer | Jürgen Gehring <Juergen.Gehring@bmw.de> | 2016-12-12 03:57:25 -0800 |
commit | ce34f857850ebf7bff1e4dc6c79574ff75abca56 (patch) | |
tree | d74c50b547412cc5dd847508b7d405ccd1520aaf /implementation/tracing/src/trace_header.cpp | |
parent | 30b6688d9f77d40352cc3cec99052e0946a8affc (diff) | |
download | vSomeIP-ce34f857850ebf7bff1e4dc6c79574ff75abca56.tar.gz |
vSomeIP 2.5.12.5.1
Diffstat (limited to 'implementation/tracing/src/trace_header.cpp')
-rw-r--r-- | implementation/tracing/src/trace_header.cpp | 65 |
1 files changed, 38 insertions, 27 deletions
diff --git a/implementation/tracing/src/trace_header.cpp b/implementation/tracing/src/trace_header.cpp index 2f293ee..7e4c700 100644 --- a/implementation/tracing/src/trace_header.cpp +++ b/implementation/tracing/src/trace_header.cpp @@ -7,6 +7,7 @@ #include "../include/trace_header.hpp" #include "../../endpoints/include/endpoint.hpp" +#include "../../endpoints/include/client_endpoint.hpp" #include "../../utility/include/byteorder.hpp" namespace vsomeip { @@ -17,39 +18,49 @@ bool trace_header::prepare(const std::shared_ptr<endpoint> &_endpoint, bool _is_ } bool trace_header::prepare(const endpoint *_endpoint, bool _is_sending) { - boost::asio::ip::address its_address; - if (_endpoint && _endpoint->get_remote_address(its_address)) { - if (its_address.is_v6()) - return false; - - unsigned long its_address_as_long = its_address.to_v4().to_ulong(); - - data_[0] = VSOMEIP_LONG_BYTE0(its_address_as_long); - data_[1] = VSOMEIP_LONG_BYTE1(its_address_as_long); - data_[2] = VSOMEIP_LONG_BYTE2(its_address_as_long); - data_[3] = VSOMEIP_LONG_BYTE3(its_address_as_long); - - unsigned short its_port = _endpoint->get_remote_port(); - data_[4] = VSOMEIP_WORD_BYTE0(its_port); - data_[5] = VSOMEIP_WORD_BYTE1(its_port); - - if (_endpoint->is_local()) { - data_[6] = static_cast<byte_t>(protocol_e::local); - } else { - if (_endpoint->is_reliable()) { - data_[6] = static_cast<byte_t>(protocol_e::tcp); + if (_endpoint) { + const client_endpoint* its_client_endpoint = + dynamic_cast<const client_endpoint*>(_endpoint); + if (its_client_endpoint) { + + boost::asio::ip::address its_address; + its_client_endpoint->get_remote_address(its_address); + if (its_address.is_v6()) { + return false; + } + + unsigned short its_port = its_client_endpoint->get_remote_port(); + protocol_e its_protocol(protocol_e::unknown); + if (_endpoint->is_local()) { + its_protocol = protocol_e::local; } else { - data_[6] = static_cast<byte_t>(protocol_e::udp); + if (_endpoint->is_reliable()) { + its_protocol = protocol_e::tcp; + } else { + its_protocol = protocol_e::udp; + } } + prepare(its_address.to_v4(), its_port, its_protocol, _is_sending); + return true; } - - data_[7] = static_cast<byte_t>(_is_sending); - - } else { - std::memset(data_, 0, VSOMEIP_TRACE_HEADER_SIZE); } + std::memset(data_, 0, VSOMEIP_TRACE_HEADER_SIZE); return true; } +void trace_header::prepare(const boost::asio::ip::address_v4 &_address, + std::uint16_t _port, protocol_e _protocol, + bool _is_sending) { + unsigned long its_address_as_long = _address.to_ulong(); + data_[0] = VSOMEIP_LONG_BYTE0(its_address_as_long); + data_[1] = VSOMEIP_LONG_BYTE1(its_address_as_long); + data_[2] = VSOMEIP_LONG_BYTE2(its_address_as_long); + data_[3] = VSOMEIP_LONG_BYTE3(its_address_as_long); + data_[4] = VSOMEIP_WORD_BYTE0(_port); + data_[5] = VSOMEIP_WORD_BYTE1(_port); + data_[6] = static_cast<byte_t>(_protocol); + data_[7] = static_cast<byte_t>(_is_sending); +} + } // namespace tc } // namespace vsomeip |