summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLutz Bichler <Lutz.Bichler@bmw.de>2014-08-19 12:50:38 +0200
committerLutz Bichler <Lutz.Bichler@bmw.de>2014-08-19 12:50:38 +0200
commitff08e5d092641ca99ef9e9bf372adb743bab26b2 (patch)
tree555f01bb4a5e4dc8e438b80856a0af6906532da9
parent136d6eba9cb27be6567b34e83933f0b3eb60f0a0 (diff)
downloadvSomeIP-ff08e5d092641ca99ef9e9bf372adb743bab26b2.tar.gz
Bugfix: routing info was not correctly read at proxy side.
-rw-r--r--examples/request-sample.cpp5
-rw-r--r--examples/response-sample.cpp2
-rw-r--r--implementation/routing/src/routing_manager_proxy.cpp29
-rw-r--r--implementation/routing/src/routing_manager_stub.cpp7
4 files changed, 25 insertions, 18 deletions
diff --git a/examples/request-sample.cpp b/examples/request-sample.cpp
index 3125291..04c815a 100644
--- a/examples/request-sample.cpp
+++ b/examples/request-sample.cpp
@@ -50,6 +50,11 @@ public:
this,
std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
+ app_->register_availability_handler(SAMPLE_SERVICE_ID + 1, SAMPLE_INSTANCE_ID,
+ std::bind(&client_sample::on_availability,
+ this,
+ std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
+
app_->register_message_handler(
vsomeip::ANY_SERVICE, SAMPLE_INSTANCE_ID, vsomeip::ANY_METHOD,
std::bind(&client_sample::on_message,
diff --git a/examples/response-sample.cpp b/examples/response-sample.cpp
index 43f4abe..fe2f1c8 100644
--- a/examples/response-sample.cpp
+++ b/examples/response-sample.cpp
@@ -45,10 +45,12 @@ class service_sample {
void offer() {
app_->offer_service(SAMPLE_SERVICE_ID, SAMPLE_INSTANCE_ID);
+ app_->offer_service(SAMPLE_SERVICE_ID + 1, SAMPLE_INSTANCE_ID);
}
void stop_offer() {
app_->stop_offer_service(SAMPLE_SERVICE_ID, SAMPLE_INSTANCE_ID);
+ app_->stop_offer_service(SAMPLE_SERVICE_ID + 1, SAMPLE_INSTANCE_ID);
}
void on_event(vsomeip::event_type_e _event) {
diff --git a/implementation/routing/src/routing_manager_proxy.cpp b/implementation/routing/src/routing_manager_proxy.cpp
index a86d8fe..8eacf8d 100644
--- a/implementation/routing/src/routing_manager_proxy.cpp
+++ b/implementation/routing/src/routing_manager_proxy.cpp
@@ -399,15 +399,16 @@ void routing_manager_proxy::on_message(const byte_t *_data, length_t _size,
void routing_manager_proxy::on_routing_info(const byte_t *_data,
uint32_t _size) {
#if 0
- std::cout << "rmp::on_routing_info: ";
+ std::stringstream msg;
+ msg << "rmp::on_routing_info: ";
for (int i = 0; i < _size; ++i)
- std::cout << std::hex << std::setw(2) << std::setfill('0') << (int)_data[i] << " ";
- std::cout << std::endl;
+ msg << std::hex << std::setw(2) << std::setfill('0') << (int)_data[i] << " ";
+ VSOMEIP_DEBUG << msg.str();
#endif
event_type_e its_state(event_type_e::DEREGISTERED);
- std::map<service_t, std::map<instance_t, client_t> > old_local_services =
- local_services_;
+ std::map<service_t,
+ std::map<instance_t, client_t> > old_local_services = local_services_;
local_services_.clear();
uint32_t i = 0;
@@ -427,29 +428,27 @@ void routing_manager_proxy::on_routing_info(const byte_t *_data,
its_state = event_type_e::REGISTERED;
}
- if (i + sizeof(uint32_t) <= _size) {
+ uint32_t j = 0;
+ while (j + sizeof(uint32_t) <= its_client_size) {
uint32_t its_services_size;
- std::memcpy(&its_services_size, &_data[i], sizeof(uint32_t));
- i += sizeof(uint32_t);
+ std::memcpy(&its_services_size, &_data[i + j], sizeof(uint32_t));
+ j += sizeof(uint32_t);
- uint32_t j = 0;
- while (j + sizeof(service_t) + sizeof(instance_t)
- <= its_services_size) {
+ if (its_services_size <= sizeof(service_t) + sizeof(instance_t)) {
service_t its_service;
std::memcpy(&its_service, &_data[i + j], sizeof(service_t));
j += sizeof(service_t);
instance_t its_instance;
- std::memcpy(&its_instance, &_data[i + j],
- sizeof(instance_t));
+ std::memcpy(&its_instance, &_data[i + j], sizeof(instance_t));
j += sizeof(instance_t);
if (its_client != client_)
local_services_[its_service][its_instance] = its_client;
}
-
- i += its_services_size;
}
+
+ i += j;
}
}
diff --git a/implementation/routing/src/routing_manager_stub.cpp b/implementation/routing/src/routing_manager_stub.cpp
index b62c8bc..380cb22 100644
--- a/implementation/routing/src/routing_manager_stub.cpp
+++ b/implementation/routing/src/routing_manager_stub.cpp
@@ -285,10 +285,11 @@ void routing_manager_stub::send_routing_info(client_t _client) {
sizeof(its_size));
its_size += VSOMEIP_COMMAND_PAYLOAD_POS;
#if 0
- std::cout << "rms::send_routing_info ";
+ std::stringstream msg;
+ msg << "rms::send_routing_info ";
for (int i = 0; i < its_size; ++i)
- std::cout << std::hex << std::setw(2) << std::setfill('0') << (int)its_command[i] << " ";
- std::cout << std::endl;
+ msg << std::hex << std::setw(2) << std::setfill('0') << (int)its_command[i] << " ";
+ VSOMEIP_DEBUG << msg.str();
#endif
its_endpoint->send(&its_command[0], its_size, true);
}