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