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>
32 #include <stdio.h> /*Standard I/O stuff */
42 #include <afs/afscbint.h> /*Callback interface defs */
44 int afs_cb_inited = 0;
45 struct interfaceAddr afs_cb_interface;
47 #define XSTAT_FS_CALLBACK_VERBOSE 0
50 * Initialize the callback interface structure
57 afs_uuid_create(&afs_cb_interface.uuid);
58 count = rx_getAllAddr(&afs_cb_interface.addr_in, AFS_MAX_INTERFACE_ADDR);
60 afs_cb_interface.numberOfInterfaces = 0;
62 afs_cb_interface.numberOfInterfaces = count;
68 * Routines we need that don't have explicit include file definitions.
70 extern char *hostutil_GetNameByINet(); /*Host parsing utility */
72 static char mn[] = "xstat_fs_callback"; /*Module name */
74 /*------------------------------------------------------------------------
78 * Handle a set of callbacks from the File Server.
81 * struct rx_call *rxcall : Ptr to the associated Rx call structure.
82 * AFSCBFids *Fids_Array : Ptr to the set of Fids.
83 * AFSCBs *CallBacks_Array : Ptr to the set of callbacks.
87 * Error value otherwise.
90 * Nothing interesting.
94 *------------------------------------------------------------------------*/
97 SRXAFSCB_CallBack(struct rx_call *rxcall, AFSCBFids * Fids_Array,
98 AFSCBs * CallBack_Array)
99 { /*SRXAFSCB_CallBack */
101 #if XSTAT_FS_CALLBACK_VERBOSE
102 static char rn[] = "SRXAFSCB_CallBack"; /*Routine name */
103 char hostName[256]; /*Host name buffer */
104 char *hostNameResult; /*Ptr to static */
106 fprintf(stderr, "[%s:%s] Called\n", mn, rn);
108 if (rxcall != (struct rx_call *)0) {
110 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
111 strcpy(hostName, hostNameResult);
112 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
113 hostName, rxcall->conn->peer->port);
114 } /*Valid rxcall param */
115 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
118 * Return successfully.
122 } /*SRXAFSCB_CallBack */
124 /*------------------------------------------------------------------------
125 * SRXAFSCB_InitCallBackState
128 * Initialize callback state on this ``Cache Manager''.
131 * struct rx_call *rxcall : Ptr to the associated Rx call structure.
135 * Error value otherwise.
138 * This will definitely be called by the File Server (exactly once),
139 * since it will think we are another new ``Cache Manager''.
143 *------------------------------------------------------------------------*/
146 SRXAFSCB_InitCallBackState(struct rx_call * rxcall)
147 { /*SRXAFSCB_InitCallBackState */
149 #if XSTAT_FS_CALLBACK_VERBOSE
150 static char rn[] = "SRXAFSCB_InitCallBackState"; /*Routine name */
151 char hostName[256]; /*Host name buffer */
152 char *hostNameResult; /*Ptr to static */
154 fprintf(stderr, "[%s:%s] Called\n", mn, rn);
156 if (rxcall != (struct rx_call *)0) {
158 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
159 strcpy(hostName, hostNameResult);
160 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
161 hostName, rxcall->conn->peer->port);
162 } /*Valid rxcall param */
163 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
166 * Return successfully.
170 } /*SRXAFSCB_InitCallBackState */
172 /*------------------------------------------------------------------------
176 * Respond to a probe from the File Server. If a File Server
177 * doesn't hear from you every so often, it will send you a probe
178 * to make sure you're there, just like any other ``Cache Manager''
179 * it's keeping track of.
182 * struct rx_call *rxcall : Ptr to the associated Rx call structure.
186 * Error value otherwise.
189 * This may be called by the File Server if we don't call it often
194 *------------------------------------------------------------------------*/
197 SRXAFSCB_Probe(struct rx_call * rxcall)
198 { /*SRXAFSCB_Probe */
200 #if XSTAT_FS_CALLBACK_VERBOSE
201 static char rn[] = "SRXAFSCB_Probe"; /*Routine name */
202 char hostName[256]; /*Host name buffer */
203 char *hostNameResult; /*Ptr to static */
205 fprintf(stderr, "[%s:%s] Called\n", mn, rn);
207 if (rxcall != (struct rx_call *)0) {
209 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
210 strcpy(hostName, hostNameResult);
211 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
212 hostName, rxcall->conn->peer->port);
213 } /*Valid rxcall param */
214 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
217 * Return successfully.
221 } /*SRXAFSCB_Probe */
224 /*------------------------------------------------------------------------
228 * Respond minimally to a request for returning the contents of
229 * a cache entry, since someone out there thinks you're a Cache
233 * struct rx_call *rxcall: Ptr to the associated Rx call structure.
239 * Nothing interesting.
243 *------------------------------------------------------------------------*/
246 SRXAFSCB_GetCE64(struct rx_call * rxcall, afs_int32 index,
247 AFSDBCacheEntry64 * ce)
248 { /*SRXAFSCB_GetCE64 */
250 #if XSTAT_FS_CALLBACK_VERBOSE
251 static char rn[] = "SRXAFSCB_GetCE64"; /*Routine name */
252 char hostName[256]; /*Host name buffer */
253 char *hostNameResult; /*Ptr to static */
255 if (rxcall != (struct rx_call *)0) {
257 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
258 strcpy(hostName, hostNameResult);
259 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
260 hostName, rxcall->conn->peer->port);
261 } /*Valid rxcall param */
262 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
266 } /*SRXAFSCB_GetCE64 */
269 SRXAFSCB_GetCE(struct rx_call * rxcall, afs_int32 index, AFSDBCacheEntry * ce)
270 { /*SRXAFSCB_GetCE */
272 #if XSTAT_FS_CALLBACK_VERBOSE
273 static char rn[] = "SRXAFSCB_GetCE"; /*Routine name */
274 char hostName[256]; /*Host name buffer */
275 char *hostNameResult; /*Ptr to static */
277 if (rxcall != (struct rx_call *)0) {
279 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
280 strcpy(hostName, hostNameResult);
281 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
282 hostName, rxcall->conn->peer->port);
283 } /*Valid rxcall param */
284 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
288 } /*SRXAFSCB_GetCE */
291 /*------------------------------------------------------------------------
295 * Respond minimally to a request for returning the contents of
296 * a cache lock, since someone out there thinks you're a Cache
300 * struct rx_call *rxcall: Ptr to the associated Rx call structure.
306 * Nothing interesting.
310 *------------------------------------------------------------------------*/
313 SRXAFSCB_GetLock(struct rx_call * rxcall, afs_int32 index, AFSDBLock * lock)
314 { /*SRXAFSCB_GetLock */
316 #if XSTAT_FS_CALLBACK_VERBOSE
317 static char rn[] = "SRXAFSCB_GetLock"; /*Routine name */
318 char hostName[256]; /*Host name buffer */
319 char *hostNameResult; /*Ptr to static */
321 if (rxcall != (struct rx_call *)0) {
323 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
324 strcpy(hostName, hostNameResult);
325 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
326 hostName, rxcall->conn->peer->port);
327 } /*Valid rxcall param */
328 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
332 } /*SRXAFSCB_GetLock */
335 /*------------------------------------------------------------------------
336 * SRXAFSCB_XStatsVersion
339 * Respond minimally to a request for fetching the version of
340 * extended Cache Manager statistics offered, since someone out
341 * there thinks you're a Cache Manager.
344 * struct rx_call *rxcall: Ptr to the associated Rx call structure.
350 * Nothing interesting.
354 *------------------------------------------------------------------------*/
357 SRXAFSCB_XStatsVersion(struct rx_call * rxcall, afs_int32 * versionNumberP)
358 { /*SRXAFSCB_XStatsVersion */
360 #if XSTAT_FS_CALLBACK_VERBOSE
361 static char rn[] = "SRXAFSCB_XStatsVersion"; /*Routine name */
362 char hostName[256]; /*Host name buffer */
363 char *hostNameResult; /*Ptr to static */
365 if (rxcall != (struct rx_call *)0) {
367 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
368 strcpy(hostName, hostNameResult);
369 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
370 hostName, rxcall->conn->peer->port);
371 } /*Valid rxcall param */
372 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
376 } /*SRXAFSCB_XStatsVersion */
379 /*------------------------------------------------------------------------
383 * Respond minimally to a request for returning extended
384 * statistics for a Cache Manager, since someone out there thinks
385 * you're a Cache Manager.
388 * struct rx_call *rxcall: Ptr to the associated Rx call structure.
394 * Nothing interesting.
398 *------------------------------------------------------------------------*/
401 SRXAFSCB_GetXStats(struct rx_call * rxcall, afs_int32 clientVersionNumber,
402 afs_int32 collectionNumber, afs_int32 * srvVersionNumberP,
403 afs_int32 * timeP, AFSCB_CollData * dataP)
404 { /*SRXAFSCB_GetXStats */
406 #if XSTAT_FS_CALLBACK_VERBOSE
407 static char rn[] = "SRXAFSCB_GetXStats"; /*Routine name */
408 char hostName[256]; /*Host name buffer */
409 char *hostNameResult; /*Ptr to static */
411 if (rxcall != (struct rx_call *)0) {
413 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
414 strcpy(hostName, hostNameResult);
415 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
416 hostName, rxcall->conn->peer->port);
417 } /*Valid rxcall param */
418 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
422 } /*SRXAFSCB_GetXStats */
424 /*------------------------------------------------------------------------
425 * EXPORTED SRXAFSCB_InitCallBackState2
428 * This routine was used in the AFS 3.5 beta release, but not anymore.
429 * It has since been replaced by SRXAFSCB_InitCallBackState3.
432 * rxcall : Ptr to Rx call on which this request came in.
435 * RXGEN_OPCODE (always).
438 * Nothing interesting.
442 *------------------------------------------------------------------------*/
445 SRXAFSCB_InitCallBackState2(struct rx_call * rxcall,
446 struct interfaceAddr * addr)
449 #if XSTAT_FS_CALLBACK_VERBOSE
450 static char rn[] = "SRXAFSCB_InitCallBackState2"; /*Routine name */
451 char hostName[256]; /*Host name buffer */
452 char *hostNameResult; /*Ptr to static */
454 if (rxcall != (struct rx_call *)0) {
456 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
457 strcpy(hostName, hostNameResult);
458 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
459 hostName, rxcall->conn->peer->port);
460 } /*Valid rxcall param */
461 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
465 /*------------------------------------------------------------------------
466 * EXPORTED SRXAFSCB_WhoAreYou
469 * Routine called by the server-side callback RPC interface to
470 * obtain a unique identifier for the client. The server uses
471 * this identifier to figure out whether or not two RX connections
472 * are from the same client, and to find out which addresses go
473 * with which clients.
476 * rxcall : Ptr to Rx call on which this request came in.
477 * addr: Ptr to return the list of interfaces for this client.
483 * Nothing interesting.
487 *------------------------------------------------------------------------*/
490 SRXAFSCB_WhoAreYou(struct rx_call * rxcall, struct interfaceAddr * addr)
496 #if XSTAT_FS_CALLBACK_VERBOSE
497 static char rn[] = "SRXAFSCB_WhoAreYou"; /*Routine name */
498 char hostName[256]; /*Host name buffer */
499 char *hostNameResult; /*Ptr to static */
501 if (rxcall != (struct rx_call *)0) {
503 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
504 strcpy(hostName, hostNameResult);
505 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
506 hostName, rxcall->conn->peer->port);
507 } /*Valid rxcall param */
508 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
510 if (rxcall && addr) {
513 *addr = afs_cb_interface;
517 * Return successfully.
523 /*------------------------------------------------------------------------
524 * EXPORTED SRXAFSCB_InitCallBackState3
527 * Routine called by the server-side callback RPC interface to
528 * implement clearing all callbacks from this host.
531 * rxcall : Ptr to Rx call on which this request came in.
537 * Nothing interesting.
541 *------------------------------------------------------------------------*/
544 SRXAFSCB_InitCallBackState3(struct rx_call * rxcall, afsUUID * uuidp)
546 #if XSTAT_FS_CALLBACK_VERBOSE
547 static char rn[] = "SRXAFSCB_InitCallBackState3"; /*Routine name */
548 char hostName[256]; /*Host name buffer */
549 char *hostNameResult; /*Ptr to static */
551 if (rxcall != (struct rx_call *)0) {
553 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
554 strcpy(hostName, hostNameResult);
555 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
556 hostName, rxcall->conn->peer->port);
557 } /*Valid rxcall param */
558 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
561 * Return successfully.
567 /*------------------------------------------------------------------------
568 * EXPORTED SRXAFSCB_ProbeUuid
571 * Routine called by the server-side callback RPC interface to
572 * implement ``probing'' the Cache Manager, just making sure it's
573 * still there is still the same client it used to be.
576 * rxcall : Ptr to Rx call on which this request came in.
577 * uuidp : Ptr to UUID that must match the client's UUID.
580 * 0 if uuidp matches the UUID for this client
584 * Nothing interesting.
588 *------------------------------------------------------------------------*/
591 SRXAFSCB_ProbeUuid(struct rx_call * rxcall, afsUUID * uuidp)
595 #if XSTAT_FS_CALLBACK_VERBOSE
596 static char rn[] = "SRXAFSCB_ProbeUuid"; /*Routine name */
597 char hostName[256]; /*Host name buffer */
598 char *hostNameResult; /*Ptr to static */
600 if (rxcall != (struct rx_call *)0) {
602 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
603 strcpy(hostName, hostNameResult);
604 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
605 hostName, rxcall->conn->peer->port);
606 } /*Valid rxcall param */
607 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
611 if (!afs_uuid_equal(uuidp, &afs_cb_interface.uuid))
612 code = 1; /* failure */
616 /*------------------------------------------------------------------------
617 * EXPORTED SRXAFSCB_GetServerPrefs
620 * Routine to list server preferences used by this client.
623 * a_call : Ptr to Rx call on which this request came in.
624 * a_index : Input server index
625 * a_srvr_addr : Output server address (0xffffffff on last server)
626 * a_srvr_rank : Output server rank
629 * RXGEN_OPCODE (always)
632 * Nothing interesting.
636 *------------------------------------------------------------------------*/
639 SRXAFSCB_GetServerPrefs(struct rx_call * a_call, afs_int32 a_index,
640 afs_int32 * a_srvr_addr, afs_int32 * a_srvr_rank)
645 /*------------------------------------------------------------------------
646 * EXPORTED SRXAFSCB_GetCellServDB
649 * Routine to list cells configured for this client
652 * a_call : Ptr to Rx call on which this request came in.
653 * a_index : Input cell index
654 * a_name : Output cell name ("" on last cell)
655 * a_hosts : Output cell database servers
661 * Nothing interesting.
665 *------------------------------------------------------------------------*/
668 SRXAFSCB_GetCellServDB(struct rx_call * a_call, afs_int32 a_index,
669 char **a_name, serverList * a_hosts)
676 SRXAFSCB_GetCellByNum(struct rx_call * a_call, afs_int32 a_cellnum,
677 char **a_name, serverList * a_hosts)
683 /*------------------------------------------------------------------------
684 * EXPORTED SRXAFSCB_GetLocalCell
687 * Routine to return name of client's local cell
690 * a_call : Ptr to Rx call on which this request came in.
691 * a_name : Output cell name
694 * RXGEN_OPCODE (always)
697 * Nothing interesting.
701 *------------------------------------------------------------------------*/
704 SRXAFSCB_GetLocalCell(struct rx_call * a_call, char **a_name)
708 t_name = (char *)malloc(AFSNAMEMAX);
711 strcpy(t_name, "This is xstat_fs");
717 /*------------------------------------------------------------------------
718 * EXPORTED SRXAFSCB_GetCacheConfig
721 * Routine to return parameters used to initialize client cache.
722 * Client may request any format version. Server may not return
723 * format version greater than version requested by client.
726 * a_call: Ptr to Rx call on which this request came in.
727 * callerVersion: Data format version desired by the client.
728 * serverVersion: Data format version of output data.
729 * configCount: Number bytes allocated for output data.
730 * config: Client cache configuration.
733 * RXGEN_OPCODE (always)
736 * Nothing interesting.
740 *------------------------------------------------------------------------*/
743 SRXAFSCB_GetCacheConfig(struct rx_call * a_call, afs_uint32 callerVersion,
744 afs_uint32 * serverVersion, afs_uint32 * configCount,
745 cacheConfig * config)
751 SRXAFSCB_TellMeAboutYourself(struct rx_call * rxcall,
752 struct interfaceAddr * addr,
753 Capabilities * capabilites)
759 #if XSTAT_FS_CALLBACK_VERBOSE
760 static char rn[] = "SRXAFSCB_TellMeAboutYourself"; /*Routine name */
761 char hostName[256]; /*Host name buffer */
762 char *hostNameResult; /*Ptr to static */
764 if (rxcall != (struct rx_call *)0) {
766 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
767 strcpy(hostName, hostNameResult);
768 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
769 hostName, rxcall->conn->peer->port);
770 } /*Valid rxcall param */
771 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
773 if (rxcall && addr) {
776 *addr = afs_cb_interface;
780 * Return successfully.
785 int SRXAFSCB_GetDE(a_call, a_index, addr, inode, flags, time, fileName)
786 struct rx_call *a_call;