2 * $NetBSD: rpcb_stat.c,v 1.2 2000/07/04 20:27:40 matt Exp $
5 * SPDX-License-Identifier: BSD-3-Clause
7 * Copyright (c) 2009, Sun Microsystems, Inc.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are met:
12 * - Redistributions of source code must retain the above copyright notice,
13 * this list of conditions and the following disclaimer.
14 * - Redistributions in binary form must reproduce the above copyright notice,
15 * this list of conditions and the following disclaimer in the documentation
16 * and/or other materials provided with the distribution.
17 * - Neither the name of Sun Microsystems, Inc. nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
35 * Allows for gathering of statistics
37 * Copyright (c) 1990 by Sun Microsystems, Inc.
40 #include <netconfig.h>
42 #include <rpc/rpcb_prot.h>
45 #include <rpc/pmap_prot.h>
51 static rpcb_stat_byvers inf;
60 rpcbs_procinfo(rpcvers_t rtype, rpcproc_t proc)
64 case PMAPVERS: /* version 2 */
65 if (proc > rpcb_highproc_2)
69 case RPCBVERS: /* version 3 */
70 if (proc > rpcb_highproc_3)
73 case RPCBVERS4: /* version 4 */
74 if (proc > rpcb_highproc_4)
79 inf[rtype].info[proc]++;
83 rpcbs_set(rpcvers_t rtype, bool_t success)
85 if ((rtype >= RPCBVERS_STAT) || (success == FALSE))
91 rpcbs_unset(rpcvers_t rtype, bool_t success)
93 if ((rtype >= RPCBVERS_STAT) || (success == FALSE))
95 inf[rtype].unsetinfo++;
99 rpcbs_getaddr(rpcvers_t rtype, rpcprog_t prog, rpcvers_t vers, char *netid,
103 struct netconfig *nconf;
105 if (rtype >= RPCBVERS_STAT)
107 for (al = inf[rtype].addrinfo; al; al = al->next) {
109 if(al->netid == NULL)
111 if ((al->prog == prog) && (al->vers == vers) &&
112 (strcmp(al->netid, netid) == 0)) {
113 if ((uaddr == NULL) || (uaddr[0] == 0))
120 nconf = rpcbind_get_conf(netid);
124 al = (rpcbs_addrlist *) malloc(sizeof (rpcbs_addrlist));
130 al->netid = nconf->nc_netid;
131 if ((uaddr == NULL) || (uaddr[0] == 0)) {
138 al->next = inf[rtype].addrinfo;
139 inf[rtype].addrinfo = al;
143 rpcbs_rmtcall(rpcvers_t rtype, rpcproc_t rpcbproc, rpcprog_t prog,
144 rpcvers_t vers, rpcproc_t proc, char *netid, rpcblist_ptr rbl)
146 rpcbs_rmtcalllist *rl;
147 struct netconfig *nconf;
149 if (rtype >= RPCBVERS_STAT)
151 for (rl = inf[rtype].rmtinfo; rl; rl = rl->next) {
153 if(rl->netid == NULL)
156 if ((rl->prog == prog) && (rl->vers == vers) &&
157 (rl->proc == proc) &&
158 (strcmp(rl->netid, netid) == 0)) {
160 (rbl->rpcb_map.r_vers != vers))
164 if (rpcbproc == RPCBPROC_INDIRECT)
169 nconf = rpcbind_get_conf(netid);
173 rl = (rpcbs_rmtcalllist *) malloc(sizeof (rpcbs_rmtcalllist));
180 rl->netid = nconf->nc_netid;
182 (rbl->rpcb_map.r_vers != vers)) {
190 rl->next = inf[rtype].rmtinfo;
191 inf[rtype].rmtinfo = rl;
195 rpcbproc_getstat(void *arg __unused, struct svc_req *req __unused,
196 SVCXPRT *xprt __unused, rpcvers_t versnum __unused)