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



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.



Error Messages



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 ]