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)
497 #if XSTAT_FS_CALLBACK_VERBOSE
498 static char rn[] = "SRXAFSCB_WhoAreYou"; /*Routine name */
499 char hostName[256]; /*Host name buffer */
500 char *hostNameResult; /*Ptr to static */
502 if (rxcall != (struct rx_call *)0) {
504 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
505 strcpy(hostName, hostNameResult);
506 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
507 hostName, rxcall->conn->peer->port);
508 } /*Valid rxcall param */
509 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
511 if (rxcall && addr) {
514 *addr = afs_cb_interface;
518 * Return successfully.
524 /*------------------------------------------------------------------------
525 * EXPORTED SRXAFSCB_InitCallBackState3
528 * Routine called by the server-side callback RPC interface to
529 * implement clearing all callbacks from this host.
532 * rxcall : Ptr to Rx call on which this request came in.
538 * Nothing interesting.
542 *------------------------------------------------------------------------*/
545 SRXAFSCB_InitCallBackState3(struct rx_call * rxcall, afsUUID * uuidp)
547 #if XSTAT_FS_CALLBACK_VERBOSE
548 static char rn[] = "SRXAFSCB_InitCallBackState3"; /*Routine name */
549 char hostName[256]; /*Host name buffer */
550 char *hostNameResult; /*Ptr to static */
552 if (rxcall != (struct rx_call *)0) {
554 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
555 strcpy(hostName, hostNameResult);
556 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
557 hostName, rxcall->conn->peer->port);
558 } /*Valid rxcall param */
559 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
562 * Return successfully.
568 /*------------------------------------------------------------------------
569 * EXPORTED SRXAFSCB_ProbeUuid
572 * Routine called by the server-side callback RPC interface to
573 * implement ``probing'' the Cache Manager, just making sure it's
574 * still there is still the same client it used to be.
577 * rxcall : Ptr to Rx call on which this request came in.
578 * uuidp : Ptr to UUID that must match the client's UUID.
581 * 0 if uuidp matches the UUID for this client
585 * Nothing interesting.
589 *------------------------------------------------------------------------*/
592 SRXAFSCB_ProbeUuid(struct rx_call * rxcall, afsUUID * uuidp)
596 #if XSTAT_FS_CALLBACK_VERBOSE
597 static char rn[] = "SRXAFSCB_ProbeUuid"; /*Routine name */
598 char hostName[256]; /*Host name buffer */
599 char *hostNameResult; /*Ptr to static */
601 if (rxcall != (struct rx_call *)0) {
603 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
604 strcpy(hostName, hostNameResult);
605 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
606 hostName, rxcall->conn->peer->port);
607 } /*Valid rxcall param */
608 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
612 if (!afs_uuid_equal(uuidp, &afs_cb_interface.uuid))
613 code = 1; /* failure */
617 /*------------------------------------------------------------------------
618 * EXPORTED SRXAFSCB_GetServerPrefs
621 * Routine to list server preferences used by this client.
624 * a_call : Ptr to Rx call on which this request came in.
625 * a_index : Input server index
626 * a_srvr_addr : Output server address (0xffffffff on last server)
627 * a_srvr_rank : Output server rank
630 * RXGEN_OPCODE (always)
633 * Nothing interesting.
637 *------------------------------------------------------------------------*/
640 SRXAFSCB_GetServerPrefs(struct rx_call * a_call, afs_int32 a_index,
641 afs_int32 * a_srvr_addr, afs_int32 * a_srvr_rank)
646 /*------------------------------------------------------------------------
647 * EXPORTED SRXAFSCB_GetCellServDB
650 * Routine to list cells configured for this client
653 * a_call : Ptr to Rx call on which this request came in.
654 * a_index : Input cell index
655 * a_name : Output cell name ("" on last cell)
656 * a_hosts : Output cell database servers
662 * Nothing interesting.
666 *------------------------------------------------------------------------*/
669 SRXAFSCB_GetCellServDB(struct rx_call * a_call, afs_int32 a_index,
670 char **a_name, serverList * a_hosts)
677 SRXAFSCB_GetCellByNum(struct rx_call * a_call, afs_int32 a_cellnum,
678 char **a_name, serverList * a_hosts)
684 /*------------------------------------------------------------------------
685 * EXPORTED SRXAFSCB_GetLocalCell
688 * Routine to return name of client's local cell
691 * a_call : Ptr to Rx call on which this request came in.
692 * a_name : Output cell name
695 * RXGEN_OPCODE (always)
698 * Nothing interesting.
702 *------------------------------------------------------------------------*/
705 SRXAFSCB_GetLocalCell(struct rx_call * a_call, char **a_name)
709 t_name = (char *)malloc(AFSNAMEMAX);
712 strcpy(t_name, "This is xstat_fs");
718 /*------------------------------------------------------------------------
719 * EXPORTED SRXAFSCB_GetCacheConfig
722 * Routine to return parameters used to initialize client cache.
723 * Client may request any format version. Server may not return
724 * format version greater than version requested by client.
727 * a_call: Ptr to Rx call on which this request came in.
728 * callerVersion: Data format version desired by the client.
729 * serverVersion: Data format version of output data.
730 * configCount: Number bytes allocated for output data.
731 * config: Client cache configuration.
734 * RXGEN_OPCODE (always)
737 * Nothing interesting.
741 *------------------------------------------------------------------------*/
744 SRXAFSCB_GetCacheConfig(struct rx_call * a_call, afs_uint32 callerVersion,
745 afs_uint32 * serverVersion, afs_uint32 * configCount,
746 cacheConfig * config)
752 SRXAFSCB_TellMeAboutYourself(struct rx_call * rxcall,
753 struct interfaceAddr * addr,
754 Capabilities * capabilites)
760 #if XSTAT_FS_CALLBACK_VERBOSE
761 static char rn[] = "SRXAFSCB_TellMeAboutYourself"; /*Routine name */
762 char hostName[256]; /*Host name buffer */
763 char *hostNameResult; /*Ptr to static */
765 if (rxcall != (struct rx_call *)0) {
767 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
768 strcpy(hostName, hostNameResult);
769 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
770 hostName, rxcall->conn->peer->port);
771 } /*Valid rxcall param */
772 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
774 if (rxcall && addr) {
777 *addr = afs_cb_interface;
781 * Return successfully.
786 int SRXAFSCB_GetDE(a_call, a_index, addr, inode, flags, time, fileName)
787 struct rx_call *a_call;