tcp_fsm.h
Go to the documentation of this file.
1 /**
2  * @file tcp_fsm.h
3  * @brief TCP finite state machine
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneTCP Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.4.0
29  **/
30 
31 #ifndef _TCP_FSM_H
32 #define _TCP_FSM_H
33 
34 //Dependencies
35 #include "core/tcp.h"
36 
37 //C++ guard
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 //TCP FSM related functions
43 void tcpProcessSegment(NetInterface *interface,
44  const IpPseudoHeader *pseudoHeader, const NetBuffer *buffer, size_t offset,
45  const NetRxAncillary *ancillary);
46 
47 void tcpStateClosed(NetInterface *interface, const IpPseudoHeader *pseudoHeader,
48  const TcpHeader *segment, size_t length);
49 
50 void tcpStateListen(Socket *socket, NetInterface *interface,
51  const IpPseudoHeader *pseudoHeader, const TcpHeader *segment, size_t length);
52 
53 void tcpStateSynSent(Socket *socket, const TcpHeader *segment, size_t length);
54 
55 void tcpStateSynReceived(Socket *socket, const TcpHeader *segment,
56  const NetBuffer *buffer, size_t offset, size_t length);
57 
58 void tcpStateEstablished(Socket *socket, const TcpHeader *segment,
59  const NetBuffer *buffer, size_t offset, size_t length);
60 
61 void tcpStateCloseWait(Socket *socket, const TcpHeader *segment, size_t length);
62 
63 void tcpStateLastAck(Socket *socket, const TcpHeader *segment, size_t length);
64 
65 void tcpStateFinWait1(Socket *socket, const TcpHeader *segment,
66  const NetBuffer *buffer, size_t offset, size_t length);
67 
68 void tcpStateFinWait2(Socket *socket, const TcpHeader *segment,
69  const NetBuffer *buffer, size_t offset, size_t length);
70 
71 void tcpStateClosing(Socket *socket, const TcpHeader *segment, size_t length);
72 
73 void tcpStateTimeWait(Socket *socket, const TcpHeader *segment, size_t length);
74 
75 //C++ guard
76 #ifdef __cplusplus
77 }
78 #endif
79 
80 #endif
int_t socket(int_t family, int_t type, int_t protocol)
Create a socket that is bound to a specific transport service provider.
Definition: bsd_socket.c:65
#define NetInterface
Definition: net.h:36
#define NetRxAncillary
Definition: net_misc.h:40
#define Socket
Definition: socket.h:36
IP pseudo header.
Definition: ip.h:99
Structure describing a buffer that spans multiple chunks.
Definition: net_mem.h:89
TCP (Transmission Control Protocol)
uint8_t length
Definition: tcp.h:368
TcpHeader
Definition: tcp.h:358
void tcpStateClosing(Socket *socket, const TcpHeader *segment, size_t length)
CLOSING state.
Definition: tcp_fsm.c:1254
void tcpStateListen(Socket *socket, NetInterface *interface, const IpPseudoHeader *pseudoHeader, const TcpHeader *segment, size_t length)
LISTEN state.
Definition: tcp_fsm.c:467
void tcpStateFinWait1(Socket *socket, const TcpHeader *segment, const NetBuffer *buffer, size_t offset, size_t length)
FIN-WAIT-1 state.
Definition: tcp_fsm.c:1094
void tcpStateSynSent(Socket *socket, const TcpHeader *segment, size_t length)
SYN-SENT state.
Definition: tcp_fsm.c:652
void tcpStateCloseWait(Socket *socket, const TcpHeader *segment, size_t length)
CLOSE-WAIT state.
Definition: tcp_fsm.c:986
void tcpStateEstablished(Socket *socket, const TcpHeader *segment, const NetBuffer *buffer, size_t offset, size_t length)
ESTABLISHED state.
Definition: tcp_fsm.c:900
void tcpStateClosed(NetInterface *interface, const IpPseudoHeader *pseudoHeader, const TcpHeader *segment, size_t length)
CLOSED state.
Definition: tcp_fsm.c:439
void tcpStateTimeWait(Socket *socket, const TcpHeader *segment, size_t length)
TIME-WAIT state.
Definition: tcp_fsm.c:1307
void tcpStateFinWait2(Socket *socket, const TcpHeader *segment, const NetBuffer *buffer, size_t offset, size_t length)
FIN-WAIT-2 state.
Definition: tcp_fsm.c:1185
void tcpProcessSegment(NetInterface *interface, const IpPseudoHeader *pseudoHeader, const NetBuffer *buffer, size_t offset, const NetRxAncillary *ancillary)
Incoming TCP segment processing.
Definition: tcp_fsm.c:73
void tcpStateLastAck(Socket *socket, const TcpHeader *segment, size_t length)
LAST-ACK state.
Definition: tcp_fsm.c:1045
void tcpStateSynReceived(Socket *socket, const TcpHeader *segment, const NetBuffer *buffer, size_t offset, size_t length)
SYN-RECEIVED state.
Definition: tcp_fsm.c:798