VxWorks Reference Manual : Libraries

hostLib

NAME

hostLib - host table subroutine library

ROUTINES

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

DESCRIPTION

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.

INCLUDE FILES

hostLib.h

SEE ALSO

hostLib, inetLib, VxWorks Programmer's Guide: Network


Libraries : Routines

hostTblInit( )

NAME

hostTblInit( ) - initialize the network host table

SYNOPSIS


void hostTblInit (void)

DESCRIPTION

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.

RETURNS

N/A

SEE ALSO

hostLib, usrConfig


Libraries : Routines

hostAdd( )

NAME

hostAdd( ) - add a host to the host table

SYNOPSIS

STATUS hostAdd
    (
    char * hostName, /* host name */
    char * hostAddr  /* host addr in standard Internet format */
    )

DESCRIPTION

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.

EXAMPLE

   -> 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

RETURNS

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.

SEE ALSO

hostLib, netDrv, nfsDrv


Libraries : Routines

hostDelete( )

NAME

hostDelete( ) - delete a host from the host table

SYNOPSIS

STATUS hostDelete
    (
    char * name, /* host name or alias */
    char * addr  /* host addr in standard Internet format */
    )

DESCRIPTION

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.

RETURNS

OK, or ERROR if the parameters are invalid or the host is unknown.

SEE ALSO

hostLib


Libraries : Routines

hostGetByName( )

NAME

hostGetByName( ) - look up a host in the host table by its name

SYNOPSIS

int hostGetByName
    (
    char * name /* name of host */
    )

DESCRIPTION

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.

RETURNS

The Internet address (as an integer in network byte order), or ERROR if the host is unknown.

SEE ALSO

hostLib


Libraries : Routines

hostGetByAddr( )

NAME

hostGetByAddr( ) - look up a host in the host table by its Internet address

SYNOPSIS

STATUS hostGetByAddr
    (
    int    addr, /* inet address of host */
    char * name  /* buffer to hold name */
    )

DESCRIPTION

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.

WARNING

This routine does not look for aliases. Host names are limited to MAXHOSTNAMELEN (from hostLib.h) characters.

RETURNS

OK, or ERROR if buffer is invalid or the host is unknown.

SEE ALSO

hostLib, hostGetByName( )


Libraries : Routines

sethostname( )

NAME

sethostname( ) - set the symbolic name of this machine

SYNOPSIS

int sethostname
    (
    char * name,   /* machine name */
    int    nameLen /* length of name */
    )

DESCRIPTION

This routine sets the target machine's symbolic name, which can be used for identification.

RETURNS

OK or ERROR.

SEE ALSO

hostLib


Libraries : Routines

gethostname( )

NAME

gethostname( ) - get the symbolic name of this machine

SYNOPSIS

int gethostname
    (
    char * name,   /* machine name */
    int    nameLen /* length of name */
    )

DESCRIPTION

This routine gets the target machine's symbolic name, which can be used for identification.

RETURNS

OK or ERROR.

SEE ALSO

hostLib