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.4
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
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 
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
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
Structure describing a buffer that spans multiple chunks.
Definition: net_mem.h:89
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 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 tcpStateSynReceived(Socket *socket, const TcpHeader *segment, const NetBuffer *buffer, size_t offset, size_t length)
SYN-RECEIVED state.
Definition: tcp_fsm.c:798
void tcpStateTimeWait(Socket *socket, const TcpHeader *segment, size_t length)
TIME-WAIT state.
Definition: tcp_fsm.c:1307
void tcpStateCloseWait(Socket *socket, const TcpHeader *segment, size_t length)
CLOSE-WAIT state.
Definition: tcp_fsm.c:986
IP pseudo header.
Definition: ip.h:110
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
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
#define NetRxAncillary
Definition: net_misc.h:40
#define NetInterface
Definition: net.h:36
NetInterface * interface
Definition: tcp.h:402
uint8_t length
Definition: tcp.h:368
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 tcpStateSynSent(Socket *socket, const TcpHeader *segment, size_t length)
SYN-SENT state.
Definition: tcp_fsm.c:652
TCP (Transmission Control Protocol)
#define Socket
Definition: socket.h:36
void tcpStateLastAck(Socket *socket, const TcpHeader *segment, size_t length)
LAST-ACK state.
Definition: tcp_fsm.c:1045
TcpHeader
Definition: tcp.h:358