Port of LwIP performed by Ralf in 2010. Not recommended for use with recent mbed libraries, but good demos of raw LwIP possible
Dependents: LwIP_raw_API_serverExample tiny-dtls
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 dns.c.
Function Documentation
static void dns_check_entries | ( | void | ) | [static] |
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
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
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.
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.
struct ip_addr dns_getserver | ( | u8_t | numdns ) | [read] |
void dns_init | ( | void | ) |
err_t dns_local_addhost | ( | const char * | hostname, |
const struct ip_addr * | addr | ||
) |
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
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.
static u32_t dns_lookup_local | ( | const char * | hostname ) | [static] |
static unsigned char* dns_parse_name | ( | unsigned char * | query ) | [static] |
static void dns_recv | ( | void * | arg, |
struct udp_pcb * | pcb, | ||
struct pbuf * | p, | ||
struct ip_addr * | addr, | ||
u16_t | port | ||
) | [static] |
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
void dns_setserver | ( | u8_t | numdns, |
struct ip_addr * | dnsserver | ||
) |
void dns_tmr | ( | void | ) |
Variable Documentation
struct local_hostlist_entry* local_hostlist_dynamic [static] |
Generated on Tue Jul 12 2022 18:50:03 by 1.7.2