continued new bridge
This commit is contained in:
parent
e0a3257f8b
commit
571da39108
@ -2,8 +2,19 @@
|
|||||||
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
||||||
|
|
||||||
TmTcUnixUdpBridge::TmTcUnixUdpBridge(object_id_t objectId,
|
TmTcUnixUdpBridge::TmTcUnixUdpBridge(object_id_t objectId,
|
||||||
object_id_t ccsdsPacketDistributor):
|
object_id_t ccsdsPacketDistributor, uint16_t serverPort,
|
||||||
|
uint16_t clientPort):
|
||||||
TmTcBridge(objectId, ccsdsPacketDistributor) {
|
TmTcBridge(objectId, ccsdsPacketDistributor) {
|
||||||
|
uint16_t setServerPort = DEFAULT_UDP_SERVER_PORT;
|
||||||
|
if(serverPort != 0xFFFF) {
|
||||||
|
setServerPort = serverPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t setClientPort = DEFAULT_UDP_CLIENT_PORT;
|
||||||
|
if(clientPort != 0xFFFF) {
|
||||||
|
setClientPort = clientPort;
|
||||||
|
}
|
||||||
|
|
||||||
serverSocket = socket(AF_INET, SOCK_DGRAM, 0);
|
serverSocket = socket(AF_INET, SOCK_DGRAM, 0);
|
||||||
if(socket < 0) {
|
if(socket < 0) {
|
||||||
sif::error << "TmTcUnixUdpBridge::TmTcUnixUdpBridge: Could not open"
|
sif::error << "TmTcUnixUdpBridge::TmTcUnixUdpBridge: Could not open"
|
||||||
@ -14,7 +25,7 @@ TmTcUnixUdpBridge::TmTcUnixUdpBridge(object_id_t objectId,
|
|||||||
|
|
||||||
serverAddress.sin_family = AF_INET;
|
serverAddress.sin_family = AF_INET;
|
||||||
serverAddress.sin_addr.s_addr = htonl(INADDR_ANY);
|
serverAddress.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||||
serverAddress.sin_port = htons(UDP_SERVER_PORT);
|
serverAddress.sin_port = htons(setServerPort);
|
||||||
setsockopt(serverSocket, SOL_SOCKET, SO_REUSEADDR, &serverSocketOptions,
|
setsockopt(serverSocket, SOL_SOCKET, SO_REUSEADDR, &serverSocketOptions,
|
||||||
sizeof(serverSocketOptions));
|
sizeof(serverSocketOptions));
|
||||||
|
|
||||||
@ -23,7 +34,7 @@ TmTcUnixUdpBridge::TmTcUnixUdpBridge(object_id_t objectId,
|
|||||||
sizeof(serverAddress));
|
sizeof(serverAddress));
|
||||||
if(result== -1) {
|
if(result== -1) {
|
||||||
sif::error << "TmTcUnixUdpBridge::TmTcUnixUdpBridge: Could not bind "
|
sif::error << "TmTcUnixUdpBridge::TmTcUnixUdpBridge: Could not bind "
|
||||||
"local port " << UDP_SERVER_PORT << " to server socket!"
|
"local port " << setServerPort << " to server socket!"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
// check errno here.
|
// check errno here.
|
||||||
return;
|
return;
|
||||||
@ -35,3 +46,15 @@ TmTcUnixUdpBridge::TmTcUnixUdpBridge(object_id_t objectId,
|
|||||||
|
|
||||||
TmTcUnixUdpBridge::~TmTcUnixUdpBridge() {
|
TmTcUnixUdpBridge::~TmTcUnixUdpBridge() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
@ -8,14 +8,18 @@
|
|||||||
|
|
||||||
class TmTcUnixUdpBridge: public TmTcBridge {
|
class TmTcUnixUdpBridge: public TmTcBridge {
|
||||||
public:
|
public:
|
||||||
static constexpr int UDP_SERVER_PORT = 7;
|
static constexpr int DEFAULT_UDP_SERVER_PORT = 7;
|
||||||
static constexpr int UDP_CLIENT_PORT = 2008;
|
static constexpr int DEFAULT_UDP_CLIENT_PORT = 2008;
|
||||||
|
|
||||||
TmTcUnixUdpBridge(object_id_t objectId, object_id_t ccsdsPacketDistributor);
|
TmTcUnixUdpBridge(object_id_t objectId, object_id_t ccsdsPacketDistributor,
|
||||||
|
uint16_t serverPort = 0xFFFF,uint16_t clientPort = 0xFFFF);
|
||||||
virtual~ TmTcUnixUdpBridge();
|
virtual~ TmTcUnixUdpBridge();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
virtual ReturnValue_t handleTc() override;
|
||||||
|
virtual ReturnValue_t receiveTc(uint8_t ** recvBuffer,
|
||||||
|
size_t * size) override;
|
||||||
|
virtual ReturnValue_t sendTm(const uint8_t * data, size_t dataLen) override;
|
||||||
private:
|
private:
|
||||||
int serverSocket = 0;
|
int serverSocket = 0;
|
||||||
const int serverSocketOptions = 0;
|
const int serverSocketOptions = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user