mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-01-04 11:38:11 +00:00
DNS: minor coding style fix: pEntry -> entry
This commit is contained in:
parent
13add693db
commit
6c7357bbf9
106
src/core/dns.c
106
src/core/dns.c
@ -763,7 +763,7 @@ again:
|
||||
}
|
||||
|
||||
/**
|
||||
* dns_check_entry() - see if pEntry has not yet been queried and, if so, sends out a query.
|
||||
* 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:
|
||||
* - send out query for new entries
|
||||
* - retry old pending entries on timeout (also with different servers)
|
||||
@ -775,24 +775,24 @@ static void
|
||||
dns_check_entry(u8_t i)
|
||||
{
|
||||
err_t err;
|
||||
struct dns_table_entry *pEntry = &dns_table[i];
|
||||
struct dns_table_entry *entry = &dns_table[i];
|
||||
|
||||
LWIP_ASSERT("array index out of bounds", i < DNS_TABLE_SIZE);
|
||||
|
||||
switch (pEntry->state) {
|
||||
switch (entry->state) {
|
||||
|
||||
case DNS_STATE_NEW: {
|
||||
u16_t txid;
|
||||
/* initialize new entry */
|
||||
txid = dns_create_txid();
|
||||
pEntry->txid = txid;
|
||||
pEntry->state = DNS_STATE_ASKING;
|
||||
pEntry->numdns = 0;
|
||||
pEntry->tmr = 1;
|
||||
pEntry->retries = 0;
|
||||
entry->txid = txid;
|
||||
entry->state = DNS_STATE_ASKING;
|
||||
entry->numdns = 0;
|
||||
entry->tmr = 1;
|
||||
entry->retries = 0;
|
||||
|
||||
/* send DNS packet for this entry */
|
||||
err = dns_send(pEntry->numdns, pEntry->name, txid);
|
||||
err = dns_send(entry->numdns, entry->name, txid);
|
||||
if (err != ERR_OK) {
|
||||
LWIP_DEBUGF(DNS_DEBUG | LWIP_DBG_LEVEL_WARNING,
|
||||
("dns_send returned error: %s\n", lwip_strerr(err)));
|
||||
@ -801,29 +801,29 @@ dns_check_entry(u8_t i)
|
||||
}
|
||||
|
||||
case DNS_STATE_ASKING:
|
||||
if (--pEntry->tmr == 0) {
|
||||
if (++pEntry->retries == DNS_MAX_RETRIES) {
|
||||
if ((pEntry->numdns+1<DNS_MAX_SERVERS) && !ip_addr_isany(&dns_servers[pEntry->numdns+1])) {
|
||||
if (--entry->tmr == 0) {
|
||||
if (++entry->retries == DNS_MAX_RETRIES) {
|
||||
if ((entry->numdns+1<DNS_MAX_SERVERS) && !ip_addr_isany(&dns_servers[entry->numdns+1])) {
|
||||
/* change of server */
|
||||
pEntry->numdns++;
|
||||
pEntry->tmr = 1;
|
||||
pEntry->retries = 0;
|
||||
entry->numdns++;
|
||||
entry->tmr = 1;
|
||||
entry->retries = 0;
|
||||
break;
|
||||
} else {
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("dns_check_entry: \"%s\": timeout\n", pEntry->name));
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("dns_check_entry: \"%s\": timeout\n", entry->name));
|
||||
/* call specified callback function if provided */
|
||||
dns_call_found(i, NULL);
|
||||
/* flush this entry */
|
||||
pEntry->state = DNS_STATE_UNUSED;
|
||||
entry->state = DNS_STATE_UNUSED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* wait longer for the next retry */
|
||||
pEntry->tmr = pEntry->retries;
|
||||
entry->tmr = entry->retries;
|
||||
|
||||
/* send DNS packet for this entry */
|
||||
err = dns_send(pEntry->numdns, pEntry->name, pEntry->txid);
|
||||
err = dns_send(entry->numdns, entry->name, entry->txid);
|
||||
if (err != ERR_OK) {
|
||||
LWIP_DEBUGF(DNS_DEBUG | LWIP_DBG_LEVEL_WARNING,
|
||||
("dns_send returned error: %s\n", lwip_strerr(err)));
|
||||
@ -832,10 +832,10 @@ dns_check_entry(u8_t i)
|
||||
break;
|
||||
case DNS_STATE_DONE:
|
||||
/* if the time to live is nul */
|
||||
if ((pEntry->ttl == 0) || (--pEntry->ttl == 0)) {
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("dns_check_entry: \"%s\": flush\n", pEntry->name));
|
||||
if ((entry->ttl == 0) || (--entry->ttl == 0)) {
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("dns_check_entry: \"%s\": flush\n", entry->name));
|
||||
/* flush this entry, there cannot be any related pending entries in this state */
|
||||
pEntry->state = DNS_STATE_UNUSED;
|
||||
entry->state = DNS_STATE_UNUSED;
|
||||
}
|
||||
break;
|
||||
case DNS_STATE_UNUSED:
|
||||
@ -900,13 +900,13 @@ dns_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, ip_addr_t *addr, u16_t
|
||||
hdr = (struct dns_hdr*)dns_payload;
|
||||
txid = htons(hdr->id);
|
||||
for (i = 0; i < DNS_TABLE_SIZE; i++) {
|
||||
struct dns_table_entry *pEntry = &dns_table[i];
|
||||
struct dns_table_entry *entry = &dns_table[i];
|
||||
entry_idx = i;
|
||||
if ((pEntry->state == DNS_STATE_ASKING) &&
|
||||
(pEntry->txid == txid)) {
|
||||
if ((entry->state == DNS_STATE_ASKING) &&
|
||||
(entry->txid == txid)) {
|
||||
/* This entry is now completed. */
|
||||
pEntry->state = DNS_STATE_DONE;
|
||||
pEntry->err = hdr->flags2 & DNS_FLAG2_ERR_MASK;
|
||||
entry->state = DNS_STATE_DONE;
|
||||
entry->err = hdr->flags2 & DNS_FLAG2_ERR_MASK;
|
||||
|
||||
/* We only care about the question(s) and the answers. The authrr
|
||||
and the extrarr are simply discarded. */
|
||||
@ -914,24 +914,24 @@ dns_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, ip_addr_t *addr, u16_t
|
||||
nanswers = htons(hdr->numanswers);
|
||||
|
||||
/* Check for error. If so, call callback to inform. */
|
||||
if (((hdr->flags1 & DNS_FLAG1_RESPONSE) == 0) || (pEntry->err != 0) || (nquestions != 1)) {
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("dns_recv: \"%s\": error in flags\n", pEntry->name));
|
||||
if (((hdr->flags1 & DNS_FLAG1_RESPONSE) == 0) || (entry->err != 0) || (nquestions != 1)) {
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("dns_recv: \"%s\": error in flags\n", entry->name));
|
||||
/* call callback to indicate error, clean up memory and return */
|
||||
goto responseerr;
|
||||
}
|
||||
|
||||
/* Check whether response comes from the same network address to which the
|
||||
question was sent. (RFC 5452) */
|
||||
if (!ip_addr_cmp(addr, &dns_servers[pEntry->numdns])) {
|
||||
if (!ip_addr_cmp(addr, &dns_servers[entry->numdns])) {
|
||||
/* call callback to indicate error, clean up memory and return */
|
||||
goto responseerr;
|
||||
}
|
||||
|
||||
/* Check if the name in the "question" part match with the name in the entry and
|
||||
skip it if equal. */
|
||||
ptr = dns_compare_name(pEntry->name, (char*)dns_payload + SIZEOF_DNS_HDR);
|
||||
ptr = dns_compare_name(entry->name, (char*)dns_payload + SIZEOF_DNS_HDR);
|
||||
if (ptr == NULL) {
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("dns_recv: \"%s\": response not match to query\n", pEntry->name));
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("dns_recv: \"%s\": response not match to query\n", entry->name));
|
||||
/* call callback to indicate error, clean up memory and return */
|
||||
goto responseerr;
|
||||
}
|
||||
@ -939,7 +939,7 @@ dns_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, ip_addr_t *addr, u16_t
|
||||
/* check if "question" part matches the request */
|
||||
SMEMCPY(&qry, ptr, SIZEOF_DNS_QUERY);
|
||||
if((qry.type != PP_HTONS(DNS_RRTYPE_A)) || (qry.cls != PP_HTONS(DNS_RRCLASS_IN))) {
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("dns_recv: \"%s\": response not match to query\n", pEntry->name));
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("dns_recv: \"%s\": response not match to query\n", entry->name));
|
||||
/* call callback to indicate error, clean up memory and return */
|
||||
goto responseerr;
|
||||
}
|
||||
@ -955,18 +955,18 @@ dns_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, ip_addr_t *addr, u16_t
|
||||
if((ans.type == PP_HTONS(DNS_RRTYPE_A)) && (ans.cls == PP_HTONS(DNS_RRCLASS_IN)) &&
|
||||
(ans.len == PP_HTONS(sizeof(ip_addr_t))) ) {
|
||||
/* read the answer resource record's TTL, and maximize it if needed */
|
||||
pEntry->ttl = ntohl(ans.ttl);
|
||||
if (pEntry->ttl > DNS_MAX_TTL) {
|
||||
pEntry->ttl = DNS_MAX_TTL;
|
||||
entry->ttl = ntohl(ans.ttl);
|
||||
if (entry->ttl > DNS_MAX_TTL) {
|
||||
entry->ttl = DNS_MAX_TTL;
|
||||
}
|
||||
/* read the IP address after answer resource record's header */
|
||||
SMEMCPY(&(pEntry->ipaddr), (ptr + SIZEOF_DNS_ANSWER), sizeof(ip_addr_t));
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("dns_recv: \"%s\": response = ", pEntry->name));
|
||||
ip_addr_debug_print(DNS_DEBUG, (&(pEntry->ipaddr)));
|
||||
SMEMCPY(&(entry->ipaddr), (ptr + SIZEOF_DNS_ANSWER), sizeof(ip_addr_t));
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("dns_recv: \"%s\": response = ", entry->name));
|
||||
ip_addr_debug_print(DNS_DEBUG, (&(entry->ipaddr)));
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("\n"));
|
||||
/* call specified callback function if provided */
|
||||
dns_call_found(entry_idx, &pEntry->ipaddr);
|
||||
if (pEntry->ttl == 0) {
|
||||
dns_call_found(entry_idx, &entry->ipaddr);
|
||||
if (entry->ttl == 0) {
|
||||
/* RFC 883, page 29: "Zero values are
|
||||
interpreted to mean that the RR can only be used for the
|
||||
transaction in progress, and should not be cached."
|
||||
@ -980,7 +980,7 @@ dns_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, ip_addr_t *addr, u16_t
|
||||
}
|
||||
--nanswers;
|
||||
}
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("dns_recv: \"%s\": error in response\n", pEntry->name));
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("dns_recv: \"%s\": error in response\n", entry->name));
|
||||
/* call callback to indicate error, clean up memory and return */
|
||||
goto responseerr;
|
||||
}
|
||||
@ -1018,7 +1018,7 @@ dns_enqueue(const char *name, size_t hostnamelen, dns_found_callback found,
|
||||
{
|
||||
u8_t i;
|
||||
u8_t lseq, lseqi;
|
||||
struct dns_table_entry *pEntry = NULL;
|
||||
struct dns_table_entry *entry = NULL;
|
||||
size_t namelen;
|
||||
struct dns_req_entry* req;
|
||||
|
||||
@ -1047,15 +1047,15 @@ dns_enqueue(const char *name, size_t hostnamelen, dns_found_callback found,
|
||||
lseq = 0;
|
||||
lseqi = DNS_TABLE_SIZE;
|
||||
for (i = 0; i < DNS_TABLE_SIZE; ++i) {
|
||||
pEntry = &dns_table[i];
|
||||
entry = &dns_table[i];
|
||||
/* is it an unused entry ? */
|
||||
if (pEntry->state == DNS_STATE_UNUSED) {
|
||||
if (entry->state == DNS_STATE_UNUSED) {
|
||||
break;
|
||||
}
|
||||
/* check if this is the oldest completed entry */
|
||||
if (pEntry->state == DNS_STATE_DONE) {
|
||||
if ((dns_seqno - pEntry->seqno) > lseq) {
|
||||
lseq = dns_seqno - pEntry->seqno;
|
||||
if (entry->state == DNS_STATE_DONE) {
|
||||
if ((dns_seqno - entry->seqno) > lseq) {
|
||||
lseq = dns_seqno - entry->seqno;
|
||||
lseqi = i;
|
||||
}
|
||||
}
|
||||
@ -1070,7 +1070,7 @@ dns_enqueue(const char *name, size_t hostnamelen, dns_found_callback found,
|
||||
} else {
|
||||
/* use the oldest completed one */
|
||||
i = lseqi;
|
||||
pEntry = &dns_table[i];
|
||||
entry = &dns_table[i];
|
||||
}
|
||||
}
|
||||
|
||||
@ -1098,13 +1098,13 @@ dns_enqueue(const char *name, size_t hostnamelen, dns_found_callback found,
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("dns_enqueue: \"%s\": use DNS entry %"U16_F"\n", name, (u16_t)(i)));
|
||||
|
||||
/* fill the entry */
|
||||
pEntry->state = DNS_STATE_NEW;
|
||||
pEntry->seqno = dns_seqno;
|
||||
entry->state = DNS_STATE_NEW;
|
||||
entry->seqno = dns_seqno;
|
||||
req->found = found;
|
||||
req->arg = callback_arg;
|
||||
namelen = LWIP_MIN(hostnamelen, DNS_MAX_NAME_LENGTH-1);
|
||||
MEMCPY(pEntry->name, name, namelen);
|
||||
pEntry->name[namelen] = 0;
|
||||
MEMCPY(entry->name, name, namelen);
|
||||
entry->name[namelen] = 0;
|
||||
|
||||
dns_seqno++;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user