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