Programming Guide

The following sections provide sample code describing how to use µC/DNSc.

API reference

Include Files

Wherever you want to use µC/DNSc, you should include the following header:

Include file
Description
Source/dns-c.hContains DNSc API definitions

Module initialization

Function name
Description
DNSc_Init()Initialize µC/DNSc module's objects and tasks. This function must be called prior to any other API

Resolve an host name

Function name
Description
DNSc_GetHost()Resolve or retrieve a host name from the cache

Cache management

Function name
Description
DNSc_CacheClrAll()Clear (flush) all entries in the DNS cache.
DNSc_CacheClrHost()Remove a specific host name from the DNS cache.

Default Server

Function name
Description
DNSc_CfgServerByStr()Configure default server using a string.
DNSc_CfgServerByAddr()Configure default server using an DNS address object.
DNSc_GetServerByStr()Get the default server configured in string format.
DNSc_GetServerByAddr()Get the default server configured in DNS object format.

Shell reference

Prerequisite

µC/TCP-IP command module.

Include Files

Wherever you want to use initialize the command in µC/Shell, you should include the following header:

Include file
Description
Cmd/dns-c_cmd.hContains DNSc Command definitions

API

Function name
Description
DNScCmd_Init()Function to load DNS client command into shell.

Command reference

Command
Description
ArgumentUsage example
dns_get_hostResolve a host name. Will printout all address retrieved for an host.Host name.dns_get_host micrium.com
dns_server_setConfigure the default server.server ip address.dns_server_set 8.8.8.8
dns_cache_clrClear all host of the DNS cachenone.dns_cache_clr
dns_helpPrint helpnonedns_help