WE310F5  39.00.000
M2MB DNS SERVER

This section describes the M2MB APIs to perform various Domain Name System (DNS) server operations. More...

#define M2MB_DNS_MAX_HOSTNAME_LEN   128
 
typedef struct M2MB_DNS_SERVER_HOST M2MB_DNS_SERVER_HOST_T
 Structure of HOST in the DNS server. More...
 
M2MB_STATUS_T m2mb_dns_server_init (VOID)
 DNS server initialization. More...
 
M2MB_STATUS_T m2mb_dns_server_deinit (VOID)
 DNS server de-initialization. More...
 
M2MB_STATUS_T m2mb_dns_server_add_host (const char *hostName, UINT32 ip4addr, M2MB_SOCKET_BSD_IPV6_ADDR_T *ip6addr, UINT32 ttl)
 Add a DNS host information. More...
 
M2MB_STATUS_T m2mb_dns_server_delete_host (const char *hostName)
 Delete the host information. More...
 
M2MB_STATUS_T m2mb_dns_server_is_started (VOID)
 Check the running status of DNS server. More...
 

Detailed Description

This section describes the M2MB APIs to perform various Domain Name System (DNS) server operations.

DNS-Server module provides the APIs for initialization, de-initialization of the server and the operations on the server like adding/deleting HOSTs.

Macro Definition Documentation

◆ M2MB_DNS_MAX_HOSTNAME_LEN

#define M2MB_DNS_MAX_HOSTNAME_LEN   128

Maximum length of the host name, including domain (e.g., www.telit.com).

Definition at line 57 of file m2mb_dns_server.h.

Typedef Documentation

◆ M2MB_DNS_SERVER_HOST_T

Structure of HOST in the DNS server.

Structure for storing a HOST in the DNS server. This would be used to add the HOST or while listing the HOST list.

Function Documentation

◆ m2mb_dns_server_add_host()

M2MB_STATUS_T m2mb_dns_server_add_host ( const char *  hostName,
UINT32  ip4addr,
M2MB_SOCKET_BSD_IPV6_ADDR_T ip6addr,
UINT32  ttl 
)

Add a DNS host information.

This API adds the host information to DNS server running.

Parameters
[in]hostNamePointer to the name of the host.
[in]ip4addrIPv4 address of the host.
[in]ip6addrIPv6 address of the host.
[in]ttltime to live in seconds. ttl = 0 indicates 0x7FFFFFFF seconds (INFINITE_DELAY).
Returns
Returns M2MB_OK on success, M2MB_ERROR on failure.
Note
This API has to be called after m2mb_dns_server_init API is called.

m2mb_dns_server_add_host( "www.testhost.com", dns_host_ip, NULL, 0 );

int main()
{
UINT32 dns_host_ip = 0;
...
if( status == M2MB_OK )
{
return M2MB_OK;
}
else
{
return M2MB_ERROR;
}
...
m2mb_socket_bsd_inet_pton( M2MB_SOCKET_BSD_AF_INET, "192.168.1.2", &dns_host_ip );
status = m2mb_dns_server_add_host( "www.testhost.com", dns_host_ip, NULL, 0 );
if( status == M2MB_OK )
{
return M2MB_OK;
}
else
{
return M2MB_ERROR;
}
}

◆ m2mb_dns_server_deinit()

M2MB_STATUS_T m2mb_dns_server_deinit ( VOID  )

DNS server de-initialization.

This API de-initializes the DNS server module.

Returns
Returns M2MB_OK on success, M2MB_ERROR on failure
Note
This API has to be called if the DNS server is already initialized.

m2mb_dns_server_deinit();

int main()
{
...
if( status != M2MB_OK )
{
return M2MB_ERROR;
}
...
if( status == M2MB_OK )
{
return M2MB_OK;
}
else
{
return M2MB_ERROR;
}
}

◆ m2mb_dns_server_delete_host()

M2MB_STATUS_T m2mb_dns_server_delete_host ( const char *  hostName)

Delete the host information.

This API deletes the details of the host that has been added to DNS server running.

Parameters
[in]hostNameName of the host added.
Returns
Returns M2MB_OK on success, M2MB_ERROR on failure.
Note
This API has to be called after m2mb_dns_server_init API is called.

m2mb_dns_server_delete_host( "www.testhost.com" );

int main()
{
UINT32 dns_host_ip = 0;
...
if( status == M2MB_OK )
{
return M2MB_OK;
}
else
{
return M2MB_ERROR;
}
...
m2mb_socket_bsd_inet_pton( M2MB_SOCKET_BSD_AF_INET, "192.168.1.2", &dns_host_ip );
status = m2mb_dns_server_add_host( "www.testhost.com", dns_host_ip, NULL, 0 );
if( status == M2MB_OK )
{
return M2MB_OK;
}
else
{
return M2MB_ERROR;
}
...
status = m2mb_dns_server_delete_host( "www.testhost.com" );
if( status == M2MB_OK )
{
return M2MB_OK;
}
else
{
return M2MB_ERROR;
}
}

◆ m2mb_dns_server_init()

M2MB_STATUS_T m2mb_dns_server_init ( VOID  )

DNS server initialization.

This API initializes the DNS server module.

Returns
Returns M2MB_OK on success, M2MB_ERROR on failure
Note
This API has to be called before any other DNS server API is called.

m2mb_dns_server_init();

int main()
{
...
if( status == M2MB_OK )
{
return M2MB_OK;
}
else
{
return M2MB_ERROR;
}
}

◆ m2mb_dns_server_is_started()

M2MB_STATUS_T m2mb_dns_server_is_started ( VOID  )

Check the running status of DNS server.

This API gives the running status of DNS server.

Returns
Returns M2MB_OK on success, M2MB_ERROR on failure.
Note

m2mb_dns_server_is_started();

int main()
{
...
if( status == M2MB_OK )
{
return M2MB_OK;
}
else
{
return M2MB_ERROR;
}
}