An RPC test dispatch library for vice
[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 #include <afs/stds.h>
34
35 #include "rpc_test_procs.h"
36
37 #include <stdio.h>
38 #include <sys/types.h>
39 #include <string.h>
40 #include <sys/stat.h>
41 #include <errno.h>
42 #include <signal.h>
43 #include <afs/vice.h>
44 #include <afs/cmd.h>
45 #include <afs/auth.h>
46 #include <afs/cellconfig.h>
47
48 #include <afs/com_err.h>
49 #ifdef HAVE_DIRENT_H
50 #include <dirent.h>
51 #endif
52 #ifdef HAVE_DIRECT_H
53 #include <direct.h>
54 #endif
55 #ifdef AFS_DARWIN_ENV
56 #include <sys/malloc.h>
57 #else
58 #include <malloc.h>
59 #endif
60 #include <afs/errors.h>
61 #include <afs/sys_prototypes.h>
62 #include <rx_prototypes.h>
63 #ifdef AFS_PTHREAD_ENV
64 #include <assert.h>
65 #endif
66
67 extern const char *prog;
68 extern pthread_key_t ctx_key;
69
70 #if defined(AFS_EXTENDED_CALLBACK)
71 #define RPC_TEST_EXTENDED_CALLBACK  1
72
73 afs_int32 SRXAFSCB_ExtendedCallBack(
74     /*IN */ struct rx_call *a_call,
75     /*IN */ HostIdentifier * Server,
76     /*IN */ AFSXCBInvocationSeq * Invocations_Array,
77     /*OUT*/ AFSExtendedCallBackRSeq * CallBack_Result_Array)
78 {
79     rpc_test_request_ctx *ctx;
80
81     ctx = CTX_FOR_RXCALL(a_call);
82
83     printf("%s: SRXAFSCB_ExtendedCallBack: enter (%s)\n", prog,
84         ctx->cb_svc_name);
85
86     return (0);
87 };
88 #endif /* AFS_EXTENDED_CALLBACK */
89
90 #if defined(AFS_BYTE_RANGE_FLOCKS)
91 afs_int32 SRXAFSCB_AsyncIssueByteRangeLock(
92         /*IN */ struct rx_call *a_call,
93         /*IN */ HostIdentifier * Server,
94         /*IN */ AFSByteRangeLockSeq Locks_Array)
95 {
96     rpc_test_request_ctx *ctx = CTX_FOR_RXCALL(a_call);
97
98     printf("%s: SRXAFSCB_AsyncIssueByteRangeLock: enter (%s)\n", prog,
99         ctx->cb_svc_name);
100
101     return (0);
102 }
103 #endif /* AFS_BYTE_RANGE_FLOCKS */
104
105 afs_int32
106 SRXAFSCB_CallBack(struct rx_call *a_call, AFSCBFids *Fids_Array,
107                   AFSCBs *CallBack_Array)
108 {
109     rpc_test_request_ctx *ctx = CTX_FOR_RXCALL(a_call);
110
111     printf("%s: SRXAFSCB_CallBack: enter (%s)\n", prog,
112         ctx->cb_svc_name);
113
114     return (0);
115 }
116
117
118 afs_int32
119 SRXAFSCB_InitCallBackState(struct rx_call *a_call)
120 {
121     return (0);
122 }
123
124
125 afs_int32
126 SRXAFSCB_Probe(struct rx_call *a_call)
127 {
128     return (0);
129 }
130
131
132 afs_int32
133 SRXAFSCB_GetCE(struct rx_call *a_call,
134                afs_int32 index,
135                AFSDBCacheEntry * ce)
136 {
137     return(0);
138 }
139
140
141 afs_int32
142 SRXAFSCB_GetLock(struct rx_call *a_call,
143                  afs_int32 index,
144                  AFSDBLock * lock)
145 {
146     return(0);
147 }
148
149
150 afs_int32
151 SRXAFSCB_XStatsVersion(struct rx_call *a_call,
152                        afs_int32 * versionNumberP)
153 {
154     return(0);
155 }
156
157
158 afs_int32
159 SRXAFSCB_GetXStats(struct rx_call *a_call,
160                    afs_int32 clientVersionNumber,
161                    afs_int32 collectionNumber,
162                    afs_int32 * srvVersionNumberP,
163                    afs_int32 * timeP,
164                    AFSCB_CollData * dataP)
165 {
166     return(0);
167 }
168
169 afs_int32
170 SRXAFSCB_ProbeUuid(struct rx_call *a_call, afsUUID *a_uuid)
171 {
172     rpc_test_request_ctx *ctx = CTX_FOR_RXCALL(a_call);
173     if ( !afs_uuid_equal(&ctx->cb_listen_addr.uuid, a_uuid) )
174         return (1);
175     else
176         return (0);
177 }
178
179
180 afs_int32
181 SRXAFSCB_WhoAreYou(struct rx_call *a_call, struct interfaceAddr *addr)
182 {
183     return SRXAFSCB_TellMeAboutYourself(a_call, addr, NULL);
184 }
185
186
187 afs_int32
188 SRXAFSCB_InitCallBackState2(struct rx_call *a_call, struct interfaceAddr *
189                             addr)
190 {
191     return RXGEN_OPCODE;
192 }
193
194
195 afs_int32
196 SRXAFSCB_InitCallBackState3(struct rx_call *a_call, afsUUID *a_uuid)
197 {
198     return (0);
199 }
200
201
202 afs_int32
203 SRXAFSCB_GetCacheConfig(struct rx_call *a_call, afs_uint32 callerVersion,
204                         afs_uint32 *serverVersion, afs_uint32 *configCount,
205                         cacheConfig *config)
206 {
207     return RXGEN_OPCODE;
208 }
209
210 afs_int32
211 SRXAFSCB_GetLocalCell(struct rx_call *a_call, char **a_name)
212 {
213     return RXGEN_OPCODE;
214 }
215
216
217 afs_int32
218 SRXAFSCB_GetCellServDB(struct rx_call *a_call, afs_int32 a_index,
219                        char **a_name, serverList *a_hosts)
220 {
221     return RXGEN_OPCODE;
222 }
223
224
225 afs_int32
226 SRXAFSCB_GetServerPrefs(struct rx_call *a_call, afs_int32 a_index,
227                         afs_int32 *a_srvr_addr, afs_int32 *a_srvr_rank)
228 {
229     return RXGEN_OPCODE;
230 }
231
232
233 afs_int32
234 SRXAFSCB_TellMeAboutYourself(struct rx_call *a_call, struct interfaceAddr *
235                              addr, Capabilities *capabilities)
236 {
237     afs_int32 code;
238     rpc_test_request_ctx *ctx = CTX_FOR_RXCALL(a_call);
239
240     printf("%s: SRXAFSCB_TellMeAboutYourself: enter (%s)\n", prog,
241         ctx->cb_svc_name);
242
243     addr->numberOfInterfaces = ctx->cb_listen_addr.numberOfInterfaces;
244     addr->uuid = ctx->cb_listen_addr.uuid;
245
246     if (capabilities) {
247         afs_uint32 *dataBuffP;
248         afs_int32 dataBytes;
249
250         dataBytes = 1 * sizeof(afs_uint32);
251         dataBuffP = (afs_uint32 *) xdr_alloc(dataBytes);
252         dataBuffP[0] = CLIENT_CAPABILITY_ERRORTRANS;
253 #if defined(AFS_EXTENDED_CALLBACK)
254         if (ctx->flags & RPC_TEST_REQ_CTX_FLAG_XCB)
255             dataBuffP[0] |= CLIENT_CAPABILITY_EXT_CALLBACK;
256 #endif /* AFS_EXTENDED_CALLBACK */
257         capabilities->Capabilities_len = dataBytes / sizeof(afs_uint32);
258         capabilities->Capabilities_val = dataBuffP;
259     }
260
261     return (0);
262
263 }        /* SRXAFSCB_TellMeAboutYourself */
264
265
266 afs_int32
267 SRXAFSCB_GetCellByNum(struct rx_call *a_call, afs_int32 a_cellnum,
268                       char **a_name, serverList *a_hosts)
269 {
270     return RXGEN_OPCODE;
271 }
272
273
274 afs_int32
275 SRXAFSCB_GetCE64(struct rx_call *a_call, afs_int32 a_index,
276                  struct AFSDBCacheEntry64 *a_result)
277 {
278     return RXGEN_OPCODE;
279 }