diff options
author | Jacob Keeler <jacob.keeler@livioradio.com> | 2017-08-18 15:27:12 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-18 15:27:12 -0400 |
commit | 9df5e02922703f00c9cfeaf7606de71d85f6345f (patch) | |
tree | 70502c83656793ecf0429560dcd7af7f89c668ed /src/components/protocol_handler | |
parent | f78d4122fc3de1070dc3fe4496488a13e29d9d8c (diff) | |
download | sdl_core-9df5e02922703f00c9cfeaf7606de71d85f6345f.tar.gz |
Fix version negotiation for pre-v5 appsfix/version_negotiation_pre_v5
The previous expected behavior was to send the maximum protocol version supported by Core in the first StartSessionACK. Now a hard limit of `PROTOCOL_VERSION_4` is set if the proxy doesn't support version 5, as v5 involves a change to the payload structure.
Diffstat (limited to 'src/components/protocol_handler')
-rw-r--r-- | src/components/protocol_handler/src/protocol_handler_impl.cc | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/components/protocol_handler/src/protocol_handler_impl.cc b/src/components/protocol_handler/src/protocol_handler_impl.cc index a4d263a00c..125e033147 100644 --- a/src/components/protocol_handler/src/protocol_handler_impl.cc +++ b/src/components/protocol_handler/src/protocol_handler_impl.cc @@ -243,6 +243,17 @@ void ProtocolHandlerImpl::SendStartSessionAck( uint8_t maxProtocolVersion = SupportedSDLProtocolVersion(); + const bool proxy_supports_v5_protocol = + protocol_version >= PROTOCOL_VERSION_5 || + (ServiceTypeFromByte(service_type) == kRpc && + full_version.majorVersion >= PROTOCOL_VERSION_5); + + // We can't send a V5+ packet if the proxy doesn't support it, + // so we manually set a maximum of V4 in that case + if (!proxy_supports_v5_protocol && maxProtocolVersion >= PROTOCOL_VERSION_5) { + maxProtocolVersion = PROTOCOL_VERSION_4; + } + ProtocolFramePtr ptr( new protocol_handler::ProtocolPacket(connection_id, maxProtocolVersion, @@ -254,13 +265,8 @@ void ProtocolHandlerImpl::SendStartSessionAck( 0u, message_counters_[session_id]++)); - const bool proxy_supports_v5_protocol = - protocol_version >= PROTOCOL_VERSION_5 || - (ServiceTypeFromByte(service_type) == kRpc && - full_version.majorVersion >= PROTOCOL_VERSION_5); - // Cannot include a constructed payload if either side doesn't support it - if (proxy_supports_v5_protocol && maxProtocolVersion >= PROTOCOL_VERSION_5) { + if (maxProtocolVersion >= PROTOCOL_VERSION_5) { ServiceType serviceTypeValue = ServiceTypeFromByte(service_type); bson_object_put_int64( |