svc_reg()--Associate Program and Version with Dispatch


  Syntax

 #include <rpc/rpc.h>
 #include <netconfig.h>

 bool_t svc_reg(const SVCXPRT *xprt,
             const u_long prognum,
             const u_long versnum,
             const void (*dispatch)(const svc_req *,
                 const SVCXPRT *),
             const struct netconfig *netconf);

  Service Program Name: QZNFTRPC

  Default Public Authority: *USE

  Threadsafe: No

The svc_reg() API associates prognum and versnum with the service dispatch procedure dispatch. If netconf is NULL, the service is not registered with the RPC service package (RPCBind). If netconf is non-null, then a mapping of the triple (prognum, versnum, netconf->nc_netid) to xprt->xp_ltaddr is established with the local RPCBind service.


Parameters

xprt  (I/O) 
A pointer to a Remote Procedure Call (RPC) service transport handle.

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

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

dispatch  (Input) 
The server dispatch function.

netconf  (Input) 
The transport protocol.

Authorities

The caller of the svc_reg() API must have execute (*X) authority to the /etc directory and must have read (*R) authority to the netconfig file.


Return Value

TRUE (1) svc_reg() was successful.
FALSE (0) svc_reg() was not successful. The errno variable is set to indicate the reason.


Error Conditions

This API calls the setnetconfig() and getnetconfig() functions in order to perform its task. The API inherits all error conditions from those functions. It also calls rpcb_set() for registering in RPCBind inheriting all error conditions from the API, except RPC_UNKNOWNPROTO.

[EINVAL] Attempt to register a dispatcher with prognum and versnum, which are already used by another dispatcher.
[EALREADY] Attempting to register a service which is already registered.


Error Messages

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.
CPIA1B2 I TI-RPC encountered a problem with the transport protocol.
CPIA1B8 I A problem occurred while trying to contact the RPCBind daemon.


Example

The following example shows how svc_reg() 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

#include <stdio.h>
#include <rpc/rpc.h>
#include <netconfig.h>

static void exm_proc();

main()
{
  SVCXPRT *xprt;
  struct netconfig *nconf;
  int result;

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

  ...

  result = svc_reg(xprt, RMTPROGNUM, RMTPROGVER,
                                 exm_proc, nconf);
  if ( !result){
    fprintf(stderr, "svc_reg failed!!\n");
    exit(1);
  }
  ...
}

/* The server dispatch function */
static void exm_proc(struct svc_req *rqstp, SVCXPRT *transp)
{

  ...

}


API introduced: V4R2

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