HP-UX Reference (11i v3 07/02) - 3 Library Functions N-Z (vol 7)
n
netdir(3N) netdir(3N)
NAME
netdir: netdir_getbyname(), netdir_getbyaddr(), netdir_free(), netdir_options(), taddr2uaddr(),
uaddr2taddr(), netdir_perror(), netdir_sperror() - generic transport name-to-address translation
SYNOPSIS
#include <netdir.h>
int netdir_getbyname(const struct netconfig *
config,
const struct nd_hostserv *
service,
struct nd_addrlist **
addrs);
int netdir_getbyaddr(const struct netconfig *
config,
struct nd_hostservlist **
service,
const struct netbuf *
netaddr);
void netdir_free(void *
ptr, const int struct_type );
int netdir_options(const struct netconfig *
config
,
const int
option,
const int
fildes,
char *
point_to_args);
char *taddr2uaddr(const struct netconfig *
config,
const struct netbuf *
addr);
struct netbuf *uaddr2taddr(const struct netconfig *
config,
const char *
uaddr);
void netdir_perror(char *
s);
char *netdir_sperror(void);
DESCRIPTION
These routines provide a generic interface for name-to-address mapping that will work with all transport
protocols. This interface provides a generic way for programs to convert transport specific addresses into
common structures and back again. The netconfig structure, described on the netconfig(4) manual
page, identifies the transport.
The netdir_getbyname()
routine maps the machine name and service name in the nd_hostserv
structure to a collection of addresses of the type understood by the transport identified in the
netconfig
structure. This routine returns all addresses that are valid for that transport in the nd_addrlist struc-
ture. The
nd_hostserv structure contains the following members:
char *h_host; /* host name */
char *h_serv; /* service name */
The nd_addrlist structure contains the following members:
int n_cnt; /* number of addresses */
struct netbuf *n_addrs;
netdir_getbyname()
accepts some special-case host names. The host names are defined in
<netdir.h> . The currently defined host names are:
HOST_SELF Represents the address to which local programs will bind their endpoints.
HOST_SELF differs from the host name provided by gethostname() (see
gethostname(2)), which represents the address to which remote programs will
bind their endpoints.
HOST_ANY Represents any host accessible by this transport provider. HOST_ANY allows
applications to specify a required service without specifying a particular host
name.
HOST_SELF_CONNECT Represents the host address that can be used to connect to the local host.
HOST_BROADCAST Represents the address for all hosts accessible by this transport provider. Net-
work requests to this address will be received by all machines.
All fields of the nd_hostserv structure must be initialized.
To find the address of a given host and service on all available transports, call the
netdir_getbyname() routine with each struct netconfig structure returned by
72 Hewlett-Packard Company − 1 − HP-UX 11i Version 3: February 2007