summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLutz Bichler <Lutz.Bichler@bmw.de>2014-07-25 12:32:45 +0200
committerLutz Bichler <Lutz.Bichler@bmw.de>2014-07-25 12:32:45 +0200
commitafdb12b765fa76d6cd0dfe7c92ce5fec69888dea (patch)
tree5092cc6da58924d5ca1536253c534fded55225ea
parent8e269cd5d31032a80e80a509399f22bcde9fadf6 (diff)
downloadvSomeIP-afdb12b765fa76d6cd0dfe7c92ce5fec69888dea.tar.gz
Switched to json configuration files.
Added event/eventgroup configuration (per service).
-rw-r--r--config/vsomeip-magic-cookies-client.json52
-rw-r--r--config/vsomeip-magic-cookies-client.xml54
-rw-r--r--config/vsomeip-magic-cookies-service.json48
-rw-r--r--config/vsomeip-magic-cookies-service.xml51
-rw-r--r--config/vsomeip-sample.xml41
-rw-r--r--config/vsomeip-tcp-client.json86
-rw-r--r--config/vsomeip-tcp-client.xml53
-rw-r--r--config/vsomeip-tcp-service.json47
-rw-r--r--config/vsomeip-tcp-service.xml50
-rw-r--r--config/vsomeip-test.json130
-rw-r--r--config/vsomeip-test.xml109
-rw-r--r--config/vsomeip-udp-client.json86
-rw-r--r--config/vsomeip-udp-client.xml54
-rw-r--r--config/vsomeip-udp-service.json47
-rw-r--r--config/vsomeip-udp-service.xml50
-rw-r--r--config/vsomeip.json58
-rw-r--r--config/vsomeip.xml68
-rw-r--r--examples/client-sample.cpp2
-rw-r--r--implementation/configuration/include/configuration_impl.hpp16
-rw-r--r--implementation/configuration/include/event.hpp31
-rw-r--r--implementation/configuration/include/eventgroup.hpp28
-rw-r--r--implementation/configuration/include/service.hpp12
-rw-r--r--implementation/configuration/include/servicegroup.hpp2
-rw-r--r--implementation/configuration/src/configuration_impl.cpp479
-rw-r--r--implementation/endpoints/src/endpoint_impl.cpp8
-rw-r--r--implementation/endpoints/src/tcp_client_endpoint_impl.cpp6
-rw-r--r--implementation/endpoints/src/tcp_server_endpoint_impl.cpp6
-rw-r--r--implementation/routing/include/eventgroupinfo.hpp48
-rw-r--r--implementation/routing/include/routing_manager.hpp3
-rw-r--r--implementation/routing/include/routing_manager_impl.hpp17
-rw-r--r--implementation/routing/include/routing_manager_proxy.hpp2
-rw-r--r--implementation/routing/include/routing_types.hpp16
-rw-r--r--implementation/routing/include/serviceinfo.hpp2
-rw-r--r--implementation/routing/src/routing_manager_impl.cpp491
-rw-r--r--implementation/routing/src/routing_manager_proxy.cpp2
-rw-r--r--implementation/runtime/include/application_impl.hpp59
-rw-r--r--implementation/runtime/src/application_impl.cpp29
-rw-r--r--implementation/service_discovery/include/service_discovery.hpp16
-rw-r--r--implementation/service_discovery/include/service_discovery_impl.hpp39
-rw-r--r--implementation/service_discovery/src/service_discovery_fsm.cpp1
-rw-r--r--implementation/service_discovery/src/service_discovery_impl.cpp174
-rw-r--r--interface/vsomeip/application.hpp56
-rw-r--r--interface/vsomeip/configuration.hpp7
-rw-r--r--interface/vsomeip/constants.hpp54
-rw-r--r--test/configuration-test.cpp20
-rw-r--r--test/magic-cookies-test-client.cpp6
46 files changed, 1520 insertions, 1196 deletions
diff --git a/config/vsomeip-magic-cookies-client.json b/config/vsomeip-magic-cookies-client.json
new file mode 100644
index 0000000..828661b
--- /dev/null
+++ b/config/vsomeip-magic-cookies-client.json
@@ -0,0 +1,52 @@
+{
+ "unicast" : "192.168.56.101",
+ "logging" :
+ {
+ "level" : "trace",
+ "console" : "true",
+ "file" : { "enable" : "false", "path" : "/var/log/vsomeip.log" },
+ "dlt" : "false"
+ },
+ "applications" :
+ [
+ {
+ "name" : "client-sample",
+ "id" : 0x1343
+ },
+ {
+ "name" : "second-client-sample",
+ "id" : 0x1344
+ },
+ {
+ "name" : "third-client-sample",
+ "id" : 0x1345
+ },
+ {
+ "name" : "fourth-client-sample",
+ "id" : 0x1346
+ }
+ ],
+ "servicegroups" :
+ [
+ {
+ "name" : "remote",
+ "address" : "192.168.56.102",
+ "services" :
+ [
+ {
+ "service" : "0x1234",
+ "instance" : "0x5678",
+ "reliable" : { "port" : 30511, "magic-cookies" : "true" },
+ }
+ ]
+ }
+ ],
+ "routing" : "client-sample",
+ "service-discovery" :
+ {
+ "enable" : "false",
+ "multicast" : "224.244.224.245",
+ "port" : "30490",
+ "protocol" : "udp"
+ }
+}
diff --git a/config/vsomeip-magic-cookies-client.xml b/config/vsomeip-magic-cookies-client.xml
deleted file mode 100644
index 8d5382e..0000000
--- a/config/vsomeip-magic-cookies-client.xml
+++ /dev/null
@@ -1,54 +0,0 @@
-<!-- vsomeip test configuration file -->
-<someip>
- <address>192.168.56.101</address>
- <logging>
- <level>trace</level>
- <console>true</console>
- <file>
- <enable>false</enable>
- <path>/tmp/vsomeip.log</path>
- </file>
- <dlt>false</dlt>
- </logging>
- <services>
- <servicegroup>
- <name>remote</name>
- <address>192.168.56.102</address>
- <service>
- <service-id>0x1234</service-id>
- <instance-id>0x5678</instance-id>
- <reliable>
- <port>30511</port>
- <use-magic-cookies>true</use-magic-cookies>
- </reliable>
- </service>
- </servicegroup>
- </services>
- <routing>
- <host>client-sample</host>
- </routing>
- <service-discovery>
- <enabled>false</enabled>
- <protocol>udp</protocol>
- <address>224.244.224.245</address>
- <port>30490</port>
- </service-discovery>
- <applications>
- <application>
- <name>client-sample</name>
- <id>0x1343</id>
- </application>
- <application>
- <name>second-client-sample</name>
- <id>0x1344</id>
- </application>
- <application>
- <name>third-client-sample</name>
- <id>0x1345</id>
- </application>
- <application>
- <name>fourth-client-sample</name>
- <id>0x1346</id>
- </application>
- </applications>
-</someip>
diff --git a/config/vsomeip-magic-cookies-service.json b/config/vsomeip-magic-cookies-service.json
new file mode 100644
index 0000000..ca73fe0
--- /dev/null
+++ b/config/vsomeip-magic-cookies-service.json
@@ -0,0 +1,48 @@
+{
+ "unicast" : "192.168.56.102",
+ "logging" :
+ {
+ "level" : "trace",
+ "console" : "true",
+ "file" : { "enable" : "false", "path" : "/var/log/vsomeip.log" },
+ "dlt" : "false"
+ },
+ "applications" :
+ [
+ {
+ "name" : "service-sample",
+ "id" : "0x1277"
+ }
+ ],
+ "servicegroups" :
+ [
+ {
+ "name" : "default",
+ "delays" :
+ {
+ "initial" : { minimum : "10", maximum : "100" },
+ "repetition-base" : "200",
+ "repetition-max" : "3",
+ "cyclic-offer" : "2000",
+ "cyclic-request" : "2001"
+ },
+ "services" :
+ [
+ {
+ "service" : "0x1234",
+ "instance" : "0x5678",
+ "reliable" : { "port" : "30511", "magic-cookies" : "true" },
+ }
+ ]
+ }
+ ],
+ "routing" : "service-sample",
+ "service-discovery" :
+ {
+ "enable" : "false",
+ "multicast" : "224.244.224.245",
+ "port" : "30490",
+ "protocol" : "udp"
+ }
+}
+
diff --git a/config/vsomeip-magic-cookies-service.xml b/config/vsomeip-magic-cookies-service.xml
deleted file mode 100644
index 32e9615..0000000
--- a/config/vsomeip-magic-cookies-service.xml
+++ /dev/null
@@ -1,51 +0,0 @@
-<!-- vsomeip test configuration file -->
-<someip>
- <address>192.168.56.102</address>
- <logging>
- <level>trace</level>
- <console>true</console>
- <file>
- <enable>false</enable>
- <path>/tmp/vsomeip.log</path>
- </file>
- <dlt>false</dlt>
- </logging>
- <services>
- <servicegroup>
- <name>default</name>
- <delays>
- <initial>
- <min>10</min>
- <max>100</max>
- </initial>
- <repetition-base>200</repetition-base>
- <repetition-max>3</repetition-max>
- <cyclic-offer>2000</cyclic-offer>
- <cyclic-request>2001</cyclic-request>
- </delays>
- <service>
- <service-id>0x1234</service-id>
- <instance-id>0x5678</instance-id>
- <reliable>
- <port>30511</port>
- <use-magic-cookies>true</use-magic-cookies>
- </reliable>
- </service>
- </servicegroup>
- </services>
- <routing>
- <host>service-sample</host>
- </routing>
- <service-discovery>
- <enabled>false</enabled>
- <protocol>udp</protocol>
- <address>224.244.224.245</address>
- <port>30490</port>
- </service-discovery>
- <applications>
- <application>
- <name>service-sample</name>
- <id>0x1277</id>
- </application>
- </applications>
-</someip>
diff --git a/config/vsomeip-sample.xml b/config/vsomeip-sample.xml
deleted file mode 100644
index c488ae6..0000000
--- a/config/vsomeip-sample.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<!-- vsomeip test configuration file -->
-<someip>
- <unicast>10.0.2.15</unicast>
- <logging>
- <level>debug</level>
- <console>true</console>
- <file>false</file>
- <dlt>false</dlt>
- </logging>
- <services>
- <servicegroup>
- <name>default</name>
- <delays>
- <initial>
- <min>10</min>
- <max>100</max>
- </initial>
- <repetition-base>200</repetition-base>
- <cyclic-offer>2000</cyclic-offer>
- <cyclic-request>2001</cyclic-request>
- </delays>
- <service>
- <service-id>0x1234</service-id>
- <instance-id>0x5678</instance-id>
- <major>0x1</major>
- <minor>0x1</minor>
- <ttl>4000</ttl>
- <port>30500</port>
- <multicast>225.225.225.1</multicast>
- </service>
- </servicegroup>
- </services>
- <routing>
- <host>client-sample</host>
- </routing>
- <service-discovery>
- <host>client-sample</host>
- <protocol>udp</protocol>
- <port>30490</port>
- </service-discovery>
-</someip>
diff --git a/config/vsomeip-tcp-client.json b/config/vsomeip-tcp-client.json
new file mode 100644
index 0000000..2a7a8c7
--- /dev/null
+++ b/config/vsomeip-tcp-client.json
@@ -0,0 +1,86 @@
+{
+ "unicast" : "192.168.56.101",
+ "netmask" : "255.255.255.0",
+ "logging" :
+ {
+ "level" : "debug",
+ "console" : "true",
+ "file" : { "enable" : "true", "path" : "/var/log/vsomeip.log" },
+ "dlt" : "true"
+ },
+ "applications" :
+ [
+ {
+ "name" : "client-sample",
+ "id" : "0x1343"
+ },
+ {
+ "name" : "second-client-sample",
+ "id" : "0x1344"
+ },
+ {
+ "name" : "third-client-sample",
+ "id" : "0x1345"
+ },
+ {
+ "name" : "fourth-client-sample",
+ "id" : "0x1346"
+ }
+ ],
+ "servicegroups" :
+ [
+ {
+ "name" : "remote",
+ "unicast" : "192.168.56.102",
+ "services" :
+ [
+ {
+ "service" : "0x1234",
+ "instance" : "0x5678",
+ "reliable" : { "port" : "30509", "magic-cookies" : false },
+ "events" :
+ [
+ {
+ "event" : "0x0777",
+ "is_field" : true
+ },
+ {
+ "event" : "0x0778",
+ "is_field" : false
+ },
+ {
+ "event" : "0x0779",
+ "is_field" : true
+ }
+ ],
+ "eventgroups" :
+ [
+ {
+ "eventgroup" : "0x4455",
+ "multicast" : "224.225.226.223",
+ "events" : [ "0x777", "0x778" ]
+ },
+ {
+ "eventgroup" : "0x4465",
+ "multicast" : "224.225.226.228",
+ "events" : [ "0x778", "0x779" ]
+ },
+ {
+ "eventgroup" : "0x4555",
+ "multicast" : "224.225.226.233",
+ "events" : [ "0x777", "0x779" ]
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "routing" : "client-sample",
+ "service-discovery" :
+ {
+ "enable" : "true",
+ "multicast" : "224.0.0.1",
+ "port" : "30490",
+ "protocol" : "udp"
+ }
+}
diff --git a/config/vsomeip-tcp-client.xml b/config/vsomeip-tcp-client.xml
deleted file mode 100644
index e08f27a..0000000
--- a/config/vsomeip-tcp-client.xml
+++ /dev/null
@@ -1,53 +0,0 @@
-<!-- vsomeip test configuration file -->
-<someip>
- <address>192.168.56.101</address>
- <logging>
- <level>debug</level>
- <console>true</console>
- <file>
- <enable>false</enable>
- <path>/tmp/vsomeip.log</path>
- </file>
- <dlt>false</dlt>
- </logging>
- <services>
- <servicegroup>
- <name>remote</name>
- <address>192.168.56.102</address>
- <service>
- <service-id>0x1234</service-id>
- <instance-id>0x5678</instance-id>
- <reliable>
- <port>30509</port>
- </reliable>
- </service>
- </servicegroup>
- </services>
- <routing>
- <host>client-sample</host>
- </routing>
- <service-discovery>
- <enabled>true</enabled>
- <protocol>udp</protocol>
- <address>224.244.224.245</address>
- <port>30490</port>
- </service-discovery>
- <applications>
- <application>
- <name>client-sample</name>
- <id>0x1343</id>
- </application>
- <application>
- <name>second-client-sample</name>
- <id>0x1344</id>
- </application>
- <application>
- <name>third-client-sample</name>
- <id>0x1345</id>
- </application>
- <application>
- <name>fourth-client-sample</name>
- <id>0x1346</id>
- </application>
- </applications>
-</someip>
diff --git a/config/vsomeip-tcp-service.json b/config/vsomeip-tcp-service.json
new file mode 100644
index 0000000..816c577
--- /dev/null
+++ b/config/vsomeip-tcp-service.json
@@ -0,0 +1,47 @@
+{
+ "unicast" : "192.168.56.102",
+ "logging" :
+ {
+ "level" : "debug",
+ "console" : "true",
+ "file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" },
+ "dlt" : "false"
+ },
+ "applications" :
+ [
+ {
+ "name" : "service-sample",
+ "id" : "0x1277"
+ }
+ ],
+ "servicegroups" :
+ [
+ {
+ "name" : "default",
+ "delays" :
+ {
+ "initial" : { "minimum" : "10", "maximum" : 100 },
+ "repetition-base" : "200",
+ "repetition-max" : "3",
+ "cyclic-offer" : "2000",
+ "cyclic-request" : "2001"
+ },
+ "services" :
+ [
+ {
+ "service" : "0x1234",
+ "instance" : "0x5678",
+ "reliable" : { "port" : "30509", "magic-cookies" : "false" }
+ }
+ ]
+ }
+ ],
+ "routing" : "service-sample",
+ "service-discovery" :
+ {
+ "enable" : "true",
+ "multicast" : "224.0.0.1",
+ "port" : "30490",
+ "protocol" : "udp"
+ }
+}
diff --git a/config/vsomeip-tcp-service.xml b/config/vsomeip-tcp-service.xml
deleted file mode 100644
index 123166c..0000000
--- a/config/vsomeip-tcp-service.xml
+++ /dev/null
@@ -1,50 +0,0 @@
-<!-- vsomeip test configuration file -->
-<someip>
- <address>192.168.56.102</address>
- <logging>
- <level>debug</level>
- <console>true</console>
- <file>
- <enable>false</enable>
- <path>/tmp/vsomeip.log</path>
- </file>
- <dlt>false</dlt>
- </logging>
- <services>
- <servicegroup>
- <name>default</name>
- <delays>
- <initial>
- <min>10</min>
- <max>100</max>
- </initial>
- <repetition-base>200</repetition-base>
- <repetition-max>3</repetition-max>
- <cyclic-offer>2000</cyclic-offer>
- <cyclic-request>2001</cyclic-request>
- </delays>
- <service>
- <service-id>0x1234</service-id>
- <instance-id>0x5678</instance-id>
- <reliable>
- <port>30509</port>
- </reliable>
- </service>
- </servicegroup>
- </services>
- <routing>
- <host>service-sample</host>
- </routing>
- <service-discovery>
- <enabled>true</enabled>
- <protocol>udp</protocol>
- <address>224.244.224.245</address>
- <port>30490</port>
- </service-discovery>
- <applications>
- <application>
- <name>service-sample</name>
- <id>0x1277</id>
- </application>
- </applications>
-</someip>
diff --git a/config/vsomeip-test.json b/config/vsomeip-test.json
new file mode 100644
index 0000000..1debb52
--- /dev/null
+++ b/config/vsomeip-test.json
@@ -0,0 +1,130 @@
+{
+ "unicast" : "10.0.2.15",
+ "logging" :
+ {
+ "level" : "debug",
+ "console" : "true",
+ "file" : { "enable" : "true", "path" : "/home/someip/another-file.log" },
+ "dlt" : "false"
+ },
+ "applications" :
+ [
+ {
+ "name" : "A",
+ "id" : "0x7788"
+ },
+ {
+ "name" : "B",
+ "id" : "0x9933"
+ }
+ ],
+ "servicegroups" :
+ [
+ {
+ "name" : "default",
+ "unicast" : "local",
+ "delays" :
+ {
+ "initial" : { "minimum" : "10", "maximum" : "100" },
+ "repetition-base" : "200",
+ "repetition-max" : "7",
+ "cyclic-offer" : "2000",
+ "cyclic-request" : "2001"
+ },
+ "services" :
+ [
+ {
+ "service" : "0x1234",
+ "instance" : "0x0022",
+ "reliable" : { "port" : "30506", "magic_cookies" : "false" },
+ "unreliable" : "31000",
+ "events" :
+ [
+ {
+ "event" : "0x0778",
+ "is_field" : "false"
+ },
+ {
+ "event" : "0x779",
+ "is_field" : "true"
+ },
+ {
+ "event" : "0x77A",
+ "is_field" : "false"
+ }
+ ],
+ "eventgroups" :
+ [
+ {
+ "eventgroup" : "0x4567",
+ "multicast" : "225.226.227.228",
+ "events" : [ "0x778", "0x779" ]
+ },
+ {
+ "eventgroup" : "0x4569",
+ "multicast" : "225.227.227.228",
+ "events" : [ "0x779", "0x77A" ]
+ },
+ {
+ "eventgroup" : "0x4569",
+ "multicast" : "225.222.227.228",
+ "events" : [ "0x778", "0x77A" ]
+ }
+ ]
+ },
+ {
+ "service" : "0x1234",
+ "instance" : "0x0023",
+ "reliable" : "30503"
+ }
+ ]
+ },
+ {
+ "name" : "extra",
+ "unicast" : "local",
+ "delays" :
+ {
+ "initial" : { "minimum" : "100", "maximum" : "200" },
+ "repetition-base" : "300",
+ "repetition-max" : "5",
+ "cyclic-offer" : "2500",
+ "cyclic-request" : "2221"
+ },
+ "services" :
+ [
+ {
+ "service" : "0x2277",
+ "instance" : "0x0022",
+ "reliable" : { "port" : "30505" },
+ "unreliable" : "31001"
+ },
+ {
+ "service" : "0x2266",
+ "instance" : "0x0022",
+ "reliable" : "30505",
+ "unreliable" : "30507"
+ }
+ ]
+ },
+ {
+ "name" : "remote",
+ "unicast" : "10.0.2.23",
+ "services" :
+ [
+ {
+ "service" : "0x4466",
+ "instance" : "0x0321",
+ "reliable" : "30506",
+ "unreliable" : "30444"
+ }
+ ]
+ }
+ ],
+ "routing" : "A",
+ "service-discovery" :
+ {
+ "enable" : "true",
+ "port" : "30666",
+ "protocol" : "tcp"
+ }
+} \ No newline at end of file
diff --git a/config/vsomeip-test.xml b/config/vsomeip-test.xml
deleted file mode 100644
index fd3a263..0000000
--- a/config/vsomeip-test.xml
+++ /dev/null
@@ -1,109 +0,0 @@
-<!-- vsomeip test configuration file -->
-<someip>
- <address>10.0.2.15</address>
- <logging>
- <level>debug</level>
- <console>true</console>
- <file>
- <enabled>true</enabled>
- <path>/home/someip/another-file.log</path>
- </file>
- <dlt>false</dlt>
- </logging>
- <services>
- <servicegroup>
- <name>default</name>
- <address>local</address>
- <delays>
- <initial>
- <min>10</min>
- <max>100</max>
- </initial>
- <repetition-base>200</repetition-base>
- <repetition-max>7</repetition-max>
- <cyclic-offer>2000</cyclic-offer>
- <cyclic-request>2001</cyclic-request>
- </delays>
- <service>
- <service-id>0x1234</service-id>
- <instance-id>0x0022</instance-id>
- <reliable>
- <port>30506</port>
- </reliable>
- <unreliable>
- <port>31000</port>
- </unreliable>
- <multicast>225.225.225.1</multicast>
- </service>
- <service>
- <service-id>0x1234</service-id>
- <instance-id>0x0023</instance-id>
- <ports>
- <reliable>30503</reliable>
- </ports>
- <multicast>225.225.225.2</multicast>
- </service>
- </servicegroup>
- <servicegroup>
- <name>extra</name>
- <address>local</address>
- <delays>
- <initial>
- <min>100</min>
- <max>200</max>
- </initial>
- <repetition-base>300</repetition-base>
- <repetition-max>5</repetition-max>
- <cyclic-offer>2500</cyclic-offer>
- <cyclic-request>2221</cyclic-request>
- </delays>
- <service>
- <service-id>0x2277</service-id>
- <instance-id>0x0022</instance-id>
- <ports>
- <reliable>30505</reliable>
- <unreliable>31001</unreliable>
- </ports>
- <multicast>225.225.225.3</multicast>
- </service>
- <service>
- <service-id>0x2266</service-id>
- <instance-id>0x0022</instance-id>
- <ports>
- <reliable>30505</reliable>
- <unreliable>30507</unreliable>
- </ports>
- <multicast>225.225.226.1</multicast>
- </service>
- </servicegroup>
- <servicegroup>
- <name>remote</name>
- <address>10.0.2.23</address>
- <service>
- <service-id>0x4466</service-id>
- <instance-id>0x0321</instance-id>
- <ports>
- <reliable>30506</reliable>
- <unreliable>30444</unreliable>
- </ports>
- <multicast>225.225.228.1</multicast>
- </service>
- </servicegroup>
- </services>
- <routing>
- <host>A</host>
- </routing>
- <service-discovery>
- <host>my_application</host>
- <port>30666</port>
- <protocol>tcp</protocol>
- </service-discovery>
- <applications>
- <application>
- <name>A</name>
- </application>
- <application>
- <name>B</name>
- </application>
- </applications>
-</someip> \ No newline at end of file
diff --git a/config/vsomeip-udp-client.json b/config/vsomeip-udp-client.json
new file mode 100644
index 0000000..544778d
--- /dev/null
+++ b/config/vsomeip-udp-client.json
@@ -0,0 +1,86 @@
+{
+ "unicast" : "192.168.56.101",
+ "netmask" : "255.255.255.0",
+ "logging" :
+ {
+ "level" : "debug",
+ "console" : "true",
+ "file" : { "enable" : "true", "path" : "/var/log/vsomeip.log" },
+ "dlt" : "true"
+ },
+ "applications" :
+ [
+ {
+ "name" : "client-sample",
+ "id" : "0x1343"
+ },
+ {
+ "name" : "client-sample",
+ "id" : "0x1344"
+ },
+ {
+ "name" : "client-sample",
+ "id" : "0x1345"
+ },
+ {
+ "name" : "client-sample",
+ "id" : "0x1346"
+ }
+ ],
+ "servicegroups" :
+ [
+ {
+ "name" : "remote",
+ "address" : "192.168.56.102",
+ "services" :
+ [
+ {
+ "service" : "0x1234",
+ "instance" : "0x5678",
+ "unreliable" : "30509",
+ "events" :
+ [
+ {
+ "event" : "0x0777",
+ "is_field" : "true"
+ },
+ {
+ "event" : "0x0778",
+ "is_field" : "false"
+ },
+ {
+ "event" : "0x0779",
+ "is_field" : "true"
+ }
+ ],
+ "eventgroups" :
+ [
+ {
+ "eventgroup" : "0x4455",
+ "multicast" : "224.225.226.223",
+ "events" : [ "0x777", "0x778" ]
+ },
+ {
+ "eventgroup" : "0x4465",
+ "multicast" : "224.225.226.228",
+ "events" : [ "0x778", "0x779" ]
+ },
+ {
+ "eventgroup" : "0x4555",
+ "multicast" : "224.225.226.233",
+ "events" : [ "0x777", "0x779" ]
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "routing" : "client-sample",
+ "service-discovery" :
+ {
+ "enable" : "true",
+ "multicast" : "224.244.224.224",
+ "port" : "30490",
+ "protocol" : "udp"
+ }
+} \ No newline at end of file
diff --git a/config/vsomeip-udp-client.xml b/config/vsomeip-udp-client.xml
deleted file mode 100644
index 4de88de..0000000
--- a/config/vsomeip-udp-client.xml
+++ /dev/null
@@ -1,54 +0,0 @@
-<!-- vsomeip test configuration file -->
-<someip>
- <address>192.168.56.101</address>
- <netmask>24</address>
- <logging>
- <level>trace</level>
- <console>true</console>
- <file>
- <enable>false</enable>
- <path>/tmp/vsomeip.log</path>
- </file>
- <dlt>false</dlt>
- </logging>
- <services>
- <servicegroup>
- <name>remote</name>
- <address>192.168.56.102</address>
- <service>
- <service-id>0x1234</service-id>
- <instance-id>0x5678</instance-id>
- <unreliable>
- <port>30507</port>
- </unreliable>
- </service>
- </servicegroup>
- </services>
- <routing>
- <host>client-sample</host>
- </routing>
- <service-discovery>
- <enabled>true</enabled>
- <protocol>udp</protocol>
- <address>224.244.224.245</address>
- <port>30490</port>
- </service-discovery>
- <applications>
- <application>
- <name>client-sample</name>
- <id>0x1343</id>
- </application>
- <application>
- <name>second-client-sample</name>
- <id>0x1344</id>
- </application>
- <application>
- <name>third-client-sample</name>
- <id>0x1345</id>
- </application>
- <application>
- <name>fourth-client-sample</name>
- <id>0x1346</id>
- </application>
- </applications>
-</someip>
diff --git a/config/vsomeip-udp-service.json b/config/vsomeip-udp-service.json
new file mode 100644
index 0000000..cba6b6e
--- /dev/null
+++ b/config/vsomeip-udp-service.json
@@ -0,0 +1,47 @@
+{
+ "unicast" : "192.168.56.102",
+ "logging" :
+ {
+ "level" : "debug",
+ "console" : "true",
+ "file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" },
+ "dlt" : "false",
+ }
+ "applications" :
+ [
+ {
+ "name" : "service-sample",
+ "id" : "0x1277"
+ }
+ ],
+ "servicegroups" :
+ [
+ {
+ "name" : "default",
+ "delays" :
+ {
+ "initial" : { "minimum" : "10", "maximum" : 100 },
+ "repetition-base" : "200",
+ "repetition-max" : "3",
+ "cyclic-offer" : "2000",
+ "cyclic-request" : "2001"
+ },
+ "services" :
+ [
+ {
+ "service" : "0x1234",
+ "instance" : "0x5678"
+ "unreliable" : "30509",
+ }
+ ]
+ }
+ ]
+ "routing" : "service-sample",
+ "service-discovery" :
+ {
+ "enable" : "true",
+ "multicast" : "224.244.224.245",
+ "port" : "30490",
+ "protocol" : "udp"
+ }
+}
diff --git a/config/vsomeip-udp-service.xml b/config/vsomeip-udp-service.xml
deleted file mode 100644
index b2684ef..0000000
--- a/config/vsomeip-udp-service.xml
+++ /dev/null
@@ -1,50 +0,0 @@
-<!-- vsomeip test configuration file -->
-<someip>
- <address>192.168.56.102</address>
- <logging>
- <level>trace</level>
- <console>true</console>
- <file>
- <enable>false</enable>
- <path>/tmp/vsomeip.log</path>
- </file>
- <dlt>false</dlt>
- </logging>
- <services>
- <servicegroup>
- <name>default</name>
- <delays>
- <initial>
- <min>10</min>
- <max>100</max>
- </initial>
- <repetition-base>200</repetition-base>
- <repetition-max>3</repetition-max>
- <cyclic-offer>2000</cyclic-offer>
- <cyclic-request>2001</cyclic-request>
- </delays>
- <service>
- <service-id>0x1234</service-id>
- <instance-id>0x5678</instance-id>
- <unreliable>
- <port>30507</port>
- </unreliable>
- </service>
- </servicegroup>
- </services>
- <routing>
- <host>service-sample</host>
- </routing>
- <service-discovery>
- <enabled>true</enabled>
- <protocol>udp</protocol>
- <address>224.244.224.245</address>
- <port>30490</port>
- </service-discovery>
- <applications>
- <application>
- <name>service-sample</name>
- <id>0x1277</id>
- </application>
- </applications>
-</someip>
diff --git a/config/vsomeip.json b/config/vsomeip.json
new file mode 100644
index 0000000..a9cd9a0
--- /dev/null
+++ b/config/vsomeip.json
@@ -0,0 +1,58 @@
+{
+ "unicast" : "192.168.56.101",
+ "logging" :
+ {
+ "level" : "debug",
+ "console" : "true",
+ "file" : { "enable" : "false", "path" : "/var/log/vsomeip.log" },
+ "dlt" : "false",
+ },
+ "applications" :
+ [
+ {
+ "name" : "client-sample",
+ "id" : "0x1343"
+ },
+ {
+ "name" : "other-client-sample",
+ "id" : "0x1344"
+ },
+ {
+ "name" : "service-sample",
+ "id" : "0x1277"
+ }
+ ]
+ "servicegroups" :
+ [
+ {
+ "name" : "default",
+ "delays" :
+ {
+ "inital" : { minimum : "10", maximum : "100" },
+ "repetition-base" : "200",
+ "repetition-max" : "3",
+ "cyclic-offer" : "2000",
+ "cyclic-request" : "2001"
+ },
+ {
+ "service" : "0x1234",
+ "instance" : "0x5678",
+ "reliable" : { "port" : "30506", "magic-cookies" : false },
+ "unreliable" : "31000"
+ },
+ {
+ "service" : "0x2248",
+ "instance" : "0x5422",
+ "unreliable" : "31010"
+ }
+ }
+ ],
+ "routing" : "client-sample",
+ "service-discovery" :
+ {
+ "enable" : "true",
+ "multicast" : "224.244.224.245",
+ "port" : "30490",
+ "protocol" : "udp"
+ }
+}
diff --git a/config/vsomeip.xml b/config/vsomeip.xml
deleted file mode 100644
index 52ca502..0000000
--- a/config/vsomeip.xml
+++ /dev/null
@@ -1,68 +0,0 @@
-<!-- vsomeip test configuration file -->
-<someip>
- <address>192.168.56.101</address>
- <logging>
- <level>trace</level>
- <console>true</console>
- <file>
- <enable>false</enable>
- <path>/tmp/vsomeip.log</path>
- </file>
- <dlt>false</dlt>
- </logging>
- <services>
- <servicegroup>
- <name>default</name>
- <delays>
- <initial>
- <min>10</min>
- <max>100</max>
- </initial>
- <repetition-base>200</repetition-base>
- <repetition-max>3</repetition-max>
- <cyclic-offer>2000</cyclic-offer>
- <cyclic-request>2001</cyclic-request>
- </delays>
- <service>
- <service-id>0x1234</service-id>
- <instance-id>0x5678</instance-id>
- <ports>
- <reliable>30506</reliable>
- <unreliable>31000</unreliable>
- </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>
- </services>
- <routing>
- <host>client-sample</host>
- </routing>
- <service-discovery>
- <enabled>true</enabled>
- <protocol>udp</protocol>
- <address>224.244.224.245</address>
- <port>30490</port>
- </service-discovery>
- <applications>
- <application>
- <name>client-sample</name>
- <id>0x1343</id>
- </application>
- <application>
- <name>other-client-sample</name>
- <id>0x1344</id>
- </application>
- <application>
- <name>service-sample</name>
- <id>0x1277</id>
- </application>
- </applications>
-</someip>
diff --git a/examples/client-sample.cpp b/examples/client-sample.cpp
index eae5ea8..7d27222 100644
--- a/examples/client-sample.cpp
+++ b/examples/client-sample.cpp
@@ -50,7 +50,7 @@ public:
std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
app_->register_message_handler(
- vsomeip::any_service, SAMPLE_INSTANCE_ID, vsomeip::any_method,
+ vsomeip::ANY_SERVICE, SAMPLE_INSTANCE_ID, vsomeip::ANY_METHOD,
std::bind(&client_sample::on_message,
this,
std::placeholders::_1));
diff --git a/implementation/configuration/include/configuration_impl.hpp b/implementation/configuration/include/configuration_impl.hpp
index a90355e..612bc4d 100644
--- a/implementation/configuration/include/configuration_impl.hpp
+++ b/implementation/configuration/include/configuration_impl.hpp
@@ -30,7 +30,7 @@ public:
bool load(const std::string &_path);
- const boost::asio::ip::address & get_address() const;
+ const boost::asio::ip::address & get_unicast() const;
bool is_v4() const;
bool is_v6() const;
@@ -55,14 +55,13 @@ public:
uint16_t get_reliable_port(service_t _service, instance_t _instance) const;
bool has_enabled_magic_cookies(std::string _address, uint16_t _port) 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_protocol() const;
- const std::string & get_service_discovery_address() const;
+ const std::string & get_service_discovery_multicast() const;
uint16_t get_service_discovery_port() const;
+ const std::string & get_service_discovery_protocol() const;
client_t get_id(const std::string &_name) const;
@@ -79,6 +78,8 @@ private:
bool get_servicegroup_configuration(const boost::property_tree::ptree &_tree);
bool get_delays_configuration(std::shared_ptr< servicegroup > &_group, const boost::property_tree::ptree &_tree);
bool get_service_configuration(std::shared_ptr< servicegroup > &_group, const boost::property_tree::ptree &_tree);
+ bool get_event_configuration(std::shared_ptr<service> &_service, const boost::property_tree::ptree &_tree);
+ bool get_eventgroup_configuration(std::shared_ptr<service> &_service, const boost::property_tree::ptree &_tree);
bool get_application_configuration(const boost::property_tree::ptree &_tree);
servicegroup * find_servicegroup(const std::string &_name) const;
@@ -89,7 +90,7 @@ private:
static std::mutex mutex_;
// Configuration data
- boost::asio::ip::address address_;
+ boost::asio::ip::address unicast_;
bool has_console_log_;
bool has_file_log_;
@@ -103,10 +104,9 @@ private:
std::string routing_host_;
bool is_service_discovery_enabled_;
- std::string service_discovery_host_;
- std::string service_discovery_protocol_;
- std::string service_discovery_address_;
+ std::string service_discovery_multicast_;
uint16_t service_discovery_port_;
+ std::string service_discovery_protocol_;
std::map< std::string, client_t > applications_;
diff --git a/implementation/configuration/include/event.hpp b/implementation/configuration/include/event.hpp
new file mode 100644
index 0000000..6e9005c
--- /dev/null
+++ b/implementation/configuration/include/event.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_CFG_EVENT_HPP
+#define VSOMEIP_CFG_EVENT_HPP
+
+#include <memory>
+#include <vector>
+
+#include <vsomeip/primitive_types.hpp>
+
+namespace vsomeip {
+namespace cfg {
+
+struct eventgroup;
+
+struct event {
+ event(event_t _id, bool _is_field) : id_(_id), is_field_(_is_field) {};
+
+ event_t id_;
+ bool is_field_;
+ std::vector<std::weak_ptr<eventgroup> > groups_;
+};
+
+} // namespace cfg
+} // namespace vsomeip
+
+#endif // VSOMEIP_CFG_EVENT_HPP
diff --git a/implementation/configuration/include/eventgroup.hpp b/implementation/configuration/include/eventgroup.hpp
new file mode 100644
index 0000000..cd58dee
--- /dev/null
+++ b/implementation/configuration/include/eventgroup.hpp
@@ -0,0 +1,28 @@
+// 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_CFG_EVENTGROUP_HPP
+#define VSOMEIP_CFG_EVENTGROUP_HPP
+
+#include <memory>
+
+#include <vsomeip/primitive_types.hpp>
+
+namespace vsomeip {
+namespace cfg {
+
+struct event;
+
+struct eventgroup {
+ eventgroup_t id_;
+ std::string multicast_;
+ std::set<std::shared_ptr<event> > events_;
+};
+
+} // namespace cfg
+} // namespace vsomeip
+
+#endif // VSOMEIP_CFG_EVENTGROUP_HPP
diff --git a/implementation/configuration/include/service.hpp b/implementation/configuration/include/service.hpp
index 825f136..9459648 100644
--- a/implementation/configuration/include/service.hpp
+++ b/implementation/configuration/include/service.hpp
@@ -14,17 +14,21 @@
namespace vsomeip {
namespace cfg {
+struct event;
+struct eventgroup;
+
struct service {
service_t service_;
instance_t instance_;
uint16_t reliable_;
- bool use_magic_cookies_;
-
uint16_t unreliable_;
- std::string multicast_;
- std::shared_ptr< servicegroup > group_;
+ bool use_magic_cookies_;
+
+ std::shared_ptr<servicegroup> group_;
+ std::map<event_t, std::shared_ptr<event> > events_;
+ std::map<eventgroup_t, std::shared_ptr<eventgroup> > eventgroups_;
};
} // namespace cfg
diff --git a/implementation/configuration/include/servicegroup.hpp b/implementation/configuration/include/servicegroup.hpp
index 41f372f..b1a2d81 100644
--- a/implementation/configuration/include/servicegroup.hpp
+++ b/implementation/configuration/include/servicegroup.hpp
@@ -12,7 +12,7 @@ namespace cfg {
struct servicegroup {
std::string name_; // Name of the ServiceGroup
- std::string address_; // either "local" or an IP address
+ std::string unicast_; // either "local" or an IP address
uint32_t min_initial_delay_;
uint32_t max_initial_delay_;
diff --git a/implementation/configuration/src/configuration_impl.cpp b/implementation/configuration/src/configuration_impl.cpp
index 3836880..4bc8621 100644
--- a/implementation/configuration/src/configuration_impl.cpp
+++ b/implementation/configuration/src/configuration_impl.cpp
@@ -10,11 +10,13 @@
#include <boost/algorithm/string.hpp>
#include <boost/foreach.hpp>
-#include <boost/property_tree/xml_parser.hpp>
+#include <boost/property_tree/json_parser.hpp>
#include <vsomeip/constants.hpp>
#include "../include/configuration_impl.hpp"
+#include "../include/event.hpp"
+#include "../include/eventgroup.hpp"
#include "../include/servicegroup.hpp"
#include "../include/service.hpp"
#include "../../logging/include/logger_impl.hpp"
@@ -23,7 +25,7 @@
namespace vsomeip {
namespace cfg {
-std::map< std::string, configuration * > configuration_impl::the_configurations;
+std::map<std::string, configuration *> configuration_impl::the_configurations;
std::mutex configuration_impl::mutex_;
configuration * configuration_impl::get(const std::string &_path) {
@@ -31,7 +33,7 @@ configuration * configuration_impl::get(const std::string &_path) {
bool is_freshly_loaded(false);
{
- std::unique_lock< std::mutex > its_lock(mutex_);
+ std::unique_lock < std::mutex > its_lock(mutex_);
auto found_configuration = the_configurations.find(_path);
if (found_configuration != the_configurations.end()) {
@@ -54,17 +56,13 @@ configuration * configuration_impl::get(const std::string &_path) {
return its_configuration;
}
-configuration_impl::configuration_impl()
- : has_console_log_(true),
- has_file_log_(false),
- has_dlt_log_(false),
- logfile_("/tmp/vsomeip.log"),
- loglevel_(boost::log::trivial::severity_level::info),
- routing_host_("vsomeipd"),
- is_service_discovery_enabled_(false),
- service_discovery_host_("vsomeipd") {
+configuration_impl::configuration_impl() :
+ has_console_log_(true), has_file_log_(false), has_dlt_log_(false), logfile_(
+ "/tmp/vsomeip.log"), loglevel_(
+ boost::log::trivial::severity_level::info), routing_host_(
+ "vsomeipd"), is_service_discovery_enabled_(false) {
- address_ = address_.from_string("127.0.0.1");
+ unicast_ = unicast_.from_string("127.0.0.1");
}
configuration_impl::~configuration_impl() {
@@ -75,137 +73,140 @@ bool configuration_impl::load(const std::string &_path) {
boost::property_tree::ptree its_tree;
try {
- boost::property_tree::xml_parser::read_xml(_path, its_tree);
-
- auto its_someip = its_tree.get_child("someip");
+ boost::property_tree::json_parser::read_json(_path, its_tree);
// Read the configuration data
- is_loaded = get_someip_configuration(its_someip);
- is_loaded = get_logging_configuration(its_someip);
- is_loaded = is_loaded && get_services_configuration(its_someip);
- is_loaded = is_loaded && get_routing_configuration(its_someip);
- is_loaded = is_loaded && get_service_discovery_configuration(its_someip);
- is_loaded = is_loaded && get_applications_configuration(its_someip);
- }
- catch (...) {
+ is_loaded = get_someip_configuration(its_tree);
+ is_loaded = get_logging_configuration(its_tree);
+ is_loaded = is_loaded && get_services_configuration(its_tree);
+ is_loaded = is_loaded && get_routing_configuration(its_tree);
+ is_loaded = is_loaded && get_service_discovery_configuration(its_tree);
+ is_loaded = is_loaded && get_applications_configuration(its_tree);
+ } catch (std::exception &e) {
+ std::cerr << e.what() << std::endl;
is_loaded = false;
}
return is_loaded;
}
-bool configuration_impl::get_someip_configuration(boost::property_tree::ptree &_tree) {
+bool configuration_impl::get_someip_configuration(
+ boost::property_tree::ptree &_tree) {
bool is_loaded(true);
try {
- std::string its_value = _tree.get< std::string >("address");
- address_ = address_.from_string(its_value);
- }
- catch (...) {
+ std::string its_value = _tree.get < std::string > ("unicast");
+ unicast_ = unicast_.from_string(its_value);
+ } catch (...) {
is_loaded = false;
}
return is_loaded;
}
-bool configuration_impl::get_logging_configuration(boost::property_tree::ptree &_tree) {
+bool configuration_impl::get_logging_configuration(
+ boost::property_tree::ptree &_tree) {
bool is_loaded(true);
try {
auto its_logging = _tree.get_child("logging");
for (auto i = its_logging.begin(); i != its_logging.end(); ++i) {
std::string its_key(i->first);
- std::string its_value(i->second.data());
-
if (its_key == "console") {
+ std::string its_value(i->second.data());
has_console_log_ = (its_value == "true");
} else if (its_key == "file") {
- try {
- auto its_file_properties = i->second;
- for (auto j : its_file_properties) {
- std::string its_file_key(j.first);
- std::string its_file_value(j.second.data());
-
- if (its_file_key == "enabled") {
- has_file_log_ = (its_file_value == "true");
- } else if (its_file_key == "path") {
- logfile_ = its_file_value;
- }
+ for (auto j : i->second) {
+ std::string its_sub_key(j.first);
+ std::string its_sub_value(j.second.data());
+ if (its_sub_key == "enable") {
+ has_file_log_ = (its_sub_value == "true");
+ } else if (its_sub_key == "path") {
+ logfile_ = its_sub_value;
}
}
- catch (...) {
- }
} else if (its_key == "dlt") {
+ std::string its_value(i->second.data());
has_dlt_log_ = (its_value == "true");
} else if (its_key == "level") {
- loglevel_ = (its_value == "trace" ? boost::log::trivial::severity_level::trace
- : (its_value == "debug" ? boost::log::trivial::severity_level::debug
- : (its_value == "info" ? boost::log::trivial::severity_level::info
- : (its_value == "warning" ? boost::log::trivial::severity_level::warning
- : (its_value == "error" ? boost::log::trivial::severity_level::error
- : (its_value == "fatal" ? boost::log::trivial::severity_level::fatal
- : boost::log::trivial::severity_level::info))))));
+ std::string its_value(i->second.data());
+ loglevel_ =
+ (its_value == "trace" ?
+ boost::log::trivial::severity_level::trace :
+ (its_value == "debug" ?
+ boost::log::trivial::severity_level::debug :
+ (its_value == "info" ?
+ boost::log::trivial::severity_level::info :
+ (its_value == "warning" ?
+ boost::log::trivial::severity_level::warning :
+ (its_value == "error" ?
+ boost::log::trivial::severity_level::error :
+ (its_value
+ == "fatal" ?
+ boost::log::trivial::severity_level::fatal :
+ boost::log::trivial::severity_level::info))))));
}
}
- }
- catch (...) {
+ } catch (...) {
is_loaded = false;
}
return is_loaded;
}
-bool configuration_impl::get_services_configuration(boost::property_tree::ptree &_tree) {
+bool configuration_impl::get_services_configuration(
+ boost::property_tree::ptree &_tree) {
bool is_loaded(true);
try {
- auto its_services = _tree.get_child("services");
- for (auto i = its_services.begin(); i != its_services.end(); ++i) {
- std::string its_key(i->first);
-
- if (its_key == "servicegroup") {
- is_loaded = is_loaded && get_servicegroup_configuration(i->second);
- }
- }
- }
- catch (...) {
+ auto its_services = _tree.get_child("servicegroups");
+ for (auto i = its_services.begin(); i != its_services.end(); ++i)
+ is_loaded = is_loaded && get_servicegroup_configuration(i->second);
+ } catch (...) {
is_loaded = false;
}
return is_loaded;
}
-bool configuration_impl::get_servicegroup_configuration(const boost::property_tree::ptree &_tree) {
+bool configuration_impl::get_servicegroup_configuration(
+ const boost::property_tree::ptree &_tree) {
bool is_loaded(true);
try {
- std::shared_ptr< servicegroup > its_servicegroup(std::make_shared< servicegroup >());
- its_servicegroup->address_ = "local"; // Default
+ std::shared_ptr<servicegroup> its_servicegroup(
+ std::make_shared<servicegroup>());
+ its_servicegroup->unicast_ = "local"; // Default
for (auto i = _tree.begin(); i != _tree.end(); ++i) {
std::string its_key(i->first);
-
if (its_key == "name") {
its_servicegroup->name_ = i->second.data();
- } else if (its_key == "address") {
- its_servicegroup->address_ = i->second.data();
+ } else if (its_key == "unicast") {
+ its_servicegroup->unicast_ = i->second.data();
} else if (its_key == "delays") {
- is_loaded = is_loaded && get_delays_configuration(its_servicegroup, i->second);
- } else if (its_key == "service") {
- is_loaded = is_loaded && get_service_configuration(its_servicegroup, i->second);
+ is_loaded = is_loaded
+ && get_delays_configuration(its_servicegroup,
+ i->second);
+ } else if (its_key == "services") {
+ for (auto j = i->second.begin(); j != i->second.end(); ++j)
+ is_loaded = is_loaded
+ && get_service_configuration(its_servicegroup,
+ j->second);
}
}
servicegroups_[its_servicegroup->name_] = its_servicegroup;
- }
- catch (...) {
+ } catch (...) {
is_loaded = false;
}
return is_loaded;
}
-bool configuration_impl::get_delays_configuration(std::shared_ptr< servicegroup > &_group, const boost::property_tree::ptree &_tree) {
+bool configuration_impl::get_delays_configuration(
+ std::shared_ptr<servicegroup> &_group,
+ const boost::property_tree::ptree &_tree) {
bool is_loaded(true);
try {
std::stringstream its_converter;
-
for (auto i = _tree.begin(); i != _tree.end(); ++i) {
std::string its_key(i->first);
-
if (its_key == "initial") {
- _group->min_initial_delay_ = i->second.get< uint32_t >("min");
- _group->max_initial_delay_ = i->second.get< uint32_t >("max");
+ _group->min_initial_delay_ = i->second.get < uint32_t
+ > ("minimum");
+ _group->max_initial_delay_ = i->second.get < uint32_t
+ > ("maximum");
} else if (its_key == "repetition-base") {
its_converter << std::dec << i->second.data();
its_converter >> _group->repetition_base_delay_;
@@ -221,26 +222,25 @@ bool configuration_impl::get_delays_configuration(std::shared_ptr< servicegroup
its_converter << std::dec << i->second.data();
its_converter >> _group->cyclic_request_delay_;
}
-
its_converter.str("");
its_converter.clear();
}
- }
- catch (...) {
+ } catch (...) {
is_loaded = false;
}
return is_loaded;
}
-bool configuration_impl::get_service_configuration(std::shared_ptr< servicegroup > &_group, const boost::property_tree::ptree &_tree) {
+bool configuration_impl::get_service_configuration(
+ std::shared_ptr<servicegroup> &_group,
+ const boost::property_tree::ptree &_tree) {
bool is_loaded(true);
try {
bool use_magic_cookies(false);
- std::shared_ptr< service > its_service(std::make_shared< service >());
- its_service->reliable_ = its_service->unreliable_ = illegal_port;
+ std::shared_ptr<service> its_service(std::make_shared<service>());
+ its_service->reliable_ = its_service->unreliable_ = ILLEGAL_PORT;
its_service->use_magic_cookies_ = false;
-
its_service->group_ = _group;
for (auto i = _tree.begin(); i != _tree.end(); ++i) {
@@ -248,27 +248,29 @@ bool configuration_impl::get_service_configuration(std::shared_ptr< servicegroup
std::string its_value(i->second.data());
std::stringstream its_converter;
- if (its_key == "multicast") {
- its_service->multicast_ = its_value;
- } else if (its_key == "reliable") {
+ if (its_key == "reliable") {
try {
its_value = i->second.get_child("port").data();
its_converter << its_value;
its_converter >> its_service->reliable_;
-
- its_value = i->second.get_child("use-magic-cookies").data();
- use_magic_cookies = ("true" == its_value);
- }
- catch (...) {
- }
- } else if (its_key == "unreliable") {
- try {
- its_value = i->second.get_child("port").data();
+ } catch (...) {
its_converter << its_value;
- its_converter >> its_service->unreliable_;
+ its_converter >> its_service->reliable_;
}
- catch (...) {
+ try {
+ its_value =
+ i->second.get_child("enable-magic-cookies").data();
+ use_magic_cookies = ("true" == its_value);
+ } catch (...) {
+
}
+ } else if (its_key == "unreliable") {
+ its_converter << its_value;
+ its_converter >> its_service->unreliable_;
+ } else if (its_key == "events") {
+ get_event_configuration(its_service, i->second);
+ } else if (its_key == "eventgroups") {
+ get_eventgroup_configuration(its_service, i->second);
} else {
// Trim "its_value"
if (its_value[0] == '0' && its_value[1] == 'x') {
@@ -277,9 +279,9 @@ bool configuration_impl::get_service_configuration(std::shared_ptr< servicegroup
its_converter << std::dec << its_value;
}
- if (its_key == "service-id") {
+ if (its_key == "service") {
its_converter >> its_service->service_;
- } else if (its_key == "instance-id") {
+ } else if (its_key == "instance") {
its_converter >> its_service->instance_;
}
}
@@ -287,111 +289,182 @@ bool configuration_impl::get_service_configuration(std::shared_ptr< servicegroup
auto found_service = services_.find(its_service->service_);
if (found_service != services_.end()) {
- auto found_instance = found_service->second.find(its_service->instance_);
+ auto found_instance = found_service->second.find(
+ its_service->instance_);
if (found_instance != found_service->second.end()) {
is_loaded = false;
}
}
if (is_loaded) {
- services_[its_service->service_][its_service->instance_] = its_service;
+ services_[its_service->service_][its_service->instance_] =
+ its_service;
}
if (use_magic_cookies) {
- std::string its_address(_group->address_);
- if (its_address == "local") its_address = get_address().to_string();
- magic_cookies_[its_address].insert(its_service->reliable_);
+ std::string its_unicast(_group->unicast_);
+ if (its_unicast == "local")
+ its_unicast = unicast_.to_string();
+ magic_cookies_[its_unicast].insert(its_service->reliable_);
}
- }
- catch (...) {
+ } catch (...) {
is_loaded = false;
}
return is_loaded;
}
-bool configuration_impl::get_routing_configuration(boost::property_tree::ptree &_tree) {
+bool configuration_impl::get_event_configuration(
+ std::shared_ptr<service> &_service,
+ const boost::property_tree::ptree &_tree) {
bool is_loaded(true);
- try {
- std::stringstream its_converter;
- auto its_service_discovery = _tree.get_child("routing");
- for (auto i = its_service_discovery.begin(); i != its_service_discovery.end(); ++i) {
- std::string its_key(i->first);
- std::string its_value(i->second.data());
+ for (auto i = _tree.begin(); i != _tree.end(); ++i) {
+ event_t its_event_id(0);
+ bool its_is_field(false);
+
+ for (auto j = i->second.begin(); j != i->second.end(); ++j) {
+ std::string its_key(j->first);
+ std::string its_value(j->second.data());
+ if (its_key == "event") {
+ std::stringstream its_converter;
+ if (its_value[0] == '0' && its_value[1] == 'x') {
+ its_converter << std::hex << its_value;
+ } else {
+ its_converter << std::dec << its_value;
+ }
+ its_converter >> its_event_id;
+ } else if (its_key == "is_field") {
+ its_is_field = (its_value == "true");
+ }
+ }
- if (its_key == "host") {
- routing_host_ = its_value;
+ if (its_event_id > 0) {
+ auto found_event = _service->events_.find(its_event_id);
+ if (found_event != _service->events_.end()) {
+ found_event->second->is_field_ = its_is_field;
+ } else {
+ std::shared_ptr<event> its_event = std::make_shared<event>(its_event_id, its_is_field);
+ _service->events_[its_event_id] = its_event;
}
}
}
- catch (...) {
- is_loaded = false;
+ return is_loaded;
+}
+bool configuration_impl::get_eventgroup_configuration(
+ std::shared_ptr<service> &_service,
+ const boost::property_tree::ptree &_tree) {
+ bool is_loaded(true);
+ for (auto i = _tree.begin(); i != _tree.end(); ++i) {
+ std::shared_ptr<eventgroup> its_eventgroup = std::make_shared<eventgroup>();
+ for (auto j = i->second.begin(); j != i->second.end(); ++j) {
+ std::string its_key(j->first);
+ if (its_key == "eventgroup") {
+ std::stringstream its_converter;
+ std::string its_value(j->second.data());
+ if (its_value[0] == '0' && its_value[1] == 'x') {
+ its_converter << std::hex << its_value;
+ } else {
+ its_converter << std::dec << its_value;
+ }
+ its_converter >> its_eventgroup->id_;
+ } else if (its_key == "multicast") {
+ std::string its_value(j->second.data());
+ its_eventgroup->multicast_ = its_value;
+ } else if (its_key == "events") {
+ for (auto k = j->second.begin(); k != j->second.end(); ++k) {
+ std::stringstream its_converter;
+ std::string its_value(k->second.data());
+ event_t its_event_id(0);
+ if (its_value[0] == '0' && its_value[1] == 'x') {
+ its_converter << std::hex << its_value;
+ } else {
+ its_converter << std::dec << its_value;
+ }
+ its_converter >> its_event_id;
+ if (0 < its_event_id) {
+ auto find_event = _service->events_.find(its_event_id);
+ if (find_event != _service->events_.end()) {
+ find_event->second->groups_.push_back(its_eventgroup);
+ } else {
+ std::shared_ptr<event> its_event = std::make_shared<event>(its_event_id, false);
+ its_event->groups_.push_back(its_eventgroup);
+ _service->events_[its_event_id] = its_event;
+ }
+ }
+ }
+ }
+ }
+
+ if (its_eventgroup->id_ > 0)
+ _service->eventgroups_[its_eventgroup->id_] = its_eventgroup;
}
+ return is_loaded;
+}
+bool configuration_impl::get_routing_configuration(
+ boost::property_tree::ptree &_tree) {
+ bool is_loaded(true);
+ try {
+ auto its_routing = _tree.get_child("routing");
+ routing_host_ = its_routing.data();
+ } catch (...) {
+ is_loaded = false;
+ }
return is_loaded;
}
-bool configuration_impl::get_service_discovery_configuration(boost::property_tree::ptree &_tree) {
+bool configuration_impl::get_service_discovery_configuration(
+ boost::property_tree::ptree &_tree) {
bool is_loaded(true);
try {
- std::stringstream its_converter;
auto its_service_discovery = _tree.get_child("service-discovery");
- for (auto i = its_service_discovery.begin(); i != its_service_discovery.end(); ++i) {
+ for (auto i = its_service_discovery.begin();
+ i != its_service_discovery.end(); ++i) {
std::string its_key(i->first);
std::string its_value(i->second.data());
-
- if (its_key == "enabled") {
+ if (its_key == "enable") {
is_service_discovery_enabled_ = (its_value == "true");
- } else if (its_key == "host") {
- service_discovery_host_ = its_value;
- } else if (its_key == "protocol") {
- service_discovery_protocol_ = its_value;
- } else if (its_key == "address") {
- service_discovery_address_ = its_value;
+ } else if (its_key == "multicast") {
+ service_discovery_multicast_ = its_value;
} else if (its_key == "port") {
+ std::stringstream its_converter;
its_converter << its_value;
its_converter >> service_discovery_port_;
- its_converter.str("");
- its_converter.clear();
+ } else if (its_key == "protocol") {
+ service_discovery_protocol_ = its_value;
}
}
- }
- catch (...) {
+ } catch (...) {
is_loaded = false;
}
return is_loaded;
}
-bool configuration_impl::get_applications_configuration(boost::property_tree::ptree &_tree) {
+bool configuration_impl::get_applications_configuration(
+ boost::property_tree::ptree &_tree) {
bool is_loaded(true);
try {
std::stringstream its_converter;
auto its_applications = _tree.get_child("applications");
- for (auto i = its_applications.begin(); i != its_applications.end(); ++i) {
- std::string its_key(i->first);
- if (its_key == "application") {
- is_loaded = is_loaded && get_application_configuration(i->second);
- }
- }
- }
- catch (...) {
+ for (auto i = its_applications.begin(); i != its_applications.end();
+ ++i)
+ is_loaded = is_loaded && get_application_configuration(i->second);
+ } catch (...) {
is_loaded = false;
}
return is_loaded;
}
-bool configuration_impl::get_application_configuration(const boost::property_tree::ptree &_tree) {
+bool configuration_impl::get_application_configuration(
+ const boost::property_tree::ptree &_tree) {
bool is_loaded(true);
-
std::string its_name("");
client_t its_id;
-
for (auto i = _tree.begin(); i != _tree.end(); ++i) {
std::string its_key(i->first);
std::string its_value(i->second.data());
std::stringstream its_converter;
-
if (its_key == "name") {
its_name = its_value;
} else if (its_key == "id") {
@@ -403,25 +476,23 @@ bool configuration_impl::get_application_configuration(const boost::property_tre
its_converter >> its_id;
}
}
-
if (its_name != "" && its_id != 0) {
applications_[its_name] = its_id;
}
-
return is_loaded;
}
// Public interface
-const boost::asio::ip::address & configuration_impl::get_address() const {
- return address_;
+const boost::asio::ip::address & configuration_impl::get_unicast() const {
+ return unicast_;
}
bool configuration_impl::is_v4() const {
- return address_.is_v4();
+ return unicast_.is_v4();
}
bool configuration_impl::is_v6() const {
- return address_.is_v6();
+ return unicast_.is_v6();
}
bool configuration_impl::has_console_log() const {
@@ -444,9 +515,10 @@ boost::log::trivial::severity_level configuration_impl::get_loglevel() const {
return loglevel_;
}
-std::set< std::string > configuration_impl::get_servicegroups() const {
- std::set< std::string > its_keys;
- for (auto i : servicegroups_) its_keys.insert(i.first);
+std::set<std::string> configuration_impl::get_servicegroups() const {
+ std::set < std::string > its_keys;
+ for (auto i : servicegroups_)
+ its_keys.insert(i.first);
return its_keys;
}
@@ -455,36 +527,42 @@ bool configuration_impl::is_local_servicegroup(const std::string &_name) const {
servicegroup *its_servicegroup = find_servicegroup(_name);
if (its_servicegroup) {
- is_local = (its_servicegroup->address_ == "local" ||
- its_servicegroup->address_ == get_address().to_string());
+ is_local = (its_servicegroup->unicast_ == "local"
+ || its_servicegroup->unicast_ == get_unicast().to_string());
}
return is_local;
}
-int32_t configuration_impl::get_min_initial_delay(const std::string &_name) const {
+int32_t configuration_impl::get_min_initial_delay(
+ const std::string &_name) const {
int32_t its_delay = VSOMEIP_DEFAULT_MIN_INITIAL_DELAY;
servicegroup *its_servicegroup = find_servicegroup(_name);
- if (its_servicegroup) its_delay = its_servicegroup->min_initial_delay_;
+ if (its_servicegroup)
+ its_delay = its_servicegroup->min_initial_delay_;
return its_delay;
}
-int32_t configuration_impl::get_max_initial_delay(const std::string &_name) const {
+int32_t configuration_impl::get_max_initial_delay(
+ const std::string &_name) const {
int32_t its_delay = VSOMEIP_DEFAULT_MAX_INITIAL_DELAY;
servicegroup *its_servicegroup = find_servicegroup(_name);
- if (its_servicegroup) its_delay = its_servicegroup->max_initial_delay_;
+ if (its_servicegroup)
+ its_delay = its_servicegroup->max_initial_delay_;
return its_delay;
}
-int32_t configuration_impl::get_repetition_base_delay(const std::string &_name) const {
+int32_t configuration_impl::get_repetition_base_delay(
+ const std::string &_name) const {
int32_t its_delay = VSOMEIP_DEFAULT_REPETITION_BASE_DELAY;
servicegroup *its_servicegroup = find_servicegroup(_name);
- if (its_servicegroup) its_delay = its_servicegroup->repetition_base_delay_;
+ if (its_servicegroup)
+ its_delay = its_servicegroup->repetition_base_delay_;
return its_delay;
}
@@ -493,30 +571,36 @@ uint8_t configuration_impl::get_repetition_max(const std::string &_name) const {
uint8_t its_max = VSOMEIP_DEFAULT_REPETITION_MAX;
servicegroup *its_servicegroup = find_servicegroup(_name);
- if (its_servicegroup) its_max = its_servicegroup->repetition_max_;
+ if (its_servicegroup)
+ its_max = its_servicegroup->repetition_max_;
return its_max;
}
-int32_t configuration_impl::get_cyclic_offer_delay(const std::string &_name) const {
+int32_t configuration_impl::get_cyclic_offer_delay(
+ const std::string &_name) const {
uint32_t its_delay = VSOMEIP_DEFAULT_CYCLIC_OFFER_DELAY;
servicegroup *its_servicegroup = find_servicegroup(_name);
- if (its_servicegroup) its_delay = its_servicegroup->cyclic_offer_delay_;
+ if (its_servicegroup)
+ its_delay = its_servicegroup->cyclic_offer_delay_;
return its_delay;
}
-int32_t configuration_impl::get_cyclic_request_delay(const std::string &_name) const {
+int32_t configuration_impl::get_cyclic_request_delay(
+ const std::string &_name) const {
uint32_t its_delay = VSOMEIP_DEFAULT_CYCLIC_REQUEST_DELAY;
servicegroup *its_servicegroup = find_servicegroup(_name);
- if (its_servicegroup) its_delay = its_servicegroup->cyclic_request_delay_;
+ if (its_servicegroup)
+ its_delay = its_servicegroup->cyclic_request_delay_;
return its_delay;
}
-std::string configuration_impl::get_group(service_t _service, instance_t _instance) const {
+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) {
@@ -525,26 +609,30 @@ std::string configuration_impl::get_group(service_t _service, instance_t _instan
return its_group;
}
-std::string configuration_impl::get_address(service_t _service, instance_t _instance) const {
+std::string configuration_impl::get_address(service_t _service,
+ instance_t _instance) const {
std::string its_address("");
service *its_service = find_service(_service, _instance);
if (its_service)
- its_address = its_service->group_->address_;
+ its_address = its_service->group_->unicast_;
return its_address;
}
-uint16_t configuration_impl::get_reliable_port(service_t _service, instance_t _instance) const {
- uint16_t its_reliable = illegal_port;
+uint16_t configuration_impl::get_reliable_port(service_t _service,
+ instance_t _instance) const {
+ uint16_t its_reliable = ILLEGAL_PORT;
service *its_service = find_service(_service, _instance);
- if (its_service) its_reliable = its_service->reliable_;
+ if (its_service)
+ its_reliable = its_service->reliable_;
return its_reliable;
}
-bool configuration_impl::has_enabled_magic_cookies(std::string _address, uint16_t _port) const {
+bool configuration_impl::has_enabled_magic_cookies(std::string _address,
+ uint16_t _port) const {
bool has_enabled(false);
auto find_address = magic_cookies_.find(_address);
if (find_address != magic_cookies_.end()) {
@@ -556,24 +644,17 @@ bool configuration_impl::has_enabled_magic_cookies(std::string _address, uint16_
return has_enabled;
}
-uint16_t configuration_impl::get_unreliable_port(service_t _service, instance_t _instance) const {
- uint16_t its_unreliable = illegal_port;
+uint16_t configuration_impl::get_unreliable_port(service_t _service,
+ instance_t _instance) const {
+ uint16_t its_unreliable = ILLEGAL_PORT;
service *its_service = find_service(_service, _instance);
- if (its_service) its_unreliable = its_service->unreliable_;
+ if (its_service)
+ its_unreliable = its_service->unreliable_;
return its_unreliable;
}
-std::string configuration_impl::get_multicast(service_t _service, instance_t _instance) const {
- std::string its_multicast(default_multicast);
-
- service *its_service = find_service(_service, _instance);
- if (its_service) its_multicast = its_service->multicast_;
-
- return its_multicast;
-}
-
const std::string & configuration_impl::get_routing_host() const {
return routing_host_;
}
@@ -586,8 +667,8 @@ const std::string & configuration_impl::get_service_discovery_protocol() const {
return service_discovery_protocol_;
}
-const std::string & configuration_impl::get_service_discovery_address() const {
- return service_discovery_address_;
+const std::string & configuration_impl::get_service_discovery_multicast() const {
+ return service_discovery_multicast_;
}
uint16_t configuration_impl::get_service_discovery_port() const {
@@ -605,18 +686,19 @@ client_t configuration_impl::get_id(const std::string &_name) const {
return its_client;
}
-std::set< std::pair< service_t, instance_t > > configuration_impl::get_remote_services() const {
- std::set< std::pair< service_t, instance_t > > its_remote_services;
+std::set<std::pair<service_t, instance_t> > configuration_impl::get_remote_services() const {
+ std::set < std::pair<service_t, instance_t> > its_remote_services;
for (auto i : services_) {
for (auto j : i.second) {
- if (j.second->group_->address_ != "local")
+ if (j.second->group_->unicast_ != "local")
its_remote_services.insert(std::make_pair(i.first, j.first));
}
}
return its_remote_services;
}
-servicegroup *configuration_impl::find_servicegroup(const std::string &_name) const {
+servicegroup *configuration_impl::find_servicegroup(
+ const std::string &_name) const {
servicegroup *its_servicegroup(0);
auto find_servicegroup = servicegroups_.find(_name);
if (find_servicegroup != servicegroups_.end()) {
@@ -625,7 +707,8 @@ servicegroup *configuration_impl::find_servicegroup(const std::string &_name) co
return its_servicegroup;
}
-service *configuration_impl::find_service(service_t _service, instance_t _instance) const {
+service *configuration_impl::find_service(service_t _service,
+ instance_t _instance) const {
service *its_service(0);
auto find_service = services_.find(_service);
if (find_service != services_.end()) {
diff --git a/implementation/endpoints/src/endpoint_impl.cpp b/implementation/endpoints/src/endpoint_impl.cpp
index a1e2e21..9972bba 100644
--- a/implementation/endpoints/src/endpoint_impl.cpp
+++ b/implementation/endpoints/src/endpoint_impl.cpp
@@ -66,14 +66,14 @@ bool endpoint_impl< MaxBufferSize >::resync_on_magic_cookie(message_buffer_t &_b
if (is_client()) {
its_cookie_identifier
- = static_cast< uint8_t >(magic_cookie_service_message);
+ = static_cast< uint8_t >(MAGIC_COOKIE_SERVICE_MESSAGE);
its_cookie_type
- = static_cast< uint8_t >(magic_cookie_service_message_type);
+ = static_cast< uint8_t >(MAGIC_COOKIE_SERVICE_MESSAGE_TYPE);
} else {
its_cookie_identifier
- = static_cast< uint8_t >(magic_cookie_client_message);
+ = static_cast< uint8_t >(MAGIC_COOKIE_CLIENT_MESSAGE);
its_cookie_type
- = static_cast< uint8_t >(magic_cookie_client_message_type);
+ = static_cast< uint8_t >(MAGIC_COOKIE_CLIENT_MESSAGE_TYPE);
}
do {
diff --git a/implementation/endpoints/src/tcp_client_endpoint_impl.cpp b/implementation/endpoints/src/tcp_client_endpoint_impl.cpp
index b15c8bd..4786d44 100644
--- a/implementation/endpoints/src/tcp_client_endpoint_impl.cpp
+++ b/implementation/endpoints/src/tcp_client_endpoint_impl.cpp
@@ -83,7 +83,7 @@ void tcp_client_endpoint_impl::send_queued(message_buffer_ptr_t _buffer) {
}
bool tcp_client_endpoint_impl::is_magic_cookie() const {
- return (0 == std::memcmp(server_cookie, &message_[0], sizeof(server_cookie)));
+ return (0 == std::memcmp(SERVICE_COOKIE, &message_[0], sizeof(SERVICE_COOKIE)));
}
void tcp_client_endpoint_impl::send_magic_cookie(message_buffer_ptr_t &_buffer) {
@@ -91,8 +91,8 @@ void tcp_client_endpoint_impl::send_magic_cookie(message_buffer_ptr_t &_buffer)
VSOMEIP_SOMEIP_HEADER_SIZE + VSOMEIP_SOMEIP_MAGIC_COOKIE_SIZE) {
_buffer->insert(
_buffer->begin(),
- client_cookie,
- client_cookie + sizeof(client_cookie)
+ CLIENT_COOKIE,
+ CLIENT_COOKIE + sizeof(CLIENT_COOKIE)
);
} else {
VSOMEIP_WARNING << "Packet full. Cannot insert magic cookie!";
diff --git a/implementation/endpoints/src/tcp_server_endpoint_impl.cpp b/implementation/endpoints/src/tcp_server_endpoint_impl.cpp
index f865bf7..9d2879a 100644
--- a/implementation/endpoints/src/tcp_server_endpoint_impl.cpp
+++ b/implementation/endpoints/src/tcp_server_endpoint_impl.cpp
@@ -168,14 +168,14 @@ void tcp_server_endpoint_impl::connection::send_magic_cookie(message_buffer_ptr_
VSOMEIP_SOMEIP_HEADER_SIZE + VSOMEIP_SOMEIP_MAGIC_COOKIE_SIZE) {
_buffer->insert(
_buffer->begin(),
- server_cookie,
- server_cookie + sizeof(server_cookie)
+ SERVICE_COOKIE,
+ SERVICE_COOKIE + sizeof(SERVICE_COOKIE)
);
}
}
bool tcp_server_endpoint_impl::connection::is_magic_cookie() const {
- return (0 == std::memcmp(client_cookie, &message_[0], sizeof(client_cookie)));
+ return (0 == std::memcmp(CLIENT_COOKIE, &message_[0], sizeof(CLIENT_COOKIE)));
}
void tcp_server_endpoint_impl::connection::receive_cbk(
diff --git a/implementation/routing/include/eventgroupinfo.hpp b/implementation/routing/include/eventgroupinfo.hpp
new file mode 100644
index 0000000..06c92e0
--- /dev/null
+++ b/implementation/routing/include/eventgroupinfo.hpp
@@ -0,0 +1,48 @@
+// 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_EVENTGROUPINFO_HPP
+#define VSOMEIP_EVENTGROUPINFO_HPP
+
+#include <memory>
+#include <set>
+
+#include <vsomeip/primitive_types.hpp>
+
+namespace vsomeip {
+
+class endpoint;
+
+class eventgroupinfo {
+public:
+ eventgroupinfo(major_version_t _major, ttl_t _ttl);
+ ~eventgroupinfo();
+
+ servicegroup * get_group() const;
+ void set_group(servicegroup *_group);
+
+ major_version_t get_major() const;
+
+ ttl_t get_ttl() const;
+ void set_ttl(ttl_t _ttl);
+
+ std::shared_ptr<endpoint> & get_multicast();
+ void set_multicast(std::shared_ptr<endpoint> &_multicast);
+
+ void add_client(client_t _client);
+ void remove_client(client_t _client);
+
+private:
+ major_version_t major_;
+ ttl_t ttl_;
+
+ std::shared_ptr<endpoint> multicast_;
+ std::set< client_t > subscribed_;
+};
+
+} // namespace vsomeip
+
+#endif // VSOMEIP_EVENTGROUPINFO_HPP
diff --git a/implementation/routing/include/routing_manager.hpp b/implementation/routing/include/routing_manager.hpp
index efe1862..0dd8974 100644
--- a/implementation/routing/include/routing_manager.hpp
+++ b/implementation/routing/include/routing_manager.hpp
@@ -65,7 +65,8 @@ public:
instance_t _instance) = 0;
virtual void subscribe(client_t _client, service_t _service,
- instance_t _instance, eventgroup_t _eventgroup) = 0;
+ instance_t _instance, eventgroup_t _eventgroup,
+ major_version_t _major, ttl_t _ttl) = 0;
virtual void unsubscribe(client_t _client, service_t _service,
instance_t _instance, eventgroup_t _eventgroup) = 0;
diff --git a/implementation/routing/include/routing_manager_impl.hpp b/implementation/routing/include/routing_manager_impl.hpp
index e5dba21..7b803b7 100644
--- a/implementation/routing/include/routing_manager_impl.hpp
+++ b/implementation/routing/include/routing_manager_impl.hpp
@@ -24,6 +24,7 @@ namespace vsomeip {
class client_endpoint;
class configuration;
class deserializer;
+class eventgroupinfo;
class routing_manager_host;
class routing_manager_stub;
class servicegroup;
@@ -83,7 +84,7 @@ public:
instance_t _instance);
void subscribe(client_t _client, service_t _service, instance_t _instance,
- eventgroup_t _eventgroup);
+ eventgroup_t _eventgroup, major_version_t _major, ttl_t _ttl);
void unsubscribe(client_t _client, service_t _service, instance_t _instance,
eventgroup_t _eventgroup);
@@ -104,8 +105,7 @@ public:
std::shared_ptr<endpoint> find_local(client_t _client);
std::shared_ptr<endpoint> find_or_create_local(client_t _client);
void remove_local(client_t _client);
- std::shared_ptr<endpoint> find_local(service_t _service,
- instance_t _instance);
+ std::shared_ptr<endpoint> find_local(service_t _service, instance_t _instance);
// interface "endpoint_host"
void on_connect(std::shared_ptr<endpoint> _endpoint);
@@ -113,13 +113,16 @@ public:
void on_message(const byte_t *_data, length_t _length, endpoint *_receiver);
// interface "service_discovery_host"
- const std::map<std::string, std::shared_ptr<servicegroup> > & get_servicegroups() const;
+ typedef std::map<std::string,
+ std::shared_ptr<servicegroup> > servicegroups_t;
+ const servicegroups_t & get_servicegroups() const;
service_map_t get_offered_services(const std::string &_name) const;
void create_service_discovery_endpoint(const std::string &_address,
uint16_t _port, const std::string &_protocol);
private:
- bool deliver_message(const byte_t *_data, length_t _length, instance_t _instance);
+ bool deliver_message(const byte_t *_data, length_t _length,
+ instance_t _instance);
client_t find_local_client(service_t _service, instance_t _instance);
instance_t find_instance(service_t _service, endpoint *_endpoint);
@@ -195,9 +198,7 @@ private:
std::map<instance_t,
std::map<eventgroup_t, std::set<std::shared_ptr<endpoint> > > > > eventgroups_;
std::map<service_t, std::map<instance_t, std::map<event_t, eventgroup_t> > > events_;
-
- // Requested (but unknown)
- std::set<std::shared_ptr<serviceinfo> > requested_;
+ std::map<eventgroup_t, std::set<client_t> > eventgroup_clients_;
// Mutexes
std::recursive_mutex endpoint_mutex_;
diff --git a/implementation/routing/include/routing_manager_proxy.hpp b/implementation/routing/include/routing_manager_proxy.hpp
index 86e670a..f94472d 100644
--- a/implementation/routing/include/routing_manager_proxy.hpp
+++ b/implementation/routing/include/routing_manager_proxy.hpp
@@ -64,7 +64,7 @@ public:
instance_t _instance);
void subscribe(client_t _client, service_t _service, instance_t _instance,
- eventgroup_t _eventgroup);
+ eventgroup_t _eventgroup, major_version_t _major, ttl_t _ttl);
void unsubscribe(client_t _client, service_t _service, instance_t _instance,
eventgroup_t _eventgroup);
diff --git a/implementation/routing/include/routing_types.hpp b/implementation/routing/include/routing_types.hpp
index 9016b78..67f0886 100644
--- a/implementation/routing/include/routing_types.hpp
+++ b/implementation/routing/include/routing_types.hpp
@@ -16,10 +16,18 @@ namespace vsomeip {
class serviceinfo;
-typedef std::map< service_t,
- std::map< instance_t,
- std::shared_ptr< serviceinfo > > > service_map_t;
+typedef std::map<service_t,
+ std::map<instance_t,
+ std::shared_ptr<serviceinfo> > > service_map_t;
-} // namespace vsomeip
+class eventgroupinfo;
+
+typedef std::map<service_t,
+ std::map<instance_t,
+ std::map<eventgroup_t,
+ std::shared_ptr<eventgroupinfo> > > > eventgroup_map_t;
+
+}
+// namespace vsomeip
#endif // VSOMEIP_ROUTING_TYPES_HPP
diff --git a/implementation/routing/include/serviceinfo.hpp b/implementation/routing/include/serviceinfo.hpp
index 3d34f25..b38df5a 100644
--- a/implementation/routing/include/serviceinfo.hpp
+++ b/implementation/routing/include/serviceinfo.hpp
@@ -52,4 +52,4 @@ private:
} // namespace vsomeip
-#endif // VSOMEIP_SERVICE_ROUTING_INFO_HPP
+#endif // VSOMEIP_SERVICEINFO_HPP
diff --git a/implementation/routing/src/routing_manager_impl.cpp b/implementation/routing/src/routing_manager_impl.cpp
index b8e65bd..b9a5df4 100644
--- a/implementation/routing/src/routing_manager_impl.cpp
+++ b/implementation/routing/src/routing_manager_impl.cpp
@@ -35,12 +35,11 @@
namespace vsomeip {
-routing_manager_impl::routing_manager_impl(routing_manager_host *_host)
- : host_(_host),
- io_(_host->get_io()),
- deserializer_(std::make_shared< deserializer>()),
- serializer_(std::make_shared< serializer >()),
- configuration_(host_->get_configuration()) {
+routing_manager_impl::routing_manager_impl(routing_manager_host *_host) :
+ host_(_host), io_(_host->get_io()), deserializer_(
+ std::make_shared<deserializer>()), serializer_(
+ std::make_shared<serializer>()), configuration_(
+ host_->get_configuration()) {
}
routing_manager_impl::~routing_manager_impl() {
@@ -60,16 +59,15 @@ void routing_manager_impl::init() {
serializer_->create_data(its_max_message_size);
// TODO: Only instantiate the stub if needed
- stub_ = std::make_shared< routing_manager_stub >(this);
+ stub_ = std::make_shared < routing_manager_stub > (this);
stub_->init();
if (configuration_->is_service_discovery_enabled()) {
VSOMEIP_INFO << "Service Discovery enabled.";
- sd::runtime **its_runtime = static_cast< sd::runtime ** >(
- utility::load_library(
- VSOMEIP_SD_LIBRARY,
- VSOMEIP_SD_RUNTIME_SYMBOL_STRING)
- );
+ sd::runtime **its_runtime =
+ static_cast<sd::runtime **>(utility::load_library(
+ VSOMEIP_SD_LIBRARY,
+ VSOMEIP_SD_RUNTIME_SYMBOL_STRING));
if (0 != its_runtime && 0 != (*its_runtime)) {
VSOMEIP_INFO << "Service Discovery module loaded.";
@@ -83,7 +81,8 @@ void routing_manager_impl::init() {
void routing_manager_impl::start() {
stub_->start();
- if (discovery_) discovery_->start();
+ if (discovery_)
+ discovery_->start();
host_->on_event(event_type_e::REGISTERED);
}
@@ -91,26 +90,28 @@ void routing_manager_impl::start() {
void routing_manager_impl::stop() {
host_->on_event(event_type_e::DEREGISTERED);
- if (discovery_) discovery_->stop();
+ if (discovery_)
+ discovery_->stop();
stub_->stop();
}
-void routing_manager_impl::offer_service(client_t _client,
- service_t _service, instance_t _instance,
- major_version_t _major, minor_version_t _minor, ttl_t _ttl) {
+void routing_manager_impl::offer_service(client_t _client, service_t _service,
+ instance_t _instance, major_version_t _major, minor_version_t _minor,
+ ttl_t _ttl) {
local_services_[_service][_instance] = _client;
// Remote route (incoming only)
- std::shared_ptr< serviceinfo > its_info(find_service(_service, _instance));
+ std::shared_ptr<serviceinfo> its_info(find_service(_service, _instance));
if (its_info) {
- if (its_info->get_major() == _major && its_info->get_minor() == _minor) {
+ if (its_info->get_major() == _major
+ && its_info->get_minor() == _minor) {
VSOMEIP_DEBUG << "Setting TTL=" << std::dec << _ttl;
its_info->set_ttl(_ttl);
} else {
host_->on_error(error_code_e::SERVICE_PROPERTY_MISMATCH);
}
} else {
- (void)create_service(_service, _instance, _major, _minor, _ttl);
+ (void) create_service(_service, _instance, _major, _minor, _ttl);
}
host_->on_availability(_service, _instance, true);
@@ -127,6 +128,7 @@ void routing_manager_impl::stop_offer_service(client_t its_client,
}
}
} else {
+ // TODO: allow to withdraw a service on one endpoint only
del_routing_info(_service, _instance, false);
del_routing_info(_service, _instance, true);
}
@@ -142,49 +144,51 @@ void routing_manager_impl::stop_publish_eventgroup(client_t its_client,
}
-std::shared_ptr< event > routing_manager_impl::add_event(client_t _client,
- service_t _service, instance_t _instance,
- eventgroup_t _eventgroup, event_t _event) {
+std::shared_ptr<event> routing_manager_impl::add_event(client_t _client,
+ service_t _service, instance_t _instance, eventgroup_t _eventgroup,
+ event_t _event) {
- return std::make_shared< event_impl >(io_);
+ return std::make_shared < event_impl > (io_);
}
-std::shared_ptr< event > routing_manager_impl::add_field(client_t _client,
- service_t _service, instance_t _instance,
- eventgroup_t _eventgroup, event_t _event,
- std::shared_ptr< payload > _payload) {
- std::shared_ptr< event > its_event = add_event(_client, _service, _instance,
- _eventgroup, _event);
+std::shared_ptr<event> routing_manager_impl::add_field(client_t _client,
+ service_t _service, instance_t _instance, eventgroup_t _eventgroup,
+ event_t _event, std::shared_ptr<payload> _payload) {
+ std::shared_ptr<event> its_event = add_event(_client, _service, _instance,
+ _eventgroup, _event);
its_event->set_payload(_payload);
return its_event;
}
-void routing_manager_impl::remove_event_or_field(std::shared_ptr< event > _event) {
+void routing_manager_impl::remove_event_or_field(
+ std::shared_ptr<event> _event) {
}
-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) {
+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) {
- std::shared_ptr< serviceinfo > its_info(find_service(_service, _instance));
+ std::shared_ptr<serviceinfo> its_info(find_service(_service, _instance));
if (its_info) {
- if ((_major > its_info->get_major()) ||
- (_major == its_info->get_major() && _minor > its_info->get_minor()) ||
- (_ttl > its_info->get_ttl())) {
+ if ((_major > its_info->get_major())
+ || (_major == its_info->get_major()
+ && _minor > its_info->get_minor())
+ || (_ttl > its_info->get_ttl())) {
host_->on_error(error_code_e::SERVICE_PROPERTY_MISMATCH);
} else {
its_info->add_client(_client);
}
} else {
if (discovery_)
- discovery_->request_service(_service, _instance, _major, _minor, _ttl);
+ discovery_->request_service(_service, _instance, _major, _minor,
+ _ttl);
}
}
-void routing_manager_impl::release_service(client_t _client,
- service_t _service, instance_t _instance) {
- std::shared_ptr< serviceinfo > its_info(find_service(_service, _instance));
+void routing_manager_impl::release_service(client_t _client, service_t _service,
+ instance_t _instance) {
+ std::shared_ptr<serviceinfo> its_info(find_service(_service, _instance));
if (its_info) {
its_info->remove_client(_client);
} else {
@@ -193,36 +197,62 @@ void routing_manager_impl::release_service(client_t _client,
}
}
-void routing_manager_impl::subscribe(client_t its_client,
- service_t _service, instance_t _instance, eventgroup_t _eventgroup) {
+void routing_manager_impl::subscribe(client_t _client, service_t _service,
+ instance_t _instance, eventgroup_t _eventgroup, major_version_t _major, ttl_t _ttl) {
+ if (discovery_) {
+ eventgroup_clients_[_eventgroup].insert(_client);
+ discovery_->subscribe(_service, _instance, _eventgroup, _major, _ttl);
+ } else {
+ VSOMEIP_ERROR << "SOME/IP eventgroups require SD to be enabled!";
+ }
}
-void routing_manager_impl::unsubscribe(client_t its_client,
- service_t _service, instance_t _instance, eventgroup_t _eventgroup) {
+void routing_manager_impl::unsubscribe(client_t _client, service_t _service,
+ instance_t _instance, eventgroup_t _eventgroup) {
+ if (discovery_) {
+ auto found_eventgroup = eventgroup_clients_.find(_eventgroup);
+ if (found_eventgroup != eventgroup_clients_.end()) {
+ found_eventgroup->second.erase(_client);
+ if (0 == found_eventgroup->second.size()) {
+ eventgroup_clients_.erase(_eventgroup);
+ }
+ }
+ discovery_->unsubscribe(_service, _instance, _eventgroup);
+ } else {
+ VSOMEIP_ERROR << "SOME/IP eventgroups require SD to be enabled!";
+ }
}
bool routing_manager_impl::send(client_t its_client,
- std::shared_ptr< message > _message, bool _reliable, bool _flush) {
+ std::shared_ptr<message> _message, bool _reliable, bool _flush) {
bool is_sent(false);
- std::unique_lock< std::mutex > its_lock(serialize_mutex_);
+ std::unique_lock < std::mutex > its_lock(serialize_mutex_);
+
+ if (utility::is_request(_message->get_message_type())) {
+ _message->set_client(its_client);
+ }
+
if (serializer_->serialize(_message.get())) {
- is_sent = send(its_client, serializer_->get_data(), serializer_->get_size(),
- _message->get_instance(), _reliable, _flush);
+ is_sent = send(its_client, serializer_->get_data(),
+ serializer_->get_size(), _message->get_instance(), _reliable,
+ _flush);
serializer_->reset();
}
return is_sent;
}
-bool routing_manager_impl::send(client_t _client,
- const byte_t *_data, length_t _size, instance_t _instance, bool _flush, bool _reliable) {
+bool routing_manager_impl::send(client_t _client, const byte_t *_data,
+ length_t _size, instance_t _instance, bool _flush, bool _reliable) {
bool is_sent(false);
- std::shared_ptr< endpoint > its_target;
-
- client_t its_client = VSOMEIP_BYTES_TO_WORD(_data[VSOMEIP_CLIENT_POS_MIN], _data[VSOMEIP_CLIENT_POS_MAX]);
- service_t its_service = VSOMEIP_BYTES_TO_WORD(_data[VSOMEIP_SERVICE_POS_MIN], _data[VSOMEIP_SERVICE_POS_MAX]);
+ std::shared_ptr<endpoint> its_target;
bool is_request = utility::is_request(_data[VSOMEIP_MESSAGE_TYPE_POS]);
+ client_t its_client = VSOMEIP_BYTES_TO_WORD(_data[VSOMEIP_CLIENT_POS_MIN],
+ _data[VSOMEIP_CLIENT_POS_MAX]);
+ service_t its_service = VSOMEIP_BYTES_TO_WORD(
+ _data[VSOMEIP_SERVICE_POS_MIN], _data[VSOMEIP_SERVICE_POS_MAX]);
+
if (_size > VSOMEIP_MESSAGE_TYPE_POS) {
if (is_request) {
its_target = find_local(its_service, _instance);
@@ -231,40 +261,59 @@ bool routing_manager_impl::send(client_t _client,
}
if (its_target) {
- std::vector< byte_t > its_command(VSOMEIP_COMMAND_HEADER_SIZE + _size + sizeof(instance_t) + sizeof(bool) + sizeof(bool));
+ std::vector<byte_t> its_command(
+ VSOMEIP_COMMAND_HEADER_SIZE + _size + sizeof(instance_t)
+ + sizeof(bool) + sizeof(bool));
its_command[VSOMEIP_COMMAND_TYPE_POS] = VSOMEIP_SEND;
- std::memcpy(&its_command[VSOMEIP_COMMAND_CLIENT_POS], &_client, sizeof(client_t));
- std::memcpy(&its_command[VSOMEIP_COMMAND_SIZE_POS_MIN], &_size, sizeof(_size));
- std::memcpy(&its_command[VSOMEIP_COMMAND_PAYLOAD_POS], _data, _size);
- std::memcpy(&its_command[VSOMEIP_COMMAND_PAYLOAD_POS + _size], &_instance, sizeof(instance_t));
- std::memcpy(&its_command[VSOMEIP_COMMAND_PAYLOAD_POS + _size + sizeof(instance_t)], &_reliable, sizeof(bool));
- std::memcpy(&its_command[VSOMEIP_COMMAND_PAYLOAD_POS + _size + sizeof(instance_t) + sizeof(bool)] , &_flush, sizeof(bool));
- is_sent = its_target->send(&its_command[0], its_command.size(), _flush);
+ std::memcpy(&its_command[VSOMEIP_COMMAND_CLIENT_POS], &_client,
+ sizeof(client_t));
+ std::memcpy(&its_command[VSOMEIP_COMMAND_SIZE_POS_MIN], &_size,
+ sizeof(_size));
+ std::memcpy(&its_command[VSOMEIP_COMMAND_PAYLOAD_POS], _data,
+ _size);
+ std::memcpy(&its_command[VSOMEIP_COMMAND_PAYLOAD_POS + _size],
+ &_instance, sizeof(instance_t));
+ std::memcpy(
+ &its_command[VSOMEIP_COMMAND_PAYLOAD_POS + _size
+ + sizeof(instance_t)], &_reliable, sizeof(bool));
+ std::memcpy(
+ &its_command[VSOMEIP_COMMAND_PAYLOAD_POS + _size
+ + sizeof(instance_t) + sizeof(bool)], &_flush,
+ sizeof(bool));
+ is_sent = its_target->send(&its_command[0], its_command.size(),
+ _flush);
} else {
// Check whether hosting application should get the message
// If not, check routes to external
- if ((its_client == host_->get_client() && !is_request) ||
- (find_local_client(its_service, _instance) == host_->get_client() && is_request)) {
+ if ((its_client == host_->get_client() && !is_request)
+ || (find_local_client(its_service, _instance)
+ == host_->get_client() && is_request)) {
+ // TODO: find out how to handle session id here
is_sent = deliver_message(_data, _size, _instance);
} else {
if (is_request) {
- its_target = find_remote_client(its_service, _instance, _reliable);
+ its_target = find_remote_client(its_service, _instance,
+ _reliable);
if (its_target) {
is_sent = its_target->send(_data, _size, _flush);
} else {
- VSOMEIP_ERROR << "Routing error. Client from remote service could not be found!";
+ VSOMEIP_ERROR
+ << "Routing error. Client from remote service could not be found!";
}
} else {
- std::shared_ptr< serviceinfo > its_info(find_service(its_service, _instance));
+ std::shared_ptr<serviceinfo> its_info(
+ find_service(its_service, _instance));
if (its_info) {
its_target = its_info->get_endpoint(_reliable);
if (its_target) {
is_sent = its_target->send(_data, _size, _flush);
} else {
- VSOMEIP_ERROR << "Routing error. Service endpoint could not be found!";
+ VSOMEIP_ERROR
+ << "Routing error. Service endpoint could not be found!";
}
} else {
- VSOMEIP_ERROR << "Routing error. Service could not be found!";
+ VSOMEIP_ERROR
+ << "Routing error. Service could not be found!";
}
}
}
@@ -274,32 +323,36 @@ bool routing_manager_impl::send(client_t _client,
return is_sent;
}
-void routing_manager_impl::set(client_t its_client,
- service_t _service, instance_t _instance,
- event_t _event, const std::vector< byte_t > &_value) {
+void routing_manager_impl::set(client_t its_client, service_t _service,
+ instance_t _instance, event_t _event,
+ const std::vector<byte_t> &_value) {
}
-void routing_manager_impl::on_message(const byte_t *_data, length_t _size, endpoint *_receiver) {
+void routing_manager_impl::on_message(const byte_t *_data, length_t _size,
+ endpoint *_receiver) {
#if 0
std::stringstream msg;
msg << "rmi::on_message: ";
for (uint32_t i = 0; i < _size; ++i)
- msg << std::hex << std::setw(2) << std::setfill('0') << (int)_data[i] << " ";
+ msg << std::hex << std::setw(2) << std::setfill('0') << (int)_data[i] << " ";
VSOMEIP_DEBUG << msg.str();
#endif
if (_size >= VSOMEIP_SOMEIP_HEADER_SIZE) {
- service_t its_service = VSOMEIP_BYTES_TO_WORD(_data[VSOMEIP_SERVICE_POS_MIN], _data[VSOMEIP_SERVICE_POS_MAX]);
+ service_t its_service = VSOMEIP_BYTES_TO_WORD(
+ _data[VSOMEIP_SERVICE_POS_MIN], _data[VSOMEIP_SERVICE_POS_MAX]);
if (its_service == VSOMEIP_SD_SERVICE) {
if (discovery_)
discovery_->on_message(_data, _size);
} else {
instance_t its_instance = find_instance(its_service, _receiver);
- if (its_instance != any_instance) {
+ if (its_instance != ANY_INSTANCE) {
client_t its_client(VSOMEIP_ROUTING_CLIENT);
if (utility::is_request(_data[VSOMEIP_MESSAGE_TYPE_POS])) {
its_client = find_local_client(its_service, its_instance);
} else {
- its_client = VSOMEIP_BYTES_TO_WORD(_data[VSOMEIP_CLIENT_POS_MIN], _data[VSOMEIP_CLIENT_POS_MAX]);
+ its_client = VSOMEIP_BYTES_TO_WORD(
+ _data[VSOMEIP_CLIENT_POS_MIN],
+ _data[VSOMEIP_CLIENT_POS_MAX]);
}
if (its_client == host_->get_client()) {
@@ -310,7 +363,8 @@ void routing_manager_impl::on_message(const byte_t *_data, length_t _size, endpo
VSOMEIP_ERROR << "Could not determine target application!";
}
} else {
- VSOMEIP_ERROR << "Could not determine service instance for [" << its_service << "]";
+ VSOMEIP_ERROR << "Could not determine service instance for ["
+ << its_service << "]";
}
}
} else {
@@ -318,42 +372,47 @@ void routing_manager_impl::on_message(const byte_t *_data, length_t _size, endpo
}
}
-void routing_manager_impl::on_connect(std::shared_ptr< endpoint > _endpoint) {
+void routing_manager_impl::on_connect(std::shared_ptr<endpoint> _endpoint) {
for (auto &its_service : remote_services_) {
for (auto &its_instance : its_service.second) {
auto found_endpoint = its_instance.second.find(false);
if (found_endpoint != its_instance.second.end()) {
- host_->on_availability(its_service.first, its_instance.first, true);
+ host_->on_availability(its_service.first, its_instance.first,
+ true);
} else {
found_endpoint = its_instance.second.find(true);
if (found_endpoint != its_instance.second.end()) {
- host_->on_availability(its_service.first, its_instance.first, true);
+ host_->on_availability(its_service.first,
+ its_instance.first, true);
}
}
}
}
}
-void routing_manager_impl::on_disconnect(std::shared_ptr< endpoint > _endpoint) {
+void routing_manager_impl::on_disconnect(std::shared_ptr<endpoint> _endpoint) {
for (auto &its_service : remote_services_) {
for (auto &its_instance : its_service.second) {
auto found_endpoint = its_instance.second.find(false);
if (found_endpoint != its_instance.second.end()) {
- host_->on_availability(its_service.first, its_instance.first, false);
+ host_->on_availability(its_service.first, its_instance.first,
+ false);
} else {
found_endpoint = its_instance.second.find(true);
if (found_endpoint != its_instance.second.end()) {
- host_->on_availability(its_service.first, its_instance.first, false);
+ host_->on_availability(its_service.first,
+ its_instance.first, false);
}
}
}
}
}
-bool routing_manager_impl::deliver_message(const byte_t *_data, length_t _size, instance_t _instance) {
+bool routing_manager_impl::deliver_message(const byte_t *_data, length_t _size,
+ instance_t _instance) {
bool is_sent(false);
deserializer_->set_data(_data, _size);
- std::shared_ptr< message > its_message(deserializer_->deserialize_message());
+ std::shared_ptr<message> its_message(deserializer_->deserialize_message());
if (its_message) {
its_message->set_instance(_instance);
host_->on_message(its_message);
@@ -365,7 +424,8 @@ bool routing_manager_impl::deliver_message(const byte_t *_data, length_t _size,
return is_sent;
}
-bool routing_manager_impl::is_available(service_t _service, instance_t _instance) const {
+bool routing_manager_impl::is_available(service_t _service,
+ instance_t _instance) const {
auto find_local_service = local_services_.find(_service);
if (find_local_service != local_services_.end()) {
auto find_local_instance = find_local_service->second.find(_instance);
@@ -385,25 +445,28 @@ bool routing_manager_impl::is_available(service_t _service, instance_t _instance
return false;
}
-const std::map< std::string, std::shared_ptr< servicegroup > > &
+const std::map<std::string, std::shared_ptr<servicegroup> > &
routing_manager_impl::get_servicegroups() const {
return servicegroups_;
}
-std::shared_ptr< configuration > routing_manager_impl::get_configuration() const {
+std::shared_ptr<configuration> routing_manager_impl::get_configuration() const {
return host_->get_configuration();
}
void routing_manager_impl::create_service_discovery_endpoint(
- const std::string &_address, uint16_t _port, const std::string &_protocol) {
+ const std::string &_address, uint16_t _port,
+ const std::string &_protocol) {
bool is_reliable = (_protocol != "udp");
- std::shared_ptr< endpoint > its_service_endpoint = find_server_endpoint(_port, is_reliable);
+ std::shared_ptr<endpoint> its_service_endpoint = find_server_endpoint(_port,
+ is_reliable);
if (!its_service_endpoint) {
its_service_endpoint = create_server_endpoint(_port, is_reliable);
- std::shared_ptr< serviceinfo > its_info(
- std::make_shared< serviceinfo >(any_major, any_minor, any_ttl));
+ std::shared_ptr<serviceinfo> its_info(
+ std::make_shared < serviceinfo
+ > (ANY_MAJOR, ANY_MINOR, ANY_TTL));
its_info->set_endpoint(its_service_endpoint, is_reliable);
// routing info
@@ -414,7 +477,8 @@ void routing_manager_impl::create_service_discovery_endpoint(
}
}
-service_map_t routing_manager_impl::get_offered_services(const std::string &_name) const {
+service_map_t routing_manager_impl::get_offered_services(
+ const std::string &_name) const {
service_map_t its_offers;
auto find_servicegroup = servicegroups_.find(_name);
@@ -428,9 +492,9 @@ service_map_t routing_manager_impl::get_offered_services(const std::string &_nam
///////////////////////////////////////////////////////////////////////////////
// PRIVATE
///////////////////////////////////////////////////////////////////////////////
-std::shared_ptr< serviceinfo > routing_manager_impl::find_service(
- service_t _service, instance_t _instance) {
- std::shared_ptr< serviceinfo > its_info;
+std::shared_ptr<serviceinfo> routing_manager_impl::find_service(
+ service_t _service, instance_t _instance) {
+ std::shared_ptr<serviceinfo> its_info;
auto found_service = services_.find(_service);
if (found_service != services_.end()) {
auto found_instance = found_service->second.find(_instance);
@@ -441,42 +505,48 @@ std::shared_ptr< serviceinfo > routing_manager_impl::find_service(
return its_info;
}
-std::shared_ptr< serviceinfo > routing_manager_impl::create_service(
- service_t _service, instance_t _instance,
- major_version_t _major, minor_version_t _minor, ttl_t _ttl) {
- std::shared_ptr< serviceinfo > its_info;
+std::shared_ptr<serviceinfo> routing_manager_impl::create_service(
+ service_t _service, instance_t _instance, major_version_t _major,
+ minor_version_t _minor, ttl_t _ttl) {
+ std::shared_ptr<serviceinfo> its_info;
if (configuration_) {
- its_info = std::make_shared< serviceinfo >(_major, _minor, _ttl);
+ 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);
+ uint16_t its_reliable_port = configuration_->get_reliable_port(_service,
+ _instance);
+ uint16_t its_unreliable_port = configuration_->get_unreliable_port(
+ _service, _instance);
- if (its_reliable_port != illegal_port) {
- std::shared_ptr< endpoint > its_reliable_endpoint(
- find_or_create_server_endpoint(its_reliable_port, true));
+ if (ILLEGAL_PORT != its_reliable_port) {
+ std::shared_ptr<endpoint> its_reliable_endpoint(
+ find_or_create_server_endpoint(its_reliable_port, true));
its_info->set_endpoint(its_reliable_endpoint, true);
// TODO: put this in a method and check whether an assignment already exists!
- service_instances_[_service][its_reliable_endpoint.get()] = _instance;
+ service_instances_[_service][its_reliable_endpoint.get()] =
+ _instance;
}
- if (its_unreliable_port != illegal_port) {
- std::shared_ptr< endpoint > its_unreliable_endpoint(
- find_or_create_server_endpoint(its_unreliable_port, false));
+ if (ILLEGAL_PORT != its_unreliable_port) {
+ std::shared_ptr<endpoint> its_unreliable_endpoint(
+ find_or_create_server_endpoint(its_unreliable_port, false));
its_info->set_endpoint(its_unreliable_endpoint, false);
- service_instances_[_service][its_unreliable_endpoint.get()] = _instance;
+ service_instances_[_service][its_unreliable_endpoint.get()] =
+ _instance;
}
- if (illegal_port != its_reliable_port || illegal_port != its_unreliable_port) {
- std::string its_servicegroup = configuration_->get_group(_service, _instance);
+ if (ILLEGAL_PORT != its_reliable_port
+ || 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] = std::make_shared
+ < servicegroup > (its_servicegroup);
}
- servicegroups_[its_servicegroup]->add_service(_service, _instance, its_info);
+ servicegroups_[its_servicegroup]->add_service(_service, _instance,
+ its_info);
services_[_service][_instance] = its_info;
} else {
host_->on_error(error_code_e::PORT_CONFIGURATION_MISSING);
@@ -488,41 +558,39 @@ std::shared_ptr< serviceinfo > routing_manager_impl::create_service(
return its_info;
}
-std::shared_ptr< endpoint > routing_manager_impl::create_client_endpoint(
- const boost::asio::ip::address &_address, uint16_t _port, bool _reliable) {
- std::shared_ptr< endpoint > its_endpoint;
+std::shared_ptr<endpoint> routing_manager_impl::create_client_endpoint(
+ const boost::asio::ip::address &_address, uint16_t _port,
+ bool _reliable) {
+ std::shared_ptr<endpoint> its_endpoint;
try {
if (_reliable) {
- its_endpoint = std::make_shared< tcp_client_endpoint_impl >(
- shared_from_this(),
- boost::asio::ip::tcp::endpoint(_address, _port),
- io_
- );
+ its_endpoint = std::make_shared < tcp_client_endpoint_impl
+ > (shared_from_this(), boost::asio::ip::tcp::endpoint(
+ _address, _port), io_);
- if (configuration_->has_enabled_magic_cookies(_address.to_string(), _port)) {
+ if (configuration_->has_enabled_magic_cookies(_address.to_string(),
+ _port)) {
its_endpoint->enable_magic_cookies();
}
} else {
- its_endpoint = std::make_shared< udp_client_endpoint_impl >(
- shared_from_this(),
- boost::asio::ip::udp::endpoint(_address, _port),
- io_
- );
+ its_endpoint = std::make_shared < udp_client_endpoint_impl
+ > (shared_from_this(), boost::asio::ip::udp::endpoint(
+ _address, _port), io_);
}
client_endpoints_[_address][_port][_reliable] = its_endpoint;
its_endpoint->start();
- }
- catch (std::exception &e) {
+ } catch (std::exception &e) {
host_->on_error(error_code_e::CLIENT_ENDPOINT_CREATION_FAILED);
}
return its_endpoint;
}
-std::shared_ptr< endpoint > routing_manager_impl::find_client_endpoint(
- const boost::asio::ip::address &_address, uint16_t _port, bool _reliable) {
- std::shared_ptr< endpoint > its_endpoint;
+std::shared_ptr<endpoint> routing_manager_impl::find_client_endpoint(
+ const boost::asio::ip::address &_address, uint16_t _port,
+ bool _reliable) {
+ std::shared_ptr<endpoint> its_endpoint;
auto found_address = client_endpoints_.find(_address);
if (found_address != client_endpoints_.end()) {
auto found_port = found_address->second.find(_port);
@@ -536,54 +604,54 @@ std::shared_ptr< endpoint > routing_manager_impl::find_client_endpoint(
return its_endpoint;
}
-std::shared_ptr< endpoint > routing_manager_impl::find_or_create_client_endpoint(
- const boost::asio::ip::address &_address, uint16_t _port, bool _reliable) {
- std::shared_ptr< endpoint > its_endpoint = find_client_endpoint(_address, _port, _reliable);
+std::shared_ptr<endpoint> routing_manager_impl::find_or_create_client_endpoint(
+ const boost::asio::ip::address &_address, uint16_t _port,
+ bool _reliable) {
+ std::shared_ptr<endpoint> its_endpoint = find_client_endpoint(_address,
+ _port, _reliable);
if (0 == its_endpoint) {
its_endpoint = create_client_endpoint(_address, _port, _reliable);
}
return its_endpoint;
}
-std::shared_ptr< endpoint > routing_manager_impl::create_server_endpoint(uint16_t _port, bool _reliable) {
- std::shared_ptr< endpoint > its_endpoint;
+std::shared_ptr<endpoint> routing_manager_impl::create_server_endpoint(
+ uint16_t _port, bool _reliable) {
+ std::shared_ptr<endpoint> its_endpoint;
try {
- boost::asio::ip::address its_address = configuration_->get_address();
+ boost::asio::ip::address its_unicast = configuration_->get_unicast();
if (_reliable) {
- its_endpoint = std::make_shared< tcp_server_endpoint_impl >(
- shared_from_this(),
- boost::asio::ip::tcp::endpoint(its_address, _port),
- io_
- );
- if (configuration_->has_enabled_magic_cookies(its_address.to_string(), _port)) {
+ its_endpoint = std::make_shared < tcp_server_endpoint_impl
+ > (shared_from_this(), boost::asio::ip::tcp::endpoint(
+ its_unicast, _port), io_);
+ if (configuration_->has_enabled_magic_cookies(
+ its_unicast.to_string(), _port)) {
its_endpoint->enable_magic_cookies();
}
} else {
- if (its_address.is_v4()) {
- its_address = boost::asio::ip::address_v4::any();
+ if (its_unicast.is_v4()) {
+ its_unicast = boost::asio::ip::address_v4::any();
} else {
// TODO: how is "ANY" specified in IPv6?
}
- its_endpoint = std::make_shared< udp_server_endpoint_impl >(
- shared_from_this(),
- boost::asio::ip::udp::endpoint(its_address, _port),
- io_
- );
+ its_endpoint = std::make_shared < udp_server_endpoint_impl
+ > (shared_from_this(), boost::asio::ip::udp::endpoint(
+ its_unicast, _port), io_);
}
server_endpoints_[_port][_reliable] = its_endpoint;
its_endpoint->start();
- }
- catch (std::exception &e) {
+ } catch (std::exception &e) {
host_->on_error(error_code_e::SERVER_ENDPOINT_CREATION_FAILED);
}
return its_endpoint;
}
-std::shared_ptr< endpoint > routing_manager_impl::find_server_endpoint(uint16_t _port, bool _reliable) {
- std::shared_ptr< endpoint > its_endpoint;
+std::shared_ptr<endpoint> routing_manager_impl::find_server_endpoint(
+ uint16_t _port, bool _reliable) {
+ std::shared_ptr<endpoint> its_endpoint;
auto found_port = server_endpoints_.find(_port);
if (found_port != server_endpoints_.end()) {
auto found_endpoint = found_port->second.find(_reliable);
@@ -594,17 +662,19 @@ std::shared_ptr< endpoint > routing_manager_impl::find_server_endpoint(uint16_t
return its_endpoint;
}
-std::shared_ptr< endpoint > routing_manager_impl::find_or_create_server_endpoint(uint16_t _port, bool _reliable) {
- std::shared_ptr< endpoint > its_endpoint = find_server_endpoint(_port, _reliable);
+std::shared_ptr<endpoint> routing_manager_impl::find_or_create_server_endpoint(
+ uint16_t _port, bool _reliable) {
+ std::shared_ptr<endpoint> its_endpoint = find_server_endpoint(_port,
+ _reliable);
if (0 == its_endpoint) {
its_endpoint = create_server_endpoint(_port, _reliable);
}
return its_endpoint;
}
-std::shared_ptr< endpoint > routing_manager_impl::find_local(client_t _client) {
- std::unique_lock< std::recursive_mutex > its_lock(endpoint_mutex_);
- std::shared_ptr< endpoint > its_endpoint;
+std::shared_ptr<endpoint> routing_manager_impl::find_local(client_t _client) {
+ std::unique_lock < std::recursive_mutex > its_lock(endpoint_mutex_);
+ std::shared_ptr<endpoint> its_endpoint;
auto found_endpoint = local_clients_.find(_client);
if (found_endpoint != local_clients_.end()) {
its_endpoint = found_endpoint->second;
@@ -612,24 +682,24 @@ std::shared_ptr< endpoint > routing_manager_impl::find_local(client_t _client) {
return its_endpoint;
}
-std::shared_ptr< endpoint > routing_manager_impl::create_local(client_t _client) {
- std::unique_lock< std::recursive_mutex > its_lock(endpoint_mutex_);
+std::shared_ptr<endpoint> routing_manager_impl::create_local(client_t _client) {
+ std::unique_lock < std::recursive_mutex > its_lock(endpoint_mutex_);
std::stringstream its_path;
its_path << base_path << std::hex << _client;
- std::shared_ptr< endpoint > its_endpoint
- = std::make_shared< local_client_endpoint_impl >(
- shared_from_this(),
- boost::asio::local::stream_protocol::endpoint(its_path.str()),
- io_);
+ std::shared_ptr<endpoint> its_endpoint =
+ std::make_shared < local_client_endpoint_impl
+ > (shared_from_this(), boost::asio::local::stream_protocol::endpoint(
+ its_path.str()), io_);
local_clients_[_client] = its_endpoint;
its_endpoint->start();
return its_endpoint;
}
-std::shared_ptr< endpoint > routing_manager_impl::find_or_create_local(client_t _client) {
- std::shared_ptr< endpoint > its_endpoint(find_local(_client));
+std::shared_ptr<endpoint> routing_manager_impl::find_or_create_local(
+ client_t _client) {
+ std::shared_ptr<endpoint> its_endpoint(find_local(_client));
if (!its_endpoint) {
its_endpoint = create_local(_client);
}
@@ -637,17 +707,19 @@ std::shared_ptr< endpoint > routing_manager_impl::find_or_create_local(client_t
}
void routing_manager_impl::remove_local(client_t _client) {
- std::unique_lock< std::recursive_mutex > its_lock(endpoint_mutex_);
- std::shared_ptr< endpoint > its_endpoint = find_local(_client);
+ std::unique_lock < std::recursive_mutex > its_lock(endpoint_mutex_);
+ std::shared_ptr<endpoint> its_endpoint = find_local(_client);
its_endpoint->stop();
local_clients_.erase(_client);
}
-std::shared_ptr< endpoint > routing_manager_impl::find_local(service_t _service, instance_t _instance) {
+std::shared_ptr<endpoint> routing_manager_impl::find_local(service_t _service,
+ instance_t _instance) {
return find_local(find_local_client(_service, _instance));
}
-client_t routing_manager_impl::find_local_client(service_t _service, instance_t _instance) {
+client_t routing_manager_impl::find_local_client(service_t _service,
+ instance_t _instance) {
client_t its_client(0);
auto found_service = local_services_.find(_service);
if (found_service != local_services_.end()) {
@@ -659,7 +731,8 @@ client_t routing_manager_impl::find_local_client(service_t _service, instance_t
return its_client;
}
-instance_t routing_manager_impl::find_instance(service_t _service, endpoint * _endpoint) {
+instance_t routing_manager_impl::find_instance(service_t _service,
+ endpoint * _endpoint) {
instance_t its_instance(0xFFFF);
auto found_service = service_instances_.find(_service);
if (found_service != service_instances_.end()) {
@@ -671,9 +744,9 @@ instance_t routing_manager_impl::find_instance(service_t _service, endpoint * _e
return its_instance;
}
-std::shared_ptr< endpoint > routing_manager_impl::find_remote_client(
+std::shared_ptr<endpoint> routing_manager_impl::find_remote_client(
service_t _service, instance_t _instance, bool _reliable) {
- std::shared_ptr< endpoint > its_endpoint;
+ std::shared_ptr<endpoint> its_endpoint;
auto found_service = remote_services_.find(_service);
if (found_service != remote_services_.end()) {
auto found_instance = found_service->second.find(_instance);
@@ -687,15 +760,16 @@ std::shared_ptr< endpoint > routing_manager_impl::find_remote_client(
return its_endpoint;
}
-void routing_manager_impl::add_routing_info(
- service_t _service, instance_t _instance,
- major_version_t _major, minor_version_t _minor, ttl_t _ttl,
- const boost::asio::ip::address &_address, uint16_t _port, bool _reliable) {
- std::shared_ptr< serviceinfo > its_info(find_service(_service, _instance));
+void routing_manager_impl::add_routing_info(service_t _service,
+ instance_t _instance, major_version_t _major, minor_version_t _minor,
+ ttl_t _ttl, const boost::asio::ip::address &_address, uint16_t _port,
+ bool _reliable) {
+ std::shared_ptr<serviceinfo> its_info(find_service(_service, _instance));
if (!its_info)
its_info = create_service(_service, _instance, _major, _minor, _ttl);
- std::shared_ptr< endpoint > its_endpoint(create_client_endpoint(_address, _port, _reliable));
+ std::shared_ptr<endpoint> its_endpoint(
+ create_client_endpoint(_address, _port, _reliable));
its_info->set_endpoint(its_endpoint, _reliable);
remote_services_[_service][_instance][_reliable] = its_endpoint;
service_instances_[_service][its_endpoint.get()] = _instance;
@@ -706,17 +780,19 @@ void routing_manager_impl::add_routing_info(
host_->on_availability(_service, _instance, true);
}
-void routing_manager_impl::del_routing_info(
- service_t _service, instance_t _instance, bool _reliable) {
- std::shared_ptr< serviceinfo > its_info(find_service(_service, _instance));
+void routing_manager_impl::del_routing_info(service_t _service,
+ instance_t _instance, bool _reliable) {
+ std::shared_ptr<serviceinfo> its_info(find_service(_service, _instance));
if (its_info) {
- std::shared_ptr< endpoint > its_empty_endpoint;
+ std::shared_ptr<endpoint> its_empty_endpoint;
// TODO: only tell the application if the service is completely gone
host_->on_availability(_service, _instance, false);
- stub_->on_stop_offer_service(VSOMEIP_ROUTING_CLIENT, _service, _instance);
+ stub_->on_stop_offer_service(VSOMEIP_ROUTING_CLIENT, _service,
+ _instance);
- std::shared_ptr< endpoint > its_endpoint = its_info->get_endpoint(_reliable);
+ std::shared_ptr<endpoint> its_endpoint = its_info->get_endpoint(
+ _reliable);
if (its_endpoint) {
if (1 >= service_instances_[_service].size()) {
service_instances_.erase(_service);
@@ -725,7 +801,8 @@ void routing_manager_impl::del_routing_info(
}
remote_services_[_service][_instance].erase(_reliable);
- auto found_endpoint = remote_services_[_service][_instance].find(!_reliable);
+ auto found_endpoint = remote_services_[_service][_instance].find(
+ !_reliable);
if (found_endpoint == remote_services_[_service][_instance].end()) {
remote_services_[_service].erase(_instance);
}
@@ -748,22 +825,28 @@ void routing_manager_impl::del_routing_info(
}
void routing_manager_impl::init_routing_info() {
- VSOMEIP_INFO << "Service Discovery disabled. Using static routing information.";
+ VSOMEIP_INFO
+ << "Service Discovery disabled. Using static routing information.";
for (auto i : configuration_->get_remote_services()) {
- std::string its_address = configuration_->get_address(i.first, i.second);
- uint16_t its_reliable = configuration_->get_reliable_port(i.first, i.second);
- uint16_t its_unreliable = configuration_->get_unreliable_port(i.first, i.second);
+ std::string its_address = configuration_->get_address(i.first,
+ i.second);
+ uint16_t its_reliable = configuration_->get_reliable_port(i.first,
+ i.second);
+ uint16_t its_unreliable = configuration_->get_unreliable_port(i.first,
+ i.second);
if (VSOMEIP_INVALID_PORT != its_reliable) {
add_routing_info(i.first, i.second,
- default_major, default_minor, default_ttl,
- boost::asio::ip::address::from_string(its_address), its_reliable, true);
+ DEFAULT_MAJOR, DEFAULT_MINOR, DEFAULT_TTL,
+ boost::asio::ip::address::from_string(its_address),
+ its_reliable, true);
}
if (VSOMEIP_INVALID_PORT != its_unreliable) {
add_routing_info(i.first, i.second,
- default_major, default_minor, default_ttl,
- boost::asio::ip::address::from_string(its_address), its_reliable, true);
+ DEFAULT_MAJOR, DEFAULT_MINOR, DEFAULT_TTL,
+ boost::asio::ip::address::from_string(its_address),
+ its_unreliable, false);
}
}
}
diff --git a/implementation/routing/src/routing_manager_proxy.cpp b/implementation/routing/src/routing_manager_proxy.cpp
index 482e9c4..6971643 100644
--- a/implementation/routing/src/routing_manager_proxy.cpp
+++ b/implementation/routing/src/routing_manager_proxy.cpp
@@ -192,7 +192,7 @@ void routing_manager_proxy::release_service(client_t _client,
}
void routing_manager_proxy::subscribe(client_t _client,
- service_t _service, instance_t _instance, eventgroup_t _eventgroup) {
+ service_t _service, instance_t _instance, eventgroup_t _eventgroup, major_version_t _major, ttl_t _ttl) {
}
void routing_manager_proxy::unsubscribe(client_t _client,
diff --git a/implementation/runtime/include/application_impl.hpp b/implementation/runtime/include/application_impl.hpp
index c70a5d4..5eef582 100644
--- a/implementation/runtime/include/application_impl.hpp
+++ b/implementation/runtime/include/application_impl.hpp
@@ -23,10 +23,9 @@ class logger;
class routing_manager;
class routing_manager_stub;
-class application_impl
- : public application,
- public routing_manager_host,
- public std::enable_shared_from_this< application_impl > {
+class application_impl: public application,
+ public routing_manager_host,
+ public std::enable_shared_from_this<application_impl> {
public:
application_impl(const std::string &_name);
~application_impl();
@@ -36,42 +35,40 @@ public:
void stop();
void offer_service(service_t _service, instance_t _instance,
- major_version_t _major, minor_version_t _minor, ttl_t _ttl);
+ major_version_t _major, minor_version_t _minor, ttl_t _ttl);
void stop_offer_service(service_t _service, instance_t _instance);
void publish_eventgroup(service_t _service, instance_t _instance,
- eventgroup_t _eventgroup,
- major_version_t _major, ttl_t _ttl);
+ eventgroup_t _eventgroup, major_version_t _major, ttl_t _ttl);
void stop_publish_eventgroup(service_t _service, instance_t _instance,
- eventgroup_t _eventgroup);
+ eventgroup_t _eventgroup);
// Consume services
void request_service(service_t _service, instance_t _instance,
- major_version_t _major, minor_version_t _minor,
- ttl_t _ttl);
+ major_version_t _major, minor_version_t _minor, ttl_t _ttl);
void release_service(service_t _service, instance_t _instance);
void subscribe(service_t _service, instance_t _instance,
- eventgroup_t _eventgroup);
+ eventgroup_t _eventgroup, major_version_t _major, ttl_t _ttl);
void unsubscribe(service_t _service, instance_t _instance,
- eventgroup_t _eventgroup);
+ eventgroup_t _eventgroup);
bool is_available(service_t _service, instance_t _instance);
// Define content of eventgroups
- std::shared_ptr< event > add_event(service_t _service,
- instance_t _instance, eventgroup_t _eventgroup, event_t _event);
+ std::shared_ptr<event> add_event(service_t _service, instance_t _instance,
+ eventgroup_t _eventgroup, event_t _event);
- std::shared_ptr< event > add_field(service_t _service,
- instance_t _instance, eventgroup_t _eventgroup, event_t _event,
- std::shared_ptr< payload > _payload);
+ std::shared_ptr<event> add_field(service_t _service, instance_t _instance,
+ eventgroup_t _eventgroup, event_t _event,
+ std::shared_ptr<payload> _payload);
- void remove_event_or_field(std::shared_ptr< event > _event /* or field */);
+ void remove_event_or_field(std::shared_ptr<event> _event /* or field */);
- void send(std::shared_ptr< message > _message, bool _flush, bool _reliable);
+ void send(std::shared_ptr<message> _message, bool _flush, bool _reliable);
void register_event_handler(event_handler_t _handler);
void unregister_event_handler();
@@ -83,17 +80,19 @@ public:
void register_availability_handler(service_t _service, instance_t _instance,
availability_handler_t _handler);
- void unregister_availability_handler(service_t _service, instance_t _instance);
+ void unregister_availability_handler(service_t _service,
+ instance_t _instance);
// routing_manager_host
const std::string & get_name() const;
client_t get_client() const;
- std::shared_ptr< configuration > get_configuration() const;
+ std::shared_ptr<configuration> get_configuration() const;
boost::asio::io_service & get_io();
void on_event(event_type_e _event);
- void on_availability(service_t _service, instance_t _instance, bool _is_available) const;
- void on_message(std::shared_ptr< message > _message);
+ void on_availability(service_t _service, instance_t _instance,
+ bool _is_available) const;
+ void on_message(std::shared_ptr<message> _message);
void on_error(error_code_e _error);
// service_discovery_host
@@ -107,26 +106,22 @@ private:
session_t session_;
std::string name_;
- std::shared_ptr< configuration > configuration_;
+ std::shared_ptr<configuration> configuration_;
boost::asio::io_service host_io_;
// Proxy to or the Routing Manager itself
- std::shared_ptr< routing_manager > routing_;
+ std::shared_ptr<routing_manager> routing_;
// (Non-SOME/IP) Event handler
event_handler_t handler_;
// Method/Event (=Member) handlers
- std::map< service_t,
- std::map< instance_t,
- std::map< method_t,
- message_handler_t > > > members_;
+ std::map<service_t,
+ std::map<instance_t, std::map<method_t, message_handler_t> > > members_;
// Availability handlers
- std::map< service_t,
- std::map< instance_t,
- availability_handler_t > > availability_;
+ std::map<service_t, std::map<instance_t, availability_handler_t> > availability_;
// Signals
boost::asio::signal_set signals_;
diff --git a/implementation/runtime/src/application_impl.cpp b/implementation/runtime/src/application_impl.cpp
index ee95c5a..cc5d3d9 100644
--- a/implementation/runtime/src/application_impl.cpp
+++ b/implementation/runtime/src/application_impl.cpp
@@ -98,7 +98,6 @@ bool application_impl::init() {
}
void application_impl::start() {
- VSOMEIP_DEBUG << "Client [" << std::hex << client_ << "]: starting up...";
if (routing_)
routing_->start();
@@ -108,7 +107,6 @@ void application_impl::start() {
}
void application_impl::stop() {
- VSOMEIP_DEBUG << "Client [" << std::hex << client_ << "]: shutting down...";
if (routing_)
routing_->stop();
@@ -154,9 +152,9 @@ void application_impl::release_service(
}
void application_impl::subscribe(
- service_t _service, instance_t _instance, eventgroup_t _eventgroup) {
+ service_t _service, instance_t _instance, eventgroup_t _eventgroup, major_version_t _major, ttl_t _ttl) {
if (routing_)
- routing_->subscribe(client_, _service, _instance, _eventgroup);
+ routing_->subscribe(client_, _service, _instance, _eventgroup, _major, _ttl);
}
void application_impl::unsubscribe(
@@ -166,7 +164,7 @@ void application_impl::unsubscribe(
}
bool application_impl::is_available(service_t _service, instance_t _instance) {
- return routing_->is_available(_service, _instance);
+ return routing_ && routing_->is_available(_service, _instance);
}
std::shared_ptr< event > application_impl::add_event(
@@ -181,17 +179,22 @@ std::shared_ptr< event > application_impl::add_field(
}
void application_impl::remove_event_or_field(std::shared_ptr< event > _event) {
- routing_->remove_event_or_field(_event);
+ if (routing_)
+ routing_->remove_event_or_field(_event);
}
void application_impl::send(std::shared_ptr< message > _message, bool _flush, bool _reliable) {
if (routing_) {
- if (utility::is_request(_message)) {
+ // in case of requests set the request-id (client-id|session-id)
+ bool is_request = utility::is_request(_message);
+ if (is_request) {
_message->set_client(client_);
_message->set_session(session_);
}
+
+ // in case of successful sending, increment the session-id
if (routing_->send(client_, _message, _flush, _reliable)) {
- session_++;
+ if (is_request) session_++;
}
}
}
@@ -222,10 +225,6 @@ void application_impl::unregister_availability_handler(
void application_impl::register_message_handler(
service_t _service, instance_t _instance, method_t _method, message_handler_t _handler) {
- VSOMEIP_DEBUG << "Registering for message ["
- << std::hex << _service << "." << _instance << "." << _method
- << "]";
-
members_[_service][_instance][_method] = _handler;
}
@@ -283,17 +282,17 @@ void application_impl::on_message(std::shared_ptr< message > _message) {
// find list of handlers
auto found_service = members_.find(its_service);
if (found_service == members_.end()) {
- found_service = members_.find(any_service);
+ found_service = members_.find(ANY_SERVICE);
}
if (found_service != members_.end()) {
auto found_instance = found_service->second.find(its_instance);
if (found_instance == found_service->second.end()) {
- found_instance = found_service->second.find(any_instance);
+ found_instance = found_service->second.find(ANY_INSTANCE);
}
if (found_instance != found_service->second.end()) {
auto found_method = found_instance->second.find(its_method);
if (found_method == found_instance->second.end()) {
- found_method = found_instance->second.find(any_method);
+ found_method = found_instance->second.find(ANY_METHOD);
}
if (found_method != found_instance->second.end()) {
diff --git a/implementation/service_discovery/include/service_discovery.hpp b/implementation/service_discovery/include/service_discovery.hpp
index b488493..d2fab83 100644
--- a/implementation/service_discovery/include/service_discovery.hpp
+++ b/implementation/service_discovery/include/service_discovery.hpp
@@ -19,9 +19,11 @@ namespace sd {
class service_discovery {
public:
- virtual ~service_discovery() {};
+ virtual ~service_discovery() {
+ }
+ ;
- virtual std::shared_ptr< configuration > get_configuration() const = 0;
+ virtual std::shared_ptr<configuration> get_configuration() const = 0;
virtual boost::asio::io_service & get_io() = 0;
virtual void init() = 0;
@@ -29,9 +31,14 @@ public:
virtual void stop() = 0;
virtual void request_service(service_t _service, instance_t _instance,
- major_version_t _major, minor_version_t _minor, ttl_t _ttl) = 0;
+ major_version_t _major, minor_version_t _minor, ttl_t _ttl) = 0;
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) = 0;
+ virtual void unsubscribe(service_t _service, instance_t _instance,
+ eventgroup_t _eventgroup) = 0;
+
virtual void send(const std::string &_name, bool _is_announcing) = 0;
virtual void on_message(const byte_t *_data, length_t _length) = 0;
@@ -42,6 +49,3 @@ public:
#endif // VSOMEIP_SERVICE_DISCOVERY_HPP
-
-
-
diff --git a/implementation/service_discovery/include/service_discovery_impl.hpp b/implementation/service_discovery/include/service_discovery_impl.hpp
index 3fdae51..d1cb3e1 100644
--- a/implementation/service_discovery/include/service_discovery_impl.hpp
+++ b/implementation/service_discovery/include/service_discovery_impl.hpp
@@ -26,14 +26,13 @@ class serviceentry_impl;
class service_discovery_fsm;
class service_discovery_host;
-class service_discovery_impl:
- public service_discovery,
- public std::enable_shared_from_this< service_discovery_impl > {
+class service_discovery_impl: public service_discovery,
+ public std::enable_shared_from_this<service_discovery_impl> {
public:
service_discovery_impl(service_discovery_host *_host);
virtual ~service_discovery_impl();
- std::shared_ptr< configuration > get_configuration() const;
+ std::shared_ptr<configuration> get_configuration() const;
boost::asio::io_service & get_io();
void init();
@@ -44,33 +43,41 @@ public:
major_version_t _major, minor_version_t _minor, ttl_t _ttl);
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);
+ void unsubscribe(service_t _service, instance_t _instance,
+ eventgroup_t _eventgroup);
+
void send(const std::string &_name, bool _is_announcing);
void on_message(const byte_t *_data, length_t _length);
private:
- void insert_service_option(std::shared_ptr< message_impl > &_message,
- std::shared_ptr< serviceentry_impl > &_entry,
- std::shared_ptr< endpoint > _endpoint);
- void insert_service_entries(std::shared_ptr< message_impl > &_message,
+ void insert_service_option(std::shared_ptr<message_impl> &_message,
+ std::shared_ptr<serviceentry_impl> &_entry,
+ std::shared_ptr<endpoint> _endpoint);
+ void insert_service_entries(std::shared_ptr<message_impl> &_message,
service_map_t &_services, bool _is_offer);
- void process_serviceentry(std::shared_ptr< serviceentry_impl > &_entry,
- const std::vector< std::shared_ptr< option_impl > > &_options);
- void process_eventgroupentry(std::shared_ptr< eventgroupentry_impl > &_entry,
- const std::vector< std::shared_ptr< option_impl > > &_options);
+ void process_serviceentry(std::shared_ptr<serviceentry_impl> &_entry,
+ const std::vector<std::shared_ptr<option_impl> > &_options);
+ void process_eventgroupentry(std::shared_ptr<eventgroupentry_impl> &_entry,
+ const std::vector<std::shared_ptr<option_impl> > &_options);
private:
boost::asio::io_service &io_;
service_discovery_host *host_;
- std::shared_ptr< deserializer > deserializer_;
+ std::shared_ptr<deserializer> deserializer_;
- std::shared_ptr< service_discovery_fsm > default_;
- std::map< std::string,
- std::shared_ptr< service_discovery_fsm > > additional_;
+ std::shared_ptr<service_discovery_fsm> default_;
+ std::map<std::string, std::shared_ptr<service_discovery_fsm> > additional_;
service_map_t requested_;
+ eventgroup_map_t subscribed_;
+
+ // Sessions
+ // TODO: handle session id per unicast peer and multicast
};
} // namespace sd
diff --git a/implementation/service_discovery/src/service_discovery_fsm.cpp b/implementation/service_discovery/src/service_discovery_fsm.cpp
index df0f070..2f9f986 100644
--- a/implementation/service_discovery/src/service_discovery_fsm.cpp
+++ b/implementation/service_discovery/src/service_discovery_fsm.cpp
@@ -25,7 +25,6 @@ fsm::fsm(service_discovery_fsm *_fsm):
fsm_(_fsm),
fsm_base(_fsm->get_io()),
is_up_(true) {
- configuration *its_configuration = configuration::get();
}
fsm::~fsm() {
diff --git a/implementation/service_discovery/src/service_discovery_impl.cpp b/implementation/service_discovery/src/service_discovery_impl.cpp
index 776beaa..4c44699 100644
--- a/implementation/service_discovery/src/service_discovery_impl.cpp
+++ b/implementation/service_discovery/src/service_discovery_impl.cpp
@@ -30,10 +30,9 @@ namespace vsomeip {
namespace sd {
service_discovery_impl::service_discovery_impl(service_discovery_host *_host) :
- host_(_host),
- io_(_host->get_io()),
- default_(std::make_shared < service_discovery_fsm > ("default", this)),
- deserializer_(std::make_shared< deserializer >()) {
+ host_(_host), io_(_host->get_io()), default_(
+ std::make_shared < service_discovery_fsm > ("default", this)), deserializer_(
+ std::make_shared<deserializer>()) {
}
service_discovery_impl::~service_discovery_impl() {
@@ -65,10 +64,9 @@ void service_discovery_impl::init() {
}
host_->create_service_discovery_endpoint(
- its_configuration->get_service_discovery_address(),
- its_configuration->get_service_discovery_port(),
- its_configuration->get_service_discovery_protocol()
- );
+ its_configuration->get_service_discovery_multicast(),
+ its_configuration->get_service_discovery_port(),
+ its_configuration->get_service_discovery_protocol());
}
void service_discovery_impl::start() {
@@ -89,8 +87,6 @@ void service_discovery_impl::stop() {
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 << "]";
auto find_service = requested_.find(_service);
if (find_service != requested_.end()) {
auto find_instance = find_service->second.find(_instance);
@@ -98,11 +94,11 @@ void service_discovery_impl::request_service(service_t _service,
// TODO: check version and report errors
} else {
find_service->second[_instance]
- = std::make_shared< serviceinfo >(_major, _minor, _ttl);
+ = std::make_shared< serviceinfo>(_major, _minor, _ttl);
}
} else {
requested_[_service][_instance]
- = std::make_shared< serviceinfo >(_major, _minor, _ttl);
+ = std::make_shared<serviceinfo>(_major, _minor, _ttl);
}
}
@@ -114,15 +110,40 @@ void service_discovery_impl::release_service(service_t _service,
}
}
+void service_discovery_impl::subscribe(service_t _service, instance_t _instance,
+ eventgroup_t _eventgroup, major_version_t _major, ttl_t _ttl) {
+ auto found_service = subscribed_.find(_service);
+ if (found_service != subscribed_.end()) {
+ auto found_instance = found_service->second.find(_instance);
+ if (found_instance != found_service->second.end()) {
+ auto found_eventgroup = found_instance->second.find(_eventgroup);
+ if (found_eventgroup != found_instance->second.end()) {
+
+ } else {
+
+ }
+ } else {
+ // insert new subscription
+ }
+ } else {
+ // insert new subscription
+ }
+}
+
+void service_discovery_impl::unsubscribe(service_t _service,
+ instance_t _instance, eventgroup_t _eventgroup) {
+
+}
+
void service_discovery_impl::insert_service_option(
- std::shared_ptr< message_impl > &_message,
- std::shared_ptr< serviceentry_impl > &_entry,
- std::shared_ptr< endpoint > _endpoint) {
+ std::shared_ptr<message_impl> &_message,
+ std::shared_ptr<serviceentry_impl> &_entry,
+ std::shared_ptr<endpoint> _endpoint) {
ipv4_address_t its_address;
if (_endpoint->get_address(its_address)) {
- std::shared_ptr< ipv4_option_impl > its_option
- = _message->create_ipv4_option(false);
+ std::shared_ptr<ipv4_option_impl> its_option =
+ _message->create_ipv4_option(false);
if (its_option) {
its_option->set_address(its_address);
its_option->set_port(_endpoint->get_port());
@@ -132,8 +153,8 @@ void service_discovery_impl::insert_service_option(
} else {
ipv6_address_t its_address;
if (_endpoint->get_address(its_address)) {
- std::shared_ptr< ipv6_option_impl > its_option
- = _message->create_ipv6_option(false);
+ std::shared_ptr<ipv6_option_impl> its_option =
+ _message->create_ipv6_option(false);
if (its_option) {
its_option->set_address(its_address);
its_option->set_port(_endpoint->get_port());
@@ -145,28 +166,31 @@ void service_discovery_impl::insert_service_option(
}
void service_discovery_impl::insert_service_entries(
- std::shared_ptr< message_impl > &_message, service_map_t &_services,
+ std::shared_ptr<message_impl> &_message, service_map_t &_services,
bool _is_offer) {
for (auto its_service : _services) {
for (auto its_instance : its_service.second) {
auto its_info = its_instance.second;
- std::shared_ptr< serviceentry_impl > its_entry
- = _message->create_service_entry();
+ std::shared_ptr<serviceentry_impl> its_entry =
+ _message->create_service_entry();
if (its_entry) {
- its_entry->set_type((_is_offer ?
- entry_type_e::OFFER_SERVICE :
- entry_type_e::FIND_SERVICE));
+ its_entry->set_type(
+ (_is_offer ?
+ entry_type_e::OFFER_SERVICE :
+ entry_type_e::FIND_SERVICE));
its_entry->set_service(its_service.first);
its_entry->set_instance(its_instance.first);
its_entry->set_major_version(its_info->get_major());
its_entry->set_minor_version(its_info->get_minor());
its_entry->set_ttl(its_info->get_ttl());
- std::shared_ptr< endpoint > its_endpoint = its_info->get_endpoint(true);
+ std::shared_ptr<endpoint> its_endpoint = its_info->get_endpoint(
+ true);
if (its_endpoint) {
insert_service_option(_message, its_entry, its_endpoint);
if (0 == its_info->get_ttl()) {
- host_->del_routing_info(its_service.first, its_instance.first, true);
+ host_->del_routing_info(its_service.first,
+ its_instance.first, true);
}
}
@@ -174,7 +198,8 @@ void service_discovery_impl::insert_service_entries(
if (its_endpoint) {
insert_service_option(_message, its_entry, its_endpoint);
if (0 == its_info->get_ttl()) {
- host_->del_routing_info(its_service.first, its_instance.first, false);
+ host_->del_routing_info(its_service.first,
+ its_instance.first, false);
}
}
} else {
@@ -184,11 +209,12 @@ void service_discovery_impl::insert_service_entries(
}
}
+void service_discovery_impl::send(const std::string &_name,
+ bool _is_announcing) {
+ std::shared_ptr<message_impl> its_message =
+ runtime::get()->create_message();
-void service_discovery_impl::send(const std::string &_name, bool _is_announcing) {
- std::shared_ptr< message_impl > its_message = runtime::get()->create_message();
-
- // TODO: optimize building of SD message (common options)
+ // TODO: optimize building of SD message (common options, utilize the two runs)
// If we are the default group and not in main phase, include "FindOffer"-entries
if (_name == "default" && !_is_announcing) {
@@ -209,22 +235,25 @@ void service_discovery_impl::on_message(const byte_t *_data, length_t _length) {
std::stringstream msg;
msg << "sdi::on_message: ";
for (length_t i = 0; i < _length; ++i)
- msg << std::hex << std::setw(2) << std::setfill('0') << (int)_data[i] << " ";
+ msg << std::hex << std::setw(2) << std::setfill('0') << (int)_data[i] << " ";
VSOMEIP_DEBUG << msg.str();
#endif
deserializer_->set_data(_data, _length);
- std::shared_ptr< message_impl > its_message(deserializer_->deserialize_sd_message());
+ std::shared_ptr<message_impl> its_message(
+ deserializer_->deserialize_sd_message());
if (its_message) {
- std::vector< std::shared_ptr< option_impl > > its_options
- = its_message->get_options();
+ std::vector < std::shared_ptr<option_impl> > its_options =
+ its_message->get_options();
for (auto its_entry : its_message->get_entries()) {
if (its_entry->is_service_entry()) {
- std::shared_ptr< serviceentry_impl > its_service_entry
- = std::dynamic_pointer_cast< serviceentry_impl >(its_entry);
+ std::shared_ptr<serviceentry_impl> its_service_entry =
+ std::dynamic_pointer_cast < serviceentry_impl
+ > (its_entry);
process_serviceentry(its_service_entry, its_options);
} else {
- std::shared_ptr< eventgroupentry_impl > its_eventgroup_entry
- = std::dynamic_pointer_cast< eventgroupentry_impl >(its_entry);
+ std::shared_ptr<eventgroupentry_impl> its_eventgroup_entry =
+ std::dynamic_pointer_cast < eventgroupentry_impl
+ > (its_entry);
process_eventgroupentry(its_eventgroup_entry, its_options);
}
}
@@ -233,8 +262,8 @@ void service_discovery_impl::on_message(const byte_t *_data, length_t _length) {
// Entry processing
void service_discovery_impl::process_serviceentry(
- std::shared_ptr< serviceentry_impl > &_entry,
- const std::vector< std::shared_ptr< option_impl > > &_options) {
+ std::shared_ptr<serviceentry_impl> &_entry,
+ const std::vector<std::shared_ptr<option_impl> > &_options) {
service_t its_service = _entry->get_service();
instance_t its_instance = _entry->get_instance();
major_version_t its_major = _entry->get_major_version();
@@ -243,52 +272,52 @@ void service_discovery_impl::process_serviceentry(
for (auto i : { 1, 2 }) {
for (auto its_index : _entry->get_options(i)) {
- std::vector< byte_t > its_option_address;
+ std::vector<byte_t> its_option_address;
uint16_t its_option_port = VSOMEIP_INVALID_PORT;
- std::shared_ptr< option_impl > its_option = _options[its_index];
+ std::shared_ptr<option_impl> its_option = _options[its_index];
switch (its_option->get_type()) {
- case option_type_e::IP4_ENDPOINT:
- {
- std::shared_ptr< ipv4_option_impl > its_ipv4_option
- = std::dynamic_pointer_cast< ipv4_option_impl >(its_option);
+ case option_type_e::IP4_ENDPOINT: {
+ std::shared_ptr<ipv4_option_impl> its_ipv4_option =
+ std::dynamic_pointer_cast < ipv4_option_impl
+ > (its_option);
- boost::asio::ip::address_v4 its_ipv4_address(its_ipv4_option->get_address());
+ boost::asio::ip::address_v4 its_ipv4_address(
+ its_ipv4_option->get_address());
boost::asio::ip::address its_address(its_ipv4_address);
its_option_port = its_ipv4_option->get_port();
if (0 < its_ttl) {
host_->add_routing_info(its_service, its_instance,
- its_major, its_minor, its_ttl,
- its_address, its_option_port,
- !its_ipv4_option->is_udp());
+ its_major, its_minor, its_ttl, its_address,
+ its_option_port, !its_ipv4_option->is_udp());
} else {
host_->del_routing_info(its_service, its_instance,
- !its_ipv4_option->is_udp());
+ !its_ipv4_option->is_udp());
}
}
- break;
- case option_type_e::IP6_ENDPOINT:
- {
- std::shared_ptr< ipv6_option_impl > its_ipv6_option
- = std::dynamic_pointer_cast< ipv6_option_impl >(its_option);
+ break;
+ case option_type_e::IP6_ENDPOINT: {
+ std::shared_ptr<ipv6_option_impl> its_ipv6_option =
+ std::dynamic_pointer_cast < ipv6_option_impl
+ > (its_option);
- boost::asio::ip::address_v6 its_ipv6_address(its_ipv6_option->get_address());
+ boost::asio::ip::address_v6 its_ipv6_address(
+ its_ipv6_option->get_address());
boost::asio::ip::address its_address(its_ipv6_address);
its_option_port = its_ipv6_option->get_port();
if (0 < its_ttl) {
host_->add_routing_info(its_service, its_instance,
- its_major, its_minor, its_ttl,
- its_address, its_option_port,
- !its_ipv6_option->is_udp());
+ its_major, its_minor, its_ttl, its_address,
+ its_option_port, !its_ipv6_option->is_udp());
} else {
host_->del_routing_info(its_service, its_instance,
- !its_ipv6_option->is_udp());
+ !its_ipv6_option->is_udp());
}
}
- break;
+ break;
case option_type_e::IP4_MULTICAST:
case option_type_e::IP6_MULTICAST:
VSOMEIP_ERROR << "Invalid service option (Multicast)";
@@ -302,23 +331,18 @@ void service_discovery_impl::process_serviceentry(
}
void service_discovery_impl::process_eventgroupentry(
- std::shared_ptr< eventgroupentry_impl > &_entry,
- const std::vector< std::shared_ptr< option_impl > > &_options) {
+ std::shared_ptr<eventgroupentry_impl> &_entry,
+ const std::vector<std::shared_ptr<option_impl> > &_options) {
service_t its_service = _entry->get_service();
instance_t its_instance = _entry->get_instance();
eventgroup_t its_eventgroup = _entry->get_eventgroup();
major_version_t its_major = _entry->get_major_version();
ttl_t its_ttl = _entry->get_ttl();
- VSOMEIP_DEBUG << "Eventgroup ["
- << std::hex << std::setw(4) << std::setfill('0')
- << its_service << "." << its_instance << "." << its_eventgroup
- << "], version "
- << std::dec
- << (int)its_major
- << " is offered for "
- << its_ttl
- << " seconds.";
+ VSOMEIP_DEBUG << "Eventgroup [" << std::hex << std::setw(4)
+ << std::setfill('0') << its_service << "." << its_instance << "."
+ << its_eventgroup << "], version " << std::dec << (int) its_major
+ << " is offered for " << its_ttl << " seconds.";
}
} // namespace sd
diff --git a/interface/vsomeip/application.hpp b/interface/vsomeip/application.hpp
index 03289a5..f34709b 100644
--- a/interface/vsomeip/application.hpp
+++ b/interface/vsomeip/application.hpp
@@ -7,7 +7,7 @@
#ifndef VSOMEIP_APPLICATION_HPP
#define VSOMEIP_APPLICATION_HPP
-#include <vector>
+#include <memory>
#include <vsomeip/primitive_types.hpp>
#include <vsomeip/enumeration_types.hpp>
@@ -21,9 +21,13 @@ class payload;
class application {
public:
- virtual ~application() {};
+ virtual ~application() {
+ }
+ ;
+ // get name
virtual const std::string & get_name() const = 0;
+ virtual client_t get_client() const = 0;
// Lifecycle
virtual bool init() = 0;
@@ -32,50 +36,48 @@ public:
// Provide services
virtual void offer_service(service_t _service, instance_t _instance,
- major_version_t _major = default_major,
- minor_version_t _minor = default_minor,
- ttl_t _ttl = default_ttl) = 0;
+ major_version_t _major = DEFAULT_MAJOR, minor_version_t _minor =
+ DEFAULT_MINOR, ttl_t _ttl = DEFAULT_TTL) = 0;
virtual void stop_offer_service(service_t _service,
- instance_t _instance) = 0;
+ instance_t _instance) = 0;
virtual void publish_eventgroup(service_t _service, instance_t _instance,
- eventgroup_t _eventgroup, major_version_t _major,
- ttl_t _ttl) = 0;
+ eventgroup_t _eventgroup, major_version_t _major, ttl_t _ttl) = 0;
virtual void stop_publish_eventgroup(service_t _service,
- instance_t _instance, eventgroup_t _eventgroup) = 0;
+ instance_t _instance, eventgroup_t _eventgroup) = 0;
// Consume services
virtual void request_service(service_t _service, instance_t _instance,
- major_version_t _major = any_major,
- minor_version_t _minor = any_minor,
- ttl_t _ttl = any_ttl) = 0;
+ major_version_t _major = ANY_MAJOR, minor_version_t _minor =
+ ANY_MINOR, ttl_t _ttl = ANY_TTL) = 0;
virtual void release_service(service_t _service, instance_t _instance) = 0;
virtual void subscribe(service_t _service, instance_t _instance,
- eventgroup_t _eventgroup) = 0;
+ eventgroup_t _eventgroup, major_version_t _major = ANY_MAJOR,
+ ttl_t _ttl = ANY_TTL) = 0;
virtual void unsubscribe(service_t _service, instance_t _instance,
- eventgroup_t _eventgroup) = 0;
+ eventgroup_t _eventgroup) = 0;
virtual bool is_available(service_t _service, instance_t _instance) = 0;
// Define content of eventgroups
- virtual std::shared_ptr< event > add_event(service_t _service,
- instance_t _instance, eventgroup_t _eventgroup, event_t _event) = 0;
+ virtual std::shared_ptr<event> add_event(service_t _service,
+ instance_t _instance, eventgroup_t _eventgroup, event_t _event) = 0;
- virtual std::shared_ptr< event > add_field(service_t _service,
- instance_t _instance, eventgroup_t _eventgroup, event_t _event,
- std::shared_ptr< payload > _payload) = 0;
+ virtual std::shared_ptr<event> add_field(service_t _service,
+ instance_t _instance, eventgroup_t _eventgroup, event_t _event,
+ std::shared_ptr<payload> _payload) = 0;
virtual void remove_event_or_field(
- std::shared_ptr< event > _event /* or field */) = 0;
+ std::shared_ptr<event> _event /* or field */) = 0;
// Send messages
- virtual void send(std::shared_ptr< message > _message,
- bool _flush = true, bool _reliable = false) = 0;
+ virtual void send(std::shared_ptr<message> _message, bool _flush = true,
+ bool _reliable = false) = 0;
// Receive events (Non-SOME/IP)
virtual void register_event_handler(event_handler_t _handler) = 0;
@@ -83,16 +85,16 @@ public:
// Receive messages
virtual void register_message_handler(service_t _service,
- instance_t _instance, method_t _method,
- message_handler_t _handler) = 0;
+ instance_t _instance, method_t _method,
+ message_handler_t _handler) = 0;
virtual void unregister_message_handler(service_t _service,
- instance_t _instance, method_t _method) = 0;
+ instance_t _instance, method_t _method) = 0;
// Receive availability
virtual void register_availability_handler(service_t _service,
- instance_t _instance, availability_handler_t _handler) = 0;
+ instance_t _instance, availability_handler_t _handler) = 0;
virtual void unregister_availability_handler(service_t _service,
- instance_t _instance) = 0;
+ instance_t _instance) = 0;
};
} // namespace vsomeip
diff --git a/interface/vsomeip/configuration.hpp b/interface/vsomeip/configuration.hpp
index d0b3c55..999210e 100644
--- a/interface/vsomeip/configuration.hpp
+++ b/interface/vsomeip/configuration.hpp
@@ -25,7 +25,7 @@ public:
virtual bool load(const std::string &_path) = 0;
- virtual const boost::asio::ip::address & get_address() const = 0;
+ virtual const boost::asio::ip::address & get_unicast() const = 0;
virtual bool is_v4() const = 0;
virtual bool is_v6() const = 0;
@@ -38,9 +38,9 @@ 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_protocol() const = 0;
- virtual const std::string & get_service_discovery_address() const = 0;
+ virtual const std::string & get_service_discovery_multicast() const = 0;
virtual uint16_t get_service_discovery_port() const = 0;
+ virtual const std::string & get_service_discovery_protocol() const = 0;
virtual std::string get_group(service_t _service, instance_t _instance) const = 0;
virtual std::set< std::string > get_servicegroups() const = 0;
@@ -57,7 +57,6 @@ public:
virtual uint16_t get_reliable_port(service_t _service, instance_t _instance) const = 0;
virtual bool has_enabled_magic_cookies(std::string _address, uint16_t _port) const = 0;
virtual uint16_t get_unreliable_port(service_t _service, instance_t _instance) const = 0;
- virtual std::string get_multicast(service_t _service, instance_t _instance) const = 0;
virtual std::set< std::pair< service_t, instance_t > > get_remote_services() const = 0;
diff --git a/interface/vsomeip/constants.hpp b/interface/vsomeip/constants.hpp
index e15980c..7d0aa5f 100644
--- a/interface/vsomeip/constants.hpp
+++ b/interface/vsomeip/constants.hpp
@@ -16,39 +16,39 @@ namespace vsomeip {
const std::string base_path = "/tmp/vsomeip-";
-const major_version_t default_major = 0x01;
-const minor_version_t default_minor = 0x000000;
-const ttl_t default_ttl = 0xFFFFFF; // basically means "forever"
-
-const std::string default_multicast = "224.0.0.0";
-const uint16_t default_port = 30500;
-const uint16_t illegal_port = 0xFFFF;
-
-const service_t any_service = 0xFFFF;
-const instance_t any_instance = 0xFFFF;
-const method_t any_method = 0xFFFF;
-const major_version_t any_major = 0xFF;
-const minor_version_t any_minor = 0xFFFFFF;
-const ttl_t any_ttl = 1;
-
-const byte_t magic_cookie_client_message = 0x00;
-const byte_t magic_cookie_service_message = 0x80;
-const length_t magic_cookie_size = 0x00000008;
-const request_t magic_cookie_request = 0xDEADBEEF;
-const protocol_version_t magic_cookie_protocol_version = 0x01;
-const interface_version_t magic_cookie_interface_version = 0x01;
-const message_type_e magic_cookie_client_message_type = message_type_e::REQUEST_NO_RETURN;
-const message_type_e magic_cookie_service_message_type = message_type_e::NOTIFICATION;
-const return_code_e magic_cookie_return_code = return_code_e::E_OK;
-
-const byte_t client_cookie[] = {
+const major_version_t DEFAULT_MAJOR = 0x01;
+const minor_version_t DEFAULT_MINOR = 0x000000;
+const ttl_t DEFAULT_TTL = 0xFFFFFF; // basically means "forever"
+
+const std::string DEFAULT_MULTICAST = "224.0.0.0";
+const uint16_t DEFAULT_PORT = 30500;
+const uint16_t ILLEGAL_PORT = 0xFFFF;
+
+const service_t ANY_SERVICE = 0xFFFF;
+const instance_t ANY_INSTANCE = 0xFFFF;
+const method_t ANY_METHOD = 0xFFFF;
+const major_version_t ANY_MAJOR = 0xFF;
+const minor_version_t ANY_MINOR = 0xFFFFFF;
+const ttl_t ANY_TTL = 1;
+
+const byte_t MAGIC_COOKIE_CLIENT_MESSAGE = 0x00;
+const byte_t MAGIC_COOKIE_SERVICE_MESSAGE = 0x80;
+const length_t MAGIC_COOKIE_SIZE = 0x00000008;
+const request_t MAGIC_COOKIE_REQUEST = 0xDEADBEEF;
+const protocol_version_t MAGIC_COOKIE_PROTOCOL_VERSION = 0x01;
+const interface_version_t MAGIC_COOKIE_INTERFACE_VERSION = 0x01;
+const message_type_e MAGIC_COOKIE_CLIENT_MESSAGE_TYPE = message_type_e::REQUEST_NO_RETURN;
+const message_type_e MAGIC_COOKIE_SERVICE_MESSAGE_TYPE = message_type_e::NOTIFICATION;
+const return_code_e MAGIC_COOKIE_RETURN_CODE = return_code_e::E_OK;
+
+const byte_t CLIENT_COOKIE[] = {
0xFF, 0xFF, 0x00, 0x00,
0x00, 0x00, 0x00, 0x08,
0xDE, 0xAD, 0xBE, 0xEF,
0x01, 0x01, 0x01, 0x00
};
-const byte_t server_cookie[] = {
+const byte_t SERVICE_COOKIE[] = {
0xFF, 0xFF, 0x80, 0x00,
0x00, 0x00, 0x00, 0x08,
0xDE, 0xAD, 0xBE, 0xEF,
diff --git a/test/configuration-test.cpp b/test/configuration-test.cpp
index ada2f83..9deed47 100644
--- a/test/configuration-test.cpp
+++ b/test/configuration-test.cpp
@@ -20,23 +20,18 @@
#define DESIRED_RELIABLE_1234_0022 30506
#define DESIRED_UNRELIABLE_1234_0022 31000
-#define DESIRED_MULTICAST_1234_0022 "225.225.225.1"
#define DESIRED_RELIABLE_1234_0023 30503
-#define DESIRED_UNRELIABLE_1234_0023 vsomeip::illegal_port
-#define DESIRED_MULTICAST_1234_0023 "225.225.225.2"
+#define DESIRED_UNRELIABLE_1234_0023 vsomeip::ILLEGAL_PORT
#define DESIRED_RELIABLE_2277_0022 30505
#define DESIRED_UNRELIABLE_2277_0022 31001
-#define DESIRED_MULTICAST_2277_0022 "225.225.225.3"
#define DESIRED_RELIABLE_2266_0022 30505
#define DESIRED_UNRELIABLE_2266_0022 30507
-#define DESIRED_MULTICAST_2266_0022 "225.225.226.1"
#define DESIRED_RELIABLE_4466_0321 30506
#define DESIRED_UNRELIABLE_4466_0321 30444
-#define DESIRED_MULTICAST_4466_0321 "225.225.228.1"
#define DESIRED_ADDRESS_1234_0022 "local"
#define DESIRED_MIN_INITIAL_DELAY_1234_0022 10
@@ -92,7 +87,7 @@ int main(int argc, char **argv) {
}
// 2. Check host address
- boost::asio::ip::address its_address = its_configuration->get_address();
+ boost::asio::ip::address its_address = its_configuration->get_unicast();
check<std::string>(its_address.to_string(), DESIRED_ADDRESS, "HOST ADDRESS");
// 3. Check logging
@@ -111,44 +106,33 @@ int main(int argc, char **argv) {
// 4. Services
uint16_t its_reliable = its_configuration->get_reliable_port(0x1234, 0x0022);
uint16_t its_unreliable = its_configuration->get_unreliable_port(0x1234, 0x0022);
- std::string its_multicast = its_configuration->get_multicast(0x1234, 0x0022);
check<uint16_t>(its_reliable, DESIRED_RELIABLE_1234_0022, "RELIABLE_TEST_1234_0022");
check<uint16_t>(its_unreliable, DESIRED_UNRELIABLE_1234_0022, "UNRELIABLE_TEST_1234_0022");
- check<std::string>(its_multicast, DESIRED_MULTICAST_1234_0022, "MULTICAST_TEST_1234_0022");
its_reliable = its_configuration->get_reliable_port(0x1234, 0x0023);
its_unreliable = its_configuration->get_unreliable_port(0x1234, 0x0023);
- its_multicast = its_configuration->get_multicast(0x1234, 0x0023);
-
check<uint16_t>(its_reliable, DESIRED_RELIABLE_1234_0023, "RELIABLE_TEST_1234_0023");
check<uint16_t>(its_unreliable, DESIRED_UNRELIABLE_1234_0023, "UNRELIABLE_TEST_1234_0023");
- check<std::string>(its_multicast, DESIRED_MULTICAST_1234_0023, "MULTICAST_TEST_1234_0023");
its_reliable = its_configuration->get_reliable_port(0x2277, 0x0022);
its_unreliable = its_configuration->get_unreliable_port(0x2277, 0x0022);
- its_multicast = its_configuration->get_multicast(0x2277, 0x0022);
check<uint16_t>(its_reliable, DESIRED_RELIABLE_2277_0022, "RELIABLE_TEST_2277_0022");
check<uint16_t>(its_unreliable, DESIRED_UNRELIABLE_2277_0022, "UNRELIABLE_TEST_2277_0022");
- check<std::string>(its_multicast, DESIRED_MULTICAST_2277_0022, "MULTICAST_TEST_2277_0022");
its_reliable = its_configuration->get_reliable_port(0x4466, 0x0321);
its_unreliable = its_configuration->get_unreliable_port(0x4466, 0x0321);
- its_multicast = its_configuration->get_multicast(0x4466, 0x0321);
check<uint16_t>(its_reliable, DESIRED_RELIABLE_4466_0321, "RELIABLE_TEST_4466_0321");
check<uint16_t>(its_unreliable, DESIRED_UNRELIABLE_4466_0321, "UNRELIABLE_TEST_4466_0321");
- check<std::string>(its_multicast, DESIRED_MULTICAST_4466_0321, "MULTICAST_TEST_4466_0321");
its_reliable = its_configuration->get_reliable_port(0x2277, 0x0022);
its_unreliable = its_configuration->get_unreliable_port(0x2277, 0x0022);
- its_multicast = its_configuration->get_multicast(0x2277, 0x0022);
check<uint16_t>(its_reliable, DESIRED_RELIABLE_2277_0022, "RELIABLE_TEST_2277_0022");
check<uint16_t>(its_unreliable, DESIRED_UNRELIABLE_2277_0022, "UNRELIABLE_TEST_2277_0022");
- check<std::string>(its_multicast, DESIRED_MULTICAST_2277_0022, "MULTICAST_TEST_2277_0022");
std::string its_address_s = its_configuration->get_address(0x1234, 0x0022);
std::string its_group_name = its_configuration->get_group(0x1234, 0x0022);
diff --git a/test/magic-cookies-test-client.cpp b/test/magic-cookies-test-client.cpp
index 8dea758..c65a565 100644
--- a/test/magic-cookies-test-client.cpp
+++ b/test/magic-cookies-test-client.cpp
@@ -41,7 +41,7 @@ public:
std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
app_->register_message_handler(
- vsomeip::any_service, SAMPLE_INSTANCE_ID, vsomeip::any_method,
+ vsomeip::ANY_SERVICE, SAMPLE_INSTANCE_ID, vsomeip::ANY_METHOD,
std::bind(&client_sample::on_message,
this,
std::placeholders::_1));
@@ -61,8 +61,8 @@ public:
if (_event == vsomeip::event_type_e::REGISTERED) {
VSOMEIP_INFO << "Client registration done.";
app_->request_service(SAMPLE_SERVICE_ID, SAMPLE_INSTANCE_ID,
- vsomeip::any_major, vsomeip::any_minor,
- vsomeip::any_ttl);
+ vsomeip::ANY_MAJOR, vsomeip::ANY_MINOR,
+ vsomeip::ANY_TTL);
}
}