summaryrefslogtreecommitdiff
path: root/src/components/transport_manager/include/transport_manager/tcp
diff options
context:
space:
mode:
authorJustin Dickow <jjdickow@gmail.com>2014-10-20 17:44:41 -0400
committerJustin Dickow <jjdickow@gmail.com>2014-10-20 17:44:41 -0400
commit34e7256493ff0e6594029b9857d7e2aa31f5dbeb (patch)
tree367306b507c52d3af211533810adbc22004e0192 /src/components/transport_manager/include/transport_manager/tcp
parent2eef966e9b5fd4d94dd98820095eb765e200c64b (diff)
downloadsdl_core-34e7256493ff0e6594029b9857d7e2aa31f5dbeb.tar.gz
SDL 3.8!
Signed-off-by: Justin Dickow <jjdickow@gmail.com>
Diffstat (limited to 'src/components/transport_manager/include/transport_manager/tcp')
-rw-r--r--src/components/transport_manager/include/transport_manager/tcp/dnssd_service_browser.h133
-rw-r--r--src/components/transport_manager/include/transport_manager/tcp/tcp_client_listener.h119
-rw-r--r--src/components/transport_manager/include/transport_manager/tcp/tcp_connection_factory.h99
-rw-r--r--src/components/transport_manager/include/transport_manager/tcp/tcp_device.h148
-rw-r--r--src/components/transport_manager/include/transport_manager/tcp/tcp_socket_connection.h112
-rw-r--r--src/components/transport_manager/include/transport_manager/tcp/tcp_transport_adapter.h83
6 files changed, 694 insertions, 0 deletions
diff --git a/src/components/transport_manager/include/transport_manager/tcp/dnssd_service_browser.h b/src/components/transport_manager/include/transport_manager/tcp/dnssd_service_browser.h
new file mode 100644
index 0000000000..cd319ca543
--- /dev/null
+++ b/src/components/transport_manager/include/transport_manager/tcp/dnssd_service_browser.h
@@ -0,0 +1,133 @@
+/**
+ * \file dnssd_service_browser.h
+ * \brief DnssdServiceBrowser class header file.
+ *
+ * Copyright (c) 2013, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_TCP_DNSSD_SERVICE_BROWSER_H_
+#define SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_TCP_DNSSD_SERVICE_BROWSER_H_
+
+#include <string>
+#include <vector>
+#include <pthread.h>
+#include <avahi-client/client.h>
+#include <avahi-client/lookup.h>
+#include <avahi-common/error.h>
+#include <avahi-common/thread-watch.h>
+
+#include "transport_manager/transport_adapter/device_scanner.h"
+#include "transport_manager/transport_adapter/transport_adapter.h"
+
+namespace transport_manager {
+
+namespace transport_adapter {
+
+struct DnssdServiceRecord {
+ AvahiIfIndex interface;
+ AvahiProtocol protocol;
+ std::string domain_name;
+ std::string host_name;
+ std::string name;
+ std::string type;
+ uint16_t port;
+ uint32_t addr;
+};
+
+#define DNSSD_DEFAULT_SERVICE_TYPE "_ford-sdlapp._tcp"
+
+/**
+ * @brief DNS service discovery class.
+ */
+class DnssdServiceBrowser : public DeviceScanner {
+ public:
+ /**
+ * @brief Constructor.
+ *
+ * @param controller Pointer to the device adapter controller.
+ */
+ DnssdServiceBrowser(class TransportAdapterController* controller);
+ virtual ~DnssdServiceBrowser();
+ protected:
+ virtual TransportAdapter::Error Init();
+ virtual TransportAdapter::Error Scan();
+ virtual void Terminate();
+ virtual bool IsInitialised() const;
+ private:
+ TransportAdapter::Error CreateAvahiClientAndBrowser();
+ void AddService(AvahiIfIndex interface, AvahiProtocol protocol,
+ const char *name, const char *type, const char *domain);
+ void RemoveService(AvahiIfIndex interface, AvahiProtocol protocol,
+ const char *name, const char *type, const char *domain);
+
+ void OnClientConnected();
+ void OnClientFailure();
+
+ DeviceVector PrepareDeviceVector() const;
+
+ void ServiceResolved(const DnssdServiceRecord& service_record);
+ void ServiceResolveFailed(const DnssdServiceRecord& service_record);
+
+ friend void AvahiClientCallback(AvahiClient *avahi_client,
+ AvahiClientState avahi_client_state,
+ void* data);
+ friend void AvahiServiceBrowserCallback(
+ AvahiServiceBrowser *avahi_service_browser, AvahiIfIndex interface,
+ AvahiProtocol protocol, AvahiBrowserEvent event, const char *name,
+ const char *type, const char *domain, AvahiLookupResultFlags flags,
+ void* data);
+
+ friend void AvahiServiceResolverCallback(
+ AvahiServiceResolver* avahi_service_resolver, AvahiIfIndex interface,
+ AvahiProtocol protocol, AvahiResolverEvent event, const char* name,
+ const char* type, const char* domain, const char* host_name,
+ const AvahiAddress* avahi_address, uint16_t port, AvahiStringList* txt,
+ AvahiLookupResultFlags flags, void *data);
+
+ TransportAdapterController* controller_;
+
+ AvahiServiceBrowser* avahi_service_browser_;
+ AvahiThreadedPoll* avahi_threaded_poll_;
+ AvahiClient* avahi_client_;
+
+ typedef std::vector<DnssdServiceRecord> ServiceRecords;
+ ServiceRecords service_records_;
+
+ pthread_mutex_t mutex_;
+
+ bool initialised_;
+}
+;
+
+} // namespace
+} // namespace
+
+#endif // SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_DNSSD_SERVICE_BROWSER
diff --git a/src/components/transport_manager/include/transport_manager/tcp/tcp_client_listener.h b/src/components/transport_manager/include/transport_manager/tcp/tcp_client_listener.h
new file mode 100644
index 0000000000..090f46d001
--- /dev/null
+++ b/src/components/transport_manager/include/transport_manager/tcp/tcp_client_listener.h
@@ -0,0 +1,119 @@
+/**
+ * \file tcp_client_listener.h
+ * \brief TcpClientListener class header file.
+ *
+ * Copyright (c) 2013, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_TCP_TCP_CLIENT_LISTENER_H_
+#define SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_TCP_TCP_CLIENT_LISTENER_H_
+
+#include "transport_manager/transport_adapter/client_connection_listener.h"
+
+namespace transport_manager {
+namespace transport_adapter {
+
+class TransportAdapterController;
+
+/**
+ * @brief Listener of device adapter that use TCP transport.
+ */
+class TcpClientListener : public ClientConnectionListener {
+ public:
+ /**
+ * @breaf Constructor.
+ *
+ * @param controller Pointer to the device adapter controller.
+ * @param port Port No.
+ * @param enable_keepalive If true enables TCP keepalive on accepted
+ *connections
+ */
+ TcpClientListener(TransportAdapterController* controller, uint16_t port,
+ bool enable_keepalive);
+
+ /**
+ * @brief Start TCP client listener thread.
+ */
+ void Thread();
+ protected:
+
+ /**
+ * @brief Destructor.
+ */
+ virtual ~TcpClientListener();
+
+ /**
+ * @brief Run TCP client listener.
+ *
+ * @return Error information about possible reason of starting TCP listener listener failure.
+ */
+ virtual TransportAdapter::Error Init();
+
+ /**
+ * @brief Stop TCP client listener.
+ */
+ virtual void Terminate();
+
+ /**
+ * @brief Check initialization.
+ *
+ * @return True if initialized.
+ * @return False if not initialized.
+ */
+ virtual bool IsInitialised() const;
+
+ /**
+ * @brief
+ *
+ * @return Error information about possible reason of failure.
+ */
+ virtual TransportAdapter::Error StartListening();
+
+ /**
+ * @brief Terminate TCP client listener thread.
+ */
+ virtual TransportAdapter::Error StopListening();
+ private:
+ const uint16_t port_;
+ const bool enable_keepalive_;
+ TransportAdapterController* controller_;
+ // TODO(Eamakhov): change to threads::Thread usage
+ pthread_t thread_;
+ int socket_;
+ bool thread_started_;
+ bool shutdown_requested_;
+ bool thread_stop_requested_;
+};
+
+} // namespace transport_adapter
+} // namespace transport_manager
+
+#endif /* TCP_CLIENT_LISTENER_H_ */
diff --git a/src/components/transport_manager/include/transport_manager/tcp/tcp_connection_factory.h b/src/components/transport_manager/include/transport_manager/tcp/tcp_connection_factory.h
new file mode 100644
index 0000000000..fba85aa601
--- /dev/null
+++ b/src/components/transport_manager/include/transport_manager/tcp/tcp_connection_factory.h
@@ -0,0 +1,99 @@
+/**
+ * \file tcp_connection_factory.h
+ * \brief TcpConnectionFactory class header file.
+ *
+ * Copyright (c) 2013, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_TCP_TCP_CONNECTION_FACTORY_H_
+#define SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_TCP_TCP_CONNECTION_FACTORY_H_
+
+#include "transport_manager/transport_adapter/server_connection_factory.h"
+#include "transport_manager/transport_adapter/transport_adapter_controller.h"
+
+namespace transport_manager {
+namespace transport_adapter {
+
+/**
+ * @brief Create connections.
+ */
+class TcpConnectionFactory : public ServerConnectionFactory {
+ public:
+
+ /**
+ * @brief Constructor.
+ *
+ * @param controller Pointer to the device adapter controller.
+ */
+ TcpConnectionFactory(TransportAdapterController* controller);
+ protected:
+
+ /**
+ * @brief Start TCP connection factory.
+ */
+ virtual TransportAdapter::Error Init();
+
+ /**
+ * @brief Constructor.
+ *
+ * @param device_uid device unique identifier.
+ * @param app_handle Handle of application.
+ *
+ * @return Error information about possible reason of failure.
+ */
+ virtual TransportAdapter::Error CreateConnection(const DeviceUID& device_uid,
+ const ApplicationHandle& app_handle);
+
+ /**
+ * @brief
+ */
+ virtual void Terminate();
+
+ /**
+ * @brief Check for initialization.
+ *
+ * @return true - initialized.
+ * false - not initialized.
+ */
+ virtual bool IsInitialised() const;
+
+ /**
+ * @brief Destructor.
+ */
+ virtual ~TcpConnectionFactory();
+ private:
+ TransportAdapterController* controller_;
+};
+
+} // namespace transport_adapter
+} // namespace transport_manager
+
+#endif // SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_TCP_CONNECTION_FACTORY_H_
diff --git a/src/components/transport_manager/include/transport_manager/tcp/tcp_device.h b/src/components/transport_manager/include/transport_manager/tcp/tcp_device.h
new file mode 100644
index 0000000000..08821ab3c4
--- /dev/null
+++ b/src/components/transport_manager/include/transport_manager/tcp/tcp_device.h
@@ -0,0 +1,148 @@
+/**
+ * \file tcp_device.h
+ * \brief TcpDevice class header file.
+ *
+ * Copyright (c) 2013, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_TCP_TCP_DEVICE_H_
+#define SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_TCP_TCP_DEVICE_H_
+
+#include "transport_manager/transport_adapter/device.h"
+
+#include <map>
+#include <memory.h>
+#include <signal.h>
+#include <errno.h>
+#include <arpa/inet.h>
+#include <netinet/in.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+
+namespace transport_manager {
+namespace transport_adapter {
+
+/**
+ * @brief Information about device that use TCP transport.
+ */
+class TcpDevice : public Device {
+ public:
+ /**
+ * @brief Constructor.
+ *
+ * @param in_addr Address.
+ * @param name Device Name.
+ **/
+ TcpDevice(const in_addr_t& in_addr, const std::string& name);
+
+ virtual ~TcpDevice();
+
+ /**
+ * @brief Compare devices.
+ *
+ * @param other Device to compare with.
+ *
+ * @return True if devices are equal, false otherwise.
+ **/
+ virtual bool IsSameAs(const Device* other) const;
+
+ /**
+ * @brief Update list of applications available on device.
+ *
+ * @return Container with list of applications.
+ */
+ virtual ApplicationList GetApplicationList() const;
+
+ /**
+ * @brief Add an application to the container of applications.
+ *
+ * @param socket Value of socket.
+ */
+ ApplicationHandle AddIncomingApplication(int socket_fd);
+
+ /**
+ * @brief Add application that was discovered before.
+ *
+ * @param Port No.
+ */
+ ApplicationHandle AddDiscoveredApplication(int port);
+
+ /**
+ * @brief Remove application from the container of applications.
+ *
+ * @param app_handle Handle of application.
+ */
+ void RemoveApplication(const ApplicationHandle app_handle);
+
+ /**
+ * @brief Return application's socket value.
+ *
+ * @param app_handle Handle of application.
+ *
+ * @return Application's socket value.
+ */
+ int GetApplicationSocket(const ApplicationHandle app_handle) const;
+
+ /**
+ * @brief Return application's port No.
+ *
+ * @param app_handle Handle of application.
+ *
+ * @return Application's port No.
+ */
+ int GetApplicationPort(const ApplicationHandle app_handle) const;
+
+ /**
+ * @brief Return address.
+ *
+ * @return Address.
+ */
+ in_addr_t in_addr() const {
+ return in_addr_;
+ }
+
+ private:
+ struct Application {
+ bool incoming;
+ int socket;
+ uint16_t port;
+ };
+ std::map<ApplicationHandle, Application> applications_;
+ mutable pthread_mutex_t applications_mutex_;
+ const in_addr_t in_addr_;
+ const std::string name_;
+ ApplicationHandle last_handle_;
+};
+
+} // namespace transport_adapter
+} // namespace transport_manager
+
+#endif /* TCP_DEVICE_H_ */
diff --git a/src/components/transport_manager/include/transport_manager/tcp/tcp_socket_connection.h b/src/components/transport_manager/include/transport_manager/tcp/tcp_socket_connection.h
new file mode 100644
index 0000000000..8fe7b8e837
--- /dev/null
+++ b/src/components/transport_manager/include/transport_manager/tcp/tcp_socket_connection.h
@@ -0,0 +1,112 @@
+/**
+ * \file tcp_socket_connection.h
+ * \brief TcpSocketConnection class header file.
+ *
+ * Copyright (c) 2013, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_TCP_TCP_SOCKET_CONNECTION_H_
+#define SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_TCP_TCP_SOCKET_CONNECTION_H_
+
+#include <arpa/inet.h>
+#include <netinet/in.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+
+#include "transport_manager/transport_adapter/threaded_socket_connection.h"
+
+namespace transport_manager {
+namespace transport_adapter {
+
+class TransportAdapterController;
+
+/**
+ * @brief Class responsible for communication over TCP sockets.
+ */
+class TcpSocketConnection : public ThreadedSocketConnection {
+ public:
+
+ /**
+ * @brief Constructor.
+ *
+ * @param device_uid Device unique identifier.
+ * @param app_handle Handle of application.
+ * @param controller Pointer to the TCP device adapter controller.
+ */
+ TcpSocketConnection(const DeviceUID& device_uid,
+ const ApplicationHandle& app_handle,
+ TransportAdapterController* controller);
+
+ /**
+ * @brief Destructor.
+ */
+ virtual ~TcpSocketConnection();
+ protected:
+
+ /**
+ * @brief
+ */
+ virtual bool Establish(ConnectError** error);
+};
+
+/**
+ * @brief Class responsible for communication over sockets that originated by server.
+ */
+class TcpServerOiginatedSocketConnection : public ThreadedSocketConnection {
+ public:
+
+ /**
+ * @brief Constructor.
+ *
+ * @param device_uid Device unique identifier.
+ * @param app_handle Handle of application.
+ * @param controller Pointer to the device adapter controller.
+ */
+ TcpServerOiginatedSocketConnection(const DeviceUID& device_uid,
+ const ApplicationHandle& app_handle,
+ TransportAdapterController* controller);
+
+ /**
+ * @brief Destructor.
+ */
+ virtual ~TcpServerOiginatedSocketConnection();
+ protected:
+
+ /**
+ * @brief
+ */
+ virtual bool Establish(ConnectError** error);
+};
+
+} // namespace transport_adapter
+} // namespace transport_manager
+
+#endif // SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_TCP_SOCKET_CONNECTION_H_
diff --git a/src/components/transport_manager/include/transport_manager/tcp/tcp_transport_adapter.h b/src/components/transport_manager/include/transport_manager/tcp/tcp_transport_adapter.h
new file mode 100644
index 0000000000..1319c40eeb
--- /dev/null
+++ b/src/components/transport_manager/include/transport_manager/tcp/tcp_transport_adapter.h
@@ -0,0 +1,83 @@
+/**
+ * \file tcp_transport_adapter.h
+ * \brief TcpTransportAdapter class header file.
+ *
+ * Copyright (c) 2013, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_TCP_TCP_ADAPTER_H_
+#define SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_TCP_TCP_ADAPTER_H_
+
+#include "transport_manager/transport_adapter/transport_adapter_impl.h"
+
+namespace transport_manager {
+namespace transport_adapter {
+
+/**
+ * @brief Transport adapter that use TCP transport.
+ */
+class TcpTransportAdapter : public TransportAdapterImpl {
+ public:
+ /**
+ * @brief Constructor.
+ */
+ explicit TcpTransportAdapter(uint16_t port);
+
+ /**
+ * @brief Destructor.
+ */
+ virtual ~TcpTransportAdapter();
+ protected:
+
+ /**
+ * @brief Return type of device.
+ *
+ * @return String with device type.
+ */
+ virtual DeviceType GetDeviceType() const;
+
+ /**
+ * @brief Store adapter state in last state singleton
+ */
+ virtual void Store() const;
+
+ /**
+ * @brief Restore adapter state from last state singleton
+ *
+ * @return True on success false otherwise
+ */
+ virtual bool Restore();
+};
+
+} // namespace transport_adapter
+} // namespace transport_manager
+
+#endif // SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_TCP_ADAPTER