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