diff --git a/sys/include/net/ng_ipv6/hdr.h b/sys/include/net/ng_ipv6/hdr.h index 4d6e5245a..6a9b9c0bb 100644 --- a/sys/include/net/ng_ipv6/hdr.h +++ b/sys/include/net/ng_ipv6/hdr.h @@ -316,6 +316,13 @@ ng_pktsnip_t *ng_ipv6_hdr_build(ng_pktsnip_t *payload, uint8_t *src, uint8_t src_len, uint8_t *dst, uint8_t dst_len); +/** + * @brief Outputs an IPv6 header to stdout. + * + * @param[in] hdr An IPv6 header. + */ +void ng_ipv6_hdr_print(ng_ipv6_hdr_t *hdr); + #ifdef __cplusplus } #endif diff --git a/sys/net/crosslayer/ng_pktdump/ng_pktdump.c b/sys/net/crosslayer/ng_pktdump/ng_pktdump.c index a787cddb6..5498fb55a 100644 --- a/sys/net/crosslayer/ng_pktdump/ng_pktdump.c +++ b/sys/net/crosslayer/ng_pktdump/ng_pktdump.c @@ -62,29 +62,6 @@ static void _dump_netif_hdr(ng_netif_hdr_t *hdr) } #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(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) { switch (pkt->type) { @@ -106,7 +83,7 @@ static void _dump_snip(ng_pktsnip_t *pkt) #ifdef MODULE_NG_IPV6 case NG_NETTYPE_IPV6: printf("NETTYPE_IPV6 (%i)\n", pkt->type); - _dump_ipv6_hdr(pkt->data); + ng_ipv6_hdr_print(pkt->data); break; #endif #ifdef MODULE_NG_ICMPV6 diff --git a/sys/net/network_layer/ng_ipv6/hdr/ng_ipv6_hdr_print.c b/sys/net/network_layer/ng_ipv6/hdr/ng_ipv6_hdr_print.c new file mode 100644 index 000000000..c8140e8c7 --- /dev/null +++ b/sys/net/network_layer/ng_ipv6/hdr/ng_ipv6_hdr_print.c @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2015 Martine Lenders + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @{ + * + * @file + */ + +#include + +#include "net/ng_ipv6/hdr.h" + +void ng_ipv6_hdr_print(ng_ipv6_hdr_t *hdr) +{ + char addr_str[NG_IPV6_ADDR_MAX_STR_LEN]; + + if (!ng_ipv6_hdr_is(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))); + +} + +/** @} */