1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/sys/net/gnrc/transport_layer/tcp/internal/option.h
smlng b283b7784c make: fix various compile errors with Wextra
pkg, nordic_softdevice_ble: disable CFLAGS to omit compiler error
        sys, pm_layered: fix casting nonscalar to the same type
        cpu, stm32_common: fix type-limits, remove always true assert
        cpu, stm32f4: fix pointer arithmetic in periph/i2c
        drivers, at86rf2xx: fix type-limits where condition always true
        saul, gpio: fix if no gpio configured for saul
        cpu, saml21: add frequency check to periph/timer
        driver, cc110x: fix unused param and type-limts errors
        boards, wsn430-common: fix old-style-declaration
        make: fix old style definition
        drivers, sdcard_spi: fix old style typedef
        driver, at30tse: remove unnecessary check
        driver, nrf24: fix type-limit
        driver, pn532: change buffer from char to uint8_t
        tests/driver_sdcard: fix type limits
        boards, feather-m0: add missing field inits
        driver, tcs37727: fix type limits
        pkg, emb6: disable some compiler warnings
        tests/emb6: disable some compiler warings
        pkg, openthread: fix sign compare and unused params
        tests/trickle: fix struct init
        tests/pthread_cooperation: fix type limits
        board, mips-malta: remove feature periph_uart
        shell: fix var size for netif command
        gnrc, netif: fix sign-compare
        gnrc, nib: fix sign-compare
        shell: fix output in netif command
        posix: fix type-limits in pthread_cond
2017-11-28 18:31:43 +01:00

78 lines
1.7 KiB
C

/*
* Copyright (C) 2015-2017 Simon Brummer
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @defgroup net_gnrc_tcp TCP
* @ingroup net_gnrc
* @brief RIOT's TCP implementation for the GNRC network stack.
*
* @{
*
* @file
* @brief TCP option handling declarations.
*
* @author Simon Brummer <simon.brummer@posteo.de>
*/
#ifndef OPTION_H
#define OPTION_H
#include <stdint.h>
#include "assert.h"
#include "net/tcp.h"
#include "net/gnrc/tcp/tcb.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Helper function to build the MSS option.
*
* @param[in] mss MSS value that should be set.
*
* @returns MSS option value.
*/
static inline uint32_t _option_build_mss(uint16_t mss)
{
return (((uint32_t) TCP_OPTION_KIND_MSS << 24) |
((uint32_t) TCP_OPTION_LENGTH_MSS << 16) | mss);
}
/**
* @brief Helper function to build the combined option and control flag field.
*
* @param[in] nopts Number of options.
* @param[in] ctl Control flag field.
*
* @returns Bitfield with encoded control bits and number of options.
*/
static inline uint16_t _option_build_offset_control(uint16_t nopts, uint16_t ctl)
{
assert(TCP_HDR_OFFSET_MIN <= nopts && nopts <= TCP_HDR_OFFSET_MAX);
return (nopts << 12) | ctl;
}
/**
* @brief Parses options of a given TCP header.
*
* @param[in,out] tcb TCB holding the connection information.
* @param[in] hdr TCP header to be parsed.
*
* @returns Zero on success.
* Negative value on error.
*/
int _option_parse(gnrc_tcp_tcb_t *tcb, tcp_hdr_t *hdr);
#ifdef __cplusplus
}
#endif
#endif /* OPTION_H */
/** @} */