2 * Copyright 2000, International Business Machines Corporation and others.
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
12 * Implementation of the fsprobe callback routines. These are the
13 * server-side functions that the FileServer expects to invoke on
14 * the client machine via the afsint interface. In this case, the
15 * client workstation is acting as a callback listener.
18 * The afsint server stubs expect the functions defined here to
19 * be provided. There is no .h file for this code, since the
20 * linker really does all the work for us, and these don't really
21 * need to be ``visible'' to anyone else.
22 *------------------------------------------------------------------------*/
24 #include <afsconfig.h>
25 #include <afs/param.h>
30 #include <stdio.h> /*Standard I/O stuff*/
31 #include <afs/afscbint.h> /*Callback interface defs*/
33 #define FSPROBE_CALLBACK_VERBOSE 0
35 int afs_cb_inited = 0;
36 struct interfaceAddr afs_cb_interface;
39 * Routines we need that don't have explicit include file definitions.
41 extern char *hostutil_GetNameByINet(); /*Host parsing utility*/
43 static char mn[] = "fsprobe_callback"; /*Module name*/
46 * Initialize the callback interface structure
48 static int init_afs_cb() {
51 afs_uuid_create(&afs_cb_interface.uuid);
52 count = rx_getAllAddr(&afs_cb_interface.addr_in, AFS_MAX_INTERFACE_ADDR);
54 afs_cb_interface.numberOfInterfaces = 0;
56 afs_cb_interface.numberOfInterfaces = count;
62 /*------------------------------------------------------------------------
66 * Handle a set of callbacks from the FileServer.
69 * struct rx_call *rxcall : Ptr to the associated Rx call structure.
70 * AFSCBFids *Fids_Array : Ptr to the set of Fids.
71 * AFSCBs *CallBacks_Array : Ptr to the set of callbacks.
75 * Error value otherwise.
78 * Nothing interesting.
82 *------------------------------------------------------------------------*/
84 afs_int32 SRXAFSCB_CallBack(rxcall, Fids_Array, CallBack_Array)
85 struct rx_call *rxcall;
86 AFSCBFids *Fids_Array;
87 AFSCBs *CallBack_Array;
89 { /*SRXAFSCB_CallBack*/
91 #if FSPROBE_CALLBACK_VERBOSE
92 static char rn[] = "SRXAFSCB_CallBack"; /*Routine name*/
93 char hostName[256]; /*Host name buffer*/
94 char *hostNameResult; /*Ptr to static*/
96 if (rxcall != (struct rx_call *)0) {
98 hostutil_GetNameByINet((afs_int32)(rxcall->conn->peer->host));
99 strcpy(hostName, hostNameResult);
100 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n",
101 mn, rn, hostName, rxcall->conn->peer->port);
102 } /*Valid rxcall param*/
103 #endif /* FSPROBE_CALLBACK_VERBOSE */
106 * Return successfully.
110 } /*SRXAFSCB_CallBack*/
113 /*------------------------------------------------------------------------
114 * SRXAFSCB_InitCallBackState
117 * Initialize callback state on this ``Cache Manager''.
120 * struct rx_call *rxcall : Ptr to the associated Rx call structure.
124 * Error value otherwise.
127 * This will definitely be called by the FileServer (exactly once),
128 * since it will think we are another new ``Cache Manager''.
132 *------------------------------------------------------------------------*/
134 afs_int32 SRXAFSCB_InitCallBackState(rxcall)
135 struct rx_call *rxcall;
137 { /*SRXAFSCB_InitCallBackState*/
139 #if FSPROBE_CALLBACK_VERBOSE
140 static char rn[] = "SRXAFSCB_InitCallBackState"; /*Routine name*/
141 char hostName[256]; /*Host name buffer*/
142 char *hostNameResult; /*Ptr to static*/
144 if (rxcall != (struct rx_call *)0) {
146 hostutil_GetNameByINet((afs_int32)(rxcall->conn->peer->host));
147 strcpy(hostName, hostNameResult);
148 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n",
149 mn, rn, hostName, rxcall->conn->peer->port);
150 } /*Valid rxcall param*/
151 #endif /* FSPROBE_CALLBACK_VERBOSE */
154 * Return successfully.
158 } /*SRXAFSCB_InitCallBackState*/
161 /*------------------------------------------------------------------------
165 * Respond to a probe from the FileServer. If a FileServer doesn't
166 * hear from you every so often, it will send you a probe to make
167 * sure you're there, just like any other ``Cache Manager'' it's
171 * struct rx_call *rxcall : Ptr to the associated Rx call structure.
175 * Error value otherwise.
178 * This may be called by the FileServer if we don't call it often
183 *------------------------------------------------------------------------*/
185 afs_int32 SRXAFSCB_Probe(rxcall)
186 struct rx_call *rxcall;
190 #if FSPROBE_CALLBACK_VERBOSE
191 static char rn[] = "SRXAFSCB_Probe"; /*Routine name*/
192 char hostName[256]; /*Host name buffer*/
193 char *hostNameResult; /*Ptr to static*/
195 if (rxcall != (struct rx_call *)0) {
197 hostutil_GetNameByINet((afs_int32)(rxcall->conn->peer->host));
198 strcpy(hostName, hostNameResult);
199 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n",
200 mn, rn, hostName, rxcall->conn->peer->port);
201 } /*Valid rxcall param*/
202 #endif /* FSPROBE_CALLBACK_VERBOSE */
205 * Return successfully.
212 /*------------------------------------------------------------------------
216 * Respond minimally to a request for returning the contents of
217 * a cache entry, since someone out there thinks you're a Cache
221 * struct rx_call *rxcall: Ptr to the associated Rx call structure.
227 * Nothing interesting.
231 *------------------------------------------------------------------------*/
233 afs_int32 SRXAFSCB_GetCE64(rxcall)
234 struct rx_call *rxcall;
236 { /*SRXAFSCB_GetCE64*/
238 #if XSTAT_FS_CALLBACK_VERBOSE
239 static char rn[] = "SRXAFSCB_GetCE64"; /*Routine name*/
240 char hostName[256]; /*Host name buffer*/
241 char *hostNameResult; /*Ptr to static*/
243 if (rxcall != (struct rx_call *)0) {
245 hostutil_GetNameByINet((afs_int32)(rxcall->conn->peer->host));
246 strcpy(hostName, hostNameResult);
247 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n",
248 mn, rn, hostName, rxcall->conn->peer->port);
249 } /*Valid rxcall param*/
250 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
254 } /*SRXAFSCB_GetCE64*/
256 afs_int32 SRXAFSCB_GetCE(rxcall)
257 struct rx_call *rxcall;
261 #if XSTAT_FS_CALLBACK_VERBOSE
262 static char rn[] = "SRXAFSCB_GetCE"; /*Routine name*/
263 char hostName[256]; /*Host name buffer*/
264 char *hostNameResult; /*Ptr to static*/
266 if (rxcall != (struct rx_call *)0) {
268 hostutil_GetNameByINet((afs_int32)(rxcall->conn->peer->host));
269 strcpy(hostName, hostNameResult);
270 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n",
271 mn, rn, hostName, rxcall->conn->peer->port);
272 } /*Valid rxcall param*/
273 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
280 /*------------------------------------------------------------------------
284 * Respond minimally to a request for returning the contents of
285 * a cache lock, since someone out there thinks you're a Cache
289 * struct rx_call *rxcall: Ptr to the associated Rx call structure.
295 * Nothing interesting.
299 *------------------------------------------------------------------------*/
301 afs_int32 SRXAFSCB_GetLock(rxcall)
302 struct rx_call *rxcall;
304 { /*SRXAFSCB_GetLock*/
306 #if XSTAT_FS_CALLBACK_VERBOSE
307 static char rn[] = "SRXAFSCB_GetLock"; /*Routine name*/
308 char hostName[256]; /*Host name buffer*/
309 char *hostNameResult; /*Ptr to static*/
311 if (rxcall != (struct rx_call *)0) {
313 hostutil_GetNameByINet((afs_int32)(rxcall->conn->peer->host));
314 strcpy(hostName, hostNameResult);
315 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n",
316 mn, rn, hostName, rxcall->conn->peer->port);
317 } /*Valid rxcall param*/
318 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
322 } /*SRXAFSCB_GetLock*/
325 /*------------------------------------------------------------------------
326 * SRXAFSCB_XStatsVersion
329 * Respond minimally to a request for fetching the version of
330 * extended Cache Manager statistics offered, since someone out
331 * there thinks you're a Cache Manager.
334 * struct rx_call *rxcall: Ptr to the associated Rx call structure.
340 * Nothing interesting.
344 *------------------------------------------------------------------------*/
346 afs_int32 SRXAFSCB_XStatsVersion(rxcall)
347 struct rx_call *rxcall;
349 { /*SRXAFSCB_XStatsVersion*/
351 #if XSTAT_FS_CALLBACK_VERBOSE
352 static char rn[] = "SRXAFSCB_XStatsVersion"; /*Routine name*/
353 char hostName[256]; /*Host name buffer*/
354 char *hostNameResult; /*Ptr to static*/
356 if (rxcall != (struct rx_call *)0) {
358 hostutil_GetNameByINet((afs_int32)(rxcall->conn->peer->host));
359 strcpy(hostName, hostNameResult);
360 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n",
361 mn, rn, hostName, rxcall->conn->peer->port);
362 } /*Valid rxcall param*/
363 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
367 } /*SRXAFSCB_XStatsVersion*/
370 /*------------------------------------------------------------------------
374 * Respond minimally to a request for returning extended
375 * statistics for a Cache Manager, since someone out there thinks
376 * you're a Cache Manager.
379 * struct rx_call *rxcall: Ptr to the associated Rx call structure.
385 * Nothing interesting.
389 *------------------------------------------------------------------------*/
391 afs_int32 SRXAFSCB_GetXStats(rxcall)
392 struct rx_call *rxcall;
394 { /*SRXAFSCB_GetXStats*/
396 #if XSTAT_FS_CALLBACK_VERBOSE
397 static char rn[] = "SRXAFSCB_GetXStats"; /*Routine name*/
398 char hostName[256]; /*Host name buffer*/
399 char *hostNameResult; /*Ptr to static*/
401 if (rxcall != (struct rx_call *)0) {
403 hostutil_GetNameByINet((afs_int32)(rxcall->conn->peer->host));
404 strcpy(hostName, hostNameResult);
405 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n",
406 mn, rn, hostName, rxcall->conn->peer->port);
407 } /*Valid rxcall param*/
408 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
412 } /*SRXAFSCB_GetXStats*/
414 /*------------------------------------------------------------------------
415 * EXPORTED SRXAFSCB_InitCallBackState2
418 * This routine was used in the AFS 3.5 beta release, but not anymore.
419 * It has since been replaced by SRXAFSCB_InitCallBackState3.
422 * rxcall : Ptr to Rx call on which this request came in.
425 * RXGEN_OPCODE (always).
428 * Nothing interesting.
432 *------------------------------------------------------------------------*/
434 int SRXAFSCB_InitCallBackState2(rxcall, addr)
435 struct rx_call *rxcall;
436 struct interfaceAddr * addr;
439 #if FSPROBE_CALLBACK_VERBOSE
440 static char rn[] = "SRXAFSCB_InitCallBackState2"; /*Routine name*/
441 char hostName[256]; /*Host name buffer*/
442 char *hostNameResult; /*Ptr to static*/
444 if (rxcall != (struct rx_call *)0) {
446 hostutil_GetNameByINet((afs_int32)(rxcall->conn->peer->host));
447 strcpy(hostName, hostNameResult);
448 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n",
449 mn, rn, hostName, rxcall->conn->peer->port);
450 } /*Valid rxcall param*/
451 #endif /* FSPROBE_CALLBACK_VERBOSE */
455 /*------------------------------------------------------------------------
456 * EXPORTED SRXAFSCB_WhoAreYou
459 * Routine called by the server-side callback RPC interface to
460 * obtain a unique identifier for the client. The server uses
461 * this identifier to figure out whether or not two RX connections
462 * are from the same client, and to find out which addresses go
463 * with which clients.
466 * rxcall : Ptr to Rx call on which this request came in.
467 * addr: Ptr to return the list of interfaces for this client.
473 * Nothing interesting.
477 *------------------------------------------------------------------------*/
479 int SRXAFSCB_WhoAreYou(rxcall, addr)
480 struct rx_call *rxcall;
481 struct interfaceAddr *addr;
487 #if FSPROBE_CALLBACK_VERBOSE
488 static char rn[] = "SRXAFSCB_WhoAreYou"; /*Routine name*/
489 char hostName[256]; /*Host name buffer*/
490 char *hostNameResult; /*Ptr to static*/
492 if (rxcall != (struct rx_call *)0) {
494 hostutil_GetNameByINet((afs_int32)(rxcall->conn->peer->host));
495 strcpy(hostName, hostNameResult);
496 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n",
497 mn, rn, hostName, rxcall->conn->peer->port);
498 } /*Valid rxcall param*/
499 #endif /* FSPROBE_CALLBACK_VERBOSE */
501 if ( rxcall && addr )
503 if (!afs_cb_inited) init_afs_cb();
504 *addr = afs_cb_interface;
508 * Return successfully.
514 /*------------------------------------------------------------------------
515 * EXPORTED SRXAFSCB_InitCallBackState3
518 * Routine called by the server-side callback RPC interface to
519 * implement clearing all callbacks from this host.
522 * rxcall : Ptr to Rx call on which this request came in.
528 * Nothing interesting.
532 *------------------------------------------------------------------------*/
534 int SRXAFSCB_InitCallBackState3(rxcall, uuidp)
535 struct rx_call *rxcall;
538 #if FSPROBE_CALLBACK_VERBOSE
539 static char rn[] = "SRXAFSCB_InitCallBackState2"; /*Routine name*/
540 char hostName[256]; /*Host name buffer*/
541 char *hostNameResult; /*Ptr to static*/
543 if (rxcall != (struct rx_call *)0) {
545 hostutil_GetNameByINet((afs_int32)(rxcall->conn->peer->host));
546 strcpy(hostName, hostNameResult);
547 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n",
548 mn, rn, hostName, rxcall->conn->peer->port);
549 } /*Valid rxcall param*/
550 #endif /* FSPROBE_CALLBACK_VERBOSE */
553 * Return successfully.
559 /*------------------------------------------------------------------------
560 * EXPORTED SRXAFSCB_ProbeUuid
563 * Routine called by the server-side callback RPC interface to
564 * implement ``probing'' the Cache Manager, just making sure it's
565 * still there is still the same client it used to be.
568 * rxcall : Ptr to Rx call on which this request came in.
569 * uuidp : Ptr to UUID that must match the client's UUID.
572 * 0 if uuidp matches the UUID for this client
576 * Nothing interesting.
580 *------------------------------------------------------------------------*/
582 int SRXAFSCB_ProbeUuid(rxcall, uuidp)
583 struct rx_call *rxcall;
588 #if FSPROBE_CALLBACK_VERBOSE
589 static char rn[] = "SRXAFSCB_ProbeUuid"; /*Routine name*/
590 char hostName[256]; /*Host name buffer*/
591 char *hostNameResult; /*Ptr to static*/
593 if (rxcall != (struct rx_call *)0) {
595 hostutil_GetNameByINet((afs_int32)(rxcall->conn->peer->host));
596 strcpy(hostName, hostNameResult);
597 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n",
598 mn, rn, hostName, rxcall->conn->peer->port);
599 } /*Valid rxcall param*/
600 #endif /* FSPROBE_CALLBACK_VERBOSE */
602 if (!afs_cb_inited) init_afs_cb();
603 if (!afs_uuid_equal(uuidp, &afs_cb_interface.uuid))
604 code = 1; /* failure */
608 /*------------------------------------------------------------------------
609 * EXPORTED SRXAFSCB_GetServerPrefs
612 * Routine to list server preferences used by this client.
615 * a_call : Ptr to Rx call on which this request came in.
616 * a_index : Input server index
617 * a_srvr_addr : Output server address (0xffffffff on last server)
618 * a_srvr_rank : Output server rank
624 * Nothing interesting.
628 *------------------------------------------------------------------------*/
630 int SRXAFSCB_GetServerPrefs(
631 struct rx_call *a_call,
633 afs_int32 *a_srvr_addr,
634 afs_int32 *a_srvr_rank)
636 *a_srvr_addr = 0xffffffff;
637 *a_srvr_rank = 0xffffffff;
641 /*------------------------------------------------------------------------
642 * EXPORTED SRXAFSCB_GetCellServDB
645 * Routine to list cells configured for this client
648 * a_call : Ptr to Rx call on which this request came in.
649 * a_index : Input cell index
650 * a_name : Output cell name ("" on last cell)
651 * a_hosts : Output cell database servers
654 * RXGEN_OPCODE (always)
657 * Nothing interesting.
661 *------------------------------------------------------------------------*/
663 int SRXAFSCB_GetCellServDB(
664 struct rx_call *a_call,
672 /*------------------------------------------------------------------------
673 * EXPORTED SRXAFSCB_GetLocalCell
676 * Routine to return name of client's local cell
679 * a_call : Ptr to Rx call on which this request came in.
680 * a_name : Output cell name
683 * RXGEN_OPCODE (always)
686 * Nothing interesting.
690 *------------------------------------------------------------------------*/
692 int SRXAFSCB_GetLocalCell(
693 struct rx_call *a_call,
700 /*------------------------------------------------------------------------
701 * EXPORTED SRXAFSCB_GetCacheConfig
704 * Routine to return parameters used to initialize client cache.
705 * Client may request any format version. Server may not return
706 * format version greater than version requested by client.
709 * a_call: Ptr to Rx call on which this request came in.
710 * callerVersion: Data format version desired by the client.
711 * serverVersion: Data format version of output data.
712 * configCount: Number bytes allocated for output data.
713 * config: Client cache configuration.
716 * RXGEN_OPCODE (always)
719 * Nothing interesting.
723 *------------------------------------------------------------------------*/
725 int SRXAFSCB_GetCacheConfig(
726 struct rx_call *a_call,
727 afs_uint32 callerVersion,
728 afs_uint32 *serverVersion,
729 afs_uint32 *configCount,