summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjacobkeeler <jacob.keeler@livioradio.com>2019-03-27 15:00:19 -0400
committerjacobkeeler <jacob.keeler@livioradio.com>2019-03-27 15:00:19 -0400
commit74ba1df3e93e33b4a3dcb799ce66142f9e9728d2 (patch)
tree5f8b56fa6c08f801b430f0f83e5bc4eea679e794
parentfb88c1700b4c4ede7be876ad236c35cbdc2f2052 (diff)
downloadsdl_core-fix/5.1.0_build_failures.tar.gz
Fix build failures depending on build optionsfix/5.1.0_build_failures
-rw-r--r--src/components/application_manager/src/application_manager_impl.cc6
-rw-r--r--src/components/application_manager/src/rpc_passing_handler.cc4
-rw-r--r--src/components/protocol_handler/src/protocol_handler_impl.cc4
-rw-r--r--src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h37
-rw-r--r--src/components/transport_manager/src/cloud/websocket_client_connection.cc84
-rw-r--r--src/components/transport_manager/src/transport_manager_impl.cc11
6 files changed, 94 insertions, 52 deletions
diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc
index 8a8671c167..efbd69bf12 100644
--- a/src/components/application_manager/src/application_manager_impl.cc
+++ b/src/components/application_manager/src/application_manager_impl.cc
@@ -1027,10 +1027,10 @@ void ApplicationManagerImpl::RefreshCloudAppInformation() {
const std::string app_icon_dir(settings_.app_icons_folder());
const std::string full_icon_path(app_icon_dir + "/" + policy_id);
if (!file_system::FileExists(full_icon_path)) {
- int icon_map_size = app_icon_map_.size();
AppIconInfo icon_info(endpoint, false);
- LOG4CXX_DEBUG(logger_,
- "Inserting cloud app into icon map: " << icon_map_size);
+ LOG4CXX_DEBUG(
+ logger_,
+ "Inserting cloud app into icon map: " << app_icon_map_.size());
app_icon_map_.insert(
std::pair<std::string, AppIconInfo>(policy_id, icon_info));
}
diff --git a/src/components/application_manager/src/rpc_passing_handler.cc b/src/components/application_manager/src/rpc_passing_handler.cc
index 3e90b86663..04d66ed207 100644
--- a/src/components/application_manager/src/rpc_passing_handler.cc
+++ b/src/components/application_manager/src/rpc_passing_handler.cc
@@ -331,10 +331,10 @@ void RPCPassingHandler::ClearCompletedTimers() {
LOG4CXX_DEBUG(logger_, "Clearing Completed Timers");
for (auto it = timeout_queue_.begin(); it != timeout_queue_.end();) {
TimerSPtr timer = it->first;
- uint32_t cid = it->second;
if (timer->is_completed()) {
LOG4CXX_DEBUG(logger_,
- "Removing completed timer for correlation id " << cid);
+ "Removing completed timer for correlation id "
+ << it->second);
it = timeout_queue_.erase(it);
} else {
++it;
diff --git a/src/components/protocol_handler/src/protocol_handler_impl.cc b/src/components/protocol_handler/src/protocol_handler_impl.cc
index d5837a0470..944d80d5d9 100644
--- a/src/components/protocol_handler/src/protocol_handler_impl.cc
+++ b/src/components/protocol_handler/src/protocol_handler_impl.cc
@@ -1710,13 +1710,12 @@ void ProtocolHandlerImpl::NotifySessionStarted(
start_session_frame_map_.erase(it);
}
- const ServiceType service_type = ServiceTypeFromByte(packet->service_type());
const uint8_t protocol_version = packet->protocol_version();
if (0 == context.new_session_id_) {
LOG4CXX_WARN(logger_,
"Refused by session_observer to create service "
- << static_cast<int32_t>(service_type) << " type.");
+ << packet->service_type() << " type.");
SendStartSessionNAck(context.connection_id_,
packet->session_id(),
protocol_version,
@@ -1781,6 +1780,7 @@ void ProtocolHandlerImpl::NotifySessionStarted(
}
#ifdef ENABLE_SECURITY
+ const ServiceType service_type = ServiceTypeFromByte(packet->service_type());
// for packet is encrypted and security plugin is enable
if (context.is_protected_ && security_manager_) {
const uint32_t connection_key = session_observer_.KeyFromPair(
diff --git a/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h b/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h
index aa608312a0..a726524af2 100644
--- a/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h
+++ b/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h
@@ -38,11 +38,13 @@
#include <boost/beast/core.hpp>
#include <boost/beast/websocket.hpp>
-#include <boost/beast/websocket/ssl.hpp>
#include <boost/asio/connect.hpp>
#include <boost/asio/ip/tcp.hpp>
-#include <boost/asio/ssl/stream.hpp>
#include <boost/asio/thread_pool.hpp>
+#ifdef ENABLE_SECURITY
+#include <boost/asio/ssl/stream.hpp>
+#include <boost/beast/websocket/ssl.hpp>
+#endif // ENABLE_SECURITY
#include <cstdlib>
#include <functional>
#include <iostream>
@@ -55,16 +57,21 @@
#include "utils/threads/message_loop_thread.h"
#include "utils/message_queue.h"
-using tcp = boost::asio::ip::tcp; // from <boost/asio/ip/tcp.hpp>
-namespace ssl = boost::asio::ssl; // from <boost/asio/ssl.hpp>
namespace websocket =
boost::beast::websocket; // from <boost/beast/websocket.hpp>
+
+using tcp = boost::asio::ip::tcp; // from <boost/asio/ip/tcp.hpp>
+typedef websocket::stream<tcp::socket> WS;
+
+#ifdef ENABLE_SECURITY
+namespace ssl = boost::asio::ssl; // from <boost/asio/ssl.hpp>
+typedef websocket::stream<ssl::stream<tcp::socket> > WSS;
+#endif // ENABLE_SECURITY
+
using ::utils::MessageQueue;
typedef std::queue<protocol_handler::RawMessagePtr> AsyncQueue;
typedef protocol_handler::RawMessagePtr Message;
-typedef websocket::stream<tcp::socket> WS;
-typedef websocket::stream<ssl::stream<tcp::socket> > WSS;
namespace transport_manager {
namespace transport_adapter {
@@ -106,12 +113,12 @@ class WebsocketClientConnection
TransportAdapter::Error Start();
/**
- * @brief Send data frame.
- *
- * @param message Smart pointer to the raw message.
- *
- * @return Error Information about possible reason of sending data failure.
- */
+ * @brief Send data frame.
+ *
+ * @param message Smart pointer to the raw message.
+ *
+ * @return Error Information about possible reason of sending data failure.
+ */
TransportAdapter::Error SendData(::protocol_handler::RawMessagePtr message);
/**
@@ -121,12 +128,14 @@ class WebsocketClientConnection
*/
TransportAdapter::Error Disconnect();
+#ifdef ENABLE_SECURITY
/**
* @brief Attempt to add provided certificate to the ssl::context
*
* @param cert Certificate string from policy table
*/
void AddCertificateAuthority(std::string cert, boost::system::error_code& ec);
+#endif // ENABLE_SECURITY
void Shutdown();
@@ -137,13 +146,15 @@ class WebsocketClientConnection
private:
TransportAdapterController* controller_;
boost::asio::io_context ioc_;
- ssl::context ctx_;
tcp::resolver resolver_;
boost::beast::flat_buffer buffer_;
std::string host_;
std::string text_;
WS ws_;
+#ifdef ENABLE_SECURITY
+ ssl::context ctx_;
WSS wss_;
+#endif // ENABLE_SECURITY
std::atomic_bool shutdown_;
diff --git a/src/components/transport_manager/src/cloud/websocket_client_connection.cc b/src/components/transport_manager/src/cloud/websocket_client_connection.cc
index 057e3d7208..bb654822c3 100644
--- a/src/components/transport_manager/src/cloud/websocket_client_connection.cc
+++ b/src/components/transport_manager/src/cloud/websocket_client_connection.cc
@@ -47,22 +47,26 @@ WebsocketClientConnection::WebsocketClientConnection(
const ApplicationHandle& app_handle,
TransportAdapterController* controller)
: controller_(controller)
- , ctx_(ssl::context::sslv23_client)
, resolver_(ioc_)
, ws_(ioc_)
+#ifdef ENABLE_SECURITY
+ , ctx_(ssl::context::sslv23_client)
, wss_(ioc_, ctx_)
+#endif // ENABLE_SECURITY
, shutdown_(false)
, thread_delegate_(new LoopThreadDelegate(&message_queue_, this))
, write_thread_(threads::CreateThread("WS Async Send", thread_delegate_))
, device_uid_(device_uid)
, app_handle_(app_handle)
- , io_pool_(1) {}
+ , io_pool_(1) {
+}
WebsocketClientConnection::~WebsocketClientConnection() {
ioc_.stop();
io_pool_.join();
}
+#ifdef ENABLE_SECURITY
void WebsocketClientConnection::AddCertificateAuthority(
const std::string cert, boost::system::error_code& ec) {
ctx_.add_certificate_authority(boost::asio::buffer(cert.data(), cert.size()),
@@ -73,6 +77,7 @@ void WebsocketClientConnection::AddCertificateAuthority(
wss_.next_layer().set_verify_mode(ssl::verify_peer);
}
+#endif // ENABLE_SECURITY
TransportAdapter::Error WebsocketClientConnection::Start() {
LOG4CXX_AUTO_TRACE(logger_);
@@ -106,12 +111,16 @@ TransportAdapter::Error WebsocketClientConnection::Start() {
}
// Make Connection to host IP Address over TCP
- if (cloud_properties.cloud_transport_type == "WSS") {
+ if (cloud_properties.cloud_transport_type == "WS") {
+ boost::asio::connect(ws_.next_layer(), results.begin(), results.end(), ec);
+ }
+#ifdef ENABLE_SECURITY
+ else if (cloud_properties.cloud_transport_type == "WSS") {
boost::asio::connect(
wss_.next_layer().next_layer(), results.begin(), results.end(), ec);
- } else {
- boost::asio::connect(ws_.next_layer(), results.begin(), results.end(), ec);
}
+#endif // ENABLE_SECURITY
+
if (ec) {
std::string str_err = "ErrorMessage: " + ec.message();
LOG4CXX_ERROR(logger_,
@@ -120,6 +129,7 @@ TransportAdapter::Error WebsocketClientConnection::Start() {
return TransportAdapter::FAIL;
}
+#ifdef ENABLE_SECURITY
if (cloud_properties.cloud_transport_type == "WSS") {
AddCertificateAuthority(cloud_properties.certificate, ec);
@@ -146,13 +156,17 @@ TransportAdapter::Error WebsocketClientConnection::Start() {
return TransportAdapter::FAIL;
}
}
+#endif // ENABLE_SECURITY
// Perform websocket handshake
- if (cloud_properties.cloud_transport_type == "WSS") {
- wss_.handshake(host, "/", ec);
- } else {
+ if (cloud_properties.cloud_transport_type == "WS") {
ws_.handshake(host, "/", ec);
}
+#ifdef ENABLE_SECURITY
+ else if (cloud_properties.cloud_transport_type == "WSS") {
+ wss_.handshake(host, "/", ec);
+ }
+#endif // ENABLE_SECURITY
if (ec) {
std::string str_err = "ErrorMessage: " + ec.message();
LOG4CXX_ERROR(logger_,
@@ -163,28 +177,34 @@ TransportAdapter::Error WebsocketClientConnection::Start() {
}
// Set the binary message write option
- if (cloud_properties.cloud_transport_type == "WSS") {
- wss_.binary(true);
- } else {
+ if (cloud_properties.cloud_transport_type == "WS") {
ws_.binary(true);
}
+#ifdef ENABLE_SECURITY
+ else if (cloud_properties.cloud_transport_type == "WSS") {
+ wss_.binary(true);
+ }
+#endif // ENABLE_SECURITY
write_thread_->start(threads::ThreadOptions());
controller_->ConnectDone(device_uid_, app_handle_);
// Start async read
- if (cloud_properties.cloud_transport_type == "WSS") {
- wss_.async_read(buffer_,
- std::bind(&WebsocketClientConnection::OnRead,
- this,
- std::placeholders::_1,
- std::placeholders::_2));
- } else {
+ if (cloud_properties.cloud_transport_type == "WS") {
ws_.async_read(buffer_,
std::bind(&WebsocketClientConnection::OnRead,
this,
std::placeholders::_1,
std::placeholders::_2));
}
+#ifdef ENABLE_SECURITY
+ else if (cloud_properties.cloud_transport_type == "WSS") {
+ wss_.async_read(buffer_,
+ std::bind(&WebsocketClientConnection::OnRead,
+ this,
+ std::placeholders::_1,
+ std::placeholders::_2));
+ }
+#endif // ENABLE_SECURITY
boost::asio::post(io_pool_, [&]() { ioc_.run(); });
@@ -205,19 +225,22 @@ void WebsocketClientConnection::Recv(boost::system::error_code ec) {
Shutdown();
return;
}
- if (cloud_properties.cloud_transport_type == "WSS") {
- wss_.async_read(buffer_,
- std::bind(&WebsocketClientConnection::OnRead,
- this,
- std::placeholders::_1,
- std::placeholders::_2));
- } else {
+ if (cloud_properties.cloud_transport_type == "WS") {
ws_.async_read(buffer_,
std::bind(&WebsocketClientConnection::OnRead,
this,
std::placeholders::_1,
std::placeholders::_2));
}
+#ifdef ENABLE_SECURITY
+ else if (cloud_properties.cloud_transport_type == "WSS") {
+ wss_.async_read(buffer_,
+ std::bind(&WebsocketClientConnection::OnRead,
+ this,
+ std::placeholders::_1,
+ std::placeholders::_2));
+ }
+#endif // ENABLE_SECURITY
}
void WebsocketClientConnection::OnRead(boost::system::error_code ec,
@@ -303,13 +326,16 @@ void WebsocketClientConnection::LoopThreadDelegate::DrainQueue() {
message_queue_.pop(message_ptr);
if (!shutdown_) {
boost::system::error_code ec;
- if (handler_.cloud_properties.cloud_transport_type == "WSS") {
- handler_.wss_.write(
- boost::asio::buffer(message_ptr->data(), message_ptr->data_size()));
- } else {
+ if (handler_.cloud_properties.cloud_transport_type == "WS") {
handler_.ws_.write(
boost::asio::buffer(message_ptr->data(), message_ptr->data_size()));
}
+#ifdef ENABLE_SECURITY
+ else if (handler_.cloud_properties.cloud_transport_type == "WSS") {
+ handler_.wss_.write(
+ boost::asio::buffer(message_ptr->data(), message_ptr->data_size()));
+ }
+#endif // ENABLE_SECURITY
if (ec) {
LOG4CXX_ERROR(logger_, "Error writing to websocket");
handler_.controller_->DataSendFailed(handler_.device_uid_,
diff --git a/src/components/transport_manager/src/transport_manager_impl.cc b/src/components/transport_manager/src/transport_manager_impl.cc
index d197882120..2b23fd73b2 100644
--- a/src/components/transport_manager/src/transport_manager_impl.cc
+++ b/src/components/transport_manager/src/transport_manager_impl.cc
@@ -134,10 +134,15 @@ void TransportManagerImpl::AddCloudDevice(
const transport_manager::transport_adapter::CloudAppProperties
cloud_properties) {
transport_adapter::DeviceType type = transport_adapter::DeviceType::UNKNOWN;
- if ((cloud_properties.cloud_transport_type == "WS") ||
- (cloud_properties.cloud_transport_type == "WSS")) {
+ if (cloud_properties.cloud_transport_type == "WS") {
type = transport_adapter::DeviceType::CLOUD_WEBSOCKET;
- } else {
+ }
+#ifdef ENABLE_SECURITY
+ else if (cloud_properties.cloud_transport_type == "WSS") {
+ type = transport_adapter::DeviceType::CLOUD_WEBSOCKET;
+ }
+#endif // ENABLE_SECURITY
+ else {
return;
}