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