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 
22 #ifndef GNRC_TCP_INTERNAL_OPTION_H
23 #define GNRC_TCP_INTERNAL_OPTION_H
24 
25 #include <stdint.h>
26 #include "assert.h"
27 #include "net/tcp.h"
28 #include "net/gnrc/tcp/tcb.h"
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
41 inline static uint32_t _option_build_mss(uint16_t mss)
42 {
43  return (((uint32_t) TCP_OPTION_KIND_MSS << 24) |
44  ((uint32_t) TCP_OPTION_LENGTH_MSS << 16) | mss);
45 }
46 
55 inline static uint16_t _option_build_offset_control(uint16_t nopts, uint16_t ctl)
56 {
57  assert(TCP_HDR_OFFSET_MIN <= nopts && nopts <= TCP_HDR_OFFSET_MAX);
58  return (nopts << 12) | ctl;
59 }
60 
70 int _option_parse(gnrc_tcp_tcb_t *tcb, tcp_hdr_t *hdr);
71 
72 #ifdef __cplusplus
73 }
74 #endif
75 
76 #endif /* GNRC_TCP_INTERNAL_OPTION_H*/
77 
GNRC TCP transmission control block.
#define TCP_HDR_OFFSET_MIN
TCP offset value boundries.
Definition: tcp.h:35
int _option_parse(gnrc_tcp_tcb_t *tcb, tcp_hdr_t *hdr)
Parses options of a given tcp-header pktsnip.
transmission control block of gnrc_tcp
Definition: tcb.h:50
POSIX.1-2008 compliant version of the assert macro.
#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
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:55
TCP header definition.
Definition: tcp.h:58
static uint32_t _option_build_mss(uint16_t mss)
Helper Function to build the MSS Option.
Definition: option.h:41
#define TCP_OPTION_LENGTH_MSS
TCP Option Length Field Values.
Definition: tcp.h:52
TCP header and helper functions.