2 * Copyright (c) 2009, Sun Microsystems, Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * - Redistributions of source code must retain the above copyright notice,
8 * this list of conditions and the following disclaimer.
9 * - Redistributions in binary form must reproduce the above copyright notice,
10 * this list of conditions and the following disclaimer in the documentation
11 * and/or other materials provided with the distribution.
12 * - Neither the name of Sun Microsystems, Inc. nor the names of its
13 * contributors may be used to endorse or promote products derived
14 * from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
28 * @(#)rpcb_stat.c 1.7 94/04/25 SMI
29 * $NetBSD: rpcb_stat.c,v 1.2 2000/07/04 20:27:40 matt Exp $
30 * $FreeBSD: src/usr.sbin/rpcbind/rpcb_stat.c,v 1.4 2003/10/29 09:29:23 mbr Exp $
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
, char *netid
,
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
;
200 rpcbproc_getstat(void *arg __unused
, struct svc_req
*req __unused
,
201 SVCXPRT
*xprt __unused
, rpcvers_t versnum __unused
)