wiretapping in runtime config now

This commit is contained in:
Robin Müller 2021-09-28 15:09:56 +02:00
parent 09299802f0
commit e536918804
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
2 changed files with 19 additions and 10 deletions

View File

@ -5,12 +5,13 @@
#include "TcpTmTcBridge.h"
#include "tcpipHelpers.h"
#include "fsfw/tmtcservices/SpacePacketParser.h"
#include "fsfw/tasks/TaskFactory.h"
#include "fsfw/globalfunctions/arrayprinter.h"
#include "fsfw/container/SharedRingBuffer.h"
#include "fsfw/ipc/MessageQueueSenderIF.h"
#include "fsfw/ipc/MutexGuard.h"
#include "fsfw/objectmanager/ObjectManager.h"
#include "fsfw/serviceinterface/ServiceInterface.h"
#include "fsfw/tmtcservices/TmTcMessage.h"
@ -20,11 +21,6 @@
#elif defined(PLATFORM_UNIX)
#include <netdb.h>
#endif
#include <chrono>
#ifndef FSFW_TCP_RECV_WIRETAPPING_ENABLED
#define FSFW_TCP_RECV_WIRETAPPING_ENABLED 0
#endif
const std::string TcpTmTcServer::DEFAULT_SERVER_PORT = tcpip::DEFAULT_SERVER_PORT;
@ -202,9 +198,11 @@ void TcpTmTcServer::handleServerOperation(socket_t& connSocket) {
}
ReturnValue_t TcpTmTcServer::handleTcReception(uint8_t* spacePacket, size_t packetSize) {
#if FSFW_TCP_RECV_WIRETAPPING_ENABLED == 1
arrayprinter::print(receptionBuffer.data(), bytesRead);
#endif
if(wiretappingEnabled) {
sif::info << "Received TC:" << std::endl;
arrayprinter::print(spacePacket, packetSize);
}
if(spacePacket == nullptr or packetSize == 0) {
return HasReturnvaluesIF::RETURN_FAILED;
}
@ -268,6 +266,10 @@ ReturnValue_t TcpTmTcServer::handleTmSending(socket_t connSocket, bool& tmSent)
if(result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
if(wiretappingEnabled) {
sif::info << "Sending TM:" << std::endl;
arrayprinter::print(storeAccessor.data(), storeAccessor.size());
}
int retval = send(connSocket,
reinterpret_cast<const char*>(storeAccessor.data()),
storeAccessor.size(),
@ -346,6 +348,10 @@ ReturnValue_t TcpTmTcServer::handleTcRingBufferData(size_t availableReadData) {
return status;
}
void TcpTmTcServer::enableWiretapping(bool enable) {
this->wiretappingEnabled = enable;
}
void TcpTmTcServer::handleSocketError(ConstStorageAccessor &accessor) {
// Don't delete data
accessor.release();

View File

@ -1,7 +1,6 @@
#ifndef FSFW_OSAL_COMMON_TCP_TMTC_SERVER_H_
#define FSFW_OSAL_COMMON_TCP_TMTC_SERVER_H_
#include <fsfw/tmtcservices/SpacePacketParser.h>
#include "TcpIpBase.h"
#include "fsfw/platform.h"
@ -22,6 +21,7 @@
#include <vector>
class TcpTmTcBridge;
class SpacePacketParser;
/**
* @brief TCP server implementation
@ -91,6 +91,8 @@ public:
ReceptionModes receptionMode = ReceptionModes::SPACE_PACKETS);
virtual~ TcpTmTcServer();
void enableWiretapping(bool enable);
/**
* Get a handle to the TCP configuration struct, which can be used to configure TCP
* properties
@ -113,6 +115,7 @@ private:
//! TMTC bridge is cached.
object_id_t tmtcBridgeId = objects::NO_OBJECT;
TcpTmTcBridge* tmtcBridge = nullptr;
bool wiretappingEnabled = false;
ReceptionModes receptionMode;
TcpConfig tcpConfig;