From 293a4782bafa8704fbd2a5163f29c91ab9418e12 Mon Sep 17 00:00:00 2001 From: Kevin Schoedel Date: Wed, 8 Jun 2022 16:41:03 -0400 Subject: [PATCH] LOG --- src/inet/UDPEndPointImplLwIP.cpp | 1 + src/system/SystemPacketBuffer.h | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git src/inet/UDPEndPointImplLwIP.cpp src/inet/UDPEndPointImplLwIP.cpp index b3ce8a24705..0dbb22e6fce 100644 --- src/inet/UDPEndPointImplLwIP.cpp +++ src/inet/UDPEndPointImplLwIP.cpp @@ -342,6 +342,7 @@ void UDPEndPointImplLwIP::LwIPReceiveUDPMessage(void * arg, struct udp_pcb * pcb UDPEndPointImplLwIP * ep = static_cast(arg); IPPacketInfo * pktInfo = nullptr; System::PacketBufferHandle buf = System::PacketBufferHandle::Adopt(p); + buf.Z("UDP"); if (buf->HasChainedBuffer()) { // Try the simple expedient of flattening in-place. diff --git src/system/SystemPacketBuffer.h src/system/SystemPacketBuffer.h index c61cbcd89bf..d441a5a1b3c 100644 --- src/system/SystemPacketBuffer.h +++ src/system/SystemPacketBuffer.h @@ -353,6 +353,19 @@ public: #endif } + static void Z(const char * tag, const PacketBuffer * p) + { + const uint16_t allocSize = p->AllocSize(); + const uint8_t * const bufferStart = reinterpret_cast(p); + const uint8_t * const bufferEnd = bufferStart + kStructureSize + allocSize; + const uint8_t * const payloadStart = reinterpret_cast(p->payload); + const uint8_t * const payloadEnd = payloadStart + p->len; + const char status = (payloadStart < bufferStart + kStructureSize) ? '<' : (payloadEnd > bufferEnd) ? '>' : ' '; + ChipLogProgress(chipSystemLayer, "%s %c pb: %8p pay: %8p %5zd len: 0x%04X asz: 0x%04X", tag, status, bufferStart, + payloadStart, payloadStart - bufferStart, p->len, allocSize); + } + void Z(const char * tag) const { Z(tag, this); } + private: // Memory required for a maximum-size PacketBuffer. static constexpr uint16_t kBlockSize = PacketBuffer::kStructureSize + PacketBuffer::kMaxSizeWithoutReserve; @@ -402,6 +415,7 @@ static_assert(sizeof(pbuf) == sizeof(PacketBuffer), "PacketBuffer must not have class DLL_EXPORT PacketBufferHandle { public: + void Z(const char * tag) const { mBuffer->Z(tag); } /** * Construct an empty PacketBufferHandle. */ -- 2.36.1.476.g0c4daa206d-goog