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