---
name: "rpc_reg"
section: "3"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd"]
url: "https://new.carta.tech/rpc_reg"
---

# rpc\_reg(3)

library routines for registering servers

## NAME

**rpc\_svc\_reg**, **rpc\_reg**, **svc\_reg**, **svc\_unreg**, **svc\_auth\_reg**, **xprt\_register**, **xprt\_unregister** – library routines for registering servers

## LIBRARY

Standard C Library (libc, -lc)

## SYNOPSIS

**#include \<rpc/rpc.h\>**

*int*\

**rpc\_reg**(*rpcprog\_t prognum*, *rpcvers\_t versnum*, *rpcproc\_t procnum*, *char \*(\*procname)()*, *xdrproc\_t inproc*, *xdrproc\_t outproc*, *char \*nettype*);

*bool\_t*\

**svc\_reg**(*SVCXPRT \*xprt*, *const rpcprog\_t prognum*, *const rpcvers\_t versnum*, *void (\*dispatch)(struct svc\_req \*, SVCXPRT \*)*, *const struct netconfig \*netconf*);

*void*\

**svc\_unreg**(*const rpcprog\_t prognum*, *const rpcvers\_t versnum*);

*int*\

**svc\_auth\_reg**(*int cred\_flavor*, *enum auth\_stat (\*handler)(struct svc\_req \*, struct rpc\_msg \*)*);

*void*\

**xprt\_register**(*SVCXPRT \*xprt*);

*void*\

**xprt\_unregister**(*SVCXPRT \*xprt*);

## DESCRIPTION

These routines are a part of the RPC library which allows the RPC servers to register themselves with rpcbind (see [rpcbind(8)](/rpcbind/8.md)), and associate the given program and version number with the dispatch function. When the RPC server receives a RPC request, the library invokes the dispatch routine with the appropriate arguments.

## Routines

See [rpc(3)](/rpc/3.md) for the definition of the *SVCXPRT* data structure.

- **rpc\_reg**()

  Register program *prognum*, procedure *procname*, and version *versnum* with the RPC service package. If a request arrives for program *prognum*, version *versnum*, and procedure *procnum*, *procname* is called with a pointer to its argument(s); *procname* should return a pointer to its static result(s); *inproc* is the XDR function used to decode the arguments while *outproc* is the XDR function used to encode the results. Procedures are registered on all available transports of the class *nettype*. See [rpc(3)](/rpc/3.md). This routine returns 0 if the registration succeeded, -1 otherwise.

- **svc\_reg**()

  Associates *prognum* and *versnum* with the service dispatch procedure, *dispatch*. If *netconf* is NULL, the service is not registered with the [rpcbind(8)](/rpcbind/8.md) service. If *netconf* is non-zero, then a mapping of the triple \[*prognum*, *versnum*, *netconf-\>nc\_netid*,,\] to *xprt-\>xp\_ltaddr* is established with the local rpcbind service.

  The **svc\_reg**() routine returns 1 if it succeeds, and 0 otherwise.

- **svc\_unreg**()

  Remove from the rpcbind service, all mappings of the triple \[*prognum*, *versnum*,, all-transports\] to network address and all mappings within the RPC service package of the double \[*prognum*, *versnum*,\] to dispatch routines.

- **svc\_auth\_reg**()

  Registers the service authentication routine *handler* with the dispatch mechanism so that it can be invoked to authenticate RPC requests received with authentication type *cred\_flavor*. This interface allows developers to add new authentication types to their RPC applications without needing to modify the libraries. Service implementors usually do not need this routine.

  Typical service application would call **svc\_auth\_reg**() after registering the service and prior to calling **svc\_run**(). When needed to process an RPC credential of type *cred\_flavor*, the *handler* procedure will be called with two arguments, *struct svc\_req \*rqst* and *struct rpc\_msg \*msg*, and is expected to return a valid *enum auth\_stat* value. There is no provision to change or delete an authentication handler once registered.

  The **svc\_auth\_reg**() routine returns 0 if the registration is successful, 1 if *cred\_flavor* already has an authentication handler registered for it, and -1 otherwise.

- **xprt\_register**()

  After RPC service transport handle *xprt* is created, it is registered with the RPC service package. This routine modifies the global variable *svc\_fdset* (see [rpc\_svc\_calls(3)](/rpc_svc_calls/3.md)). Service implementors usually do not need this routine.

- **xprt\_unregister**()

  Before an RPC service transport handle *xprt* is destroyed, it unregisters itself with the RPC service package. This routine modifies the global variable *svc\_fdset* (see [rpc\_svc\_calls(3)](/rpc_svc_calls/3.md)). Service implementors usually do not need this routine.

## SEE ALSO

[select(2)](/select/2.md), [rpc(3)](/rpc/3.md), [rpc\_svc\_calls(3)](/rpc_svc_calls/3.md), [rpc\_svc\_create(3)](/rpc_svc_create/3.md), [rpc\_svc\_err(3)](/rpc_svc_err/3.md), [rpcbind(3)](/rpcbind/3.md), [rpcbind(8)](/rpcbind/8.md)
