]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Network/ArpDxe/ArpImpl.h
Clean up to update the reference of the these macros:
[mirror_edk2.git] / MdeModulePkg / Universal / Network / ArpDxe / ArpImpl.h
CommitLineData
83cbd279 1/** @file\r
c6d0ee4b 2 Abstract:\r
83cbd279 3\r
c6d0ee4b 4Copyright (c) 2006 - 2008, Intel Corporation.<BR>\r
83cbd279 5All rights reserved. This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
c6d0ee4b 7which accompanies this distribution. The full text of the license may be found at<BR>\r
83cbd279 8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
83cbd279 13**/\r
14\r
15#ifndef _ARP_IMPL_H_\r
16#define _ARP_IMPL_H_\r
17\r
772db4bb 18\r
19#include <PiDxe.h>\r
20\r
21#include <Protocol/Arp.h>\r
83cbd279 22#include <Protocol/ManagedNetwork.h>\r
772db4bb 23#include <Protocol/ServiceBinding.h>\r
24\r
25#include <Library/DebugLib.h>\r
26#include <Library/UefiDriverEntryPoint.h>\r
27#include <Library/UefiBootServicesTableLib.h>\r
83cbd279 28#include <Library/UefiLib.h>\r
29#include <Library/NetLib.h>\r
30#include <Library/BaseLib.h>\r
31#include <Library/BaseMemoryLib.h>\r
32#include <Library/MemoryAllocationLib.h>\r
33\r
83cbd279 34\r
35#define ARP_ETHER_PROTO_TYPE 0x0806\r
7bce0c5a 36#define IPV4_ETHER_PROTO_TYPE 0x0800\r
37#define IPV6_ETHER_PROTO_TYPE 0x86DD\r
83cbd279 38\r
39#define ARP_OPCODE_REQUEST 0x0001\r
40#define ARP_OPCODE_REPLY 0x0002\r
41\r
42#define ARP_DEFAULT_TIMEOUT_VALUE (400 * TICKS_PER_SECOND)\r
43#define ARP_DEFAULT_RETRY_COUNT 2\r
44#define ARP_DEFAULT_RETRY_INTERVAL (5 * TICKS_PER_MS)\r
45#define ARP_PERIODIC_TIMER_INTERVAL (500 * TICKS_PER_MS)\r
46\r
47#pragma pack(1)\r
c6d0ee4b 48typedef struct {\r
83cbd279 49 UINT16 HwType;\r
50 UINT16 ProtoType;\r
51 UINT8 HwAddrLen;\r
52 UINT8 ProtoAddrLen;\r
53 UINT16 OpCode;\r
54} ARP_HEAD;\r
55#pragma pack()\r
56\r
c6d0ee4b 57typedef struct {\r
83cbd279 58 UINT8 *SenderHwAddr;\r
59 UINT8 *SenderProtoAddr;\r
60 UINT8 *TargetHwAddr;\r
61 UINT8 *TargetProtoAddr;\r
62} ARP_ADDRESS;\r
63\r
64#define MATCH_SW_ADDRESS 0x1\r
65#define MATCH_HW_ADDRESS 0x2\r
66\r
67typedef enum {\r
68 ByNone = 0,\r
69 ByProtoAddress = MATCH_SW_ADDRESS,\r
70 ByHwAddress = MATCH_HW_ADDRESS,\r
71 ByBoth = MATCH_SW_ADDRESS | MATCH_HW_ADDRESS\r
72} FIND_OPTYPE;\r
73\r
f3f2e05d 74#define ARP_INSTANCE_DATA_SIGNATURE SIGNATURE_32('A', 'R', 'P', 'I')\r
83cbd279 75\r
c6d0ee4b 76//\r
77//comment for macro\r
78//\r
83cbd279 79#define ARP_INSTANCE_DATA_FROM_THIS(a) \\r
80 CR ( \\r
81 (a), \\r
82 ARP_INSTANCE_DATA, \\r
83 ArpProto, \\r
84 ARP_INSTANCE_DATA_SIGNATURE \\r
85 )\r
86\r
87typedef struct _ARP_SERVICE_DATA ARP_SERVICE_DATA;\r
88\r
c6d0ee4b 89typedef struct {\r
83cbd279 90 UINT32 Signature;\r
91 ARP_SERVICE_DATA *ArpService;\r
92 EFI_HANDLE Handle;\r
93 EFI_ARP_PROTOCOL ArpProto;\r
e48e37fc 94 LIST_ENTRY List;\r
83cbd279 95 EFI_ARP_CONFIG_DATA ConfigData;\r
96 BOOLEAN Configured;\r
97 BOOLEAN Destroyed;\r
98} ARP_INSTANCE_DATA;\r
99\r
f3f2e05d 100#define ARP_SERVICE_DATA_SIGNATURE SIGNATURE_32('A', 'R', 'P', 'S')\r
83cbd279 101\r
c6d0ee4b 102//\r
103//comment for macro\r
104//\r
83cbd279 105#define ARP_SERVICE_DATA_FROM_THIS(a) \\r
106 CR ( \\r
107 (a), \\r
108 ARP_SERVICE_DATA, \\r
109 ServiceBinding, \\r
110 ARP_SERVICE_DATA_SIGNATURE \\r
111 )\r
112\r
113struct _ARP_SERVICE_DATA {\r
114 UINT32 Signature;\r
115 EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;\r
116\r
117 EFI_HANDLE MnpChildHandle;\r
118 EFI_HANDLE ImageHandle;\r
119 EFI_HANDLE ControllerHandle;\r
120\r
121 EFI_MANAGED_NETWORK_PROTOCOL *Mnp;\r
122 EFI_MANAGED_NETWORK_CONFIG_DATA MnpConfigData;\r
123 EFI_MANAGED_NETWORK_COMPLETION_TOKEN RxToken;\r
124\r
125 EFI_SIMPLE_NETWORK_MODE SnpMode;\r
126\r
83cbd279 127 UINTN ChildrenNumber;\r
e48e37fc 128 LIST_ENTRY ChildrenList;\r
83cbd279 129\r
e48e37fc 130 LIST_ENTRY PendingRequestTable;\r
131 LIST_ENTRY DeniedCacheTable;\r
132 LIST_ENTRY ResolvedCacheTable;\r
83cbd279 133\r
134 EFI_EVENT PeriodicTimer;\r
135};\r
136\r
c6d0ee4b 137typedef struct {\r
e48e37fc 138 LIST_ENTRY List;\r
83cbd279 139 ARP_INSTANCE_DATA *Instance;\r
140 EFI_EVENT UserRequestEvent;\r
141 VOID *UserHwAddrBuffer;\r
142} USER_REQUEST_CONTEXT;\r
143\r
144#define ARP_MAX_PROTOCOL_ADDRESS_LEN sizeof(EFI_IP_ADDRESS)\r
145#define ARP_MAX_HARDWARE_ADDRESS_LEN sizeof(EFI_MAC_ADDRESS)\r
146\r
c6d0ee4b 147typedef struct {\r
83cbd279 148 UINT16 Type;\r
149 UINT8 Length;\r
150 UINT8 *AddressPtr;\r
151 union {\r
152 UINT8 ProtoAddress[ARP_MAX_PROTOCOL_ADDRESS_LEN];\r
153 UINT8 HwAddress[ARP_MAX_HARDWARE_ADDRESS_LEN];\r
154 } Buffer;\r
155} NET_ARP_ADDRESS;\r
156\r
157typedef enum {\r
158 Hardware,\r
159 Protocol\r
160} ARP_ADDRESS_TYPE;\r
161\r
c6d0ee4b 162typedef struct {\r
e48e37fc 163 LIST_ENTRY List;\r
83cbd279 164\r
165 UINT32 RetryCount;\r
166 UINT32 DefaultDecayTime;\r
167 UINT32 DecayTime;\r
168 UINT32 NextRetryTime;\r
169\r
170 NET_ARP_ADDRESS Addresses[2];\r
171\r
e48e37fc 172 LIST_ENTRY UserRequestList;\r
83cbd279 173} ARP_CACHE_ENTRY;\r
174\r
7bce0c5a 175/**\r
176 This function is used to assign a station address to the ARP cache for this instance\r
c6d0ee4b 177 of the ARP driver. Each ARP instance has one station address. The EFI_ARP_PROTOCOL \r
178 driver will respond to ARP requests that match this registered station address. \r
179 A call to this function with the ConfigData field set to NULL will reset this \r
180 ARP instance.\r
181 \r
182 Once a protocol type and station address have been assigned to this ARP instance, \r
183 all the following ARP functions will use this information. Attempting to change \r
184 the protocol type or station address to a configured ARP instance will result in errors.\r
185\r
186 @param[in] This Pointer to the EFI_ARP_PROTOCOL instance.\r
187 @param[in] ConfigData Pointer to the EFI_ARP_CONFIG_DATA structure.\r
7bce0c5a 188\r
189 @retval EFI_SUCCESS The new station address was successfully\r
190 registered.\r
191 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
192 This is NULL. SwAddressLength is zero when\r
193 ConfigData is not NULL. StationAddress is NULL\r
194 when ConfigData is not NULL.\r
195 @retval EFI_ACCESS_DENIED The SwAddressType, SwAddressLength, or\r
196 StationAddress is different from the one that is\r
197 already registered.\r
198 @retval EFI_OUT_OF_RESOURCES Storage for the new StationAddress could not be\r
199 allocated.\r
200\r
201**/\r
83cbd279 202EFI_STATUS\r
203EFIAPI\r
204ArpConfigure (\r
205 IN EFI_ARP_PROTOCOL *This,\r
206 IN EFI_ARP_CONFIG_DATA *ConfigData OPTIONAL\r
207 );\r
208\r
7bce0c5a 209/**\r
210 This function is used to insert entries into the ARP cache.\r
211\r
c6d0ee4b 212 ARP cache entries are typically inserted and updated by network protocol drivers \r
213 as network traffic is processed. Most ARP cache entries will time out and be \r
214 deleted if the network traffic stops. ARP cache entries that were inserted \r
215 by the Add() function may be static (will not time out) or dynamic (will time out).\r
216 Default ARP cache timeout values are not covered in most network protocol \r
217 specifications (although RFC 1122 comes pretty close) and will only be \r
218 discussed in general in this specification. The timeout values that are \r
219 used in the EFI Sample Implementation should be used only as a guideline. \r
220 Final product implementations of the EFI network stack should be tuned for \r
221 their expected network environments.\r
222 \r
223 @param[in] This Pointer to the EFI_ARP_PROTOCOL instance.\r
224 @param[in] DenyFlag Set to TRUE if this entry is a deny entry. Set to\r
7bce0c5a 225 FALSE if this entry is a normal entry.\r
c6d0ee4b 226 @param[in] TargetSwAddress Pointer to a protocol address to add (or deny).\r
7bce0c5a 227 May be set to NULL if DenyFlag is TRUE.\r
c6d0ee4b 228 @param[in] TargetHwAddress Pointer to a hardware address to add (or deny).\r
7bce0c5a 229 May be set to NULL if DenyFlag is TRUE.\r
c6d0ee4b 230 @param[in] TimeoutValue Time in 100-ns units that this entry will remain\r
7bce0c5a 231 in the ARP cache. A value of zero means that the\r
232 entry is permanent. A nonzero value will override\r
233 the one given by Configure() if the entry to be\r
234 added is a dynamic entry.\r
c6d0ee4b 235 @param[in] Overwrite If TRUE, the matching cache entry will be\r
7bce0c5a 236 overwritten with the supplied parameters. If\r
237 FALSE, EFI_ACCESS_DENIED is returned if the\r
238 corresponding cache entry already exists.\r
239\r
240 @retval EFI_SUCCESS The entry has been added or updated.\r
241 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
242 This is NULL. DenyFlag is FALSE and\r
243 TargetHwAddress is NULL. DenyFlag is FALSE and\r
244 TargetSwAddress is NULL. TargetHwAddress is NULL\r
245 and TargetSwAddress is NULL. Both TargetSwAddress\r
246 and TargetHwAddress are not NULL when DenyFlag is\r
247 TRUE.\r
248 @retval EFI_OUT_OF_RESOURCES The new ARP cache entry could not be allocated.\r
249 @retval EFI_ACCESS_DENIED The ARP cache entry already exists and Overwrite\r
250 is not true.\r
251 @retval EFI_NOT_STARTED The ARP driver instance has not been configured.\r
252\r
253**/\r
83cbd279 254EFI_STATUS\r
255EFIAPI\r
256ArpAdd (\r
257 IN EFI_ARP_PROTOCOL *This,\r
258 IN BOOLEAN DenyFlag,\r
259 IN VOID *TargetSwAddress OPTIONAL,\r
260 IN VOID *TargetHwAddress OPTIONAL,\r
261 IN UINT32 TimeoutValue,\r
262 IN BOOLEAN Overwrite\r
263 );\r
264\r
7bce0c5a 265/**\r
266 This function searches the ARP cache for matching entries and allocates a buffer into\r
267 which those entries are copied.\r
c6d0ee4b 268 \r
269 The first part of the allocated buffer is EFI_ARP_FIND_DATA, following which \r
270 are protocol address pairs and hardware address pairs.\r
271 When finding a specific protocol address (BySwAddress is TRUE and AddressBuffer \r
272 is not NULL), the ARP cache timeout for the found entry is reset if Refresh is \r
273 set to TRUE. If the found ARP cache entry is a permanent entry, it is not \r
274 affected by Refresh.\r
275 \r
276 @param[in] This Pointer to the EFI_ARP_PROTOCOL instance.\r
277 @param[in] BySwAddress Set to TRUE to look for matching software protocol\r
7bce0c5a 278 addresses. Set to FALSE to look for matching\r
279 hardware protocol addresses.\r
c6d0ee4b 280 @param[in] AddressBuffer Pointer to address buffer. Set to NULL to match\r
7bce0c5a 281 all addresses.\r
c6d0ee4b 282 @param[out] EntryLength The size of an entry in the entries buffer.\r
283 @param[out] EntryCount The number of ARP cache entries that are found by\r
7bce0c5a 284 the specified criteria.\r
c6d0ee4b 285 @param[out] Entries Pointer to the buffer that will receive the ARP\r
7bce0c5a 286 cache entries.\r
c6d0ee4b 287 @param[in] Refresh Set to TRUE to refresh the timeout value of the\r
7bce0c5a 288 matching ARP cache entry.\r
289\r
290 @retval EFI_SUCCESS The requested ARP cache entries were copied into\r
291 the buffer.\r
292 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
293 This is NULL. Both EntryCount and EntryLength are\r
294 NULL, when Refresh is FALSE.\r
295 @retval EFI_NOT_FOUND No matching entries were found.\r
296 @retval EFI_NOT_STARTED The ARP driver instance has not been configured.\r
297\r
298**/\r
83cbd279 299EFI_STATUS\r
300EFIAPI\r
301ArpFind (\r
302 IN EFI_ARP_PROTOCOL *This,\r
303 IN BOOLEAN BySwAddress,\r
304 IN VOID *AddressBuffer OPTIONAL,\r
305 OUT UINT32 *EntryLength OPTIONAL,\r
306 OUT UINT32 *EntryCount OPTIONAL,\r
307 OUT EFI_ARP_FIND_DATA **Entries OPTIONAL,\r
308 IN BOOLEAN Refresh\r
309 );\r
310\r
7bce0c5a 311/**\r
312 This function removes specified ARP cache entries.\r
313\r
c6d0ee4b 314 @param[in] This Pointer to the EFI_ARP_PROTOCOL instance.\r
315 @param[in] BySwAddress Set to TRUE to delete matching protocol addresses.\r
7bce0c5a 316 Set to FALSE to delete matching hardware\r
317 addresses.\r
c6d0ee4b 318 @param[in] AddressBuffer Pointer to the address buffer that is used as a\r
7bce0c5a 319 key to look for the cache entry. Set to NULL to\r
320 delete all entries.\r
321\r
322 @retval EFI_SUCCESS The entry was removed from the ARP cache.\r
323 @retval EFI_INVALID_PARAMETER This is NULL.\r
324 @retval EFI_NOT_FOUND The specified deletion key was not found.\r
325 @retval EFI_NOT_STARTED The ARP driver instance has not been configured.\r
326\r
327**/\r
83cbd279 328EFI_STATUS\r
329EFIAPI\r
330ArpDelete (\r
331 IN EFI_ARP_PROTOCOL *This,\r
332 IN BOOLEAN BySwAddress,\r
333 IN VOID *AddressBuffer OPTIONAL\r
334 );\r
335\r
7bce0c5a 336/**\r
337 This function delete all dynamic entries from the ARP cache that match the specified\r
338 software protocol type.\r
339\r
c6d0ee4b 340 @param[in] This Pointer to the EFI_ARP_PROTOCOL instance.\r
7bce0c5a 341\r
342 @retval EFI_SUCCESS The cache has been flushed.\r
343 @retval EFI_INVALID_PARAMETER This is NULL.\r
344 @retval EFI_NOT_FOUND There are no matching dynamic cache entries.\r
345 @retval EFI_NOT_STARTED The ARP driver instance has not been configured.\r
346\r
347**/\r
83cbd279 348EFI_STATUS\r
349EFIAPI\r
350ArpFlush (\r
351 IN EFI_ARP_PROTOCOL *This\r
352 );\r
353\r
7bce0c5a 354/**\r
355 This function tries to resolve the TargetSwAddress and optionally returns a\r
356 TargetHwAddress if it already exists in the ARP cache.\r
357\r
c6d0ee4b 358 @param[in] This Pointer to the EFI_ARP_PROTOCOL instance.\r
359 @param[in] TargetSwAddress Pointer to the protocol address to resolve.\r
360 @param[in] ResolvedEvent Pointer to the event that will be signaled when\r
7bce0c5a 361 the address is resolved or some error occurs.\r
c6d0ee4b 362 @param[out] TargetHwAddress Pointer to the buffer for the resolved hardware\r
7bce0c5a 363 address in network byte order.\r
364\r
365 @retval EFI_SUCCESS The data is copied from the ARP cache into the\r
366 TargetHwAddress buffer.\r
367 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
368 This is NULL. TargetHwAddress is NULL.\r
369 @retval EFI_ACCESS_DENIED The requested address is not present in the normal\r
370 ARP cache but is present in the deny address list.\r
371 Outgoing traffic to that address is forbidden.\r
372 @retval EFI_NOT_STARTED The ARP driver instance has not been configured.\r
373 @retval EFI_NOT_READY The request has been started and is not finished.\r
374\r
375**/\r
83cbd279 376EFI_STATUS\r
377EFIAPI\r
378ArpRequest (\r
379 IN EFI_ARP_PROTOCOL *This,\r
380 IN VOID *TargetSwAddress OPTIONAL,\r
381 IN EFI_EVENT ResolvedEvent OPTIONAL,\r
382 OUT VOID *TargetHwAddress\r
383 );\r
384\r
7bce0c5a 385/**\r
386 This function aborts the previous ARP request (identified by This, TargetSwAddress\r
387 and ResolvedEvent) that is issued by EFI_ARP_PROTOCOL.Request().\r
c6d0ee4b 388 \r
389 If the request is in the internal ARP request queue, the request is aborted \r
390 immediately and its ResolvedEvent is signaled. Only an asynchronous address \r
391 request needs to be canceled. If TargeSwAddress and ResolveEvent are both \r
392 NULL, all the pending asynchronous requests that have been issued by This \r
393 instance will be cancelled and their corresponding events will be signaled.\r
394 \r
395 @param[in] This Pointer to the EFI_ARP_PROTOCOL instance.\r
396 @param[in] TargetSwAddress Pointer to the protocol address in previous\r
7bce0c5a 397 request session.\r
c6d0ee4b 398 @param[in] ResolvedEvent Pointer to the event that is used as the\r
7bce0c5a 399 notification event in previous request session.\r
400\r
401 @retval EFI_SUCCESS The pending request session(s) is/are aborted and\r
402 corresponding event(s) is/are signaled.\r
403 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
404 This is NULL. TargetSwAddress is not NULL and\r
405 ResolvedEvent is NULL. TargetSwAddress is NULL and\r
406 ResolvedEvent is not NULL.\r
407 @retval EFI_NOT_STARTED The ARP driver instance has not been configured.\r
408 @retval EFI_NOT_FOUND The request is not issued by\r
409 EFI_ARP_PROTOCOL.Request().\r
410\r
411**/\r
83cbd279 412EFI_STATUS\r
413EFIAPI\r
414ArpCancel (\r
415 IN EFI_ARP_PROTOCOL *This,\r
416 IN VOID *TargetSwAddress OPTIONAL,\r
417 IN EFI_EVENT ResolvedEvent OPTIONAL\r
418 );\r
419\r
7bce0c5a 420/**\r
421 Configure the instance using the ConfigData. ConfigData is already validated.\r
422\r
c6d0ee4b 423 @param[in] Instance Pointer to the instance context data to be\r
7bce0c5a 424 configured.\r
c6d0ee4b 425 @param[in] ConfigData Pointer to the configuration data used to\r
7bce0c5a 426 configure the instance.\r
427\r
428 @retval EFI_SUCCESS The instance is configured with the ConfigData.\r
429 @retval EFI_ACCESS_DENIED The instance is already configured and the\r
430 ConfigData tries to reset some unchangeable\r
431 fields.\r
432 @retval EFI_INVALID_PARAMETER The ConfigData provides a non-unicast IPv4 address\r
433 when the SwAddressType is IPv4.\r
434 @retval EFI_OUT_OF_RESOURCES The instance fails to configure due to memory\r
435 limitation.\r
436\r
437**/\r
83cbd279 438EFI_STATUS\r
439ArpConfigureInstance (\r
440 IN ARP_INSTANCE_DATA *Instance,\r
441 IN EFI_ARP_CONFIG_DATA *ConfigData OPTIONAL\r
442 );\r
443\r
7bce0c5a 444/**\r
445 Find the CacheEntry, using ProtocolAddress or HardwareAddress or both, as the keyword,\r
446 in the DeniedCacheTable.\r
447\r
c6d0ee4b 448 @param[in] ArpService Pointer to the arp service context data.\r
449 @param[in] ProtocolAddress Pointer to the protocol address.\r
450 @param[in] HardwareAddress Pointer to the hardware address.\r
7bce0c5a 451\r
452 @return Pointer to the matched cache entry, if NULL no match is found.\r
453\r
454**/\r
83cbd279 455ARP_CACHE_ENTRY *\r
456ArpFindDeniedCacheEntry (\r
457 IN ARP_SERVICE_DATA *ArpService,\r
458 IN NET_ARP_ADDRESS *ProtocolAddress OPTIONAL,\r
459 IN NET_ARP_ADDRESS *HardwareAddress OPTIONAL\r
460 );\r
461\r
7bce0c5a 462/**\r
463 Find the CacheEntry which matches the requirements in the specified CacheTable.\r
464\r
c6d0ee4b 465 @param[in] CacheTable Pointer to the arp cache table.\r
466 @param[in] StartEntry Pointer to the start entry this search begins with\r
467 in the cache table.\r
468 @param[in] FindOpType The search type.\r
469 @param[in] ProtocolAddress Pointer to the protocol address to match.\r
470 @param[in] HardwareAddress Pointer to the hardware address to match.\r
7bce0c5a 471\r
472 @return Pointer to the matched arp cache entry, if NULL, no match is found.\r
473\r
474**/\r
83cbd279 475ARP_CACHE_ENTRY *\r
476ArpFindNextCacheEntryInTable (\r
e48e37fc 477 IN LIST_ENTRY *CacheTable,\r
478 IN LIST_ENTRY *StartEntry,\r
83cbd279 479 IN FIND_OPTYPE FindOpType,\r
480 IN NET_ARP_ADDRESS *ProtocolAddress OPTIONAL,\r
481 IN NET_ARP_ADDRESS *HardwareAddress OPTIONAL\r
482 );\r
483\r
7bce0c5a 484/**\r
485 Allocate a cache entry and initialize it.\r
486\r
c6d0ee4b 487 @param[in] Instance Pointer to the instance context data.\r
7bce0c5a 488\r
489 @return Pointer to the new created cache entry.\r
490\r
491**/\r
83cbd279 492ARP_CACHE_ENTRY *\r
493ArpAllocCacheEntry (\r
494 IN ARP_INSTANCE_DATA *Instance\r
495 );\r
496\r
7bce0c5a 497/**\r
498 Fill the addresses in the CacheEntry using the information passed in by\r
499 HwAddr and SwAddr.\r
500\r
c6d0ee4b 501 @param[in] CacheEntry Pointer to the cache entry.\r
502 @param[in] HwAddr Pointer to the software address.\r
503 @param[in] SwAddr Pointer to the hardware address.\r
7bce0c5a 504\r
505 @return None.\r
506\r
507**/\r
83cbd279 508VOID\r
509ArpFillAddressInCacheEntry (\r
510 IN ARP_CACHE_ENTRY *CacheEntry,\r
511 IN NET_ARP_ADDRESS *HwAddr OPTIONAL,\r
512 IN NET_ARP_ADDRESS *SwAddr OPTIONAL\r
513 );\r
514\r
7bce0c5a 515/**\r
516 Turn the CacheEntry into the resolved status.\r
517\r
c6d0ee4b 518 @param[in] CacheEntry Pointer to the resolved cache entry.\r
519 @param[in] Instance Pointer to the instance context data.\r
520 @param[in] UserEvent Pointer to the UserEvent to notify.\r
7bce0c5a 521\r
522 @return The count of notifications sent to the instance.\r
523\r
524**/\r
83cbd279 525UINTN\r
526ArpAddressResolved (\r
527 IN ARP_CACHE_ENTRY *CacheEntry,\r
528 IN ARP_INSTANCE_DATA *Instance OPTIONAL,\r
529 IN EFI_EVENT UserEvent OPTIONAL\r
530 );\r
531\r
7bce0c5a 532/**\r
533 Delete cache entries in all the cache tables.\r
534\r
c6d0ee4b 535 @param[in] Instance Pointer to the instance context data.\r
536 @param[in] BySwAddress Delete the cache entry by software address or by\r
537 hardware address.\r
538 @param[in] AddressBuffer Pointer to the buffer containing the address to\r
539 match for the deletion.\r
540 @param[in] Force This deletion is forced or not.\r
7bce0c5a 541\r
542 @return The count of the deleted cache entries.\r
543\r
544**/\r
83cbd279 545UINTN\r
546ArpDeleteCacheEntry (\r
547 IN ARP_INSTANCE_DATA *Instance,\r
548 IN BOOLEAN BySwAddress,\r
549 IN UINT8 *AddressBuffer OPTIONAL,\r
550 IN BOOLEAN Force\r
551 );\r
552\r
7bce0c5a 553/**\r
554 Send out an arp frame using the CachEntry and the ArpOpCode.\r
555\r
c6d0ee4b 556 @param[in] Instance Pointer to the instance context data.\r
557 @param[in] CacheEntry Pointer to the configuration data used to\r
558 configure the instance.\r
559 @param[in] ArpOpCode The opcode used to send out this Arp frame, either\r
560 request or reply.\r
7bce0c5a 561\r
562 @return None.\r
563\r
564**/\r
83cbd279 565VOID\r
566ArpSendFrame (\r
567 IN ARP_INSTANCE_DATA *Instance,\r
568 IN ARP_CACHE_ENTRY *CacheEntry,\r
569 IN UINT16 ArpOpCode\r
570 );\r
571\r
7bce0c5a 572/**\r
573 Initialize the instance context data.\r
574\r
c6d0ee4b 575 @param[in] ArpService Pointer to the arp service context data this\r
576 instance belongs to.\r
577 @param[in] Instance Pointer to the instance context data.\r
7bce0c5a 578\r
579 @return None.\r
580\r
581**/\r
83cbd279 582VOID\r
583ArpInitInstance (\r
584 IN ARP_SERVICE_DATA *ArpService,\r
585 IN ARP_INSTANCE_DATA *Instance\r
586 );\r
587\r
7bce0c5a 588/**\r
589 Process the Arp packets received from Mnp, the procedure conforms to RFC826.\r
590\r
c6d0ee4b 591 @param[in] Context Pointer to the context data registerd to the\r
7bce0c5a 592 Event.\r
593\r
594 @return None.\r
595\r
596**/\r
36ee91ca 597VOID\r
598EFIAPI\r
599ArpOnFrameRcvdDpc (\r
600 IN VOID *Context\r
601 );\r
602\r
7bce0c5a 603/**\r
604 Queue ArpOnFrameRcvdDpc as a DPC at TPL_CALLBACK.\r
605\r
c6d0ee4b 606 @param[in] Event The Event this notify function registered to.\r
607 @param[in] Context Pointer to the context data registerd to the\r
608 Event.\r
7bce0c5a 609\r
610 @return None.\r
611\r
612**/\r
83cbd279 613VOID\r
614EFIAPI\r
615ArpOnFrameRcvd (\r
616 IN EFI_EVENT Event,\r
617 IN VOID *Context\r
618 );\r
619\r
7bce0c5a 620/**\r
621 Process the already sent arp packets.\r
622\r
c6d0ee4b 623 @param[in] Context Pointer to the context data registerd to the\r
624 Event.\r
7bce0c5a 625\r
626 @return None.\r
627\r
628**/\r
36ee91ca 629VOID\r
630EFIAPI\r
631ArpOnFrameSentDpc (\r
632 IN VOID *Context\r
633 );\r
634\r
7bce0c5a 635/**\r
636 Queue ArpOnFrameRcvdDpc as a DPC at TPL_CALLBACK.\r
637\r
c6d0ee4b 638 @param[in] Event The Event this notify function registered to.\r
639 @param[in] Context Pointer to the context data registerd to the\r
640 Event.\r
7bce0c5a 641\r
642 @return None.\r
643\r
644**/\r
83cbd279 645VOID\r
646EFIAPI\r
647ArpOnFrameSent (\r
648 IN EFI_EVENT Event,\r
649 IN VOID *Context\r
650 );\r
651\r
7bce0c5a 652/**\r
653 Process the arp cache olding and drive the retrying arp requests.\r
654\r
c6d0ee4b 655 @param[in] Event The Event this notify function registered to.\r
656 @param[in] Context Pointer to the context data registerd to the\r
657 Event.\r
7bce0c5a 658\r
659 @return None.\r
660\r
661**/\r
83cbd279 662VOID\r
663EFIAPI\r
664ArpTimerHandler (\r
665 IN EFI_EVENT Event,\r
666 IN VOID *Context\r
667 );\r
668\r
7bce0c5a 669/**\r
670 Cancel the arp request.\r
671\r
c6d0ee4b 672 @param[in] Instance Pointer to the instance context data.\r
673 @param[in] TargetSwAddress Pointer to the buffer containing the target\r
674 software address to match the arp request.\r
675 @param[in] UserEvent The user event used to notify this request\r
676 cancellation.\r
7bce0c5a 677\r
678 @return The count of the cancelled requests.\r
679\r
680**/\r
83cbd279 681UINTN\r
682ArpCancelRequest (\r
683 IN ARP_INSTANCE_DATA *Instance,\r
684 IN VOID *TargetSwAddress OPTIONAL,\r
685 IN EFI_EVENT UserEvent OPTIONAL\r
686 );\r
687\r
7bce0c5a 688/**\r
689 Find the cache entry in the cache table.\r
690\r
c6d0ee4b 691 @param[in] Instance Pointer to the instance context data.\r
692 @param[in] BySwAddress Set to TRUE to look for matching software protocol\r
7bce0c5a 693 addresses. Set to FALSE to look for matching\r
694 hardware protocol addresses.\r
c6d0ee4b 695 @param[in] AddressBuffer Pointer to address buffer. Set to NULL to match\r
7bce0c5a 696 all addresses.\r
c6d0ee4b 697 @param[out] EntryLength The size of an entry in the entries buffer.\r
698 @param[out] EntryCount The number of ARP cache entries that are found by\r
7bce0c5a 699 the specified criteria.\r
c6d0ee4b 700 @param[out] Entries Pointer to the buffer that will receive the ARP\r
7bce0c5a 701 cache entries.\r
c6d0ee4b 702 @param[in] Refresh Set to TRUE to refresh the timeout value of the\r
7bce0c5a 703 matching ARP cache entry.\r
704\r
705 @retval EFI_SUCCESS The requested ARP cache entries are copied into\r
706 the buffer.\r
707 @retval EFI_NOT_FOUND No matching entries found.\r
708 @retval EFI_OUT_OF_RESOURCE There is a memory allocation failure.\r
709\r
710**/\r
83cbd279 711EFI_STATUS\r
712ArpFindCacheEntry (\r
713 IN ARP_INSTANCE_DATA *Instance,\r
714 IN BOOLEAN BySwAddress,\r
715 IN VOID *AddressBuffer OPTIONAL,\r
716 OUT UINT32 *EntryLength OPTIONAL,\r
717 OUT UINT32 *EntryCount OPTIONAL,\r
718 OUT EFI_ARP_FIND_DATA **Entries OPTIONAL,\r
719 IN BOOLEAN Refresh\r
720 );\r
721\r
722#endif\r