]> git.sur5r.net Git - freertos/blob - FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/FreeRTOS_ARP.h
Update version number in readiness for V10.3.0 release. Sync SVN with reviewed releas...
[freertos] / FreeRTOS-Plus / Source / FreeRTOS-Plus-TCP / include / FreeRTOS_ARP.h
1 /*
2  * FreeRTOS+TCP V2.2.0
3  * Copyright (C) 2017 Amazon.com, Inc. or its affiliates.  All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of
6  * this software and associated documentation files (the "Software"), to deal in
7  * the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9  * the Software, and to permit persons to whom the Software is furnished to do so,
10  * subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in all
13  * copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  *
22  * http://aws.amazon.com/freertos
23  * http://www.FreeRTOS.org
24  */
25
26 #ifndef FREERTOS_ARP_H
27 #define FREERTOS_ARP_H
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32
33 /* Application level configuration options. */
34 #include "FreeRTOSIPConfig.h"
35 #include "FreeRTOSIPConfigDefaults.h"
36 #include "IPTraceMacroDefaults.h"
37
38 /*-----------------------------------------------------------*/
39 /* Miscellaneous structure and definitions. */
40 /*-----------------------------------------------------------*/
41
42 typedef struct xARP_CACHE_TABLE_ROW
43 {
44         uint32_t ulIPAddress;           /* The IP address of an ARP cache entry. */
45         MACAddress_t xMACAddress;  /* The MAC address of an ARP cache entry. */
46         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. */
47     uint8_t ucValid;                    /* pdTRUE: xMACAddress is valid, pdFALSE: waiting for ARP reply */
48 } ARPCacheRow_t;
49
50 typedef enum
51 {
52         eARPCacheMiss = 0,                      /* 0 An ARP table lookup did not find a valid entry. */
53         eARPCacheHit,                           /* 1 An ARP table lookup found a valid entry. */
54         eCantSendPacket                         /* 2 There is no IP address, or an ARP is still in progress, so the packet cannot be sent. */
55 } eARPLookupResult_t;
56
57 typedef enum
58 {
59         eNotFragment = 0,                       /* The IP packet being sent is not part of a fragment. */
60         eFirstFragment,                         /* The IP packet being sent is the first in a set of fragmented packets. */
61         eFollowingFragment                      /* The IP packet being sent is part of a set of fragmented packets. */
62 } eIPFragmentStatus_t;
63
64 /*
65  * If ulIPAddress is already in the ARP cache table then reset the age of the
66  * entry back to its maximum value.  If ulIPAddress is not already in the ARP
67  * cache table then add it - replacing the oldest current entry if there is not
68  * a free space available.
69  */
70 void vARPRefreshCacheEntry( const MACAddress_t * pxMACAddress, const uint32_t ulIPAddress );
71
72 #if( ipconfigARP_USE_CLASH_DETECTION != 0 )
73         /* Becomes non-zero if another device responded to a gratuitos ARP message. */
74         extern BaseType_t xARPHadIPClash;
75         /* MAC-address of the other device containing the same IP-address. */
76         extern MACAddress_t xARPClashMacAddress;
77 #endif /* ipconfigARP_USE_CLASH_DETECTION */
78
79 #if( ipconfigUSE_ARP_REMOVE_ENTRY != 0 )
80
81         /*
82          * In some rare cases, it might be useful to remove a ARP cache entry of a
83          * known MAC address to make sure it gets refreshed.
84          */
85         uint32_t ulARPRemoveCacheEntryByMac( const MACAddress_t * pxMACAddress );
86
87 #endif /* ipconfigUSE_ARP_REMOVE_ENTRY != 0 */
88
89 /*
90  * Look for ulIPAddress in the ARP cache.  If the IP address exists, copy the
91  * associated MAC address into pxMACAddress, refresh the ARP cache entry's
92  * age, and return eARPCacheHit.  If the IP address does not exist in the ARP
93  * cache return eARPCacheMiss.  If the packet cannot be sent for any reason
94  * (maybe DHCP is still in process, or the addressing needs a gateway but there
95  * isn't a gateway defined) then return eCantSendPacket.
96  */
97 eARPLookupResult_t eARPGetCacheEntry( uint32_t *pulIPAddress, MACAddress_t * const pxMACAddress );
98
99 #if( ipconfigUSE_ARP_REVERSED_LOOKUP != 0 )
100
101         /* Lookup an IP-address if only the MAC-address is known */
102         eARPLookupResult_t eARPGetCacheEntryByMac( MACAddress_t * const pxMACAddress, uint32_t *pulIPAddress );
103
104 #endif
105 /*
106  * Reduce the age count in each entry within the ARP cache.  An entry is no
107  * longer considered valid and is deleted if its age reaches zero.
108  */
109 void vARPAgeCache( void );
110
111 /*
112  * Send out an ARP request for the IP address contained in pxNetworkBuffer, and
113  * add an entry into the ARP table that indicates that an ARP reply is
114  * outstanding so re-transmissions can be generated.
115  */
116 void vARPGenerateRequestPacket( NetworkBufferDescriptor_t * const pxNetworkBuffer );
117
118 /*
119  * After DHCP is ready and when changing IP address, force a quick send of our new IP
120  * address
121  */
122 void vARPSendGratuitous( void );
123
124 #ifdef __cplusplus
125 } // extern "C"
126 #endif
127
128 #endif /* FREERTOS_ARP_H */
129
130
131
132
133
134
135
136
137
138
139
140
141