From ec61db5234ccc1c498c541675bc74c969c52746a Mon Sep 17 00:00:00 2001 From: Martine Lenders <mlenders@inf.fu-berlin.de> Date: Fri, 8 May 2015 19:08:21 +0200 Subject: [PATCH] netif_hdr: print 0-length L2 addresses correctly --- .../ng_netif/hdr/ng_netif_hdr_print.c | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/sys/net/crosslayer/ng_netif/hdr/ng_netif_hdr_print.c b/sys/net/crosslayer/ng_netif/hdr/ng_netif_hdr_print.c index 0c7bd3b71b..9f1386269b 100644 --- a/sys/net/crosslayer/ng_netif/hdr/ng_netif_hdr_print.c +++ b/sys/net/crosslayer/ng_netif/hdr/ng_netif_hdr_print.c @@ -24,14 +24,26 @@ void ng_netif_hdr_print(ng_netif_hdr_t *hdr) printf("if_pid: %" PRIkernel_pid " ", hdr->if_pid); printf("rssi: %" PRIu8 " ", hdr->rssi); printf("lqi: %" PRIu8 "\n", hdr->lqi); - printf("src_l2addr: %s\n", - ng_netif_addr_to_str(addr_str, sizeof(addr_str), - ng_netif_hdr_get_src_addr(hdr), - (size_t)hdr->src_l2addr_len)); - printf("dst_l2addr: %s\n", - ng_netif_addr_to_str(addr_str, sizeof(addr_str), - ng_netif_hdr_get_dst_addr(hdr), - (size_t)hdr->dst_l2addr_len)); + + if (hdr->src_l2addr_len > 0) { + printf("src_l2addr: %s\n", + ng_netif_addr_to_str(addr_str, sizeof(addr_str), + ng_netif_hdr_get_src_addr(hdr), + (size_t)hdr->src_l2addr_len)); + } + else { + puts("src_l2addr: (nil)"); + } + + if (hdr->dst_l2addr_len > 0) { + printf("dst_l2addr: %s\n", + ng_netif_addr_to_str(addr_str, sizeof(addr_str), + ng_netif_hdr_get_dst_addr(hdr), + (size_t)hdr->dst_l2addr_len)); + } + else { + puts("dst_l2addr: (nil)"); + } } /** @} */ -- GitLab