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 
9 #pragma once
10 
24 #include "byteorder.h"
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
34 #define TCP_HDR_OFFSET_MIN (0x05)
35 #define TCP_HDR_OFFSET_MAX (0x0F)
42 #define TCP_OPTION_KIND_EOL (0x00)
43 #define TCP_OPTION_KIND_NOP (0x01)
44 #define TCP_OPTION_KIND_MSS (0x02)
51 #define TCP_OPTION_LENGTH_MIN (2U)
52 #define TCP_OPTION_LENGTH_MSS (0x04)
58 typedef struct __attribute__((packed)) {
67 } tcp_hdr_t;
68 
72 typedef struct __attribute__((packed)) {
73  uint8_t kind;
74  uint8_t length;
75  uint8_t value[];
77 
84 
85 #ifdef __cplusplus
86 }
87 #endif
88 
Functions to work with different byte orders.
void tcp_hdr_print(tcp_hdr_t *hdr)
Print the given TCP header to STDOUT.
TCP option field helper structure.
Definition: tcp.h:72
uint8_t kind
TCP options "Kind" field.
Definition: tcp.h:73
uint8_t length
TCP options "Length" field.
Definition: tcp.h:74
TCP header definition.
Definition: tcp.h:58
network_uint16_t dst_port
Destination port, in network byte order.
Definition: tcp.h:60
network_uint16_t src_port
Source port, in network byte order.
Definition: tcp.h:59
network_uint32_t ack_num
Acknowledgement number, in network byte order.
Definition: tcp.h:62
network_uint16_t urgent_ptr
Urgent pointer, in network byte order.
Definition: tcp.h:66
network_uint32_t seq_num
Sequence number, in network byte order.
Definition: tcp.h:61
network_uint16_t window
Window, in network byte order.
Definition: tcp.h:64
network_uint16_t checksum
Checksum, in network byte order.
Definition: tcp.h:65
network_uint16_t off_ctl
Data Offset and control Bits in network byte order.
Definition: tcp.h:63
A 16 bit integer in big endian aka network byte order.
Definition: byteorder.h:73
A 32 bit integer in big endian aka network byte order.
Definition: byteorder.h:83