TianoCore EDK2 master
Loading...
Searching...
No Matches
ArpImpl.h
Go to the documentation of this file.
1
9#ifndef _ARP_IMPL_H_
10#define _ARP_IMPL_H_
11
12#include <Uefi.h>
13
14#include <Protocol/Arp.h>
17
18#include <Library/DebugLib.h>
21#include <Library/UefiLib.h>
22#include <Library/NetLib.h>
23#include <Library/BaseLib.h>
26#include <Library/DpcLib.h>
27
28//
29// Ethernet protocol type definitions.
30//
31#define ARP_ETHER_PROTO_TYPE 0x0806
32#define IPV4_ETHER_PROTO_TYPE 0x0800
33#define IPV6_ETHER_PROTO_TYPE 0x86DD
34
35//
36// ARP opcode definitions.
37//
38#define ARP_OPCODE_REQUEST 0x0001
39#define ARP_OPCODE_REPLY 0x0002
40
41//
42// ARP timeout, retry count and interval definitions.
43//
44#define ARP_DEFAULT_TIMEOUT_VALUE (400 * TICKS_PER_SECOND)
45#define ARP_DEFAULT_RETRY_COUNT 2
46#define ARP_DEFAULT_RETRY_INTERVAL (5 * TICKS_PER_MS)
47#define ARP_PERIODIC_TIMER_INTERVAL (500 * TICKS_PER_MS)
48
49//
50// ARP packet head definition.
51//
52#pragma pack(1)
53typedef struct {
54 UINT16 HwType;
55 UINT16 ProtoType;
56 UINT8 HwAddrLen;
57 UINT8 ProtoAddrLen;
58 UINT16 OpCode;
59} ARP_HEAD;
60#pragma pack()
61
62//
63// ARP Address definition for internal use.
64//
65typedef struct {
66 UINT8 *SenderHwAddr;
67 UINT8 *SenderProtoAddr;
68 UINT8 *TargetHwAddr;
69 UINT8 *TargetProtoAddr;
71
72#define MATCH_SW_ADDRESS 0x1
73#define MATCH_HW_ADDRESS 0x2
74
75//
76// Enumeration for the search type. A search type is specified as the keyword to find
77// a cache entry in the cache table.
78//
79typedef enum {
80 ByNone = 0,
81 ByProtoAddress = MATCH_SW_ADDRESS,
82 ByHwAddress = MATCH_HW_ADDRESS,
83 ByBoth = MATCH_SW_ADDRESS | MATCH_HW_ADDRESS
84} FIND_OPTYPE;
85
86#define ARP_INSTANCE_DATA_SIGNATURE SIGNATURE_32('A', 'R', 'P', 'I')
87
98#define ARP_INSTANCE_DATA_FROM_THIS(a) \
99 CR ( \
100 (a), \
101 ARP_INSTANCE_DATA, \
102 ArpProto, \
103 ARP_INSTANCE_DATA_SIGNATURE \
104 )
105
107
108//
109// ARP instance context data structure.
110//
111typedef struct {
112 UINT32 Signature;
113 ARP_SERVICE_DATA *ArpService;
114 EFI_HANDLE Handle;
115 EFI_ARP_PROTOCOL ArpProto;
116 LIST_ENTRY List;
117 EFI_ARP_CONFIG_DATA ConfigData;
118 BOOLEAN Configured;
119 BOOLEAN InDestroy;
121
122#define ARP_SERVICE_DATA_SIGNATURE SIGNATURE_32('A', 'R', 'P', 'S')
123
134#define ARP_SERVICE_DATA_FROM_THIS(a) \
135 CR ( \
136 (a), \
137 ARP_SERVICE_DATA, \
138 ServiceBinding, \
139 ARP_SERVICE_DATA_SIGNATURE \
140 )
141
142//
143// ARP service data structure.
144//
146 UINT32 Signature;
147 EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;
148
149 EFI_HANDLE MnpChildHandle;
150 EFI_HANDLE ImageHandle;
151 EFI_HANDLE ControllerHandle;
152
156
158
159 UINTN ChildrenNumber;
160 LIST_ENTRY ChildrenList;
161
162 LIST_ENTRY PendingRequestTable;
163 LIST_ENTRY DeniedCacheTable;
164 LIST_ENTRY ResolvedCacheTable;
165
166 EFI_EVENT PeriodicTimer;
167};
168
169//
170// User request context structure.
171//
172typedef struct {
173 LIST_ENTRY List;
174 ARP_INSTANCE_DATA *Instance;
175 EFI_EVENT UserRequestEvent;
176 VOID *UserHwAddrBuffer;
178
179#define ARP_MAX_PROTOCOL_ADDRESS_LEN sizeof(EFI_IP_ADDRESS)
180#define ARP_MAX_HARDWARE_ADDRESS_LEN sizeof(EFI_MAC_ADDRESS)
181
182typedef union {
183 UINT8 ProtoAddress[ARP_MAX_PROTOCOL_ADDRESS_LEN];
184 UINT8 HwAddress[ARP_MAX_HARDWARE_ADDRESS_LEN];
186
187//
188// ARP address structure in an ARP packet.
189//
190typedef struct {
191 UINT16 Type;
192 UINT8 Length;
193 UINT8 *AddressPtr;
196
197//
198// Enumeration for ARP address type.
199//
200typedef enum {
201 Hardware,
202 Protocol
203} ARP_ADDRESS_TYPE;
204
205//
206// ARP cache entry definition.
207//
208typedef struct {
209 LIST_ENTRY List;
210
211 UINT32 RetryCount;
212 UINT32 DefaultDecayTime;
213 UINT32 DecayTime;
214 UINT32 NextRetryTime;
215
216 NET_ARP_ADDRESS Addresses[2];
217
218 LIST_ENTRY UserRequestList;
220
250EFIAPI
252 IN EFI_ARP_PROTOCOL *This,
253 IN EFI_ARP_CONFIG_DATA *ConfigData OPTIONAL
254 );
255
302EFIAPI
303ArpAdd (
304 IN EFI_ARP_PROTOCOL *This,
305 IN BOOLEAN DenyFlag,
306 IN VOID *TargetSwAddress OPTIONAL,
307 IN VOID *TargetHwAddress OPTIONAL,
308 IN UINT32 TimeoutValue,
309 IN BOOLEAN Overwrite
310 );
311
347EFIAPI
348ArpFind (
349 IN EFI_ARP_PROTOCOL *This,
350 IN BOOLEAN BySwAddress,
351 IN VOID *AddressBuffer OPTIONAL,
352 OUT UINT32 *EntryLength OPTIONAL,
353 OUT UINT32 *EntryCount OPTIONAL,
354 OUT EFI_ARP_FIND_DATA **Entries OPTIONAL,
355 IN BOOLEAN Refresh
356 );
357
376EFIAPI
377ArpDelete (
378 IN EFI_ARP_PROTOCOL *This,
379 IN BOOLEAN BySwAddress,
380 IN VOID *AddressBuffer OPTIONAL
381 );
382
396EFIAPI
397ArpFlush (
398 IN EFI_ARP_PROTOCOL *This
399 );
400
424EFIAPI
426 IN EFI_ARP_PROTOCOL *This,
427 IN VOID *TargetSwAddress OPTIONAL,
428 IN EFI_EVENT ResolvedEvent OPTIONAL,
429 OUT VOID *TargetHwAddress
430 );
431
460EFIAPI
461ArpCancel (
462 IN EFI_ARP_PROTOCOL *This,
463 IN VOID *TargetSwAddress OPTIONAL,
464 IN EFI_EVENT ResolvedEvent OPTIONAL
465 );
466
487 IN ARP_INSTANCE_DATA *Instance,
488 IN EFI_ARP_CONFIG_DATA *ConfigData OPTIONAL
489 );
490
504 IN ARP_SERVICE_DATA *ArpService,
505 IN NET_ARP_ADDRESS *ProtocolAddress OPTIONAL,
506 IN NET_ARP_ADDRESS *HardwareAddress OPTIONAL
507 );
508
524 IN LIST_ENTRY *CacheTable,
525 IN LIST_ENTRY *StartEntry,
526 IN FIND_OPTYPE FindOpType,
527 IN NET_ARP_ADDRESS *ProtocolAddress OPTIONAL,
528 IN NET_ARP_ADDRESS *HardwareAddress OPTIONAL
529 );
530
541 IN ARP_INSTANCE_DATA *Instance
542 );
543
555VOID
557 IN ARP_CACHE_ENTRY *CacheEntry,
558 IN NET_ARP_ADDRESS *HwAddr OPTIONAL,
559 IN NET_ARP_ADDRESS *SwAddr OPTIONAL
560 );
561
572UINTN
574 IN ARP_CACHE_ENTRY *CacheEntry,
575 IN ARP_INSTANCE_DATA *Instance OPTIONAL,
576 IN EFI_EVENT UserEvent OPTIONAL
577 );
578
592UINTN
594 IN ARP_INSTANCE_DATA *Instance,
595 IN BOOLEAN BySwAddress,
596 IN UINT8 *AddressBuffer OPTIONAL,
597 IN BOOLEAN Force
598 );
599
612VOID
614 IN ARP_INSTANCE_DATA *Instance,
615 IN ARP_CACHE_ENTRY *CacheEntry,
616 IN UINT16 ArpOpCode
617 );
618
629VOID
631 IN ARP_SERVICE_DATA *ArpService,
632 OUT ARP_INSTANCE_DATA *Instance
633 );
634
644VOID
645EFIAPI
647 IN VOID *Context
648 );
649
660VOID
661EFIAPI
663 IN EFI_EVENT Event,
664 IN VOID *Context
665 );
666
676VOID
677EFIAPI
679 IN VOID *Context
680 );
681
692VOID
693EFIAPI
695 IN EFI_EVENT Event,
696 IN VOID *Context
697 );
698
709VOID
710EFIAPI
712 IN EFI_EVENT Event,
713 IN VOID *Context
714 );
715
728UINTN
730 IN ARP_INSTANCE_DATA *Instance,
731 IN VOID *TargetSwAddress OPTIONAL,
732 IN EFI_EVENT UserEvent OPTIONAL
733 );
734
760 IN ARP_INSTANCE_DATA *Instance,
761 IN BOOLEAN BySwAddress,
762 IN VOID *AddressBuffer OPTIONAL,
763 OUT UINT32 *EntryLength OPTIONAL,
764 OUT UINT32 *EntryCount OPTIONAL,
765 OUT EFI_ARP_FIND_DATA **Entries OPTIONAL,
766 IN BOOLEAN Refresh
767 );
768
769#endif
UINT64 UINTN
EFI_STATUS ArpConfigureInstance(IN ARP_INSTANCE_DATA *Instance, IN EFI_ARP_CONFIG_DATA *ConfigData OPTIONAL)
Definition: ArpImpl.c:906
VOID ArpSendFrame(IN ARP_INSTANCE_DATA *Instance, IN ARP_CACHE_ENTRY *CacheEntry, IN UINT16 ArpOpCode)
Definition: ArpImpl.c:1027
UINTN ArpDeleteCacheEntry(IN ARP_INSTANCE_DATA *Instance, IN BOOLEAN BySwAddress, IN UINT8 *AddressBuffer OPTIONAL, IN BOOLEAN Force)
Definition: ArpImpl.c:1326
ARP_CACHE_ENTRY * ArpFindNextCacheEntryInTable(IN LIST_ENTRY *CacheTable, IN LIST_ENTRY *StartEntry, IN FIND_OPTYPE FindOpType, IN NET_ARP_ADDRESS *ProtocolAddress OPTIONAL, IN NET_ARP_ADDRESS *HardwareAddress OPTIONAL)
Definition: ArpImpl.c:589
EFI_STATUS EFIAPI ArpCancel(IN EFI_ARP_PROTOCOL *This, IN VOID *TargetSwAddress OPTIONAL, IN EFI_EVENT ResolvedEvent OPTIONAL)
Definition: ArpMain.c:698
UINTN ArpAddressResolved(IN ARP_CACHE_ENTRY *CacheEntry, IN ARP_INSTANCE_DATA *Instance OPTIONAL, IN EFI_EVENT UserEvent OPTIONAL)
Definition: ArpImpl.c:783
VOID EFIAPI ArpOnFrameRcvd(IN EFI_EVENT Event, IN VOID *Context)
Definition: ArpImpl.c:333
VOID EFIAPI ArpOnFrameRcvdDpc(IN VOID *Context)
Definition: ArpImpl.c:64
VOID EFIAPI ArpOnFrameSentDpc(IN VOID *Context)
Definition: ArpImpl.c:355
VOID EFIAPI ArpOnFrameSent(IN EFI_EVENT Event, IN VOID *Context)
Definition: ArpImpl.c:395
EFI_STATUS ArpFindCacheEntry(IN ARP_INSTANCE_DATA *Instance, IN BOOLEAN BySwAddress, IN VOID *AddressBuffer OPTIONAL, OUT UINT32 *EntryLength OPTIONAL, OUT UINT32 *EntryCount OPTIONAL, OUT EFI_ARP_FIND_DATA **Entries OPTIONAL, IN BOOLEAN Refresh)
Definition: ArpImpl.c:1448
EFI_STATUS EFIAPI ArpRequest(IN EFI_ARP_PROTOCOL *This, IN VOID *TargetSwAddress OPTIONAL, IN EFI_EVENT ResolvedEvent OPTIONAL, OUT VOID *TargetHwAddress)
Definition: ArpMain.c:476
EFI_STATUS EFIAPI ArpConfigure(IN EFI_ARP_PROTOCOL *This, IN EFI_ARP_CONFIG_DATA *ConfigData OPTIONAL)
Definition: ArpMain.c:41
EFI_STATUS EFIAPI ArpFind(IN EFI_ARP_PROTOCOL *This, IN BOOLEAN BySwAddress, IN VOID *AddressBuffer OPTIONAL, OUT UINT32 *EntryLength OPTIONAL, OUT UINT32 *EntryCount OPTIONAL, OUT EFI_ARP_FIND_DATA **Entries OPTIONAL, IN BOOLEAN Refresh)
Definition: ArpMain.c:310
VOID EFIAPI ArpTimerHandler(IN EFI_EVENT Event, IN VOID *Context)
Definition: ArpImpl.c:418
UINTN ArpCancelRequest(IN ARP_INSTANCE_DATA *Instance, IN VOID *TargetSwAddress OPTIONAL, IN EFI_EVENT UserEvent OPTIONAL)
Definition: ArpImpl.c:1378
EFI_STATUS EFIAPI ArpAdd(IN EFI_ARP_PROTOCOL *This, IN BOOLEAN DenyFlag, IN VOID *TargetSwAddress OPTIONAL, IN VOID *TargetHwAddress OPTIONAL, IN UINT32 TimeoutValue, IN BOOLEAN Overwrite)
Definition: ArpMain.c:123
EFI_STATUS EFIAPI ArpDelete(IN EFI_ARP_PROTOCOL *This, IN BOOLEAN BySwAddress, IN VOID *AddressBuffer OPTIONAL)
Definition: ArpMain.c:376
ARP_CACHE_ENTRY * ArpAllocCacheEntry(IN ARP_INSTANCE_DATA *Instance)
Definition: ArpImpl.c:715
VOID ArpFillAddressInCacheEntry(IN ARP_CACHE_ENTRY *CacheEntry, IN NET_ARP_ADDRESS *HwAddr OPTIONAL, IN NET_ARP_ADDRESS *SwAddr OPTIONAL)
Definition: ArpImpl.c:845
EFI_STATUS EFIAPI ArpFlush(IN EFI_ARP_PROTOCOL *This)
Definition: ArpMain.c:422
VOID ArpInitInstance(IN ARP_SERVICE_DATA *ArpService, OUT ARP_INSTANCE_DATA *Instance)
Definition: ArpImpl.c:35
ARP_CACHE_ENTRY * ArpFindDeniedCacheEntry(IN ARP_SERVICE_DATA *ArpService, IN NET_ARP_ADDRESS *ProtocolAddress OPTIONAL, IN NET_ARP_ADDRESS *HardwareAddress OPTIONAL)
Definition: ArpImpl.c:658
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_EVENT
Definition: UefiBaseType.h:37
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33