gnrc_tcp_option.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 
20 #ifndef GNRC_TCP_OPTION_H
21 #define GNRC_TCP_OPTION_H
22 
23 #include <stdint.h>
24 #include "assert.h"
25 #include "net/tcp.h"
26 #include "net/gnrc/tcp/tcb.h"
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
39 static inline uint32_t _gnrc_tcp_option_build_mss(uint16_t mss)
40 {
41  return (((uint32_t) TCP_OPTION_KIND_MSS << 24) |
42  ((uint32_t) TCP_OPTION_LENGTH_MSS << 16) | mss);
43 }
44 
53 static inline uint16_t _gnrc_tcp_option_build_offset_control(uint16_t nopts, uint16_t ctl)
54 {
55  assert(TCP_HDR_OFFSET_MIN <= nopts && nopts <= TCP_HDR_OFFSET_MAX);
56  return (nopts << 12) | ctl;
57 }
58 
69 
70 #ifdef __cplusplus
71 }
72 #endif
73 
74 #endif /* GNRC_TCP_OPTION_H */
75 
assert
#define assert(cond)
abort the program if assertion is false
Definition: assert.h:104
assert.h
POSIX.1-2008 compliant version of the assert macro.
TCP_HDR_OFFSET_MIN
#define TCP_HDR_OFFSET_MIN
TCP offset value boundaries.
Definition: tcp.h:35
_gnrc_tcp_option_build_mss
static uint32_t _gnrc_tcp_option_build_mss(uint16_t mss)
Helper function to build the MSS option.
Definition: gnrc_tcp_option.h:39
_gnrc_tcp_option_parse
int _gnrc_tcp_option_parse(gnrc_tcp_tcb_t *tcb, tcp_hdr_t *hdr)
Parses options of a given TCP header.
_transmission_control_block
Transmission control block of GNRC TCP.
Definition: tcb.h:45
_gnrc_tcp_option_build_offset_control
static uint16_t _gnrc_tcp_option_build_offset_control(uint16_t nopts, uint16_t ctl)
Helper function to build the combined option and control flag field.
Definition: gnrc_tcp_option.h:53
tcp_hdr_t
TCP header definition.
Definition: tcp.h:59
TCP_OPTION_KIND_MSS
#define TCP_OPTION_KIND_MSS
"Maximum Segment Size"-Option
Definition: tcp.h:45
tcp.h
TCP header and helper functions.
tcb.h
GNRC TCP transmission control block (TCB)
TCP_OPTION_LENGTH_MSS
#define TCP_OPTION_LENGTH_MSS
MSS Option Size always 4.
Definition: tcp.h:53