Dallas Semiconductor DS80C400 C Libraries Home Page

Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals

tini400_dns.h File Reference


Detailed Description

DNS Client functions for the DS80C400 ROM.

This libarary contains functions for resolving a host name to an IP address that is usable by the silicon software for making socket function calls. Note that the functions in this library are not safe to be called from multiple processes at the same time. The functions in this library store their results in static memory locations, and must be retrieved and stored in alternate locations before further DNS operations are performed.

Note that as of version 3, this library has been changed to use the system-wide DNS server entries, which might be set by the DHCP client (from data recieved in a DHCP response). Applications can make sure they have a valid server entry by making sure the DNS server IP addresses are not all 0's, since the ROM initialization functions clear the DNS server entries.

For detailed information on the DS80C400 please see the High-Speed Microcontroller User's Guide: DS80C400 Supplement.

Warning:
The functions in this library are NOT multi-process safe--that is, if you call the same method from two different processes at the same time, the parameters to the function may be destroyed, yielding unpredictable results.

The functions in this library use String functions such as sprintf for data formatting, which are not multiprocess safe. Care must be taken that DNS functions do not operate at the same time as other string formatting operations.

#include <stdlib.h>

Go to the source code of this file.

Data Structures

struct  hostent
struct  mailhostent

Defines

#define TINI400_DNS_VERSION   7

Functions

hostentgethostbyaddr (void *addr, size_t len, int type)
 Looks up information on a host given an IP address.
hostentgethostbyname (char *name)
 Looks up information on a host given a host name.
void dns_init (void)
 Initializes the DNS client code.
void dns_settimeout (unsigned long t)
 Sets the socket timeout value used for DNS server communications.
void dns_setmaxtimeout (unsigned long t)
 Sets the maximum socket timeout value used for DNS server communications.
unsigned long dns_gettimeout (void)
 Gets the socket timeout value used for DNS server communications.
void dns_getprimary (struct sockaddr *sa)
 Gets the address of the primary DNS server.
void dns_setprimary (struct sockaddr *sa)
 Sets the address of the primary DNS server.
void dns_getsecondary (struct sockaddr *sa)
 Gets the address of the secondary DNS server.
void dns_setsecondary (struct sockaddr *sa)
 Sets the address of the secondary DNS server.
mailhostentdns_getmx (char *name)
 Performs a DNS MX record lookup.
void dns_enableipv6queries (unsigned char enable)
 Enables/disables attempts to make IPv6 DNS queries.
unsigned int dns_version ()
 Returns the version number of this DNS client library.


Define Documentation

#define TINI400_DNS_VERSION   7
 

Version number associated with this header file. Should be the same as the version number returned by the dns_version function.

See also:
dns_version


Function Documentation

void dns_enableipv6queries unsigned char  enable  ) 
 

Enables/disables attempts to make IPv6 DNS queries.

Use an enable value of 0 to disable attempts to perform IPv6 queries. Diabling IPv6 queries can dramatically increase the speed of the library routines. Use an enable value of non-zero to enable IPv6 DNS queries.

Parameters:
enable 0 to disable IPv6 DNS queries, non-zero to enable

struct mailhostent* dns_getmx char *  name  ) 
 

Performs a DNS MX record lookup.

MX records are mail exchanger records. In order to send an email without using a mail relay (mail host), you need to look up the MX record of the remote domain and then open the SMTP connection to the address returned by dns_getmx().

Parameters:
name domain to look up.
Returns:
DNS response(s) or NULL for failed lookup. If any valid data is returned, the first invalid mailhostent entry will have NULL for a host name.
See also:
mailhostent

void dns_getprimary struct sockaddr sa  ) 
 

Gets the address of the primary DNS server.

Fills in an address structure with the IP of the secondary DNS server used by this DNS client code. DNS operations first try to use a server designated as primary, and the use a server designated as secondary if the primary fails to return results.

Note that this gets the system's primary DNS server setting. This may have been set by the DHCP client or by previous calls to dns_setprimary. This function is equivalent to dhcp_getprimarydns.

Parameters:
sa will be filled in with the address of the primary DNS server
See also:
dns_setprimary

dns_setsecondary

dns_getsecondary

dhcp_getprimarydns

void dns_getsecondary struct sockaddr sa  ) 
 

Gets the address of the secondary DNS server.

Fills in an address structure with the IP of the secondary DNS server used by this DNS client code. DNS operations first try to use a server designated as primary, and the use a server designated as secondary if the primary fails to return results.

Note that this gets the system's secondary DNS server setting. This may have been set by the DHCP client or by previous calls to dns_setsecondary. This function is equivalent to dhcp_getsecondarydns.

Parameters:
sa will be filled in with the address of the secondary DNS server
See also:
dns_setprimary

dns_getprimary

dns_setsecondary

dhcp_getsecondarydns

unsigned long dns_gettimeout void   ) 
 

Gets the socket timeout value used for DNS server communications.

Gets the timeout value applied to all sockets that communicate with the DNS server. Call this function to verify the timeout used by DNS socket operations.

Returns:
Global timeout value for sockets use in DNS server communications
See also:
dns_settimeout

void dns_init void   ) 
 

Initializes the DNS client code.

Performs initialization for the DNS client. This function need only be called once at the start of the application.

void dns_setmaxtimeout unsigned long  t  ) 
 

Sets the maximum socket timeout value used for DNS server communications.

Sets the maximum timeout value that can be applied sockets that communicate with the DNS server. DNS operations are retried up to 4 times, and each time the timeout is doubled. This function sets the maximum timeout allowed for a single operation.

Parameters:
t Global maximum timeout value for sockets use in DNS server communications
See also:
dns_gettimeout

dns_settimeout

void dns_setprimary struct sockaddr sa  ) 
 

Sets the address of the primary DNS server.

Sets the address of the primary DNS server used by this DNS client code. DNS operations first try to use a server designated as primary, and the use a server designated as secondary if the primary fails to return results.

Note that this sets the system's primary DNS server setting. If the system's primary DNS server entry had been previously set by the DHCP client, that information will be destroyed by this function.

Parameters:
sa address of primary DNS server
See also:
dns_getprimary

dns_setsecondary

dns_getsecondary

void dns_setsecondary struct sockaddr sa  ) 
 

Sets the address of the secondary DNS server.

Sets the address of the secondary DNS server used by this DNS client code. DNS operations first try to use a server designated as primary, and the use a server designated as secondary if the primary fails to return results.

Note that this sets the system's secondary DNS server setting. If the system's secondary DNS server entry had been previously set by the DHCP client, that information will be destroyed by this function.

Parameters:
sa address of secondary DNS server
See also:
dns_getprimary

dns_setprimary

dns_getsecondary

void dns_settimeout unsigned long  t  ) 
 

Sets the socket timeout value used for DNS server communications.

Sets the timeout value applied to all sockets that communicate with the DNS server. Call this function to make sure DNS operations fail after a reasonable waiting time. All DNS operations are retried up to 4 times. In each retry, the local timeout will be doubled, up to the maximum timeout allowed.

Parameters:
t Global timeout value for sockets use in DNS server communications
See also:
dns_gettimeout

dns_setmaxtimeout

unsigned int dns_version  ) 
 

Returns the version number of this DNS client library.

Returns:
Version number of this DNS client library.

struct hostent* gethostbyaddr void *  addr,
size_t  len,
int  type
 

Looks up information on a host given an IP address.

Contacts a DNS server and attempts to find known host names for the given IP address.

Parameters:
addr IP address structure, either in_addr or in6_addr
len The length of the input structure passed to addr (4 or 16)
type AF_INET or AF_INET6
Returns:
Host structure with any names found, or NULL if the operation failed.
See also:
AF_INET

AF_INET6

in_addr

in6_addr

gethostbyname

inet_addr

hostent

struct hostent* gethostbyname char *  name  ) 
 

Looks up information on a host given a host name.

Contacts a DNS server and attempts to find known IP addresses given a host name.

Parameters:
name String representing the host name
Returns:
Host structure with any names found, or NULL if the operation failed.
See also:
gethostbyaddr

hostent


Copyright 2005 Dallas Semiconductor, Inc.. Documentation generated by Doxygen.