net: Add net_hexdump() utility to print network data
Only usable if network debugging is activated. Change-Id: Id7d70d88b5ddca772603e5d2c567b8df23cf084e Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
parent
402996e374
commit
eba768aba0
1 changed files with 34 additions and 0 deletions
|
@ -87,6 +87,37 @@ static inline char *net_sprint_ip_addr(struct net_addr *addr)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void net_hexdump(const char *str, const uint8_t *packet, size_t length)
|
||||||
|
{
|
||||||
|
int n = 0;
|
||||||
|
|
||||||
|
if (!length) {
|
||||||
|
SYS_LOG_DBG("%s zero-length packet", str);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (length--) {
|
||||||
|
if (n % 16 == 0) {
|
||||||
|
printf("%s %08X ", str, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("%02X ", *packet++);
|
||||||
|
|
||||||
|
n++;
|
||||||
|
if (n % 8 == 0) {
|
||||||
|
if (n % 16 == 0) {
|
||||||
|
printf("\n");
|
||||||
|
} else {
|
||||||
|
printf(" ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (n % 16) {
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#else /* NET_DEBUG */
|
#else /* NET_DEBUG */
|
||||||
|
|
||||||
static inline char *net_sprint_ll_addr(uint8_t *ll, uint8_t ll_len)
|
static inline char *net_sprint_ll_addr(uint8_t *ll, uint8_t ll_len)
|
||||||
|
@ -113,4 +144,7 @@ static inline char *net_sprint_ip_addr(struct net_addr *addr)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define net_hexdump(str, packet, length)
|
||||||
|
|
||||||
#endif /* NET_DEBUG */
|
#endif /* NET_DEBUG */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue