Blame view

RIOT/sys/net/gnrc/transport_layer/tcp/internal/fsm.h 2.44 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
78
79
80
81
82
83
84
85
86
87
  /*
   * 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 finite state maschine declarations.
   *
   * @author      Simon Brummer <simon.brummer@posteo.de>
   */
  
  #ifndef FSM_H
  #define FSM_H
  
  #include <stdint.h>
  #include "net/gnrc/pkt.h"
  #include "net/gnrc/tcp/tcb.h"
  
  #ifdef __cplusplus
  extern "C" {
  #endif
  
  /**
   *  @brief The TCP FSM states.
   */
  typedef enum {
      FSM_STATE_CLOSED = 0,
      FSM_STATE_LISTEN,
      FSM_STATE_SYN_SENT,
      FSM_STATE_SYN_RCVD,
      FSM_STATE_ESTABLISHED,
      FSM_STATE_CLOSE_WAIT,
      FSM_STATE_LAST_ACK,
      FSM_STATE_FIN_WAIT_1,
      FSM_STATE_FIN_WAIT_2,
      FSM_STATE_CLOSING,
      FSM_STATE_TIME_WAIT
  } fsm_state_t;
  
  /**
   *  @brief Events that trigger transitions in TCP FSM.
   */
  typedef enum {
      FSM_EVENT_CALL_OPEN,          /* User function call: open */
      FSM_EVENT_CALL_SEND,          /* User function call: send */
      FSM_EVENT_CALL_RECV,          /* User function call: recv */
      FSM_EVENT_CALL_CLOSE,         /* User function call: close */
      FSM_EVENT_CALL_ABORT,         /* User function call: abort */
      FSM_EVENT_RCVD_PKT,           /* Paket received from peer */
      FSM_EVENT_TIMEOUT_TIMEWAIT,   /* Timeout: timewait */
      FSM_EVENT_TIMEOUT_RETRANSMIT, /* Timeout: retransmit */
      FSM_EVENT_TIMEOUT_CONNECTION, /* Timeout: connection */
      FSM_EVENT_SEND_PROBE,         /* Send zero window probe */
      FSM_EVENT_CLEAR_RETRANSMIT    /* Clear retransmission mechanism */
  } fsm_event_t;
  
  /**
   * @brief TCP finite state maschine
   *
   * @param[in,out] tcb     TCB holding the connection information.
   * @param[in]     event   Current event that triggers FSM transition.
   * @param[in]     in_pkt  Incomming packet. Only not NULL in case of event RCVD_PKT.
   * @param[in,out] buf     Buffer for send and receive functions.
   * @param[in]     len     Number of bytes to send or receive.
   *
   * @returns   Zero on success
   *            Positive Number, number of bytes sent from or copied into @p buf.
   *            -ENOSYS if event is not implemented
   */
  int _fsm(gnrc_tcp_tcb_t *tcb, fsm_event_t event, gnrc_pktsnip_t *in_pkt, void *buf, size_t len);
  
  #ifdef __cplusplus
  }
  #endif
  
  #endif /* FSM_H */
  /** @} */