started unix udp bridge
This commit is contained in:
parent
18173772af
commit
72768a6815
37
osal/linux/TmTcUnixUdpBridge.cpp
Normal file
37
osal/linux/TmTcUnixUdpBridge.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
#include <framework/osal/linux/TmTcUnixUdpBridge.h>
|
||||
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
||||
|
||||
TmTcUnixUdpBridge::TmTcUnixUdpBridge(object_id_t objectId,
|
||||
object_id_t ccsdsPacketDistributor):
|
||||
TmTcBridge(objectId, ccsdsPacketDistributor) {
|
||||
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);
|
||||
serverAddress.sin_port = htons(UDP_SERVER_PORT);
|
||||
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 "
|
||||
"local port " << UDP_SERVER_PORT << " to server socket!"
|
||||
<< std::endl;
|
||||
// check errno here.
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
TmTcUnixUdpBridge::~TmTcUnixUdpBridge() {
|
||||
}
|
28
osal/linux/TmTcUnixUdpBridge.h
Normal file
28
osal/linux/TmTcUnixUdpBridge.h
Normal file
@ -0,0 +1,28 @@
|
||||
#ifndef FRAMEWORK_OSAL_LINUX_TMTCUNIXUDPBRIDGE_H_
|
||||
#define FRAMEWORK_OSAL_LINUX_TMTCUNIXUDPBRIDGE_H_
|
||||
|
||||
#include <framework/tmtcservices/TmTcBridge.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/udp.h>
|
||||
|
||||
class TmTcUnixUdpBridge: public TmTcBridge {
|
||||
public:
|
||||
static constexpr int UDP_SERVER_PORT = 7;
|
||||
static constexpr int UDP_CLIENT_PORT = 2008;
|
||||
|
||||
TmTcUnixUdpBridge(object_id_t objectId, object_id_t ccsdsPacketDistributor);
|
||||
virtual~ TmTcUnixUdpBridge();
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
int serverSocket = 0;
|
||||
const int serverSocketOptions = 0;
|
||||
struct sockaddr_in clientAddress;
|
||||
struct sockaddr_in serverAddress;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* FRAMEWORK_OSAL_LINUX_TMTCUNIXUDPBRIDGE_H_ */
|
@ -5,9 +5,9 @@
|
||||
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
||||
#include <framework/globalfunctions/arrayprinter.h>
|
||||
|
||||
TmTcBridge::TmTcBridge(object_id_t objectId_,
|
||||
object_id_t ccsdsPacketDistributor_): SystemObject(objectId_),
|
||||
ccsdsPacketDistributor(ccsdsPacketDistributor_)
|
||||
TmTcBridge::TmTcBridge(object_id_t objectId,
|
||||
object_id_t ccsdsPacketDistributor): SystemObject(objectId),
|
||||
ccsdsPacketDistributor(ccsdsPacketDistributor)
|
||||
{
|
||||
TmTcReceptionQueue = QueueFactory::instance()->
|
||||
createMessageQueue(TMTC_RECEPTION_QUEUE_DEPTH);
|
||||
|
@ -22,7 +22,7 @@ public:
|
||||
static constexpr uint8_t DEFAULT_STORED_DATA_SENT_PER_CYCLE = 5;
|
||||
static constexpr uint8_t DEFAULT_DOWNLINK_PACKETS_STORED = 10;
|
||||
|
||||
TmTcBridge(object_id_t objectId_, object_id_t ccsdsPacketDistributor_);
|
||||
TmTcBridge(object_id_t objectId, object_id_t ccsdsPacketDistributor);
|
||||
virtual ~TmTcBridge();
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user