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