summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config/vsomeip.xml8
-rw-r--r--exportmap11
-rw-r--r--implementation/configuration/include/configuration_impl.hpp9
-rw-r--r--implementation/configuration/src/configuration_impl.cpp13
-rw-r--r--implementation/examples/client-sample.cpp14
-rw-r--r--implementation/examples/sample-ids.hpp18
-rw-r--r--implementation/examples/service-sample.cpp4
-rw-r--r--implementation/routing/include/routing_manager_impl.hpp11
-rw-r--r--implementation/routing/include/servicegroup.hpp (renamed from implementation/service_discovery/include/servicegroup.hpp)19
-rw-r--r--implementation/routing/include/serviceinfo.hpp (renamed from implementation/routing/include/service_info.hpp)10
-rw-r--r--implementation/routing/src/routing_manager_impl.cpp32
-rw-r--r--implementation/routing/src/service_info.cpp62
-rw-r--r--implementation/routing/src/servicegroup.cpp (renamed from implementation/service_discovery/src/servicegroup.cpp)10
-rw-r--r--implementation/routing/src/serviceinfo.cpp62
-rw-r--r--implementation/runtime/include/runtime_impl.hpp2
-rw-r--r--implementation/runtime/src/runtime_impl.cpp2
-rw-r--r--implementation/service_discovery/include/fsm_base.hpp37
-rw-r--r--implementation/service_discovery/include/fsm_events.hpp31
-rw-r--r--implementation/service_discovery/include/offer_fsm.hpp79
-rw-r--r--implementation/service_discovery/include/service_discovery_host.hpp6
-rw-r--r--implementation/service_discovery/include/service_discovery_impl.hpp4
-rw-r--r--implementation/service_discovery/src/fsm_base.cpp44
-rw-r--r--implementation/service_discovery/src/offer_fsm.cpp57
-rw-r--r--implementation/service_discovery/src/service_discovery_impl.cpp17
-rw-r--r--implementation/test/configuration-test.cpp2
-rw-r--r--interface/vsomeip/configuration.hpp2
-rw-r--r--interface/vsomeip/runtime.hpp2
27 files changed, 425 insertions, 143 deletions
diff --git a/config/vsomeip.xml b/config/vsomeip.xml
index 83cb54a..ddecf81 100644
--- a/config/vsomeip.xml
+++ b/config/vsomeip.xml
@@ -31,6 +31,14 @@
</ports>
<multicast>225.225.225.1</multicast>
</service>
+ <service>
+ <service-id>0x0248</service-id>
+ <instance-id>0x5422</instance-id>
+ <ports>
+ <unreliable>31010</unreliable>
+ </ports>
+ <multicast>225.225.225.2</multicast>
+ </service>
</servicegroup>
<servicegroup>
<address>10.0.2.15</address>
diff --git a/exportmap b/exportmap
index 6d588e3..2bcbb11 100644
--- a/exportmap
+++ b/exportmap
@@ -11,11 +11,14 @@ global:
*vsomeip::message_base_impl::*;
*vsomeip::runtime;
vsomeip::runtime::get*;
+ *vsomeip::servicegroup;
+ vsomeip::servicegroup::*;
+ *vsomeip::serviceinfo;
+ vsomeip::serviceinfo::*;
*vsomeip::sd::runtime;
- vsomeip::sd::runtime::get*;
- *vsomeip::sd::servicegroup;
- vsomeip::sd::servicegroup::*;
+ vsomeip::sd::runtime::*;
};
-local:
+ VSOMEIP_SD_RUNTIME;
+local:
*;
};
diff --git a/implementation/configuration/include/configuration_impl.hpp b/implementation/configuration/include/configuration_impl.hpp
index 717d6dc..c105893 100644
--- a/implementation/configuration/include/configuration_impl.hpp
+++ b/implementation/configuration/include/configuration_impl.hpp
@@ -40,7 +40,11 @@ public:
const std::string & get_logfile() const;
boost::log::trivial::severity_level get_loglevel() const;
+ std::string get_group(service_t _service, instance_t _instance) const;
std::string get_address(service_t _service, instance_t _instance) const;
+ uint16_t get_reliable_port(service_t _service, instance_t _instance) const;
+ uint16_t get_unreliable_port(service_t _service, instance_t _instance) const;
+ std::string get_multicast(service_t _service, instance_t _instance) const;
uint32_t get_min_initial_delay(service_t _service, instance_t _instance) const;
uint32_t get_max_initial_delay(service_t _service, instance_t _instance) const;
@@ -51,14 +55,9 @@ public:
uint32_t get_cyclic_offer_delay(service_t _service, instance_t _instance) const;
uint32_t get_cyclic_request_delay(service_t _service, instance_t _instance) const;
- uint16_t get_reliable_port(service_t _service, instance_t _instance) const;
- uint16_t get_unreliable_port(service_t _service, instance_t _instance) const;
- std::string get_multicast(service_t _service, instance_t _instance) const;
-
const std::string & get_routing_host() const;
bool is_service_discovery_enabled() const;
- const std::string & get_service_discovery_host() const;
const std::string & get_service_discovery_protocol() const;
uint16_t get_service_discovery_port() const;
diff --git a/implementation/configuration/src/configuration_impl.cpp b/implementation/configuration/src/configuration_impl.cpp
index 2abad15..56fc46c 100644
--- a/implementation/configuration/src/configuration_impl.cpp
+++ b/implementation/configuration/src/configuration_impl.cpp
@@ -484,6 +484,15 @@ uint32_t configuration_impl::get_cyclic_request_delay(service_t _service, instan
return its_delay;
}
+std::string configuration_impl::get_group(service_t _service, instance_t _instance) const {
+ std::string its_group("default");
+ service *its_service = find_service(_service, _instance);
+ if (nullptr != its_service) {
+ its_group = its_service->group_->name_;
+ }
+ return its_group;
+}
+
std::string configuration_impl::get_address(service_t _service, instance_t _instance) const {
std::string its_address("");
@@ -529,10 +538,6 @@ bool configuration_impl::is_service_discovery_enabled() const {
return is_service_discovery_enabled_;
}
-const std::string & configuration_impl::get_service_discovery_host() const {
- return service_discovery_host_;
-}
-
const std::string & configuration_impl::get_service_discovery_protocol() const {
return service_discovery_protocol_;
}
diff --git a/implementation/examples/client-sample.cpp b/implementation/examples/client-sample.cpp
index 327399f..7eb44e2 100644
--- a/implementation/examples/client-sample.cpp
+++ b/implementation/examples/client-sample.cpp
@@ -11,11 +11,7 @@
#include <vsomeip/vsomeip.hpp>
-#define SAMPLE_CYCLE 100
-
-#define SAMPLE_SERVICE_ID 0x1234
-#define SAMPLE_INSTANCE_ID 0x5678
-#define SAMPLE_METHOD_ID 0x0421
+#include "sample-ids.hpp"
class client_sample {
public:
@@ -30,6 +26,8 @@ public:
std::bind(&client_sample::on_availability,
this,
std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
+
+ app_->offer_service(OTHER_SAMPLE_SERVICE_ID, OTHER_SAMPLE_INSTANCE_ID);
app_->request_service(SAMPLE_SERVICE_ID, SAMPLE_INSTANCE_ID);
app_->register_message_handler(
vsomeip::VSOMEIP_ANY_SERVICE, SAMPLE_INSTANCE_ID, vsomeip::VSOMEIP_ANY_METHOD,
@@ -74,8 +72,6 @@ public:
<< std::setw(4) << std::setfill('0') << std::hex << _response->get_session()
<< "]";
-
- //std::this_thread::sleep_for(std::chrono::milliseconds(SAMPLE_CYCLE));
send();
}
@@ -100,7 +96,6 @@ private:
int main(int argc, char **argv) {
- // determine path
std::string its_sample_name("client-sample");
int i = 0;
@@ -118,6 +113,3 @@ int main(int argc, char **argv) {
its_sample.start();
return 0;
}
-
-
-
diff --git a/implementation/examples/sample-ids.hpp b/implementation/examples/sample-ids.hpp
new file mode 100644
index 0000000..3fc097f
--- /dev/null
+++ b/implementation/examples/sample-ids.hpp
@@ -0,0 +1,18 @@
+// Copyright (C) 2014 BMW Group
+// Author: Lutz Bichler (lutz.bichler@bmw.de)
+// 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_EXAMPLES_SAMPLE_IDS_HPP
+#define VSOMEIP_EXAMPLES_SAMPLE_IDS_HPP
+
+#define SAMPLE_SERVICE_ID 0x1234
+#define SAMPLE_INSTANCE_ID 0x5678
+#define SAMPLE_METHOD_ID 0x0421
+
+#define OTHER_SAMPLE_SERVICE_ID 0x0248
+#define OTHER_SAMPLE_INSTANCE_ID 0x5422
+#define OTHER_SAMPLE_METHOD_ID 0x1421
+
+#endif // VSOMEIP_EXAMPLES_SAMPLE_IDS_HPP
diff --git a/implementation/examples/service-sample.cpp b/implementation/examples/service-sample.cpp
index a5c79c3..14ccf94 100644
--- a/implementation/examples/service-sample.cpp
+++ b/implementation/examples/service-sample.cpp
@@ -10,9 +10,7 @@
#include <vsomeip/vsomeip.hpp>
-#define SAMPLE_SERVICE_ID 0x1234
-#define SAMPLE_INSTANCE_ID 0x5678
-#define SAMPLE_METHOD_ID 0x0421
+#include "sample-ids.hpp"
class service_sample {
public:
diff --git a/implementation/routing/include/routing_manager_impl.hpp b/implementation/routing/include/routing_manager_impl.hpp
index 2f6f55a..c3540bf 100644
--- a/implementation/routing/include/routing_manager_impl.hpp
+++ b/implementation/routing/include/routing_manager_impl.hpp
@@ -25,7 +25,8 @@ class configuration;
class deserializer;
class routing_manager_host;
class routing_manager_stub;
-class service_info;
+class servicegroup;
+class serviceinfo;
class serializer;
class service_endpoint;
@@ -107,7 +108,7 @@ public:
void remove_local(client_t _client);
endpoint * find_local(service_t _service, instance_t _instance);
- const std::set< std::shared_ptr< service_info > > & get_services() const;
+ const std::map< std::string, std::shared_ptr< servicegroup > > & get_servicegroups() const;
private:
void on_message(const byte_t *_data, length_t _length, instance_t _instance);
@@ -115,7 +116,7 @@ private:
client_t find_client(service_t _service, instance_t _instance);
instance_t find_instance(service_t _service, endpoint *_endpoint);
- service_info * find_service(service_t _service, instance_t _instance);
+ serviceinfo * find_service(service_t _service, instance_t _instance);
void create_service(service_t _service, instance_t _instance,
major_version_t _major, minor_version_t _minor, ttl_t _ttl);
@@ -146,8 +147,8 @@ private:
std::map< service_t, std::map< endpoint *, instance_t > > service_instances_;
// Servicegroups
- std::map< std::string, std::set< std::shared_ptr< service_info > > > servicegroups_;
- std::map< service_t, std::map< instance_t, std::shared_ptr< service_info > > > services_;
+ std::map< std::string, std::shared_ptr< servicegroup > > servicegroups_;
+ std::map< service_t, std::map< instance_t, std::shared_ptr< serviceinfo > > > services_;
// Eventgroups
std::map< service_t,
diff --git a/implementation/service_discovery/include/servicegroup.hpp b/implementation/routing/include/servicegroup.hpp
index 89f913b..f8ae4d9 100644
--- a/implementation/service_discovery/include/servicegroup.hpp
+++ b/implementation/routing/include/servicegroup.hpp
@@ -4,8 +4,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_SD_SERVICEGROUP_HPP
-#define VSOMEIP_SD_SERVICEGROUP_HPP
+#ifndef VSOMEIP_SERVICEGROUP_HPP
+#define VSOMEIP_SERVICEGROUP_HPP
#include <memory>
#include <set>
@@ -13,24 +13,23 @@
namespace vsomeip {
-class service_info;
-
-namespace sd {
+class serviceinfo;
class servicegroup {
public:
servicegroup(const std::string &_name);
virtual ~servicegroup();
- void add_service(std::shared_ptr< service_info > _service);
- void remove_service(std::shared_ptr< service_info > _service);
+ std::string get_name() const;
+
+ void add_service(std::shared_ptr< serviceinfo > _service);
+ void remove_service(std::shared_ptr< serviceinfo > _service);
private:
std::string name_;
- std::set< std::shared_ptr< service_info > > services_;
+ std::set< std::shared_ptr< serviceinfo > > services_;
};
-} // namespace sd
} // namespace vsomeip
-#endif // VSOMEIP_SD_SERVICEGROUP_HPP
+#endif // VSOMEIP_SERVICEGROUP_HPP
diff --git a/implementation/routing/include/service_info.hpp b/implementation/routing/include/serviceinfo.hpp
index 9bb33eb..981b7e7 100644
--- a/implementation/routing/include/service_info.hpp
+++ b/implementation/routing/include/serviceinfo.hpp
@@ -4,8 +4,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_ROUTING_INFO_HPP
-#define VSOMEIP_SERVICE_ROUTING_INFO_HPP
+#ifndef VSOMEIP_SERVICEINFO_HPP
+#define VSOMEIP_SERVICEINFO_HPP
#include <memory>
#include <set>
@@ -16,10 +16,10 @@ namespace vsomeip {
class endpoint;
-class service_info {
+class serviceinfo {
public:
- service_info(major_version_t _major, minor_version_t _minor, ttl_t _ttl);
- ~service_info();
+ serviceinfo(major_version_t _major, minor_version_t _minor, ttl_t _ttl);
+ ~serviceinfo();
major_version_t get_major() const;
minor_version_t get_minor() const;
diff --git a/implementation/routing/src/routing_manager_impl.cpp b/implementation/routing/src/routing_manager_impl.cpp
index 3540f57..5d028fa 100644
--- a/implementation/routing/src/routing_manager_impl.cpp
+++ b/implementation/routing/src/routing_manager_impl.cpp
@@ -15,7 +15,8 @@
#include "../include/routing_manager_host.hpp"
#include "../include/routing_manager_impl.hpp"
#include "../include/routing_manager_stub.hpp"
-#include "../include/service_info.hpp"
+#include "../include/servicegroup.hpp"
+#include "../include/serviceinfo.hpp"
#include "../../configuration/include/internal.hpp"
#include "../../endpoints/include/local_client_endpoint_impl.hpp"
#include "../../endpoints/include/tcp_client_endpoint_impl.hpp"
@@ -102,7 +103,7 @@ void routing_manager_impl::offer_service(client_t _client,
local_services_[_service][_instance] = _client;
// Remote route (incoming only)
- service_info *its_info = find_service(_service, _instance);
+ serviceinfo *its_info = find_service(_service, _instance);
if (its_info) {
if (its_info->get_major() == _major && its_info->get_minor() == _minor) {
its_info->set_ttl(_ttl);
@@ -172,7 +173,7 @@ void routing_manager_impl::request_service(client_t _client,
service_t _service, instance_t _instance,
major_version_t _major, minor_version_t _minor, ttl_t _ttl) {
- service_info *its_info = find_service(_service, _instance);
+ serviceinfo *its_info = find_service(_service, _instance);
if (nullptr != its_info) {
if ((_major > its_info->get_major()) ||
(_major == its_info->get_major() && _minor > its_info->get_minor()) ||
@@ -189,7 +190,7 @@ void routing_manager_impl::request_service(client_t _client,
void routing_manager_impl::release_service(client_t _client,
service_t _service, instance_t _instance) {
- service_info *its_info = find_service(_service, _instance);
+ serviceinfo *its_info = find_service(_service, _instance);
if (nullptr != its_info) {
its_info->remove_client(_client);
} else {
@@ -297,23 +298,16 @@ void routing_manager_impl::on_message(const byte_t *_data, length_t _size, insta
}
}
-const std::set< std::shared_ptr< service_info > > & routing_manager_impl::get_services() const {
- static std::set< std::shared_ptr< service_info > > its_services;
- its_services.clear();
- for (auto i : services_) {
- for (auto j : i.second) {
- its_services.insert(j.second);
- }
- }
- return its_services;
+const std::map< std::string, std::shared_ptr< servicegroup > > & routing_manager_impl::get_servicegroups() const {
+ return servicegroups_;
}
///////////////////////////////////////////////////////////////////////////////
// PRIVATE
///////////////////////////////////////////////////////////////////////////////
-service_info * routing_manager_impl::find_service(
+serviceinfo * routing_manager_impl::find_service(
service_t _service, instance_t _instance) {
- service_info *its_info = 0;
+ serviceinfo *its_info = 0;
auto found_service = services_.find(_service);
if (found_service != services_.end()) {
auto found_instance = found_service->second.find(_instance);
@@ -329,7 +323,7 @@ void routing_manager_impl::create_service(
major_version_t _major, minor_version_t _minor, ttl_t _ttl) {
if (configuration_) {
- std::shared_ptr< service_info > its_info(std::make_shared< service_info >(_major, _minor, _ttl));
+ std::shared_ptr< serviceinfo > its_info(std::make_shared< serviceinfo >(_major, _minor, _ttl));
uint16_t its_reliable_port = configuration_->get_reliable_port(_service, _instance);
uint16_t its_unreliable_port = configuration_->get_unreliable_port(_service, _instance);
@@ -352,6 +346,12 @@ void routing_manager_impl::create_service(
}
if (VSOMEIP_ILLEGAL_PORT != its_reliable_port || VSOMEIP_ILLEGAL_PORT != its_unreliable_port) {
+ std::string its_servicegroup = configuration_->get_group(_service, _instance);
+ auto found_servicegroup = servicegroups_.find(its_servicegroup);
+ if (found_servicegroup == servicegroups_.end()) {
+ servicegroups_[its_servicegroup] = std::make_shared< servicegroup >(its_servicegroup);
+ }
+ servicegroups_[its_servicegroup]->add_service(its_info);
services_[_service][_instance] = its_info;
} else {
host_->on_error(); // TODO: Define configuration error "No valid port for service!"
diff --git a/implementation/routing/src/service_info.cpp b/implementation/routing/src/service_info.cpp
deleted file mode 100644
index 74ea99c..0000000
--- a/implementation/routing/src/service_info.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-// Copyright (C) 2014 BMW Group
-// Author: Lutz Bichler (lutz.bichler@bmw.de)
-// 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 "../include/service_info.hpp"
-
-namespace vsomeip {
-
-service_info::service_info(major_version_t _major, minor_version_t _minor, ttl_t _ttl)
- : major_(_major), minor_(_minor), ttl_(_ttl) {
-}
-
-service_info::~service_info() {
-}
-
-major_version_t service_info::get_major() const {
- return major_;
-}
-
-minor_version_t service_info::get_minor() const {
- return minor_;
-}
-
-ttl_t service_info::get_ttl() const {
- return ttl_;
-}
-
-void service_info::set_ttl(ttl_t _ttl) {
- ttl_ = _ttl;
-}
-
-std::shared_ptr< endpoint > & service_info::get_reliable_endpoint() {
- return reliable_endpoint_;
-}
-
-void service_info::set_reliable_endpoint(std::shared_ptr< endpoint > &_endpoint) {
- reliable_endpoint_ = _endpoint;
-}
-
-std::shared_ptr< endpoint > & service_info::get_unreliable_endpoint() {
- return unreliable_endpoint_;
-}
-
-void service_info::set_unreliable_endpoint(std::shared_ptr< endpoint > &_endpoint) {
- unreliable_endpoint_ = _endpoint;
-}
-
-void service_info::add_client(client_t _client) {
- requesters_.insert(_client);
-}
-
-void service_info::remove_client(client_t _client) {
- requesters_.erase(_client);
-}
-
-
-} // namespace vsomeip
-
-
-
diff --git a/implementation/service_discovery/src/servicegroup.cpp b/implementation/routing/src/servicegroup.cpp
index 88588e8..b141fcc 100644
--- a/implementation/service_discovery/src/servicegroup.cpp
+++ b/implementation/routing/src/servicegroup.cpp
@@ -7,7 +7,6 @@
#include "../include/servicegroup.hpp"
namespace vsomeip {
-namespace sd {
servicegroup::servicegroup(const std::string &_name)
: name_(_name) {
@@ -16,15 +15,18 @@ servicegroup::servicegroup(const std::string &_name)
servicegroup::~servicegroup() {
}
-void servicegroup::add_service(std::shared_ptr< service_info > _service) {
+std::string servicegroup::get_name() const {
+ return name_;
+}
+
+void servicegroup::add_service(std::shared_ptr< serviceinfo > _service) {
services_.insert(_service);
}
-void servicegroup::remove_service(std::shared_ptr< service_info > _service) {
+void servicegroup::remove_service(std::shared_ptr< serviceinfo > _service) {
services_.erase(_service);
}
-} // namespace sd
} // namespace vsomeip
diff --git a/implementation/routing/src/serviceinfo.cpp b/implementation/routing/src/serviceinfo.cpp
new file mode 100644
index 0000000..69095b5
--- /dev/null
+++ b/implementation/routing/src/serviceinfo.cpp
@@ -0,0 +1,62 @@
+// Copyright (C) 2014 BMW Group
+// Author: Lutz Bichler (lutz.bichler@bmw.de)
+// 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 "../include/serviceinfo.hpp"
+
+namespace vsomeip {
+
+serviceinfo::serviceinfo(major_version_t _major, minor_version_t _minor, ttl_t _ttl)
+ : major_(_major), minor_(_minor), ttl_(_ttl) {
+}
+
+serviceinfo::~serviceinfo() {
+}
+
+major_version_t serviceinfo::get_major() const {
+ return major_;
+}
+
+minor_version_t serviceinfo::get_minor() const {
+ return minor_;
+}
+
+ttl_t serviceinfo::get_ttl() const {
+ return ttl_;
+}
+
+void serviceinfo::set_ttl(ttl_t _ttl) {
+ ttl_ = _ttl;
+}
+
+std::shared_ptr< endpoint > & serviceinfo::get_reliable_endpoint() {
+ return reliable_endpoint_;
+}
+
+void serviceinfo::set_reliable_endpoint(std::shared_ptr< endpoint > &_endpoint) {
+ reliable_endpoint_ = _endpoint;
+}
+
+std::shared_ptr< endpoint > & serviceinfo::get_unreliable_endpoint() {
+ return unreliable_endpoint_;
+}
+
+void serviceinfo::set_unreliable_endpoint(std::shared_ptr< endpoint > &_endpoint) {
+ unreliable_endpoint_ = _endpoint;
+}
+
+void serviceinfo::add_client(client_t _client) {
+ requesters_.insert(_client);
+}
+
+void serviceinfo::remove_client(client_t _client) {
+ requesters_.erase(_client);
+}
+
+
+} // namespace vsomeip
+
+
+
diff --git a/implementation/runtime/include/runtime_impl.hpp b/implementation/runtime/include/runtime_impl.hpp
index 1847a99..b32c5e3 100644
--- a/implementation/runtime/include/runtime_impl.hpp
+++ b/implementation/runtime/include/runtime_impl.hpp
@@ -20,7 +20,7 @@ public:
std::shared_ptr< application > create_application(const std::string &_name) const;
std::shared_ptr< message > create_request() const;
- std::shared_ptr< message > create_response(std::shared_ptr< message > &_request) const;
+ std::shared_ptr< message > create_response(const std::shared_ptr< message > &_request) const;
std::shared_ptr< message > create_notification() const;
diff --git a/implementation/runtime/src/runtime_impl.cpp b/implementation/runtime/src/runtime_impl.cpp
index 3123183..76f2ea8 100644
--- a/implementation/runtime/src/runtime_impl.cpp
+++ b/implementation/runtime/src/runtime_impl.cpp
@@ -33,7 +33,7 @@ std::shared_ptr< message > runtime_impl::create_request() const {
return its_request;
}
-std::shared_ptr< message > runtime_impl::create_response(std::shared_ptr< message > &_request) const {
+std::shared_ptr< message > runtime_impl::create_response(const std::shared_ptr< message > &_request) const {
std::shared_ptr< message_impl > its_response = std::make_shared< message_impl >();
its_response->set_service(_request->get_service());
its_response->set_instance(_request->get_instance());
diff --git a/implementation/service_discovery/include/fsm_base.hpp b/implementation/service_discovery/include/fsm_base.hpp
new file mode 100644
index 0000000..f82fde7
--- /dev/null
+++ b/implementation/service_discovery/include/fsm_base.hpp
@@ -0,0 +1,37 @@
+// Copyright (C) 2014 BMW Group
+// Author: Lutz Bichler (lutz.bichler@bmw.de)
+// 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_FSM_BASE_HPP
+#define VSOMEIP_FSM_BASE_HPP
+
+#include <memory>
+
+#include <boost/asio/io_service.hpp>
+#include <boost/asio/system_timer.hpp>
+
+namespace vsomeip {
+namespace sd {
+
+class fsm_base: public std::enable_shared_from_this< fsm_base > {
+public:
+ fsm_base(boost::asio::io_service &_io);
+ virtual ~fsm_base();
+
+ void start_timer(uint32_t _ms);
+ void stop_timer();
+
+ uint32_t expired_from_now();
+
+ virtual void timer_expired(const boost::system::error_code &_error) = 0;
+
+private:
+ boost::asio::system_timer timer_;
+};
+
+} // namespace sd
+} // namespace vsomeip
+
+#endif // VSOMEIP_FSM_BASE_HPP
diff --git a/implementation/service_discovery/include/fsm_events.hpp b/implementation/service_discovery/include/fsm_events.hpp
new file mode 100644
index 0000000..d490a46
--- /dev/null
+++ b/implementation/service_discovery/include/fsm_events.hpp
@@ -0,0 +1,31 @@
+// Copyright (C) 2014 BMW Group
+// Author: Lutz Bichler (lutz.bichler@bmw.de)
+// 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_FSM_EVENTS_HPP
+#define VSOMEIP_FSM_EVENTS_HPP
+
+#include <boost/statechart/event.hpp>
+
+#include <vsomeip/primitive_types.hpp>
+
+namespace sc = boost::statechart;
+
+namespace vsomeip {
+namespace sd {
+
+struct ev_none: sc::event< ev_none > {};
+struct ev_timeout: sc::event< ev_timeout > {};
+
+struct ev_status_change: sc::event< ev_status_change > {
+ ev_status_change(bool _is_up) : is_up_(_is_up) {};
+
+ bool is_up_;
+};
+
+} // namespace sd
+} // namespace vsomeip
+
+#endif // VSOMEIP_FSM_EVENTS_HPP
diff --git a/implementation/service_discovery/include/offer_fsm.hpp b/implementation/service_discovery/include/offer_fsm.hpp
new file mode 100644
index 0000000..0c71f00
--- /dev/null
+++ b/implementation/service_discovery/include/offer_fsm.hpp
@@ -0,0 +1,79 @@
+// Copyright (C) 2014 BMW Group
+// Author: Lutz Bichler (lutz.bichler@bmw.de)
+// 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_OFFER_FSM_HPP
+#define VSOMEIP_SD_OFFER_FSM_HPP
+
+#include <boost/mpl/list.hpp>
+#include <boost/statechart/custom_reaction.hpp>
+#include <boost/statechart/state.hpp>
+#include <boost/statechart/state_machine.hpp>
+#include <boost/statechart/transition.hpp>
+
+#include "../include/fsm_base.hpp"
+#include "../include/fsm_events.hpp"
+
+namespace vsomeip {
+namespace sd {
+
+class offer_fsm;
+
+///////////////////////////////////////////////////////////////////////////////
+// Machine
+///////////////////////////////////////////////////////////////////////////////
+namespace mpl = boost::mpl;
+namespace sc = boost::statechart;
+
+namespace _offer {
+
+struct inactive;
+struct fsm:
+ sc::state_machine< fsm, inactive >, public fsm_base {
+
+ fsm(offer_fsm *_fsm);
+ virtual ~fsm();
+
+ void timer_expired(const boost::system::error_code &_error);
+
+ offer_fsm *fsm_;
+};
+
+struct inactive:
+ sc::state< inactive, fsm > {
+
+ inactive(my_context context);
+
+ typedef mpl::list<
+ sc::custom_reaction< ev_none >,
+ sc::custom_reaction< ev_status_change >
+ > reactions;
+
+ sc::result react(const ev_none &_event);
+ sc::result react(const ev_status_change &_event);
+};
+
+} // namespace _offer
+
+///////////////////////////////////////////////////////////////////////////////
+// Interface
+///////////////////////////////////////////////////////////////////////////////
+class offer_fsm {
+public:
+ offer_fsm(const std::string &_name, boost::asio::io_service &_io);
+
+ boost::asio::io_service & get_io();
+
+private:
+ std::string name_;
+ boost::asio::io_service &io_;
+ _offer::fsm fsm_;
+};
+
+
+} // namespace sd
+} // namespace vsomeip
+
+#endif // VSOMEIP_SD_OFFER_FSM_HPP
diff --git a/implementation/service_discovery/include/service_discovery_host.hpp b/implementation/service_discovery/include/service_discovery_host.hpp
index 34fdde3..0c4a3b6 100644
--- a/implementation/service_discovery/include/service_discovery_host.hpp
+++ b/implementation/service_discovery/include/service_discovery_host.hpp
@@ -7,14 +7,14 @@
#ifndef VSOMEIP_SERVICE_DISCOVERY_HOST_HPP
#define VSOMEIP_SERVICE_DISCOVERY_HOST_HPP
+#include <map>
#include <memory>
-#include <set>
#include <boost/asio/io_service.hpp>
namespace vsomeip {
-class service_info;
+class servicegroup;
namespace sd {
@@ -23,7 +23,7 @@ public:
virtual ~service_discovery_host() {};
virtual boost::asio::io_service & get_io() = 0;
- virtual const std::set< std::shared_ptr< service_info > > & get_services() const = 0;
+ virtual const std::map< std::string, std::shared_ptr< servicegroup > > & get_servicegroups() const = 0;
};
} // namespace sd
diff --git a/implementation/service_discovery/include/service_discovery_impl.hpp b/implementation/service_discovery/include/service_discovery_impl.hpp
index 896685f..c065b6b 100644
--- a/implementation/service_discovery/include/service_discovery_impl.hpp
+++ b/implementation/service_discovery/include/service_discovery_impl.hpp
@@ -14,9 +14,11 @@
#include "../../endpoints/include/endpoint_host.hpp"
namespace vsomeip {
-namespace sd {
class servicegroup;
+
+namespace sd {
+
class service_discovery_host;
class service_discovery_impl:
diff --git a/implementation/service_discovery/src/fsm_base.cpp b/implementation/service_discovery/src/fsm_base.cpp
new file mode 100644
index 0000000..1c52db7
--- /dev/null
+++ b/implementation/service_discovery/src/fsm_base.cpp
@@ -0,0 +1,44 @@
+// Copyright (C) 2014 BMW Group
+// Author: Lutz Bichler (lutz.bichler@bmw.de)
+// 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 "../include/fsm_base.hpp"
+
+namespace vsomeip {
+namespace sd {
+
+fsm_base::fsm_base(boost::asio::io_service &_service)
+ : timer_(_service) {
+}
+
+fsm_base::~fsm_base() {
+}
+
+void fsm_base::start_timer(uint32_t _milliseconds) {
+ timer_.expires_from_now(std::chrono::milliseconds(_milliseconds));
+ timer_.async_wait(
+ std::bind(
+ &fsm_base::timer_expired,
+ shared_from_this(),
+ std::placeholders::_1
+ )
+ );
+}
+
+void fsm_base::stop_timer() {
+ timer_.cancel();
+}
+
+uint32_t fsm_base::expired_from_now() {
+ return std::chrono::duration_cast<
+ std::chrono::milliseconds>(
+ timer_.expires_from_now()).count();
+}
+
+} // namespace sd
+} // namespace vsomeip
+
+
+
diff --git a/implementation/service_discovery/src/offer_fsm.cpp b/implementation/service_discovery/src/offer_fsm.cpp
new file mode 100644
index 0000000..6f3b9e0
--- /dev/null
+++ b/implementation/service_discovery/src/offer_fsm.cpp
@@ -0,0 +1,57 @@
+// Copyright (C) 2014 BMW Group
+// Author: Lutz Bichler (lutz.bichler@bmw.de)
+// 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 "../include/offer_fsm.hpp"
+
+namespace vsomeip {
+namespace sd {
+
+///////////////////////////////////////////////////////////////////////////////
+// Machine
+///////////////////////////////////////////////////////////////////////////////
+namespace _offer {
+
+fsm::fsm(offer_fsm *_fsm): fsm_(_fsm), fsm_base(_fsm->get_io()) {
+}
+
+fsm::~fsm() {
+}
+
+void fsm::timer_expired(const boost::system::error_code &_error) {
+ if (!_error) {
+ process_event(ev_timeout());
+ }
+}
+
+inactive::inactive(my_context context): sc::state< inactive, fsm >(context) {
+}
+
+sc::result inactive::react(const ev_none &_event) {
+ return discard_event();
+}
+
+sc::result inactive::react(const ev_status_change &_event) {
+ return discard_event();
+}
+
+} // namespace _offer
+
+///////////////////////////////////////////////////////////////////////////////
+// Interface
+///////////////////////////////////////////////////////////////////////////////
+offer_fsm::offer_fsm(const std::string &_name, boost::asio::io_service &_io)
+ : name_(_name), io_(_io), fsm_(this) {
+}
+
+boost::asio::io_service & offer_fsm::get_io() {
+ return io_;
+}
+
+} // namespace sd
+} // namespace vsomeip
+
+
+
diff --git a/implementation/service_discovery/src/service_discovery_impl.cpp b/implementation/service_discovery/src/service_discovery_impl.cpp
index a95f8c3..7d630db 100644
--- a/implementation/service_discovery/src/service_discovery_impl.cpp
+++ b/implementation/service_discovery/src/service_discovery_impl.cpp
@@ -6,9 +6,9 @@
#include <vsomeip/logger.hpp>
-#include "../include/servicegroup.hpp"
#include "../include/service_discovery_host.hpp"
#include "../include/service_discovery_impl.hpp"
+#include "../../routing/include/servicegroup.hpp"
namespace vsomeip {
namespace sd {
@@ -26,17 +26,24 @@ boost::asio::io_service & service_discovery_impl::get_io() {
}
void service_discovery_impl::init() {
- const std::set< std::shared_ptr< service_info > > &its_offers = host_->get_services();
+ VSOMEIP_INFO << "sdi::init";
}
void service_discovery_impl::start() {
+ VSOMEIP_INFO << "sdi::start";
+ const std::map< std::string, std::shared_ptr< servicegroup > > &its_groups = host_->get_servicegroups();
+ for (auto i : its_groups) {
+ VSOMEIP_INFO << "Initializing servicegroup \"" << i.first << "\"";
+ }
}
void service_discovery_impl::stop() {
+ VSOMEIP_INFO << "sdi::stop";
}
void service_discovery_impl::offer_service(service_t _service, instance_t _instance) {
VSOMEIP_DEBUG << "sdi::offer_service [" << std::hex << _service << "." << _instance << "]";
+
}
void service_discovery_impl::stop_offer_service(service_t _service, instance_t _instance) {
@@ -45,14 +52,16 @@ void service_discovery_impl::stop_offer_service(service_t _service, instance_t _
void service_discovery_impl::request_service(service_t _service, instance_t _instance,
major_version_t _major, minor_version_t _minor, ttl_t _ttl) {
+ VSOMEIP_DEBUG << "sdi::request_service [" << std::hex << _service << "." << _instance << "]";
}
void service_discovery_impl::release_service(service_t _service, instance_t _instance) {
-
+ VSOMEIP_DEBUG << "sdi::release_service [" << std::hex << _service << "." << _instance << "]";
}
+
// Interface endpoint_host
void service_discovery_impl::on_message(const byte_t *_data, length_t _length, endpoint *_receiver) {
-
+ VSOMEIP_DEBUG << "sdi::on_message";
}
} // namespace sd
diff --git a/implementation/test/configuration-test.cpp b/implementation/test/configuration-test.cpp
index f860aea..f8ce0b6 100644
--- a/implementation/test/configuration-test.cpp
+++ b/implementation/test/configuration-test.cpp
@@ -212,11 +212,9 @@ int main(int argc, char **argv) {
check<std::string>(its_address_s, DESIRED_ADDRESS_4466_0321, "ADDRESS_TEST_4466_0321");
// 5. Service discovery
- std::string host = its_configuration->get_service_discovery_host();
std::string protocol = its_configuration->get_service_discovery_protocol();
uint16_t port = its_configuration->get_service_discovery_port();
- check<std::string>(host, DESIRED_HOST, "SERVICE DISCOVERY HOST");
check<std::string>(protocol, DESIRED_PROTOCOL, "SERVICE DISCOVERY PROTOCOL");
check<uint16_t>(port, DESIRED_PORT, "SERVICE DISCOVERY PORT");
diff --git a/interface/vsomeip/configuration.hpp b/interface/vsomeip/configuration.hpp
index f3d1cc0..5c91e39 100644
--- a/interface/vsomeip/configuration.hpp
+++ b/interface/vsomeip/configuration.hpp
@@ -38,10 +38,10 @@ public:
virtual const std::string & get_routing_host() const = 0;
virtual bool is_service_discovery_enabled() const = 0;
- virtual const std::string & get_service_discovery_host() const = 0;
virtual const std::string & get_service_discovery_protocol() const = 0;
virtual uint16_t get_service_discovery_port() const = 0;
+ virtual std::string get_group(service_t _service, instance_t _instance) const = 0;
virtual std::string get_address(service_t _service, instance_t _instance) const = 0;
virtual uint32_t get_min_initial_delay(service_t _service, instance_t _instance) const = 0;
diff --git a/interface/vsomeip/runtime.hpp b/interface/vsomeip/runtime.hpp
index 43dc351..bf39882 100644
--- a/interface/vsomeip/runtime.hpp
+++ b/interface/vsomeip/runtime.hpp
@@ -25,7 +25,7 @@ public:
virtual std::shared_ptr< application > create_application(const std::string &_name) const = 0;
virtual std::shared_ptr< message > create_request() const = 0;
- virtual std::shared_ptr< message > create_response(std::shared_ptr< message > &_request) const = 0;
+ virtual std::shared_ptr< message > create_response(const std::shared_ptr< message > &_request) const = 0;
virtual std::shared_ptr< message > create_notification() const = 0;