mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
Merge pull request #2741 from authmillenon/pktdump/feat/dump-ipv6
pktdump: add IPv6 header dump
This commit is contained in:
commit
480924afc0
@ -18,13 +18,17 @@
|
|||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <inttypes.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "byteorder.h"
|
||||||
#include "thread.h"
|
#include "thread.h"
|
||||||
#include "msg.h"
|
#include "msg.h"
|
||||||
#include "kernel.h"
|
#include "kernel.h"
|
||||||
#include "net/ng_pktdump.h"
|
#include "net/ng_pktdump.h"
|
||||||
#include "net/ng_netbase.h"
|
#include "net/ng_netbase.h"
|
||||||
|
#include "net/ng_ipv6/addr.h"
|
||||||
|
#include "net/ng_ipv6/hdr.h"
|
||||||
#include "od.h"
|
#include "od.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -58,6 +62,29 @@ static void _dump_netif_hdr(ng_netif_hdr_t *hdr)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef MODULE_NG_IPV6
|
||||||
|
static void _dump_ipv6_hdr(ng_ipv6_hdr_t *hdr)
|
||||||
|
{
|
||||||
|
char addr_str[NG_IPV6_ADDR_MAX_STR_LEN];
|
||||||
|
|
||||||
|
if (ng_ipv6_hdr_is_ipv6_hdr(hdr)) {
|
||||||
|
printf("illegal version field: %" PRIu8 "\n", ng_ipv6_hdr_get_version(hdr));
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("traffic class: 0x%02" PRIx8 " (ECN: 0x%" PRIx8 ", DSCP: 0x%02" PRIx8 ")\n",
|
||||||
|
ng_ipv6_hdr_get_tc(hdr), ng_ipv6_hdr_get_tc_ecn(hdr),
|
||||||
|
ng_ipv6_hdr_get_tc_dscp(hdr));
|
||||||
|
printf("flow label: 0x%05" PRIx32 "\n", ng_ipv6_hdr_get_fl(hdr));
|
||||||
|
printf("length: %" PRIu16 " next header: %" PRIu8 " hop limit: %" PRIu8 "\n",
|
||||||
|
byteorder_ntohs(hdr->len), hdr->nh, hdr->hl);
|
||||||
|
printf("source address: %s\n", ng_ipv6_addr_to_str(addr_str, &hdr->src,
|
||||||
|
sizeof(addr_str)));
|
||||||
|
printf("destination address: %s\n", ng_ipv6_addr_to_str(addr_str, &hdr->dst,
|
||||||
|
sizeof(addr_str)));
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void _dump_snip(ng_pktsnip_t *pkt)
|
static void _dump_snip(ng_pktsnip_t *pkt)
|
||||||
{
|
{
|
||||||
switch (pkt->type) {
|
switch (pkt->type) {
|
||||||
@ -78,7 +105,8 @@ static void _dump_snip(ng_pktsnip_t *pkt)
|
|||||||
#endif
|
#endif
|
||||||
#ifdef MODULE_NG_IPV6
|
#ifdef MODULE_NG_IPV6
|
||||||
case NG_NETTYPE_IPV6:
|
case NG_NETTYPE_IPV6:
|
||||||
printf("NETTYPE_IPV6 (%i)", pkt->type);
|
printf("NETTYPE_IPV6 (%i)\n", pkt->type);
|
||||||
|
_dump_ipv6_hdr(pkt->data);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
#ifdef MODULE_NG_ICMPV6
|
#ifdef MODULE_NG_ICMPV6
|
||||||
|
Loading…
Reference in New Issue
Block a user