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