netif_hdr: add print function
This commit is contained in:
parent
32e27c3ff3
commit
067a3498c5
@ -100,6 +100,7 @@ ifneq (,$(filter ng_netbase,$(USEMODULE)))
|
|||||||
USEMODULE += ng_netapi
|
USEMODULE += ng_netapi
|
||||||
USEMODULE += ng_netreg
|
USEMODULE += ng_netreg
|
||||||
USEMODULE += ng_netif
|
USEMODULE += ng_netif
|
||||||
|
USEMODULE += ng_netif_hdr
|
||||||
USEMODULE += ng_pktbuf
|
USEMODULE += ng_pktbuf
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|||||||
@ -86,6 +86,9 @@ endif
|
|||||||
ifneq (,$(filter ng_netif,$(USEMODULE)))
|
ifneq (,$(filter ng_netif,$(USEMODULE)))
|
||||||
DIRS += net/crosslayer/ng_netif
|
DIRS += net/crosslayer/ng_netif
|
||||||
endif
|
endif
|
||||||
|
ifneq (,$(filter ng_netif_hdr,$(USEMODULE)))
|
||||||
|
DIRS += net/crosslayer/ng_netif/hdr
|
||||||
|
endif
|
||||||
ifneq (,$(filter ng_netreg,$(USEMODULE)))
|
ifneq (,$(filter ng_netreg,$(USEMODULE)))
|
||||||
DIRS += net/crosslayer/ng_netreg
|
DIRS += net/crosslayer/ng_netreg
|
||||||
endif
|
endif
|
||||||
|
|||||||
@ -32,6 +32,12 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Maximum length of the l2 addresses of the generic interface header
|
||||||
|
* in bytes.
|
||||||
|
*/
|
||||||
|
#define NG_NETIF_HDR_L2ADDR_MAX_LEN (8)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @{
|
* @{
|
||||||
* @name Flags for the ng_netif_hdr_t
|
* @name Flags for the ng_netif_hdr_t
|
||||||
@ -208,6 +214,13 @@ static inline ng_pktsnip_t *ng_netif_hdr_build(uint8_t *src, uint8_t src_len,
|
|||||||
return pkt;
|
return pkt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Outputs a generic interface header to stdout.
|
||||||
|
*
|
||||||
|
* @param[in] hdr A generic interface header.
|
||||||
|
*/
|
||||||
|
void ng_netif_hdr_print(ng_netif_hdr_t *hdr);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
3
sys/net/crosslayer/ng_netif/hdr/Makefile
Normal file
3
sys/net/crosslayer/ng_netif/hdr/Makefile
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
MODULE = ng_netif_hdr
|
||||||
|
|
||||||
|
include $(RIOTBASE)/Makefile.base
|
||||||
37
sys/net/crosslayer/ng_netif/hdr/ng_netif_hdr_print.c
Normal file
37
sys/net/crosslayer/ng_netif/hdr/ng_netif_hdr_print.c
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2015 Martine Lenders <mlenders@inf.fu-berlin.de>
|
||||||
|
*
|
||||||
|
* 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 <stdio.h>
|
||||||
|
|
||||||
|
#include "net/ng_netif.h"
|
||||||
|
#include "net/ng_netif/hdr.h"
|
||||||
|
|
||||||
|
void ng_netif_hdr_print(ng_netif_hdr_t *hdr)
|
||||||
|
{
|
||||||
|
char addr_str[NG_NETIF_HDR_L2ADDR_MAX_LEN * 3];
|
||||||
|
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @} */
|
||||||
@ -41,27 +41,6 @@ static kernel_pid_t _pid = KERNEL_PID_UNDEF;
|
|||||||
*/
|
*/
|
||||||
static char _stack[NG_PKTDUMP_STACKSIZE];
|
static char _stack[NG_PKTDUMP_STACKSIZE];
|
||||||
|
|
||||||
#define ADDR_STR_MAX (24)
|
|
||||||
|
|
||||||
#ifdef MODULE_NG_NETIF
|
|
||||||
static void _dump_netif_hdr(ng_netif_hdr_t *hdr)
|
|
||||||
{
|
|
||||||
char addr_str[ADDR_STR_MAX];
|
|
||||||
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void _dump_snip(ng_pktsnip_t *pkt)
|
static void _dump_snip(ng_pktsnip_t *pkt)
|
||||||
{
|
{
|
||||||
switch (pkt->type) {
|
switch (pkt->type) {
|
||||||
@ -72,7 +51,7 @@ static void _dump_snip(ng_pktsnip_t *pkt)
|
|||||||
#ifdef MODULE_NG_NETIF
|
#ifdef MODULE_NG_NETIF
|
||||||
case NG_NETTYPE_NETIF:
|
case NG_NETTYPE_NETIF:
|
||||||
printf("NETTYPE_NETIF (%i)\n", pkt->type);
|
printf("NETTYPE_NETIF (%i)\n", pkt->type);
|
||||||
_dump_netif_hdr(pkt->data);
|
ng_netif_hdr_print(pkt->data);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
#ifdef MODULE_NG_SIXLOWPAN
|
#ifdef MODULE_NG_SIXLOWPAN
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user