VxWorks Reference Manual : Libraries
hostLib - host table subroutine library
hostTblInit( ) - initialize the network host table
hostAdd( ) - add a host to the host table
hostDelete( ) - delete a host from the host table
hostGetByName( ) - look up a host in the host table by its name
hostGetByAddr( ) - look up a host in the host table by its Internet address
sethostname( ) - set the symbolic name of this machine
gethostname( ) - get the symbolic name of this machine
This library provides routines to store and access the network host database. The host table contains information regarding the known hosts on the local network. The host table (displayed with hostShow( )) contains the Internet address, the official host name, and aliases.
By convention, network addresses are specified in dotted (".") decimal notation. The library inetLib contains Internet address manipulation routines. Host names and aliases may contain any printable character.
Before any of the routines in this module can be used, the library must be initialized by hostTblInit( ). This is done automatically if the configuration macro INCLUDE_NET_INIT is defined.
hostLib.h
hostLib, inetLib, VxWorks Programmer's Guide: Network
hostTblInit( ) - initialize the network host table
void hostTblInit (void)
This routine initializes the host list data structure used by routines throughout this module. It should be called before any other routines in this module. This is done automatically if the configuration macro INCLUDE_NET_INIT is defined.
N/A
hostLib, usrConfig
hostAdd( ) - add a host to the host table
STATUS hostAdd ( char * hostName, /* host name */ char * hostAddr /* host addr in standard Internet format */ )
This routine adds a host name to the local host table. This must be called before sockets on the remote host are opened, or before files on the remote host are accessed via netDrv or nfsDrv.
The host table has one entry per Internet address. More than one name may be used for an address. Additional host names are added as aliases.
-> hostAdd "wrs", "90.2" -> hostShow hostname inet address aliases -------- ------------ ------- localhost 127.0.0.1 yuba 90.0.0.3 wrs 90.0.0.2 value = 12288 = 0x3000 = _bzero + 0x18
OK, or ERROR if the host table is full, the host name/inet address pair is already entered, the Internet address is invalid, or memory is insufficient.
hostDelete( ) - delete a host from the host table
STATUS hostDelete ( char * name, /* host name or alias */ char * addr /* host addr in standard Internet format */ )
This routine deletes a host name from the local host table. If name is a host name, the host entry is deleted. If name is a host name alias, the alias is deleted.
OK, or ERROR if the parameters are invalid or the host is unknown.
hostGetByName( ) - look up a host in the host table by its name
int hostGetByName ( char * name /* name of host */ )
This routine returns the Internet address of a host that has been added to the host table by hostAdd( ). If the DNS resolver library resolvLib has been configured in the vxWorks image, a query for the host IP address is sent to the DNS server, if the name was not found in the local host table.
The Internet address (as an integer in network byte order), or ERROR if the host is unknown.
hostGetByAddr( ) - look up a host in the host table by its Internet address
STATUS hostGetByAddr ( int addr, /* inet address of host */ char * name /* buffer to hold name */ )
This routine finds the host name by its Internet address and copies it to name. The buffer name should be preallocated with (MAXHOSTNAMELEN + 1) bytes of memory and is NULL-terminated unless insufficient space is provided. If the DNS resolver library resolvLib has been configured in the vxWorks image, a query for the host name is sent to the DNS server, if the name was not found in the local host table.
This routine does not look for aliases. Host names are limited to MAXHOSTNAMELEN (from hostLib.h) characters.
OK, or ERROR if buffer is invalid or the host is unknown.
hostLib, hostGetByName( )
sethostname( ) - set the symbolic name of this machine
int sethostname ( char * name, /* machine name */ int nameLen /* length of name */ )
This routine sets the target machine's symbolic name, which can be used for identification.
OK or ERROR.
gethostname( ) - get the symbolic name of this machine
int gethostname ( char * name, /* machine name */ int nameLen /* length of name */ )
This routine gets the target machine's symbolic name, which can be used for identification.
OK or ERROR.