mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-10-04 05:39:53 +00:00
fix DNS problem with pbuf chain.
This commit is contained in:
parent
8ff1194b6a
commit
8c0e6de00a
@ -523,7 +523,7 @@ static void dhcp_handle_ack(struct netif *netif)
|
||||
#endif /* LWIP_DNS */
|
||||
}
|
||||
#if LWIP_DNS
|
||||
dns_setserver( n, &ip_addr_any);
|
||||
dns_setserver( n, (struct ip_addr *)(&ip_addr_any));
|
||||
#endif /* LWIP_DNS */
|
||||
}
|
||||
}
|
||||
|
@ -65,7 +65,6 @@
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/** @todo: define good default values (rfc compliance) */
|
||||
/** @todo: pbuf chain not yet supported */
|
||||
/** @todo: improve answer parsing, more checkings... */
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
@ -216,9 +215,10 @@ static void dns_check_entries(void);
|
||||
|
||||
/* DNS variables */
|
||||
static struct udp_pcb *dns_pcb;
|
||||
static struct dns_table_entry dns_table[DNS_TABLE_SIZE];
|
||||
static u8_t dns_seqno;
|
||||
static struct dns_table_entry dns_table[DNS_TABLE_SIZE];
|
||||
static struct ip_addr dns_servers[DNS_MAX_SERVERS];
|
||||
static u8_t dns_payload[DNS_MSG_SIZE];
|
||||
|
||||
/**
|
||||
* Initialize the resolver and configure which DNS server to use for queries.
|
||||
@ -493,9 +493,9 @@ dns_recv(void *s, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr, u16
|
||||
struct dns_table_entry *pEntry;
|
||||
u8_t nquestions, nanswers;
|
||||
|
||||
/* is the dns message in a pbuf chain ? */
|
||||
if (p->next != NULL) {
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("dns_recv: pbuf chain not yet supported\n"));
|
||||
/* is the dns message too big ? */
|
||||
if (p->tot_len > DNS_MSG_SIZE) {
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("dns_recv: pbuf too big\n"));
|
||||
pbuf_free(p);
|
||||
return;
|
||||
}
|
||||
@ -509,8 +509,10 @@ dns_recv(void *s, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr, u16
|
||||
|
||||
/** @todo: check RFC1035 - 7.3. Processing responses */
|
||||
|
||||
/* copy dns payload inside static buffer for processing */
|
||||
if (pbuf_copy_partial(p, dns_payload, p->tot_len, 0) == p->tot_len) {
|
||||
/* The ID in the DNS header should be our entry into the name table. */
|
||||
hdr = (struct dns_hdr *)p->payload;
|
||||
hdr = (struct dns_hdr *)dns_payload;
|
||||
i = htons(hdr->id);
|
||||
if(i < DNS_TABLE_SIZE) {
|
||||
pEntry = &dns_table[i];
|
||||
@ -541,7 +543,7 @@ dns_recv(void *s, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr, u16
|
||||
|
||||
/* Skip the name in the "question" part. This should really be checked
|
||||
agains the name in the question, to be sure that they match. */
|
||||
pHostname = (char *) dns_parse_name((unsigned char *)p->payload + sizeof(struct dns_hdr)) + sizeof(struct dns_query);
|
||||
pHostname = (char *) dns_parse_name((unsigned char *)dns_payload + sizeof(struct dns_hdr)) + sizeof(struct dns_query);
|
||||
|
||||
while(nanswers > 0) {
|
||||
/* skip answer resource record's host name */
|
||||
@ -569,7 +571,7 @@ dns_recv(void *s, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr, u16
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("dns_recv: \"%s\": error in response\n", pEntry->name));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/* free pbuf */
|
||||
pbuf_free(p);
|
||||
}
|
||||
|
@ -194,10 +194,6 @@ lwip_sanity_check(void)
|
||||
if (TCP_WND < TCP_MSS)
|
||||
LWIP_PLATFORM_DIAG(("lwip_sanity_check: WARNING: TCP_WND is smaller than MSS\n"));
|
||||
#endif /* LWIP_TCP */
|
||||
#if LWIP_DNS
|
||||
if (PBUF_POOL_BUFSIZE<(PBUF_LINK_HLEN+PBUF_IP_HLEN+PBUF_TRANSPORT_HLEN+DNS_MSG_SIZE))
|
||||
LWIP_PLATFORM_DIAG(("lwip_sanity_check: WARNING: UDP messages for DNS could need until 512 bytes\n"));
|
||||
#endif /* LWIP_DNS */
|
||||
}
|
||||
#else /* LWIP_DEBUG */
|
||||
#define lwip_sanity_check()
|
||||
|
Loading…
Reference in New Issue
Block a user