![]() |
Morse Micro IoT SDK
2.9.7
|
Simple DNS client demonstration.
This file demonstrates how to use DNS to resolve a hostname using the Morse Micro WLAN API.
The application sets the primary and secondary DNS servers from the config store keys ip.dns_server0 and ip.dns_server1, falling back to dns.server0 and dns.server1 if these are not found for legacy support (note that this is done as part of the loading of configuration during app_wlan_init()/app_wlan_start()). It then tries to resolve the IP for the hostname specified in config store key dns.lookup – if the key is not specified then it tries to lookup www.google.com. The application has been written in a generic way to display all IP addresses for a given hostname, but currently LwIP returns only 1 IP for each lookup - but this may change in the future.
See Application helper routines for Wireless LAN interface for details of WLAN and IP stack configuration. Additional configuration options for this application can be found in the config.hjson file.
Definition in file dns_client.c.
#include <string.h>#include "mmosal.h"#include "mmwlan.h"#include "mmconfig.h"#include "mmipal.h"#include "netdb.h"#include "sys/socket.h"#include "mm_app_common.h"
Go to the source code of this file.
Macros | |
| #define | DEFAULT_LOOKUP "www.morsemicro.com" |
| This is the default hostname to lookup if none are specified in config store. More... | |
| #define | DNS_MAX_NAME_LENGTH (256) |
| Maximum supported length of hostname for DNS lookup. More... | |
Functions | |
| static void | dns_lookup (const char *hostname, int ai_family) |
| Perform a DNS lookup for the given hostname and print the results. More... | |
| void | app_init (void) |
| Main entry point to the application. More... | |
| #define DEFAULT_LOOKUP "www.morsemicro.com" |
This is the default hostname to lookup if none are specified in config store.
Definition at line 42 of file dns_client.c.
| #define DNS_MAX_NAME_LENGTH (256) |
Maximum supported length of hostname for DNS lookup.
Definition at line 46 of file dns_client.c.
| void app_init | ( | void | ) |
Main entry point to the application.
This will be invoked in a thread once operating system and hardware initialization has completed. It may return, but it does not have to.
Definition at line 151 of file dns_client.c.
|
static |
Perform a DNS lookup for the given hostname and print the results.
| hostname | Hostname to look up. |
| ai_family | Address family (AF_INET or AF_INET6) to request. |
Definition at line 56 of file dns_client.c.