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