1 /* 2 * FreeRTOS+TCP <DEVELOPMENT BRANCH> 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 /* 69 * Return either a newly created socket, or the current socket in a connected 70 * state (depends on the 'bReuseSocket' flag). 71 */ 72 FreeRTOS_Socket_t * prvHandleListen_IPV4( FreeRTOS_Socket_t * pxSocket, 73 NetworkBufferDescriptor_t * pxNetworkBuffer ); 74 75 /* 76 * Return either a newly created socket, or the current socket in a connected 77 * state (depends on the 'bReuseSocket' flag). 78 */ 79 FreeRTOS_Socket_t * prvHandleListen_IPV6( FreeRTOS_Socket_t * pxSocket, 80 NetworkBufferDescriptor_t * pxNetworkBuffer ); 81 82 /* 83 * Common code for sending a TCP protocol control packet (i.e. no options, no 84 * payload, just flags). 85 */ 86 BaseType_t prvTCPSendSpecialPacketHelper( NetworkBufferDescriptor_t * pxNetworkBuffer, 87 uint8_t ucTCPFlags ); 88 89 /* 90 * Common code for sending a TCP protocol control packet (i.e. no options, no 91 * payload, just flags). 92 */ 93 BaseType_t prvTCPSendSpecialPktHelper_IPV4( NetworkBufferDescriptor_t * pxNetworkBuffer, 94 uint8_t ucTCPFlags ); 95 96 /* 97 * Common code for sending a TCP protocol control packet (i.e. no options, no 98 * payload, just flags). 99 */ 100 BaseType_t prvTCPSendSpecialPktHelper_IPV6( NetworkBufferDescriptor_t * pxNetworkBuffer, 101 uint8_t ucTCPFlags ); 102 103 /* 104 * After a listening socket receives a new connection, it may duplicate itself. 105 * The copying takes place in prvTCPSocketCopy. 106 */ 107 BaseType_t prvTCPSocketCopy( FreeRTOS_Socket_t * pxNewSocket, 108 FreeRTOS_Socket_t * pxSocket ); 109 110 111 /* *INDENT-OFF* */ 112 #ifdef __cplusplus 113 } /* extern "C" */ 114 #endif 115 /* *INDENT-ON* */ 116 117 #endif /* FREERTOS_TCP_STATE_HANDLING_H */ 118