netdir(3N)netdir(3N)NAME
netdir: netdir_getbyname(), netdir_getbyaddr(), netdir_free(), net‐
dir_options(), taddr2uaddr(), uaddr2taddr(), netdir_perror(), net‐
dir_sperror() - generic transport name-to-address translation
SYNOPSISDESCRIPTION
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 structure, described on the net‐
config(4) manual page, identifies the transport.
The routine maps the machine name and service name in the structure to
a collection of addresses of the type understood by the transport iden‐
tified in the structure. This routine returns all addresses that are
valid for that transport in the structure. The structure contains the
following members:
The structure contains the following members:
accepts some special-case host names. The host names are defined in
The currently defined host names are:
Represents the address to which local programs will bind their end‐
points. differs from the host name provided by (see gethostname(2)),
which represents the address to which remote programs will bind their
endpoints.
Represents any host accessible by this transport provider.
allows applications to specify a required service without speci‐
fying a particular host name.
Represents the host address that can be used to connect to the local
host.
Represents the address for all hosts
accessible by this transport provider. Network requests to this
address will be received by all machines.
All fields of the structure must be initialized.
To find the address of a given host and service on all available trans‐
ports, call the routine with each structure returned by (See getnetcon‐
fig(3N)).
The routine maps addresses to service names. This routine returns ser‐
vice, a list of host and service pairs that would yield this address.
If more than one tuple of host and service name is returned, then the
first tuple contains the preferred host and service names:
The function is used to free the structures allocated by the name to
address translation routines. The ptr parameter points to the struc‐
ture that has to be freed. The parameter identifies the structure:
The universal address returned by should be freed by
The routine is used to do all transport-specific setups and option man‐
agement. fildes is the associated file descriptor. option, fildes,
and pointer_to_args are passed to the routine for the transport speci‐
fied in config. Currently four values are defined for option:
The and routines support translation between universal addresses and
TLI type The routine takes a data structure and returns a pointer to a
string that contains the universal address. It returns NULL if the
conversion is not possible. This is not a fatal condition as some
transports may not support a universal address form.
is the reverse of It returns the data structure for the given universal
address.
If a transport provider does not support an option, returns and the
error message can be printed through or
The specific actions of each option follow.
Sets the transport provider up to allow broadcast, if the transport
supports broadcast. fildes is a file descriptor into the transport
(i.e., the result of a of pointer_to_args is not used. If this com‐
pletes, broadcast operations may be performed on file descriptor
fildes.
Allows the application to bind to a reserved port, if that concept
exists for the transport provider. fildes is an unbound file
descriptor into the transport. If pointer_to_args is NULL,
fildes will be bound to a reserved port. If pointer_to_args is
a pointer to a structure, an attempt will be made to bind to any
reserved port on the specified address.
Used to verify that the address corresponds to a reserved port,
if that concept exists for the transport provider. fildes is
not used. pointer_to_args is a pointer to a structure that con‐
tains the address. This option returns only if the address
specified in pointer_to_args is reserved.
Used to take a "local address", such as a
TCP address, and return a "real address" to which client
machines can connect. fildes is not used. pointer_to_args is a
pointer to a which has the following members:
If is an address such as and the call is successful, is set to
an address such as For most transports, is identical to
MULTITHREAD USAGE
Thread Safe: Yes
Cancel Safe: Yes
Fork Safe: No
Async-cancel Safe: No
Async-signal Safe: No
These functions can be called safely in a multithreaded environment.
They may be cancellation points in that they call functions that are
cancel points.
In a multithreaded environment, these functions are not safe to be
called by a child process after and before These functions should not
be called by a multithreaded application that supports asynchronous
cancellation or asynchronous signals.
RETURN VALUE
The routine prints an error message on the standard output stating why
one of the name-to-address mapping routines failed. The error message
is preceded by the string given as an argument.
The returns a pointer to a buffer which contains an error message
string stating why one of the name-to-address mapping routines failed.
This buffer is overwritten on each call. In multithreaded applica‐
tions, this buffer is implemented as thread-specific data.
The function returns on success and a non-zero value on failure.
SEE ALSOgethostname(2), getnetconfig(3N), getnetpath(3N), netconfig(4).
netdir(3N)