#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);
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.
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.
| TRUE (1) | svc_reg() was successful. |
| FALSE (0) | svc_reg() was not successful. The errno variable is set to indicate the reason. |
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. |
| 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. |
See Code disclaimer information for information pertaining to code examples.
The following example shows how svc_reg() is used:
/* 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)
{
...
}
| Top | Remote Procedure Call (RPC) APIs | APIs by category |