Skip to content
Snippets Groups Projects
Unverified Commit 5230e773 authored by Cenk Gündoğan's avatar Cenk Gündoğan Committed by GitHub
Browse files

Merge pull request #9188 from miri64/gnrc_pktdump/enh/print-rest

gnrc_pktdump: print rest of snip as hex if available
parents e0c50e41 8c77cbb9
Branches
No related tags found
No related merge requests found
......@@ -47,6 +47,8 @@ static char _stack[GNRC_PKTDUMP_STACKSIZE];
static void _dump_snip(gnrc_pktsnip_t *pkt)
{
size_t hdr_len = pkt->size;
switch (pkt->type) {
case GNRC_NETTYPE_UNDEF:
printf("NETTYPE_UNDEF (%i)\n", pkt->type);
......@@ -68,24 +70,28 @@ static void _dump_snip(gnrc_pktsnip_t *pkt)
case GNRC_NETTYPE_IPV6:
printf("NETTYPE_IPV6 (%i)\n", pkt->type);
ipv6_hdr_print(pkt->data);
hdr_len = sizeof(ipv6_hdr_t);
break;
#endif
#ifdef MODULE_GNRC_ICMPV6
case GNRC_NETTYPE_ICMPV6:
printf("NETTYPE_ICMPV6 (%i)\n", pkt->type);
icmpv6_hdr_print(pkt->data);
hdr_len = sizeof(icmpv6_hdr_t);
break;
#endif
#ifdef MODULE_GNRC_TCP
case GNRC_NETTYPE_TCP:
printf("NETTYPE_TCP (%i)\n", pkt->type);
tcp_hdr_print(pkt->data);
hdr_len = sizeof(tcp_hdr_t);
break;
#endif
#ifdef MODULE_GNRC_UDP
case GNRC_NETTYPE_UDP:
printf("NETTYPE_UDP (%i)\n", pkt->type);
udp_hdr_print(pkt->data);
hdr_len = sizeof(udp_hdr_t);
break;
#endif
#ifdef MODULE_CCN_LITE_UTILS
......@@ -111,6 +117,11 @@ static void _dump_snip(gnrc_pktsnip_t *pkt)
od_hex_dump(pkt->data, pkt->size, OD_WIDTH_DEFAULT);
break;
}
if (hdr_len < pkt->size) {
size_t size = pkt->size - hdr_len;
od_hex_dump(((uint8_t *)pkt->data) + hdr_len, size, OD_WIDTH_DEFAULT);
}
}
static void _dump(gnrc_pktsnip_t *pkt)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment