2 * FreeRTOS+TCP Labs Build 160919 (C) 2016 Real Time Engineers ltd.
\r
3 * Authors include Hein Tibosch and Richard Barry
\r
5 *******************************************************************************
\r
6 ***** NOTE ******* NOTE ******* NOTE ******* NOTE ******* NOTE ******* NOTE ***
\r
9 *** FREERTOS+TCP IS STILL IN THE LAB (mainly because the FTP and HTTP ***
\r
10 *** demos have a dependency on FreeRTOS+FAT, which is only in the Labs ***
\r
13 *** FreeRTOS+TCP is functional and has been used in commercial products ***
\r
14 *** for some time. Be aware however that we are still refining its ***
\r
15 *** design, the source code does not yet quite conform to the strict ***
\r
16 *** coding and style standards mandated by Real Time Engineers ltd., and ***
\r
17 *** the documentation and testing is not necessarily complete. ***
\r
19 *** PLEASE REPORT EXPERIENCES USING THE SUPPORT RESOURCES FOUND ON THE ***
\r
20 *** URL: http://www.FreeRTOS.org/contact Active early adopters may, at ***
\r
21 *** the sole discretion of Real Time Engineers Ltd., be offered versions ***
\r
22 *** under a license other than that described below. ***
\r
25 ***** NOTE ******* NOTE ******* NOTE ******* NOTE ******* NOTE ******* NOTE ***
\r
26 *******************************************************************************
\r
28 * FreeRTOS+TCP can be used under two different free open source licenses. The
\r
29 * license that applies is dependent on the processor on which FreeRTOS+TCP is
\r
30 * executed, as follows:
\r
32 * If FreeRTOS+TCP is executed on one of the processors listed under the Special
\r
33 * License Arrangements heading of the FreeRTOS+TCP license information web
\r
34 * page, then it can be used under the terms of the FreeRTOS Open Source
\r
35 * License. If FreeRTOS+TCP is used on any other processor, then it can be used
\r
36 * under the terms of the GNU General Public License V2. Links to the relevant
\r
39 * The FreeRTOS+TCP License Information Page: http://www.FreeRTOS.org/tcp_license
\r
40 * The FreeRTOS Open Source License: http://www.FreeRTOS.org/license
\r
41 * The GNU General Public License Version 2: http://www.FreeRTOS.org/gpl-2.0.txt
\r
43 * FreeRTOS+TCP is distributed in the hope that it will be useful. You cannot
\r
44 * use FreeRTOS+TCP unless you agree that you use the software 'as is'.
\r
45 * FreeRTOS+TCP is provided WITHOUT ANY WARRANTY; without even the implied
\r
46 * warranties of NON-INFRINGEMENT, MERCHANTABILITY or FITNESS FOR A PARTICULAR
\r
47 * PURPOSE. Real Time Engineers Ltd. disclaims all conditions and terms, be they
\r
48 * implied, expressed, or statutory.
\r
50 * 1 tab == 4 spaces!
\r
52 * http://www.FreeRTOS.org
\r
53 * http://www.FreeRTOS.org/plus
\r
54 * http://www.FreeRTOS.org/labs
\r
58 #ifndef FREERTOS_ARP_H
\r
59 #define FREERTOS_ARP_H
\r
65 /* Application level configuration options. */
\r
66 #include "FreeRTOSIPConfig.h"
\r
67 #include "FreeRTOSIPConfigDefaults.h"
\r
68 #include "IPTraceMacroDefaults.h"
\r
70 /*-----------------------------------------------------------*/
\r
71 /* Miscellaneous structure and definitions. */
\r
72 /*-----------------------------------------------------------*/
\r
74 typedef struct xARP_CACHE_TABLE_ROW
\r
76 uint32_t ulIPAddress; /* The IP address of an ARP cache entry. */
\r
77 MACAddress_t xMACAddress; /* The MAC address of an ARP cache entry. */
\r
78 uint8_t ucAge; /* A value that is periodically decremented but can also be refreshed by active communication. The ARP cache entry is removed if the value reaches zero. */
\r
79 uint8_t ucValid; /* pdTRUE: xMACAddress is valid, pdFALSE: waiting for ARP reply */
\r
84 eARPCacheMiss = 0, /* 0 An ARP table lookup did not find a valid entry. */
\r
85 eARPCacheHit, /* 1 An ARP table lookup found a valid entry. */
\r
86 eCantSendPacket /* 2 There is no IP address, or an ARP is still in progress, so the packet cannot be sent. */
\r
87 } eARPLookupResult_t;
\r
91 eNotFragment = 0, /* The IP packet being sent is not part of a fragment. */
\r
92 eFirstFragment, /* The IP packet being sent is the first in a set of fragmented packets. */
\r
93 eFollowingFragment /* The IP packet being sent is part of a set of fragmented packets. */
\r
94 } eIPFragmentStatus_t;
\r
97 * If ulIPAddress is already in the ARP cache table then reset the age of the
\r
98 * entry back to its maximum value. If ulIPAddress is not already in the ARP
\r
99 * cache table then add it - replacing the oldest current entry if there is not
\r
100 * a free space available.
\r
102 void vARPRefreshCacheEntry( const MACAddress_t * pxMACAddress, const uint32_t ulIPAddress );
\r
104 #if( ipconfigARP_USE_CLASH_DETECTION != 0 )
\r
105 /* Becomes non-zero if another device responded to a gratuitos ARP message. */
\r
106 extern BaseType_t xARPHadIPClash;
\r
107 /* MAC-address of the other device containing the same IP-address. */
\r
108 extern MACAddress_t xARPClashMacAddress;
\r
109 #endif /* ipconfigARP_USE_CLASH_DETECTION */
\r
111 #if( ipconfigUSE_ARP_REMOVE_ENTRY != 0 )
\r
114 * In some rare cases, it might be useful to remove a ARP cache entry of a
\r
115 * known MAC address to make sure it gets refreshed.
\r
117 uint32_t ulARPRemoveCacheEntryByMac( const MACAddress_t * pxMACAddress );
\r
119 #endif /* ipconfigUSE_ARP_REMOVE_ENTRY != 0 */
\r
122 * Look for ulIPAddress in the ARP cache. If the IP address exists, copy the
\r
123 * associated MAC address into pxMACAddress, refresh the ARP cache entry's
\r
124 * age, and return eARPCacheHit. If the IP address does not exist in the ARP
\r
125 * cache return eARPCacheMiss. If the packet cannot be sent for any reason
\r
126 * (maybe DHCP is still in process, or the addressing needs a gateway but there
\r
127 * isn't a gateway defined) then return eCantSendPacket.
\r
129 eARPLookupResult_t eARPGetCacheEntry( uint32_t *pulIPAddress, MACAddress_t * const pxMACAddress );
\r
131 #if( ipconfigUSE_ARP_REVERSED_LOOKUP != 0 )
\r
133 /* Lookup an IP-address if only the MAC-address is known */
\r
134 eARPLookupResult_t eARPGetCacheEntryByMac( MACAddress_t * const pxMACAddress, uint32_t *pulIPAddress );
\r
138 * Reduce the age count in each entry within the ARP cache. An entry is no
\r
139 * longer considered valid and is deleted if its age reaches zero.
\r
141 void vARPAgeCache( void );
\r
144 * Send out an ARP request for the IP address contained in pxNetworkBuffer, and
\r
145 * add an entry into the ARP table that indicates that an ARP reply is
\r
146 * outstanding so re-transmissions can be generated.
\r
148 void vARPGenerateRequestPacket( NetworkBufferDescriptor_t * const pxNetworkBuffer );
\r
151 * After DHCP is ready and when changing IP address, force a quick send of our new IP
\r
154 void vARPSendGratuitous( void );
\r
160 #endif /* FREERTOS_ARP_H */
\r