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 */
34 #define FSPROBE_CALLBACK_VERBOSE 0
36 int afs_cb_inited = 0;
37 struct interfaceAddr afs_cb_interface;
40 * Routines we need that don't have explicit include file definitions.
42 extern char *hostutil_GetNameByINet(); /*Host parsing utility */
44 static char mn[] = "fsprobe_callback"; /*Module name */
47 * Initialize the callback interface structure
54 afs_uuid_create(&afs_cb_interface.uuid);
55 count = rx_getAllAddr(&afs_cb_interface.addr_in, AFS_MAX_INTERFACE_ADDR);
57 afs_cb_interface.numberOfInterfaces = 0;
59 afs_cb_interface.numberOfInterfaces = count;
65 /*------------------------------------------------------------------------
69 * Handle a set of callbacks from the FileServer.
72 * struct rx_call *rxcall : Ptr to the associated Rx call structure.
73 * AFSCBFids *Fids_Array : Ptr to the set of Fids.
74 * AFSCBs *CallBacks_Array : Ptr to the set of callbacks.
78 * Error value otherwise.
81 * Nothing interesting.
85 *------------------------------------------------------------------------*/
88 SRXAFSCB_CallBack(struct rx_call * rxcall, AFSCBFids * Fids_Array,
89 AFSCBs * CallBack_Array)
90 { /*SRXAFSCB_CallBack */
92 #if FSPROBE_CALLBACK_VERBOSE
93 static char rn[] = "SRXAFSCB_CallBack"; /*Routine name */
94 char hostName[256]; /*Host name buffer */
95 char *hostNameResult; /*Ptr to static */
97 if (rxcall != (struct rx_call *)0) {
99 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
100 strcpy(hostName, hostNameResult);
101 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
102 hostName, rxcall->conn->peer->port);
103 } /*Valid rxcall param */
104 #endif /* FSPROBE_CALLBACK_VERBOSE */
107 * Return successfully.
111 } /*SRXAFSCB_CallBack */
114 /*------------------------------------------------------------------------
115 * SRXAFSCB_InitCallBackState
118 * Initialize callback state on this ``Cache Manager''.
121 * struct rx_call *rxcall : Ptr to the associated Rx call structure.
125 * Error value otherwise.
128 * This will definitely be called by the FileServer (exactly once),
129 * since it will think we are another new ``Cache Manager''.
133 *------------------------------------------------------------------------*/
136 SRXAFSCB_InitCallBackState(struct rx_call * rxcall)
137 { /*SRXAFSCB_InitCallBackState */
139 #if FSPROBE_CALLBACK_VERBOSE
140 static char rn[] = "SRXAFSCB_InitCallBackState"; /*Routine name */
141 char hostName[256]; /*Host name buffer */
142 char *hostNameResult; /*Ptr to static */
144 if (rxcall != (struct rx_call *)0) {
146 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
147 strcpy(hostName, hostNameResult);
148 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
149 hostName, rxcall->conn->peer->port);
150 } /*Valid rxcall param */
151 #endif /* FSPROBE_CALLBACK_VERBOSE */
154 * Return successfully.
158 } /*SRXAFSCB_InitCallBackState */
161 /*------------------------------------------------------------------------
165 * Respond to a probe from the FileServer. If a FileServer doesn't
166 * hear from you every so often, it will send you a probe to make
167 * sure you're there, just like any other ``Cache Manager'' it's
171 * struct rx_call *rxcall : Ptr to the associated Rx call structure.
175 * Error value otherwise.
178 * This may be called by the FileServer if we don't call it often
183 *------------------------------------------------------------------------*/
186 SRXAFSCB_Probe(struct rx_call * rxcall)
187 { /*SRXAFSCB_Probe */
189 #if FSPROBE_CALLBACK_VERBOSE
190 static char rn[] = "SRXAFSCB_Probe"; /*Routine name */
191 char hostName[256]; /*Host name buffer */
192 char *hostNameResult; /*Ptr to static */
194 if (rxcall != (struct rx_call *)0) {
196 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
197 strcpy(hostName, hostNameResult);
198 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
199 hostName, rxcall->conn->peer->port);
200 } /*Valid rxcall param */
201 #endif /* FSPROBE_CALLBACK_VERBOSE */
204 * Return successfully.
208 } /*SRXAFSCB_Probe */
211 /*------------------------------------------------------------------------
215 * Respond minimally to a request for returning the contents of
216 * a cache entry, since someone out there thinks you're a Cache
220 * struct rx_call *rxcall: Ptr to the associated Rx call structure.
226 * Nothing interesting.
230 *------------------------------------------------------------------------*/
233 SRXAFSCB_GetCE64(struct rx_call * rxcall, afs_int32 index,
234 AFSDBCacheEntry64 * ce)
235 { /*SRXAFSCB_GetCE64 */
237 #if XSTAT_FS_CALLBACK_VERBOSE
238 static char rn[] = "SRXAFSCB_GetCE64"; /*Routine name */
239 char hostName[256]; /*Host name buffer */
240 char *hostNameResult; /*Ptr to static */
242 if (rxcall != (struct rx_call *)0) {
244 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
245 strcpy(hostName, hostNameResult);
246 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
247 hostName, rxcall->conn->peer->port);
248 } /*Valid rxcall param */
249 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
253 } /*SRXAFSCB_GetCE64 */
256 SRXAFSCB_GetCE(struct rx_call * rxcall, afs_int32 index, AFSDBCacheEntry * ce)
257 { /*SRXAFSCB_GetCE */
259 #if XSTAT_FS_CALLBACK_VERBOSE
260 static char rn[] = "SRXAFSCB_GetCE"; /*Routine name */
261 char hostName[256]; /*Host name buffer */
262 char *hostNameResult; /*Ptr to static */
264 if (rxcall != (struct rx_call *)0) {
266 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
267 strcpy(hostName, hostNameResult);
268 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
269 hostName, rxcall->conn->peer->port);
270 } /*Valid rxcall param */
271 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
275 } /*SRXAFSCB_GetCE */
278 /*------------------------------------------------------------------------
282 * Respond minimally to a request for returning the contents of
283 * a cache lock, since someone out there thinks you're a Cache
287 * struct rx_call *rxcall: Ptr to the associated Rx call structure.
293 * Nothing interesting.
297 *------------------------------------------------------------------------*/
300 SRXAFSCB_GetLock(struct rx_call * rxcall, afs_int32 index, AFSDBLock * lock)
301 { /*SRXAFSCB_GetLock */
303 #if XSTAT_FS_CALLBACK_VERBOSE
304 static char rn[] = "SRXAFSCB_GetLock"; /*Routine name */
305 char hostName[256]; /*Host name buffer */
306 char *hostNameResult; /*Ptr to static */
308 if (rxcall != (struct rx_call *)0) {
310 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
311 strcpy(hostName, hostNameResult);
312 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
313 hostName, rxcall->conn->peer->port);
314 } /*Valid rxcall param */
315 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
319 } /*SRXAFSCB_GetLock */
322 /*------------------------------------------------------------------------
323 * SRXAFSCB_XStatsVersion
326 * Respond minimally to a request for fetching the version of
327 * extended Cache Manager statistics offered, since someone out
328 * there thinks you're a Cache Manager.
331 * struct rx_call *rxcall: Ptr to the associated Rx call structure.
337 * Nothing interesting.
341 *------------------------------------------------------------------------*/
344 SRXAFSCB_XStatsVersion(struct rx_call * rxcall, afs_int32 * versionNumberP)
345 { /*SRXAFSCB_XStatsVersion */
347 #if XSTAT_FS_CALLBACK_VERBOSE
348 static char rn[] = "SRXAFSCB_XStatsVersion"; /*Routine name */
349 char hostName[256]; /*Host name buffer */
350 char *hostNameResult; /*Ptr to static */
352 if (rxcall != (struct rx_call *)0) {
354 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
355 strcpy(hostName, hostNameResult);
356 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
357 hostName, rxcall->conn->peer->port);
358 } /*Valid rxcall param */
359 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
363 } /*SRXAFSCB_XStatsVersion */
366 /*------------------------------------------------------------------------
370 * Respond minimally to a request for returning extended
371 * statistics for a Cache Manager, since someone out there thinks
372 * you're a Cache Manager.
375 * struct rx_call *rxcall: Ptr to the associated Rx call structure.
381 * Nothing interesting.
385 *------------------------------------------------------------------------*/
388 SRXAFSCB_GetXStats(struct rx_call * rxcall, afs_int32 clientVN,
389 afs_int32 collN, afs_int32 * srvVNP, afs_int32 * timeP,
390 AFSCB_CollData * dataP)
391 { /*SRXAFSCB_GetXStats */
393 #if XSTAT_FS_CALLBACK_VERBOSE
394 static char rn[] = "SRXAFSCB_GetXStats"; /*Routine name */
395 char hostName[256]; /*Host name buffer */
396 char *hostNameResult; /*Ptr to static */
398 if (rxcall != (struct rx_call *)0) {
400 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
401 strcpy(hostName, hostNameResult);
402 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
403 hostName, rxcall->conn->peer->port);
404 } /*Valid rxcall param */
405 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
409 } /*SRXAFSCB_GetXStats */
411 /*------------------------------------------------------------------------
412 * EXPORTED SRXAFSCB_InitCallBackState2
415 * This routine was used in the AFS 3.5 beta release, but not anymore.
416 * It has since been replaced by SRXAFSCB_InitCallBackState3.
419 * rxcall : Ptr to Rx call on which this request came in.
422 * RXGEN_OPCODE (always).
425 * Nothing interesting.
429 *------------------------------------------------------------------------*/
432 SRXAFSCB_InitCallBackState2(struct rx_call * rxcall,
433 struct interfaceAddr * addr)
436 #if FSPROBE_CALLBACK_VERBOSE
437 static char rn[] = "SRXAFSCB_InitCallBackState2"; /*Routine name */
438 char hostName[256]; /*Host name buffer */
439 char *hostNameResult; /*Ptr to static */
441 if (rxcall != (struct rx_call *)0) {
443 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
444 strcpy(hostName, hostNameResult);
445 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
446 hostName, rxcall->conn->peer->port);
447 } /*Valid rxcall param */
448 #endif /* FSPROBE_CALLBACK_VERBOSE */
452 /*------------------------------------------------------------------------
453 * EXPORTED SRXAFSCB_WhoAreYou
456 * Routine called by the server-side callback RPC interface to
457 * obtain a unique identifier for the client. The server uses
458 * this identifier to figure out whether or not two RX connections
459 * are from the same client, and to find out which addresses go
460 * with which clients.
463 * rxcall : Ptr to Rx call on which this request came in.
464 * addr: Ptr to return the list of interfaces for this client.
470 * Nothing interesting.
474 *------------------------------------------------------------------------*/
477 SRXAFSCB_WhoAreYou(struct rx_call * rxcall, struct interfaceAddr * addr)
483 #if FSPROBE_CALLBACK_VERBOSE
484 static char rn[] = "SRXAFSCB_WhoAreYou"; /*Routine name */
485 char hostName[256]; /*Host name buffer */
486 char *hostNameResult; /*Ptr to static */
488 if (rxcall != (struct rx_call *)0) {
490 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
491 strcpy(hostName, hostNameResult);
492 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
493 hostName, rxcall->conn->peer->port);
494 } /*Valid rxcall param */
495 #endif /* FSPROBE_CALLBACK_VERBOSE */
497 if (rxcall && addr) {
500 *addr = afs_cb_interface;
504 * Return successfully.
510 /*------------------------------------------------------------------------
511 * EXPORTED SRXAFSCB_InitCallBackState3
514 * Routine called by the server-side callback RPC interface to
515 * implement clearing all callbacks from this host.
518 * rxcall : Ptr to Rx call on which this request came in.
524 * Nothing interesting.
528 *------------------------------------------------------------------------*/
531 SRXAFSCB_InitCallBackState3(struct rx_call * rxcall, afsUUID * uuidp)
533 #if FSPROBE_CALLBACK_VERBOSE
534 static char rn[] = "SRXAFSCB_InitCallBackState2"; /*Routine name */
535 char hostName[256]; /*Host name buffer */
536 char *hostNameResult; /*Ptr to static */
538 if (rxcall != (struct rx_call *)0) {
540 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
541 strcpy(hostName, hostNameResult);
542 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
543 hostName, rxcall->conn->peer->port);
544 } /*Valid rxcall param */
545 #endif /* FSPROBE_CALLBACK_VERBOSE */
548 * Return successfully.
554 /*------------------------------------------------------------------------
555 * EXPORTED SRXAFSCB_ProbeUuid
558 * Routine called by the server-side callback RPC interface to
559 * implement ``probing'' the Cache Manager, just making sure it's
560 * still there is still the same client it used to be.
563 * rxcall : Ptr to Rx call on which this request came in.
564 * uuidp : Ptr to UUID that must match the client's UUID.
567 * 0 if uuidp matches the UUID for this client
571 * Nothing interesting.
575 *------------------------------------------------------------------------*/
578 SRXAFSCB_ProbeUuid(struct rx_call * rxcall, afsUUID * uuidp)
582 #if FSPROBE_CALLBACK_VERBOSE
583 static char rn[] = "SRXAFSCB_ProbeUuid"; /*Routine name */
584 char hostName[256]; /*Host name buffer */
585 char *hostNameResult; /*Ptr to static */
587 if (rxcall != (struct rx_call *)0) {
589 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
590 strcpy(hostName, hostNameResult);
591 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
592 hostName, rxcall->conn->peer->port);
593 } /*Valid rxcall param */
594 #endif /* FSPROBE_CALLBACK_VERBOSE */
598 if (!afs_uuid_equal(uuidp, &afs_cb_interface.uuid))
599 code = 1; /* failure */
603 /*------------------------------------------------------------------------
604 * EXPORTED SRXAFSCB_GetServerPrefs
607 * Routine to list server preferences used by this client.
610 * a_call : Ptr to Rx call on which this request came in.
611 * a_index : Input server index
612 * a_srvr_addr : Output server address (0xffffffff on last server)
613 * a_srvr_rank : Output server rank
619 * Nothing interesting.
623 *------------------------------------------------------------------------*/
626 SRXAFSCB_GetServerPrefs(struct rx_call * a_call, afs_int32 a_index,
627 afs_int32 * a_srvr_addr, afs_int32 * a_srvr_rank)
629 *a_srvr_addr = 0xffffffff;
630 *a_srvr_rank = 0xffffffff;
634 /*------------------------------------------------------------------------
635 * EXPORTED SRXAFSCB_GetCellServDB
638 * Routine to list cells configured for this client
641 * a_call : Ptr to Rx call on which this request came in.
642 * a_index : Input cell index
643 * a_name : Output cell name ("" on last cell)
644 * a_hosts : Output cell database servers
647 * RXGEN_OPCODE (always)
650 * Nothing interesting.
654 *------------------------------------------------------------------------*/
657 SRXAFSCB_GetCellServDB(struct rx_call * a_call, afs_int32 a_index,
658 char **a_name, serverList * a_hosts)
664 SRXAFSCB_GetCellByNum(struct rx_call * a_call, afs_int32 a_cellnum,
665 char **a_name, serverList * a_hosts)
670 /*------------------------------------------------------------------------
671 * EXPORTED SRXAFSCB_GetLocalCell
674 * Routine to return name of client's local cell
677 * a_call : Ptr to Rx call on which this request came in.
678 * a_name : Output cell name
681 * RXGEN_OPCODE (always)
684 * Nothing interesting.
688 *------------------------------------------------------------------------*/
691 SRXAFSCB_GetLocalCell(struct rx_call * a_call, char **a_name)
697 /*------------------------------------------------------------------------
698 * EXPORTED SRXAFSCB_GetCacheConfig
701 * Routine to return parameters used to initialize client cache.
702 * Client may request any format version. Server may not return
703 * format version greater than version requested by client.
706 * a_call: Ptr to Rx call on which this request came in.
707 * callerVersion: Data format version desired by the client.
708 * serverVersion: Data format version of output data.
709 * configCount: Number bytes allocated for output data.
710 * config: Client cache configuration.
713 * RXGEN_OPCODE (always)
716 * Nothing interesting.
720 *------------------------------------------------------------------------*/
723 SRXAFSCB_GetCacheConfig(struct rx_call * a_call, afs_uint32 callerVersion,
724 afs_uint32 * serverVersion, afs_uint32 * configCount,
725 cacheConfig * config)
731 SRXAFSCB_TellMeAboutYourself(struct rx_call * rxcall,
732 struct interfaceAddr * addr,
733 Capabilities * capabilities)
739 #if FSPROBE_CALLBACK_VERBOSE
740 static char rn[] = "SRXAFSCB_TellMeAboutYourself"; /*Routine name */
741 char hostName[256]; /*Host name buffer */
742 char *hostNameResult; /*Ptr to static */
744 if (rxcall != (struct rx_call *)0) {
746 hostutil_GetNameByINet((afs_int32) (rxcall->conn->peer->host));
747 strcpy(hostName, hostNameResult);
748 fprintf(stderr, "[%s:%s] Called from host %s, port %d\n", mn, rn,
749 hostName, rxcall->conn->peer->port);
750 } /*Valid rxcall param */
751 #endif /* FSPROBE_CALLBACK_VERBOSE */
753 if (rxcall && addr) {
756 *addr = afs_cb_interface;
760 * Return successfully.
765 int SRXAFSCB_GetDE(a_call, a_index, addr, inode, flags, time, fileName)
766 struct rx_call *a_call;