Blame view

RIOT/sys/net/gnrc/transport_layer/tcp/internal/rcvbuf.h 1.75 KB
a752c7ab   elopes   add first test an...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
  /*
   * 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       Functions for allocating and freeing the receive buffer.
   *
   * @author      Simon Brummer <simon.brummer@posteo.de>
   */
  
  #ifndef RCVBUF_H
  #define RCVBUF_H
  
  #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.
   */
  typedef struct rcvbuf_entry {
      uint8_t used;                          /**< Flag: Is buffer in use? */
      uint8_t buffer[GNRC_TCP_RCV_BUF_SIZE]; /**< Receive buffer storage */
  } rcvbuf_entry_t;
  
  /**
   * @brief   Stuct holding receive buffers.
   */
  typedef struct rcvbuf {
      mutex_t lock;                                 /**< Lock for allocation synchronization */
      rcvbuf_entry_t entries[GNRC_TCP_RCV_BUFFERS]; /**< Maintained receive buffers */
  } rcvbuf_t;
  
  /**
   * @brief   Initializes global receive buffer.
   */
  void _rcvbuf_init(void);
  
  /**
   * @brief Allocate receive buffer and assign it to TCB.
   *
   * @param[in,out] tcb   TCB that aquires receive buffer.
   *
   * @returns   Zero  on success.
   *            -ENOMEM if all receive buffers are currently used.
   */
  int _rcvbuf_get_buffer(gnrc_tcp_tcb_t *tcb);
  
  /**
   * @brief Release allocated receive buffer.
   *
   * @param[in,out] tcb   TCB holding the receive buffer that should be released.
   */
  void _rcvbuf_release_buffer(gnrc_tcp_tcb_t *tcb);
  
  #ifdef __cplusplus
  }
  #endif
  
  #endif /* RCVBUF_H */
  /** @} */