diff options
Diffstat (limited to 'implementation/service_discovery/include')
26 files changed, 1049 insertions, 916 deletions
diff --git a/implementation/service_discovery/include/configuration_option_impl.hpp b/implementation/service_discovery/include/configuration_option_impl.hpp index 1d231e8..567762d 100644 --- a/implementation/service_discovery/include/configuration_option_impl.hpp +++ b/implementation/service_discovery/include/configuration_option_impl.hpp @@ -1,46 +1,47 @@ -// 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_SD_CONFIGURATION_OPTION_IMPL_HPP
-#define VSOMEIP_SD_CONFIGURATION_OPTION_IMPL_HPP
-
-#include <map>
-#include <string>
-#include <vector>
-
-#include "option_impl.hpp"
-
-namespace vsomeip {
-
-class serializer;
-class deserializer;
-
-namespace sd {
-
-class configuration_option_impl: public option_impl {
-
-public:
- configuration_option_impl();
- virtual ~configuration_option_impl();
- bool operator==(const configuration_option_impl &_other) const;
-
- void add_item(const std::string &_key, const std::string &_value);
- void remove_item(const std::string &_key);
-
- std::vector<std::string> get_keys() const;
- std::vector<std::string> get_values() const;
- std::string get_value(const std::string &_key) const;
-
- bool serialize(vsomeip::serializer *_to) const;
- bool deserialize(vsomeip::deserializer *_from);
-
-private:
- std::map<std::string, std::string> configuration_;
-};
-
-} // namespace sd
-} // namespace vsomeip
-
-#endif // VSOMEIP_SD_CONFIGURATION_OPTION_IMPL_HPP
+// Copyright (C) 2014-2018 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_SD_CONFIGURATION_OPTION_IMPL_HPP_ +#define VSOMEIP_V3_SD_CONFIGURATION_OPTION_IMPL_HPP_ + +#include <map> +#include <string> +#include <vector> + +#include "option_impl.hpp" + +namespace vsomeip_v3 { + +class serializer; +class deserializer; + +namespace sd { + +class configuration_option_impl: public option_impl { + +public: + configuration_option_impl(); + virtual ~configuration_option_impl(); + + bool operator==(const option_impl &_other) const; + + void add_item(const std::string &_key, const std::string &_value); + void remove_item(const std::string &_key); + + std::vector<std::string> get_keys() const; + std::vector<std::string> get_values() const; + std::string get_value(const std::string &_key) const; + + bool serialize(vsomeip_v3::serializer *_to) const; + bool deserialize(vsomeip_v3::deserializer *_from); + +private: + std::map<std::string, std::string> configuration_; +}; + +} // namespace sd +} // namespace vsomeip_v3 + +#endif // VSOMEIP_V3_SD_CONFIGURATION_OPTION_IMPL_HPP_ diff --git a/implementation/service_discovery/include/constants.hpp b/implementation/service_discovery/include/constants.hpp index 31bff53..c50fac1 100644 --- a/implementation/service_discovery/include/constants.hpp +++ b/implementation/service_discovery/include/constants.hpp @@ -1,15 +1,15 @@ -// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2018 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_SD_CONSTANTS_HPP -#define VSOMEIP_SD_CONSTANTS_HPP +#ifndef VSOMEIP_V3_SD_CONSTANTS_HPP_ +#define VSOMEIP_V3_SD_CONSTANTS_HPP_ #include <vsomeip/enumeration_types.hpp> #include <vsomeip/primitive_types.hpp> -namespace vsomeip { +namespace vsomeip_v3 { namespace sd { const service_t service = 0xFFFF; @@ -32,6 +32,6 @@ const uint8_t udp = 0x11; } // namespace protocol } // namespace sd -} // namespace vsomeip +} // namespace vsomeip_v3 -#endif // VSOMEIP_SD_CONSTANTS_HPP +#endif // VSOMEIP_V3_SD_CONSTANTS_HPP_ diff --git a/implementation/service_discovery/include/defines.hpp b/implementation/service_discovery/include/defines.hpp index 1f884d2..b7e840b 100644 --- a/implementation/service_discovery/include/defines.hpp +++ b/implementation/service_discovery/include/defines.hpp @@ -6,8 +6,6 @@ #ifndef VSOMEIP_SD_DEFINES_HPP #define VSOMEIP_SD_DEFINES_HPP -#include "../../configuration/include/internal.hpp" - #define VSOMEIP_MAX_TCP_SD_PAYLOAD 4075 // Available for entries & options #define VSOMEIP_MAX_UDP_SD_PAYLOAD 1380 @@ -16,8 +14,13 @@ #define VSOMEIP_SOMEIP_SD_ENTRY_SIZE 16 #define VSOMEIP_SOMEIP_SD_IPV4_OPTION_SIZE 12 #define VSOMEIP_SOMEIP_SD_IPV6_OPTION_SIZE 24 +#define VSOMEIP_SOMEIP_SD_LOAD_BALANCING_OPTION_SIZE 8 +#define VSOMEIP_SOMEIP_SD_PROTECTION_OPTION_SIZE 12 + #define VSOMEIP_SOMEIP_SD_OPTION_LENGTH_SIZE 4 #define VSOMEIP_SOMEIP_SD_OPTION_HEADER_SIZE 3 +#define VSOMEIP_SOMEIP_SD_EMPTY_MESSAGE_SIZE 28 +#define VSOMEIP_SOMEIP_SD_SPACE_FOR_PAYLOAD VSOMEIP_MAX_UDP_MESSAGE_SIZE - VSOMEIP_SOMEIP_SD_EMPTY_MESSAGE_SIZE; @@ -27,7 +30,7 @@ #define VSOMEIP_SD_SERVICE 0xFFFF #define VSOMEIP_SD_INSTANCE 0x0000 #define VSOMEIP_SD_METHOD 0x8100 -#define VSOMEIP_SD_CLIENT (VSOMEIP_DIAGNOSIS_ADDRESS << 8) // SIP_SD_1139 +#define VSOMEIP_SD_CLIENT 0x0 #define VSOMEIP_SD_DEFAULT_ENABLED true diff --git a/implementation/service_discovery/include/deserializer.hpp b/implementation/service_discovery/include/deserializer.hpp index a1b45be..97ebcd4 100755 --- a/implementation/service_discovery/include/deserializer.hpp +++ b/implementation/service_discovery/include/deserializer.hpp @@ -1,30 +1,31 @@ -// 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_SD_DESERIALIZER_HPP
-#define VSOMEIP_SD_DESERIALIZER_HPP
-
-#include "../../message/include/deserializer.hpp"
-
-namespace vsomeip {
-namespace sd {
-
-class message_impl;
-
-class deserializer: public vsomeip::deserializer {
-public:
- deserializer(std::uint32_t _shrink_buffer_threshold);
- deserializer(uint8_t *_data, std::size_t _length,
- std::uint32_t _shrink_buffer_threshold);
- deserializer(const deserializer &_other);
- virtual ~deserializer();
-
- message_impl * deserialize_sd_message();
-};
-
-} // namespace sd
-} // vsomeip
-
-#endif // VSOMEIP_SD_DESERIALIZER_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_SD_DESERIALIZER_HPP +#define VSOMEIP_V3_SD_DESERIALIZER_HPP + +#include "../../message/include/deserializer.hpp" + +namespace vsomeip_v3 { +namespace sd { + +class message_impl; + +class deserializer + : public vsomeip_v3::deserializer { +public: + deserializer(std::uint32_t _shrink_buffer_threshold); + deserializer(uint8_t *_data, std::size_t _length, + std::uint32_t _shrink_buffer_threshold); + deserializer(const deserializer &_other); + virtual ~deserializer(); + + message_impl * deserialize_sd_message(); +}; + +} // namespace sd +} // vsomeip_v3 + +#endif // VSOMEIP_V3_SD_DESERIALIZER_HPP diff --git a/implementation/service_discovery/include/entry_impl.hpp b/implementation/service_discovery/include/entry_impl.hpp index b41a94c..39d5416 100755 --- a/implementation/service_discovery/include/entry_impl.hpp +++ b/implementation/service_discovery/include/entry_impl.hpp @@ -1,81 +1,81 @@ -// 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_SD_ENTRY_IMPL_HPP
-#define VSOMEIP_SD_ENTRY_IMPL_HPP
-
-#include <memory>
-#include <vector>
-
-#include <vsomeip/primitive_types.hpp>
-#include <vsomeip/internal/serializable.hpp>
-
-#include "enumeration_types.hpp"
-#include "message_element_impl.hpp"
-
-#define VSOMEIP_MAX_OPTION_RUN 2
-
-namespace vsomeip {
-
-class deserializer;
-
-namespace sd {
-
-class option_impl;
-class message_impl;
-
-class entry_impl: public message_element_impl {
-public:
- virtual ~entry_impl();
-
- // public interface
- entry_type_e get_type() const;
-
- service_t get_service() const;
- void set_service(service_t _service);
-
- instance_t get_instance() const;
- void set_instance(instance_t _instance);
-
- major_version_t get_major_version() const;
- void set_major_version(major_version_t _major_version);
-
- ttl_t get_ttl() const;
- void set_ttl(ttl_t _ttl);
-
- const std::vector<uint8_t> & get_options(uint8_t _run) const;
- void assign_option(const std::shared_ptr<option_impl> &_option);
-
- bool is_service_entry() const;
- bool is_eventgroup_entry() const;
-
- void set_type(entry_type_e _type);
-
- virtual bool serialize(vsomeip::serializer *_to) const;
- virtual bool deserialize(vsomeip::deserializer *_from);
-
- uint8_t get_num_options(uint8_t _run) const;
-
-protected:
- entry_type_e type_;
- service_t service_;
- instance_t instance_;
- major_version_t major_version_;
- ttl_t ttl_;
-
- std::vector<uint8_t> options_[VSOMEIP_MAX_OPTION_RUN];
-
- uint8_t num_options_[VSOMEIP_MAX_OPTION_RUN];
- std::uint8_t index1_;
- std::uint8_t index2_;
-
- entry_impl();
- entry_impl(const entry_impl &_entry);
-};
-
-} // namespace sd
-} // namespace vsomeip
-
-#endif // VSOMEIP_SD_ENTRY_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_SD_ENTRY_IMPL_HPP +#define VSOMEIP_V3_SD_ENTRY_IMPL_HPP + +#include <memory> +#include <vector> + +#include <vsomeip/primitive_types.hpp> +#include <vsomeip/internal/serializable.hpp> + +#include "enumeration_types.hpp" +#include "message_element_impl.hpp" + +#define VSOMEIP_MAX_OPTION_RUN 2 + +namespace vsomeip_v3 { + +class deserializer; + +namespace sd { + +class option_impl; +class message_impl; + +class entry_impl: public message_element_impl { +public: + virtual ~entry_impl(); + + // public interface + entry_type_e get_type() const; + + service_t get_service() const; + void set_service(service_t _service); + + instance_t get_instance() const; + void set_instance(instance_t _instance); + + major_version_t get_major_version() const; + void set_major_version(major_version_t _major_version); + + ttl_t get_ttl() const; + void set_ttl(ttl_t _ttl); + + const std::vector<uint8_t> & get_options(uint8_t _run) const; + void assign_option(const std::shared_ptr<option_impl> &_option); + + bool is_service_entry() const; + bool is_eventgroup_entry() const; + + void set_type(entry_type_e _type); + + virtual bool serialize(vsomeip_v3::serializer *_to) const; + virtual bool deserialize(vsomeip_v3::deserializer *_from); + + uint8_t get_num_options(uint8_t _run) const; + +protected: + entry_type_e type_; + service_t service_; + instance_t instance_; + major_version_t major_version_; + ttl_t ttl_; + + std::vector<uint8_t> options_[VSOMEIP_MAX_OPTION_RUN]; + + uint8_t num_options_[VSOMEIP_MAX_OPTION_RUN]; + std::uint8_t index1_; + std::uint8_t index2_; + + entry_impl(); + entry_impl(const entry_impl &_entry); +}; + +} // namespace sd +} // namespace vsomeip_v3 + +#endif // VSOMEIP_V3_SD_ENTRY_IMPL_HPP diff --git a/implementation/service_discovery/include/enumeration_types.hpp b/implementation/service_discovery/include/enumeration_types.hpp index 59538e5..63d0378 100644 --- a/implementation/service_discovery/include/enumeration_types.hpp +++ b/implementation/service_discovery/include/enumeration_types.hpp @@ -5,10 +5,10 @@ #include <cstdint> -#ifndef VSOMEIP_SD_ENUMERATION_TYPES_HPP -#define VSOMEIP_SD_ENUMERATION_TYPES_HPP +#ifndef VSOMEIP_V3_SD_ENUMERATION_TYPES_HPP +#define VSOMEIP_V3_SD_ENUMERATION_TYPES_HPP -namespace vsomeip { +namespace vsomeip_v3 { namespace sd { enum class option_type_e @@ -20,6 +20,7 @@ enum class option_type_e IP6_ENDPOINT = 0x6, IP4_MULTICAST = 0x14, IP6_MULTICAST = 0x16, + SELECTIVE = 0x20, UNKNOWN = 0xFF }; @@ -47,6 +48,6 @@ enum class layer_four_protocol_e }; } // namespace sd -} // namespace vsomeip +} // namespace vsomeip_v3 -#endif // VSOMEIP_SD_ENUMERATION_TYPES_HPP +#endif // VSOMEIP_V3_SD_ENUMERATION_TYPES_HPP diff --git a/implementation/service_discovery/include/eventgroupentry_impl.hpp b/implementation/service_discovery/include/eventgroupentry_impl.hpp index 3a5d897..08b25a6 100755 --- a/implementation/service_discovery/include/eventgroupentry_impl.hpp +++ b/implementation/service_discovery/include/eventgroupentry_impl.hpp @@ -1,68 +1,73 @@ -// 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_SD_EVENTGROUPENTRY_IMPL_HPP
-#define VSOMEIP_SD_EVENTGROUPENTRY_IMPL_HPP
-
-#include "entry_impl.hpp"
-#include "../../endpoints/include/endpoint_definition.hpp"
-#include "message_impl.hpp"
-
-namespace vsomeip {
-namespace sd {
-
-class eventgroupentry_impl: public entry_impl {
-public:
- eventgroupentry_impl();
- eventgroupentry_impl(const eventgroupentry_impl &_entry);
- virtual ~eventgroupentry_impl();
-
- eventgroup_t get_eventgroup() const;
- void set_eventgroup(eventgroup_t _eventgroup);
-
- uint16_t get_reserved() const;
- void set_reserved(uint16_t _reserved);
-
- uint8_t get_counter() const;
- void set_counter(uint8_t _counter);
-
- bool serialize(vsomeip::serializer *_to) const;
- bool deserialize(vsomeip::deserializer *_from);
-
- bool operator==(const eventgroupentry_impl& _other) const {
- return (ttl_ == _other.ttl_ &&
- service_ == _other.service_ &&
- instance_ == _other.instance_ &&
- eventgroup_ == _other.eventgroup_ &&
- index1_ == _other.index1_ &&
- index2_ == _other.index2_ &&
- num_options_[0] == _other.num_options_[0] &&
- num_options_[1] == _other.num_options_[1] &&
- major_version_ == _other.major_version_ &&
- counter_ == _other.counter_);
- }
-
- bool is_matching_subscribe(const eventgroupentry_impl& _other,
- const message_impl::options_t& _options) const;
-
- void add_target(const std::shared_ptr<endpoint_definition> &_target);
- std::shared_ptr<endpoint_definition> get_target(bool _reliable) const;
-
-private:
- eventgroup_t eventgroup_;
- uint16_t reserved_;
-
- // counter field to differentiate parallel subscriptions on same event group
- // 4Bit only (max 16. parralel subscriptions)
- uint8_t counter_;
-
- std::shared_ptr<endpoint_definition> target_reliable_;
- std::shared_ptr<endpoint_definition> target_unreliable_;
-};
-
-} // namespace sd
-} // namespace vsomeip
-
-#endif // VSOMEIP_INTERNAL_SD_EVENTGROUPENTRY_IMPL_HPP
+// Copyright (C) 2014-2018 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_SD_EVENTGROUPENTRY_IMPL_HPP_ +#define VSOMEIP_V3_SD_EVENTGROUPENTRY_IMPL_HPP_ + +#include "entry_impl.hpp" +#include "../../endpoints/include/endpoint_definition.hpp" +#include "message_impl.hpp" + +namespace vsomeip_v3 { +namespace sd { + +class selective_option_impl; + +class eventgroupentry_impl: public entry_impl { +public: + eventgroupentry_impl(); + eventgroupentry_impl(const eventgroupentry_impl &_entry); + virtual ~eventgroupentry_impl(); + + eventgroup_t get_eventgroup() const; + void set_eventgroup(eventgroup_t _eventgroup); + + uint16_t get_reserved() const; + void set_reserved(uint16_t _reserved); + + uint8_t get_counter() const; + void set_counter(uint8_t _counter); + + bool serialize(vsomeip_v3::serializer *_to) const; + bool deserialize(vsomeip_v3::deserializer *_from); + + bool operator==(const eventgroupentry_impl& _other) const { + return (ttl_ == _other.ttl_ && + service_ == _other.service_ && + instance_ == _other.instance_ && + eventgroup_ == _other.eventgroup_ && + index1_ == _other.index1_ && + index2_ == _other.index2_ && + num_options_[0] == _other.num_options_[0] && + num_options_[1] == _other.num_options_[1] && + major_version_ == _other.major_version_ && + counter_ == _other.counter_); + } + + bool matches(const eventgroupentry_impl &_other, + const message_impl::options_t &_options) const; + + void add_target(const std::shared_ptr<endpoint_definition> &_target); + std::shared_ptr<endpoint_definition> get_target(bool _reliable) const; + + std::shared_ptr<selective_option_impl> get_selective_option() const; + +private: + eventgroup_t eventgroup_; + uint16_t reserved_; + + // counter field to differentiate parallel subscriptions on same event group + // 4Bit only (max 16. parralel subscriptions) + uint8_t counter_; + + std::shared_ptr<endpoint_definition> target_reliable_; + std::shared_ptr<endpoint_definition> target_unreliable_; +}; + +} // namespace sd +} // namespace vsomeip_v3 + +#endif // VSOMEIP_V3_SD_EVENTGROUPENTRY_IMPL_HPP_ + diff --git a/implementation/service_discovery/include/ip_option_impl.hpp b/implementation/service_discovery/include/ip_option_impl.hpp index a2a7660..c83d745 100644 --- a/implementation/service_discovery/include/ip_option_impl.hpp +++ b/implementation/service_discovery/include/ip_option_impl.hpp @@ -1,23 +1,25 @@ -// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2018 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_SD_IP_OPTION_IMPL_HPP -#define VSOMEIP_SD_IP_OPTION_IMPL_HPP +#ifndef VSOMEIP_V3_SD_IP_OPTION_IMPL_HPP_ +#define VSOMEIP_V3_SD_IP_OPTION_IMPL_HPP_ #include <vsomeip/primitive_types.hpp> #include "option_impl.hpp" -namespace vsomeip { +namespace vsomeip_v3 { namespace sd { -class ip_option_impl: public option_impl { +class ip_option_impl + : public option_impl { public: ip_option_impl(); + ip_option_impl(const uint16_t _port, const bool _is_reliable); virtual ~ip_option_impl(); - virtual bool operator ==(const ip_option_impl &_other) const; + virtual bool operator ==(const option_impl &_other) const; uint16_t get_port() const; void set_port(uint16_t _port); @@ -27,8 +29,8 @@ public: virtual bool is_multicast() const = 0; - virtual bool serialize(vsomeip::serializer *_to) const = 0; - virtual bool deserialize(vsomeip::deserializer *_from) = 0; + virtual bool serialize(vsomeip_v3::serializer *_to) const = 0; + virtual bool deserialize(vsomeip_v3::deserializer *_from) = 0; protected: layer_four_protocol_e protocol_; @@ -36,6 +38,7 @@ protected: }; } // namespace sd -} // namespace vsomeip +} // namespace vsomeip_v3 + +#endif // VSOMEIP_V3_SD_IP_OPTION_IMPL_HPP_ -#endif // VSOMEIP_SD_IP_OPTION_IMPL_HPP diff --git a/implementation/service_discovery/include/ipv4_option_impl.hpp b/implementation/service_discovery/include/ipv4_option_impl.hpp index 8ede63d..15c04b2 100644 --- a/implementation/service_discovery/include/ipv4_option_impl.hpp +++ b/implementation/service_discovery/include/ipv4_option_impl.hpp @@ -1,36 +1,42 @@ -// 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_SD_IPV4_OPTION_IMPL_HPP
-#define VSOMEIP_SD_IPV4_OPTION_IMPL_HPP
-
-#include <vsomeip/primitive_types.hpp>
-
-#include "ip_option_impl.hpp"
-
-namespace vsomeip {
-namespace sd {
-
-class ipv4_option_impl: public ip_option_impl {
-public:
- ipv4_option_impl(bool _is_multicast);
- virtual ~ipv4_option_impl();
- bool operator ==(const ipv4_option_impl &_other) const;
-
- const ipv4_address_t & get_address() const;
- void set_address(const ipv4_address_t &_address);
-
- bool is_multicast() const;
- bool serialize(vsomeip::serializer *_to) const;
- bool deserialize(vsomeip::deserializer *_from);
-
-private:
- ipv4_address_t address_;
-};
-
-} // namespace sd
-} // namespace vsomeip
-
-#endif // VSOMEIP_SD_IPV4_OPTION_IMPL_HPP
+// Copyright (C) 2014-2018 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_SD_IPV4_OPTION_IMPL_HPP_ +#define VSOMEIP_V3_SD_IPV4_OPTION_IMPL_HPP_ + +#include <boost/asio/ip/address.hpp> + +#include <vsomeip/primitive_types.hpp> + +#include "ip_option_impl.hpp" + +namespace vsomeip_v3 { +namespace sd { + +class ipv4_option_impl: public ip_option_impl { +public: + ipv4_option_impl(); + ipv4_option_impl(const boost::asio::ip::address &_address, + const uint16_t _port, const bool _is_reliable); + virtual ~ipv4_option_impl(); + + bool operator ==(const option_impl &_other) const; + + const ipv4_address_t & get_address() const; + void set_address(const ipv4_address_t &_address); + + bool is_multicast() const; + bool serialize(vsomeip_v3::serializer *_to) const; + bool deserialize(vsomeip_v3::deserializer *_from); + +private: + ipv4_address_t address_; +}; + +} // namespace sd +} // namespace vsomeip_v3 + +#endif // VSOMEIP_V3_SD_IPV4_OPTION_IMPL_HPP_ + diff --git a/implementation/service_discovery/include/ipv6_option_impl.hpp b/implementation/service_discovery/include/ipv6_option_impl.hpp index 92701c0..d896300 100644 --- a/implementation/service_discovery/include/ipv6_option_impl.hpp +++ b/implementation/service_discovery/include/ipv6_option_impl.hpp @@ -1,36 +1,42 @@ -// 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_SD_IPV6_OPTION_IMPL_HPP
-#define VSOMEIP_SD_IPV6_OPTION_IMPL_HPP
-
-#include <vsomeip/primitive_types.hpp>
-
-#include "ip_option_impl.hpp"
-
-namespace vsomeip {
-namespace sd {
-
-class ipv6_option_impl: public ip_option_impl {
-public:
- ipv6_option_impl(bool _is_multicast);
- virtual ~ipv6_option_impl();
- bool operator ==(const ipv6_option_impl &_other) const;
-
- const ipv6_address_t & get_address() const;
- void set_address(const ipv6_address_t &_address);
-
- bool is_multicast() const;
- bool serialize(vsomeip::serializer *_to) const;
- bool deserialize(vsomeip::deserializer *_from);
-
-private:
- ipv6_address_t address_;
-};
-
-} // namespace sd
-} // namespace vsomeip
-
-#endif // VSOMEIP_SD_IPV6_OPTION_IMPL_HPP
+// Copyright (C) 2014-2018 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_SD_IPV6_OPTION_IMPL_HPP_ +#define VSOMEIP_V3_SD_IPV6_OPTION_IMPL_HPP_ + +#include <boost/asio/ip/address.hpp> + +#include <vsomeip/primitive_types.hpp> + +#include "ip_option_impl.hpp" + +namespace vsomeip_v3 { +namespace sd { + +class ipv6_option_impl + : public ip_option_impl { +public: + ipv6_option_impl(); + ipv6_option_impl(const boost::asio::ip::address &_address, + const uint16_t _port, const bool _is_reliable); + virtual ~ipv6_option_impl(); + + bool operator ==(const option_impl &_other) const; + + const ipv6_address_t & get_address() const; + void set_address(const ipv6_address_t &_address); + + bool is_multicast() const; + bool serialize(vsomeip_v3::serializer *_to) const; + bool deserialize(vsomeip_v3::deserializer *_from); + +private: + ipv6_address_t address_; +}; + +} // namespace sd +} // namespace vsomeip_v3 + +#endif // VSOMEIP_V3_SD_IPV6_OPTION_IMPL_HPP_ diff --git a/implementation/service_discovery/include/load_balancing_option_impl.hpp b/implementation/service_discovery/include/load_balancing_option_impl.hpp index 767c345..dafcfc7 100755 --- a/implementation/service_discovery/include/load_balancing_option_impl.hpp +++ b/implementation/service_discovery/include/load_balancing_option_impl.hpp @@ -1,38 +1,40 @@ -// 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_SD_LOAD_BALANCING_OPTION_IMPL_HPP
-#define VSOMEIP_SD_LOAD_BALANCING_OPTION_IMPL_HPP
-
-#include "primitive_types.hpp"
-#include "option_impl.hpp"
-
-namespace vsomeip {
-namespace sd {
-
-class load_balancing_option_impl: public option_impl {
-public:
- load_balancing_option_impl();
- virtual ~load_balancing_option_impl();
- bool operator ==(const load_balancing_option_impl &_other) const;
-
- priority_t get_priority() const;
- void set_priority(priority_t _priority);
-
- weight_t get_weight() const;
- void set_weight(weight_t _weight);
-
- bool serialize(vsomeip::serializer *_to) const;
- bool deserialize(vsomeip::deserializer *_from);
-
-private:
- priority_t priority_;
- weight_t weight_;
-};
-
-} // namespace sd
-} // namespace vsomeip
-
-#endif // VSOMEIP_SD_LOAD_BALANCING_OPTION_IMPL_HPP
+// Copyright (C) 2014-2018 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_SD_LOAD_BALANCING_OPTION_IMPL_HPP_ +#define VSOMEIP_V3_SD_LOAD_BALANCING_OPTION_IMPL_HPP_ + +#include "primitive_types.hpp" +#include "option_impl.hpp" + +namespace vsomeip_v3 { +namespace sd { + +class load_balancing_option_impl: public option_impl { +public: + load_balancing_option_impl(); + virtual ~load_balancing_option_impl(); + + bool operator ==(const option_impl &_other) const; + + priority_t get_priority() const; + void set_priority(priority_t _priority); + + weight_t get_weight() const; + void set_weight(weight_t _weight); + + bool serialize(vsomeip_v3::serializer *_to) const; + bool deserialize(vsomeip_v3::deserializer *_from); + +private: + priority_t priority_; + weight_t weight_; +}; + +} // namespace sd +} // namespace vsomeip_v3 + +#endif // VSOMEIP_V3_SD_LOAD_BALANCING_OPTION_IMPL_HPP_ + diff --git a/implementation/service_discovery/include/message_element_impl.hpp b/implementation/service_discovery/include/message_element_impl.hpp index 835326a..29b5d86 100755 --- a/implementation/service_discovery/include/message_element_impl.hpp +++ b/implementation/service_discovery/include/message_element_impl.hpp @@ -1,28 +1,29 @@ -// 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_SD_MESSAGE_ELEMENT_IMPL_HPP
-#define VSOMEIP_SD_MESSAGE_ELEMENT_IMPL_HPP
-
-namespace vsomeip {
-namespace sd {
-
-class message_impl;
-
-class message_element_impl {
-public:
- message_element_impl();
-
- message_impl * get_owning_message() const;
- void set_owning_message(message_impl *_owner);
-
-protected:
- message_impl *owner_;
-};
-
-} // namespace sd
-} // namespace vsomeip
-
-#endif // VSOMEIP_SD_MESSAGE_ELEMENT_IMPL_HPP
+// Copyright (C) 2014-2018 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_SD_MESSAGE_ELEMENT_IMPL_HPP_ +#define VSOMEIP_V3_SD_MESSAGE_ELEMENT_IMPL_HPP_ + +namespace vsomeip_v3 { +namespace sd { + +class message_impl; + +class message_element_impl { +public: + message_element_impl(); + + message_impl * get_owning_message() const; + void set_owning_message(message_impl *_owner); + +protected: + message_impl *owner_; +}; + +} // namespace sd +} // namespace vsomeip_v3 + +#endif // VSOMEIP_V3_SD_MESSAGE_ELEMENT_IMPL_HPP_ + diff --git a/implementation/service_discovery/include/message_impl.hpp b/implementation/service_discovery/include/message_impl.hpp index 83d3a64..b9e858d 100755 --- a/implementation/service_discovery/include/message_impl.hpp +++ b/implementation/service_discovery/include/message_impl.hpp @@ -1,127 +1,127 @@ -// 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_SD_MESSAGE_IMPL_HPP
-#define VSOMEIP_SD_MESSAGE_IMPL_HPP
-
-#include <memory>
-#include <vector>
-#include <atomic>
-#include <mutex>
-
-#include <vsomeip/message.hpp>
-
-#include "../include/primitive_types.hpp"
-#include "../../message/include/message_base_impl.hpp"
-#include "../../endpoints/include/endpoint_definition.hpp"
-
-# if _MSC_VER >= 1300
-/*
-* Diamond inheritance is used for the vsomeip::message_base base class.
-* The Microsoft compiler put warning (C4250) using a desired c++ feature: "Delegating to a sister class"
-* A powerful technique that arises from using virtual inheritance is to delegate a method from a class in another class
-* by using a common abstract base class. This is also called cross delegation.
-*/
-# pragma warning( disable : 4250 )
-# endif
-
-namespace vsomeip {
-namespace sd {
-
-class entry_impl;
-class eventgroupentry_impl;
-class serviceentry_impl;
-
-class option_impl;
-class configuration_option_impl;
-class ipv4_option_impl;
-class ipv6_option_impl;
-class load_balancing_option_impl;
-class protection_option_impl;
-
-class message_impl: public vsomeip::message, public vsomeip::message_base_impl {
-public:
- typedef std::vector<std::shared_ptr<entry_impl>> entries_t;
- typedef std::vector<std::shared_ptr<option_impl>> options_t;
- struct forced_initial_events_t {
- std::shared_ptr<vsomeip::endpoint_definition> target_;
- vsomeip::service_t service_;
- vsomeip::instance_t instance_;
- vsomeip::eventgroup_t eventgroup_;
- };
- message_impl();
- virtual ~message_impl();
-
- length_t get_length() const;
- void set_length(length_t _length);
-
- bool get_reboot_flag() const;
- void set_reboot_flag(bool _is_set);
-
- bool get_unicast_flag() const;
- void set_unicast_flag(bool _is_set);
-
- std::shared_ptr<eventgroupentry_impl> create_eventgroup_entry();
- std::shared_ptr<serviceentry_impl> create_service_entry();
-
- std::shared_ptr<configuration_option_impl> create_configuration_option();
- std::shared_ptr<ipv4_option_impl> create_ipv4_option(bool _is_multicast);
- std::shared_ptr<ipv6_option_impl> create_ipv6_option(bool _is_multicast);
- std::shared_ptr<load_balancing_option_impl> create_load_balancing_option();
- std::shared_ptr<protection_option_impl> create_protection_option();
-
- const entries_t & get_entries() const;
- const options_t & get_options() const;
-
- int16_t get_option_index(const std::shared_ptr<option_impl> &_option) const;
- uint32_t get_options_length();
-
- std::shared_ptr<payload> get_payload() const;
- void set_payload(std::shared_ptr<payload> _payload);
-
- bool serialize(vsomeip::serializer *_to) const;
- bool deserialize(vsomeip::deserializer *_from);
-
- length_t get_someip_length() const;
-
- std::uint8_t get_number_required_acks() const;
- std::uint8_t get_number_contained_acks() const;
- void set_number_required_acks(std::uint8_t _required_acks);
- void increase_number_required_acks(std::uint8_t _amount = 1);
- void decrease_number_required_acks(std::uint8_t _amount = 1);
- void increase_number_contained_acks();
- bool all_required_acks_contained() const;
- std::unique_lock<std::mutex> get_message_lock();
-
- void forced_initial_events_add(forced_initial_events_t _entry);
- const std::vector<forced_initial_events_t> forced_initial_events_get();
-
- void set_initial_events_required(bool _initial_events_required);
- bool initial_events_required() const;
-
-private:
- entry_impl * deserialize_entry(vsomeip::deserializer *_from);
- option_impl * deserialize_option(vsomeip::deserializer *_from);
-
-private:
- flags_t flags_;
- uint32_t options_length_;
-
- entries_t entries_;
- options_t options_;
- std::atomic<std::uint8_t> number_required_acks_;
- std::atomic<std::uint8_t> number_contained_acks_;
- std::mutex message_mutex_;
-
- std::mutex forced_initial_events_mutex_;
- std::vector<forced_initial_events_t> forced_initial_events_info_;
-
- std::atomic<bool> initial_events_required_;
-};
-
-} // namespace sd
-} // namespace vsomeip
-
-#endif // VSOMEIP_INTERNAL_SD_MESSAGE_IMPL_HPP
+// Copyright (C) 2014-2018 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_SD_MESSAGE_IMPL_HPP_ +#define VSOMEIP_V3_SD_MESSAGE_IMPL_HPP_ + +#include <atomic> +#include <memory> +#include <mutex> +#include <vector> + +#include <vsomeip/message.hpp> + +#include "../include/primitive_types.hpp" +#include "../../message/include/message_base_impl.hpp" +#include "../../endpoints/include/endpoint_definition.hpp" + +# if _MSC_VER >= 1300 +/* +* Diamond inheritance is used for the vsomeip::message_base base class. +* The Microsoft compiler put warning (C4250) using a desired c++ feature: "Delegating to a sister class" +* A powerful technique that arises from using virtual inheritance is to delegate a method from a class in another class +* by using a common abstract base class. This is also called cross delegation. +*/ +# pragma warning( disable : 4250 ) +# endif + +namespace vsomeip_v3 { +namespace sd { + +class entry_impl; +class eventgroupentry_impl; +class serviceentry_impl; + +class option_impl; +class configuration_option_impl; +class ipv4_option_impl; +class ipv6_option_impl; +class load_balancing_option_impl; +class protection_option_impl; +class selective_option_impl; + +class message_impl + : public vsomeip_v3::message, public vsomeip_v3::message_base_impl { +public: + typedef std::vector<std::shared_ptr<entry_impl>> entries_t; + typedef std::vector<std::shared_ptr<option_impl>> options_t; + struct forced_initial_events_t { + std::shared_ptr<vsomeip_v3::endpoint_definition> target_; + vsomeip_v3::service_t service_; + vsomeip_v3::instance_t instance_; + vsomeip_v3::eventgroup_t eventgroup_; + }; + message_impl(); + virtual ~message_impl(); + + length_t get_length() const; + void set_length(length_t _length); + + length_t get_size() const; + + bool get_reboot_flag() const; + void set_reboot_flag(bool _is_set); + + bool get_unicast_flag() const; + void set_unicast_flag(bool _is_set); + + bool has_entry() const; + bool has_option() const; + + const entries_t & get_entries() const; + const options_t & get_options() const; + + bool add_entry_data(const std::shared_ptr<entry_impl> &_entry, + const std::vector<std::shared_ptr<option_impl> > &_options, + const std::shared_ptr<entry_impl> &_other = nullptr); + + std::shared_ptr<option_impl> find_option( + const std::shared_ptr<option_impl> &_option) const; + + int16_t get_option_index(const std::shared_ptr<option_impl> &_option) const; + std::shared_ptr<option_impl> get_option(int16_t _index) const; + uint32_t get_options_length(); + + std::shared_ptr<payload> get_payload() const; + void set_payload(std::shared_ptr<payload> _payload); + + uint8_t get_check_result() const; + void set_check_result(uint8_t _check_result); + bool is_valid_crc() const; + + bool serialize(vsomeip_v3::serializer *_to) const; + bool deserialize(vsomeip_v3::deserializer *_from); + + length_t get_someip_length() const; + + void forced_initial_events_add(forced_initial_events_t _entry); + const std::vector<forced_initial_events_t> forced_initial_events_get(); + + void set_initial_events_required(bool _initial_events_required); + bool initial_events_required() const; + + uid_t get_uid() const; + gid_t get_gid() const; + +private: + entry_impl * deserialize_entry(vsomeip_v3::deserializer *_from); + option_impl * deserialize_option(vsomeip_v3::deserializer *_from); + +private: + flags_t flags_; + uint32_t options_length_; + + entries_t entries_; + options_t options_; + + std::mutex message_mutex_; + + std::uint32_t current_message_size_; +}; + +} // namespace sd +} // namespace vsomeip_v3 + +#endif // VSOMEIP_V3_SD_MESSAGE_IMPL_HPP_ diff --git a/implementation/service_discovery/include/option_impl.hpp b/implementation/service_discovery/include/option_impl.hpp index c4426e9..e171c74 100644 --- a/implementation/service_discovery/include/option_impl.hpp +++ b/implementation/service_discovery/include/option_impl.hpp @@ -1,44 +1,50 @@ -// 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_SD_OPTION_IMPL_HPP
-#define VSOMEIP_SD_OPTION_IMPL_HPP
-
-#include <cstdint>
-
-#include "enumeration_types.hpp"
-#include "message_element_impl.hpp"
-
-namespace vsomeip {
-
-class serializer;
-class deserializer;
-
-namespace sd {
-
-class message_impl;
-
-class option_impl: public message_element_impl {
-public:
- option_impl();
- virtual ~option_impl();
-
- virtual bool operator ==(const option_impl &_other) const;
-
- uint16_t get_length() const;
- option_type_e get_type() const;
-
- virtual bool serialize(vsomeip::serializer *_to) const;
- virtual bool deserialize(vsomeip::deserializer *_from);
-
-protected:
- uint16_t length_;
- option_type_e type_;
-};
-
-} // namespace sd
-} // namespace vsomeip
-
-#endif // VSOMEIP_INTERNAL_SD_OPTION_IMPL_HPP
+// Copyright (C) 2014-2018 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_SD_OPTION_IMPL_HPP_ +#define VSOMEIP_V3_SD_OPTION_IMPL_HPP_ + +#include <cstdint> +#include <memory> + +#include "enumeration_types.hpp" +#include "message_element_impl.hpp" + +namespace vsomeip_v3 { + +class serializer; +class deserializer; + +namespace sd { + +class message_impl; + +class option_impl: public message_element_impl { +public: + option_impl(); + virtual ~option_impl(); + + virtual bool operator ==(const option_impl &_other) const; + bool equals(const std::shared_ptr<option_impl> &_other) const; + + uint16_t get_length() const; + option_type_e get_type() const; + + inline uint32_t get_size() const { + return static_cast<uint32_t>(length_) + 3; + } + + virtual bool serialize(vsomeip_v3::serializer *_to) const; + virtual bool deserialize(vsomeip_v3::deserializer *_from); + +protected: + uint16_t length_; + option_type_e type_; +}; + +} // namespace sd +} // namespace vsomeip_v3 + +#endif // VSOMEIP_V3_SD_OPTION_IMPL_HPP_ diff --git a/implementation/service_discovery/include/primitive_types.hpp b/implementation/service_discovery/include/primitive_types.hpp index f3a0c9f..fd093e9 100644 --- a/implementation/service_discovery/include/primitive_types.hpp +++ b/implementation/service_discovery/include/primitive_types.hpp @@ -1,14 +1,14 @@ -// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2018 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/. #include <cstdint> -#ifndef VSOMEIP_SD_PRIMITIVE_TYPES_HPP -#define VSOMEIP_SD_PRIMITIVE_TYPES_HPP +#ifndef VSOMEIP_V3_SD_PRIMITIVE_TYPES_HPP_ +#define VSOMEIP_V3_SD_PRIMITIVE_TYPES_HPP_ -namespace vsomeip { +namespace vsomeip_v3 { namespace sd { // Load balancing @@ -23,6 +23,6 @@ typedef uint32_t crc_t; typedef uint8_t flags_t; } // namespace sd -} // namespace vsomeip +} // namespace vsomeip_v3 -#endif // VSOMEIP_SD_PRIMITIVE_TYPES_HPP +#endif // VSOMEIP_V3_SD_PRIMITIVE_TYPES_HPP_ diff --git a/implementation/service_discovery/include/protection_option_impl.hpp b/implementation/service_discovery/include/protection_option_impl.hpp index 33d5849..792d7cc 100755 --- a/implementation/service_discovery/include/protection_option_impl.hpp +++ b/implementation/service_discovery/include/protection_option_impl.hpp @@ -1,38 +1,39 @@ -// 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_SD_PROTECTION_OPTION_IMPL_HPP
-#define VSOMEIP_SD_PROTECTION_OPTION_IMPL_HPP
-
-#include "../include/primitive_types.hpp"
-#include "../include/option_impl.hpp"
-
-namespace vsomeip {
-namespace sd {
-
-class protection_option_impl: public option_impl {
-public:
- protection_option_impl();
- virtual ~protection_option_impl();
- bool operator ==(const protection_option_impl &_other) const;
-
- alive_counter_t get_alive_counter() const;
- void set_alive_counter(alive_counter_t _counter);
-
- crc_t get_crc() const;
- void set_crc(crc_t _crc);
-
- bool serialize(vsomeip::serializer *_to) const;
- bool deserialize(vsomeip::deserializer *_from);
-
-private:
- alive_counter_t counter_;
- crc_t crc_;
-};
-
-} // namespace sd
-} // namespace vsomeip
-
-#endif // VSOMEIP_SD_PROTECTION_OPTION_IMPL_HPP
+// Copyright (C) 2014-2018 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_SD_PROTECTION_OPTION_IMPL_HPP_ +#define VSOMEIP_V3_SD_PROTECTION_OPTION_IMPL_HPP_ + +#include "../include/primitive_types.hpp" +#include "../include/option_impl.hpp" + +namespace vsomeip_v3 { +namespace sd { + +class protection_option_impl: public option_impl { +public: + protection_option_impl(); + virtual ~protection_option_impl(); + + bool operator ==(const option_impl &_other) const; + + alive_counter_t get_alive_counter() const; + void set_alive_counter(alive_counter_t _counter); + + crc_t get_crc() const; + void set_crc(crc_t _crc); + + bool serialize(vsomeip_v3::serializer *_to) const; + bool deserialize(vsomeip_v3::deserializer *_from); + +private: + alive_counter_t counter_; + crc_t crc_; +}; + +} // namespace sd +} // namespace vsomeip_v3 + +#endif // VSOMEIP_V3_SD_PROTECTION_OPTION_IMPL_HPP_ diff --git a/implementation/service_discovery/include/remote_subscription_ack.hpp b/implementation/service_discovery/include/remote_subscription_ack.hpp new file mode 100644 index 0000000..1bc8792 --- /dev/null +++ b/implementation/service_discovery/include/remote_subscription_ack.hpp @@ -0,0 +1,64 @@ +// Copyright (C) 2018 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_SD_REMOTE_SUBSCRIPTION_ACK_HPP_ +#define VSOMEIP_V3_SD_REMOTE_SUBSCRIPTION_ACK_HPP_ + +#include <memory> +#include <mutex> +#include <set> + +namespace vsomeip_v3 { + +class remote_subscription; + +namespace sd { + +class message_impl; + +class remote_subscription_ack { +public: + remote_subscription_ack(const boost::asio::ip::address &_address); + + // The complete flag signals whether or not all subscribes + // of a message have been inserted. + bool is_complete() const; + void complete(); + + // The done flag signals whether or not all subscribes + // have been processed. + bool is_done() const; + void done(); + + std::vector<std::shared_ptr<message_impl> > get_messages() const; + std::shared_ptr<message_impl> get_current_message() const; + std::shared_ptr<message_impl> add_message(); + + boost::asio::ip::address get_target_address() const; + + bool is_pending() const; + + std::set<std::shared_ptr<remote_subscription> > get_subscriptions() const; + void add_subscription( + const std::shared_ptr<remote_subscription> &_subscription); + bool has_subscription() const; + + std::unique_lock<std::recursive_mutex> get_lock(); + +private: + std::recursive_mutex mutex_; + std::vector<std::shared_ptr<message_impl> > messages_; + bool is_complete_; + bool is_done_; + + const boost::asio::ip::address target_address_; + + std::set<std::shared_ptr<remote_subscription> > subscriptions_; +}; + +} // namespace sd +} // namespace vsomeip_v3 + +#endif // VSOMEIP_V3_SD_REMOTE_SUBSCRIPTION_ACK_HPP_ diff --git a/implementation/service_discovery/include/request.hpp b/implementation/service_discovery/include/request.hpp index b835202..0e6e2ec 100644 --- a/implementation/service_discovery/include/request.hpp +++ b/implementation/service_discovery/include/request.hpp @@ -1,16 +1,16 @@ -// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2018 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_SD_REQUEST_HPP -#define VSOMEIP_SD_REQUEST_HPP +#ifndef VSOMEIP_V3_SD_REQUEST_HPP_ +#define VSOMEIP_V3_SD_REQUEST_HPP_ #include <memory> #include <vsomeip/primitive_types.hpp> -namespace vsomeip { +namespace vsomeip_v3 { class endpoint; @@ -41,6 +41,6 @@ private: }; } // namespace sd -} // namespace vsomeip +} // namespace vsomeip_v3 -#endif // VSOMEIP_SD_SUBSCRIPTION_HPP +#endif // VSOMEIP_V3_SD_REQUEST_HPP_ diff --git a/implementation/service_discovery/include/runtime.hpp b/implementation/service_discovery/include/runtime.hpp index 670a7bb..0772de4 100644 --- a/implementation/service_discovery/include/runtime.hpp +++ b/implementation/service_discovery/include/runtime.hpp @@ -1,36 +1,38 @@ -// 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_SD_RUNTIME_HPP
-#define VSOMEIP_SD_RUNTIME_HPP
-
-#include <memory>
-
-namespace vsomeip {
-
-class configuration;
-
-namespace sd {
-
-class message_impl;
-class service_discovery;
-class service_discovery_host;
-
-class runtime {
-public:
- virtual ~runtime() {
- }
-
- virtual std::shared_ptr<service_discovery> create_service_discovery(
- service_discovery_host *_host,
- std::shared_ptr<vsomeip::configuration> _configuration) const = 0;
- virtual std::shared_ptr<message_impl> create_message() const = 0;
-};
-
-} // namespace sd
-} // namespace vsomeip
-
-#endif // VSOMEIP_SD_RUNTIME_HPP
-
+// Copyright (C) 2014-2018 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_SD_RUNTIME_HPP_ +#define VSOMEIP_V3_SD_RUNTIME_HPP_ + +#include <memory> + +namespace vsomeip_v3 { + +class configuration; + +namespace sd { + +class message_impl; +class service_discovery; +class service_discovery_host; + +class runtime { +public: + virtual ~runtime() +#ifndef ANDROID + {} +#else + ; +#endif + + virtual std::shared_ptr<service_discovery> create_service_discovery( + service_discovery_host *_host, + std::shared_ptr<configuration> _configuration) const = 0; +}; + +} // namespace sd +} // namespace vsomeip_v3 + +#endif // VSOMEIP_V3_SD_RUNTIME_HPP_ diff --git a/implementation/service_discovery/include/runtime_impl.hpp b/implementation/service_discovery/include/runtime_impl.hpp index 0a9baaf..0010de6 100644 --- a/implementation/service_discovery/include/runtime_impl.hpp +++ b/implementation/service_discovery/include/runtime_impl.hpp @@ -1,15 +1,15 @@ -// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2018 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_SD_RUNTIME_IMPL_HPP -#define VSOMEIP_SD_RUNTIME_IMPL_HPP +#ifndef VSOMEIP_V3_SD_RUNTIME_IMPL_HPP_ +#define VSOMEIP_V3_SD_RUNTIME_IMPL_HPP_ #include <vsomeip/plugin.hpp> #include "runtime.hpp" -namespace vsomeip { +namespace vsomeip_v3 { namespace sd { class runtime_impl @@ -22,10 +22,10 @@ public: std::shared_ptr<service_discovery> create_service_discovery( service_discovery_host *_host, std::shared_ptr<configuration> _configuration) const; - std::shared_ptr<message_impl> create_message() const; }; } // namespace sd -} // namespace vsomeip +} // namespace vsomeip_v3 + +#endif // VSOMEIP_V3_SD_RUNTIME_IMPL_HPP_ -#endif // VSOMEIP_SD_RUNTIME_IMPL_HPP diff --git a/implementation/service_discovery/include/selective_option_impl.hpp b/implementation/service_discovery/include/selective_option_impl.hpp new file mode 100644 index 0000000..0660f1e --- /dev/null +++ b/implementation/service_discovery/include/selective_option_impl.hpp @@ -0,0 +1,46 @@ +// Copyright (C) 2018 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_SD_SELECTIVE_OPTION_IMPL_HPP +#define VSOMEIP_V3_SD_SELECTIVE_OPTION_IMPL_HPP + +#include <set> + +#include <vsomeip/primitive_types.hpp> + +#include "option_impl.hpp" + +namespace vsomeip_v3 { + +class serializer; +class deserializer; + +namespace sd { + +class selective_option_impl: public option_impl { + +public: + selective_option_impl(); + virtual ~selective_option_impl(); + + bool operator==(const option_impl &_other) const; + + std::set<client_t> get_clients() const; + bool add_client(client_t _client); + bool remove_client(client_t _client); + bool has_clients() const; + bool has_client(client_t _client); + + bool serialize(vsomeip_v3::serializer *_to) const; + bool deserialize(vsomeip_v3::deserializer *_from); + +private: + std::set<client_t> clients_; +}; + +} // namespace sd +} // namespace vsomeip_v3 + +#endif // VSOMEIP_V3_SD_SELECTIVE_OPTION_IMPL_HPP diff --git a/implementation/service_discovery/include/service_discovery.hpp b/implementation/service_discovery/include/service_discovery.hpp index e1c3dc4..0a5adc0 100644 --- a/implementation/service_discovery/include/service_discovery.hpp +++ b/implementation/service_discovery/include/service_discovery.hpp @@ -3,8 +3,8 @@ // 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_SERVICE_DISCOVERY_HPP -#define VSOMEIP_SERVICE_DISCOVERY_HPP +#ifndef VSOMEIP_V3_SD_SERVICE_DISCOVERY_HPP_ +#define VSOMEIP_V3_SD_SERVICE_DISCOVERY_HPP_ #include <boost/asio/io_service.hpp> #include <boost/asio/ip/address.hpp> @@ -16,7 +16,7 @@ #include "../../endpoints/include/endpoint.hpp" #include "../include/service_discovery_host.hpp" -namespace vsomeip { +namespace vsomeip_v3 { class configuration; @@ -38,13 +38,11 @@ public: virtual void release_service(service_t _service, instance_t _instance) = 0; virtual void subscribe(service_t _service, instance_t _instance, - eventgroup_t _eventgroup, major_version_t _major, ttl_t _ttl, client_t _client, - subscription_type_e _subscription_type) = 0; + eventgroup_t _eventgroup, major_version_t _major, + ttl_t _ttl, client_t _client) = 0; virtual void unsubscribe(service_t _service, instance_t _instance, eventgroup_t _eventgroup, client_t _client) = 0; virtual void unsubscribe_all(service_t _service, instance_t _instance) = 0; - virtual void unsubscribe_client(service_t _service, instance_t _instance, - client_t _client) = 0; virtual bool send(bool _is_announcing) = 0; @@ -52,34 +50,27 @@ public: const boost::asio::ip::address &_sender, const boost::asio::ip::address &_destination) = 0; - virtual void send_subscriptions(service_t _service, instance_t _instance, - client_t _client, bool _reliable) = 0; - virtual void on_endpoint_connected( service_t _service, instance_t _instance, - const std::shared_ptr<const vsomeip::endpoint> &_endpoint) = 0; + const std::shared_ptr<endpoint> &_endpoint) = 0; - virtual void offer_service(service_t _service, instance_t _instance, - std::shared_ptr<serviceinfo> _info) = 0; - virtual void stop_offer_service(service_t _service, instance_t _instance, - std::shared_ptr<serviceinfo> _info) = 0; + virtual void offer_service(const std::shared_ptr<serviceinfo> &_info) = 0; + virtual void stop_offer_service(const std::shared_ptr<serviceinfo> &_info) = 0; virtual void set_diagnosis_mode(const bool _activate) = 0; virtual bool get_diagnosis_mode() = 0; - virtual void remote_subscription_acknowledge( - service_t _service, instance_t _instance, eventgroup_t _eventgroup, - client_t _client, bool _accepted, - const std::shared_ptr<sd_message_identifier_t> &_sd_message_id) = 0; + virtual void update_remote_subscription( + const std::shared_ptr<remote_subscription> &_subscription) = 0; - virtual void register_offer_acceptance_handler( - vsomeip::offer_acceptance_handler_t _handler) = 0; + virtual void register_sd_acceptance_handler( + sd_acceptance_handler_t _handler) = 0; virtual void register_reboot_notification_handler( reboot_notification_handler_t _handler) = 0; }; } // namespace sd -} // namespace vsomeip +} // namespace vsomeip_v3 -#endif // VSOMEIP_SERVICE_DISCOVERY_HPP +#endif // VSOMEIP_V3_SD_SERVICE_DISCOVERY_HPP_ diff --git a/implementation/service_discovery/include/service_discovery_host.hpp b/implementation/service_discovery/include/service_discovery_host.hpp index 9c346fd..94b67ec 100644 --- a/implementation/service_discovery/include/service_discovery_host.hpp +++ b/implementation/service_discovery/include/service_discovery_host.hpp @@ -1,10 +1,10 @@ -// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2018 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_SERVICE_DISCOVERY_HOST_HPP -#define VSOMEIP_SERVICE_DISCOVERY_HOST_HPP +#ifndef VSOMEIP_V3_SERVICE_DISCOVERY_HOST_HPP_ +#define VSOMEIP_V3_SERVICE_DISCOVERY_HOST_HPP_ #include <map> #include <memory> @@ -13,11 +13,12 @@ #include <boost/asio/ip/address.hpp> #include <boost/asio/io_service.hpp> +#include "../../routing/include/function_types.hpp" #include "../../routing/include/types.hpp" #include <vsomeip/message.hpp> -namespace vsomeip { +namespace vsomeip_v3 { class configuration; class endpoint; @@ -39,10 +40,9 @@ public: virtual std::shared_ptr<eventgroupinfo> find_eventgroup(service_t _service, instance_t _instance, eventgroup_t _eventgroup) const = 0; - virtual bool send(client_t _client, std::shared_ptr<message> _message, - bool _flush) = 0; + virtual bool send(client_t _client, std::shared_ptr<message> _message) = 0; - virtual bool send_to(const std::shared_ptr<endpoint_definition> &_target, + virtual bool send_via_sd(const std::shared_ptr<endpoint_definition> &_target, const byte_t *_data, uint32_t _size, uint16_t _sd_port) = 0; virtual void add_routing_info(service_t _service, instance_t _instance, @@ -57,37 +57,30 @@ public: virtual void update_routing_info(std::chrono::milliseconds _elapsed) = 0; - virtual void on_unsubscribe(service_t _service, instance_t _instance, - eventgroup_t _eventgroup, - std::shared_ptr<endpoint_definition> _target) = 0; - - virtual void on_subscribe_ack(service_t _service, instance_t _instance, - const boost::asio::ip::address &_address, uint16_t _port) = 0; + virtual void on_remote_unsubscribe( + std::shared_ptr<remote_subscription> &_subscription) = 0; virtual void on_subscribe_ack(client_t _client, service_t _service, instance_t _instance, eventgroup_t _eventgroup, - event_t _event, pending_subscription_id_t _subscription_id) = 0; + event_t _event, remote_subscription_id_t _subscription_id) = 0; - virtual std::shared_ptr<endpoint> find_or_create_remote_client( + virtual void on_subscribe_ack_with_multicast( service_t _service, instance_t _instance, - bool _reliable, client_t _client) = 0; + const boost::asio::ip::address &_address, uint16_t _port) = 0; + + virtual std::shared_ptr<endpoint> find_or_create_remote_client( + service_t _service, instance_t _instance, bool _reliable, client_t _client) = 0; virtual void expire_subscriptions(const boost::asio::ip::address &_address) = 0; virtual void expire_services(const boost::asio::ip::address &_address) = 0; - virtual void on_remote_subscription( - service_t _service, instance_t _instance, eventgroup_t _eventgroup, - const std::shared_ptr<endpoint_definition> &_subscriber, - const std::shared_ptr<endpoint_definition> &_target, ttl_t _ttl, - const std::shared_ptr<sd_message_identifier_t> &_sd_message_id, - const std::function<void(remote_subscription_state_e, client_t)>& _callback) = 0; + virtual void on_remote_subscribe( + std::shared_ptr<remote_subscription> &_subscription, + const remote_subscription_callback_t& _callback) = 0; virtual void on_subscribe_nack(client_t _client, service_t _service, instance_t _instance, eventgroup_t _eventgroup, - event_t _event, pending_subscription_id_t _subscription_id) = 0; - - virtual bool has_identified(client_t _client, service_t _service, - instance_t _instance, bool _reliable) = 0; + event_t _event, remote_subscription_id_t _subscription_id) = 0; virtual std::chrono::steady_clock::time_point expire_subscriptions(bool _force) = 0; @@ -95,13 +88,10 @@ public: service_t _service, instance_t _instance) const = 0; virtual std::map<instance_t, std::shared_ptr<serviceinfo>> get_offered_service_instances( service_t _service) const = 0; - - virtual void send_initial_events(service_t _service, instance_t _instance, - eventgroup_t _eventgroup, - const std::shared_ptr<endpoint_definition>& _subscriber) = 0; }; } // namespace sd -} // namespace vsomeip +} // namespace vsomeip_v3 + +#endif // VSOMEIP_V3_SERVICE_DISCOVERY_HOST_HPP_ -#endif // VSOMEIP_SERVICE_DISCOVERY_HOST_HPP diff --git a/implementation/service_discovery/include/service_discovery_impl.hpp b/implementation/service_discovery/include/service_discovery_impl.hpp index 77dbae9..ba3c723 100644 --- a/implementation/service_discovery/include/service_discovery_impl.hpp +++ b/implementation/service_discovery/include/service_discovery_impl.hpp @@ -1,10 +1,10 @@ -// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2018 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_SERVICE_DISCOVERY_IMPL -#define VSOMEIP_SERVICE_DISCOVERY_IMPL +#ifndef VSOMEIP_V3_SD_SERVICE_DISCOVERY_IMPL_ +#define VSOMEIP_V3_SD_SERVICE_DISCOVERY_IMPL_ #include <map> #include <memory> @@ -16,16 +16,19 @@ #include <boost/asio/steady_timer.hpp> -#include "service_discovery.hpp" +#include "../../configuration/include/configuration.hpp" #include "../../endpoints/include/endpoint_definition.hpp" #include "../../routing/include/types.hpp" +#include "../../routing/include/remote_subscription.hpp" + +#include "service_discovery.hpp" #include "ip_option_impl.hpp" #include "ipv4_option_impl.hpp" #include "ipv6_option_impl.hpp" #include "deserializer.hpp" -#include "../../configuration/include/configuration.hpp" +#include "message_impl.hpp" -namespace vsomeip { +namespace vsomeip_v3 { class endpoint; class serializer; @@ -35,29 +38,29 @@ namespace sd { class entry_impl; class eventgroupentry_impl; class option_impl; +class remote_subscription_ack; class request; class serviceentry_impl; class service_discovery_host; class subscription; -typedef std::map<service_t, std::map<instance_t, std::shared_ptr<request> > > requests_t; - -struct subscriber_t { - std::shared_ptr<endpoint_definition> subscriber; - std::shared_ptr<endpoint_definition> target; - std::shared_ptr<sd_message_identifier_t> response_message_id_; - std::shared_ptr<eventgroupinfo> eventgroupinfo_; - vsomeip::ttl_t ttl_; - vsomeip::major_version_t major_; - std::uint16_t reserved_; - std::uint8_t counter_; +typedef std::map<service_t, + std::map<instance_t, + std::shared_ptr<request> + > + > requests_t; + +struct entry_data_t { + std::shared_ptr<entry_impl> entry_; + std::vector<std::shared_ptr<option_impl> > options_; + std::shared_ptr<entry_impl> other_; }; class service_discovery_impl: public service_discovery, public std::enable_shared_from_this<service_discovery_impl> { public: service_discovery_impl(service_discovery_host *_host, - std::shared_ptr<configuration> _configuration); + const std::shared_ptr<configuration>& _configuration); virtual ~service_discovery_impl(); boost::asio::io_service & get_io(); @@ -71,13 +74,11 @@ public: void release_service(service_t _service, instance_t _instance); void subscribe(service_t _service, instance_t _instance, - eventgroup_t _eventgroup, major_version_t _major, ttl_t _ttl, client_t _client, - subscription_type_e _subscription_type); + eventgroup_t _eventgroup, major_version_t _major, ttl_t _ttl, + client_t _client); void unsubscribe(service_t _service, instance_t _instance, eventgroup_t _eventgroup, client_t _client); void unsubscribe_all(service_t _service, instance_t _instance); - void unsubscribe_client(service_t _service, instance_t _instance, - client_t _client); bool send(bool _is_announcing); @@ -87,23 +88,20 @@ public: void on_endpoint_connected( service_t _service, instance_t _instance, - const std::shared_ptr<const vsomeip::endpoint> &_endpoint); + const std::shared_ptr<endpoint> &_endpoint); - void offer_service(service_t _service, instance_t _instance, - std::shared_ptr<serviceinfo> _info); - void stop_offer_service(service_t _service, instance_t _instance, - std::shared_ptr<serviceinfo> _info); + void offer_service(const std::shared_ptr<serviceinfo> &_info); + void stop_offer_service(const std::shared_ptr<serviceinfo> &_info); void set_diagnosis_mode(const bool _activate); bool get_diagnosis_mode(); - void remote_subscription_acknowledge( - service_t _service, instance_t _instance, eventgroup_t _eventgroup, - client_t _client, bool _acknowledged, - const std::shared_ptr<sd_message_identifier_t> &_sd_message_id); - void register_offer_acceptance_handler(offer_acceptance_handler_t _handler); + void update_remote_subscription( + const std::shared_ptr<remote_subscription> &_subscription); + + void register_sd_acceptance_handler(sd_acceptance_handler_t _handler); void register_reboot_notification_handler( reboot_notification_handler_t _handler); private: @@ -114,55 +112,43 @@ private: const boost::asio::ip::address &_destination, bool _reboot_flag, session_t _session); - void insert_option(std::shared_ptr<message_impl> &_message, - std::shared_ptr<entry_impl> _entry, - const boost::asio::ip::address &_address, uint16_t _port, - bool _is_reliable); - void insert_find_entries(std::shared_ptr<message_impl> &_message, - const requests_t &_requests, uint32_t _start, - uint32_t &_size, bool &_done); - void insert_offer_entries(std::shared_ptr<message_impl> &_message, - const services_t &_services, uint32_t &_start, - uint32_t _size, bool &_done, bool _ignore_phase); - bool insert_offer_service(std::shared_ptr<message_impl> _message, - service_t _service, instance_t _instance, - const std::shared_ptr<const serviceinfo> &_info, - uint32_t &_size); + void insert_find_entries(std::vector<std::shared_ptr<message_impl> > &_messages, + const requests_t &_requests); + void insert_offer_entries(std::vector<std::shared_ptr<message_impl> > &_messages, + const services_t &_services, bool _ignore_phase); + void insert_offer_service(std::vector<std::shared_ptr<message_impl> > &_messages, + const std::shared_ptr<const serviceinfo> &_info); enum remote_offer_type_e : std::uint8_t { RELIABLE_UNRELIABLE, RELIABLE, UNRELIABLE, UNKNOWN = 0xff }; - bool insert_subscription(std::shared_ptr<message_impl> &_message, - service_t _service, instance_t _instance, eventgroup_t _eventgroup, - std::shared_ptr<subscription> &_subscription, - remote_offer_type_e _offer_type); - bool insert_nack_subscription_on_resubscribe(std::shared_ptr<message_impl> &_message, + + entry_data_t create_eventgroup_entry( service_t _service, instance_t _instance, eventgroup_t _eventgroup, - std::shared_ptr<subscription> &_subscription, + const std::shared_ptr<subscription> &_subscription, remote_offer_type_e _offer_type); - void insert_subscription_ack(std::shared_ptr<message_impl> &_message, - service_t _service, instance_t _instance, eventgroup_t _eventgroup, + + void insert_subscription_ack( + const std::shared_ptr<remote_subscription_ack>& _acknowledgement, const std::shared_ptr<eventgroupinfo> &_info, ttl_t _ttl, - uint8_t _counter, major_version_t _major, uint16_t _reserved, - const std::shared_ptr<endpoint_definition> &_target = nullptr); - void insert_subscription_nack(std::shared_ptr<message_impl> &_message, service_t _service, - instance_t _instance, eventgroup_t _eventgroup, - uint8_t _counter, major_version_t _major, uint16_t _reserved); + const std::shared_ptr<endpoint_definition> &_target = nullptr, + const client_t _client = VSOMEIP_ROUTING_CLIENT); void process_serviceentry(std::shared_ptr<serviceentry_impl> &_entry, const std::vector<std::shared_ptr<option_impl> > &_options, - bool _unicast_flag, - std::vector<std::pair<std::uint16_t, std::shared_ptr<message_impl>>>* _resubscribes, - bool _accept_offers); + bool _unicast_flag, std::vector<std::shared_ptr<message_impl> > &_resubscribes, + bool _received_via_mcast, bool _accept_offers); void process_offerservice_serviceentry( service_t _service, instance_t _instance, major_version_t _major, minor_version_t _minor, ttl_t _ttl, const boost::asio::ip::address &_reliable_address, uint16_t _reliable_port, const boost::asio::ip::address &_unreliable_address, - uint16_t _unreliable_port, std::vector<std::pair<std::uint16_t, std::shared_ptr<message_impl>>>* _resubscribes); + uint16_t _unreliable_port, + std::vector<std::shared_ptr<message_impl> > &_resubscribes, + bool _received_via_mcast); void send_offer_service( const std::shared_ptr<const serviceinfo> &_info, service_t _service, instance_t _instance, major_version_t _major, minor_version_t _minor, @@ -176,11 +162,9 @@ private: void process_eventgroupentry( std::shared_ptr<eventgroupentry_impl> &_entry, const std::vector<std::shared_ptr<option_impl> > &_options, - std::shared_ptr < message_impl > &its_message_response, + std::shared_ptr<remote_subscription_ack> &_acknowledgement, const boost::asio::ip::address &_destination, - const std::shared_ptr<sd_message_identifier_t> &_message_id, - bool _is_stop_subscribe_subscribe, - bool _force_initial_events); + bool _is_stop_subscribe_subscribe, bool _force_initial_events); void handle_eventgroup_subscription(service_t _service, instance_t _instance, eventgroup_t _eventgroup, major_version_t _major, ttl_t _ttl, uint8_t _counter, uint16_t _reserved, @@ -188,22 +172,30 @@ private: bool _is_first_reliable, const boost::asio::ip::address &_second_address, uint16_t _second_port, bool _is_second_reliable, - std::shared_ptr < message_impl > &its_message, - const std::shared_ptr<sd_message_identifier_t> &_message_id, - bool _is_stop_subscribe_subscribe, - bool _force_initial_events); + std::shared_ptr<remote_subscription_ack> &_acknowledgement, + bool _is_stop_subscribe_subscribe, bool _force_initial_events, + const std::set<client_t> &_clients, + const std::shared_ptr<eventgroupinfo>& _info); void handle_eventgroup_subscription_ack(service_t _service, instance_t _instance, eventgroup_t _eventgroup, major_version_t _major, ttl_t _ttl, uint8_t _counter, + const std::set<client_t> &_clients, const boost::asio::ip::address &_address, uint16_t _port); void handle_eventgroup_subscription_nack(service_t _service, - instance_t _instance, eventgroup_t _eventgroup, uint8_t _counter); - void serialize_and_send(std::shared_ptr<message_impl> _message, + instance_t _instance, eventgroup_t _eventgroup, uint8_t _counter, + const std::set<client_t> &_clients); + + bool send(const std::vector<std::shared_ptr<message_impl>> &_messages); + bool serialize_and_send( + const std::vector<std::shared_ptr<message_impl>> &_messages, const boost::asio::ip::address &_address); + void update_acknowledgement( + const std::shared_ptr<remote_subscription_ack> &_acknowledgement); + bool is_tcp_connected(service_t _service, instance_t _instance, - std::shared_ptr<vsomeip::endpoint_definition> its_endpoint); + const std::shared_ptr<endpoint_definition>& its_endpoint); void start_ttl_timer(); void stop_ttl_timer(); @@ -221,33 +213,14 @@ private: bool check_static_header_fields( const std::shared_ptr<const message> &_message) const; bool check_layer_four_protocol( - const std::shared_ptr<const ip_option_impl> _ip_option) const; - void get_subscription_endpoints(std::shared_ptr<endpoint>& _unreliable, - std::shared_ptr<endpoint>& _reliable, - boost::asio::ip::address* _address, - bool* _has_address, - service_t _service, instance_t _instance, - client_t _client) const; - - void send_subscriptions(service_t _service, instance_t _instance, client_t _client, bool _reliable); - - template<class Option, typename AddressType> - std::shared_ptr<option_impl> find_existing_option( - std::shared_ptr<message_impl> &_message, - AddressType _address, uint16_t _port, - layer_four_protocol_e _protocol, - option_type_e _option_type); - template<class Option, typename AddressType> - bool check_message_for_ip_option_and_assign_existing( - std::shared_ptr<message_impl> &_message, - std::shared_ptr<entry_impl> _entry, AddressType _address, - uint16_t _port, layer_four_protocol_e _protocol, - option_type_e _option_type); - template<class Option, typename AddressType> - void assign_ip_option_to_entry(std::shared_ptr<Option> _option, - AddressType _address, uint16_t _port, - layer_four_protocol_e _protocol, - std::shared_ptr<entry_impl> _entry); + const std::shared_ptr<const ip_option_impl>& _ip_option) const; + + void get_subscription_endpoints(service_t _service, instance_t _instance, + std::shared_ptr<endpoint>& _reliable, + std::shared_ptr<endpoint>& _unreliable) const; + void get_subscription_address(const std::shared_ptr<endpoint> &_reliable, + const std::shared_ptr<endpoint> &_unreliable, + boost::asio::ip::address &_address) const; std::shared_ptr<request> find_request(service_t _service, instance_t _instance); @@ -261,71 +234,57 @@ private: void on_repetition_phase_timer_expired( const boost::system::error_code &_error, - std::shared_ptr<boost::asio::steady_timer> _timer, + const std::shared_ptr<boost::asio::steady_timer>& _timer, std::uint8_t _repetition, std::uint32_t _last_delay); void on_find_repetition_phase_timer_expired( const boost::system::error_code &_error, - std::shared_ptr<boost::asio::steady_timer> _timer, + const std::shared_ptr<boost::asio::steady_timer>& _timer, std::uint8_t _repetition, std::uint32_t _last_delay); void move_offers_into_main_phase( const std::shared_ptr<boost::asio::steady_timer> &_timer); - void fill_message_with_offer_entries( - std::shared_ptr<runtime> _runtime, - std::shared_ptr<message_impl> _message, - std::vector<std::shared_ptr<message_impl>> &_messages, - const services_t &_offers, bool _ignore_phase); - - void fill_message_with_find_entries( - std::shared_ptr<runtime> _runtime, - std::shared_ptr<message_impl> _message, - std::vector<std::shared_ptr<message_impl>> &_messages, - const requests_t &_requests); - - bool serialize_and_send_messages( - const std::vector<std::shared_ptr<message_impl>> &_messages); - - bool send_stop_offer(service_t _service, instance_t _instance, - std::shared_ptr<serviceinfo> _info); + bool send_stop_offer(const std::shared_ptr<serviceinfo>& _info); void start_main_phase_timer(); void on_main_phase_timer_expired(const boost::system::error_code &_error); void send_uni_or_multicast_offerservice( - service_t _service, instance_t _instance, major_version_t _major, - minor_version_t _minor, const std::shared_ptr<const serviceinfo> &_info, bool _unicast_flag); bool last_offer_shorter_half_offer_delay_ago(); void send_unicast_offer_service( - const std::shared_ptr<const serviceinfo> &_info, service_t _service, - instance_t _instance, major_version_t _major, - minor_version_t _minor); + const std::shared_ptr<const serviceinfo> &_info); void send_multicast_offer_service( - const std::shared_ptr<const serviceinfo>& _info, service_t _service, - instance_t _instance, major_version_t _major, - minor_version_t _minor); + const std::shared_ptr<const serviceinfo>& _info); bool check_source_address(const boost::asio::ip::address &its_source_address) const; - void update_subscription_expiration_timer(const std::shared_ptr<message_impl> &_message); + void update_subscription_expiration_timer( + const std::vector<std::shared_ptr<message_impl> > &_messages); - void remote_subscription_acknowledge_subscriber( + void remote_subscription_acknowledge( service_t _service, instance_t _instance, eventgroup_t _eventgroup, - const std::shared_ptr<subscriber_t> &_subscriber, bool _acknowledged); + const std::shared_ptr<remote_subscription> &_subscription); - void remote_subscription_not_acknowledge_subscriber( - service_t _service, instance_t _instance, eventgroup_t _eventgroup, - const std::shared_ptr<subscriber_t> &_subscriber, bool _acknowledged); + bool check_stop_subscribe_subscribe( + message_impl::entries_t::const_iterator _iter, + message_impl::entries_t::const_iterator _end, + const message_impl::options_t &_options) const; - void remote_subscription_not_acknowledge_all(service_t _service, instance_t _instance); + bool has_opposite( + message_impl::entries_t::const_iterator _iter, + message_impl::entries_t::const_iterator _end, + const message_impl::options_t &_options) const; - void remote_subscription_not_acknowledge_all(); + bool has_same( + message_impl::entries_t::const_iterator _iter, + message_impl::entries_t::const_iterator _end, + const message_impl::options_t &_options) const; - bool check_stop_subscribe_subscribe(message_impl::entries_t::const_iterator _iter, - message_impl::entries_t::const_iterator _end, - const message_impl::options_t& _options) const; + bool is_subscribed( + const std::shared_ptr<eventgroupentry_impl> &_entry, + const message_impl::options_t &_options) const; configuration::ttl_factor_t get_ttl_factor( service_t _service, instance_t _instance, @@ -333,8 +292,11 @@ private: void on_last_msg_received_timer_expired(const boost::system::error_code &_error); void stop_last_msg_received_timer(); + remote_offer_type_e get_remote_offer_type( + service_t _service, instance_t _instance) const; + remote_offer_type_e get_remote_offer_type( + const std::shared_ptr<subscription> &_subscription) const; - remote_offer_type_e get_remote_offer_type(service_t _service, instance_t _instance); bool update_remote_offer_type(service_t _service, instance_t _instance, remote_offer_type_e _offer_type, const boost::asio::ip::address &_reliable_address, @@ -343,11 +305,33 @@ private: const boost::asio::ip::address &_address); void remove_remote_offer_type_by_ip(const boost::asio::ip::address &_address); - std::vector<std::tuple<service_t, instance_t, eventgroup_t, - std::shared_ptr<endpoint_definition>>> - get_eventgroups_requiring_initial_events( - const std::shared_ptr<message_impl>& _response) const; + std::shared_ptr<subscription> create_subscription( + service_t _service, instance_t _instance, eventgroup_t _eventgroup, + major_version_t _major, ttl_t _ttl, + const std::shared_ptr<endpoint> &_reliable, + const std::shared_ptr<endpoint> &_unreliable); + std::shared_ptr<remote_subscription> get_remote_subscription( + const service_t _service, const instance_t _instance, + const eventgroup_t _eventgroup); + + void send_subscription_ack( + const std::shared_ptr<remote_subscription_ack> &_acknowledgement); + + std::shared_ptr<option_impl> create_ip_option( + const boost::asio::ip::address &_address, uint16_t _port, + bool _is_reliable) const; + + void send_subscription(const std::shared_ptr<subscription> &_subscription, + const service_t _service, const instance_t _instance, + const eventgroup_t _eventgroup, const client_t _client); + + void add_entry_data(std::vector<std::shared_ptr<message_impl>> &_messages, + const entry_data_t &_data); + + void add_entry_data_to_remote_subscription_ack_msg( + const std::shared_ptr<remote_subscription_ack>& _acknowledgement, + const entry_data_t &_data); private: boost::asio::io_service &io_; @@ -365,10 +349,12 @@ private: requests_t requested_; std::mutex requested_mutex_; std::map<service_t, - std::map<instance_t, - std::map<eventgroup_t, - std::map<client_t, - std::shared_ptr<subscription> > > > > subscribed_; + std::map<instance_t, + std::map<eventgroup_t, + std::shared_ptr<subscription> + > + > + > subscribed_; std::mutex subscribed_mutex_; std::mutex serialize_mutex_; @@ -434,10 +420,11 @@ private: std::atomic<bool> is_diagnosis_; std::mutex pending_remote_subscriptions_mutex_; - std::map<service_t, - std::map<instance_t, - std::map<eventgroup_t, - std::map<client_t, std::vector<std::shared_ptr<subscriber_t>>>>>> pending_remote_subscriptions_; + std::map<std::shared_ptr<remote_subscription>, + std::shared_ptr<remote_subscription_ack> + > pending_remote_subscriptions_; + std::mutex acknowledgement_mutex_; + std::mutex response_mutex_; configuration::ttl_map_t ttl_factor_offers_; @@ -447,18 +434,19 @@ private: boost::asio::steady_timer last_msg_received_timer_; std::chrono::milliseconds last_msg_received_timer_timeout_; - std::mutex remote_offer_types_mutex_; + mutable std::mutex remote_offer_types_mutex_; std::map<std::pair<service_t, instance_t>, remote_offer_type_e> remote_offer_types_; std::map<boost::asio::ip::address, std::set<std::pair<service_t, instance_t>>> remote_offers_by_ip_; reboot_notification_handler_t reboot_notification_handler_; - offer_acceptance_handler_t offer_acceptance_handler_; + sd_acceptance_handler_t sd_acceptance_handler_; std::mutex offer_mutex_; std::mutex check_ttl_mutex_; }; } // namespace sd -} // namespace vsomeip +} // namespace vsomeip_v3 + +#endif // VSOMEIP_V3_SD_SERVICE_DISCOVERY_IMPL_ -#endif // VSOMEIP_SERVICE_DISCOVERY_IMPL diff --git a/implementation/service_discovery/include/serviceentry_impl.hpp b/implementation/service_discovery/include/serviceentry_impl.hpp index c8ad7d0..f7b2b92 100644 --- a/implementation/service_discovery/include/serviceentry_impl.hpp +++ b/implementation/service_discovery/include/serviceentry_impl.hpp @@ -1,32 +1,32 @@ -// 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_SD_SERVICEENTRY_IMPL_HPP
-#define VSOMEIP_SD_SERVICEENTRY_IMPL_HPP
-
-#include "entry_impl.hpp"
-
-namespace vsomeip {
-namespace sd {
-
-class serviceentry_impl: public entry_impl {
-public:
- serviceentry_impl();
- virtual ~serviceentry_impl();
-
- minor_version_t get_minor_version() const;
- void set_minor_version(minor_version_t _version);
-
- bool serialize(vsomeip::serializer *_to) const;
- bool deserialize(vsomeip::deserializer *_from);
-
-private:
- minor_version_t minor_version_;
-};
-
-} // namespace sd
-} // namespace vsomeip
-
-#endif // VSOMEIP_SD_SERVICEENTRY_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_SD_SERVICEENTRY_IMPL_HPP +#define VSOMEIP_V3_SD_SERVICEENTRY_IMPL_HPP + +#include "entry_impl.hpp" + +namespace vsomeip_v3 { +namespace sd { + +class serviceentry_impl: public entry_impl { +public: + serviceentry_impl(); + virtual ~serviceentry_impl(); + + minor_version_t get_minor_version() const; + void set_minor_version(minor_version_t _version); + + bool serialize(vsomeip_v3::serializer *_to) const; + bool deserialize(vsomeip_v3::deserializer *_from); + +private: + minor_version_t minor_version_; +}; + +} // namespace sd +} // namespace vsomeip_v3 + +#endif // VSOMEIP_V3_SD_SERVICEENTRY_IMPL_HPP diff --git a/implementation/service_discovery/include/subscription.hpp b/implementation/service_discovery/include/subscription.hpp index 3c3bfe8..f172348 100644 --- a/implementation/service_discovery/include/subscription.hpp +++ b/implementation/service_discovery/include/subscription.hpp @@ -1,39 +1,52 @@ -// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2018 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_SD_SUBSCRIPTION_HPP -#define VSOMEIP_SD_SUBSCRIPTION_HPP +#ifndef VSOMEIP_V3_SD_SUBSCRIPTION_HPP_ +#define VSOMEIP_V3_SD_SUBSCRIPTION_HPP_ +#include <map> #include <memory> +#include <mutex> +#include <set> #include <vsomeip/primitive_types.hpp> #include <vsomeip/enumeration_types.hpp> -namespace vsomeip { +namespace vsomeip_v3 { class endpoint; namespace sd { +enum class subscription_state_e : uint8_t { + ST_ACKNOWLEDGED = 0x00, + ST_NOT_ACKNOWLEDGED = 0x01, + ST_RESUBSCRIBING = 0x2, + ST_RESUBSCRIBING_NOT_ACKNOWLEDGED = 0x3, + ST_UNKNOWN = 0xFF +}; + class subscription { public: - subscription(major_version_t _major, ttl_t _ttl, - std::shared_ptr<endpoint> _reliable, - std::shared_ptr<endpoint> _unreliable, - subscription_type_e _subscription_type, - uint8_t _counter); - ~subscription(); + subscription() = default; + ~subscription() = default; major_version_t get_major() const; + void set_major(major_version_t _major); + ttl_t get_ttl() const; void set_ttl(ttl_t _ttl); + std::shared_ptr<endpoint> get_endpoint(bool _reliable) const; - void set_endpoint(std::shared_ptr<endpoint> _endpoint, bool _reliable); + void set_endpoint(const std::shared_ptr<endpoint>& _endpoint, bool _reliable); + + bool is_selective() const; + void set_selective(const bool _is_selective); - bool is_acknowledged() const; - void set_acknowledged(bool _is_acknowledged); + subscription_state_e get_state(const client_t _client) const; + void set_state(const client_t _client, subscription_state_e _state); bool is_tcp_connection_established() const; void set_tcp_connection_established(bool _is_established); @@ -41,9 +54,11 @@ public: bool is_udp_connection_established() const; void set_udp_connection_established(bool _is_established); - subscription_type_e get_subscription_type() const; - - uint8_t get_counter() const; + bool add_client(const client_t _client); + bool remove_client(const client_t _client); + std::set<client_t> get_clients() const; + bool has_client() const; + bool has_client(const client_t _client) const; private: major_version_t major_; @@ -52,16 +67,17 @@ private: std::shared_ptr<endpoint> reliable_; std::shared_ptr<endpoint> unreliable_; - bool is_acknowledged_; + bool is_selective_; + bool tcp_connection_established_; bool udp_connection_established_; - subscription_type_e subscription_type_; - - uint8_t counter_; + mutable std::mutex clients_mutex_; + std::map<client_t, subscription_state_e> clients_; // client-> is acknowledged? }; } // namespace sd -} // namespace vsomeip +} // namespace vsomeip_v3 + +#endif // VSOMEIP_V3_SD_SUBSCRIPTION_HPP_ -#endif // VSOMEIP_SD_SUBSCRIPTION_HPP |