Standardize License information
[openafs.git] / src / rxstat / rxstat.c
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 #ifdef UKERNEL
11 #include "../afs/param.h"
12 #include "../afs/sysincludes.h"
13 #include "../afs/afsincludes.h"
14 #include "rxstat.h"
15 #else /* UKERNEL */
16 #include <afs/stds.h>
17 #include <rx/rx.h>
18 #include "rxstat.h"
19 #ifdef KERNEL
20 #include "../sys/errno.h"
21 #else /* KERNEL */
22 #include <errno.h>
23 #endif /* KERNEL */
24 #endif /* UKERNEL */
25
26 /*
27  * This file creates a centralized mechanism for implementing the rpc
28  * stat code - which is generic across all servers.
29  */
30
31 afs_int32 MRXSTATS_RetrieveProcessRPCStats(
32   struct rx_call *call,
33   IN afs_uint32 clientVersion,
34   OUT afs_uint32 *serverVersion,
35   OUT afs_uint32 *clock_sec,
36   OUT afs_uint32 *clock_usec,
37   OUT afs_uint32 *stat_count,
38   OUT rpcStats *stats)
39
40     afs_int32 rc;
41     size_t allocSize;
42
43     rc = rx_RetrieveProcessRPCStats(clientVersion,
44                                     serverVersion,
45                                     clock_sec,
46                                     clock_usec,
47                                     &allocSize,
48                                     stat_count,
49                                     &stats->rpcStats_val);
50     stats->rpcStats_len = allocSize/sizeof(afs_uint32);
51     return rc;
52 }   
53
54
55 afs_int32 MRXSTATS_RetrievePeerRPCStats(
56   struct rx_call *call,
57   IN afs_uint32 clientVersion,
58   OUT afs_uint32 *serverVersion,
59   OUT afs_uint32 *clock_sec,
60   OUT afs_uint32 *clock_usec,
61   OUT afs_uint32 *stat_count,
62   OUT rpcStats *stats)
63
64     afs_int32 rc;
65     size_t allocSize;
66
67     rc = rx_RetrievePeerRPCStats(clientVersion,
68                                     serverVersion,
69                                     clock_sec,
70                                     clock_usec,
71                                     &allocSize,
72                                     stat_count,
73                                     &stats->rpcStats_val);
74     stats->rpcStats_len = allocSize/sizeof(afs_uint32);
75     return rc;
76 }   
77
78
79 afs_int32 MRXSTATS_QueryProcessRPCStats(
80   struct rx_call *call,
81   OUT afs_int32 *on)
82
83     afs_int32 rc = 0;
84     *on = rx_queryProcessRPCStats();
85     return rc;
86 }   
87
88
89 afs_int32 MRXSTATS_QueryPeerRPCStats(
90   struct rx_call *call,
91   OUT afs_int32 *on)
92
93     afs_int32 rc = 0;
94     *on = rx_queryPeerRPCStats();
95     return rc;
96 }   
97
98
99 afs_int32 MRXSTATS_EnableProcessRPCStats(
100   struct rx_call *call)
101
102     afs_int32 rc = 0;
103     if (!rx_RxStatUserOk(call)) {
104         rc = EPERM;
105     } else {
106         rx_enableProcessRPCStats();
107     }
108     return rc;
109 }   
110
111 afs_int32 MRXSTATS_EnablePeerRPCStats(
112   struct rx_call *call)
113
114     afs_int32 rc = 0;
115     if (!rx_RxStatUserOk(call)) {
116         rc = EPERM;
117     } else {
118         rx_enablePeerRPCStats();
119     }
120     return rc;
121 }   
122
123
124 afs_int32 MRXSTATS_DisableProcessRPCStats(
125   struct rx_call *call)
126
127     afs_int32 rc = 0;
128     if (!rx_RxStatUserOk(call)) {
129         rc = EPERM;
130     } else {
131         rx_disableProcessRPCStats();
132     }
133     return rc;
134 }   
135
136 afs_int32 MRXSTATS_DisablePeerRPCStats(
137   struct rx_call *call)
138
139     afs_int32 rc = 0;
140     if (!rx_RxStatUserOk(call)) {
141         rc = EPERM;
142     } else {
143     rx_disablePeerRPCStats();
144     }
145     return rc;
146 }   
147
148 afs_int32 MRXSTATS_QueryRPCStatsVersion(
149   struct rx_call *call,
150   OUT afs_uint32 *ver)
151 {
152     afs_int32 rc = 0;
153     *ver = RX_STATS_RETRIEVAL_VERSION;
154     return rc;
155 }
156
157 afs_int32 MRXSTATS_ClearProcessRPCStats(
158   struct rx_call *call,
159   IN afs_uint32 clearFlag)
160 {
161     afs_int32 rc = 0;
162     if (!rx_RxStatUserOk(call)) {
163         rc = EPERM;
164     } else {
165         rx_clearProcessRPCStats(clearFlag);
166     }
167     return rc;
168 }
169
170 afs_int32 MRXSTATS_ClearPeerRPCStats(
171   struct rx_call *call,
172   IN afs_uint32 clearFlag)
173 {
174     afs_int32 rc = 0;
175     if (!rx_RxStatUserOk(call)) {
176         rc = EPERM;
177     } else {
178         rx_clearPeerRPCStats(clearFlag);
179     }
180     return rc;
181 }