NetBurner 3.5.0
PDF Version
 
DNS - Domain Name System

Topics

 DNS Record Types
 
 DNS Return Codes
 

Functions

bool IsNameIPAddress (const char *name)
 Determine if the name is a valid IP Address and does not need to be looked up.
 
int fd_dns_part1 (const char *name, const IPADDR &dns_server, uint16_t TYPE=DNS_A, uint16_t TYPE2=0, int ifn=-1)
 Open a UDP socket and initiate a DNS lookup.
 
bool fd_dns_processresult (int fd, const char *name, IPADDR &addr_out, uint16_t TYPE=DNS_A, uint16_t TYPE2=DNS_AAAA, uint32_t *ttl=0)
 Process any responses on the UDP socket opened for DNS.
 
int fd_outstanding_Responses (int fd)
 Check to see if there are any outstanding DNS requests.
 
bool AnyDNSInterFaceActive ()
 Determine if we have an active DNS route; DNS server is set for an active interface.
 
int GetHostByName (const char *name, IPADDR *pIpaddr, const IPADDR &dns_server, const TickTimeout tout, uint16_t TYPE1=DNS_A, uint16_t TYPE2=extra_dns_t, uint32_t *ttl=NULL)
 Get the IP address associated with the specified domain name.
 
int GetHostByNameViaIfNum (const char *name, IPADDR *pIpaddr, const IPADDR &dns_server, int ifn, const TickTimeout &tout, uint16_t TYPE1=DNS_A, uint16_t TYPE2=extra_dns_t, uint32_t *ttl=NULL)
 Get the IP address associated with the specified domain name on a specific interface.
 

Detailed Description

#include< dns.h >

The current DNS system is agnostic about the use of IPADDR, IPADDR6 or IPADDR4. The capability of C++ is such that you pass in any of those types and the compiler will select the correct function for that type. This is a change from tools versions 3.4.0 and earlier in which explicit IPv4 and IPv6 functions were used.

Note
While we are pointing out the automatic functionality in this DNS API, the same is true for most functions, structures and classes throughout the NetBurner API libraries.

The DNS system can be accessed as a blocking or synchronous operation with: GetHostByName(). If you want to do asynchronous non-blocking lookups, please refer to the functions:

Function Documentation

◆ AnyDNSInterFaceActive()

bool AnyDNSInterFaceActive ( )

#include <dns.h>

Determine if we have an active DNS route; DNS server is set for an active interface.

Returns
true if active DNS is available somewhere
See also
GetHostByName()
InterfaceLinkActive(int interface);

◆ fd_dns_part1()

int fd_dns_part1 ( const char * name,
const IPADDR & dns_server,
uint16_t TYPE = DNS_A,
uint16_t TYPE2 = 0,
int ifn = -1 )

#include <dns.h>

Open a UDP socket and initiate a DNS lookup.

This socket can be put in a select and used for asynchronous DNS lookups. Opens a UDP receive FD and sends DNS queries.

Parameters
namePointer to domain name to resolve
dns_serverReference to the DNS server to use. Pass INADDR_ANY to use the DNS server associated with the interface.
TYPEOptional DNS record type. If no type is specified the default is IPv4 DNS_A
TYPE2Optional 2nd DNS record type. If no type is specified the default is no look up
ifnWhich interface to use -1 uses the default active DNS interface
Returns
fd The file descriptor of the udp socket. DNS Return Codes
See also
fd_dns_processresult(), fd_outstanding_Responses(), GetHostByName(),

◆ fd_dns_processresult()

bool fd_dns_processresult ( int fd,
const char * name,
IPADDR & addr_out,
uint16_t TYPE = DNS_A,
uint16_t TYPE2 = DNS_AAAA,
uint32_t * ttl = 0 )

#include <dns.h>

Process any responses on the UDP socket opened for DNS.

This should only be called when the socket has data, otherwise it will block.

Parameters
fdThe file descriptor opened with fd_dns_part1
namePointer to domain name to resolve
addr_outReference to IPADDR variable to hold the result
TYPEDNS record type. If no type is specified the default is IPv4 DNS_A
TYPE22nd DNS record type. If no type is specified the default is no look up
ttlOptional pointer to return variable for TimeToLive value for DNS record
Returns
true if resolution was successful
See also
fd_dns_part1(), fd_outstanding_Responses(), GetHostByName(),

◆ fd_outstanding_Responses()

int fd_outstanding_Responses ( int fd)

#include <dns.h>

Check to see if there are any outstanding DNS requests.

If this returns 0 then all DNS responses have been processed and one can assume ther eis no such name.

Parameters
fdThe file descriptor opened with fd_dns_part1
Returns
The number of outstanding DNS requests that have not been answered.
See also
fd_dns_part1(), fd_dns_processresult(), GetHostByName(),

◆ GetHostByName()

int GetHostByName ( const char * name,
IPADDR * pIpaddr,
const IPADDR & dns_server,
const TickTimeout tout,
uint16_t TYPE1 = DNS_A,
uint16_t TYPE2 = extra_dns_t,
uint32_t * ttl = NULL )
inline

#include <dns.h>

Get the IP address associated with the specified domain name.

Calling GetHostByName() in dual stack mode will automatically call the correct IPv4 or IPv6 function.

The function will attempt to retrieve record type 1 first. If successful the function returns. If if the attempt using type 1 fails, the function will attempt to get a record using the type 2 parameter. For example, lets say you wish your code to use IPv6, but its OK to fall back to IPv4. You can set type 1 to DNS_AAAA and type2 to DNS_A.

Parameters
*namePointer to domain name to resolve
*pIpaddrPointer to variable of type IPADDR (or IPADDR4) to store resultant IP address.
&dns_serverSpecified the DNS server to use. Pass INADDR_ANY to use the DNS server associated with the interface.
toutNumber of time ticks to wait of type TickTimeout
TYPE1Optional record type. If not specified will default to IPv4 DNS_A
TYPE2Optional record type. If not specified will default to IPv6 DNS_AAAA
ttlOptional pointer to return variable for TimeToLive value for DNS record
Returns
DNS Return Codes
See also
GetHostByName4()
GetHostByName6()

◆ GetHostByNameViaIfNum()

int GetHostByNameViaIfNum ( const char * name,
IPADDR * pIpaddr,
const IPADDR & dns_server,
int ifn,
const TickTimeout & tout,
uint16_t TYPE1 = DNS_A,
uint16_t TYPE2 = extra_dns_t,
uint32_t * ttl = NULL )
inline

#include <dns.h>

Get the IP address associated with the specified domain name on a specific interface.

Calling GetHostByName() in dual stack mode will automatically call the correct IPv4 or IPv6 function.

The function will attempt to retrieve record type 1 first. If successful the function returns. If if the attempt using type 1 fails, the function will attempt to get a record using the type 2 parameter. For example, lets say you wish your code to use IPv6, but its OK to fall back to IPv4. You can set type 1 to DNS_AAAA and type2 to DNS_A.

Parameters
*namePointer to domain name to resolve
*pIpaddrPointer to variable of type IPADDR to store resultant IP address
&dns_serverSpecified the DNS server to use. Pass INADDR_ANY to use the DNS server associated with the interface.
toutA reference to the number of time ticks to wait of type TickTimeout
TYPE1Optional record type. If not specified will default to IPv4 DNS_A
TYPE2Optional record type. If not specified will default to IPv6 DNS_AAAA
ifnInterface number
ttlOptional pointer to return variable for TimeToLive value for DNS record
Returns
DNS Return Codes
See also
GetHostByName4ViaIfNum()
GetHostByNameViaIfNum()

◆ IsNameIPAddress()

bool IsNameIPAddress ( const char * name)

#include <dns.h>

Determine if the name is a valid IP Address and does not need to be looked up.

Parameters
*namePointer to domain name to check
Returns
true If it is a valid IP address
See also
GetHostByName(), GetHostByName4ViaIfNum(), GetHostByName6()