![]() |
WL865E4-P
36.07.001
|
This section describes the M2MB APIs to perform various Domain Name System (DNS) client operations. More...
This section describes the M2MB APIs to perform various Domain Name System (DNS) client operations.
typedef enum M2MB_DNS_SERVER_ID M2MB_DNS_SERVER_ID_E |
typedef struct M2MB_HOST_NAME_TO_IP M2MB_HOST_NAME_TO_IP_T |
Structure to get IP address from host name.
This data structure is used to get the IP address of a given host name.
This is the same as the UNIX struct hostent{}.
enum M2MB_DNS_SERVER_ID |
Enumerator | |
---|---|
M2MB_DNS_SERVER_PRIMARY | MACRO to set primary server details |
M2MB_DNS_SERVER_SECONDARY | MACRO to set secondary server details |
Definition at line 55 of file m2mb_dns_client.h.
M2MB_STATUS_T m2mb_dns_client_deinit | ( | VOID | ) |
De-initialize DNS client module.
This API de-initializes the DNS client module.
M2MB_HOST_NAME_TO_IP_T* m2mb_dns_client_get_host_by_name | ( | UINT8 * | name | ) |
Get IP address of host name.
This API initiates DNS resolution to get the IP address from the given host name.
Implements a standard Unix version of gethostbyname().
The returned structure should not be freed by the caller.
[in] | name | Either a hostname or an IPv4 address in standard dot notation. |
Example
M2MB_HOST_NAME_TO_IP_T* m2mb_dns_client_get_host_by_name2 | ( | UINT8 * | name, |
INT32 | af | ||
) |
Get the IP address from the host name of the server.
m2mb_dns_client_get_host_by_name2 initiates DNS resolution to get the IP address from the given host name.
Implements a standard Unix version of gethostbyname2().
The returned M2MB_HOST_NAME_TO_IP_T structure is not thread safe. It can be freed by internal DNS client routines if the entry ages out or if the table becomes full and space is needed for another entry.
[in] | name | Either a hostname or an IPv4 address in standard dot notation. |
[in] | af | Address family; either M2MB_SOCKET_BSD_AF_INET or M2MB_SOCKET_BSD_AF_INET6. |
M2MB_STATUS_T m2mb_dns_client_get_server_list | ( | M2MB_NWIF_DNS_SERVER_LIST_T * | srv_list | ) |
Get the DNS server list.
This API gets the DNS server list.
[out] | srv_list | Pointer to DNS server list. |
Example
M2MB_STATUS_T m2mb_dns_client_init | ( | VOID | ) |
Initialize DNS client.
This API initializes the DNS client module.
M2MB_STATUS_T m2mb_dns_client_is_started | ( | VOID | ) |
Check the status of DNS client.
This API checks whether the DNS client module is started or not.
M2MB_STATUS_T m2mb_dns_client_resolve_host | ( | UINT8 * | hostname, |
M2MB_IP46_ADDR_T * | ipaddr | ||
) |
Resolve the URL details.
This API resolves the URL details.
[in] | hostname | URL mentioned in a string format. |
[out] | ipaddr | Pointer to the URL's IP address structure (M2MB_IP46_ADDR_T *). |
Example
M2MB_STATUS_T m2mb_dns_client_svr_add | ( | UINT8 * | ipAddr, |
M2MB_DNS_SERVER_ID_E | serverID | ||
) |
Add a DNS server.
This API stores the DNS server address to resolve the host name. The server name has to be a valid IP address of DNS server.
[in] | ipAddr | Pointer to the IP address string of the server. |
[in] | serverID | User is supposed to pass M2MB_DNS_SERVER_PRIMARY or M2MB_DNS_SERVER_SECONDARY to indicate whether the primary or secondary server has to be added. |
m2mb_dns_client_svr_add( "192.168.1.1", M2MB_DNS_SERVER_PRIMARY );
M2MB_STATUS_T m2mb_dns_client_svr_delete | ( | M2MB_DNS_SERVER_ID_E | serverID | ) |
Delete the DNS server details.
This API deletes the DNS server details added to DNS client module.
[in] | serverID | User is supposed to pass M2MB_DNS_SERVER_PRIMARY or M2MB_DNS_SERVER_SECONDARY to indicate whether the primary or secondary server has to be deleted. |
m2mb_dns_client_svr_delete( M2MB_DNS_SERVER_PRIMARY );