Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Anchor10439521043952 DNSc_GetHostByName() Anchor10444111044411Converts the string representation of a host name to its corresponding IP address using DNS service. Anchor10444511044451

Files

...

...

dns-c.h/dns-c.c

...

Prototype

HTML Tablecode

...

NET_IP_ADDR dns_ip;   dns_ip = DNSc_GetHostByName("www.micrium.com");tr NET_IP_ADDR DNSc_GetHostByName (CPU_CHAR *host_name);
HTML Table
classCode_Listing
Table Row (tr)
Table Cell (td)
rowspan8
Anchor
10474941047494
Anchor
10474971047497
Anchor
10479301047930
Table Row (tr)
Table Row (tr)
Table Row (tr)
Table Row (tr)
Table Row (tr)
Table Row (tr)
classlanguageCode_Listing
Table Row (tr)
Table Cell (td)
rowspan5
Anchor
10444861044486
Table Row (tr)
Table Row (tr)
Table Row (tr)
Table Row (tr)

...

cpp
DNSc_STATUS  DNSc_GetHost(const  CPU_CHAR       *p_host_name,
                                 CPU_CHAR       *p_res_host_name,
                                 CPU_INT32U      res_hostname_len,
                                 DNSc_ADDR_OBJ  *p_addrs,
                                 CPU_INT08U     *p_addr_nbr,
                                 DNSc_FLAGS      flags,
                                 DNSc_REQ_CFG   *p_cfg,
                                 DNSc_ERR       *p_err)
p_host_namePointer to a string that contains the host name.
p_res_host_name

Pointer to a string that will receive the host name resulting from a reverse lookup OR the canonical name resulting from a forward lookup with the DNSc_FLAG_CANON set.
This argument should be left DEF_NULL if a simple forward DNS request is desired.

res_hostname_len

String length of p_res_host_name. This argument should evaluate to 0 if a simple forward DNS request is desired (with DNSc_FLAG_CANON cleared).

p_addrsPointer to arrays that will receive the IP address(es) from this function.
p_addr_nbr

Pointer to a variable that:

(1) Indicates how many addresses can fit into the addresses array pointed by the 'p_addrs' argument.

and

(2) Will receive the number of address(es) copied into the addresses array.

flags

DNS client flag:

DNSc_FLAG_NONE - By default this function is blocking.
DNSc_FLAG_NO_BLOCK - Don't block (only possible if DNSc's task is enabled).
DNSc_FLAG_FORCE_CACHE - Take host from the cache, don't send new DNS request.
DNSc_FLAG_FORCE_RENEW - Force DNS request, remove existing entry in the cache.
DNSc_FLAG_FORCE_RESOLUTION - Force DNS to resolve given host name.
DNSc_FLAG_IPv4_ONLY - Return only IPv4 address(es) (A type).
DNSc_FLAG_IPv6_ONLY - Return only IPv6 address(es) (AAAA type).
DNSc_FLAG_REVERSE_LOOKUP - Issue a reverse DNS lookup for an IP address (PTR type).
DNSc_FLAG_CANON - Process canonical name if present in DNS answers.

p_cfg

Pointer to a request configuration. Should be used to override the default DNS configuration's values for DNS server, request timeout, etc. per request.

Must be set to DEF_NULL to use default configuration.

p_errPointer to variable that will receive the return error code from this function.


Arguments

Returned Values

Resolution status:

DNSc_STATUS_PENDING  Host resolution is pending, call again to see the status. (Processed by DNSc's task)
DNSc_STATUS_RESOLVED Host is resolved.
DNSc_STATUS_FAILED Host resolution has failed.

Required Configuration

None.

Notes / Warnings

(1) If this function successfully resolves a reverse lookup, the host's address information is added to the cache just as it would be for a forward lookup.

(2) If a forward request is successfully resolved and a reverse request is issued for the same host name, the same host cache entry will be used and the

     reverse name will be updated internally.

(3) DNSc_FLAG_REVERSE_LOOKUP and DNSc_FLAG_CANON flags cannot not be set simultaneously.

(4) DNSc_FLAG_FORCE_CACHE and DNSc_FLAG_FORCE_RENEW flags cannot be set simultaneously.

(5) DNSc_FLAG_UPDATE_PREF and DNSc_FLAG_RESET_REQ flags are meant for internal use and should never be set.

Example Usage

See Sample Application.