#include <rpc/rpc.h> #include <netconfig.h> bool_t rpcb_getaddr(const u_long prognum, const u_long versnum, const struct netconfig *netconf, struct netbuf *svcaddr, const char *host);
The rpcb_getaddr() function is an interface to the RPC service package (RPCBind). The function finds the address of the service on the host that is registered with program number prognum and version versnum, and uses the transport protocol that is associated with netconf.
The caller of the rpcb_getaddr() API must have execute (*X) authority to the /etc directory and must have read (*R) authority to the netconfig file.
TRUE (1) | rpcb_getaddr() was successful. The address of the remote service in the svcaddr parameter was returned. |
FALSE (0) | rpcb_getaddr() was unsuccessful. |
Upon failure, rpcb_getaddr() sets the global structure rpc_createerr. The rpc_createerr.cf_stat variable contains a status value, which indicates the error reason. The rpc_createerr.cf_error.re_errno variable is meaningful when some status values are set.
The rpc_createerr.cf_stat variable can be set to one of the following values:
[RPC_FAILED] | The buffer referenced by the svcaddr parameter does not have enough space. re_errno field is set to ENOBUFS. |
[RPC_INTR] | Interrupted RPC call. An exception has occurred in the RPC API. The rpc_createerr.cf_error.re_errno is set to EUNKNOWN. |
[RPC_N2AXLATEFAILURE] | Name-to-address translation failed. |
[RPC_PROGNOTREGISTERED] | Remote program is not registered. |
[RPC_RPCBFAILURE] | Unable to contact the RPCBind daemon. |
[RPC_UNKNOWNADDR] | Unknown address. The svcaddr is invalid. |
[RPC_UNKNOWNHOST] | Unknown host. The rpc_createerr.cf_error.re_errno variable is not applicable. |
[RPC_UNKNOWNPROTO] | Unknown client/server protocol. The rpc_createerr.cf_error.re_errno is set with errno value returned from the setnetconfig() or getnetconfig() call. |
This API calls clnt_tli_create() and clnt_call() APIs. It inherits RPC_SYSTEMERROR from clnt_tli_create() API and it inherits all error conditions from clnt_call() API except RPC_TIMEDOUT, RPC_PROGNOTREGISTERED, RPC_PROGVERSMISMATCH, and RPC_FAILED.
Message ID | Error Message Text |
---|---|
CPIA1B1 I | A problem was encountered in the RPC client. |
CPIA1B2 I | TI-RPC encountered a problem in the transport protocol. |
CPIA1B8 I | A problem occurred while trying to contact the RPCBind daemon. |
CPE3418 E | Possible APAR condition or hardware failure. |
CPF3CF2 E | Error(s) occurred during running of &1 API. |
CPF9872 E | Program or service program &1 in library &2 ended. Reason code &3. |
See Code disclaimer information for information pertaining to code examples.
The following example shows how rpcb_getaddr is used:
/* Define remote program number and version */ #define RMTPROGNUM (u_long)0x3fffffffL #define RMTPROGVER (u_long)0x1 #define ADDBUFSIZE 100 #include <stdio.h> #include <rpc/rpc.h> #include <netconfig.h> main() { struct netconfig *nconf; struct netbuf *svcaddr; char addrbuf[ADDRBUFSIZE]; ... svcaddr.len = 0; svcaddr.maxlen = ADDRBUFSIZE; svcaddr.buf = addrbuf; /* Returns a pointer to nconf corresponding to NETCONF */ if ((nconf = getnetconfigent("UDP")) == (struct netconfig *)NULL) { fprintf(stderr, "Cannot get netconfig entry for UDP\n"); exit(1); } ... if (!rpcb_getaddr(RMTPROGNUM, RMTPROGVER, nconf, svcaddr, "as400.somewhere.ibm.com")){ fprintf(stderr, "rpcb_getaddr failed!!\n"); exit(1); } ... }
Top | Remote Procedure Call (RPC) APIs | APIs by category |