2016-02-04 14:37:35 +01:00
|
|
|
/*
|
2017-02-06 18:26:45 +01:00
|
|
|
* Copyright (C) 2015-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
|
2017-03-06 08:47:06 +01:00
|
|
|
* @brief RIOT's TCP implementation for the GNRC network stack.
|
2016-02-04 14:37:35 +01:00
|
|
|
*
|
|
|
|
* @{
|
|
|
|
*
|
|
|
|
* @file
|
2017-03-06 08:47:06 +01:00
|
|
|
* @brief TCP option handling declarations.
|
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-26 17:31:23 +01:00
|
|
|
#include <stdint.h>
|
2017-02-04 10:19:59 +01:00
|
|
|
#include "assert.h"
|
2017-01-28 14:40:24 +01:00
|
|
|
#include "net/tcp.h"
|
2017-02-26 17:31:23 +01:00
|
|
|
#include "net/gnrc/tcp/tcb.h"
|
2016-02-04 14:37:35 +01:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
2017-03-06 08:47:06 +01:00
|
|
|
* @brief Helper function to build the MSS option.
|
2016-02-04 14:37:35 +01:00
|
|
|
*
|
2017-03-06 08:47:06 +01:00
|
|
|
* @param[in] mss MSS value that should be set.
|
2016-02-04 14:37:35 +01:00
|
|
|
*
|
2017-03-06 08:47:06 +01:00
|
|
|
* @returns MSS option value.
|
2016-02-04 14:37:35 +01:00
|
|
|
*/
|
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
|
|
|
|
|
|
|
/**
|
2017-03-06 08:47:06 +01:00
|
|
|
* @brief Helper function to build the combined option and control flag field.
|
2016-02-04 14:37:35 +01:00
|
|
|
*
|
2017-03-06 08:47:06 +01:00
|
|
|
* @param[in] nopts Number of options.
|
|
|
|
* @param[in] ctl Control flag field.
|
2016-02-04 14:37:35 +01:00
|
|
|
*
|
2017-03-06 08:47:06 +01:00
|
|
|
* @returns Bitfield with encoded control bits and number of options.
|
2016-02-04 14:37:35 +01:00
|
|
|
*/
|
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
|
|
|
|
|
|
|
/**
|
2017-03-06 08:47:06 +01:00
|
|
|
* @brief Parses options of a given TCP header.
|
2016-02-04 14:37:35 +01:00
|
|
|
*
|
2017-03-06 08:47:06 +01:00
|
|
|
* @param[in,out] tcb TCB holding the connection information.
|
|
|
|
* @param[in] hdr TCP header to be parsed.
|
2016-02-04 14:37:35 +01:00
|
|
|
*
|
2017-03-06 08:47:06 +01:00
|
|
|
* @returns Zero on success.
|
|
|
|
* Negative value on error.
|
2016-02-04 14:37:35 +01:00
|
|
|
*/
|
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
|
|
|
/** @} */
|