OpenBSD: Complete implementation of afs_osi_TimedSleep
[openafs.git] / tests / rpctestlib / rpc_test_cb_procs.c
1 /*
2  * Copyright (c) 2010, Linux Box Corporation.
3  * All Rights Reserved.
4  *
5  * Portions Copyright (c) 2007, Hartmut Reuter,
6  * RZG, Max-Planck-Institut f. Plasmaphysik.
7  * All Rights Reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions are met:
11  *
12  *   1. Redistributions of source code must retain the above copyright
13  *      notice, this list of conditions and the following disclaimer.
14  *   2. Redistributions in binary form must reproduce the above copyright
15  *      notice, this list of conditions and the following disclaimer in
16  *      the documentation and/or other materials provided with the
17  *      distribution.
18  *
19  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
20  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
21  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30
31 #include <afsconfig.h>
32 #include <afs/param.h>
33
34 #include <roken.h>
35
36 #include <afs/stds.h>
37
38 #include "rpc_test_procs.h"
39
40 #include <stdio.h>
41 #include <sys/types.h>
42 #include <string.h>
43 #include <sys/stat.h>
44 #include <errno.h>
45 #include <signal.h>
46 #include <afs/vice.h>
47 #include <afs/cmd.h>
48 #include <afs/auth.h>
49 #include <afs/cellconfig.h>
50
51 #include <afs/com_err.h>
52 #ifdef HAVE_DIRENT_H
53 #include <dirent.h>
54 #endif
55 #ifdef HAVE_DIRECT_H
56 #include <direct.h>
57 #endif
58 #ifdef AFS_DARWIN_ENV
59 #include <sys/malloc.h>
60 #else
61 #include <malloc.h>
62 #endif
63 #include <afs/errors.h>
64 #include <afs/sys_prototypes.h>
65 #include <rx/rx_prototypes.h>
66 #ifdef AFS_PTHREAD_ENV
67 #include <assert.h>
68 #endif
69
70 extern const char *prog;
71 extern pthread_key_t ctx_key;
72
73 #if defined(AFS_EXTENDED_CALLBACK)
74 #define RPC_TEST_EXTENDED_CALLBACK  1
75
76 afs_int32 SRXAFSCB_ExtendedCallBack(
77     /*IN */ struct rx_call *a_call,
78     /*IN */ HostIdentifier * Server,
79     /*IN */ AFSXCBInvocationSeq * Invocations_Array,
80     /*OUT*/ AFSExtendedCallBackRSeq * CallBack_Result_Array)
81 {
82     rpc_test_request_ctx *ctx;
83
84     ctx = CTX_FOR_RXCALL(a_call);
85
86     printf("%s: SRXAFSCB_ExtendedCallBack: enter (%s)\n", prog,
87         ctx->cb_svc_name);
88
89     return (0);
90 };
91 #endif /* AFS_EXTENDED_CALLBACK */
92
93 #if defined(AFS_BYTE_RANGE_FLOCKS)
94 afs_int32 SRXAFSCB_AsyncIssueByteRangeLock(
95         /*IN */ struct rx_call *a_call,
96         /*IN */ HostIdentifier * Server,
97         /*IN */ AFSByteRangeLockSeq Locks_Array)
98 {
99     rpc_test_request_ctx *ctx = CTX_FOR_RXCALL(a_call);
100
101     printf("%s: SRXAFSCB_AsyncIssueByteRangeLock: enter (%s)\n", prog,
102         ctx->cb_svc_name);
103
104     return (0);
105 }
106 #endif /* AFS_BYTE_RANGE_FLOCKS */
107
108 afs_int32
109 SRXAFSCB_CallBack(struct rx_call *a_call, AFSCBFids *Fids_Array,
110                   AFSCBs *CallBack_Array)
111 {
112     rpc_test_request_ctx *ctx = CTX_FOR_RXCALL(a_call);
113
114     printf("%s: SRXAFSCB_CallBack: enter (%s)\n", prog,
115         ctx->cb_svc_name);
116
117     return (0);
118 }
119
120
121 afs_int32
122 SRXAFSCB_InitCallBackState(struct rx_call *a_call)
123 {
124     return (0);
125 }
126
127
128 afs_int32
129 SRXAFSCB_Probe(struct rx_call *a_call)
130 {
131     return (0);
132 }
133
134
135 afs_int32
136 SRXAFSCB_GetCE(struct rx_call *a_call,
137                afs_int32 index,
138                AFSDBCacheEntry * ce)
139 {
140     return(0);
141 }
142
143
144 afs_int32
145 SRXAFSCB_GetLock(struct rx_call *a_call,
146                  afs_int32 index,
147                  AFSDBLock * lock)
148 {
149     return(0);
150 }
151
152
153 afs_int32
154 SRXAFSCB_XStatsVersion(struct rx_call *a_call,
155                        afs_int32 * versionNumberP)
156 {
157     return(0);
158 }
159
160
161 afs_int32
162 SRXAFSCB_GetXStats(struct rx_call *a_call,
163                    afs_int32 clientVersionNumber,
164                    afs_int32 collectionNumber,
165                    afs_int32 * srvVersionNumberP,
166                    afs_int32 * timeP,
167                    AFSCB_CollData * dataP)
168 {
169     return(0);
170 }
171
172 afs_int32
173 SRXAFSCB_ProbeUuid(struct rx_call *a_call, afsUUID *a_uuid)
174 {
175     rpc_test_request_ctx *ctx = CTX_FOR_RXCALL(a_call);
176     if ( !afs_uuid_equal(&ctx->cb_listen_addr.uuid, a_uuid) )
177         return (1);
178     else
179         return (0);
180 }
181
182
183 afs_int32
184 SRXAFSCB_WhoAreYou(struct rx_call *a_call, struct interfaceAddr *addr)
185 {
186     return SRXAFSCB_TellMeAboutYourself(a_call, addr, NULL);
187 }
188
189
190 afs_int32
191 SRXAFSCB_InitCallBackState2(struct rx_call *a_call, struct interfaceAddr *
192                             addr)
193 {
194     return RXGEN_OPCODE;
195 }
196
197
198 afs_int32
199 SRXAFSCB_InitCallBackState3(struct rx_call *a_call, afsUUID *a_uuid)
200 {
201     return (0);
202 }
203
204
205 afs_int32
206 SRXAFSCB_GetCacheConfig(struct rx_call *a_call, afs_uint32 callerVersion,
207                         afs_uint32 *serverVersion, afs_uint32 *configCount,
208                         cacheConfig *config)
209 {
210     return RXGEN_OPCODE;
211 }
212
213 afs_int32
214 SRXAFSCB_GetLocalCell(struct rx_call *a_call, char **a_name)
215 {
216     return RXGEN_OPCODE;
217 }
218
219
220 afs_int32
221 SRXAFSCB_GetCellServDB(struct rx_call *a_call, afs_int32 a_index,
222                        char **a_name, serverList *a_hosts)
223 {
224     return RXGEN_OPCODE;
225 }
226
227
228 afs_int32
229 SRXAFSCB_GetServerPrefs(struct rx_call *a_call, afs_int32 a_index,
230                         afs_int32 *a_srvr_addr, afs_int32 *a_srvr_rank)
231 {
232     return RXGEN_OPCODE;
233 }
234
235
236 afs_int32
237 SRXAFSCB_TellMeAboutYourself(struct rx_call *a_call, struct interfaceAddr *
238                              addr, Capabilities *capabilities)
239 {
240     afs_int32 code;
241     rpc_test_request_ctx *ctx = CTX_FOR_RXCALL(a_call);
242
243     printf("%s: SRXAFSCB_TellMeAboutYourself: enter (%s)\n", prog,
244         ctx->cb_svc_name);
245
246     addr->numberOfInterfaces = ctx->cb_listen_addr.numberOfInterfaces;
247     addr->uuid = ctx->cb_listen_addr.uuid;
248
249     if (capabilities) {
250         afs_uint32 *dataBuffP;
251         afs_int32 dataBytes;
252
253         dataBytes = 1 * sizeof(afs_uint32);
254         dataBuffP = (afs_uint32 *) xdr_alloc(dataBytes);
255         dataBuffP[0] = CLIENT_CAPABILITY_ERRORTRANS;
256 #if defined(AFS_EXTENDED_CALLBACK)
257         if (ctx->flags & RPC_TEST_REQ_CTX_FLAG_XCB)
258             dataBuffP[0] |= CLIENT_CAPABILITY_EXT_CALLBACK;
259 #endif /* AFS_EXTENDED_CALLBACK */
260         capabilities->Capabilities_len = dataBytes / sizeof(afs_uint32);
261         capabilities->Capabilities_val = dataBuffP;
262     }
263
264     return (0);
265
266 }        /* SRXAFSCB_TellMeAboutYourself */
267
268
269 afs_int32
270 SRXAFSCB_GetCellByNum(struct rx_call *a_call, afs_int32 a_cellnum,
271                       char **a_name, serverList *a_hosts)
272 {
273     return RXGEN_OPCODE;
274 }
275
276
277 afs_int32
278 SRXAFSCB_GetCE64(struct rx_call *a_call, afs_int32 a_index,
279                  struct AFSDBCacheEntry64 *a_result)
280 {
281     return RXGEN_OPCODE;
282 }