From 6b6026feba4b5ce279197f18872927cdc56ce5a1 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 22 Jun 2014 18:53:18 -0600 Subject: TCP write buffering: Extend and fix some buffer dumping logic --- nuttx/net/iob/iob_dump.c | 44 ++++++-------------------------------------- nuttx/net/iob/iob_free.c | 7 +++++++ 2 files changed, 13 insertions(+), 38 deletions(-) (limited to 'nuttx/net/iob') diff --git a/nuttx/net/iob/iob_dump.c b/nuttx/net/iob/iob_dump.c index a4d1cf04a..b56477071 100644 --- a/nuttx/net/iob/iob_dump.c +++ b/nuttx/net/iob/iob_dump.c @@ -81,50 +81,18 @@ void iob_dump(FAR const char *msg, FAR struct iob_s *iob) { FAR struct iob_s *head = iob; - FAR const uint8_t *buffer; uint8_t data[32]; unsigned int nbytes; unsigned int i; unsigned int j; - int len; - message("%s: IOB=%p pktlen=%d\n", msg, head, head->io_pktlen); + message("%s: iob=%p pktlen=%d\n", msg, head, head->io_pktlen); - buffer = &iob->io_data[iob->io_offset]; - len = iob->io_len; - - for (i = 0; i < head->io_pktlen && iob; i += 32) + for (i = 0; i < head->io_pktlen; i += 32) { /* Copy 32-bytes into our local buffer */ - for (nbytes = 0; nbytes < 32; nbytes++) - { - data[nbytes] = *buffer++; - - /* If we have exhausted the data in this I/O buffer, - * then skip to the next I/O buffer in the chain. - */ - - if (--len <= 0) - { - iob = iob->io_flink; - if (!iob) - { - /* Ooops... we are at the end of the chain. - * break out with iob = NULL, len == 0, and - * nbytes <= 32. - */ - - len = 0; - break; - } - - /* Get the data from the next I/O buffer in the chain */ - - buffer = &iob->io_data[iob->io_offset]; - len = iob->io_len; - } - } + nbytes = iob_copyout(data, iob, 32, i); /* Make sure that we have something to print */ @@ -140,7 +108,7 @@ void iob_dump(FAR const char *msg, FAR struct iob_s *iob) if (i + j < head->io_pktlen) { - message("%02x", buffer[j]); + message("%02x", data[j]); } else { @@ -158,9 +126,9 @@ void iob_dump(FAR const char *msg, FAR struct iob_s *iob) if (i + j < head->io_pktlen) { - if (buffer[j] >= 0x20 && buffer[j] < 0x7f) + if (data[j] >= 0x20 && data[j] < 0x7f) { - message("%c", buffer[j]); + message("%c", data[j]); } else { diff --git a/nuttx/net/iob/iob_free.c b/nuttx/net/iob/iob_free.c index 511c6438f..68c7fb264 100644 --- a/nuttx/net/iob/iob_free.c +++ b/nuttx/net/iob/iob_free.c @@ -48,6 +48,7 @@ #include #include +#include #include #include @@ -88,6 +89,9 @@ FAR struct iob_s *iob_free(FAR struct iob_s *iob) FAR struct iob_s *next = iob->io_flink; irqstate_t flags; + nllvdbg("iob=%p io_pktlen=%u io_len=%u next=%p\n", + iob, iob->io_pktlen, iob->io_len, next); + /* Copy the data that only exists in the head of a I/O buffer chain into * the next entry. */ @@ -114,6 +118,9 @@ FAR struct iob_s *iob_free(FAR struct iob_s *iob) next->io_pktlen = 0; DEBUGASSERT(next->io_len == 0 && next->io_flink == NULL); } + + nllvdbg("next=%p io_pktlen=%u io_len=%u\n", + next, next->io_pktlen, next->io_len); } /* Free the I/O buffer by adding it to the head of the free list. We don't -- cgit v1.2.3