dns: Use dns_backupserver_available() instead of open-coded

Slightly better readability by calling dns_backupserver_available()
instead of open-coded. Also move dns_backupserver_available() function
up to avoid forward declaration.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: goldsimon <goldsimon@gmx.de>
This commit is contained in:
Axel Lin 2017-11-14 15:59:18 +08:00 committed by goldsimon
parent d20a7aba0c
commit 40a563cdd3

View File

@ -1006,6 +1006,23 @@ again:
return txid;
}
/**
* Check whether there are other backup DNS servers available to try
*/
static u8_t
dns_backupserver_available(struct dns_table_entry *pentry)
{
u8_t ret = 0;
if (pentry) {
if ((pentry->server_idx + 1 < DNS_MAX_SERVERS) && !ip_addr_isany_val(dns_servers[pentry->server_idx + 1])) {
ret = 1;
}
}
return ret;
}
/**
* dns_check_entry() - see if entry has not yet been queried and, if so, sends out a query.
* Check an entry in the dns_table:
@ -1042,7 +1059,7 @@ dns_check_entry(u8_t i)
case DNS_STATE_ASKING:
if (--entry->tmr == 0) {
if (++entry->retries == DNS_MAX_RETRIES) {
if ((entry->server_idx + 1 < DNS_MAX_SERVERS) && !ip_addr_isany_val(dns_servers[entry->server_idx + 1])
if (dns_backupserver_available(entry)
#if LWIP_DNS_SUPPORT_MDNS_QUERIES
&& !entry->is_mdns
#endif /* LWIP_DNS_SUPPORT_MDNS_QUERIES */
@ -1135,23 +1152,6 @@ dns_correct_response(u8_t idx, u32_t ttl)
}
}
/**
* Check whether there are other backup DNS servers available to try
*/
static u8_t
dns_backupserver_available(struct dns_table_entry *pentry)
{
u8_t ret = 0;
if (pentry) {
if ((pentry->server_idx + 1 < DNS_MAX_SERVERS) && !ip_addr_isany_val(dns_servers[pentry->server_idx + 1])) {
ret = 1;
}
}
return ret;
}
/**
* Receive input function for DNS response packets arriving for the dns UDP pcb.
*/