Hallo, dies ist ein Test.
PWD: /www/data-lst1/unixsoft/unixsoft/kaempfer/.public_html
Running in File Mode
Relative path: ./../../../../../../usr/man/man3c/./netdir.3c
Real path: /usr/share/man/man3c/netdir.3c
Zurück
'\" te .\" Portions Copyright (c) 2005, 2021, Oracle and/or its affiliates. .\" Copyright (c) 1989, AT&T. All rights reserved. .TH netdir 3C "2 Feb 2021" "Oracle Solaris 11.4" "Standard C Library Functions" .SH NAME netdir, netdir_getbyname, netdir_getbyaddr, netdir_free, netdir_options, taddr2uaddr, uaddr2taddr, netdir_perror, netdir_sperror, netdir_mergeaddr \- generic transport name-to-address translation .SH SYNOPSIS .LP .nf #include <netdir.h> \fBint\fR \fBnetdir_getbyname\fR(\fBstruct netconfig *\fR\fIconfig\fR, \fBstruct nd_hostserv *\fR\fIservice\fR, \fBstruct nd_addrlist **\fR\fIaddrs\fR); .fi .LP .nf \fBint\fR \fBnetdir_getbyaddr\fR(\fBstruct netconfig *\fR\fIconfig\fR, \fBstruct nd_hostservlist **\fR\fIservice\fR, \fBstruct netbuf *\fR\fInetaddr\fR); .fi .LP .nf \fBvoid\fR \fBnetdir_free\fR(\fBvoid *\fR\fIptr\fR, \fBint\fR \fIstruct_type\fR); .fi .LP .nf \fBint\fR \fBnetdir_options\fR(\fBstruct netconfig *\fR\fIconfig\fR, \fBint\fR \fIoption\fR, \fBint\fR \fIfildes\fR, \fBchar *\fR\fIpoint_to_args\fR); .fi .LP .nf \fBchar *\fR\fBtaddr2uaddr\fR(\fBstruct netconfig *\fR\fIconfig\fR, \fBstruct netbuf *\fR\fIaddr\fR); .fi .LP .nf \fBstruct netbuf *\fR\fBuaddr2taddr\fR(\fBstruct netconfig *\fR\fIconfig\fR, \fBchar *\fR\fIuaddr\fR); .fi .LP .nf \fBvoid\fR \fBnetdir_perror\fR(\fBchar *\fR\fIs\fR); .fi .LP .nf \fBchar *\fR\fBnetdir_sperror\fR(\fBvoid\fR); .fi .SH DESCRIPTION .sp .LP The \fBnetdir\fR functions 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 \fBnetconfig\fR structure, described on the \fBnetconfig\fR(5) manual page, identifies the transport. .sp .LP These functions are primarily used with the \fBRPC\fR and \fBTLI\fR frameworks. For general use, especially with the sockets \fBAPI\fR, the \fBgetaddrinfo\fR(3C) and \fBgetnameinfo\fR(3C) functions are recommended instead. .sp .LP The \fBnetdir_getbyname()\fR function maps the machine name and service name in the \fBnd_hostserv\fR structure to a collection of addresses of the type understood by the transport identified in the \fBnetconfig\fR structure. This function returns all addresses that are valid for that transport in the \fBnd_addrlist\fR structure. The \fBnd_hostserv\fR structure contains the following members: .sp .in +2 .nf char *h_host; /* host name */ char *h_serv; /* service name */ .fi .in -2 .sp .sp .LP The \fBnd_addrlist\fR structure contains the following members: .sp .in +2 .nf int n_cnt; /* number of addresses */ struct netbuf *n_addrs; .fi .in -2 .sp .sp .LP The \fBnetdir_getbyname()\fR function accepts some special-case host names. The host names are defined in <\fBnetdir.h\fR>. The currently defined host names are: .sp .ne 2 .mk .na \fB\fBHOST_SELF\fR\fR .ad .RS 21n .rt Represents the address to which local programs will bind their endpoints. \fBHOST_SELF\fR differs from the host name provided by \fBgethostname\fR(3C), which represents the address to which \fIremote\fR programs will bind their endpoints. .RE .sp .ne 2 .mk .na \fB\fBHOST_ANY\fR\fR .ad .RS 21n .rt Represents any host accessible by this transport provider. \fBHOST_ANY\fR allows applications to specify a required service without specifying a particular host name. .RE .sp .ne 2 .mk .na \fB\fBHOST_SELF_CONNECT\fR\fR .ad .RS 21n .rt Represents the host address that can be used to connect to the local host. .RE .sp .ne 2 .mk .na \fB\fBHOST_BROADCAST\fR\fR .ad .RS 21n .rt Represents the address for all hosts accessible by this transport provider. Network requests to this address are received by all machines. .RE .sp .LP All fields of the \fBnd_hostserv\fR structure must be initialized. .sp .LP To find the address of a given host and service on all available transports, call the \fBnetdir_getbyname()\fR function with each \fBstruct netconfig\fR structure returned by \fBgetnetconfig\fR(3C). .sp .LP The \fBnetdir_getbyaddr()\fR function maps addresses specified in the \fBnetbuf\fR structure pointed to by \fInetaddr\fR to service names. The function returns \fIservice\fR, a list of host and service pairs that yield these addresses. If more than one tuple of host and service name is returned, the first tuple contains the preferred host and service names: .sp .in +2 .nf struct nd_hostservlist { int *h_cnt; /* number of hostservs found */ struct hostserv *h_hostservs; } .fi .in -2 .sp .sp .LP The \fBnetdir_free()\fR structure is used to free the structures allocated by the name to address translation functions. The \fIptr\fR parameter points to the structure that has to be freed. The parameter \fBstruct_type\fR identifies the structure: .sp .in +2 .nf struct netbuf ND_ADDR struct nd_addrlist ND_ADDRLIST struct hostserv ND_HOSTSERV struct nd_hostservlist ND_HOSTSERVLIST .fi .in -2 .sp .sp .LP The \fBfree()\fR function is used to free the universal address returned by the \fBtaddr2uaddr()\fR function. .sp .LP The \fBnetdir_options()\fR function is used to do all transport-specific setups and option management. \fIfildes\fR is the associated file descriptor. \fIoption\fR, \fIfildes\fR, and \fIpointer_to_args\fR are passed to the \fBnetdir_options()\fR function for the transport specified in \fIconfig\fR. Currently four values are defined for \fIoption\fR: .br .in +2 \fBND_SET_BROADCAST\fR .in -2 .br .in +2 \fBND_SET_RESERVEDPORT\fR .in -2 .br .in +2 \fBND_CHECK_RESERVEDPORT\fR .in -2 .br .in +2 \fBND_MERGEADDR\fR .in -2 .sp .LP The \fBtaddr2uaddr()\fR and \fBuaddr2taddr()\fR functions support translation between universal addresses and \fBTLI\fR type \fBnetbufs\fR. The \fBtaddr2uaddr()\fR function takes a \fBstruct netbuf\fR data structure and returns a pointer to a string that contains the universal address. It returns \fBNULL\fR if the conversion is not possible. This is not a fatal condition as some transports do not support a universal address form. .sp .LP The \fBuaddr2taddr()\fR function is the reverse of the \fBtaddr2uaddr()\fR function. It returns the \fBstruct netbuf\fR data structure for the given universal address. .sp .LP If a transport provider does not support an option, \fBnetdir_options\fR returns \fB-1\fR and the error message can be printed through \fBnetdir_perror()\fR or \fBnetdir_sperror()\fR. .sp .LP The specific actions of each option follow. .sp .ne 2 .mk .na \fB\fBND_SET_BROADCAST\fR\fR .ad .br .sp .6 .RS 4n Sets the transport provider up to allow broadcast if the transport supports broadcast. \fIfildes\fR is a file descriptor into the transport, that is, the result of a \fBt_open\fR of \fB/dev/udp\fR. \fIpointer_to_args\fR is not used. If this completes, broadcast operations can be performed on file descriptor \fIfildes\fR. .RE .sp .ne 2 .mk .na \fB\fBND_SET_RESERVEDPORT\fR\fR .ad .br .sp .6 .RS 4n Allows the application to bind to a reserved port if that concept exists for the transport provider. \fIfildes\fR is an unbound file descriptor into the transport. If \fIpointer_to_args\fR is \fBNULL\fR, \fIfildes\fR is bound to a reserved port. If \fIpointer_to_args\fR is a pointer to a \fBnetbuf\fR structure, an attempt is made to bind to any reserved port on the specified address. .RE .sp .ne 2 .mk .na \fB\fBND_CHECK_RESERVEDPORT\fR\fR .ad .br .sp .6 .RS 4n Used to verify that the address corresponds to a reserved port if that concept exists for the transport provider. \fIfildes\fR is not used. \fIpointer_to_args\fR is a pointer to a \fBnetbuf\fR structure that contains the address. This option returns \fB0\fR only if the address specified in \fIpointer_to_args\fR is reserved. .sp This option only checks the port value against \fBIPPORT_RESERVED\fR and does not take into account the controls on port usage handled via \fBprivileges\fR(7) or additional ports restricted via the "\fBextra-priv-ports\fR" or "\fBsmallest-nonpriv-port\fR" protocol properties which may be set via \fBipadm\fR(8). .RE .sp .ne 2 .mk .na \fB\fBND_MERGEADDR\fR\fR .ad .br .sp .6 .RS 4n Used to take a "local address" such as a \fB0.0.0.0\fR TCP address and return a "real address" to which client machines can connect. \fIfildes\fR is not used. \fIpointer_to_args\fR is a pointer to a \fBstruct nd_mergearg\fR which has the following members: .sp .sp .in +2 .nf \fBchar\fR \fIs_uaddr;\fR /* server's universal address */ \fBchar\fR \fIc_uaddr;\fR /* client's universal address */ \fBchar\fR \fIm_uaddr;\fR /* the result */ .fi .in -2 .sp If \fBs_uaddr\fR is an address such as \fB0.0.0.0.1.12\fR, and the call is successful \fBm_uaddr\fR is set to an address such as \fB192.11.109.89.1.12\fR. For most transports, \fBm_uaddr\fR is identical to \fBs_uaddr\fR. .RE .SH RETURN VALUES .sp .LP The \fBnetdir_perror()\fR function prints an error message in standard output that states the cause of a name-to-address mapping failure. The error message is preceded by the string given as an argument. .sp .LP The \fBnetdir_sperror()\fR function returns a string with an error message that states the cause of a name-to-address mapping failure. .sp .LP The \fBnetdir_sperror()\fR function returns a pointer to a buffer which contains the error message string. The buffer is overwritten on each call. In multithreaded applications, this buffer is implemented as thread-specific data. .sp .LP The \fBnetdir_getbyaddr()\fR function returns \fB0\fR on success and a non-zero value on failure. .SH ATTRIBUTES .sp .LP See \fBattributes\fR(7) for descriptions of the following attributes: .sp .TS tab( ) box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) . ATTRIBUTE TYPE ATTRIBUTE VALUE _ Interface Stability Committed _ MT-Level Safe .TE .sp .SH SEE ALSO .sp .LP \fBgetaddrinfo\fR(3C), \fBgethostname\fR(3C), \fBgetnetconfig\fR(3C), \fBgetnetpath\fR(3C), \fBnetconfig\fR(5), \fBattributes\fR(7) .SH HISTORY .sp .LP These functions have been present since the initial release of Solaris.