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>
29 #include <stdio.h> /*Standard I/O stuff */
30 #include <afs/afscbint.h> /*Callback interface defs */
31 #include <afs/afsutil.h>
33 #define FSPROBE_CALLBACK_VERBOSE 0
35 int afs_cb_inited = 0;
36 struct interfaceAddr afs_cb_interface;
39 * Initialize the callback interface structure
46 afs_uuid_create(&afs_cb_interface.uuid);
47 count = rx_getAllAddr((afs_uint32 *) &afs_cb_interface.addr_in, AFS_MAX_INTERFACE_ADDR);
49 afs_cb_interface.numberOfInterfaces = 0;
51 afs_cb_interface.numberOfInterfaces = count;
57 /*------------------------------------------------------------------------
61 * Handle a set of callbacks from the FileServer.
64 * struct rx_call *rxcall : Ptr to the associated Rx call structure.
65 * AFSCBFids *Fids_Array : Ptr to the set of Fids.
66 * AFSCBs *CallBacks_Array : Ptr to the set of callbacks.
70 * Error value otherwise.
73 * Nothing interesting.
77 *------------------------------------------------------------------------*/
80 SRXAFSCB_CallBack(struct rx_call * rxcall, AFSCBFids * Fids_Array,
81 AFSCBs * CallBack_Array)
82 { /*SRXAFSCB_CallBack */
84 #if FSPROBE_CALLBACK_VERBOSE
85 static char rn[] = "SRXAFSCB_CallBack"; /*Routine name */
86 char hostName[256]; /*Host name buffer */
87 char *hostNameResult; /*Ptr to static */
89 if (rxcall != (struct rx_call *)0) {
91 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
92 strcpy(hostName, hostNameResult);
93 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
94 hostName, rxcall->conn->peer->port);
95 } /*Valid rxcall param */
96 #endif /* FSPROBE_CALLBACK_VERBOSE */
99 * Return successfully.
103 } /*SRXAFSCB_CallBack */
106 /*------------------------------------------------------------------------
107 * SRXAFSCB_InitCallBackState
110 * Initialize callback state on this ``Cache Manager''.
113 * struct rx_call *rxcall : Ptr to the associated Rx call structure.
117 * Error value otherwise.
120 * This will definitely be called by the FileServer (exactly once),
121 * since it will think we are another new ``Cache Manager''.
125 *------------------------------------------------------------------------*/
128 SRXAFSCB_InitCallBackState(struct rx_call * rxcall)
129 { /*SRXAFSCB_InitCallBackState */
131 #if FSPROBE_CALLBACK_VERBOSE
132 static char rn[] = "SRXAFSCB_InitCallBackState"; /*Routine name */
133 char hostName[256]; /*Host name buffer */
134 char *hostNameResult; /*Ptr to static */
136 if (rxcall != (struct rx_call *)0) {
138 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
139 strcpy(hostName, hostNameResult);
140 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
141 hostName, rxcall->conn->peer->port);
142 } /*Valid rxcall param */
143 #endif /* FSPROBE_CALLBACK_VERBOSE */
146 * Return successfully.
150 } /*SRXAFSCB_InitCallBackState */
153 /*------------------------------------------------------------------------
157 * Respond to a probe from the FileServer. If a FileServer doesn't
158 * hear from you every so often, it will send you a probe to make
159 * sure you're there, just like any other ``Cache Manager'' it's
163 * struct rx_call *rxcall : Ptr to the associated Rx call structure.
167 * Error value otherwise.
170 * This may be called by the FileServer if we don't call it often
175 *------------------------------------------------------------------------*/
178 SRXAFSCB_Probe(struct rx_call * rxcall)
179 { /*SRXAFSCB_Probe */
181 #if FSPROBE_CALLBACK_VERBOSE
182 static char rn[] = "SRXAFSCB_Probe"; /*Routine name */
183 char hostName[256]; /*Host name buffer */
184 char *hostNameResult; /*Ptr to static */
186 if (rxcall != (struct rx_call *)0) {
188 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
189 strcpy(hostName, hostNameResult);
190 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
191 hostName, rxcall->conn->peer->port);
192 } /*Valid rxcall param */
193 #endif /* FSPROBE_CALLBACK_VERBOSE */
196 * Return successfully.
200 } /*SRXAFSCB_Probe */
203 /*------------------------------------------------------------------------
207 * Respond minimally to a request for returning the contents of
208 * a cache entry, since someone out there thinks you're a Cache
212 * struct rx_call *rxcall: Ptr to the associated Rx call structure.
218 * Nothing interesting.
222 *------------------------------------------------------------------------*/
225 SRXAFSCB_GetCE64(struct rx_call * rxcall, afs_int32 index,
226 AFSDBCacheEntry64 * ce)
227 { /*SRXAFSCB_GetCE64 */
229 #if XSTAT_FS_CALLBACK_VERBOSE
230 static char rn[] = "SRXAFSCB_GetCE64"; /*Routine name */
231 char hostName[256]; /*Host name buffer */
232 char *hostNameResult; /*Ptr to static */
234 if (rxcall != (struct rx_call *)0) {
236 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
237 strcpy(hostName, hostNameResult);
238 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
239 hostName, rxcall->conn->peer->port);
240 } /*Valid rxcall param */
241 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
245 } /*SRXAFSCB_GetCE64 */
248 SRXAFSCB_GetCE(struct rx_call * rxcall, afs_int32 index, AFSDBCacheEntry * ce)
249 { /*SRXAFSCB_GetCE */
251 #if XSTAT_FS_CALLBACK_VERBOSE
252 static char rn[] = "SRXAFSCB_GetCE"; /*Routine name */
253 char hostName[256]; /*Host name buffer */
254 char *hostNameResult; /*Ptr to static */
256 if (rxcall != (struct rx_call *)0) {
258 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
259 strcpy(hostName, hostNameResult);
260 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
261 hostName, rxcall->conn->peer->port);
262 } /*Valid rxcall param */
263 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
267 } /*SRXAFSCB_GetCE */
270 /*------------------------------------------------------------------------
274 * Respond minimally to a request for returning the contents of
275 * a cache lock, since someone out there thinks you're a Cache
279 * struct rx_call *rxcall: Ptr to the associated Rx call structure.
285 * Nothing interesting.
289 *------------------------------------------------------------------------*/
292 SRXAFSCB_GetLock(struct rx_call * rxcall, afs_int32 index, AFSDBLock * lock)
293 { /*SRXAFSCB_GetLock */
295 #if XSTAT_FS_CALLBACK_VERBOSE
296 static char rn[] = "SRXAFSCB_GetLock"; /*Routine name */
297 char hostName[256]; /*Host name buffer */
298 char *hostNameResult; /*Ptr to static */
300 if (rxcall != (struct rx_call *)0) {
302 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
303 strcpy(hostName, hostNameResult);
304 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
305 hostName, rxcall->conn->peer->port);
306 } /*Valid rxcall param */
307 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
311 } /*SRXAFSCB_GetLock */
314 /*------------------------------------------------------------------------
315 * SRXAFSCB_XStatsVersion
318 * Respond minimally to a request for fetching the version of
319 * extended Cache Manager statistics offered, since someone out
320 * there thinks you're a Cache Manager.
323 * struct rx_call *rxcall: Ptr to the associated Rx call structure.
329 * Nothing interesting.
333 *------------------------------------------------------------------------*/
336 SRXAFSCB_XStatsVersion(struct rx_call * rxcall, afs_int32 * versionNumberP)
337 { /*SRXAFSCB_XStatsVersion */
339 #if XSTAT_FS_CALLBACK_VERBOSE
340 static char rn[] = "SRXAFSCB_XStatsVersion"; /*Routine name */
341 char hostName[256]; /*Host name buffer */
342 char *hostNameResult; /*Ptr to static */
344 if (rxcall != (struct rx_call *)0) {
346 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
347 strcpy(hostName, hostNameResult);
348 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
349 hostName, rxcall->conn->peer->port);
350 } /*Valid rxcall param */
351 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
355 } /*SRXAFSCB_XStatsVersion */
358 /*------------------------------------------------------------------------
362 * Respond minimally to a request for returning extended
363 * statistics for a Cache Manager, since someone out there thinks
364 * you're a Cache Manager.
367 * struct rx_call *rxcall: Ptr to the associated Rx call structure.
373 * Nothing interesting.
377 *------------------------------------------------------------------------*/
380 SRXAFSCB_GetXStats(struct rx_call * rxcall, afs_int32 clientVN,
381 afs_int32 collN, afs_int32 * srvVNP, afs_int32 * timeP,
382 AFSCB_CollData * dataP)
383 { /*SRXAFSCB_GetXStats */
385 #if XSTAT_FS_CALLBACK_VERBOSE
386 static char rn[] = "SRXAFSCB_GetXStats"; /*Routine name */
387 char hostName[256]; /*Host name buffer */
388 char *hostNameResult; /*Ptr to static */
390 if (rxcall != (struct rx_call *)0) {
392 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
393 strcpy(hostName, hostNameResult);
394 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
395 hostName, rxcall->conn->peer->port);
396 } /*Valid rxcall param */
397 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
401 } /*SRXAFSCB_GetXStats */
403 /*------------------------------------------------------------------------
404 * EXPORTED SRXAFSCB_InitCallBackState2
407 * This routine was used in the AFS 3.5 beta release, but not anymore.
408 * It has since been replaced by SRXAFSCB_InitCallBackState3.
411 * rxcall : Ptr to Rx call on which this request came in.
414 * RXGEN_OPCODE (always).
417 * Nothing interesting.
421 *------------------------------------------------------------------------*/
424 SRXAFSCB_InitCallBackState2(struct rx_call * rxcall,
425 struct interfaceAddr * addr)
428 #if FSPROBE_CALLBACK_VERBOSE
429 static char rn[] = "SRXAFSCB_InitCallBackState2"; /*Routine name */
430 char hostName[256]; /*Host name buffer */
431 char *hostNameResult; /*Ptr to static */
433 if (rxcall != (struct rx_call *)0) {
435 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
436 strcpy(hostName, hostNameResult);
437 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
438 hostName, rxcall->conn->peer->port);
439 } /*Valid rxcall param */
440 #endif /* FSPROBE_CALLBACK_VERBOSE */
444 /*------------------------------------------------------------------------
445 * EXPORTED SRXAFSCB_WhoAreYou
448 * Routine called by the server-side callback RPC interface to
449 * obtain a unique identifier for the client. The server uses
450 * this identifier to figure out whether or not two RX connections
451 * are from the same client, and to find out which addresses go
452 * with which clients.
455 * rxcall : Ptr to Rx call on which this request came in.
456 * addr: Ptr to return the list of interfaces for this client.
462 * Nothing interesting.
466 *------------------------------------------------------------------------*/
469 SRXAFSCB_WhoAreYou(struct rx_call * rxcall, struct interfaceAddr * addr)
472 #if FSPROBE_CALLBACK_VERBOSE
473 static char rn[] = "SRXAFSCB_WhoAreYou"; /*Routine name */
474 char hostName[256]; /*Host name buffer */
475 char *hostNameResult; /*Ptr to static */
477 if (rxcall != (struct rx_call *)0) {
479 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
480 strcpy(hostName, hostNameResult);
481 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
482 hostName, rxcall->conn->peer->port);
483 } /*Valid rxcall param */
484 #endif /* FSPROBE_CALLBACK_VERBOSE */
486 if (rxcall && addr) {
489 *addr = afs_cb_interface;
493 * Return successfully.
499 /*------------------------------------------------------------------------
500 * EXPORTED SRXAFSCB_InitCallBackState3
503 * Routine called by the server-side callback RPC interface to
504 * implement clearing all callbacks from this host.
507 * rxcall : Ptr to Rx call on which this request came in.
513 * Nothing interesting.
517 *------------------------------------------------------------------------*/
520 SRXAFSCB_InitCallBackState3(struct rx_call * rxcall, afsUUID * uuidp)
522 #if FSPROBE_CALLBACK_VERBOSE
523 static char rn[] = "SRXAFSCB_InitCallBackState2"; /*Routine name */
524 char hostName[256]; /*Host name buffer */
525 char *hostNameResult; /*Ptr to static */
527 if (rxcall != (struct rx_call *)0) {
529 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
530 strcpy(hostName, hostNameResult);
531 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
532 hostName, rxcall->conn->peer->port);
533 } /*Valid rxcall param */
534 #endif /* FSPROBE_CALLBACK_VERBOSE */
537 * Return successfully.
543 /*------------------------------------------------------------------------
544 * EXPORTED SRXAFSCB_ProbeUuid
547 * Routine called by the server-side callback RPC interface to
548 * implement ``probing'' the Cache Manager, just making sure it's
549 * still there is still the same client it used to be.
552 * rxcall : Ptr to Rx call on which this request came in.
553 * uuidp : Ptr to UUID that must match the client's UUID.
556 * 0 if uuidp matches the UUID for this client
560 * Nothing interesting.
564 *------------------------------------------------------------------------*/
567 SRXAFSCB_ProbeUuid(struct rx_call * rxcall, afsUUID * uuidp)
571 #if FSPROBE_CALLBACK_VERBOSE
572 static char rn[] = "SRXAFSCB_ProbeUuid"; /*Routine name */
573 char hostName[256]; /*Host name buffer */
574 char *hostNameResult; /*Ptr to static */
576 if (rxcall != (struct rx_call *)0) {
578 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
579 strcpy(hostName, hostNameResult);
580 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
581 hostName, rxcall->conn->peer->port);
582 } /*Valid rxcall param */
583 #endif /* FSPROBE_CALLBACK_VERBOSE */
587 if (!afs_uuid_equal(uuidp, &afs_cb_interface.uuid))
588 code = 1; /* failure */
592 /*------------------------------------------------------------------------
593 * EXPORTED SRXAFSCB_GetServerPrefs
596 * Routine to list server preferences used by this client.
599 * a_call : Ptr to Rx call on which this request came in.
600 * a_index : Input server index
601 * a_srvr_addr : Output server address (0xffffffff on last server)
602 * a_srvr_rank : Output server rank
608 * Nothing interesting.
612 *------------------------------------------------------------------------*/
615 SRXAFSCB_GetServerPrefs(struct rx_call * a_call, afs_int32 a_index,
616 afs_int32 * a_srvr_addr, afs_int32 * a_srvr_rank)
618 *a_srvr_addr = 0xffffffff;
619 *a_srvr_rank = 0xffffffff;
623 /*------------------------------------------------------------------------
624 * EXPORTED SRXAFSCB_GetCellServDB
627 * Routine to list cells configured for this client
630 * a_call : Ptr to Rx call on which this request came in.
631 * a_index : Input cell index
632 * a_name : Output cell name ("" on last cell)
633 * a_hosts : Output cell database servers
636 * RXGEN_OPCODE (always)
639 * Nothing interesting.
643 *------------------------------------------------------------------------*/
646 SRXAFSCB_GetCellServDB(struct rx_call * a_call, afs_int32 a_index,
647 char **a_name, serverList * a_hosts)
653 SRXAFSCB_GetCellByNum(struct rx_call * a_call, afs_int32 a_cellnum,
654 char **a_name, serverList * a_hosts)
659 /*------------------------------------------------------------------------
660 * EXPORTED SRXAFSCB_GetLocalCell
663 * Routine to return name of client's local cell
666 * a_call : Ptr to Rx call on which this request came in.
667 * a_name : Output cell name
670 * RXGEN_OPCODE (always)
673 * Nothing interesting.
677 *------------------------------------------------------------------------*/
680 SRXAFSCB_GetLocalCell(struct rx_call * a_call, char **a_name)
686 /*------------------------------------------------------------------------
687 * EXPORTED SRXAFSCB_GetCacheConfig
690 * Routine to return parameters used to initialize client cache.
691 * Client may request any format version. Server may not return
692 * format version greater than version requested by client.
695 * a_call: Ptr to Rx call on which this request came in.
696 * callerVersion: Data format version desired by the client.
697 * serverVersion: Data format version of output data.
698 * configCount: Number bytes allocated for output data.
699 * config: Client cache configuration.
702 * RXGEN_OPCODE (always)
705 * Nothing interesting.
709 *------------------------------------------------------------------------*/
712 SRXAFSCB_GetCacheConfig(struct rx_call * a_call, afs_uint32 callerVersion,
713 afs_uint32 * serverVersion, afs_uint32 * configCount,
714 cacheConfig * config)
720 SRXAFSCB_TellMeAboutYourself(struct rx_call * rxcall,
721 struct interfaceAddr * addr,
722 Capabilities * capabilities)
724 #if FSPROBE_CALLBACK_VERBOSE
725 static char rn[] = "SRXAFSCB_TellMeAboutYourself"; /*Routine name */
726 char hostName[256]; /*Host name buffer */
727 char *hostNameResult; /*Ptr to static */
729 if (rxcall != (struct rx_call *)0) {
731 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
732 strcpy(hostName, hostNameResult);
733 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
734 hostName, rxcall->conn->peer->port);
735 } /*Valid rxcall param */
736 #endif /* FSPROBE_CALLBACK_VERBOSE */
738 if (rxcall && addr) {
741 *addr = afs_cb_interface;
745 * Return successfully.
750 int SRXAFSCB_GetDE(struct rx_call *a_call, afs_int32 a_index,
751 afs_int32 addr, afs_int32 inode, afs_int32 flags,
752 afs_int32 time, char ** fileName)