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