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>
31 #include <stdio.h> /*Standard I/O stuff */
32 #include <afs/afscbint.h> /*Callback interface defs */
33 #include <afs/afsutil.h>
35 #define FSPROBE_CALLBACK_VERBOSE 0
37 int afs_cb_inited = 0;
38 struct interfaceAddr afs_cb_interface;
41 * Initialize the callback interface structure
48 afs_uuid_create(&afs_cb_interface.uuid);
49 count = rx_getAllAddr(&afs_cb_interface.addr_in, AFS_MAX_INTERFACE_ADDR);
51 afs_cb_interface.numberOfInterfaces = 0;
53 afs_cb_interface.numberOfInterfaces = count;
59 /*------------------------------------------------------------------------
63 * Handle a set of callbacks from the FileServer.
66 * struct rx_call *rxcall : Ptr to the associated Rx call structure.
67 * AFSCBFids *Fids_Array : Ptr to the set of Fids.
68 * AFSCBs *CallBacks_Array : Ptr to the set of callbacks.
72 * Error value otherwise.
75 * Nothing interesting.
79 *------------------------------------------------------------------------*/
82 SRXAFSCB_CallBack(struct rx_call * rxcall, AFSCBFids * Fids_Array,
83 AFSCBs * CallBack_Array)
84 { /*SRXAFSCB_CallBack */
86 #if FSPROBE_CALLBACK_VERBOSE
87 static char rn[] = "SRXAFSCB_CallBack"; /*Routine name */
88 char hostName[256]; /*Host name buffer */
89 char *hostNameResult; /*Ptr to static */
91 if (rxcall != (struct rx_call *)0) {
93 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
94 strcpy(hostName, hostNameResult);
95 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
96 hostName, rxcall->conn->peer->port);
97 } /*Valid rxcall param */
98 #endif /* FSPROBE_CALLBACK_VERBOSE */
101 * Return successfully.
105 } /*SRXAFSCB_CallBack */
108 /*------------------------------------------------------------------------
109 * SRXAFSCB_InitCallBackState
112 * Initialize callback state on this ``Cache Manager''.
115 * struct rx_call *rxcall : Ptr to the associated Rx call structure.
119 * Error value otherwise.
122 * This will definitely be called by the FileServer (exactly once),
123 * since it will think we are another new ``Cache Manager''.
127 *------------------------------------------------------------------------*/
130 SRXAFSCB_InitCallBackState(struct rx_call * rxcall)
131 { /*SRXAFSCB_InitCallBackState */
133 #if FSPROBE_CALLBACK_VERBOSE
134 static char rn[] = "SRXAFSCB_InitCallBackState"; /*Routine name */
135 char hostName[256]; /*Host name buffer */
136 char *hostNameResult; /*Ptr to static */
138 if (rxcall != (struct rx_call *)0) {
140 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
141 strcpy(hostName, hostNameResult);
142 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
143 hostName, rxcall->conn->peer->port);
144 } /*Valid rxcall param */
145 #endif /* FSPROBE_CALLBACK_VERBOSE */
148 * Return successfully.
152 } /*SRXAFSCB_InitCallBackState */
155 /*------------------------------------------------------------------------
159 * Respond to a probe from the FileServer. If a FileServer doesn't
160 * hear from you every so often, it will send you a probe to make
161 * sure you're there, just like any other ``Cache Manager'' it's
165 * struct rx_call *rxcall : Ptr to the associated Rx call structure.
169 * Error value otherwise.
172 * This may be called by the FileServer if we don't call it often
177 *------------------------------------------------------------------------*/
180 SRXAFSCB_Probe(struct rx_call * rxcall)
181 { /*SRXAFSCB_Probe */
183 #if FSPROBE_CALLBACK_VERBOSE
184 static char rn[] = "SRXAFSCB_Probe"; /*Routine name */
185 char hostName[256]; /*Host name buffer */
186 char *hostNameResult; /*Ptr to static */
188 if (rxcall != (struct rx_call *)0) {
190 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
191 strcpy(hostName, hostNameResult);
192 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
193 hostName, rxcall->conn->peer->port);
194 } /*Valid rxcall param */
195 #endif /* FSPROBE_CALLBACK_VERBOSE */
198 * Return successfully.
202 } /*SRXAFSCB_Probe */
205 /*------------------------------------------------------------------------
209 * Respond minimally to a request for returning the contents of
210 * a cache entry, since someone out there thinks you're a Cache
214 * struct rx_call *rxcall: Ptr to the associated Rx call structure.
220 * Nothing interesting.
224 *------------------------------------------------------------------------*/
227 SRXAFSCB_GetCE64(struct rx_call * rxcall, afs_int32 index,
228 AFSDBCacheEntry64 * ce)
229 { /*SRXAFSCB_GetCE64 */
231 #if XSTAT_FS_CALLBACK_VERBOSE
232 static char rn[] = "SRXAFSCB_GetCE64"; /*Routine name */
233 char hostName[256]; /*Host name buffer */
234 char *hostNameResult; /*Ptr to static */
236 if (rxcall != (struct rx_call *)0) {
238 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
239 strcpy(hostName, hostNameResult);
240 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
241 hostName, rxcall->conn->peer->port);
242 } /*Valid rxcall param */
243 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
247 } /*SRXAFSCB_GetCE64 */
250 SRXAFSCB_GetCE(struct rx_call * rxcall, afs_int32 index, AFSDBCacheEntry * ce)
251 { /*SRXAFSCB_GetCE */
253 #if XSTAT_FS_CALLBACK_VERBOSE
254 static char rn[] = "SRXAFSCB_GetCE"; /*Routine name */
255 char hostName[256]; /*Host name buffer */
256 char *hostNameResult; /*Ptr to static */
258 if (rxcall != (struct rx_call *)0) {
260 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
261 strcpy(hostName, hostNameResult);
262 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
263 hostName, rxcall->conn->peer->port);
264 } /*Valid rxcall param */
265 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
269 } /*SRXAFSCB_GetCE */
272 /*------------------------------------------------------------------------
276 * Respond minimally to a request for returning the contents of
277 * a cache lock, since someone out there thinks you're a Cache
281 * struct rx_call *rxcall: Ptr to the associated Rx call structure.
287 * Nothing interesting.
291 *------------------------------------------------------------------------*/
294 SRXAFSCB_GetLock(struct rx_call * rxcall, afs_int32 index, AFSDBLock * lock)
295 { /*SRXAFSCB_GetLock */
297 #if XSTAT_FS_CALLBACK_VERBOSE
298 static char rn[] = "SRXAFSCB_GetLock"; /*Routine name */
299 char hostName[256]; /*Host name buffer */
300 char *hostNameResult; /*Ptr to static */
302 if (rxcall != (struct rx_call *)0) {
304 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
305 strcpy(hostName, hostNameResult);
306 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
307 hostName, rxcall->conn->peer->port);
308 } /*Valid rxcall param */
309 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
313 } /*SRXAFSCB_GetLock */
316 /*------------------------------------------------------------------------
317 * SRXAFSCB_XStatsVersion
320 * Respond minimally to a request for fetching the version of
321 * extended Cache Manager statistics offered, since someone out
322 * there thinks you're a Cache Manager.
325 * struct rx_call *rxcall: Ptr to the associated Rx call structure.
331 * Nothing interesting.
335 *------------------------------------------------------------------------*/
338 SRXAFSCB_XStatsVersion(struct rx_call * rxcall, afs_int32 * versionNumberP)
339 { /*SRXAFSCB_XStatsVersion */
341 #if XSTAT_FS_CALLBACK_VERBOSE
342 static char rn[] = "SRXAFSCB_XStatsVersion"; /*Routine name */
343 char hostName[256]; /*Host name buffer */
344 char *hostNameResult; /*Ptr to static */
346 if (rxcall != (struct rx_call *)0) {
348 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
349 strcpy(hostName, hostNameResult);
350 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
351 hostName, rxcall->conn->peer->port);
352 } /*Valid rxcall param */
353 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
357 } /*SRXAFSCB_XStatsVersion */
360 /*------------------------------------------------------------------------
364 * Respond minimally to a request for returning extended
365 * statistics for a Cache Manager, since someone out there thinks
366 * you're a Cache Manager.
369 * struct rx_call *rxcall: Ptr to the associated Rx call structure.
375 * Nothing interesting.
379 *------------------------------------------------------------------------*/
382 SRXAFSCB_GetXStats(struct rx_call * rxcall, afs_int32 clientVN,
383 afs_int32 collN, afs_int32 * srvVNP, afs_int32 * timeP,
384 AFSCB_CollData * dataP)
385 { /*SRXAFSCB_GetXStats */
387 #if XSTAT_FS_CALLBACK_VERBOSE
388 static char rn[] = "SRXAFSCB_GetXStats"; /*Routine name */
389 char hostName[256]; /*Host name buffer */
390 char *hostNameResult; /*Ptr to static */
392 if (rxcall != (struct rx_call *)0) {
394 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
395 strcpy(hostName, hostNameResult);
396 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
397 hostName, rxcall->conn->peer->port);
398 } /*Valid rxcall param */
399 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
403 } /*SRXAFSCB_GetXStats */
405 /*------------------------------------------------------------------------
406 * EXPORTED SRXAFSCB_InitCallBackState2
409 * This routine was used in the AFS 3.5 beta release, but not anymore.
410 * It has since been replaced by SRXAFSCB_InitCallBackState3.
413 * rxcall : Ptr to Rx call on which this request came in.
416 * RXGEN_OPCODE (always).
419 * Nothing interesting.
423 *------------------------------------------------------------------------*/
426 SRXAFSCB_InitCallBackState2(struct rx_call * rxcall,
427 struct interfaceAddr * addr)
430 #if FSPROBE_CALLBACK_VERBOSE
431 static char rn[] = "SRXAFSCB_InitCallBackState2"; /*Routine name */
432 char hostName[256]; /*Host name buffer */
433 char *hostNameResult; /*Ptr to static */
435 if (rxcall != (struct rx_call *)0) {
437 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
438 strcpy(hostName, hostNameResult);
439 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
440 hostName, rxcall->conn->peer->port);
441 } /*Valid rxcall param */
442 #endif /* FSPROBE_CALLBACK_VERBOSE */
446 /*------------------------------------------------------------------------
447 * EXPORTED SRXAFSCB_WhoAreYou
450 * Routine called by the server-side callback RPC interface to
451 * obtain a unique identifier for the client. The server uses
452 * this identifier to figure out whether or not two RX connections
453 * are from the same client, and to find out which addresses go
454 * with which clients.
457 * rxcall : Ptr to Rx call on which this request came in.
458 * addr: Ptr to return the list of interfaces for this client.
464 * Nothing interesting.
468 *------------------------------------------------------------------------*/
471 SRXAFSCB_WhoAreYou(struct rx_call * rxcall, struct interfaceAddr * addr)
474 #if FSPROBE_CALLBACK_VERBOSE
475 static char rn[] = "SRXAFSCB_WhoAreYou"; /*Routine name */
476 char hostName[256]; /*Host name buffer */
477 char *hostNameResult; /*Ptr to static */
479 if (rxcall != (struct rx_call *)0) {
481 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
482 strcpy(hostName, hostNameResult);
483 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
484 hostName, rxcall->conn->peer->port);
485 } /*Valid rxcall param */
486 #endif /* FSPROBE_CALLBACK_VERBOSE */
488 if (rxcall && addr) {
491 *addr = afs_cb_interface;
495 * Return successfully.
501 /*------------------------------------------------------------------------
502 * EXPORTED SRXAFSCB_InitCallBackState3
505 * Routine called by the server-side callback RPC interface to
506 * implement clearing all callbacks from this host.
509 * rxcall : Ptr to Rx call on which this request came in.
515 * Nothing interesting.
519 *------------------------------------------------------------------------*/
522 SRXAFSCB_InitCallBackState3(struct rx_call * rxcall, afsUUID * uuidp)
524 #if FSPROBE_CALLBACK_VERBOSE
525 static char rn[] = "SRXAFSCB_InitCallBackState2"; /*Routine name */
526 char hostName[256]; /*Host name buffer */
527 char *hostNameResult; /*Ptr to static */
529 if (rxcall != (struct rx_call *)0) {
531 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
532 strcpy(hostName, hostNameResult);
533 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
534 hostName, rxcall->conn->peer->port);
535 } /*Valid rxcall param */
536 #endif /* FSPROBE_CALLBACK_VERBOSE */
539 * Return successfully.
545 /*------------------------------------------------------------------------
546 * EXPORTED SRXAFSCB_ProbeUuid
549 * Routine called by the server-side callback RPC interface to
550 * implement ``probing'' the Cache Manager, just making sure it's
551 * still there is still the same client it used to be.
554 * rxcall : Ptr to Rx call on which this request came in.
555 * uuidp : Ptr to UUID that must match the client's UUID.
558 * 0 if uuidp matches the UUID for this client
562 * Nothing interesting.
566 *------------------------------------------------------------------------*/
569 SRXAFSCB_ProbeUuid(struct rx_call * rxcall, afsUUID * uuidp)
573 #if FSPROBE_CALLBACK_VERBOSE
574 static char rn[] = "SRXAFSCB_ProbeUuid"; /*Routine name */
575 char hostName[256]; /*Host name buffer */
576 char *hostNameResult; /*Ptr to static */
578 if (rxcall != (struct rx_call *)0) {
580 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
581 strcpy(hostName, hostNameResult);
582 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
583 hostName, rxcall->conn->peer->port);
584 } /*Valid rxcall param */
585 #endif /* FSPROBE_CALLBACK_VERBOSE */
589 if (!afs_uuid_equal(uuidp, &afs_cb_interface.uuid))
590 code = 1; /* failure */
594 /*------------------------------------------------------------------------
595 * EXPORTED SRXAFSCB_GetServerPrefs
598 * Routine to list server preferences used by this client.
601 * a_call : Ptr to Rx call on which this request came in.
602 * a_index : Input server index
603 * a_srvr_addr : Output server address (0xffffffff on last server)
604 * a_srvr_rank : Output server rank
610 * Nothing interesting.
614 *------------------------------------------------------------------------*/
617 SRXAFSCB_GetServerPrefs(struct rx_call * a_call, afs_int32 a_index,
618 afs_int32 * a_srvr_addr, afs_int32 * a_srvr_rank)
620 *a_srvr_addr = 0xffffffff;
621 *a_srvr_rank = 0xffffffff;
625 /*------------------------------------------------------------------------
626 * EXPORTED SRXAFSCB_GetCellServDB
629 * Routine to list cells configured for this client
632 * a_call : Ptr to Rx call on which this request came in.
633 * a_index : Input cell index
634 * a_name : Output cell name ("" on last cell)
635 * a_hosts : Output cell database servers
638 * RXGEN_OPCODE (always)
641 * Nothing interesting.
645 *------------------------------------------------------------------------*/
648 SRXAFSCB_GetCellServDB(struct rx_call * a_call, afs_int32 a_index,
649 char **a_name, serverList * a_hosts)
655 SRXAFSCB_GetCellByNum(struct rx_call * a_call, afs_int32 a_cellnum,
656 char **a_name, serverList * a_hosts)
661 /*------------------------------------------------------------------------
662 * EXPORTED SRXAFSCB_GetLocalCell
665 * Routine to return name of client's local cell
668 * a_call : Ptr to Rx call on which this request came in.
669 * a_name : Output cell name
672 * RXGEN_OPCODE (always)
675 * Nothing interesting.
679 *------------------------------------------------------------------------*/
682 SRXAFSCB_GetLocalCell(struct rx_call * a_call, char **a_name)
688 /*------------------------------------------------------------------------
689 * EXPORTED SRXAFSCB_GetCacheConfig
692 * Routine to return parameters used to initialize client cache.
693 * Client may request any format version. Server may not return
694 * format version greater than version requested by client.
697 * a_call: Ptr to Rx call on which this request came in.
698 * callerVersion: Data format version desired by the client.
699 * serverVersion: Data format version of output data.
700 * configCount: Number bytes allocated for output data.
701 * config: Client cache configuration.
704 * RXGEN_OPCODE (always)
707 * Nothing interesting.
711 *------------------------------------------------------------------------*/
714 SRXAFSCB_GetCacheConfig(struct rx_call * a_call, afs_uint32 callerVersion,
715 afs_uint32 * serverVersion, afs_uint32 * configCount,
716 cacheConfig * config)
722 SRXAFSCB_TellMeAboutYourself(struct rx_call * rxcall,
723 struct interfaceAddr * addr,
724 Capabilities * capabilities)
726 #if FSPROBE_CALLBACK_VERBOSE
727 static char rn[] = "SRXAFSCB_TellMeAboutYourself"; /*Routine name */
728 char hostName[256]; /*Host name buffer */
729 char *hostNameResult; /*Ptr to static */
731 if (rxcall != (struct rx_call *)0) {
733 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
734 strcpy(hostName, hostNameResult);
735 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
736 hostName, rxcall->conn->peer->port);
737 } /*Valid rxcall param */
738 #endif /* FSPROBE_CALLBACK_VERBOSE */
740 if (rxcall && addr) {
743 *addr = afs_cb_interface;
747 * Return successfully.
752 int SRXAFSCB_GetDE(a_call, a_index, addr, inode, flags, time, fileName)
753 struct rx_call *a_call;