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