run auto-formatter
This commit is contained in:
@ -9,8 +9,10 @@
|
||||
#include "ethernetif.h"
|
||||
#include "udp_config.h"
|
||||
|
||||
TmTcLwIpUdpBridge::TmTcLwIpUdpBridge(object_id_t objectId, object_id_t ccsdsPacketDistributor,
|
||||
object_id_t tmStoreId, object_id_t tcStoreId)
|
||||
TmTcLwIpUdpBridge::TmTcLwIpUdpBridge(object_id_t objectId,
|
||||
object_id_t ccsdsPacketDistributor,
|
||||
object_id_t tmStoreId,
|
||||
object_id_t tcStoreId)
|
||||
: TmTcBridge(objectId, ccsdsPacketDistributor, tmStoreId, tcStoreId) {
|
||||
TmTcLwIpUdpBridge::lastAdd.addr = IPADDR_TYPE_ANY;
|
||||
}
|
||||
@ -38,7 +40,8 @@ ReturnValue_t TmTcLwIpUdpBridge::udp_server_init(void) {
|
||||
|
||||
if (err == ERR_OK) {
|
||||
/* Set a receive callback for the upcb */
|
||||
udp_recv(TmTcLwIpUdpBridge::upcb, &udp_server_receive_callback, (void*)this);
|
||||
udp_recv(TmTcLwIpUdpBridge::upcb, &udp_server_receive_callback,
|
||||
(void *)this);
|
||||
return RETURN_OK;
|
||||
} else {
|
||||
udp_remove(TmTcLwIpUdpBridge::upcb);
|
||||
@ -54,20 +57,22 @@ ReturnValue_t TmTcLwIpUdpBridge::performOperation(uint8_t operationCode) {
|
||||
|
||||
#if TCPIP_RECV_WIRETAPPING == 1
|
||||
if (connectFlag) {
|
||||
uint32_t ipAddress = ((ip4_addr*)&lastAdd)->addr;
|
||||
uint32_t ipAddress = ((ip4_addr *)&lastAdd)->addr;
|
||||
int ipAddress1 = (ipAddress & 0xFF000000) >> 24;
|
||||
int ipAddress2 = (ipAddress & 0xFF0000) >> 16;
|
||||
int ipAddress3 = (ipAddress & 0xFF00) >> 8;
|
||||
int ipAddress4 = ipAddress & 0xFF;
|
||||
#if OBSW_VERBOSE_LEVEL == 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::info << "TmTcLwIpUdpBridge: Client IP Address " << std::dec << ipAddress4 << "."
|
||||
<< ipAddress3 << "." << ipAddress2 << "." << ipAddress1 << std::endl;
|
||||
sif::info << "TmTcLwIpUdpBridge: Client IP Address " << std::dec
|
||||
<< ipAddress4 << "." << ipAddress3 << "." << ipAddress2 << "."
|
||||
<< ipAddress1 << std::endl;
|
||||
uint16_t portSwapped = EndianConverter::convertBigEndian(lastPort);
|
||||
sif::info << "TmTcLwIpUdpBridge: Client IP Port " << (int)portSwapped << std::endl;
|
||||
sif::info << "TmTcLwIpUdpBridge: Client IP Port " << (int)portSwapped
|
||||
<< std::endl;
|
||||
#else
|
||||
sif::printInfo("TmTcLwIpUdpBridge: Client IP Address %d.%d.%d.%d\n", ipAddress4, ipAddress3,
|
||||
ipAddress2, ipAddress1);
|
||||
sif::printInfo("TmTcLwIpUdpBridge: Client IP Address %d.%d.%d.%d\n",
|
||||
ipAddress4, ipAddress3, ipAddress2, ipAddress1);
|
||||
uint16_t portSwapped = EndianConverter::convertBigEndian(lastPort);
|
||||
sif::printInfo("TmTcLwIpUdpBridge: Client IP Port: %d\n", portSwapped);
|
||||
#endif
|
||||
@ -79,11 +84,12 @@ ReturnValue_t TmTcLwIpUdpBridge::performOperation(uint8_t operationCode) {
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t TmTcLwIpUdpBridge::sendTm(const uint8_t* data, size_t dataLen) {
|
||||
struct pbuf* p_tx = pbuf_alloc(PBUF_TRANSPORT, dataLen, PBUF_RAM);
|
||||
if ((p_tx != nullptr) && (lastAdd.addr != IPADDR_TYPE_ANY) && (upcb != nullptr)) {
|
||||
ReturnValue_t TmTcLwIpUdpBridge::sendTm(const uint8_t *data, size_t dataLen) {
|
||||
struct pbuf *p_tx = pbuf_alloc(PBUF_TRANSPORT, dataLen, PBUF_RAM);
|
||||
if ((p_tx != nullptr) && (lastAdd.addr != IPADDR_TYPE_ANY) &&
|
||||
(upcb != nullptr)) {
|
||||
/* copy data to pbuf */
|
||||
err_t err = pbuf_take(p_tx, (char*)data, dataLen);
|
||||
err_t err = pbuf_take(p_tx, (char *)data, dataLen);
|
||||
if (err != ERR_OK) {
|
||||
pbuf_free(p_tx);
|
||||
return err;
|
||||
@ -109,17 +115,21 @@ ReturnValue_t TmTcLwIpUdpBridge::sendTm(const uint8_t* data, size_t dataLen) {
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
void TmTcLwIpUdpBridge::udp_server_receive_callback(void* arg, struct udp_pcb* upcb_,
|
||||
struct pbuf* p, const ip_addr_t* addr,
|
||||
void TmTcLwIpUdpBridge::udp_server_receive_callback(void *arg,
|
||||
struct udp_pcb *upcb_,
|
||||
struct pbuf *p,
|
||||
const ip_addr_t *addr,
|
||||
u16_t port) {
|
||||
struct pbuf* p_tx = nullptr;
|
||||
auto udpBridge = reinterpret_cast<TmTcLwIpUdpBridge*>(arg);
|
||||
struct pbuf *p_tx = nullptr;
|
||||
auto udpBridge = reinterpret_cast<TmTcLwIpUdpBridge *>(arg);
|
||||
if (udpBridge == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "TmTcLwIpUdpBridge::udp_server_receive_callback: Invalid UDP bridge!"
|
||||
<< std::endl;
|
||||
sif::warning
|
||||
<< "TmTcLwIpUdpBridge::udp_server_receive_callback: Invalid UDP bridge!"
|
||||
<< std::endl;
|
||||
#else
|
||||
sif::printWarning("TmTcLwIpUdpBridge::udp_server_receive_callback: Invalid UDP bridge!\n");
|
||||
sif::printWarning("TmTcLwIpUdpBridge::udp_server_receive_callback: Invalid "
|
||||
"UDP bridge!\n");
|
||||
#endif
|
||||
}
|
||||
/* allocate pbuf from RAM*/
|
||||
@ -140,9 +150,9 @@ void TmTcLwIpUdpBridge::udp_server_receive_callback(void* arg, struct udp_pcb* u
|
||||
udpBridge->physicalConnectStatusChange(true);
|
||||
}
|
||||
}
|
||||
pbuf_take(p_tx, (char*)p->payload, p->len);
|
||||
pbuf_take(p_tx, (char *)p->payload, p->len);
|
||||
/* send the received data to the uart port */
|
||||
char* data = reinterpret_cast<char*>(p_tx->payload);
|
||||
char *data = reinterpret_cast<char *>(p_tx->payload);
|
||||
*(data + p_tx->len) = '\0';
|
||||
|
||||
#if TCPIP_RECV_WIRETAPPING == 1
|
||||
@ -150,8 +160,8 @@ void TmTcLwIpUdpBridge::udp_server_receive_callback(void* arg, struct udp_pcb* u
|
||||
#endif
|
||||
|
||||
store_address_t storeId;
|
||||
ReturnValue_t returnValue =
|
||||
udpBridge->tcStore->addData(&storeId, reinterpret_cast<uint8_t*>(p->payload), p->len);
|
||||
ReturnValue_t returnValue = udpBridge->tcStore->addData(
|
||||
&storeId, reinterpret_cast<uint8_t *>(p->payload), p->len);
|
||||
if (returnValue != RETURN_OK) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "UDP Server: Data storage failed" << std::endl;
|
||||
@ -178,8 +188,8 @@ bool TmTcLwIpUdpBridge::comLinkUp() const { return communicationLinkUp; }
|
||||
/* Caller must ensure thread-safety */
|
||||
void TmTcLwIpUdpBridge::physicalConnectStatusChange(bool connect) {
|
||||
if (connect) {
|
||||
/* Physical connection does not mean there is a recipient to send packets too.
|
||||
This will be done by the receive callback! */
|
||||
/* Physical connection does not mean there is a recipient to send packets
|
||||
too. This will be done by the receive callback! */
|
||||
physicalConnection = true;
|
||||
} else {
|
||||
physicalConnection = false;
|
||||
|
Reference in New Issue
Block a user