Browse Source

net: add tcp_hdr_print

patch-1
smlng 6 years ago
parent
commit
43de60daf0
  1. 1
      Makefile.dep
  2. 3
      sys/Makefile
  3. 7
      sys/include/net/tcp.h
  4. 1
      sys/net/transport_layer/tcp/Makefile
  5. 33
      sys/net/transport_layer/tcp/tcp_hdr_print.c

1
Makefile.dep

@ -341,6 +341,7 @@ endif
ifneq (,$(filter gnrc_tcp,$(USEMODULE)))
USEMODULE += inet_csum
USEMODULE += random
USEMODULE += tcp
USEMODULE += xtimer
endif

3
sys/Makefile

@ -79,6 +79,9 @@ endif
ifneq (,$(filter udp,$(USEMODULE)))
DIRS += net/transport_layer/udp
endif
ifneq (,$(filter tcp,$(USEMODULE)))
DIRS += net/transport_layer/tcp
endif
ifneq (,$(filter hamming256,$(USEMODULE)))
DIRS += ecc/hamming256

7
sys/include/net/tcp.h

@ -75,6 +75,13 @@ typedef struct __attribute__((packed)) {
uint8_t value[]; /**< Pointer to TCP options Value field */
} tcp_hdr_opt_t;
/**
* @brief Print the given TCP header to STDOUT
*
* @param[in] hdr TCP header to print
*/
void tcp_hdr_print(tcp_hdr_t *hdr);
#ifdef __cplusplus
}
#endif

1
sys/net/transport_layer/tcp/Makefile

@ -0,0 +1 @@
include $(RIOTBASE)/Makefile.base

33
sys/net/transport_layer/tcp/tcp_hdr_print.c

@ -0,0 +1,33 @@
/*
* Copyright (C) 2017 HAW Hamburg
*
* 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
*
* @author smlng <s@mlng.net>
*/
#include <stdio.h>
#include <inttypes.h>
#include "net/tcp.h"
void tcp_hdr_print(tcp_hdr_t *hdr)
{
printf(" src-port: %5" PRIu16 " dst-port: %5" PRIu16 "\n",
byteorder_ntohs(hdr->src_port), byteorder_ntohs(hdr->dst_port));
printf(" seq-num: %10" PRIu32 " ack-num: %10" PRIu32 "\n",
byteorder_ntohl(hdr->seq_num), byteorder_ntohl(hdr->ack_num));
printf(" off_ctl: %5" PRIu16 " window: %5" PRIu16 "\n",
byteorder_ntohs(hdr->off_ctl), byteorder_ntohs(hdr->window));
printf(" cksum: 0x%04" PRIx16 " urgent_ptr: %5" PRIu16 "\n",
byteorder_ntohs(hdr->checksum), byteorder_ntohs(hdr->urgent_ptr));
}
/** @} */
Loading…
Cancel
Save