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 xstat_fs callback routines. These are the
13 * server-side functions that the File Server expects to invoke on
14 * the client machine via the afsint interface. In this case, the
15 * client process is acting as a callback listener, so it has to
16 * be prepared to answer these calls.
19 * The afsint server stubs expect the functions defined here to
20 * be provided. There is no .h file for this code, since the
21 * linker really does all the work for us, and these don't really
22 * need to be ``visible'' to anyone else.
23 *------------------------------------------------------------------------*/
25 #include <afsconfig.h>
26 #include <afs/param.h>
36 #include <stdio.h> /*Standard I/O stuff */
39 #include <afs/afscbint.h> /*Callback interface defs */
41 int afs_cb_inited = 0;
42 struct interfaceAddr afs_cb_interface;
44 #define XSTAT_FS_CALLBACK_VERBOSE 0
47 * Initialize the callback interface structure
55 UuidCreate((UUID *)&afs_cb_interface.uuid);
57 afs_uuid_create(&afs_cb_interface.uuid);
59 count = rx_getAllAddr(&afs_cb_interface.addr_in, AFS_MAX_INTERFACE_ADDR);
61 afs_cb_interface.numberOfInterfaces = 0;
63 afs_cb_interface.numberOfInterfaces = count;
69 * Routines we need that don't have explicit include file definitions.
71 extern char *hostutil_GetNameByINet(); /*Host parsing utility */
73 static char mn[] = "xstat_fs_callback"; /*Module name */
75 /*------------------------------------------------------------------------
79 * Handle a set of callbacks from the File Server.
82 * struct rx_call *rxcall : Ptr to the associated Rx call structure.
83 * AFSCBFids *Fids_Array : Ptr to the set of Fids.
84 * AFSCBs *CallBacks_Array : Ptr to the set of callbacks.
88 * Error value otherwise.
91 * Nothing interesting.
95 *------------------------------------------------------------------------*/
98 SRXAFSCB_CallBack(struct rx_call *rxcall, AFSCBFids * Fids_Array,
99 AFSCBs * CallBack_Array)
100 { /*SRXAFSCB_CallBack */
102 #if XSTAT_FS_CALLBACK_VERBOSE
103 static char rn[] = "SRXAFSCB_CallBack"; /*Routine name */
104 char hostName[256]; /*Host name buffer */
105 char *hostNameResult; /*Ptr to static */
107 fprintf(stderr, "[%s:%s] Called\n", mn, rn);
109 if (rxcall != (struct rx_call *)0) {
111 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
112 strcpy(hostName, hostNameResult);
113 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
114 hostName, rxcall->conn->peer->port);
115 } /*Valid rxcall param */
116 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
119 * Return successfully.
123 } /*SRXAFSCB_CallBack */
125 /*------------------------------------------------------------------------
126 * SRXAFSCB_InitCallBackState
129 * Initialize callback state on this ``Cache Manager''.
132 * struct rx_call *rxcall : Ptr to the associated Rx call structure.
136 * Error value otherwise.
139 * This will definitely be called by the File Server (exactly once),
140 * since it will think we are another new ``Cache Manager''.
144 *------------------------------------------------------------------------*/
147 SRXAFSCB_InitCallBackState(struct rx_call * rxcall)
148 { /*SRXAFSCB_InitCallBackState */
150 #if XSTAT_FS_CALLBACK_VERBOSE
151 static char rn[] = "SRXAFSCB_InitCallBackState"; /*Routine name */
152 char hostName[256]; /*Host name buffer */
153 char *hostNameResult; /*Ptr to static */
155 fprintf(stderr, "[%s:%s] Called\n", mn, rn);
157 if (rxcall != (struct rx_call *)0) {
159 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
160 strcpy(hostName, hostNameResult);
161 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
162 hostName, rxcall->conn->peer->port);
163 } /*Valid rxcall param */
164 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
167 * Return successfully.
171 } /*SRXAFSCB_InitCallBackState */
173 /*------------------------------------------------------------------------
177 * Respond to a probe from the File Server. If a File Server
178 * doesn't hear from you every so often, it will send you a probe
179 * to make sure you're there, just like any other ``Cache Manager''
180 * it's keeping track of.
183 * struct rx_call *rxcall : Ptr to the associated Rx call structure.
187 * Error value otherwise.
190 * This may be called by the File Server if we don't call it often
195 *------------------------------------------------------------------------*/
198 SRXAFSCB_Probe(struct rx_call * rxcall)
199 { /*SRXAFSCB_Probe */
201 #if XSTAT_FS_CALLBACK_VERBOSE
202 static char rn[] = "SRXAFSCB_Probe"; /*Routine name */
203 char hostName[256]; /*Host name buffer */
204 char *hostNameResult; /*Ptr to static */
206 fprintf(stderr, "[%s:%s] Called\n", mn, rn);
208 if (rxcall != (struct rx_call *)0) {
210 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
211 strcpy(hostName, hostNameResult);
212 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
213 hostName, rxcall->conn->peer->port);
214 } /*Valid rxcall param */
215 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
218 * Return successfully.
222 } /*SRXAFSCB_Probe */
225 /*------------------------------------------------------------------------
229 * Respond minimally to a request for returning the contents of
230 * a cache entry, since someone out there thinks you're a Cache
234 * struct rx_call *rxcall: Ptr to the associated Rx call structure.
240 * Nothing interesting.
244 *------------------------------------------------------------------------*/
247 SRXAFSCB_GetCE64(struct rx_call * rxcall, afs_int32 index,
248 AFSDBCacheEntry64 * ce)
249 { /*SRXAFSCB_GetCE64 */
251 #if XSTAT_FS_CALLBACK_VERBOSE
252 static char rn[] = "SRXAFSCB_GetCE64"; /*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_GetCE64 */
270 SRXAFSCB_GetCE(struct rx_call * rxcall, afs_int32 index, AFSDBCacheEntry * ce)
271 { /*SRXAFSCB_GetCE */
273 #if XSTAT_FS_CALLBACK_VERBOSE
274 static char rn[] = "SRXAFSCB_GetCE"; /*Routine name */
275 char hostName[256]; /*Host name buffer */
276 char *hostNameResult; /*Ptr to static */
278 if (rxcall != (struct rx_call *)0) {
280 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
281 strcpy(hostName, hostNameResult);
282 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
283 hostName, rxcall->conn->peer->port);
284 } /*Valid rxcall param */
285 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
289 } /*SRXAFSCB_GetCE */
292 /*------------------------------------------------------------------------
296 * Respond minimally to a request for returning the contents of
297 * a cache lock, since someone out there thinks you're a Cache
301 * struct rx_call *rxcall: Ptr to the associated Rx call structure.
307 * Nothing interesting.
311 *------------------------------------------------------------------------*/
314 SRXAFSCB_GetLock(struct rx_call * rxcall, afs_int32 index, AFSDBLock * lock)
315 { /*SRXAFSCB_GetLock */
317 #if XSTAT_FS_CALLBACK_VERBOSE
318 static char rn[] = "SRXAFSCB_GetLock"; /*Routine name */
319 char hostName[256]; /*Host name buffer */
320 char *hostNameResult; /*Ptr to static */
322 if (rxcall != (struct rx_call *)0) {
324 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
325 strcpy(hostName, hostNameResult);
326 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
327 hostName, rxcall->conn->peer->port);
328 } /*Valid rxcall param */
329 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
333 } /*SRXAFSCB_GetLock */
336 /*------------------------------------------------------------------------
337 * SRXAFSCB_XStatsVersion
340 * Respond minimally to a request for fetching the version of
341 * extended Cache Manager statistics offered, since someone out
342 * there thinks you're a Cache Manager.
345 * struct rx_call *rxcall: Ptr to the associated Rx call structure.
351 * Nothing interesting.
355 *------------------------------------------------------------------------*/
358 SRXAFSCB_XStatsVersion(struct rx_call * rxcall, afs_int32 * versionNumberP)
359 { /*SRXAFSCB_XStatsVersion */
361 #if XSTAT_FS_CALLBACK_VERBOSE
362 static char rn[] = "SRXAFSCB_XStatsVersion"; /*Routine name */
363 char hostName[256]; /*Host name buffer */
364 char *hostNameResult; /*Ptr to static */
366 if (rxcall != (struct rx_call *)0) {
368 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
369 strcpy(hostName, hostNameResult);
370 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
371 hostName, rxcall->conn->peer->port);
372 } /*Valid rxcall param */
373 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
377 } /*SRXAFSCB_XStatsVersion */
380 /*------------------------------------------------------------------------
384 * Respond minimally to a request for returning extended
385 * statistics for a Cache Manager, since someone out there thinks
386 * you're a Cache Manager.
389 * struct rx_call *rxcall: Ptr to the associated Rx call structure.
395 * Nothing interesting.
399 *------------------------------------------------------------------------*/
402 SRXAFSCB_GetXStats(struct rx_call * rxcall, afs_int32 clientVersionNumber,
403 afs_int32 collectionNumber, afs_int32 * srvVersionNumberP,
404 afs_int32 * timeP, AFSCB_CollData * dataP)
405 { /*SRXAFSCB_GetXStats */
407 #if XSTAT_FS_CALLBACK_VERBOSE
408 static char rn[] = "SRXAFSCB_GetXStats"; /*Routine name */
409 char hostName[256]; /*Host name buffer */
410 char *hostNameResult; /*Ptr to static */
412 if (rxcall != (struct rx_call *)0) {
414 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
415 strcpy(hostName, hostNameResult);
416 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
417 hostName, rxcall->conn->peer->port);
418 } /*Valid rxcall param */
419 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
423 } /*SRXAFSCB_GetXStats */
425 /*------------------------------------------------------------------------
426 * EXPORTED SRXAFSCB_InitCallBackState2
429 * This routine was used in the AFS 3.5 beta release, but not anymore.
430 * It has since been replaced by SRXAFSCB_InitCallBackState3.
433 * rxcall : Ptr to Rx call on which this request came in.
436 * RXGEN_OPCODE (always).
439 * Nothing interesting.
443 *------------------------------------------------------------------------*/
446 SRXAFSCB_InitCallBackState2(struct rx_call * rxcall,
447 struct interfaceAddr * addr)
450 #if XSTAT_FS_CALLBACK_VERBOSE
451 static char rn[] = "SRXAFSCB_InitCallBackState2"; /*Routine name */
452 char hostName[256]; /*Host name buffer */
453 char *hostNameResult; /*Ptr to static */
455 if (rxcall != (struct rx_call *)0) {
457 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
458 strcpy(hostName, hostNameResult);
459 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
460 hostName, rxcall->conn->peer->port);
461 } /*Valid rxcall param */
462 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
466 /*------------------------------------------------------------------------
467 * EXPORTED SRXAFSCB_WhoAreYou
470 * Routine called by the server-side callback RPC interface to
471 * obtain a unique identifier for the client. The server uses
472 * this identifier to figure out whether or not two RX connections
473 * are from the same client, and to find out which addresses go
474 * with which clients.
477 * rxcall : Ptr to Rx call on which this request came in.
478 * addr: Ptr to return the list of interfaces for this client.
484 * Nothing interesting.
488 *------------------------------------------------------------------------*/
491 SRXAFSCB_WhoAreYou(struct rx_call * rxcall, struct interfaceAddr * addr)
495 #if XSTAT_FS_CALLBACK_VERBOSE
496 static char rn[] = "SRXAFSCB_WhoAreYou"; /*Routine name */
497 char hostName[256]; /*Host name buffer */
498 char *hostNameResult; /*Ptr to static */
500 if (rxcall != (struct rx_call *)0) {
502 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
503 strcpy(hostName, hostNameResult);
504 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
505 hostName, rxcall->conn->peer->port);
506 } /*Valid rxcall param */
507 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
509 if (rxcall && addr) {
512 *addr = afs_cb_interface;
516 * Return successfully.
522 /*------------------------------------------------------------------------
523 * EXPORTED SRXAFSCB_InitCallBackState3
526 * Routine called by the server-side callback RPC interface to
527 * implement clearing all callbacks from this host.
530 * rxcall : Ptr to Rx call on which this request came in.
536 * Nothing interesting.
540 *------------------------------------------------------------------------*/
543 SRXAFSCB_InitCallBackState3(struct rx_call * rxcall, afsUUID * uuidp)
545 #if XSTAT_FS_CALLBACK_VERBOSE
546 static char rn[] = "SRXAFSCB_InitCallBackState3"; /*Routine name */
547 char hostName[256]; /*Host name buffer */
548 char *hostNameResult; /*Ptr to static */
550 if (rxcall != (struct rx_call *)0) {
552 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
553 strcpy(hostName, hostNameResult);
554 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
555 hostName, rxcall->conn->peer->port);
556 } /*Valid rxcall param */
557 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
560 * Return successfully.
566 /*------------------------------------------------------------------------
567 * EXPORTED SRXAFSCB_ProbeUuid
570 * Routine called by the server-side callback RPC interface to
571 * implement ``probing'' the Cache Manager, just making sure it's
572 * still there is still the same client it used to be.
575 * rxcall : Ptr to Rx call on which this request came in.
576 * uuidp : Ptr to UUID that must match the client's UUID.
579 * 0 if uuidp matches the UUID for this client
583 * Nothing interesting.
587 *------------------------------------------------------------------------*/
590 SRXAFSCB_ProbeUuid(struct rx_call * rxcall, afsUUID * uuidp)
594 #if XSTAT_FS_CALLBACK_VERBOSE
595 static char rn[] = "SRXAFSCB_ProbeUuid"; /*Routine name */
596 char hostName[256]; /*Host name buffer */
597 char *hostNameResult; /*Ptr to static */
599 if (rxcall != (struct rx_call *)0) {
601 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
602 strcpy(hostName, hostNameResult);
603 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
604 hostName, rxcall->conn->peer->port);
605 } /*Valid rxcall param */
606 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
610 if (!afs_uuid_equal(uuidp, &afs_cb_interface.uuid))
611 code = 1; /* failure */
615 /*------------------------------------------------------------------------
616 * EXPORTED SRXAFSCB_GetServerPrefs
619 * Routine to list server preferences used by this client.
622 * a_call : Ptr to Rx call on which this request came in.
623 * a_index : Input server index
624 * a_srvr_addr : Output server address (0xffffffff on last server)
625 * a_srvr_rank : Output server rank
628 * RXGEN_OPCODE (always)
631 * Nothing interesting.
635 *------------------------------------------------------------------------*/
638 SRXAFSCB_GetServerPrefs(struct rx_call * a_call, afs_int32 a_index,
639 afs_int32 * a_srvr_addr, afs_int32 * a_srvr_rank)
644 /*------------------------------------------------------------------------
645 * EXPORTED SRXAFSCB_GetCellServDB
648 * Routine to list cells configured for this client
651 * a_call : Ptr to Rx call on which this request came in.
652 * a_index : Input cell index
653 * a_name : Output cell name ("" on last cell)
654 * a_hosts : Output cell database servers
660 * Nothing interesting.
664 *------------------------------------------------------------------------*/
667 SRXAFSCB_GetCellServDB(struct rx_call * a_call, afs_int32 a_index,
668 char **a_name, serverList * a_hosts)
675 SRXAFSCB_GetCellByNum(struct rx_call * a_call, afs_int32 a_cellnum,
676 char **a_name, serverList * a_hosts)
682 /*------------------------------------------------------------------------
683 * EXPORTED SRXAFSCB_GetLocalCell
686 * Routine to return name of client's local cell
689 * a_call : Ptr to Rx call on which this request came in.
690 * a_name : Output cell name
693 * RXGEN_OPCODE (always)
696 * Nothing interesting.
700 *------------------------------------------------------------------------*/
703 SRXAFSCB_GetLocalCell(struct rx_call * a_call, char **a_name)
707 t_name = (char *)malloc(AFSNAMEMAX);
710 strcpy(t_name, "This is xstat_fs");
716 /*------------------------------------------------------------------------
717 * EXPORTED SRXAFSCB_GetCacheConfig
720 * Routine to return parameters used to initialize client cache.
721 * Client may request any format version. Server may not return
722 * format version greater than version requested by client.
725 * a_call: Ptr to Rx call on which this request came in.
726 * callerVersion: Data format version desired by the client.
727 * serverVersion: Data format version of output data.
728 * configCount: Number bytes allocated for output data.
729 * config: Client cache configuration.
732 * RXGEN_OPCODE (always)
735 * Nothing interesting.
739 *------------------------------------------------------------------------*/
742 SRXAFSCB_GetCacheConfig(struct rx_call * a_call, afs_uint32 callerVersion,
743 afs_uint32 * serverVersion, afs_uint32 * configCount,
744 cacheConfig * config)
750 SRXAFSCB_TellMeAboutYourself(struct rx_call * rxcall,
751 struct interfaceAddr * addr,
752 Capabilities * capabilites)
756 #if XSTAT_FS_CALLBACK_VERBOSE
757 static char rn[] = "SRXAFSCB_TellMeAboutYourself"; /*Routine name */
758 char hostName[256]; /*Host name buffer */
759 char *hostNameResult; /*Ptr to static */
761 if (rxcall != (struct rx_call *)0) {
763 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
764 strcpy(hostName, hostNameResult);
765 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
766 hostName, rxcall->conn->peer->port);
767 } /*Valid rxcall param */
768 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
770 if (rxcall && addr) {
773 *addr = afs_cb_interface;
777 * Return successfully.
782 int SRXAFSCB_GetDE(a_call, a_index, addr, inode, flags, time, fileName)
783 struct rx_call *a_call;