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