diff --git a/osal/linux/MessageQueue.cpp b/osal/linux/MessageQueue.cpp index 3d5d7a5a..ce1da17c 100644 --- a/osal/linux/MessageQueue.cpp +++ b/osal/linux/MessageQueue.cpp @@ -47,7 +47,7 @@ MessageQueue::~MessageQueue() { status = mq_unlink(name); if(status != 0){ sif::error << "MessageQueue::Destructor: mq_unlink Failed with status: " - << strerror(errno) < #include +#include TmTcUnixUdpBridge::TmTcUnixUdpBridge(object_id_t objectId, object_id_t ccsdsPacketDistributor, uint16_t serverPort, @@ -20,6 +21,7 @@ TmTcUnixUdpBridge::TmTcUnixUdpBridge(object_id_t objectId, sif::error << "TmTcUnixUdpBridge::TmTcUnixUdpBridge: Could not open" " UDP socket!" << std::endl; // check errno here. + handleSocketError(); return; } @@ -39,9 +41,6 @@ TmTcUnixUdpBridge::TmTcUnixUdpBridge(object_id_t objectId, // check errno here. return; } - - - } TmTcUnixUdpBridge::~TmTcUnixUdpBridge() { @@ -58,3 +57,19 @@ ReturnValue_t TmTcUnixUdpBridge::receiveTc(uint8_t **recvBuffer, size_t *size) { ReturnValue_t TmTcUnixUdpBridge::sendTm(const uint8_t *data, size_t dataLen) { return HasReturnvaluesIF::RETURN_OK; } + +void TmTcUnixUdpBridge::handleSocketError() { + // See: https://man7.org/linux/man-pages/man2/socket.2.html + switch(errno) { + case(EACCES): + case(EINVAL): + case(EMFILE): + case(ENFILE): + case(EAFNOSUPPORT): + case(ENOBUFS): + case(ENOMEM): + case(EPROTONOSUPPORT): + sif::error << "TmTcUnixBridge::TmTcUnixBridge: Socket creation failed" + << " with " << strerror(errno) << std::endl; + } +} diff --git a/osal/linux/TmTcUnixUdpBridge.h b/osal/linux/TmTcUnixUdpBridge.h index ab2e2d67..ccab1b1f 100644 --- a/osal/linux/TmTcUnixUdpBridge.h +++ b/osal/linux/TmTcUnixUdpBridge.h @@ -25,6 +25,8 @@ private: const int serverSocketOptions = 0; struct sockaddr_in clientAddress; struct sockaddr_in serverAddress; + + void handleSocketError(); };