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