diff options
author | AKalinich-Luxoft <AKalinich@luxoft.com> | 2018-05-30 16:04:40 +0300 |
---|---|---|
committer | AKalinich-Luxoft <AKalinich@luxoft.com> | 2018-05-31 14:18:13 +0300 |
commit | 0b8f54986b843b11bfd66c9e5dc74f3f2ee6c5e7 (patch) | |
tree | de0d1a0ef2aa60b7581061e191734739b0fba863 | |
parent | 60254e8117237b9e5039a4c05d0b6ac0757d7350 (diff) | |
download | sdl_core-0b8f54986b843b11bfd66c9e5dc74f3f2ee6c5e7.tar.gz |
Fix style issues and compilation errors
-rw-r--r-- | src/components/protocol_handler/src/protocol_handler_impl.cc | 94 |
1 files changed, 53 insertions, 41 deletions
diff --git a/src/components/protocol_handler/src/protocol_handler_impl.cc b/src/components/protocol_handler/src/protocol_handler_impl.cc index 5d6aa09874..039f06b7d2 100644 --- a/src/components/protocol_handler/src/protocol_handler_impl.cc +++ b/src/components/protocol_handler/src/protocol_handler_impl.cc @@ -280,8 +280,8 @@ void ProtocolHandlerImpl::SendStartSessionAck( // Cannot include a constructed payload if either side doesn't support it if (ack_protocol_version >= PROTOCOL_VERSION_5) { - serviceTypeValue = ServiceTypeFromByte(service_type); - bson_success1 = bson_object_put_int64( + serviceTypeValue = ServiceTypeFromByte(service_type); + bson_success1 = bson_object_put_int64( ¶ms, strings::mtu, static_cast<int64_t>( @@ -312,18 +312,20 @@ void ProtocolHandlerImpl::SendStartSessionAck( raw_ford_messages_to_mobile_.PostMessage( impl::RawFordMessageToMobile(ptr, false)); - LOG4CXX_DEBUG(logger_, - "SendStartSessionAck() for connection " - << connection_id << " for service_type " - << static_cast<int32_t>(service_type) << " session_id " - << static_cast<int32_t>(session_id) << " protection " - << (protection ? "ON" : "OFF") - << " hashid " << static_cast<int32_t>(bson_object_get_int32(¶ms, strings::hash_id)) - << " mtu " << static_cast<int32_t>(bson_object_get_int64(¶ms, strings::mtu)) - << " protocol_version " << bson_object_get_string(¶ms, strings::protocol_version) - << "bson_success1 " << bson_success1 - << "bson_success2 " << bson_success2 - << "bson_success3 " << bson_success3); + LOG4CXX_DEBUG( + logger_, + "SendStartSessionAck() for connection " + << connection_id << " for service_type " + << static_cast<int32_t>(service_type) << " session_id " + << static_cast<int32_t>(session_id) << " protection " + << (protection ? "ON" : "OFF") << " hashid " + << static_cast<int32_t>( + bson_object_get_int32(¶ms, strings::hash_id)) << " mtu " + << static_cast<int32_t>(bson_object_get_int64(¶ms, strings::mtu)) + << " protocol_version " + << bson_object_get_string(¶ms, strings::protocol_version) + << "bson_success1 " << bson_success1 << "bson_success2 " + << bson_success2 << "bson_success3 " << bson_success3); } void ProtocolHandlerImpl::SendStartSessionNAck(ConnectionID connection_id, @@ -1551,46 +1553,50 @@ void ProtocolHandlerImpl::NotifySessionStarted( packet->service_type(), rejected_params); } else if (ssl_context->IsInitCompleted()) { - - // BsonObject req_param = bson_object_from_bytes(packet->data()); + // BsonObject req_param = bson_object_from_bytes(packet->data()); ServiceType serviceTypeValue; bool bson_success1 = false; bool bson_success2 = false; bool bson_success3 = false; - if (fullVersion->majorVersion >= PROTOCOL_VERSION_5) { + if (fullVersion->majorVersion >= PROTOCOL_VERSION_5) { serviceTypeValue = ServiceTypeFromByte(service_type); bson_success1 = bson_object_put_int64( - start_session_ack_params.get(), - strings::mtu, - static_cast<int64_t>( - protocol_header_validator_.max_payload_size_by_service_type( - serviceTypeValue))); + start_session_ack_params.get(), + strings::mtu, + static_cast<int64_t>( + protocol_header_validator_.max_payload_size_by_service_type( + serviceTypeValue))); if (serviceTypeValue == kRpc) { // Hash ID is only used in RPC case - bson_success2 = bson_object_put_int32( - start_session_ack_params.get(), strings::hash_id, static_cast<int32_t>(context.hash_id_)); + bson_success2 = + bson_object_put_int32(start_session_ack_params.get(), + strings::hash_id, + static_cast<int32_t>(context.hash_id_)); // Minimum protocol version supported by both ProtocolPacket::ProtocolVersion* minVersion = - (fullVersion->majorVersion < PROTOCOL_VERSION_5) + (fullVersion->majorVersion < PROTOCOL_VERSION_5) ? &defaultProtocolVersion - : ProtocolPacket::ProtocolVersion::min(*fullVersion, - defaultProtocolVersion); + : ProtocolPacket::ProtocolVersion::min( + *fullVersion, defaultProtocolVersion); char protocolVersionString[256]; - strncpy(protocolVersionString, (*minVersion).to_string().c_str(), 255); - bson_success3 = bson_object_put_string( - start_session_ack_params.get(), strings::protocol_version, protocolVersionString); + strncpy( + protocolVersionString, (*minVersion).to_string().c_str(), 255); + bson_success3 = bson_object_put_string(start_session_ack_params.get(), + strings::protocol_version, + protocolVersionString); } - uint8_t* payloadBytes = bson_object_to_bytes(¶ms); - ptr->set_data(payloadBytes, bson_object_size(¶ms)); + uint8_t* payloadBytes = + bson_object_to_bytes(start_session_ack_params.get()); + packet->set_data(payloadBytes, + bson_object_size(start_session_ack_params.get())); free(payloadBytes); } - LOG4CXX_DEBUG(logger_, - "bson_success1 " << bson_success1 - << "bson_success2 " << bson_success2 - << "bson_success3 " << bson_success3); + "bson_success1 " << bson_success1 << "bson_success2 " + << bson_success2 << "bson_success3 " + << bson_success3); // mark service as protected session_observer_.SetProtectionFlag(connection_key, service_type); @@ -1833,7 +1839,8 @@ void ProtocolHandlerImpl::set_security_manager( RESULT_CODE ProtocolHandlerImpl::EncryptFrame(ProtocolFramePtr packet) { DCHECK(packet); - // Data over control service shall be unprotected, control frames can be protected + // Data over control service shall be unprotected, control frames can be + // protected if (packet->service_type() == kControl) { return RESULT_OK; } @@ -1879,10 +1886,15 @@ RESULT_CODE ProtocolHandlerImpl::DecryptFrame(ProtocolFramePtr packet) { DCHECK(packet); if (!packet->protection_flag() || // Data over control service shall be unprotected - packet->service_type() == kControl - || (packet->frame_type() == FRAME_TYPE_CONTROL && packet->service_type() == kMobileNav ) //Start service requests shall be unprotected - || (packet->frame_type() == FRAME_TYPE_CONTROL && packet->service_type() == kAudio ) - || (packet->frame_type() == FRAME_TYPE_CONTROL && packet->service_type() == kRpc )) { + packet->service_type() == kControl || + (packet->frame_type() == FRAME_TYPE_CONTROL && + packet->service_type() == + kMobileNav) // Start service requests shall be unprotected + || + (packet->frame_type() == FRAME_TYPE_CONTROL && + packet->service_type() == kAudio) || + (packet->frame_type() == FRAME_TYPE_CONTROL && + packet->service_type() == kRpc)) { return RESULT_OK; } if (!security_manager_) { |