1 /*
2  * FreeRTOS+TCP V3.1.0
3  * Copyright (C) 2022 Amazon.com, Inc. or its affiliates.  All Rights Reserved.
4  *
5  * SPDX-License-Identifier: MIT
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a copy of
8  * this software and associated documentation files (the "Software"), to deal in
9  * the Software without restriction, including without limitation the rights to
10  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
11  * the Software, and to permit persons to whom the Software is furnished to do so,
12  * subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be included in all
15  * copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
19  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  *
24  * http://aws.amazon.com/freertos
25  * http://www.FreeRTOS.org
26  */
27 
28 #ifndef FREERTOS_TCP_STATE_HANDLING_H
29 #define FREERTOS_TCP_STATE_HANDLING_H
30 
31 #include "FreeRTOS_TCP_IP.h"
32 
33 /* *INDENT-OFF* */
34 #ifdef __cplusplus
35     extern "C" {
36 #endif
37 /* *INDENT-ON* */
38 
39 /*
40  * Returns true if the socket must be checked.  Non-active sockets are waiting
41  * for user action, either connect() or close().
42  */
43 BaseType_t prvTCPSocketIsActive( eIPTCPState_t eStatus );
44 
45 /*
46  * prvTCPStatusAgeCheck() will see if the socket has been in a non-connected
47  * state for too long.  If so, the socket will be closed, and -1 will be
48  * returned.
49  */
50 #if ( ipconfigTCP_HANG_PROTECTION == 1 )
51     BaseType_t prvTCPStatusAgeCheck( FreeRTOS_Socket_t * pxSocket );
52 #endif
53 
54 /*
55  * The heart of all: check incoming packet for valid data and acks and do what
56  * is necessary in each state.
57  */
58 BaseType_t prvTCPHandleState( FreeRTOS_Socket_t * pxSocket,
59                               NetworkBufferDescriptor_t ** ppxNetworkBuffer );
60 
61 /*
62  * Return either a newly created socket, or the current socket in a connected
63  * state (depends on the 'bReuseSocket' flag).
64  */
65 FreeRTOS_Socket_t * prvHandleListen( FreeRTOS_Socket_t * pxSocket,
66                                      NetworkBufferDescriptor_t * pxNetworkBuffer );
67 
68 /* *INDENT-OFF* */
69 #ifdef __cplusplus
70     } /* extern "C" */
71 #endif
72 /* *INDENT-ON* */
73 
74 #endif /* FREERTOS_TCP_STATE_HANDLING_H */
75