afsconfig-and-rcsid-all-around-20010705
[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 #else
13 #include <afs/param.h>
14 #endif
15 #include <afsconfig.h>
16
17 RCSID("$Header$");
18
19 #ifdef UKERNEL
20 #include "../afs/sysincludes.h"
21 #include "../afs/afsincludes.h"
22 #include "rxstat.h"
23 #else /* UKERNEL */
24 #include <afs/stds.h>
25 #include <rx/rx.h>
26 #include "rxstat.h"
27 #ifdef KERNEL
28 #include "../sys/errno.h"
29 #else /* KERNEL */
30 #include <errno.h>
31 #endif /* KERNEL */
32 #endif /* UKERNEL */
33
34 /*
35  * This file creates a centralized mechanism for implementing the rpc
36  * stat code - which is generic across all servers.
37  */
38
39 afs_int32 MRXSTATS_RetrieveProcessRPCStats(
40   struct rx_call *call,
41   IN afs_uint32 clientVersion,
42   OUT afs_uint32 *serverVersion,
43   OUT afs_uint32 *clock_sec,
44   OUT afs_uint32 *clock_usec,
45   OUT afs_uint32 *stat_count,
46   OUT rpcStats *stats)
47
48     afs_int32 rc;
49     size_t allocSize;
50
51     rc = rx_RetrieveProcessRPCStats(clientVersion,
52                                     serverVersion,
53                                     clock_sec,
54                                     clock_usec,
55                                     &allocSize,
56                                     stat_count,
57                                     &stats->rpcStats_val);
58     stats->rpcStats_len = allocSize/sizeof(afs_uint32);
59     return rc;
60 }   
61
62
63 afs_int32 MRXSTATS_RetrievePeerRPCStats(
64   struct rx_call *call,
65   IN afs_uint32 clientVersion,
66   OUT afs_uint32 *serverVersion,
67   OUT afs_uint32 *clock_sec,
68   OUT afs_uint32 *clock_usec,
69   OUT afs_uint32 *stat_count,
70   OUT rpcStats *stats)
71
72     afs_int32 rc;
73     size_t allocSize;
74
75     rc = rx_RetrievePeerRPCStats(clientVersion,
76                                     serverVersion,
77                                     clock_sec,
78                                     clock_usec,
79                                     &allocSize,
80                                     stat_count,
81                                     &stats->rpcStats_val);
82     stats->rpcStats_len = allocSize/sizeof(afs_uint32);
83     return rc;
84 }   
85
86
87 afs_int32 MRXSTATS_QueryProcessRPCStats(
88   struct rx_call *call,
89   OUT afs_int32 *on)
90
91     afs_int32 rc = 0;
92     *on = rx_queryProcessRPCStats();
93     return rc;
94 }   
95
96
97 afs_int32 MRXSTATS_QueryPeerRPCStats(
98   struct rx_call *call,
99   OUT afs_int32 *on)
100
101     afs_int32 rc = 0;
102     *on = rx_queryPeerRPCStats();
103     return rc;
104 }   
105
106
107 afs_int32 MRXSTATS_EnableProcessRPCStats(
108   struct rx_call *call)
109
110     afs_int32 rc = 0;
111     if (!rx_RxStatUserOk(call)) {
112         rc = EPERM;
113     } else {
114         rx_enableProcessRPCStats();
115     }
116     return rc;
117 }   
118
119 afs_int32 MRXSTATS_EnablePeerRPCStats(
120   struct rx_call *call)
121
122     afs_int32 rc = 0;
123     if (!rx_RxStatUserOk(call)) {
124         rc = EPERM;
125     } else {
126         rx_enablePeerRPCStats();
127     }
128     return rc;
129 }   
130
131
132 afs_int32 MRXSTATS_DisableProcessRPCStats(
133   struct rx_call *call)
134
135     afs_int32 rc = 0;
136     if (!rx_RxStatUserOk(call)) {
137         rc = EPERM;
138     } else {
139         rx_disableProcessRPCStats();
140     }
141     return rc;
142 }   
143
144 afs_int32 MRXSTATS_DisablePeerRPCStats(
145   struct rx_call *call)
146
147     afs_int32 rc = 0;
148     if (!rx_RxStatUserOk(call)) {
149         rc = EPERM;
150     } else {
151     rx_disablePeerRPCStats();
152     }
153     return rc;
154 }   
155
156 afs_int32 MRXSTATS_QueryRPCStatsVersion(
157   struct rx_call *call,
158   OUT afs_uint32 *ver)
159 {
160     afs_int32 rc = 0;
161     *ver = RX_STATS_RETRIEVAL_VERSION;
162     return rc;
163 }
164
165 afs_int32 MRXSTATS_ClearProcessRPCStats(
166   struct rx_call *call,
167   IN afs_uint32 clearFlag)
168 {
169     afs_int32 rc = 0;
170     if (!rx_RxStatUserOk(call)) {
171         rc = EPERM;
172     } else {
173         rx_clearProcessRPCStats(clearFlag);
174     }
175     return rc;
176 }
177
178 afs_int32 MRXSTATS_ClearPeerRPCStats(
179   struct rx_call *call,
180   IN afs_uint32 clearFlag)
181 {
182     afs_int32 rc = 0;
183     if (!rx_RxStatUserOk(call)) {
184         rc = EPERM;
185     } else {
186         rx_clearPeerRPCStats(clearFlag);
187     }
188     return rc;
189 }