summaryrefslogtreecommitdiff
path: root/src/components/protocol_handler/src
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/protocol_handler/src')
-rw-r--r--src/components/protocol_handler/src/incoming_data_handler.cc15
-rw-r--r--src/components/protocol_handler/src/protocol_handler_impl.cc10
-rw-r--r--src/components/protocol_handler/src/protocol_packet.cc22
3 files changed, 34 insertions, 13 deletions
diff --git a/src/components/protocol_handler/src/incoming_data_handler.cc b/src/components/protocol_handler/src/incoming_data_handler.cc
index 566b36f46d..498618d6de 100644
--- a/src/components/protocol_handler/src/incoming_data_handler.cc
+++ b/src/components/protocol_handler/src/incoming_data_handler.cc
@@ -50,10 +50,9 @@ static const size_t MIN_HEADER_SIZE =
ProtocolFramePtrList IncomingDataHandler::ProcessData(
const RawMessage& tm_message,
- RESULT_CODE* result,
+ RESULT_CODE& out_result,
size_t* malformed_occurrence) {
LOG4CXX_AUTO_TRACE(logger_);
- DCHECK(result);
DCHECK(malformed_occurrence);
const transport_manager::ConnectionUID connection_id =
tm_message.connection_key();
@@ -61,7 +60,7 @@ ProtocolFramePtrList IncomingDataHandler::ProcessData(
const size_t tm_message_size = tm_message.data_size();
if (tm_message_size == 0 || data == NULL) {
LOG4CXX_WARN(logger_, "Wrong raw message " << tm_message_size << " bytes");
- *result = RESULT_FAIL;
+ out_result = RESULT_FAIL;
return ProtocolFramePtrList();
}
LOG4CXX_INFO(logger_,
@@ -70,7 +69,7 @@ ProtocolFramePtrList IncomingDataHandler::ProcessData(
ConnectionsDataMap::iterator it = connections_data_.find(connection_id);
if (connections_data_.end() == it) {
LOG4CXX_WARN(logger_, "ProcessData requested for unknown connection");
- *result = RESULT_FAIL;
+ out_result = RESULT_FAIL;
return ProtocolFramePtrList();
}
std::vector<uint8_t>& connection_data = it->second;
@@ -80,7 +79,7 @@ ProtocolFramePtrList IncomingDataHandler::ProcessData(
<< connection_data.size());
ProtocolFramePtrList out_frames;
*malformed_occurrence = 0;
- *result = CreateFrame(
+ out_result = CreateFrame(
connection_data, out_frames, *malformed_occurrence, connection_id);
LOG4CXX_DEBUG(logger_,
"New data size for connection " << connection_id << " is "
@@ -89,7 +88,7 @@ ProtocolFramePtrList IncomingDataHandler::ProcessData(
LOG4CXX_INFO(logger_,
"Created and passed " << out_frames.size() << " packets");
} else {
- if (RESULT_DEFERRED == *result) {
+ if (RESULT_DEFERRED == out_result) {
LOG4CXX_DEBUG(
logger_,
"No packets have been created. Waiting next portion of data.");
@@ -98,9 +97,9 @@ ProtocolFramePtrList IncomingDataHandler::ProcessData(
}
}
if (*malformed_occurrence > 0u || last_portion_of_data_was_malformed_) {
- *result = RESULT_MALFORMED_OCCURS;
+ out_result = RESULT_MALFORMED_OCCURS;
} else {
- *result = RESULT_OK;
+ out_result = RESULT_OK;
}
return out_frames;
}
diff --git a/src/components/protocol_handler/src/protocol_handler_impl.cc b/src/components/protocol_handler/src/protocol_handler_impl.cc
index 04c1529573..ace27fb307 100644
--- a/src/components/protocol_handler/src/protocol_handler_impl.cc
+++ b/src/components/protocol_handler/src/protocol_handler_impl.cc
@@ -104,6 +104,8 @@ ProtocolHandlerImpl::ProtocolHandlerImpl(
get_settings().maximum_audio_payload_size());
protocol_header_validator_.set_max_video_payload_size(
get_settings().maximum_video_payload_size());
+ protocol_header_validator_.set_max_protocol_version_supported(
+ get_settings().max_supported_protocol_version());
incoming_data_handler_.set_validator(&protocol_header_validator_);
const size_t& message_frequency_count =
@@ -976,17 +978,17 @@ void ProtocolHandlerImpl::OnTMMessageReceived(const RawMessagePtr tm_message) {
size_t malformed_occurs = 0u;
const ProtocolFramePtrList protocol_frames =
incoming_data_handler_.ProcessData(
- *tm_message, &result, &malformed_occurs);
- LOG4CXX_DEBUG(logger_, "Proccessed " << protocol_frames.size() << " frames");
+ *tm_message, result, &malformed_occurs);
+ LOG4CXX_DEBUG(logger_, "Processed " << protocol_frames.size() << " frames");
if (result != RESULT_OK) {
if (result == RESULT_MALFORMED_OCCURS) {
LOG4CXX_WARN(
logger_,
"Malformed message occurs, connection id " << connection_key);
if (!get_settings().malformed_message_filtering()) {
- LOG4CXX_DEBUG(logger_, "Malformed message filterign disabled");
+ LOG4CXX_DEBUG(logger_, "Malformed message filtering disabled");
session_observer_.OnMalformedMessageCallback(connection_key);
- // For tracking only malformed occurrence check outpute
+ // For tracking only malformed occurrence check output
} else {
if (malformed_occurs > 0) {
TrackMalformedMessage(connection_key, malformed_occurs);
diff --git a/src/components/protocol_handler/src/protocol_packet.cc b/src/components/protocol_handler/src/protocol_packet.cc
index 1f9fc431ae..5bee1c16b2 100644
--- a/src/components/protocol_handler/src/protocol_packet.cc
+++ b/src/components/protocol_handler/src/protocol_packet.cc
@@ -162,7 +162,8 @@ ProtocolPacket::ProtocolHeaderValidator::ProtocolHeaderValidator()
, max_control_payload_size_(0)
, max_rpc_payload_size_(0)
, max_audio_payload_size_(0)
- , max_video_payload_size_(0) {}
+ , max_video_payload_size_(0)
+ , max_protocol_version_supported_(PROTOCOL_VERSION_MAX) {}
void ProtocolPacket::ProtocolHeaderValidator::set_max_payload_size(
const size_t max_payload_size) {
@@ -198,6 +199,15 @@ void ProtocolPacket::ProtocolHeaderValidator::set_max_video_payload_size(
max_video_payload_size_ = max_payload_size;
}
+void ProtocolPacket::ProtocolHeaderValidator::
+ set_max_protocol_version_supported(
+ const uint16_t max_protocol_version_supported) {
+ LOG4CXX_DEBUG(logger_,
+ "New maximum protocol version supported is "
+ << max_protocol_version_supported);
+ max_protocol_version_supported_ = max_protocol_version_supported;
+}
+
size_t ProtocolPacket::ProtocolHeaderValidator::max_payload_size() const {
return max_payload_size_;
}
@@ -219,6 +229,12 @@ size_t ProtocolPacket::ProtocolHeaderValidator::max_video_payload_size() const {
return max_video_payload_size_;
}
+uint16_t
+ProtocolPacket::ProtocolHeaderValidator::max_protocol_version_supported()
+ const {
+ return max_protocol_version_supported_;
+}
+
size_t
ProtocolPacket::ProtocolHeaderValidator::max_payload_size_by_service_type(
const ServiceType type) const {
@@ -257,6 +273,10 @@ RESULT_CODE ProtocolPacket::ProtocolHeaderValidator::validate(
// expected payload size will be calculated depending
// on used protocol version and service type
size_t payload_size = MAXIMUM_FRAME_DATA_V2_SIZE;
+ // Protocol version shall be from 1 to 4
+ if (max_protocol_version_supported_ < header.version) {
+ return RESULT_FAIL;
+ }
switch (header.version) {
case PROTOCOL_VERSION_1:
case PROTOCOL_VERSION_2: