return "OSA_LIB";
case MODULE_CLIENT_TA:
return "CLIENT_TA";
+ case MODULE_DEBUGPROXY:
+ return "DEBUGPROXY";
default:
return "TA_SDK";
}
MODULE_SSF_LIB = 0x20,
MODULE_OSA_LIB = 0x40,
MODULE_CLIENT_TA = 0x80,
+ MODULE_DEBUGPROXY = 0x100,
MODULE_ALL = 0xFFFFFFF,
} ModuleLevel;
# @brief CMakeLists for tef-simulator daemon debugproxy
#
+PKG_CHECK_MODULES(DEBUGPROXY_DEPS REQUIRED
+ dlog
+)
+
SET(DEBUGPROXY_SOURCES
${DEBUGPROXY_PATH}/src/AsyncEvent.cpp
${DEBUGPROXY_PATH}/src/DebugproxySocket.cpp
INCLUDE_DIRECTORIES(
${DEBUGPROXY_PATH}/inc
${TEF_SIMULATOR_INCLUDE_PATH}/include
+ ${LOG_PATH}
)
+LINK_DIRECTORIES(
+ ${LOG_PATH}
+)
+
TARGET_LINK_LIBRARIES(${TARGET_TEF_SIMULATOR_DEBUGPROXY}
boost_system boost_signals boost_coroutine
+ ${TARGET_TEF_SIMULATOR_LOG}
+ ${DEBUGPROXY_DEPS_LIBRARIES}
)
INSTALL(TARGETS ${TARGET_TEF_SIMULATOR_DEBUGPROXY} DESTINATION ${BIN_DIR})
#define __FORWARDING_H__
#include <memory>
+#include <log.h>
#include <boost/asio.hpp>
#include "AsyncEvent.h"
*to, boost::asio::buffer(data, len), yield);
}
} catch (std::exception &e) {
- /* TODO - logging */
+ LOGD(MODULE_DEBUGPROXY, "Stopped forwarding sockets: %s", e.what());
connection_end->set();
}
}
#include <boost/system/system_error.hpp>
#include <config.h>
+#include <log.h>
#include "common.h"
#include "DebugproxySocket.h"
void DebugproxySocket::start_accept()
{
+ LOGD(MODULE_DEBUGPROXY, "Listening on %s", DEBUGPROXY_SOCK_PATH);
boost::asio::spawn(this->io, boost::bind(&DebugproxySocket::async_accept,
this, _1));
}
return this->handle_connection(sock, yield);
});
}
- } catch (boost::system::system_error &e) {
- /* TODO - log */
+ } catch (std::exception &e) {
+ LOGE(MODULE_DEBUGPROXY, "Failed to accept new connection: %s", e.what());
this->quit_event->set();
}
}
try {
ProxySession session(local_sock, this->quit_event);
session.async_session(yield);
- } catch (boost::system::system_error &e) {
- /* TODO - log */
+ } catch (std::exception &e) {
+ LOGE(MODULE_DEBUGPROXY, "Forwarding session ended: %s", e.what());
}
}
#include <memory>
#include <boost/bind.hpp>
#include <boost/asio/deadline_timer.hpp>
+
+#include <log.h>
#include "ProxySession.h"
#include "forwarding.h"
#include "common.h"
uint32_t target_port[1];
boost::asio::async_read(
*this->local_socket, boost::asio::buffer(target_port), yield);
+ LOGD(MODULE_DEBUGPROXY, "(%p) Received port number: %d", this, target_port[0]);
return target_port[0];
}
if (!acceptor)
return;
acceptor->cancel();
+ LOGI(MODULE_DEBUGPROXY, "(%p) Timed out waiting for a port connection", this);
};
boost::asio::spawn(this->io(), stop_at_timeout);
port_acceptor->async_accept(*this->port_socket, yield);
std::shared_ptr<AsyncEvent> ProxySession::start_forwarding()
{
+ LOGD(MODULE_DEBUGPROXY, "(%p) Two-way forwarding started", this);
auto connection_lost_event = std::make_shared<AsyncEvent>(this->io());
boost::asio::spawn(
this->io(),
void ProxySession::async_session(yield_ctx yield)
{
+ LOGD(MODULE_DEBUGPROXY, "Started forwarding session: %p", this);
uint32_t target_port = this->read_forwarded_port(yield);
this->setup_port_socket(target_port, yield);
auto connection_lost_event = this->start_forwarding();
connection_lost_event},
this->io());
events.wait_on_any(yield);
+ LOGD(MODULE_DEBUGPROXY, "(%p) Received session end event", this);
}
template <typename T>