A version of LWIP, provided for backwards compatibility.
Dependents: AA_DemoBoard DemoBoard HelloServerDemo DemoBoard_RangeIndicator ... more
DNS - host name to IP address resolver. More...
Go to the source code of this file.
Functions | |
static void | dns_recv (void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr, u16_t port) |
Receive input function for DNS response packets arriving for the dns UDP pcb. | |
static void | dns_check_entries (void) |
Call dns_check_entry for each entry in dns_table - check all entries. | |
void | dns_init () |
Initialize the resolver: set up the UDP pcb and configure the default server (DNS_SERVER_ADDRESS). | |
void | dns_setserver (u8_t numdns, struct ip_addr *dnsserver) |
Initialize one of the DNS servers. | |
struct ip_addr | dns_getserver (u8_t numdns) |
Obtain one of the currently configured DNS server. | |
void | dns_tmr (void) |
The DNS resolver client timer - handle retries and timeouts and should be called every DNS_TMR_INTERVAL milliseconds (every second by default). | |
static u32_t | dns_lookup_local (const char *hostname) |
Scans the local host-list for a hostname. | |
int | dns_local_removehost (const char *hostname, const struct ip_addr *addr) |
Remove all entries from the local host-list for a specific hostname and/or IP addess. | |
err_t | dns_local_addhost (const char *hostname, const struct ip_addr *addr) |
Add a hostname/IP address pair to the local host-list. | |
static u32_t | dns_lookup (const char *name) |
Look up a hostname in the array of known hostnames. | |
static u8_t | dns_compare_name (unsigned char *query, unsigned char *response) |
Compare the "dotted" name "query" with the encoded name "response" to make sure an answer from the DNS server matches the current dns_table entry (otherwise, answers might arrive late for hostname not on the list any more). | |
static unsigned char * | dns_parse_name (unsigned char *query) |
Walk through a compact encoded DNS name and return the end of the name. | |
static err_t | dns_send (u8_t numdns, const char *name, u8_t id) |
Send a DNS query packet. | |
static void | dns_check_entry (u8_t i) |
dns_check_entry() - see if pEntry has not yet been queried and, if so, sends out a query. | |
static err_t | dns_enqueue (const char *name, dns_found_callback found, void *callback_arg) |
Queues a new hostname to resolve and sends out a DNS query for that hostname. | |
err_t | dns_gethostbyname (const char *hostname, struct ip_addr *addr, dns_found_callback found, void *callback_arg) |
Resolve a hostname (string) into an IP address. | |
Variables | |
static struct local_hostlist_entry * | local_hostlist_dynamic |
Local host-list. |
Detailed Description
DNS - host name to IP address resolver.
Definition in file trunk/Core/lwIP/core/dns.c.
Function Documentation
static void dns_check_entries | ( | void | ) | [static] |
Call dns_check_entry for each entry in dns_table - check all entries.
Definition at line 721 of file trunk/Core/lwIP/core/dns.c.
static void dns_check_entry | ( | u8_t | i ) | [static] |
dns_check_entry() - see if pEntry has not yet been queried and, if so, sends out a query.
Check an entry in the dns_table:
- send out query for new entries
- retry old pending entries on timeout (also with different servers)
- remove completed entries from the table if their TTL has expired
- Parameters:
-
i index of the dns_table entry to check
Definition at line 648 of file trunk/Core/lwIP/core/dns.c.
static u8_t dns_compare_name | ( | unsigned char * | query, |
unsigned char * | response | ||
) | [static] |
Compare the "dotted" name "query" with the encoded name "response" to make sure an answer from the DNS server matches the current dns_table entry (otherwise, answers might arrive late for hostname not on the list any more).
- Parameters:
-
query hostname (not encoded) from the dns_table response encoded hostname in the DNS response
- Returns:
- 0: names equal; 1: names differ
- See also:
- RFC 1035 - 4.1.4. Message compression
Definition at line 505 of file trunk/Core/lwIP/core/dns.c.
static err_t dns_enqueue | ( | const char * | name, |
dns_found_callback | found, | ||
void * | callback_arg | ||
) | [static] |
Queues a new hostname to resolve and sends out a DNS query for that hostname.
- Parameters:
-
name the hostname that is to be queried found a callback founction to be called on success, failure or timeout callback_arg argument to pass to the callback function
- Returns:
- a err_t return code.
Definition at line 883 of file trunk/Core/lwIP/core/dns.c.
err_t dns_gethostbyname | ( | const char * | hostname, |
struct ip_addr * | addr, | ||
dns_found_callback | found, | ||
void * | callback_arg | ||
) |
Resolve a hostname (string) into an IP address.
NON-BLOCKING callback version for use with raw API!!!
Returns immediately with one of err_t return codes:
- ERR_OK if hostname is a valid IP address string or the host name is already in the local names table.
- ERR_INPROGRESS enqueue a request to be sent to the DNS server for resolution if no errors are present.
- Parameters:
-
hostname the hostname that is to be queried addr pointer to a struct ip_addr where to store the address if it is already cached in the dns_table (only valid if ERR_OK is returned!) found a callback function to be called on success, failure or timeout (only if ERR_INPROGRESS is returned!) callback_arg argument to pass to the callback function
- Returns:
- a err_t return code.
Definition at line 955 of file trunk/Core/lwIP/core/dns.c.
struct ip_addr dns_getserver | ( | u8_t | numdns ) | [read] |
Obtain one of the currently configured DNS server.
- Parameters:
-
numdns the index of the DNS server
- Returns:
- IP address of the indexed DNS server or "ip_addr_any" if the DNS server has not been configured.
Definition at line 313 of file trunk/Core/lwIP/core/dns.c.
void dns_init | ( | void | ) |
Initialize the resolver: set up the UDP pcb and configure the default server (DNS_SERVER_ADDRESS).
Definition at line 258 of file trunk/Core/lwIP/core/dns.c.
err_t dns_local_addhost | ( | const char * | hostname, |
const struct ip_addr * | addr | ||
) |
Add a hostname/IP address pair to the local host-list.
Duplicates are not checked.
- Parameters:
-
hostname hostname of the new entry addr IP address of the new entry
- Returns:
- ERR_OK if succeeded or ERR_MEM on memory error
Definition at line 432 of file trunk/Core/lwIP/core/dns.c.
int dns_local_removehost | ( | const char * | hostname, |
const struct ip_addr * | addr | ||
) |
Remove all entries from the local host-list for a specific hostname and/or IP addess.
- Parameters:
-
hostname hostname for which entries shall be removed from the local host-list addr address for which entries shall be removed from the local host-list
- Returns:
- the number of removed entries
Definition at line 397 of file trunk/Core/lwIP/core/dns.c.
static u32_t dns_lookup | ( | const char * | name ) | [static] |
Look up a hostname in the array of known hostnames.
- Note:
- This function only looks in the internal array of known hostnames, it does not send out a query for the hostname if none was found. The function dns_enqueue() can be used to send a query for a hostname.
- Parameters:
-
name the hostname to look up
- Returns:
- the hostname's IP address, as u32_t (instead of struct ip_addr to better check for failure: != INADDR_NONE) or INADDR_NONE if the hostname was not found in the cached dns_table.
Definition at line 462 of file trunk/Core/lwIP/core/dns.c.
static u32_t dns_lookup_local | ( | const char * | hostname ) | [static] |
Scans the local host-list for a hostname.
- Parameters:
-
hostname Hostname to look for in the local host-list
- Returns:
- The first IP address for the hostname in the local host-list or INADDR_NONE if not found.
Definition at line 366 of file trunk/Core/lwIP/core/dns.c.
static unsigned char* dns_parse_name | ( | unsigned char * | query ) | [static] |
Walk through a compact encoded DNS name and return the end of the name.
- Parameters:
-
query encoded DNS name in the DNS server response
- Returns:
- end of the name
- See also:
- RFC 1035 - 4.1.4. Message compression
Definition at line 540 of file trunk/Core/lwIP/core/dns.c.
static void dns_recv | ( | void * | arg, |
struct udp_pcb * | pcb, | ||
struct pbuf * | p, | ||
struct ip_addr * | addr, | ||
u16_t | port | ||
) | [static] |
Receive input function for DNS response packets arriving for the dns UDP pcb.
see udp.h
Definition at line 736 of file trunk/Core/lwIP/core/dns.c.
static err_t dns_send | ( | u8_t | numdns, |
const char * | name, | ||
u8_t | id | ||
) | [static] |
Send a DNS query packet.
- Parameters:
-
numdns index of the DNS server in the dns_servers table name hostname to query id index of the hostname in dns_table, used as transaction ID in the DNS query packet
- Returns:
- ERR_OK if packet is sent; an err_t indicating the problem otherwise
Definition at line 572 of file trunk/Core/lwIP/core/dns.c.
void dns_setserver | ( | u8_t | numdns, |
struct ip_addr * | dnsserver | ||
) |
Initialize one of the DNS servers.
- Parameters:
-
numdns the index of the DNS server to set must be < DNS_MAX_SERVERS dnsserver IP address of the DNS server to set
Definition at line 297 of file trunk/Core/lwIP/core/dns.c.
void dns_tmr | ( | void | ) |
The DNS resolver client timer - handle retries and timeouts and should be called every DNS_TMR_INTERVAL milliseconds (every second by default).
Definition at line 327 of file trunk/Core/lwIP/core/dns.c.
Variable Documentation
struct local_hostlist_entry* local_hostlist_dynamic [static] |
Local host-list.
For hostnames in this list, no external name resolution is performed
Definition at line 213 of file trunk/Core/lwIP/core/dns.c.
Generated on Tue Jul 12 2022 16:06:28 by 1.7.2