]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Protocol/Dns4.h
OvmfPkg: Skip initrd command on Xcode toolchain
[mirror_edk2.git] / MdePkg / Include / Protocol / Dns4.h
1 /** @file
2 This file defines the EFI Domain Name Service Binding Protocol interface. It is split
3 into the following two main sections:
4 DNSv4 Service Binding Protocol (DNSv4SB)
5 DNSv4 Protocol (DNSv4)
6
7 Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
8 SPDX-License-Identifier: BSD-2-Clause-Patent
9
10 @par Revision Reference:
11 This Protocol is introduced in UEFI Specification 2.5
12
13 **/
14
15 #ifndef __EFI_DNS4_PROTOCOL_H__
16 #define __EFI_DNS4_PROTOCOL_H__
17
18 #define EFI_DNS4_SERVICE_BINDING_PROTOCOL_GUID \
19 { \
20 0xb625b186, 0xe063, 0x44f7, {0x89, 0x5, 0x6a, 0x74, 0xdc, 0x6f, 0x52, 0xb4 } \
21 }
22
23 #define EFI_DNS4_PROTOCOL_GUID \
24 { \
25 0xae3d28cc, 0xe05b, 0x4fa1, {0xa0, 0x11, 0x7e, 0xb5, 0x5a, 0x3f, 0x14, 0x1 } \
26 }
27
28 typedef struct _EFI_DNS4_PROTOCOL EFI_DNS4_PROTOCOL;
29
30 ///
31 /// EFI_DNS4_CONFIG_DATA
32 ///
33 typedef struct {
34 ///
35 /// Count of the DNS servers. When used with GetModeData(),
36 /// this field is the count of originally configured servers when
37 /// Configure() was called for this instance. When used with
38 /// Configure() this is the count of caller-supplied servers. If the
39 /// DnsServerListCount is zero, the DNS server configuration
40 /// will be retrieved from DHCP server automatically.
41 ///
42 UINTN DnsServerListCount;
43 ///
44 /// Pointer to DNS server list containing DnsServerListCount entries or NULL
45 /// if DnsServerListCountis 0. For Configure(), this will be NULL when there are
46 /// no caller supplied server addresses, and, the DNS instance will retrieve
47 /// DNS server from DHCP Server. The provided DNS server list is
48 /// recommended to be filled up in the sequence of preference. When
49 /// used with GetModeData(), the buffer containing the list will
50 /// be allocated by the driver implementing this protocol and must be
51 /// freed by the caller. When used with Configure(), the buffer
52 /// containing the list will be allocated and released by the caller.
53 ///
54 EFI_IPv4_ADDRESS *DnsServerList;
55 ///
56 /// Set to TRUE to use the default IP address/subnet mask and default routing table.
57 ///
58 BOOLEAN UseDefaultSetting;
59 ///
60 /// If TRUE, enable DNS cache function for this DNS instance. If FALSE, all DNS
61 /// query will not lookup local DNS cache.
62 ///
63 BOOLEAN EnableDnsCache;
64 ///
65 /// Use the protocol number defined in "Links to UEFI-Related
66 /// Documents"(http://uefi.org/uefi) under the heading "IANA
67 /// Protocol Numbers". Only TCP or UDP are supported, and other
68 /// protocol values are invalid. An implementation can choose to
69 /// support only UDP, or both TCP and UDP.
70 ///
71 UINT8 Protocol;
72 ///
73 /// If UseDefaultSetting is FALSE indicates the station address to use.
74 ///
75 EFI_IPv4_ADDRESS StationIp;
76 ///
77 /// If UseDefaultSetting is FALSE indicates the subnet mask to use.
78 ///
79 EFI_IPv4_ADDRESS SubnetMask;
80 ///
81 /// Local port number. Set to zero to use the automatically assigned port number.
82 ///
83 UINT16 LocalPort;
84 ///
85 /// Retry number if no response received after RetryInterval.
86 ///
87 UINT32 RetryCount;
88 ///
89 /// Minimum interval of retry is 2 second. If the retry interval is less than 2
90 /// seconds, then use the 2 seconds.
91 ///
92 UINT32 RetryInterval;
93 } EFI_DNS4_CONFIG_DATA;
94
95
96 ///
97 /// EFI_DNS4_CACHE_ENTRY
98 ///
99 typedef struct {
100 ///
101 /// Host name.
102 ///
103 CHAR16 *HostName;
104 ///
105 /// IP address of this host.
106 ///
107 EFI_IPv4_ADDRESS *IpAddress;
108 ///
109 /// Time in second unit that this entry will remain in DNS cache. A value of zero
110 /// means that this entry is permanent. A nonzero value will override the existing
111 /// one if this entry to be added is dynamic entry. Implementations may set its
112 /// default timeout value for the dynamically created DNS cache entry after one DNS
113 /// resolve succeeds.
114 ///
115 UINT32 Timeout;
116 } EFI_DNS4_CACHE_ENTRY;
117
118 ///
119 /// EFI_DNS4_MODE_DATA
120 ///
121 typedef struct {
122 ///
123 /// The configuration data of this instance.
124 ///
125 EFI_DNS4_CONFIG_DATA DnsConfigData;
126 ///
127 /// Number of configured DNS server. Each DNS instance has its own DNS server
128 /// configuration.
129 ///
130 UINT32 DnsServerCount;
131 ///
132 /// Pointer to common list of addresses of all configured DNS server
133 /// used by EFI_DNS4_PROTOCOL instances. List will include
134 /// DNS servers configured by this or any other EFI_DNS4_PROTOCOL instance.
135 /// The storage for this list is allocated by the driver publishing this
136 /// protocol, and must be freed by the caller.
137 ///
138 EFI_IPv4_ADDRESS *DnsServerList;
139 ///
140 /// Number of DNS Cache entries. The DNS Cache is shared among all DNS instances.
141 ///
142 UINT32 DnsCacheCount;
143 ///
144 /// Pointer to a buffer containing DnsCacheCount DNS Cache
145 /// entry structures. The storage for this list is allocated by the driver
146 /// publishing this protocol and must be freed by caller.
147 ///
148 EFI_DNS4_CACHE_ENTRY *DnsCacheList;
149 } EFI_DNS4_MODE_DATA;
150
151 ///
152 /// DNS_HOST_TO_ADDR_DATA
153 ///
154 typedef struct {
155 ///
156 /// Number of the returned IP addresses.
157 ///
158 UINT32 IpCount;
159 ///
160 /// Pointer to the all the returned IP addresses.
161 ///
162 EFI_IPv4_ADDRESS *IpList;
163 } DNS_HOST_TO_ADDR_DATA;
164
165 ///
166 /// DNS_ADDR_TO_HOST_DATA
167 ///
168 typedef struct {
169 ///
170 /// Pointer to the primary name for this host address. It's the caller's
171 /// responsibility to free the response memory.
172 ///
173 CHAR16 *HostName;
174 } DNS_ADDR_TO_HOST_DATA;
175
176 ///
177 /// DNS_RESOURCE_RECORD
178 ///
179 typedef struct {
180 ///
181 /// The Owner name.
182 ///
183 CHAR8 *QName;
184 ///
185 /// The Type Code of this RR.
186 ///
187 UINT16 QType;
188 ///
189 /// The CLASS code of this RR.
190 ///
191 UINT16 QClass;
192 ///
193 /// 32 bit integer which specify the time interval that the resource record may be
194 /// cached before the source of the information should again be consulted. Zero means
195 /// this RR can not be cached.
196 ///
197 UINT32 TTL;
198 ///
199 /// 16 big integer which specify the length of RData.
200 ///
201 UINT16 DataLength;
202 ///
203 /// A string of octets that describe the resource, the format of this information
204 /// varies according to QType and QClass difference.
205 ///
206 CHAR8 *RData;
207 } DNS_RESOURCE_RECORD;
208
209 ///
210 /// DNS_GENERAL_LOOKUP_DATA
211 ///
212 typedef struct {
213 ///
214 /// Number of returned matching RRs.
215 ///
216 UINTN RRCount;
217 ///
218 /// Pointer to the all the returned matching RRs. It's caller responsibility to free
219 /// the allocated memory to hold the returned RRs.
220 ///
221 DNS_RESOURCE_RECORD *RRList;
222 } DNS_GENERAL_LOOKUP_DATA;
223
224 ///
225 /// EFI_DNS4_COMPLETION_TOKEN
226 ///
227 typedef struct {
228 ///
229 /// This Event will be signaled after the Status field is updated by the EFI DNS
230 /// protocol driver. The type of Event must be EFI_NOTIFY_SIGNAL.
231 ///
232 EFI_EVENT Event;
233 ///
234 /// Will be set to one of the following values:
235 /// EFI_SUCCESS: The host name to address translation completed successfully.
236 /// EFI_NOT_FOUND: No matching Resource Record (RR) is found.
237 /// EFI_TIMEOUT: No DNS server reachable, or RetryCount was exhausted without
238 /// response from all specified DNS servers.
239 /// EFI_DEVICE_ERROR: An unexpected system or network error occurred.
240 /// EFI_NO_MEDIA: There was a media error.
241 ///
242 EFI_STATUS Status;
243 ///
244 /// Retry number if no response received after RetryInterval. If zero, use the
245 /// parameter configured through Dns.Configure() interface.
246 ///
247 UINT32 RetryCount;
248 ///
249 /// Minimum interval of retry is 2 second. If the retry interval is less than 2
250 /// seconds, then use the 2 seconds. If zero, use the parameter configured through
251 /// Dns.Configure() interface.
252 UINT32 RetryInterval;
253 ///
254 /// DNSv4 completion token data
255 ///
256 union {
257 ///
258 /// When the Token is used for host name to address translation, H2AData is a pointer
259 /// to the DNS_HOST_TO_ADDR_DATA.
260 ///
261 DNS_HOST_TO_ADDR_DATA *H2AData;
262 ///
263 /// When the Token is used for host address to host name translation, A2HData is a
264 /// pointer to the DNS_ADDR_TO_HOST_DATA.
265 ///
266 DNS_ADDR_TO_HOST_DATA *A2HData;
267 ///
268 /// When the Token is used for a general lookup function, GLookupDATA is a pointer to
269 /// the DNS_GENERAL_LOOKUP_DATA.
270 ///
271 DNS_GENERAL_LOOKUP_DATA *GLookupData;
272 } RspData;
273 } EFI_DNS4_COMPLETION_TOKEN;
274
275 /**
276 Retrieve mode data of this DNS instance.
277
278 This function is used to retrieve DNS mode data for this DNS instance.
279
280 @param[in] This Pointer to EFI_DNS4_PROTOCOL instance.
281 @param[out] DnsModeData Point to the mode data.
282
283 @retval EFI_SUCCESS The operation completed successfully.
284 @retval EFI_NOT_STARTED When DnsConfigData is queried, no configuration data
285 is available because this instance has not been
286 configured.
287 @retval EFI_INVALID_PARAMETER This is NULL or DnsModeData is NULL.
288 @retval EFI_OUT_OF_RESOURCES Failed to allocate needed resources.
289 **/
290 typedef
291 EFI_STATUS
292 (EFIAPI *EFI_DNS4_GET_MODE_DATA) (
293 IN EFI_DNS4_PROTOCOL *This,
294 OUT EFI_DNS4_MODE_DATA *DnsModeData
295 );
296
297 /**
298 Configure this DNS instance.
299
300 This function is used to configure DNS mode data for this DNS instance.
301
302 @param[in] This Pointer to EFI_DNS4_PROTOCOL instance.
303 @param[in] DnsConfigData Point to the Configuration data.
304
305 @retval EFI_SUCCESS The operation completed successfully.
306 @retval EFI_UNSUPPORTED The designated protocol is not supported.
307 @retval EFI_INVALID_PARAMETER This is NULL.
308 The StationIp address provided in DnsConfigData is not a
309 valid unicast.
310 DnsServerList is NULL while DnsServerListCount
311 is not ZERO.
312 DnsServerListCount is ZERO while DnsServerList
313 is not NULL
314 @retval EFI_OUT_OF_RESOURCES The DNS instance data or required space could not be
315 allocated.
316 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. The
317 EFI DNSv4 Protocol instance is not configured.
318 @retval EFI_ALREADY_STARTED Second call to Configure() with DnsConfigData. To
319 reconfigure the instance the caller must call Configure()
320 with NULL first to return driver to unconfigured state.
321 **/
322 typedef
323 EFI_STATUS
324 (EFIAPI *EFI_DNS4_CONFIGURE) (
325 IN EFI_DNS4_PROTOCOL *This,
326 IN EFI_DNS4_CONFIG_DATA *DnsConfigData
327 );
328
329 /**
330 Host name to host address translation.
331
332 The HostNameToIp () function is used to translate the host name to host IP address. A
333 type A query is used to get the one or more IP addresses for this host.
334
335 @param[in] This Pointer to EFI_DNS4_PROTOCOL instance.
336 @param[in] HostName Host name.
337 @param[in] Token Point to the completion token to translate host name
338 to host address.
339
340 @retval EFI_SUCCESS The operation completed successfully.
341 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
342 This is NULL.
343 Token is NULL.
344 Token.Event is NULL.
345 HostName is NULL. HostName string is unsupported format.
346 @retval EFI_NO_MAPPING There's no source address is available for use.
347 @retval EFI_NOT_STARTED This instance has not been started.
348 **/
349 typedef
350 EFI_STATUS
351 (EFIAPI *EFI_DNS4_HOST_NAME_TO_IP) (
352 IN EFI_DNS4_PROTOCOL *This,
353 IN CHAR16 *HostName,
354 IN EFI_DNS4_COMPLETION_TOKEN *Token
355 );
356
357 /**
358 IPv4 address to host name translation also known as Reverse DNS lookup.
359
360 The IpToHostName() function is used to translate the host address to host name. A type PTR
361 query is used to get the primary name of the host. Support of this function is optional.
362
363 @param[in] This Pointer to EFI_DNS4_PROTOCOL instance.
364 @param[in] IpAddress Ip Address.
365 @param[in] Token Point to the completion token to translate host
366 address to host name.
367
368 @retval EFI_SUCCESS The operation completed successfully.
369 @retval EFI_UNSUPPORTED This function is not supported.
370 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
371 This is NULL.
372 Token is NULL.
373 Token.Event is NULL.
374 IpAddress is not valid IP address .
375 @retval EFI_NO_MAPPING There's no source address is available for use.
376 @retval EFI_ALREADY_STARTED This Token is being used in another DNS session.
377 @retval EFI_OUT_OF_RESOURCES Failed to allocate needed resources.
378 **/
379 typedef
380 EFI_STATUS
381 (EFIAPI *EFI_DNS4_IP_TO_HOST_NAME) (
382 IN EFI_DNS4_PROTOCOL *This,
383 IN EFI_IPv4_ADDRESS IpAddress,
384 IN EFI_DNS4_COMPLETION_TOKEN *Token
385 );
386
387 /**
388 Retrieve arbitrary information from the DNS server.
389
390 This GeneralLookup() function retrieves arbitrary information from the DNS. The caller
391 supplies a QNAME, QTYPE, and QCLASS, and all of the matching RRs are returned. All
392 RR content (e.g., TTL) was returned. The caller need parse the returned RR to get
393 required information. The function is optional.
394
395 @param[in] This Pointer to EFI_DNS4_PROTOCOL instance.
396 @param[in] QName Pointer to Query Name.
397 @param[in] QType Query Type.
398 @param[in] QClass Query Name.
399 @param[in] Token Point to the completion token to retrieve arbitrary
400 information.
401
402 @retval EFI_SUCCESS The operation completed successfully.
403 @retval EFI_UNSUPPORTED This function is not supported. Or the requested
404 QType is not supported
405 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
406 This is NULL.
407 Token is NULL.
408 Token.Event is NULL.
409 QName is NULL.
410 @retval EFI_NO_MAPPING There's no source address is available for use.
411 @retval EFI_ALREADY_STARTED This Token is being used in another DNS session.
412 @retval EFI_OUT_OF_RESOURCES Failed to allocate needed resources.
413 **/
414 typedef
415 EFI_STATUS
416 (EFIAPI *EFI_DNS4_GENERAL_LOOKUP) (
417 IN EFI_DNS4_PROTOCOL *This,
418 IN CHAR8 *QName,
419 IN UINT16 QType,
420 IN UINT16 QClass,
421 IN EFI_DNS4_COMPLETION_TOKEN *Token
422 );
423
424 /**
425 This function is to update the DNS Cache.
426
427 The UpdateDnsCache() function is used to add/delete/modify DNS cache entry. DNS cache
428 can be normally dynamically updated after the DNS resolve succeeds. This function
429 provided capability to manually add/delete/modify the DNS cache.
430
431 @param[in] This Pointer to EFI_DNS4_PROTOCOL instance.
432 @param[in] DeleteFlag If FALSE, this function is to add one entry to the
433 DNS Cahce. If TRUE, this function will delete
434 matching DNS Cache entry.
435 @param[in] Override If TRUE, the maching DNS cache entry will be
436 overwritten with the supplied parameter. If FALSE,
437 EFI_ACCESS_DENIED will be returned if the entry to
438 be added is already existed.
439 @param[in] DnsCacheEntry Pointer to DNS Cache entry.
440
441 @retval EFI_SUCCESS The operation completed successfully.
442 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
443 This is NULL.
444 DnsCacheEntry.HostName is NULL.
445 DnsCacheEntry.IpAddress is NULL.
446 DnsCacheEntry.Timeout is zero.
447 @retval EFI_ACCESS_DENIED The DNS cache entry already exists and Override is
448 not TRUE.
449 **/
450 typedef
451 EFI_STATUS
452 (EFIAPI *EFI_DNS4_UPDATE_DNS_CACHE) (
453 IN EFI_DNS4_PROTOCOL *This,
454 IN BOOLEAN DeleteFlag,
455 IN BOOLEAN Override,
456 IN EFI_DNS4_CACHE_ENTRY DnsCacheEntry
457 );
458
459 /**
460 Polls for incoming data packets and processes outgoing data packets.
461
462 The Poll() function can be used by network drivers and applications to increase the
463 rate that data packets are moved between the communications device and the transmit
464 and receive queues.
465 In some systems, the periodic timer event in the managed network driver may not poll
466 the underlying communications device fast enough to transmit and/or receive all data
467 packets without missing incoming packets or dropping outgoing packets. Drivers and
468 applications that are experiencing packet loss should try calling the Poll()
469 function more often.
470
471 @param[in] This Pointer to EFI_DNS4_PROTOCOL instance.
472
473 @retval EFI_SUCCESS Incoming or outgoing data was processed.
474 @retval EFI_NOT_STARTED This EFI DNS Protocol instance has not been started.
475 @retval EFI_INVALID_PARAMETER This is NULL.
476 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
477 @retval EFI_TIMEOUT Data was dropped out of the transmit and/or receive
478 queue. Consider increasing the polling rate.
479 **/
480 typedef
481 EFI_STATUS
482 (EFIAPI *EFI_DNS4_POLL) (
483 IN EFI_DNS4_PROTOCOL *This
484 );
485
486 /**
487 Abort an asynchronous DNS operation, including translation between IP and Host, and
488 general look up behavior.
489
490 The Cancel() function is used to abort a pending resolution request. After calling
491 this function, Token.Status will be set to EFI_ABORTED and then Token.Event will be
492 signaled. If the token is not in one of the queues, which usually means that the
493 asynchronous operation has completed, this function will not signal the token and
494 EFI_NOT_FOUND is returned.
495
496 @param[in] This Pointer to EFI_DNS4_PROTOCOL instance.
497 @param[in] Token Pointer to a token that has been issued by
498 EFI_DNS4_PROTOCOL.HostNameToIp (),
499 EFI_DNS4_PROTOCOL.IpToHostName() or
500 EFI_DNS4_PROTOCOL.GeneralLookup().
501 If NULL, all pending tokens are aborted.
502
503 @retval EFI_SUCCESS Incoming or outgoing data was processed.
504 @retval EFI_NOT_STARTED This EFI DNS4 Protocol instance has not been started.
505 @retval EFI_INVALID_PARAMETER This is NULL.
506 @retval EFI_NOT_FOUND When Token is not NULL, and the asynchronous DNS
507 operation was not found in the transmit queue. It
508 was either completed or was not issued by
509 HostNameToIp(), IpToHostName() or GeneralLookup().
510 **/
511 typedef
512 EFI_STATUS
513 (EFIAPI *EFI_DNS4_CANCEL) (
514 IN EFI_DNS4_PROTOCOL *This,
515 IN EFI_DNS4_COMPLETION_TOKEN *Token
516 );
517
518 ///
519 /// The EFI_DNS4_Protocol provides the function to get the host name and address
520 /// mapping, also provides pass through interface to retrieve arbitrary information
521 /// from DNS.
522 ///
523 struct _EFI_DNS4_PROTOCOL {
524 EFI_DNS4_GET_MODE_DATA GetModeData;
525 EFI_DNS4_CONFIGURE Configure;
526 EFI_DNS4_HOST_NAME_TO_IP HostNameToIp;
527 EFI_DNS4_IP_TO_HOST_NAME IpToHostName;
528 EFI_DNS4_GENERAL_LOOKUP GeneralLookUp;
529 EFI_DNS4_UPDATE_DNS_CACHE UpdateDnsCache;
530 EFI_DNS4_POLL Poll;
531 EFI_DNS4_CANCEL Cancel;
532 };
533
534 extern EFI_GUID gEfiDns4ServiceBindingProtocolGuid;
535 extern EFI_GUID gEfiDns4ProtocolGuid;
536
537 #endif