fsfw/osal/windows/TmTcWinUdpBridge.h

49 lines
1.4 KiB
C
Raw Normal View History

2020-09-06 15:46:49 +02:00
#ifndef FSFW_OSAL_WINDOWS_TMTCWINUDPBRIDGE_H_
#define FSFW_OSAL_WINDOWS_TMTCWINUDPBRIDGE_H_
#include "../../tmtcservices/TmTcBridge.h"
#include <winsock2.h>
2021-03-08 23:00:53 +01:00
//! Debugging preprocessor define.
#define FSFW_UDP_SEND_WIRETAPPING_ENABLED 0
2020-09-06 15:46:49 +02:00
class TmTcWinUdpBridge: public TmTcBridge {
friend class TcWinUdpPollingTask;
public:
2021-03-08 23:00:53 +01:00
/* The ports chosen here should not be used by any other process. */
2021-03-12 00:34:30 +01:00
static const std::string DEFAULT_UDP_SERVER_PORT;
static const std::string DEFAULT_UDP_CLIENT_PORT;
2020-09-06 15:46:49 +02:00
TmTcWinUdpBridge(object_id_t objectId, object_id_t tcDestination,
object_id_t tmStoreId, object_id_t tcStoreId,
2021-03-12 00:34:30 +01:00
std::string udpServerPort = "", std::string udpClientPort = "");
2020-09-06 15:46:49 +02:00
virtual~ TmTcWinUdpBridge();
2021-03-12 00:34:30 +01:00
ReturnValue_t initialize() override;
2021-03-12 01:40:58 +01:00
void checkAndSetClientAddress(sockaddr_in& clientAddress);
2020-09-06 15:46:49 +02:00
protected:
virtual ReturnValue_t sendTm(const uint8_t * data, size_t dataLen) override;
private:
SOCKET serverSocket = 0;
2021-03-12 00:34:30 +01:00
std::string udpServerPort;
std::string udpClientPort;
2020-09-06 15:46:49 +02:00
const int serverSocketOptions = 0;
struct sockaddr_in clientAddress;
int clientAddressLen = 0;
struct sockaddr_in serverAddress;
int serverAddressLen = 0;
2021-03-12 02:15:21 +01:00
//! Access to the client address is mutex protected as it is set by another task.
2020-09-06 15:46:49 +02:00
MutexIF* mutex;
};
#endif /* FSFW_OSAL_HOST_TMTCWINUDPBRIDGE_H_ */