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_GetCE(rxcall)
234 struct rx_call *rxcall;
238 #if XSTAT_FS_CALLBACK_VERBOSE
239 static char rn[] = "SRXAFSCB_GetCE"; /*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 */
257 /*------------------------------------------------------------------------
261 * Respond minimally to a request for returning the contents of
262 * a cache lock, since someone out there thinks you're a Cache
266 * struct rx_call *rxcall: Ptr to the associated Rx call structure.
272 * Nothing interesting.
276 *------------------------------------------------------------------------*/
278 afs_int32 SRXAFSCB_GetLock(rxcall)
279 struct rx_call *rxcall;
281 { /*SRXAFSCB_GetLock*/
283 #if XSTAT_FS_CALLBACK_VERBOSE
284 static char rn[] = "SRXAFSCB_GetLock"; /*Routine name*/
285 char hostName[256]; /*Host name buffer*/
286 char *hostNameResult; /*Ptr to static*/
288 if (rxcall != (struct rx_call *)0) {
290 hostutil_GetNameByINet((afs_int32)(rxcall->conn->peer->host));
291 strcpy(hostName, hostNameResult);
292 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n",
293 mn, rn, hostName, rxcall->conn->peer->port);
294 } /*Valid rxcall param*/
295 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
299 } /*SRXAFSCB_GetLock*/
302 /*------------------------------------------------------------------------
303 * SRXAFSCB_XStatsVersion
306 * Respond minimally to a request for fetching the version of
307 * extended Cache Manager statistics offered, since someone out
308 * there thinks you're a Cache Manager.
311 * struct rx_call *rxcall: Ptr to the associated Rx call structure.
317 * Nothing interesting.
321 *------------------------------------------------------------------------*/
323 afs_int32 SRXAFSCB_XStatsVersion(rxcall)
324 struct rx_call *rxcall;
326 { /*SRXAFSCB_XStatsVersion*/
328 #if XSTAT_FS_CALLBACK_VERBOSE
329 static char rn[] = "SRXAFSCB_XStatsVersion"; /*Routine name*/
330 char hostName[256]; /*Host name buffer*/
331 char *hostNameResult; /*Ptr to static*/
333 if (rxcall != (struct rx_call *)0) {
335 hostutil_GetNameByINet((afs_int32)(rxcall->conn->peer->host));
336 strcpy(hostName, hostNameResult);
337 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n",
338 mn, rn, hostName, rxcall->conn->peer->port);
339 } /*Valid rxcall param*/
340 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
344 } /*SRXAFSCB_XStatsVersion*/
347 /*------------------------------------------------------------------------
351 * Respond minimally to a request for returning extended
352 * statistics for a Cache Manager, since someone out there thinks
353 * you're a Cache Manager.
356 * struct rx_call *rxcall: Ptr to the associated Rx call structure.
362 * Nothing interesting.
366 *------------------------------------------------------------------------*/
368 afs_int32 SRXAFSCB_GetXStats(rxcall)
369 struct rx_call *rxcall;
371 { /*SRXAFSCB_GetXStats*/
373 #if XSTAT_FS_CALLBACK_VERBOSE
374 static char rn[] = "SRXAFSCB_GetXStats"; /*Routine name*/
375 char hostName[256]; /*Host name buffer*/
376 char *hostNameResult; /*Ptr to static*/
378 if (rxcall != (struct rx_call *)0) {
380 hostutil_GetNameByINet((afs_int32)(rxcall->conn->peer->host));
381 strcpy(hostName, hostNameResult);
382 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n",
383 mn, rn, hostName, rxcall->conn->peer->port);
384 } /*Valid rxcall param*/
385 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
389 } /*SRXAFSCB_GetXStats*/
391 /*------------------------------------------------------------------------
392 * EXPORTED SRXAFSCB_InitCallBackState2
395 * This routine was used in the AFS 3.5 beta release, but not anymore.
396 * It has since been replaced by SRXAFSCB_InitCallBackState3.
399 * rxcall : Ptr to Rx call on which this request came in.
402 * RXGEN_OPCODE (always).
405 * Nothing interesting.
409 *------------------------------------------------------------------------*/
411 int SRXAFSCB_InitCallBackState2(rxcall, addr)
412 struct rx_call *rxcall;
413 struct interfaceAddr * addr;
416 #if FSPROBE_CALLBACK_VERBOSE
417 static char rn[] = "SRXAFSCB_InitCallBackState2"; /*Routine name*/
418 char hostName[256]; /*Host name buffer*/
419 char *hostNameResult; /*Ptr to static*/
421 if (rxcall != (struct rx_call *)0) {
423 hostutil_GetNameByINet((afs_int32)(rxcall->conn->peer->host));
424 strcpy(hostName, hostNameResult);
425 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n",
426 mn, rn, hostName, rxcall->conn->peer->port);
427 } /*Valid rxcall param*/
428 #endif /* FSPROBE_CALLBACK_VERBOSE */
432 /*------------------------------------------------------------------------
433 * EXPORTED SRXAFSCB_WhoAreYou
436 * Routine called by the server-side callback RPC interface to
437 * obtain a unique identifier for the client. The server uses
438 * this identifier to figure out whether or not two RX connections
439 * are from the same client, and to find out which addresses go
440 * with which clients.
443 * rxcall : Ptr to Rx call on which this request came in.
444 * addr: Ptr to return the list of interfaces for this client.
450 * Nothing interesting.
454 *------------------------------------------------------------------------*/
456 int SRXAFSCB_WhoAreYou(rxcall, addr)
457 struct rx_call *rxcall;
458 struct interfaceAddr *addr;
464 #if FSPROBE_CALLBACK_VERBOSE
465 static char rn[] = "SRXAFSCB_WhoAreYou"; /*Routine name*/
466 char hostName[256]; /*Host name buffer*/
467 char *hostNameResult; /*Ptr to static*/
469 if (rxcall != (struct rx_call *)0) {
471 hostutil_GetNameByINet((afs_int32)(rxcall->conn->peer->host));
472 strcpy(hostName, hostNameResult);
473 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n",
474 mn, rn, hostName, rxcall->conn->peer->port);
475 } /*Valid rxcall param*/
476 #endif /* FSPROBE_CALLBACK_VERBOSE */
478 if ( rxcall && addr )
480 if (!afs_cb_inited) init_afs_cb();
481 *addr = afs_cb_interface;
485 * Return successfully.
491 /*------------------------------------------------------------------------
492 * EXPORTED SRXAFSCB_InitCallBackState3
495 * Routine called by the server-side callback RPC interface to
496 * implement clearing all callbacks from this host.
499 * rxcall : Ptr to Rx call on which this request came in.
505 * Nothing interesting.
509 *------------------------------------------------------------------------*/
511 int SRXAFSCB_InitCallBackState3(rxcall, uuidp)
512 struct rx_call *rxcall;
515 #if FSPROBE_CALLBACK_VERBOSE
516 static char rn[] = "SRXAFSCB_InitCallBackState2"; /*Routine name*/
517 char hostName[256]; /*Host name buffer*/
518 char *hostNameResult; /*Ptr to static*/
520 if (rxcall != (struct rx_call *)0) {
522 hostutil_GetNameByINet((afs_int32)(rxcall->conn->peer->host));
523 strcpy(hostName, hostNameResult);
524 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n",
525 mn, rn, hostName, rxcall->conn->peer->port);
526 } /*Valid rxcall param*/
527 #endif /* FSPROBE_CALLBACK_VERBOSE */
530 * Return successfully.
536 /*------------------------------------------------------------------------
537 * EXPORTED SRXAFSCB_ProbeUuid
540 * Routine called by the server-side callback RPC interface to
541 * implement ``probing'' the Cache Manager, just making sure it's
542 * still there is still the same client it used to be.
545 * rxcall : Ptr to Rx call on which this request came in.
546 * uuidp : Ptr to UUID that must match the client's UUID.
549 * 0 if uuidp matches the UUID for this client
553 * Nothing interesting.
557 *------------------------------------------------------------------------*/
559 int SRXAFSCB_ProbeUuid(rxcall, uuidp)
560 struct rx_call *rxcall;
565 #if FSPROBE_CALLBACK_VERBOSE
566 static char rn[] = "SRXAFSCB_ProbeUuid"; /*Routine name*/
567 char hostName[256]; /*Host name buffer*/
568 char *hostNameResult; /*Ptr to static*/
570 if (rxcall != (struct rx_call *)0) {
572 hostutil_GetNameByINet((afs_int32)(rxcall->conn->peer->host));
573 strcpy(hostName, hostNameResult);
574 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n",
575 mn, rn, hostName, rxcall->conn->peer->port);
576 } /*Valid rxcall param*/
577 #endif /* FSPROBE_CALLBACK_VERBOSE */
579 if (!afs_cb_inited) init_afs_cb();
580 if (!afs_uuid_equal(uuidp, &afs_cb_interface.uuid))
581 code = 1; /* failure */
585 /*------------------------------------------------------------------------
586 * EXPORTED SRXAFSCB_GetServerPrefs
589 * Routine to list server preferences used by this client.
592 * a_call : Ptr to Rx call on which this request came in.
593 * a_index : Input server index
594 * a_srvr_addr : Output server address (0xffffffff on last server)
595 * a_srvr_rank : Output server rank
601 * Nothing interesting.
605 *------------------------------------------------------------------------*/
607 int SRXAFSCB_GetServerPrefs(
608 struct rx_call *a_call,
610 afs_int32 *a_srvr_addr,
611 afs_int32 *a_srvr_rank)
613 *a_srvr_addr = 0xffffffff;
614 *a_srvr_rank = 0xffffffff;
618 /*------------------------------------------------------------------------
619 * EXPORTED SRXAFSCB_GetCellServDB
622 * Routine to list cells configured for this client
625 * a_call : Ptr to Rx call on which this request came in.
626 * a_index : Input cell index
627 * a_name : Output cell name ("" on last cell)
628 * a_hosts : Output cell database servers
631 * RXGEN_OPCODE (always)
634 * Nothing interesting.
638 *------------------------------------------------------------------------*/
640 int SRXAFSCB_GetCellServDB(
641 struct rx_call *a_call,
649 /*------------------------------------------------------------------------
650 * EXPORTED SRXAFSCB_GetLocalCell
653 * Routine to return name of client's local cell
656 * a_call : Ptr to Rx call on which this request came in.
657 * a_name : Output cell name
660 * RXGEN_OPCODE (always)
663 * Nothing interesting.
667 *------------------------------------------------------------------------*/
669 int SRXAFSCB_GetLocalCell(
670 struct rx_call *a_call,
677 /*------------------------------------------------------------------------
678 * EXPORTED SRXAFSCB_GetCacheConfig
681 * Routine to return parameters used to initialize client cache.
682 * Client may request any format version. Server may not return
683 * format version greater than version requested by client.
686 * a_call: Ptr to Rx call on which this request came in.
687 * callerVersion: Data format version desired by the client.
688 * serverVersion: Data format version of output data.
689 * configCount: Number bytes allocated for output data.
690 * config: Client cache configuration.
693 * RXGEN_OPCODE (always)
696 * Nothing interesting.
700 *------------------------------------------------------------------------*/
702 int SRXAFSCB_GetCacheConfig(
703 struct rx_call *a_call,
704 afs_uint32 callerVersion,
705 afs_uint32 *serverVersion,
706 afs_uint32 *configCount,