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 /** 29 * @file FreeRTOS_IP_Timers.h 30 * @brief Header file for IP Timers on FreeRTOS+TCP network stack. 31 */ 32 33 #ifndef FREERTOS_IP_TIMERS_H 34 #define FREERTOS_IP_TIMERS_H 35 36 /* Standard includes. */ 37 #include <stdint.h> 38 #include <stdio.h> 39 #include <string.h> 40 41 /* FreeRTOS includes. */ 42 #include "FreeRTOS.h" 43 #include "task.h" 44 #include "queue.h" 45 #include "semphr.h" 46 47 /* FreeRTOS+TCP includes. */ 48 #include "FreeRTOS_IP.h" 49 #include "FreeRTOS_Sockets.h" 50 #include "FreeRTOS_IP_Private.h" 51 #include "FreeRTOS_ARP.h" 52 #include "FreeRTOS_UDP_IP.h" 53 #include "FreeRTOS_DHCP.h" 54 #include "NetworkInterface.h" 55 #include "NetworkBufferManagement.h" 56 #include "FreeRTOS_DNS.h" 57 58 /* *INDENT-OFF* */ 59 #ifdef __cplusplus 60 extern "C" { 61 #endif 62 /* *INDENT-ON* */ 63 64 /* 65 * Checks the ARP, DHCP and TCP timers to see if any periodic or timeout 66 * processing is required. 67 */ 68 void vCheckNetworkTimers( void ); 69 70 /* 71 * Determine how long the IP task can sleep for, which depends on when the next 72 * periodic or timeout processing must be performed. 73 */ 74 TickType_t xCalculateSleepTime( void ); 75 76 /* 77 * Start an ARP Resolution timer. 78 */ 79 void vIPTimerStartARPResolution( TickType_t xTime ); 80 81 /* 82 * Enable/disable the TCP timer. 83 */ 84 void vIPSetTCPTimerExpiredState( BaseType_t xExpiredState ); 85 86 /* 87 * Enable/disable the ARP timer. 88 */ 89 void vIPSetARPTimerEnableState( BaseType_t xEnableState ); 90 91 /* 92 * Enable or disable the ARP resolution timer. 93 */ 94 void vIPSetARPResolutionTimerEnableState( BaseType_t xEnableState ); 95 96 #if ( ipconfigUSE_DHCP == 1 ) || ( ipconfigUSE_RA == 1 ) 97 98 /** 99 * @brief Enable/disable the DHCP/RA timer. 100 * @param[in] pxEndPoint: The end-point for which the timer will be called. 101 * @param[in] xEnableState: pdTRUE - enable timer; pdFALSE - disable timer. 102 */ 103 void vIPSetDHCP_RATimerEnableState( NetworkEndPoint_t * pxEndPoint, 104 BaseType_t xEnableState ); 105 #endif /* ( ipconfigUSE_DHCP == 1 ) || ( ipconfigUSE_RA == 1 ) */ 106 107 #if ( ipconfigDNS_USE_CALLBACKS != 0 ) 108 109 /** 110 * @brief Enable/disable the DNS timer. 111 * @param[in] xEnableState: pdTRUE - enable timer; pdFALSE - disable timer. 112 */ 113 void vIPSetDNSTimerEnableState( BaseType_t xEnableState ); 114 #endif /* ipconfigDNS_USE_CALLBACKS != 0 */ 115 116 /** 117 * Sets the reload time of an ARP timer and restarts it. 118 */ 119 void vARPTimerReload( TickType_t xTime ); 120 121 /** 122 * Sets the reload time of an TCP timer and restarts it. 123 */ 124 void vTCPTimerReload( TickType_t xTime ); 125 126 #if ( ipconfigUSE_DHCP == 1 ) || ( ipconfigUSE_RA == 1 ) 127 void vDHCP_RATimerReload( NetworkEndPoint_t * pxEndPoint, 128 TickType_t uxClockTicks ); 129 #endif /* ( ipconfigUSE_DHCP == 1 ) || ( ipconfigUSE_RA == 1 ) */ 130 131 #if ( ipconfigDNS_USE_CALLBACKS != 0 ) 132 133 /** 134 * Reload the DNS timer. 135 */ 136 void vDNSTimerReload( uint32_t ulCheckTime ); 137 #endif /* ipconfigDNS_USE_CALLBACKS != 0 */ 138 139 /** 140 * Reload the Network timer. 141 */ 142 void vNetworkTimerReload( TickType_t xTime ); 143 144 /* *INDENT-OFF* */ 145 #ifdef __cplusplus 146 } /* extern "C" */ 147 #endif 148 /* *INDENT-ON* */ 149 150 #endif /* FREERTOS_IP_TIMERS_H */ 151