2020-07-04 00:51:49 +02:00
|
|
|
#include <framework/osal/linux/TmTcUnixUdpBridge.h>
|
|
|
|
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
|
|
|
|
|
|
|
TmTcUnixUdpBridge::TmTcUnixUdpBridge(object_id_t objectId,
|
2020-07-04 23:52:44 +02:00
|
|
|
object_id_t ccsdsPacketDistributor, uint16_t serverPort,
|
|
|
|
uint16_t clientPort):
|
2020-07-04 00:51:49 +02:00
|
|
|
TmTcBridge(objectId, ccsdsPacketDistributor) {
|
2020-07-04 23:52:44 +02:00
|
|
|
uint16_t setServerPort = DEFAULT_UDP_SERVER_PORT;
|
|
|
|
if(serverPort != 0xFFFF) {
|
|
|
|
setServerPort = serverPort;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint16_t setClientPort = DEFAULT_UDP_CLIENT_PORT;
|
|
|
|
if(clientPort != 0xFFFF) {
|
|
|
|
setClientPort = clientPort;
|
|
|
|
}
|
|
|
|
|
2020-07-04 00:51:49 +02:00
|
|
|
serverSocket = socket(AF_INET, SOCK_DGRAM, 0);
|
|
|
|
if(socket < 0) {
|
|
|
|
sif::error << "TmTcUnixUdpBridge::TmTcUnixUdpBridge: Could not open"
|
|
|
|
" UDP socket!" << std::endl;
|
|
|
|
// check errno here.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
serverAddress.sin_family = AF_INET;
|
|
|
|
serverAddress.sin_addr.s_addr = htonl(INADDR_ANY);
|
2020-07-04 23:52:44 +02:00
|
|
|
serverAddress.sin_port = htons(setServerPort);
|
2020-07-04 00:51:49 +02:00
|
|
|
setsockopt(serverSocket, SOL_SOCKET, SO_REUSEADDR, &serverSocketOptions,
|
|
|
|
sizeof(serverSocketOptions));
|
|
|
|
|
|
|
|
int result = bind(serverSocket,
|
|
|
|
reinterpret_cast<struct sockaddr*>(&serverAddress),
|
|
|
|
sizeof(serverAddress));
|
|
|
|
if(result== -1) {
|
|
|
|
sif::error << "TmTcUnixUdpBridge::TmTcUnixUdpBridge: Could not bind "
|
2020-07-04 23:52:44 +02:00
|
|
|
"local port " << setServerPort << " to server socket!"
|
2020-07-04 00:51:49 +02:00
|
|
|
<< std::endl;
|
|
|
|
// check errno here.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
TmTcUnixUdpBridge::~TmTcUnixUdpBridge() {
|
|
|
|
}
|
2020-07-04 23:52:44 +02:00
|
|
|
|
|
|
|
ReturnValue_t TmTcUnixUdpBridge::handleTc() {
|
|
|
|
return HasReturnvaluesIF::RETURN_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t TmTcUnixUdpBridge::receiveTc(uint8_t **recvBuffer, size_t *size) {
|
|
|
|
return HasReturnvaluesIF::RETURN_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t TmTcUnixUdpBridge::sendTm(const uint8_t *data, size_t dataLen) {
|
|
|
|
return HasReturnvaluesIF::RETURN_OK;
|
|
|
|
}
|