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_Utils.h
30  * @brief Implements the utility functions for FreeRTOS_IP.c
31  */
32 
33 #ifndef FREERTOS_IP_UTILS_H
34 #define FREERTOS_IP_UTILS_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_Routing.h"
51 #include "FreeRTOS_IP_Private.h"
52 #include "FreeRTOS_ARP.h"
53 #include "FreeRTOS_UDP_IP.h"
54 #include "FreeRTOS_DHCP.h"
55 #include "NetworkInterface.h"
56 #include "NetworkBufferManagement.h"
57 #include "FreeRTOS_DNS.h"
58 
59 #include "FreeRTOS_IPv4_Utils.h"
60 #include "FreeRTOS_IPv6_Utils.h"
61 
62 /* *INDENT-OFF* */
63 #ifdef __cplusplus
64     extern "C" {
65 #endif
66 /* *INDENT-ON* */
67 
68 /* Forward declaration. */
69 struct xNetworkInterface;
70 
71 #if ( ipconfigUSE_DHCP != 0 )
72 
73 /**
74  * @brief Create a DHCP event.
75  *
76  * @return pdPASS or pdFAIL, depending on whether xSendEventStructToIPTask()
77  *         succeeded.
78  */
79     BaseType_t xSendDHCPEvent( struct xNetworkEndPoint * pxEndPoint );
80 #endif
81 
82 #if ( ipconfigZERO_COPY_TX_DRIVER != 0 ) || ( ipconfigZERO_COPY_RX_DRIVER != 0 )
83 
84 /**
85  * @brief Get the network buffer from the packet buffer.
86  *
87  * @param[in] pvBuffer: Pointer to the packet buffer.
88  *
89  * @return The network buffer if the alignment is correct. Else a NULL is returned.
90  */
91     NetworkBufferDescriptor_t * pxPacketBuffer_to_NetworkBuffer( const void * pvBuffer );
92 #endif
93 
94 /**
95  * @brief Check the values of configuration options and assert on it. Also verify that the IP-task
96  *        has not already been initialized.
97  */
98 void vPreCheckConfigs( void );
99 
100 /**
101  * @brief Called to create a network connection when the stack is first
102  *        started, or when the network connection is lost.
103  */
104 void prvProcessNetworkDownEvent( struct xNetworkInterface * pxInterface );
105 
106 /* *INDENT-OFF* */
107 #ifdef __cplusplus
108     } /* extern "C" */
109 #endif
110 /* *INDENT-ON* */
111 
112 #endif /* FREERTOS_IP_UTILS_H */
113