Skip to main content

onc_rpcbind/
rpcbind.rs

1//! RPCBIND v3/v4 types and client -- [RFC 1833].
2//!
3//! rpcbind (program 100000) extends the portmapper with versioned
4//! protocol bindings.  Version 3 adds `GETTIME` (server clock);
5//! version 4 adds `GETSTAT` (per-version operational statistics).
6//! Both accept `AUTH_NONE` and return useful recon data.
7//!
8//! [RFC 1833]: https://www.rfc-editor.org/rfc/rfc1833
9
10use onc_rpc_client::RpcClient;
11use onc_rpc_client::RpcError;
12use onc_rpc_client::transport::io::{AsyncRead, AsyncWrite};
13use onc_xdr::{List, Opaque, Pack, Unpack, Void};
14
15use crate::types::PROGRAM;
16
17// --- Procedure numbers (RFC 1833 sec. 2.1, 2.2.1, 2.2.2) ---
18
19/// RPCBPROC_SET (proc 1, v3/v4, RFC 1833 sec. 2.1).
20const RPCBPROC_SET: u32 = 1;
21/// RPCBPROC_UNSET (proc 2, v3/v4, RFC 1833 sec. 2.1).
22const RPCBPROC_UNSET: u32 = 2;
23/// RPCBPROC_GETADDR (proc 3, v3/v4, RFC 1833 sec. 2.1).
24const RPCBPROC_GETADDR: u32 = 3;
25/// RPCBPROC_DUMP (proc 4, v3/v4, RFC 1833 sec. 2.1).
26const RPCBPROC_DUMP: u32 = 4;
27/// RPCBPROC_CALLIT / RPCBPROC_BCAST (proc 5, v3/v4, RFC 1833 sec. 2.1).
28const RPCBPROC_CALLIT: u32 = 5;
29/// RPCBPROC_GETTIME (proc 6, v3/v4, RFC 1833 sec. 2.1).
30const RPCBPROC_GETTIME: u32 = 6;
31/// RPCBPROC_UADDR2TADDR (proc 7, v3/v4, RFC 1833 sec. 2.1).
32const RPCBPROC_UADDR2TADDR: u32 = 7;
33/// RPCBPROC_TADDR2UADDR (proc 8, v3/v4, RFC 1833 sec. 2.1).
34const RPCBPROC_TADDR2UADDR: u32 = 8;
35/// RPCBPROC_GETVERSADDR (proc 9, v4 only, RFC 1833 sec. 2.2.2).
36const RPCBPROC_GETVERSADDR: u32 = 9;
37/// RPCBPROC_INDIRECT (proc 10, v4 only, RFC 1833 sec. 2.2.2).
38const RPCBPROC_INDIRECT: u32 = 10;
39/// RPCBPROC_GETADDRLIST (proc 11, v4 only, RFC 1833 sec. 2.2.2).
40const RPCBPROC_GETADDRLIST: u32 = 11;
41/// RPCBPROC_GETSTAT (proc 12, v4 only, RFC 1833 sec. 2.2.2).
42const RPCBPROC_GETSTAT: u32 = 12;
43
44/// rpcbind version 3 -- adds GETTIME, TADDR2UADDR, UADDR2TADDR.
45const RPCBIND_V3: u32 = 3;
46/// rpcbind version 4 -- adds GETSTAT and indirect call helpers.
47const RPCBIND_V4: u32 = 4;
48
49/// One rpcbind version's operational statistics from RPCBPROC_GETSTAT
50/// (RFC 1833 sec. 2.2.2).
51///
52/// Each entry covers a single rpcbind version (2, 3, or 4) and carries
53/// per-procedure call counts plus aggregate SET/UNSET totals.
54#[derive(Debug, Clone)]
55pub struct RpcbindStatEntry {
56    /// rpcbind version this entry covers (2, 3, or 4).
57    pub rpcb_version: u32,
58    /// Per-procedure call counts (index = procedure number).
59    /// RFC 1833 sec 2.2.2: `typedef int rpcbs_proc[RPCBSTAT_HIGHPROC]`.
60    pub info: Vec<i32>,
61    /// Total SET calls (RFC 1833: `int setinfo`).
62    pub setinfo: i32,
63    /// Total UNSET calls (RFC 1833: `int unsetinfo`).
64    pub unsetinfo: i32,
65}
66
67/// XDR type for `rpcb_stat_byvers` (RFC 1833 sec. 2.2.2): fixed array of
68/// `RPCBVERS_STAT` (3) `rpcb_stat` elements.  Each element contains
69/// per-procedure call counts, set/unset totals, and linked lists of
70/// per-address and per-rmtcall stats (which we skip).
71#[derive(Debug)]
72pub struct RpcbStatByvers(
73    /// The decoded stat entries, one per rpcbind version.
74    pub Vec<RpcbindStatEntry>,
75);
76
77impl Unpack for RpcbStatByvers {
78    fn unpack(input: &mut impl std::io::Read) -> onc_xdr::Result<(Self, usize)> {
79        /// Number of rpcbind versions reported (v2, v3, v4).
80        const RPCBVERS_STAT: usize = 3;
81        /// Highest procedure number + 1 in the per-version stats array.
82        const RPCBSTAT_HIGHPROC: usize = 13;
83
84        let mut entries = Vec::with_capacity(RPCBVERS_STAT);
85        let mut total_bytes = 0usize;
86
87        for ver_idx in 0..RPCBVERS_STAT {
88            // info[RPCBSTAT_HIGHPROC]: fixed array of 13 signed ints (RFC 1833 sec 2.2.2)
89            let mut info = Vec::with_capacity(RPCBSTAT_HIGHPROC);
90            for _ in 0..RPCBSTAT_HIGHPROC {
91                let (v, n) = i32::unpack(input)?;
92                info.push(v);
93                total_bytes += n;
94            }
95            // setinfo: int (RFC 1833 sec 2.2.2)
96            let (setinfo, n) = i32::unpack(input)?;
97            total_bytes += n;
98            // unsetinfo: int (RFC 1833 sec 2.2.2)
99            let (unsetinfo, n) = i32::unpack(input)?;
100            total_bytes += n;
101            // addrinfo: rpcbs_addrlist* (optional linked list)
102            loop {
103                let (disc, n) = u32::unpack(input)?;
104                total_bytes += n;
105                if disc == 0 {
106                    break;
107                }
108                // rpcbs_addrlist: prog(u32) + vers(u32) + success(i32) + failure(i32) + netid(string)
109                for _ in 0..4 {
110                    let (_, n) = u32::unpack(input)?;
111                    total_bytes += n;
112                }
113                let (netid, n) = onc_xdr::unpack_string(input)?;
114                total_bytes += n;
115                drop(netid);
116            }
117            // rmtinfo: rpcbs_rmtcalllist* (optional linked list)
118            loop {
119                let (disc, n) = u32::unpack(input)?;
120                total_bytes += n;
121                if disc == 0 {
122                    break;
123                }
124                // rpcbs_rmtcalllist: prog(u32) + vers(u32) + proc(u32) + success(i32) + failure(i32) + indirect(i32) + netid(string)
125                for _ in 0..6 {
126                    let (_, n) = u32::unpack(input)?;
127                    total_bytes += n;
128                }
129                let (netid, n) = onc_xdr::unpack_string(input)?;
130                total_bytes += n;
131                drop(netid);
132            }
133
134            entries.push(RpcbindStatEntry { rpcb_version: u32::try_from(ver_idx).unwrap_or(0) + 2, info, setinfo, unsetinfo });
135        }
136
137        Ok((Self(entries), total_bytes))
138    }
139}
140
141// --- Wire types (RFC 1833 sec. 2.1) ---
142
143/// The `rpcb` structure used by GETADDR and other rpcbind v3+ procedures
144/// (RFC 1833 sec. 2.1).
145///
146/// Encodes program, version, network id, universal address, and owner
147/// as five XDR fields.  For GETADDR queries the caller typically leaves
148/// `addr` and `owner` empty.
149#[derive(Debug)]
150#[expect(clippy::struct_field_names, reason = "r_ prefix matches the RFC 1833 XDR field names verbatim")]
151struct Rpcb<'a> {
152    r_prog: u32,
153    r_vers: u32,
154    r_netid: &'a str,
155    r_addr: &'a str,
156    r_owner: &'a str,
157}
158
159impl Pack for Rpcb<'_> {
160    fn packed_size(&self) -> usize {
161        self.r_prog.packed_size() + self.r_vers.packed_size() + onc_xdr::string_packed_size(self.r_netid) + onc_xdr::string_packed_size(self.r_addr) + onc_xdr::string_packed_size(self.r_owner)
162    }
163
164    fn pack(&self, out: &mut impl std::io::Write) -> onc_xdr::Result<usize> {
165        let mut n = self.r_prog.pack(out)?;
166        n += self.r_vers.pack(out)?;
167        n += onc_xdr::pack_string(self.r_netid, out)?;
168        n += onc_xdr::pack_string(self.r_addr, out)?;
169        n += onc_xdr::pack_string(self.r_owner, out)?;
170        Ok(n)
171    }
172}
173
174/// An rpcbind entry from a DUMP response (RFC 1833 sec. 2.1).
175///
176/// Owned version of `Rpcb` with both Pack and Unpack, used in DUMP
177/// result lists and public API.
178#[derive(Debug, Clone)]
179pub struct RpcbEntry {
180    /// RPC program number.
181    pub program: u32,
182    /// RPC version number.
183    pub version: u32,
184    /// Network identifier (e.g., "tcp", "udp", "tcp6").
185    pub netid: String,
186    /// Universal address (e.g., "0.0.0.0.8.1" for port 2049).
187    pub addr: String,
188    /// Owner of the binding.
189    pub owner: String,
190}
191
192impl Pack for RpcbEntry {
193    fn packed_size(&self) -> usize {
194        self.program.packed_size() + self.version.packed_size() + onc_xdr::string_packed_size(&self.netid) + onc_xdr::string_packed_size(&self.addr) + onc_xdr::string_packed_size(&self.owner)
195    }
196
197    fn pack(&self, out: &mut impl std::io::Write) -> onc_xdr::Result<usize> {
198        let mut n = self.program.pack(out)?;
199        n += self.version.pack(out)?;
200        n += onc_xdr::pack_string(&self.netid, out)?;
201        n += onc_xdr::pack_string(&self.addr, out)?;
202        n += onc_xdr::pack_string(&self.owner, out)?;
203        Ok(n)
204    }
205}
206
207impl Unpack for RpcbEntry {
208    fn unpack(input: &mut impl std::io::Read) -> onc_xdr::Result<(Self, usize)> {
209        let mut n = 0;
210        let (program, b) = u32::unpack(input)?;
211        n += b;
212        let (version, b) = u32::unpack(input)?;
213        n += b;
214        let (netid, b) = onc_xdr::unpack_string(input)?;
215        n += b;
216        let (addr, b) = onc_xdr::unpack_string(input)?;
217        n += b;
218        let (owner, b) = onc_xdr::unpack_string(input)?;
219        n += b;
220        Ok((Self { program, version, netid, addr, owner }, n))
221    }
222}
223
224/// Linked list of rpcbind entries from RPCBPROC_DUMP (RFC 1833 sec. 2.1).
225pub type RpcbList = List<RpcbEntry>;
226
227/// Arguments for RPCBPROC_CALLIT / RPCBPROC_BCAST / RPCBPROC_INDIRECT
228/// (RFC 1833 sec. 2.1).
229#[derive(Debug, Clone)]
230pub struct RpcbRmtCallArgs<'a> {
231    /// Target RPC program number.
232    pub program: u32,
233    /// Target RPC version number.
234    pub version: u32,
235    /// Target RPC procedure number.
236    pub proc: u32,
237    /// XDR-encoded arguments for the target procedure.
238    pub args: Opaque<'a>,
239}
240
241impl Pack for RpcbRmtCallArgs<'_> {
242    fn packed_size(&self) -> usize {
243        self.program.packed_size() + self.version.packed_size() + self.proc.packed_size() + self.args.packed_size()
244    }
245
246    fn pack(&self, out: &mut impl std::io::Write) -> onc_xdr::Result<usize> {
247        let mut n = self.program.pack(out)?;
248        n += self.version.pack(out)?;
249        n += self.proc.pack(out)?;
250        n += self.args.pack(out)?;
251        Ok(n)
252    }
253}
254
255impl Unpack for RpcbRmtCallArgs<'static> {
256    fn unpack(input: &mut impl std::io::Read) -> onc_xdr::Result<(Self, usize)> {
257        let mut n = 0;
258        let (program, b) = u32::unpack(input)?;
259        n += b;
260        let (version, b) = u32::unpack(input)?;
261        n += b;
262        let (proc, b) = u32::unpack(input)?;
263        n += b;
264        let (args, b) = Opaque::unpack(input)?;
265        n += b;
266        Ok((Self { program, version, proc, args }, n))
267    }
268}
269
270/// Result of RPCBPROC_CALLIT / RPCBPROC_BCAST / RPCBPROC_INDIRECT
271/// (RFC 1833 sec. 2.1).
272#[derive(Debug, Clone)]
273pub struct RpcbRmtCallRes {
274    /// Universal address of the responding service.
275    pub addr: String,
276    /// XDR-encoded results from the target procedure.
277    pub results: Vec<u8>,
278}
279
280impl Pack for RpcbRmtCallRes {
281    fn packed_size(&self) -> usize {
282        onc_xdr::string_packed_size(&self.addr) + Opaque::borrowed(&self.results).packed_size()
283    }
284
285    fn pack(&self, out: &mut impl std::io::Write) -> onc_xdr::Result<usize> {
286        let mut n = onc_xdr::pack_string(&self.addr, out)?;
287        n += Opaque::borrowed(&self.results).pack(out)?;
288        Ok(n)
289    }
290}
291
292impl Unpack for RpcbRmtCallRes {
293    fn unpack(input: &mut impl std::io::Read) -> onc_xdr::Result<(Self, usize)> {
294        let mut n = 0;
295        let (addr, b) = onc_xdr::unpack_string(input)?;
296        n += b;
297        let (results, b) = Opaque::unpack(input)?;
298        n += b;
299        Ok((Self { addr, results: results.into_owned() }, n))
300    }
301}
302
303/// Transport address buffer (RFC 1833 sec. 2.1).
304///
305/// Used by RPCBPROC_UADDR2TADDR (returns a `Netbuf` for a universal address)
306/// and RPCBPROC_TADDR2UADDR (takes a `Netbuf`, returns a universal address).
307#[derive(Debug, Clone)]
308pub struct Netbuf {
309    /// Maximum buffer size the caller can accept.
310    pub maxlen: u32,
311    /// The transport address bytes.
312    pub buf: Vec<u8>,
313}
314
315impl Pack for Netbuf {
316    fn packed_size(&self) -> usize {
317        self.maxlen.packed_size() + Opaque::borrowed(&self.buf).packed_size()
318    }
319
320    fn pack(&self, out: &mut impl std::io::Write) -> onc_xdr::Result<usize> {
321        let mut n = self.maxlen.pack(out)?;
322        n += Opaque::borrowed(&self.buf).pack(out)?;
323        Ok(n)
324    }
325}
326
327impl Unpack for Netbuf {
328    fn unpack(input: &mut impl std::io::Read) -> onc_xdr::Result<(Self, usize)> {
329        let mut n = 0;
330        let (maxlen, b) = u32::unpack(input)?;
331        n += b;
332        let (buf, b) = Opaque::unpack(input)?;
333        n += b;
334        Ok((Self { maxlen, buf: buf.into_owned() }, n))
335    }
336}
337
338/// One entry from RPCBPROC_GETADDRLIST (rpcbind v4, RFC 1833 sec. 2.2.2).
339#[derive(Debug, Clone)]
340pub struct RpcbAddrEntry {
341    /// Merged universal address.
342    pub maddr: String,
343    /// Network id (e.g., "tcp", "udp").
344    pub nc_netid: String,
345    /// Transport semantics (NC_TPI_CLTS=1, NC_TPI_COTS=2, NC_TPI_COTS_ORD=3, NC_TPI_RAW=4).
346    pub nc_semantics: u32,
347    /// Protocol family (e.g., "inet", "inet6", "loopback").
348    pub nc_protofmly: String,
349    /// Protocol name (e.g., "tcp", "udp").
350    pub nc_proto: String,
351}
352
353impl Pack for RpcbAddrEntry {
354    fn packed_size(&self) -> usize {
355        onc_xdr::string_packed_size(&self.maddr) + onc_xdr::string_packed_size(&self.nc_netid) + self.nc_semantics.packed_size() + onc_xdr::string_packed_size(&self.nc_protofmly) + onc_xdr::string_packed_size(&self.nc_proto)
356    }
357
358    fn pack(&self, out: &mut impl std::io::Write) -> onc_xdr::Result<usize> {
359        let mut n = onc_xdr::pack_string(&self.maddr, out)?;
360        n += onc_xdr::pack_string(&self.nc_netid, out)?;
361        n += self.nc_semantics.pack(out)?;
362        n += onc_xdr::pack_string(&self.nc_protofmly, out)?;
363        n += onc_xdr::pack_string(&self.nc_proto, out)?;
364        Ok(n)
365    }
366}
367
368impl Unpack for RpcbAddrEntry {
369    fn unpack(input: &mut impl std::io::Read) -> onc_xdr::Result<(Self, usize)> {
370        let mut n = 0;
371        let (maddr, b) = onc_xdr::unpack_string(input)?;
372        n += b;
373        let (nc_netid, b) = onc_xdr::unpack_string(input)?;
374        n += b;
375        let (nc_semantics, b) = u32::unpack(input)?;
376        n += b;
377        let (nc_protofmly, b) = onc_xdr::unpack_string(input)?;
378        n += b;
379        let (nc_proto, b) = onc_xdr::unpack_string(input)?;
380        n += b;
381        Ok((Self { maddr, nc_netid, nc_semantics, nc_protofmly, nc_proto }, n))
382    }
383}
384
385/// Linked list of address entries from RPCBPROC_GETADDRLIST
386/// (rpcbind v4, RFC 1833 sec. 2.2.2).
387pub type RpcbAddrList = List<RpcbAddrEntry>;
388
389/// Newtype around `String` for XDR string responses (e.g., universal
390/// addresses from GETADDR).
391#[derive(Debug)]
392struct XdrString(String);
393
394impl Unpack for XdrString {
395    fn unpack(input: &mut impl std::io::Read) -> onc_xdr::Result<(Self, usize)> {
396        let (s, n) = onc_xdr::unpack_string(input)?;
397        Ok((Self(s), n))
398    }
399}
400
401/// Pack-only wrapper for sending a string as RPC call arguments.
402struct XdrPackString<'a>(&'a str);
403
404impl Pack for XdrPackString<'_> {
405    fn packed_size(&self) -> usize {
406        onc_xdr::string_packed_size(self.0)
407    }
408
409    fn pack(&self, out: &mut impl std::io::Write) -> onc_xdr::Result<usize> {
410        onc_xdr::pack_string(self.0, out)
411    }
412}
413
414/// Client for rpcbind v3/v4 procedures (RFC 1833).
415///
416/// Provides `gettime()` (version 3) and `getstat()` (version 4) over
417/// a single TCP connection.  Accepts `AUTH_NONE`, matching the
418/// portmapper convention.
419#[derive(Debug)]
420pub struct RpcbindClient<IO> {
421    rpc: RpcClient<IO>,
422}
423
424impl<IO> RpcbindClient<IO>
425where
426    IO: AsyncRead + AsyncWrite + Send,
427{
428    /// Create a new rpcbind client.
429    ///
430    /// The rpcbind service accepts AUTH_NONE for query procedures, so no
431    /// credential is set up here.
432    pub fn new(io: IO) -> Self {
433        Self { rpc: RpcClient::new(io) }
434    }
435
436    // --- rpcbind v3 procedures (RFC 1833 sec. 2.2.1) ---
437
438    /// RPCBPROC_SET (proc 1, version 3): register a binding.
439    pub async fn set(&mut self, program: u32, version: u32, netid: &str, addr: &str, owner: &str) -> Result<bool, RpcError> {
440        let args = Rpcb { r_prog: program, r_vers: version, r_netid: netid, r_addr: addr, r_owner: owner };
441        self.rpc.call(PROGRAM, RPCBIND_V3, RPCBPROC_SET, &args).await
442    }
443
444    /// RPCBPROC_UNSET (proc 2, version 3): unregister a binding.
445    pub async fn unset(&mut self, program: u32, version: u32, netid: &str, addr: &str, owner: &str) -> Result<bool, RpcError> {
446        let args = Rpcb { r_prog: program, r_vers: version, r_netid: netid, r_addr: addr, r_owner: owner };
447        self.rpc.call(PROGRAM, RPCBIND_V3, RPCBPROC_UNSET, &args).await
448    }
449
450    /// RPCBPROC_GETADDR (proc 3, version 3): looks up the universal
451    /// address for a given program, version, and network id.
452    pub async fn getaddr(&mut self, program: u32, version: u32, netid: &str) -> Result<String, RpcError> {
453        let args = Rpcb { r_prog: program, r_vers: version, r_netid: netid, r_addr: "", r_owner: "" };
454        let result: XdrString = self.rpc.call(PROGRAM, RPCBIND_V3, RPCBPROC_GETADDR, &args).await?;
455        Ok(result.0)
456    }
457
458    /// RPCBPROC_DUMP (proc 4, version 3): list all registered bindings.
459    pub async fn dump(&mut self) -> Result<Vec<RpcbEntry>, RpcError> {
460        let list: RpcbList = self.rpc.call(PROGRAM, RPCBIND_V3, RPCBPROC_DUMP, &Void).await?;
461        Ok(list.into_inner())
462    }
463
464    /// RPCBPROC_CALLIT (proc 5, version 3): indirect call through rpcbind.
465    pub async fn callit(&mut self, program: u32, version: u32, proc: u32, args: &[u8]) -> Result<RpcbRmtCallRes, RpcError> {
466        let rmt_args = RpcbRmtCallArgs { program, version, proc, args: Opaque::borrowed(args) };
467        self.rpc.call(PROGRAM, RPCBIND_V3, RPCBPROC_CALLIT, &rmt_args).await
468    }
469
470    /// RPCBPROC_GETTIME (proc 6, version 3): returns the server's local
471    /// time as seconds since the Unix epoch.
472    pub async fn gettime(&mut self) -> Result<u32, RpcError> {
473        self.rpc.call(PROGRAM, RPCBIND_V3, RPCBPROC_GETTIME, &Void).await
474    }
475
476    /// RPCBPROC_UADDR2TADDR (proc 7, version 3): convert a universal
477    /// address to a transport-specific address.
478    pub async fn uaddr2taddr(&mut self, uaddr: &str) -> Result<Netbuf, RpcError> {
479        let args = XdrPackString(uaddr);
480        self.rpc.call(PROGRAM, RPCBIND_V3, RPCBPROC_UADDR2TADDR, &args).await
481    }
482
483    /// RPCBPROC_TADDR2UADDR (proc 8, version 3): convert a transport-specific
484    /// address to a universal address.
485    pub async fn taddr2uaddr(&mut self, taddr: &Netbuf) -> Result<String, RpcError> {
486        let result: XdrString = self.rpc.call(PROGRAM, RPCBIND_V3, RPCBPROC_TADDR2UADDR, taddr).await?;
487        Ok(result.0)
488    }
489
490    // --- rpcbind v4 procedures (RFC 1833 sec. 2.2.2) ---
491
492    /// RPCBPROC_BCAST (proc 5, version 4): broadcast call through rpcbind.
493    ///
494    /// Same wire format as CALLIT but sent via v4; the server broadcasts
495    /// the call and returns the first response.
496    pub async fn bcast(&mut self, program: u32, version: u32, proc: u32, args: &[u8]) -> Result<RpcbRmtCallRes, RpcError> {
497        let rmt_args = RpcbRmtCallArgs { program, version, proc, args: Opaque::borrowed(args) };
498        self.rpc.call(PROGRAM, RPCBIND_V4, RPCBPROC_CALLIT, &rmt_args).await
499    }
500
501    /// RPCBPROC_GETVERSADDR (proc 9, version 4): like GETADDR but
502    /// respects `r_vers` strictly (RFC 1833 sec. 2.2.2).
503    pub async fn getversaddr(&mut self, program: u32, version: u32, netid: &str) -> Result<String, RpcError> {
504        let args = Rpcb { r_prog: program, r_vers: version, r_netid: netid, r_addr: "", r_owner: "" };
505        let result: XdrString = self.rpc.call(PROGRAM, RPCBIND_V4, RPCBPROC_GETVERSADDR, &args).await?;
506        Ok(result.0)
507    }
508
509    /// RPCBPROC_INDIRECT (proc 10, version 4): indirect RPC call with
510    /// error reporting (RFC 1833 sec. 2.2.2).
511    pub async fn indirect(&mut self, program: u32, version: u32, proc: u32, args: &[u8]) -> Result<RpcbRmtCallRes, RpcError> {
512        let rmt_args = RpcbRmtCallArgs { program, version, proc, args: Opaque::borrowed(args) };
513        self.rpc.call(PROGRAM, RPCBIND_V4, RPCBPROC_INDIRECT, &rmt_args).await
514    }
515
516    /// RPCBPROC_GETADDRLIST (proc 11, version 4): list all addresses
517    /// for a service across transports (RFC 1833 sec. 2.2.2).
518    pub async fn getaddrlist(&mut self, program: u32, version: u32, netid: &str) -> Result<Vec<RpcbAddrEntry>, RpcError> {
519        let args = Rpcb { r_prog: program, r_vers: version, r_netid: netid, r_addr: "", r_owner: "" };
520        let list: RpcbAddrList = self.rpc.call(PROGRAM, RPCBIND_V4, RPCBPROC_GETADDRLIST, &args).await?;
521        Ok(list.into_inner())
522    }
523
524    /// RPCBPROC_GETSTAT (proc 12, version 4): returns operational
525    /// statistics per rpcbind version.
526    pub async fn getstat(&mut self) -> Result<RpcbStatByvers, RpcError> {
527        self.rpc.call(PROGRAM, RPCBIND_V4, RPCBPROC_GETSTAT, &Void).await
528    }
529}