tcp.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015-2017 Simon Brummer
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
22 #ifndef NET_TCP_H
23 #define NET_TCP_H
24 
25 #include "byteorder.h"
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
35 #define TCP_HDR_OFFSET_MIN (0x05)
36 #define TCP_HDR_OFFSET_MAX (0x0F)
37 
43 #define TCP_OPTION_KIND_EOL (0x00)
44 #define TCP_OPTION_KIND_NOP (0x01)
45 #define TCP_OPTION_KIND_MSS (0x02)
52 #define TCP_OPTION_LENGTH_MIN (2U)
53 #define TCP_OPTION_LENGTH_MSS (0x04)
59 typedef struct __attribute__((packed)) {
68 } tcp_hdr_t;
69 
73 typedef struct __attribute__((packed)) {
74  uint8_t kind;
75  uint8_t length;
76  uint8_t value[];
78 
84 void tcp_hdr_print(tcp_hdr_t *hdr);
85 
86 #ifdef __cplusplus
87 }
88 #endif
89 
90 #endif /* NET_TCP_H */
91 
tcp_hdr_opt_t::length
uint8_t length
TCP options "Length" field.
Definition: tcp.h:75
be_uint32_t
A 32 bit integer in big endian aka network byte order.
Definition: byteorder.h:87
tcp_hdr_opt_t::kind
uint8_t kind
TCP options "Kind" field.
Definition: tcp.h:74
byteorder.h
Functions to work with different byte orders.
be_uint16_t
A 16 bit integer in big endian aka network byte order.
Definition: byteorder.h:77
tcp_hdr_t::src_port
network_uint16_t src_port
Source port, in network byte order.
Definition: tcp.h:60
tcp_hdr_t::urgent_ptr
network_uint16_t urgent_ptr
Urgent pointer, in network byte order.
Definition: tcp.h:67
tcp_hdr_t::ack_num
network_uint32_t ack_num
Acknowledgement number, in network byte order.
Definition: tcp.h:63
tcp_hdr_t::checksum
network_uint16_t checksum
Checksum, in network byte order.
Definition: tcp.h:66
tcp_hdr_t
TCP header definition.
Definition: tcp.h:59
tcp_hdr_opt_t
TCP option field helper structure.
Definition: tcp.h:73
tcp_hdr_print
void tcp_hdr_print(tcp_hdr_t *hdr)
Print the given TCP header to STDOUT.
tcp_hdr_t::seq_num
network_uint32_t seq_num
Sequence number, in network byte order.
Definition: tcp.h:62
tcp_hdr_t::off_ctl
network_uint16_t off_ctl
Data Offset and control Bits in network byte order.
Definition: tcp.h:64
tcp_hdr_t::window
network_uint16_t window
Window, in network byte order.
Definition: tcp.h:65
tcp_hdr_t::dst_port
network_uint16_t dst_port
Destination port, in network byte order.
Definition: tcp.h:61