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