RPCBIND(3)

πŸ“¦
version 1.3.8 Β· 2 versions
  • 1.3.8 Β· alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, centos-stream 9, debian bookworm, debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking (latest)
  • 1.3.2 Β· ubuntu jammy
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, centos-stream 9, debian bookworm, debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– RPCBIND(3) β€” bestie's guide to the RPC bind service πŸ’–

Library Functions Manual Β· RPCBIND(3)

okay so. hi. you're here because you're writing C that needs to talk to the RPC binder, and honestly? iconic of you. this whole page lives in section 3 of the manual and it's all about the little squad of routines that let your client C program yell at rpcbind. buckle up bestie πŸŽ€


✨ NAME ✨

rpcb_getmaps, rpcb_getaddr, rpcb_gettime, rpcb_rmtcall, rpcb_set, rpcb_unset β€” library routines for the RPC bind service, aka your new besties 🫢


🌸 SYNOPSIS 🌸

like literally just include the header and you're in:

#include <rpc/rpc.h>

rpcblist *
rpcb_getmaps(const struct netconfig *netconf, const char *host);

bool_t
rpcb_getaddr(const rpcprog_t prognum, const rpcvers_t versnum,
    const struct netconfig *netconf, struct netbuf *svcaddr,
    const char *host);

bool_t
rpcb_gettime(const char *host, time_t * timep);

enum clnt_stat
rpcb_rmtcall(const struct netconfig *netconf, const char *host,
    const rpcprog_t prognum, const rpcvers_t versnum,
    const rpcproc_t procnum, const xdrproc_t inproc, const caddr_t in,
    const xdrproc_t outproc, const caddr_t out,
    const struct timeval tout, const struct netbuf *svcaddr);

bool_t
rpcb_set(const rpcprog_t prognum, const rpcvers_t versnum,
    const struct netconfig *netconf, const struct netbuf *svcaddr);

bool_t
rpcb_unset(const rpcprog_t prognum, const rpcvers_t versnum,
    const struct netconfig *netconf);

πŸ’… DESCRIPTION πŸ’…

these routines let client C programs make procedure calls to the RPC binder service. and like, rpcbind(8) (yes, go read it, i'll wait πŸ’–) is out here maintaining a whole list of mappings between programs and their universal addresses. it's giving matchmaker. it's giving address book but for RPC. no cap.


πŸ¦‹ Routines πŸ¦‹

rpcb_getmaps()

an interface to the rpcbind service that returns a list of the current RPC program-to-address mappings on host. it uses the transport you specified through netconf to go contact the remote rpcbind service on host. and heads up: this one will return NULL if the remote rpcbind could not be contacted. like, ghosted. πŸ’€

rpcb_getaddr()

an interface to the rpcbind service that finds the address of the service on host that's registered with program number prognum, version versnum, and speaks the transport protocol associated with netconf. the address it finds gets returned in svcaddr. and btw the svcaddr argument should be preallocated β€” you gotta bring your own buffer, bestie, this routine is not doing it for you.

this routine returns TRUE if it succeeds. a return value of FALSE means either the mapping does not exist, or the RPC system failed to contact the remote rpcbind service. in that latter case, the global variable rpc_createerr (see rpc_clnt_create(3)) is holding the RPC status for you. so check it. πŸ‘‘

rpcb_gettime()

this routine returns the time on host in timep. and if host is NULL? it just returns the time on its own machine. main character energy, honestly. returns TRUE if it succeeds, FALSE if it fails.

the rpcb_gettime() function can be used to synchronize the time between the client and the remote server. clock sync slay ⏰✨

rpcb_rmtcall()

an interface to the rpcbind service that instructs rpcbind on host to make an RPC call on your behalf to a procedure on that host. the netconfig() structure should correspond to a connectionless transport. the svcaddr argument will be modified to the server's address if the procedure succeeds (see rpc_call() and clnt_call() in rpc_clnt_calls(3) for the definitions of the other arguments).

this procedure should normally be used for a "ping" and nothing else. it does let programs do lookup and call, all in one step, which is cute, but still β€” ping. that's the vibe.
Note: even if the server is not running, rpcb_rmtcall() does not return any error messages to the caller. in such a case, the caller times out. 😭 silence. just silence.
Note: rpcb_rmtcall() is only available for connectionless transports. periodt.

rpcb_set()

an interface to the rpcbind service that establishes a mapping between the triple [prognum, versnum, netconf->nc_netid] and svcaddr on the machine's rpcbind service. the value of nc_netid must correspond to a network identifier that is defined by the netconfig database. this routine returns TRUE if it succeeds, FALSE otherwise. (see also svc_reg() in rpc_svc_calls(3).)

and okay important: if there already exists such an entry with rpcbind, rpcb_set() will fail. no duplicates, we don't do that here πŸ™ˆ

rpcb_unset()

an interface to the rpcbind service that destroys the mapping between the triple [prognum, versnum, netconf->nc_netid] and the address on the machine's rpcbind service.

if netconf is NULL, rpcb_unset() destroys all mapping between the triple [prognum, versnum, all-transports] and the addresses on the machine's rpcbind service. yeah. all of them. wipeout.

this routine returns TRUE if it succeeds, FALSE otherwise. only the owner of the service or the super-user can destroy the mapping. (see also svc_unreg() in rpc_svc_calls(3).) so like, know your permissions before you start deleting things, bestie πŸ’…


🌈 AVAILABILITY 🌈

these functions are part of libtirpc. 🫢


⭐ ENVIRONMENT ⭐

if RPCB_V2FIRST is defined, the rpcbind protocol version tryout algorithm changes from v4,v2,v3 to v2,v4,v3.

that's it. that's the whole env var. tiny but mighty. ✨


πŸ‘‘ SEE ALSO πŸ‘‘


Debian Β· May 7, 1993

and that's the whole page, bestie πŸŽ€ written by the good people at Debian, dated May 7, 1993 (yes, a true vintage icon, older than most of us and still serving). go register something. go call something. go be the main character of your own RPC stack. mwah πŸ’–πŸ¦‹βœ¨

πŸ“¦ where this page comes from