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/rcvbuf.h

76 lines
1.7 KiB
C
Raw Normal View History

2016-02-04 14:37:35 +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.
*/
/**
* @ingroup net_gnrc_tcp
2016-02-04 14:37:35 +01:00
*
* @{
*
* @file
* @brief Functions for allocating and freeing the receive buffer.
2016-02-04 14:37:35 +01:00
*
* @author Simon Brummer <simon.brummer@posteo.de>
2016-02-04 14:37:35 +01:00
*/
#ifndef RCVBUF_H
#define RCVBUF_H
2016-02-04 14:37:35 +01:00
#include <stdint.h>
#include "mutex.h"
#include "net/gnrc/tcp/config.h"
#include "net/gnrc/tcp/tcb.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Receive buffer entry.
2016-02-04 14:37:35 +01:00
*/
typedef struct rcvbuf_entry {
uint8_t used; /**< Flag: Is buffer in use? */
uint8_t buffer[GNRC_TCP_RCV_BUF_SIZE]; /**< Receive buffer storage */
2016-02-04 14:37:35 +01:00
} rcvbuf_entry_t;
/**
2019-10-23 21:16:23 +02:00
* @brief Struct holding receive buffers.
2016-02-04 14:37:35 +01:00
*/
typedef struct rcvbuf {
mutex_t lock; /**< Lock for allocation synchronization */
rcvbuf_entry_t entries[GNRC_TCP_RCV_BUFFERS]; /**< Maintained receive buffers */
2016-02-04 14:37:35 +01:00
} rcvbuf_t;
/**
* @brief Initializes global receive buffer.
2016-02-04 14:37:35 +01:00
*/
void _rcvbuf_init(void);
/**
* @brief Allocate receive buffer and assign it to TCB.
2016-02-04 14:37:35 +01:00
*
2019-10-23 21:16:23 +02:00
* @param[in,out] tcb TCB that acquires receive buffer.
2016-02-04 14:37:35 +01:00
*
* @returns Zero on success.
* -ENOMEM if all receive buffers are currently used.
2016-02-04 14:37:35 +01:00
*/
int _rcvbuf_get_buffer(gnrc_tcp_tcb_t *tcb);
2016-02-04 14:37:35 +01:00
/**
* @brief Release allocated receive buffer.
2016-02-04 14:37:35 +01:00
*
* @param[in,out] tcb TCB holding the receive buffer that should be released.
2016-02-04 14:37:35 +01:00
*/
void _rcvbuf_release_buffer(gnrc_tcp_tcb_t *tcb);
2016-02-04 14:37:35 +01:00
#ifdef __cplusplus
}
#endif
#endif /* RCVBUF_H */
2016-02-04 14:37:35 +01:00
/** @} */