1 /* $NetBSD: rpcb_stat.c,v 1.1 2010/07/26 15:53:00 pooka Exp $ */
4 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
5 * unrestricted use provided that this legend is included on all tape
6 * media and as a part of the software program in whole or part. Users
7 * may copy or modify Sun RPC without charge, but are not authorized
8 * to license or distribute it to anyone else except as part of a product or
9 * program developed by the user.
11 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
12 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
13 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
15 * Sun RPC is provided with no support and without any obligation on the
16 * part of Sun Microsystems, Inc. to assist in its use, correction,
17 * modification or enhancement.
19 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
20 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
21 * OR ANY PART THEREOF.
23 * In no event will Sun Microsystems, Inc. be liable for any lost revenue
24 * or profits or other special, indirect and consequential damages, even if
25 * Sun has been advised of the possibility of such damages.
27 * Sun Microsystems, Inc.
29 * Mountain View, California 94043
31 /* #pragma ident "@(#)rpcb_stat.c 1.7 94/04/25 SMI" */
35 * Allows for gathering of statistics
37 * Copyright (c) 1990 by Sun Microsystems, Inc.
41 #include <netconfig.h>
43 #include <rpc/rpcb_prot.h>
46 #include <rpc/pmap_prot.h>
52 static rpcb_stat_byvers inf;
61 rpcbs_procinfo(rpcvers_t rtype, rpcproc_t proc)
65 case PMAPVERS: /* version 2 */
66 if (proc > rpcb_highproc_2)
70 case RPCBVERS: /* version 3 */
71 if (proc > rpcb_highproc_3)
74 case RPCBVERS4: /* version 4 */
75 if (proc > rpcb_highproc_4)
80 inf[rtype].info[proc]++;
85 rpcbs_set(rpcvers_t rtype, bool_t success)
87 if ((rtype >= RPCBVERS_STAT) || (success == FALSE))
94 rpcbs_unset(rpcvers_t rtype, bool_t success)
96 if ((rtype >= RPCBVERS_STAT) || (success == FALSE))
98 inf[rtype].unsetinfo++;
103 rpcbs_getaddr(rpcvers_t rtype, rpcprog_t prog, rpcvers_t vers,
104 const char *netid, const char *uaddr)
107 struct netconfig *nconf;
109 if (rtype >= RPCBVERS_STAT)
111 for (al = inf[rtype].addrinfo; al; al = al->next) {
113 if(al->netid == NULL)
115 if ((al->prog == prog) && (al->vers == vers) &&
116 (strcmp(al->netid, netid) == 0)) {
117 if ((uaddr == NULL) || (uaddr[0] == 0))
124 nconf = rpcbind_get_conf(netid);
128 al = (rpcbs_addrlist *) malloc(sizeof (rpcbs_addrlist));
134 al->netid = nconf->nc_netid;
135 if ((uaddr == NULL) || (uaddr[0] == 0)) {
142 al->next = inf[rtype].addrinfo;
143 inf[rtype].addrinfo = al;
147 rpcbs_rmtcall(rpcvers_t rtype, rpcproc_t rpcbproc, rpcprog_t prog,
148 rpcvers_t vers, rpcproc_t proc, char *netid, rpcblist_ptr rbl)
150 rpcbs_rmtcalllist *rl;
151 struct netconfig *nconf;
153 if (rtype >= RPCBVERS_STAT)
155 for (rl = inf[rtype].rmtinfo; rl; rl = rl->next) {
157 if(rl->netid == NULL)
160 if ((rl->prog == prog) && (rl->vers == vers) &&
161 (rl->proc == proc) &&
162 (strcmp(rl->netid, netid) == 0)) {
164 (rbl->rpcb_map.r_vers != vers))
168 if (rpcbproc == RPCBPROC_INDIRECT)
173 nconf = rpcbind_get_conf(netid);
177 rl = (rpcbs_rmtcalllist *) malloc(sizeof (rpcbs_rmtcalllist));
184 rl->netid = nconf->nc_netid;
186 (rbl->rpcb_map.r_vers != vers)) {
194 rl->next = inf[rtype].rmtinfo;
195 inf[rtype].rmtinfo = rl;
202 rpcbproc_getstat(void *arg, struct svc_req *req, SVCXPRT *xprt,