fsfw/osal/linux/TmTcUnixUdpBridge.h

54 lines
1.6 KiB
C
Raw Normal View History

2020-07-13 13:33:12 +02:00
#ifndef FRAMEWORK_OSAL_LINUX_TMTCUNIXUDPBRIDGE_H_
#define FRAMEWORK_OSAL_LINUX_TMTCUNIXUDPBRIDGE_H_
2020-08-28 17:14:20 +02:00
#include "../../tmtcservices/AcceptsTelecommandsIF.h"
#include "../../tmtcservices/TmTcBridge.h"
2020-07-13 13:33:12 +02:00
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/udp.h>
class TmTcUnixUdpBridge:
public TmTcBridge {
friend class TcUnixUdpPollingTask;
2020-07-13 13:33:12 +02:00
public:
/* The ports chosen here should not be used by any other process.
2021-03-12 17:15:53 +01:00
List of used ports on Linux: /etc/services */
static const std::string DEFAULT_UDP_SERVER_PORT;
TmTcUnixUdpBridge(object_id_t objectId, object_id_t tcDestination,
object_id_t tmStoreId, object_id_t tcStoreId,
std::string serverPort = "");
virtual~ TmTcUnixUdpBridge();
2020-07-13 13:33:12 +02:00
/**
* Set properties of internal mutex.
*/
void setMutexProperties(MutexIF::TimeoutType timeoutType, dur_millis_t timeoutMs);
2020-07-13 13:33:12 +02:00
ReturnValue_t initialize() override;
2021-03-12 18:12:38 +01:00
void checkAndSetClientAddress(sockaddr_in& clientAddress);
2021-03-12 17:15:53 +01:00
void setClientAddressToAny(bool ipAddrAnySet);
2020-07-13 13:33:12 +02:00
protected:
virtual ReturnValue_t sendTm(const uint8_t * data, size_t dataLen) override;
2020-07-13 13:33:12 +02:00
private:
int serverSocket = 0;
std::string udpServerPort;
2020-07-13 13:33:12 +02:00
struct sockaddr_in clientAddress;
socklen_t clientAddressLen = 0;
2020-07-13 13:33:12 +02:00
bool ipAddrAnySet = false;
2020-11-07 20:30:42 +01:00
//! Access to the client address is mutex protected as it is set by another task.
MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING;
dur_millis_t mutexTimeoutMs = 20;
MutexIF* mutex;
2020-07-13 13:33:12 +02:00
};
#endif /* FRAMEWORK_OSAL_LINUX_TMTCUNIXUDPBRIDGE_H_ */