2016-02-04 14:37:35 +01:00
|
|
|
/*
|
2017-02-01 16:33:31 +01:00
|
|
|
* Copyright (C) 2017 Simon Brummer
|
2016-02-04 14:37:35 +01:00
|
|
|
*
|
|
|
|
* 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 stack
|
|
|
|
*
|
|
|
|
* @{
|
|
|
|
*
|
|
|
|
* @file
|
2017-02-01 16:33:31 +01:00
|
|
|
* @brief TCP option handling function declaration
|
2016-02-04 14:37:35 +01:00
|
|
|
*
|
2017-02-01 16:33:31 +01:00
|
|
|
* @author Simon Brummer <simon.brummer@posteo.de>
|
2016-02-04 14:37:35 +01:00
|
|
|
*/
|
|
|
|
|
2017-02-01 15:51:26 +01:00
|
|
|
#ifndef GNRC_TCP_INTERNAL_OPTION_H
|
|
|
|
#define GNRC_TCP_INTERNAL_OPTION_H
|
2016-02-04 14:37:35 +01:00
|
|
|
|
2017-02-04 10:19:59 +01:00
|
|
|
#include "assert.h"
|
2017-01-28 14:40:24 +01:00
|
|
|
#include "net/tcp.h"
|
2016-02-04 14:37:35 +01:00
|
|
|
#include "net/gnrc/tcp.h"
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Helper Function to build the MSS Option
|
|
|
|
*
|
|
|
|
* @param[in] mss tcp header to be checked
|
|
|
|
*
|
|
|
|
* @return Valid MSS Option.
|
|
|
|
*/
|
2017-02-04 10:19:59 +01:00
|
|
|
inline static uint32_t _option_build_mss(uint16_t mss)
|
|
|
|
{
|
|
|
|
return (((uint32_t) TCP_OPTION_KIND_MSS << 24) |
|
|
|
|
((uint32_t) TCP_OPTION_LENGTH_MSS << 16) | mss);
|
|
|
|
}
|
2016-02-04 14:37:35 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Helper Function to build the combined option and control flag field
|
|
|
|
*
|
|
|
|
* @param[in] nopts Number of Options
|
|
|
|
* @param[in] ctl Control Flags
|
|
|
|
*
|
|
|
|
* @return Valid option size and control field.
|
|
|
|
*/
|
2017-02-04 10:19:59 +01:00
|
|
|
inline static 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;
|
|
|
|
}
|
2016-02-04 14:37:35 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Parses options of a given tcp-header pktsnip.
|
|
|
|
*
|
|
|
|
* @param[out] tcb transmission control block to memorize options.
|
|
|
|
* @param[in] hdr tcp header to be checked
|
|
|
|
*
|
|
|
|
* @return Zero on success
|
|
|
|
* @return A negative value on error
|
|
|
|
*/
|
2017-02-04 10:19:59 +01:00
|
|
|
int _option_parse(gnrc_tcp_tcb_t *tcb, tcp_hdr_t *hdr);
|
2016-02-04 14:37:35 +01:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-02-01 15:51:26 +01:00
|
|
|
#endif /* GNRC_TCP_INTERNAL_OPTION_H*/
|
2016-02-04 14:37:35 +01:00
|
|
|
/** @} */
|