rpcb_getaddr()--Find the Universal Address of a Service


  Syntax

 #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);

  Service Program Name: QZNFTRPC

  Default Public Authority: *USE

  Threadsafe: No

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.


Parameters

prognum  (Input) 
The program number of the remote program.

vernum  (Input) 
The version number of the remote program.

netconf  (Input) 
The transport protocol.

svcaddr  (Output) 
A pointer to the address of the requested service on the remote host machine.

host  (Input) 
The name of the remote host where the server is located.

Authorities

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.


Return Value



Error Conditions

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:

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.


Error Messages



Example

The following example shows how rpcb_getaddr is used.

Note: By using the code examples, you agree to the terms of the Code license and disclaimer information.

/* 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);
  }

  ...

}


API introduced: V4R2

[ Back to top | Remote Procedure Call (RPC) APIs | APIs by category ]