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 OPTION_H
21 #define 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 _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 _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 
68 int _option_parse(gnrc_tcp_tcb_t *tcb, tcp_hdr_t *hdr);
69 
70 #ifdef __cplusplus
71 }
72 #endif
73 
74 #endif /* OPTION_H */
75 
GNRC TCP transmission control block (TCB)
#define TCP_HDR_OFFSET_MIN
TCP offset value boundaries.
Definition: tcp.h:35
static uint16_t _option_build_offset_control(uint16_t nopts, uint16_t ctl)
Helper function to build the combined option and control flag field.
Definition: option.h:53
Transmission control block of GNRC TCP.
Definition: tcb.h:49
POSIX.1-2008 compliant version of the assert macro.
int _option_parse(gnrc_tcp_tcb_t *tcb, tcp_hdr_t *hdr)
Parses options of a given TCP header.
#define assert(cond)
abort the program if assertion is false
Definition: assert.h:104
#define TCP_OPTION_KIND_MSS
"Maximum Segment Size"-Option
Definition: tcp.h:45
TCP header definition.
Definition: tcp.h:59
#define TCP_OPTION_LENGTH_MSS
MSS Option Size always 4.
Definition: tcp.h:53
TCP header and helper functions.
static uint32_t _option_build_mss(uint16_t mss)
Helper function to build the MSS option.
Definition: option.h:39