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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2019-07-07 12:07:56 +02:00
|
|
|
* @ingroup net_gnrc_tcp
|
2016-02-04 14:37:35 +01:00
|
|
|
*
|
|
|
|
* @{
|
|
|
|
*
|
|
|
|
* @file
|
2017-03-06 08:47:06 +01:00
|
|
|
* @brief TCP finite state maschine 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-05-23 18:19:52 +02:00
|
|
|
#ifndef FSM_H
|
|
|
|
#define FSM_H
|
2016-02-04 14:37:35 +01:00
|
|
|
|
2017-02-26 17:31:23 +01:00
|
|
|
#include <stdint.h>
|
2018-07-10 15:25:02 +02:00
|
|
|
#include "net/gnrc.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-02-01 15:43:16 +01:00
|
|
|
/**
|
2017-03-06 08:47:06 +01:00
|
|
|
* @brief The TCP FSM states.
|
2017-02-01 15:43:16 +01:00
|
|
|
*/
|
|
|
|
typedef enum {
|
2017-04-26 13:37:42 +02:00
|
|
|
FSM_STATE_CLOSED = 0,
|
2017-02-01 15:43:16 +01:00
|
|
|
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;
|
|
|
|
|
|
|
|
/**
|
2017-03-06 08:47:06 +01:00
|
|
|
* @brief Events that trigger transitions in TCP FSM.
|
2017-02-01 15:43:16 +01:00
|
|
|
*/
|
|
|
|
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 */
|
2017-03-06 08:47:06 +01:00
|
|
|
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 */
|
2017-02-01 15:43:16 +01:00
|
|
|
} fsm_event_t;
|
|
|
|
|
2016-02-04 14:37:35 +01:00
|
|
|
/**
|
|
|
|
* @brief TCP finite state maschine
|
|
|
|
*
|
2017-03-06 08:47:06 +01:00
|
|
|
* @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.
|
2016-02-04 14:37:35 +01:00
|
|
|
*
|
2017-03-06 08:47:06 +01:00
|
|
|
* @returns Zero on success
|
|
|
|
* Positive Number, number of bytes sent from or copied into @p buf.
|
|
|
|
* -ENOSYS if event is not implemented
|
2016-02-04 14:37:35 +01:00
|
|
|
*/
|
2017-02-04 10:19:59 +01:00
|
|
|
int _fsm(gnrc_tcp_tcb_t *tcb, fsm_event_t event, gnrc_pktsnip_t *in_pkt, void *buf, size_t len);
|
2016-02-04 14:37:35 +01:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-05-23 18:19:52 +02:00
|
|
|
#endif /* FSM_H */
|
2016-02-04 14:37:35 +01:00
|
|
|
/** @} */
|