Oberon || Library || Module Index || Search Engine || Definition || Module


Ulm's Oberon Library:
UnixHost


NAME

UnixHost - retrieve name and address of the current host

SYNOPSIS

PROCEDURE GetHostName(VAR hostname: ARRAY OF CHAR);
PROCEDURE GetDomainName(VAR domain: ARRAY OF CHAR);
PROCEDURE GetFullyQualifiedHostName(VAR name: ARRAY OF CHAR);


PROCEDURE GetLocalIPv4Address(VAR ipaddr: IPv4Addresses.Address) : BOOLEAN; PROCEDURE GetLocalIPv6Address(VAR ipaddr: IPv6Addresses.Address) : BOOLEAN;

DESCRIPTION

UnixHost attempts to find and verify the host and domain name of the current host and the corresponding IP addresses using some system calls and the DNS system.

GetHostName returns the non-qualified hostname of the current host. Firstly, SysUname.GetNodeName is tried, and, if this fails, SysHost.GetHostName. If the hostname returned by either of these system calls includes a domain name, it is stripped off.

GetDomainName uses GetFullyQualifiedHostName to retrieve the fully qualified domain name and remove its host part.

GetFullyQualifiedHostName attempts to return the fully qualified hostname of the current host for which DNS address records exists to which local sockets can be bound to. It starts with the hostname returned by GetHostName and attempts to retrieve address records for it using DNSResolvers. If this fails, the environment variable LOCALDOMAIN is checked for and, if defined, combined with the unqualified hostname to retrieve DNS address records. If this fails as well, a final attempt is made using the domain name returned by SysHost.GetDomainName.

GetLocalIPv4Address and GetLocalIPv6Address return one of the address records that are defined for the hostname returned by GetFullyQualifiedHostName. They return FALSE if no such addresses exists. The selection is non-deterministic if multiple addresses exist.

ENVIRONMENT

LOCALDOMAIN
is, if provided, one of the candidates for domain names that are tested by GetFullyQualifiedHostName

SEE ALSO

SysHost
system calls gethostname(2) and getdomainname(2)
SysUname
system call uname(2) which includes a node name

BUGS

On machines that are connected to external and private networks, GetFullyQualifiedHostName is unable to ensure that the external network is picked out. If different domains are used, it is helpful to enforce the correct selection by setting the environment variable LOCALDOMAIN appropriately.
Edited by: borchert, last change: 2004/04/08, revision: 1.1, converted to HTML: 2004/04/08

Oberon || Library || Module Index || Search Engine || Definition || Module