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