diff --git a/Makefile.dep b/Makefile.dep index e8732e8e13c281c57e46304c4627ea97f394d2c9..0590f995818044cf291a3b41d252bf959b1f9d74 100644 --- a/Makefile.dep +++ b/Makefile.dep @@ -341,6 +341,7 @@ endif ifneq (,$(filter gnrc_tcp,$(USEMODULE))) USEMODULE += inet_csum USEMODULE += random + USEMODULE += tcp USEMODULE += xtimer endif diff --git a/sys/Makefile b/sys/Makefile index 75102da22901f9496c001986ea06323099b6edad..5405e7b5f0061afd45e793c1c06507a32f0a6786 100644 --- a/sys/Makefile +++ b/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 diff --git a/sys/include/net/tcp.h b/sys/include/net/tcp.h index 64d7739cddeca22f60378985f089cecfd9b5be63..e42bb06ce5fa5504c64632e6e4450ec3c8f13602 100644 --- a/sys/include/net/tcp.h +++ b/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 diff --git a/sys/net/transport_layer/tcp/Makefile b/sys/net/transport_layer/tcp/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..48422e909a47d7cd428d10fa73825060ccc8d8c2 --- /dev/null +++ b/sys/net/transport_layer/tcp/Makefile @@ -0,0 +1 @@ +include $(RIOTBASE)/Makefile.base diff --git a/sys/net/transport_layer/tcp/tcp_hdr_print.c b/sys/net/transport_layer/tcp/tcp_hdr_print.c new file mode 100644 index 0000000000000000000000000000000000000000..b7dfcb50d2d0016e77b0006e0e9582e1c72b158f --- /dev/null +++ b/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)); +} +/** @} */