summaryrefslogtreecommitdiff
path: root/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h')
-rw-r--r--src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h152
1 files changed, 115 insertions, 37 deletions
diff --git a/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h b/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h
index 0efb81cdd7..3e7d64e9d2 100644
--- a/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h
+++ b/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h
@@ -42,8 +42,10 @@
#include "utils/prioritized_queue.h"
#include "utils/message_queue.h"
#include "utils/threads/message_loop_thread.h"
-#include "utils/shared_ptr.h"
+
#include "utils/messagemeter.h"
+#include "utils/custom_string.h"
+#include "utils/semantic_version.h"
#include "protocol_handler/protocol_handler.h"
#include "protocol_handler/protocol_packet.h"
@@ -55,6 +57,7 @@
#include "transport_manager/common.h"
#include "transport_manager/transport_manager.h"
#include "transport_manager/transport_manager_listener_empty.h"
+#include "transport_manager/transport_adapter/transport_adapter.h"
#include "connection_handler/connection_handler.h"
#include "application_manager/policies/policy_handler_observer.h"
@@ -131,6 +134,30 @@ typedef threads::MessageLoopThread<
utils::PrioritizedQueue<RawFordMessageFromMobile> > FromMobileQueue;
typedef threads::MessageLoopThread<
utils::PrioritizedQueue<RawFordMessageToMobile> > ToMobileQueue;
+
+// Type to allow easy mapping between a device type and transport
+// characteristics
+typedef enum {
+ TT_NONE = -1,
+ TT_USB = 0,
+ TT_BLUETOOTH = 1,
+ TT_WIFI = 2
+} TransportType;
+
+struct TransportDescription {
+ TransportDescription(const TransportType transport_type,
+ const bool ios_transport,
+ const bool android_transport)
+ : transport_type_(transport_type)
+ , ios_transport_(ios_transport)
+ , android_transport_(android_transport) {}
+
+ TransportType transport_type_;
+ bool ios_transport_;
+ bool android_transport_;
+};
+
+typedef std::map<std::string, TransportDescription> TransportTypes;
} // namespace impl
/**
@@ -231,10 +258,20 @@ class ProtocolHandlerImpl
*/
void SendEndSession(int32_t connection_id, uint8_t session_id);
- void SendEndService(int32_t connection_id,
+ /**
+ * \brief Sends ending session to mobile application
+ * \param primary_connection_id Identifier of connection within which
+ * service exists
+ * \param connection_id Identifier of the actual transport for the service
+ * \param session_id ID of session to be ended
+ */
+ void SendEndService(int32_t primary_connection_id,
+ int32_t connection_id,
uint8_t session_id,
uint8_t service_type);
+ void NotifyOnFailedHandshake() OVERRIDE;
+
// TODO(Ezamakhov): move Ack/Nack as interface for StartSessionHandler
/**
* \brief Sends acknowledgement of starting session to mobile application
@@ -277,7 +314,7 @@ class ProtocolHandlerImpl
uint32_t hash_code,
uint8_t service_type,
bool protection,
- ProtocolPacket::ProtocolVersion& full_version);
+ utils::SemanticVersion& full_version);
/**
* \brief Sends acknowledgement of starting session to mobile application
@@ -301,7 +338,7 @@ class ProtocolHandlerImpl
uint32_t hash_code,
uint8_t service_type,
bool protection,
- ProtocolPacket::ProtocolVersion& full_version,
+ utils::SemanticVersion& full_version,
BsonObject& params);
const ProtocolHandlerSettings& get_settings() const OVERRIDE {
@@ -381,27 +418,6 @@ class ProtocolHandlerImpl
SessionObserver& get_session_observer() OVERRIDE;
/**
- * \brief Called by connection handler to notify the result of
- * OnSessionStartedCallback().
- * \param connection_id Identifier of connection within which session exists
- * \param session_id session ID passed to OnSessionStartedCallback()
- * \param generated_session_id Generated session ID, will be 0 if session is
- * not started
- * \param hash_id Generated Hash ID
- * \param protection whether the service will be protected
- * \param rejected_params list of parameters' name that are rejected.
- * Only valid when generated_session_id is 0. Note, even if
- * generated_session_id is 0, the list may be empty.
- */
- DEPRECATED void NotifySessionStartedResult(
- int32_t connection_id,
- uint8_t session_id,
- uint8_t generated_session_id,
- uint32_t hash_id,
- bool protection,
- std::vector<std::string>& rejected_params) OVERRIDE;
-
- /**
* @brief Called by connection handler to notify the result of
* OnSessionStartedCallback().
* @param context reference to structure with started session data
@@ -420,10 +436,19 @@ class ProtocolHandlerImpl
const impl::ToMobileQueue& get_to_mobile_queue() const {
return raw_ford_messages_to_mobile_;
}
+
+ void set_tcp_config(bool tcp_enabled,
+ std::string tcp_address,
+ std::string tcp_port) {
+ tcp_enabled_ = tcp_enabled;
+ tcp_ip_address_ = tcp_address;
+ tcp_port_ = tcp_port;
+ }
#endif
private:
- void SendEndServicePrivate(int32_t connection_id,
+ void SendEndServicePrivate(int32_t primary_connection_id,
+ int32_t connection_id,
uint8_t session_id,
uint8_t service_type);
@@ -434,6 +459,28 @@ class ProtocolHandlerImpl
uint8_t session_id,
uint32_t message_id);
+ /*
+ * Prepare and send TransportUpdateEvent message
+ */
+ void SendTransportUpdateEvent(ConnectionID connection_id, uint8_t session_id);
+
+ /*
+ * Prepare and send RegisterSecondaryTransportAck message
+ */
+ RESULT_CODE SendRegisterSecondaryTransportAck(
+ ConnectionID connection_id,
+ ConnectionID primary_transport_connection_id,
+ uint8_t session_id);
+
+ /*
+ * Prepare and send RegisterSecondaryTransportNAck message
+ */
+ RESULT_CODE SendRegisterSecondaryTransportNAck(
+ ConnectionID connection_id,
+ ConnectionID primary_transport_connection_id,
+ uint8_t session_id,
+ BsonObject* reason = NULL);
+
/**
* @brief Notifies about receiving message from TM.
*
@@ -472,13 +519,18 @@ class ProtocolHandlerImpl
void OnConnectionClosed(
const transport_manager::ConnectionUID connection_id) OVERRIDE;
+ void OnUnexpectedDisconnect(
+ const transport_manager::ConnectionUID connection_id,
+ const transport_manager::CommunicationError& error) OVERRIDE;
+
/**
- * @brief OnPTUFinished the callback which signals PTU has finished
+ * @brief Notifies that configuration of a transport has been updated.
*
- * @param ptu_result the result from the PTU - true if successful,
- * otherwise false.
+ * @param configs pairs of key and value that represent configuration.
*/
- void OnPTUFinished(const bool ptu_result) OVERRIDE;
+ void OnTransportConfigUpdated(
+ const transport_manager::transport_adapter::TransportConfig& configs)
+ OVERRIDE;
/**
* @brief Notifies subscribers about message
@@ -576,11 +628,11 @@ class ProtocolHandlerImpl
RESULT_CODE HandleControlMessageEndServiceACK(const ProtocolPacket& packet);
- DEPRECATED RESULT_CODE
- HandleControlMessageStartSession(const ProtocolPacket& packet);
-
RESULT_CODE HandleControlMessageStartSession(const ProtocolFramePtr packet);
+ RESULT_CODE HandleControlMessageRegisterSecondaryTransport(
+ const ProtocolFramePtr packet);
+
RESULT_CODE HandleControlMessageHeartBeat(const ProtocolPacket& packet);
void PopValideAndExpirateMultiframes();
@@ -609,6 +661,32 @@ class ProtocolHandlerImpl
*/
uint8_t SupportedSDLProtocolVersion() const;
+ const impl::TransportDescription GetTransportTypeFromConnectionType(
+ const std::string& device_type) const;
+
+ const bool ParseSecondaryTransportConfiguration(
+ const ConnectionID connection_id,
+ std::vector<std::string>& secondaryTransports,
+ std::vector<int32_t>& audioServiceTransports,
+ std::vector<int32_t>& videoServiceTransports) const;
+
+ void GenerateSecondaryTransportsForStartSessionAck(
+ const std::vector<std::string>& secondary_transport_types,
+ bool device_is_ios,
+ bool device_is_android,
+ std::vector<std::string>& secondaryTransports) const;
+
+ void GenerateServiceTransportsForStartSessionAck(
+ bool secondary_enabled,
+ const std::vector<std::string>& service_transports,
+ const std::string& primary_connection_type,
+ const impl::TransportType primary_transport_type,
+ const std::vector<std::string>& secondary_transport_types,
+ std::vector<int32_t>& serviceTransports) const;
+
+ const std::string TransportTypeFromTransport(
+ const utils::custom_string::CustomString& transport) const;
+
const ProtocolHandlerSettings& settings_;
/**
@@ -683,10 +761,6 @@ class ProtocolHandlerImpl
#ifdef ENABLE_SECURITY
security_manager::SecurityManager* security_manager_;
-
- bool is_ptu_triggered_;
- std::list<std::shared_ptr<HandshakeHandler> > ptu_pending_handlers_;
- sync_primitives::Lock ptu_handlers_lock_;
#endif // ENABLE_SECURITY
// Thread that pumps non-parsed messages coming from mobile side.
@@ -699,6 +773,10 @@ class ProtocolHandlerImpl
sync_primitives::Lock start_session_frame_map_lock_;
StartSessionFrameMap start_session_frame_map_;
+ bool tcp_enabled_;
+ std::string tcp_port_;
+ std::string tcp_ip_address_;
+
#ifdef TELEMETRY_MONITOR
PHTelemetryObserver* metric_observer_;
#endif // TELEMETRY_MONITOR