Host — C Library Procedures
NAME
Host_ByName, Host_ByID, Host_ByNetAddr, Host_ByInetAddr, Host_SetFile, Host_Start, Host_Next, Host_End − return information about Sprite machines
SYNOPSIS
#include <host.h>
Host_Entry ∗
Host_ByName(name)
Host_Entry ∗
Host_ByID(spriteID)
Host_Entry ∗
Host_ByNetAddr(addrPtr)
Host_Entry ∗
Host_ByInetAddr(inetAddr)
int
Host_SetFile(fileName)
int
Host_Start()
Host_Entry ∗
Host_Next()
void
Host_End()
int
Host_Stat(statPtr)
ARGUMENTS
char ∗name (in) The name of a Sprite host for which information is desired.
int spriteID (in) The Sprite ID of the host for which information is desired.
Net_Address ∗addrPtr (in) The local network address of the host for which information is desired.
Net_InetAddress inetAddr (in) The internet address of the host for which information is desired.
char ∗fileName (in) The name of a host-description file.
struct stat (∗statPtr) Pointer to stat structure for host database file.
DESCRIPTION
These functions are used to learn about hosts on the local Sprite network. These functions cause the host description file to be opened. Host_End() must be called to close the file.
A Host_Entry structure is defined as follows: typedef struct { char ∗name; /∗ Primary name ∗/ char ∗∗aliases; /∗ Other names ∗/ int id; /∗ Sprite ID ∗/ char ∗machType; /∗ Machine type, i.e "sun3" ∗/ int numNets; /∗ Number of network interfaces the ∗ host has. ∗/ Host_Interface nets[HOST_MAX_INTERFACES]; /∗ Internet and physical address for ∗ each network interface. ∗/ } Host_Entry;
typedef struct Host_Interface { Net_InetAddress inetAddr; /∗ Internet address ∗/ Net_Address netAddr; /∗ Physical address ∗/ } Host_Interface;
The numNets field indicates how many network interfaces the host has. One entry in the nets array will be filled in per interface. Unused entries will have the network type in netAddr set to NET_ADDRESS_NONE.
The Host_Entry structures returned by the routines are statically allocated and may change on the next call to any Host_ procedure. Be sure to copy out any information you need before calling a Host_ procedure again.
Host_ByName() returns a Host_Entry based on the name or alias of a host.
Host_ByID() returns a Host_Entry for the host with the given sprite ID.
Host_ByNetAddr() returns the Host_Entry for the host with the given local-area-network address.
Host_ByInetAddr() returns the Host_Entry for the host with the given internet address.
Host_SetFile() specifies a different host information file to use (the file normally used is /etc/spritehosts).
Host_Start() opens the current host-description file (if it isn’t already open), while Host_End() closes it. The Host_By... procedures automatically call Host_Start.
Host_Next() may be used to step through the current host-description file. The host-description file must have been opened using Host_Start() or one of the Host_By functions.
Host_Stat() is used to get the statistics for the host-description file. See the stat() man page for details on the stat structure. Host_Stat() is useful if you are writing a daemon that wants to do something when the host-description file is updated. The daemon can loop waiting for the modify time of the file to change. Make sure the host-description file is closed (use Host_End()) before the daemon waits, otherwise every machine running the daemon will have the host-description file open, causing lots of consistency traffic.
DIAGNOSTICS
Host_SetFile(),Host_Start() and Host_Stat() return zero if all went well. Otherwise they return -1 and the errno variable contains additional information about what error occurred. Host_Next() returns NULL on end-of-file. Host_ByName(), Host_ByID(), Host_ByNetAddr() and Host_ByInetAddr() return NULL if the given host could not be found.
FILES
/etc/spritehostsThe default host-description file.
KEYWORDS
hostname, internet address, local net, machine type, sprite ID
Sprite version 1.0 — June 04, 1992