From 1655324b6939c32c114b220c7f62d03e1d9cfd87 Mon Sep 17 00:00:00 2001 From: Andrew Burger Date: Tue, 15 Sep 2020 13:35:23 -0700 Subject: [PATCH] Some logging --- nfapi/open-nFAPI/nfapi/src/nfapi_p7.c | 34 +++++++++++++++++++++++++++ openair2/PHY_INTERFACE/phy_stub_UE.c | 6 +++++ 2 files changed, 40 insertions(+) diff --git a/nfapi/open-nFAPI/nfapi/src/nfapi_p7.c b/nfapi/open-nFAPI/nfapi/src/nfapi_p7.c index b4d1653fce..cf24f551d8 100755 --- a/nfapi/open-nFAPI/nfapi/src/nfapi_p7.c +++ b/nfapi/open-nFAPI/nfapi/src/nfapi_p7.c @@ -37,6 +37,31 @@ #include #include +static const char *hexdump(const void *data, size_t data_len, char *out, size_t out_len) +{ + char *p = out; + char *endp = out + out_len; + const uint8_t *q = data; + snprintf(p, endp - p, "[%zu]", data_len); + p += strlen(p); + for (size_t i = 0; i < data_len; ++i) + { + if (p >= endp) + { + static const char ellipses[] = "..."; + char *s = endp - sizeof(ellipses); + if (s >= p) + { + strcpy(s, ellipses); + } + break; + } + snprintf(p, endp - p, " %02X", *q++); + p += strlen(p); + } + return out; +} + extern int nfapi_unpack_p7_vendor_extension(nfapi_p7_message_header_t* header, uint8_t **ppReadPackedMsg, void* user_data); extern int nfapi_pack_p7_vendor_extension(nfapi_p7_message_header_t* header, uint8_t **ppWritePackedMsg, void* user_data); @@ -6109,6 +6134,8 @@ int nfapi_p7_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUn nfapi_p7_message_header_t *pMessageHeader = (nfapi_p7_message_header_t*)pUnpackedBuf; uint8_t *pReadPackedMessage = pMessageBuf; uint8_t *end = pMessageBuf + messageBufLen; + uint8_t *end_unpacked_buf = pUnpackedBuf + unpackedBufLen; + uint8_t *start_unpacked_buf = pUnpackedBuf; if (pMessageBuf == NULL || pUnpackedBuf == NULL) { @@ -6317,6 +6344,13 @@ int nfapi_p7_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUn break; } + if (pMessageHeader->message_id == NFAPI_RX_ULSCH_INDICATION) + { + char foobar[1024]; + NFAPI_TRACE(NFAPI_TRACE_ERROR, "Biden %s:%d: %s\n", __FUNCTION__, + __LINE__, hexdump(pUnpackedBuf, end_unpacked_buf - start_unpacked_buf, foobar, sizeof(foobar))); + } + if(result == 0) return -1; else diff --git a/openair2/PHY_INTERFACE/phy_stub_UE.c b/openair2/PHY_INTERFACE/phy_stub_UE.c index 73dbdcb319..75bb239ce3 100644 --- a/openair2/PHY_INTERFACE/phy_stub_UE.c +++ b/openair2/PHY_INTERFACE/phy_stub_UE.c @@ -1330,6 +1330,12 @@ const char *hexdump(const void *data, size_t data_len, char *out, size_t out_len LOG_I(MAC, "RX_IND sent to Proxy, Size: %d Frame %d Subframe %d rx_ind.tl.length: %u num_pdus: %u\n", encoded_size, NFAPI_SFNSF2SFN(UL->rx_ind.sfn_sf), NFAPI_SFNSF2SF(UL->rx_ind.sfn_sf), UL->rx_ind.rx_indication_body.tl.length, UL->rx_ind.rx_indication_body.number_of_pdus); + nfapi_rx_indication_t test_ind; + if (nfapi_p7_message_unpack(buffer, encoded_size, &test_ind, sizeof(test_ind), NULL) < 0) + { + LOG_E(MAC, "could not unpack rx_ind right after packing encoded_size: %d\n" encoded_size); + abort(); + } break; case NFAPI_RX_CQI_INDICATION: encoded_size = nfapi_p7_message_pack(&UL->cqi_ind, buffer, sizeof(buffer), NULL); // Check pdu->ul_cqi_information.channel = 1