]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Protocol/Arp.h
MdePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdePkg / Include / Protocol / Arp.h
1 /** @file
2 EFI ARP Protocol Definition
3
4 The EFI ARP Service Binding Protocol is used to locate EFI
5 ARP Protocol drivers to create and destroy child of the
6 driver to communicate with other host using ARP protocol.
7 The EFI ARP Protocol provides services to map IP network
8 address to hardware address used by a data link protocol.
9
10 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
11 SPDX-License-Identifier: BSD-2-Clause-Patent
12
13 @par Revision Reference:
14 This Protocol was introduced in UEFI Specification 2.0.
15
16 **/
17
18 #ifndef __EFI_ARP_PROTOCOL_H__
19 #define __EFI_ARP_PROTOCOL_H__
20
21 #define EFI_ARP_SERVICE_BINDING_PROTOCOL_GUID \
22 { \
23 0xf44c00ee, 0x1f2c, 0x4a00, {0xaa, 0x9, 0x1c, 0x9f, 0x3e, 0x8, 0x0, 0xa3 } \
24 }
25
26 #define EFI_ARP_PROTOCOL_GUID \
27 { \
28 0xf4b427bb, 0xba21, 0x4f16, {0xbc, 0x4e, 0x43, 0xe4, 0x16, 0xab, 0x61, 0x9c } \
29 }
30
31 typedef struct _EFI_ARP_PROTOCOL EFI_ARP_PROTOCOL;
32
33 typedef struct {
34 ///
35 /// Length in bytes of this entry.
36 ///
37 UINT32 Size;
38
39 ///
40 /// Set to TRUE if this entry is a "deny" entry.
41 /// Set to FALSE if this entry is a "normal" entry.
42 ///
43 BOOLEAN DenyFlag;
44
45 ///
46 /// Set to TRUE if this entry will not time out.
47 /// Set to FALSE if this entry will time out.
48 ///
49 BOOLEAN StaticFlag;
50
51 ///
52 /// 16-bit ARP hardware identifier number.
53 ///
54 UINT16 HwAddressType;
55
56 ///
57 /// 16-bit protocol type number.
58 ///
59 UINT16 SwAddressType;
60
61 ///
62 /// The length of the hardware address.
63 ///
64 UINT8 HwAddressLength;
65
66 ///
67 /// The length of the protocol address.
68 ///
69 UINT8 SwAddressLength;
70 } EFI_ARP_FIND_DATA;
71
72 typedef struct {
73 ///
74 /// 16-bit protocol type number in host byte order.
75 ///
76 UINT16 SwAddressType;
77
78 ///
79 /// The length in bytes of the station's protocol address to register.
80 ///
81 UINT8 SwAddressLength;
82
83 ///
84 /// The pointer to the first byte of the protocol address to register. For
85 /// example, if SwAddressType is 0x0800 (IP), then
86 /// StationAddress points to the first byte of this station's IP
87 /// address stored in network byte order.
88 ///
89 VOID *StationAddress;
90
91 ///
92 /// The timeout value in 100-ns units that is associated with each
93 /// new dynamic ARP cache entry. If it is set to zero, the value is
94 /// implementation-specific.
95 ///
96 UINT32 EntryTimeOut;
97
98 ///
99 /// The number of retries before a MAC address is resolved. If it is
100 /// set to zero, the value is implementation-specific.
101 ///
102 UINT32 RetryCount;
103
104 ///
105 /// The timeout value in 100-ns units that is used to wait for the ARP
106 /// reply packet or the timeout value between two retries. Set to zero
107 /// to use implementation-specific value.
108 ///
109 UINT32 RetryTimeOut;
110 } EFI_ARP_CONFIG_DATA;
111
112
113 /**
114 This function is used to assign a station address to the ARP cache for this instance
115 of the ARP driver.
116
117 Each ARP instance has one station address. The EFI_ARP_PROTOCOL driver will
118 respond to ARP requests that match this registered station address. A call to
119 this function with the ConfigData field set to NULL will reset this ARP instance.
120
121 Once a protocol type and station address have been assigned to this ARP instance,
122 all the following ARP functions will use this information. Attempting to change
123 the protocol type or station address to a configured ARP instance will result in errors.
124
125 @param This The pointer to the EFI_ARP_PROTOCOL instance.
126 @param ConfigData The pointer to the EFI_ARP_CONFIG_DATA structure.
127
128 @retval EFI_SUCCESS The new station address was successfully
129 registered.
130 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
131 * This is NULL.
132 * SwAddressLength is zero when ConfigData is not NULL.
133 * StationAddress is NULL when ConfigData is not NULL.
134 @retval EFI_ACCESS_DENIED The SwAddressType, SwAddressLength, or
135 StationAddress is different from the one that is
136 already registered.
137 @retval EFI_OUT_OF_RESOURCES Storage for the new StationAddress could not be
138 allocated.
139
140 **/
141 typedef
142 EFI_STATUS
143 (EFIAPI *EFI_ARP_CONFIGURE)(
144 IN EFI_ARP_PROTOCOL *This,
145 IN EFI_ARP_CONFIG_DATA *ConfigData OPTIONAL
146 );
147
148 /**
149 This function is used to insert entries into the ARP cache.
150
151 ARP cache entries are typically inserted and updated by network protocol drivers
152 as network traffic is processed. Most ARP cache entries will time out and be
153 deleted if the network traffic stops. ARP cache entries that were inserted
154 by the Add() function may be static (will not time out) or dynamic (will time out).
155 Default ARP cache timeout values are not covered in most network protocol
156 specifications (although RFC 1122 comes pretty close) and will only be
157 discussed in general terms in this specification. The timeout values that are
158 used in the EFI Sample Implementation should be used only as a guideline.
159 Final product implementations of the EFI network stack should be tuned for
160 their expected network environments.
161
162 @param This Pointer to the EFI_ARP_PROTOCOL instance.
163 @param DenyFlag Set to TRUE if this entry is a deny entry. Set to
164 FALSE if this entry is a normal entry.
165 @param TargetSwAddress Pointer to a protocol address to add (or deny).
166 May be set to NULL if DenyFlag is TRUE.
167 @param TargetHwAddress Pointer to a hardware address to add (or deny).
168 May be set to NULL if DenyFlag is TRUE.
169 @param TimeoutValue Time in 100-ns units that this entry will remain
170 in the ARP cache. A value of zero means that the
171 entry is permanent. A nonzero value will override
172 the one given by Configure() if the entry to be
173 added is a dynamic entry.
174 @param Overwrite If TRUE, the matching cache entry will be
175 overwritten with the supplied parameters. If
176 FALSE, EFI_ACCESS_DENIED is returned if the
177 corresponding cache entry already exists.
178
179 @retval EFI_SUCCESS The entry has been added or updated.
180 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
181 * This is NULL.
182 * DenyFlag is FALSE and TargetHwAddress is NULL.
183 * DenyFlag is FALSE and TargetSwAddress is NULL.
184 * TargetHwAddress is NULL and TargetSwAddress is NULL.
185 * Neither TargetSwAddress nor TargetHwAddress are NULL when DenyFlag is
186 TRUE.
187 @retval EFI_OUT_OF_RESOURCES The new ARP cache entry could not be allocated.
188 @retval EFI_ACCESS_DENIED The ARP cache entry already exists and Overwrite
189 is not true.
190 @retval EFI_NOT_STARTED The ARP driver instance has not been configured.
191
192 **/
193 typedef
194 EFI_STATUS
195 (EFIAPI *EFI_ARP_ADD)(
196 IN EFI_ARP_PROTOCOL *This,
197 IN BOOLEAN DenyFlag,
198 IN VOID *TargetSwAddress OPTIONAL,
199 IN VOID *TargetHwAddress OPTIONAL,
200 IN UINT32 TimeoutValue,
201 IN BOOLEAN Overwrite
202 );
203
204 /**
205 This function searches the ARP cache for matching entries and allocates a buffer into
206 which those entries are copied.
207
208 The first part of the allocated buffer is EFI_ARP_FIND_DATA, following which
209 are protocol address pairs and hardware address pairs.
210 When finding a specific protocol address (BySwAddress is TRUE and AddressBuffer
211 is not NULL), the ARP cache timeout for the found entry is reset if Refresh is
212 set to TRUE. If the found ARP cache entry is a permanent entry, it is not
213 affected by Refresh.
214
215 @param This The pointer to the EFI_ARP_PROTOCOL instance.
216 @param BySwAddress Set to TRUE to look for matching software protocol
217 addresses. Set to FALSE to look for matching
218 hardware protocol addresses.
219 @param AddressBuffer The pointer to the address buffer. Set to NULL
220 to match all addresses.
221 @param EntryLength The size of an entry in the entries buffer.
222 @param EntryCount The number of ARP cache entries that are found by
223 the specified criteria.
224 @param Entries The pointer to the buffer that will receive the ARP
225 cache entries.
226 @param Refresh Set to TRUE to refresh the timeout value of the
227 matching ARP cache entry.
228
229 @retval EFI_SUCCESS The requested ARP cache entries were copied into
230 the buffer.
231 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
232 This is NULL. Both EntryCount and EntryLength are
233 NULL, when Refresh is FALSE.
234 @retval EFI_NOT_FOUND No matching entries were found.
235 @retval EFI_NOT_STARTED The ARP driver instance has not been configured.
236
237 **/
238 typedef
239 EFI_STATUS
240 (EFIAPI *EFI_ARP_FIND)(
241 IN EFI_ARP_PROTOCOL *This,
242 IN BOOLEAN BySwAddress,
243 IN VOID *AddressBuffer OPTIONAL,
244 OUT UINT32 *EntryLength OPTIONAL,
245 OUT UINT32 *EntryCount OPTIONAL,
246 OUT EFI_ARP_FIND_DATA **Entries OPTIONAL,
247 IN BOOLEAN Refresh
248 );
249
250
251 /**
252 This function removes specified ARP cache entries.
253
254 @param This The pointer to the EFI_ARP_PROTOCOL instance.
255 @param BySwAddress Set to TRUE to delete matching protocol addresses.
256 Set to FALSE to delete matching hardware
257 addresses.
258 @param AddressBuffer The pointer to the address buffer that is used as a
259 key to look for the cache entry. Set to NULL to
260 delete all entries.
261
262 @retval EFI_SUCCESS The entry was removed from the ARP cache.
263 @retval EFI_INVALID_PARAMETER This is NULL.
264 @retval EFI_NOT_FOUND The specified deletion key was not found.
265 @retval EFI_NOT_STARTED The ARP driver instance has not been configured.
266
267 **/
268 typedef
269 EFI_STATUS
270 (EFIAPI *EFI_ARP_DELETE)(
271 IN EFI_ARP_PROTOCOL *This,
272 IN BOOLEAN BySwAddress,
273 IN VOID *AddressBuffer OPTIONAL
274 );
275
276 /**
277 This function delete all dynamic entries from the ARP cache that match the specified
278 software protocol type.
279
280 @param This The pointer to the EFI_ARP_PROTOCOL instance.
281
282 @retval EFI_SUCCESS The cache has been flushed.
283 @retval EFI_INVALID_PARAMETER This is NULL.
284 @retval EFI_NOT_FOUND There are no matching dynamic cache entries.
285 @retval EFI_NOT_STARTED The ARP driver instance has not been configured.
286
287 **/
288 typedef
289 EFI_STATUS
290 (EFIAPI *EFI_ARP_FLUSH)(
291 IN EFI_ARP_PROTOCOL *This
292 );
293
294 /**
295 This function tries to resolve the TargetSwAddress and optionally returns a
296 TargetHwAddress if it already exists in the ARP cache.
297
298 @param This The pointer to the EFI_ARP_PROTOCOL instance.
299 @param TargetSwAddress The pointer to the protocol address to resolve.
300 @param ResolvedEvent The pointer to the event that will be signaled when
301 the address is resolved or some error occurs.
302 @param TargetHwAddress The pointer to the buffer for the resolved hardware
303 address in network byte order.
304
305 @retval EFI_SUCCESS The data is copied from the ARP cache into the
306 TargetHwAddress buffer.
307 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
308 This is NULL. TargetHwAddress is NULL.
309 @retval EFI_ACCESS_DENIED The requested address is not present in the normal
310 ARP cache but is present in the deny address list.
311 Outgoing traffic to that address is forbidden.
312 @retval EFI_NOT_STARTED The ARP driver instance has not been configured.
313 @retval EFI_NOT_READY The request has been started and is not finished.
314
315 **/
316 typedef
317 EFI_STATUS
318 (EFIAPI *EFI_ARP_REQUEST)(
319 IN EFI_ARP_PROTOCOL *This,
320 IN VOID *TargetSwAddress OPTIONAL,
321 IN EFI_EVENT ResolvedEvent OPTIONAL,
322 OUT VOID *TargetHwAddress
323 );
324
325 /**
326 This function aborts the previous ARP request (identified by This, TargetSwAddress
327 and ResolvedEvent) that is issued by EFI_ARP_PROTOCOL.Request().
328
329 If the request is in the internal ARP request queue, the request is aborted
330 immediately and its ResolvedEvent is signaled. Only an asynchronous address
331 request needs to be canceled. If TargeSwAddress and ResolveEvent are both
332 NULL, all the pending asynchronous requests that have been issued by This
333 instance will be cancelled and their corresponding events will be signaled.
334
335 @param This The pointer to the EFI_ARP_PROTOCOL instance.
336 @param TargetSwAddress The pointer to the protocol address in previous
337 request session.
338 @param ResolvedEvent Pointer to the event that is used as the
339 notification event in previous request session.
340
341 @retval EFI_SUCCESS The pending request session(s) is/are aborted and
342 corresponding event(s) is/are signaled.
343 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
344 This is NULL. TargetSwAddress is not NULL and
345 ResolvedEvent is NULL. TargetSwAddress is NULL and
346 ResolvedEvent is not NULL.
347 @retval EFI_NOT_STARTED The ARP driver instance has not been configured.
348 @retval EFI_NOT_FOUND The request is not issued by
349 EFI_ARP_PROTOCOL.Request().
350
351
352 **/
353 typedef
354 EFI_STATUS
355 (EFIAPI *EFI_ARP_CANCEL)(
356 IN EFI_ARP_PROTOCOL *This,
357 IN VOID *TargetSwAddress OPTIONAL,
358 IN EFI_EVENT ResolvedEvent OPTIONAL
359 );
360
361 ///
362 /// ARP is used to resolve local network protocol addresses into
363 /// network hardware addresses.
364 ///
365 struct _EFI_ARP_PROTOCOL {
366 EFI_ARP_CONFIGURE Configure;
367 EFI_ARP_ADD Add;
368 EFI_ARP_FIND Find;
369 EFI_ARP_DELETE Delete;
370 EFI_ARP_FLUSH Flush;
371 EFI_ARP_REQUEST Request;
372 EFI_ARP_CANCEL Cancel;
373 };
374
375
376 extern EFI_GUID gEfiArpServiceBindingProtocolGuid;
377 extern EFI_GUID gEfiArpProtocolGuid;
378
379 #endif