1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

Merge pull request #3168 from haukepetersen/ng_add_udp_printhdr

net/ng_pktdump: added printing of UDP header details
This commit is contained in:
Martine Lenders 2015-06-05 16:12:13 +02:00
commit 789b11b25c
3 changed files with 40 additions and 0 deletions

View File

@ -92,6 +92,13 @@ ng_pktsnip_t *ng_udp_hdr_build(ng_pktsnip_t *payload,
uint8_t *src, size_t src_len,
uint8_t *dst, size_t dst_len);
/**
* @brief Print the given UDP header to STDOUT
*
* @param[in] hdr UDP header to print
*/
void ng_udp_hdr_print(ng_udp_hdr_t *hdr);
/**
* @brief Initialize and start UDP
*

View File

@ -29,6 +29,7 @@
#include "net/ng_netbase.h"
#include "net/ng_ipv6/addr.h"
#include "net/ng_ipv6/hdr.h"
#include "net/ng_udp.h"
#include "od.h"
/**
@ -78,6 +79,7 @@ static void _dump_snip(ng_pktsnip_t *pkt)
#ifdef MODULE_NG_UDP
case NG_NETTYPE_UDP:
printf("NETTYPE_UDP (%i)\n", pkt->type);
ng_udp_hdr_print(pkt->data);
break;
#endif
#ifdef TEST_SUITES

View File

@ -0,0 +1,31 @@
/*
* Copyright (C) 2015 Freie Universität Berlin
*
* 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.
*/
/**
* @ingroup net_pktdump
* @{
*
* @file
* @brief Generic module to dump packages received via netapi to STDOUT
*
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
*
* @}
*/
#include <stdio.h>
#include "net/ng_udp.h"
void ng_udp_hdr_print(ng_udp_hdr_t *hdr)
{
printf(" src-port: %5" PRIu16 " dst-port: %5" PRIu16 "\n",
byteorder_ntohs(hdr->src_port), byteorder_ntohs(hdr->dst_port));
printf(" length: %" PRIu16 " cksum: 0x4%" PRIx16 "\n",
byteorder_ntohs(hdr->length), byteorder_ntohs(hdr->checksum));
}