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>
29 #include <afs/afscbint.h> /*Callback interface defs */
30 #include <afs/afsutil.h>
32 #define FSPROBE_CALLBACK_VERBOSE 0
34 int afs_cb_inited
= 0;
35 struct interfaceAddr afs_cb_interface
;
38 * Initialize the callback interface structure
45 afs_uuid_create(&afs_cb_interface
.uuid
);
46 count
= rx_getAllAddr((afs_uint32
*) &afs_cb_interface
.addr_in
, AFS_MAX_INTERFACE_ADDR
);
48 afs_cb_interface
.numberOfInterfaces
= 0;
50 afs_cb_interface
.numberOfInterfaces
= count
;
56 /*------------------------------------------------------------------------
60 * Handle a set of callbacks from the FileServer.
63 * struct rx_call *rxcall : Ptr to the associated Rx call structure.
64 * AFSCBFids *Fids_Array : Ptr to the set of Fids.
65 * AFSCBs *CallBacks_Array : Ptr to the set of callbacks.
69 * Error value otherwise.
72 * Nothing interesting.
76 *------------------------------------------------------------------------*/
79 SRXAFSCB_CallBack(struct rx_call
* rxcall
, AFSCBFids
* Fids_Array
,
80 AFSCBs
* CallBack_Array
)
81 { /*SRXAFSCB_CallBack */
83 #if FSPROBE_CALLBACK_VERBOSE
84 static char rn
[] = "SRXAFSCB_CallBack"; /*Routine name */
85 char hostName
[256]; /*Host name buffer */
86 char *hostNameResult
; /*Ptr to static */
88 if (rxcall
!= (struct rx_call
*)0) {
90 hostutil_GetNameByINet((afs_int32
) (rxcall
->conn
->peer
->host
));
91 strcpy(hostName
, hostNameResult
);
92 fprintf(stderr
, "[%s:%s] Called from host %s, port %d\n", mn
, rn
,
93 hostName
, rxcall
->conn
->peer
->port
);
94 } /*Valid rxcall param */
95 #endif /* FSPROBE_CALLBACK_VERBOSE */
98 * Return successfully.
102 } /*SRXAFSCB_CallBack */
105 /*------------------------------------------------------------------------
106 * SRXAFSCB_InitCallBackState
109 * Initialize callback state on this ``Cache Manager''.
112 * struct rx_call *rxcall : Ptr to the associated Rx call structure.
116 * Error value otherwise.
119 * This will definitely be called by the FileServer (exactly once),
120 * since it will think we are another new ``Cache Manager''.
124 *------------------------------------------------------------------------*/
127 SRXAFSCB_InitCallBackState(struct rx_call
* rxcall
)
128 { /*SRXAFSCB_InitCallBackState */
130 #if FSPROBE_CALLBACK_VERBOSE
131 static char rn
[] = "SRXAFSCB_InitCallBackState"; /*Routine name */
132 char hostName
[256]; /*Host name buffer */
133 char *hostNameResult
; /*Ptr to static */
135 if (rxcall
!= (struct rx_call
*)0) {
137 hostutil_GetNameByINet((afs_int32
) (rxcall
->conn
->peer
->host
));
138 strcpy(hostName
, hostNameResult
);
139 fprintf(stderr
, "[%s:%s] Called from host %s, port %d\n", mn
, rn
,
140 hostName
, rxcall
->conn
->peer
->port
);
141 } /*Valid rxcall param */
142 #endif /* FSPROBE_CALLBACK_VERBOSE */
145 * Return successfully.
149 } /*SRXAFSCB_InitCallBackState */
152 /*------------------------------------------------------------------------
156 * Respond to a probe from the FileServer. If a FileServer doesn't
157 * hear from you every so often, it will send you a probe to make
158 * sure you're there, just like any other ``Cache Manager'' it's
162 * struct rx_call *rxcall : Ptr to the associated Rx call structure.
166 * Error value otherwise.
169 * This may be called by the FileServer if we don't call it often
174 *------------------------------------------------------------------------*/
177 SRXAFSCB_Probe(struct rx_call
* rxcall
)
178 { /*SRXAFSCB_Probe */
180 #if FSPROBE_CALLBACK_VERBOSE
181 static char rn
[] = "SRXAFSCB_Probe"; /*Routine name */
182 char hostName
[256]; /*Host name buffer */
183 char *hostNameResult
; /*Ptr to static */
185 if (rxcall
!= (struct rx_call
*)0) {
187 hostutil_GetNameByINet((afs_int32
) (rxcall
->conn
->peer
->host
));
188 strcpy(hostName
, hostNameResult
);
189 fprintf(stderr
, "[%s:%s] Called from host %s, port %d\n", mn
, rn
,
190 hostName
, rxcall
->conn
->peer
->port
);
191 } /*Valid rxcall param */
192 #endif /* FSPROBE_CALLBACK_VERBOSE */
195 * Return successfully.
199 } /*SRXAFSCB_Probe */
202 /*------------------------------------------------------------------------
206 * Respond minimally to a request for returning the contents of
207 * a cache entry, since someone out there thinks you're a Cache
211 * struct rx_call *rxcall: Ptr to the associated Rx call structure.
217 * Nothing interesting.
221 *------------------------------------------------------------------------*/
224 SRXAFSCB_GetCE64(struct rx_call
* rxcall
, afs_int32 index
,
225 AFSDBCacheEntry64
* ce
)
226 { /*SRXAFSCB_GetCE64 */
228 #if XSTAT_FS_CALLBACK_VERBOSE
229 static char rn
[] = "SRXAFSCB_GetCE64"; /*Routine name */
230 char hostName
[256]; /*Host name buffer */
231 char *hostNameResult
; /*Ptr to static */
233 if (rxcall
!= (struct rx_call
*)0) {
235 hostutil_GetNameByINet((afs_int32
) (rxcall
->conn
->peer
->host
));
236 strcpy(hostName
, hostNameResult
);
237 fprintf(stderr
, "[%s:%s] Called from host %s, port %d\n", mn
, rn
,
238 hostName
, rxcall
->conn
->peer
->port
);
239 } /*Valid rxcall param */
240 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
244 } /*SRXAFSCB_GetCE64 */
247 SRXAFSCB_GetCE(struct rx_call
* rxcall
, afs_int32 index
, AFSDBCacheEntry
* ce
)
248 { /*SRXAFSCB_GetCE */
250 #if XSTAT_FS_CALLBACK_VERBOSE
251 static char rn
[] = "SRXAFSCB_GetCE"; /*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_GetCE */
269 /*------------------------------------------------------------------------
273 * Respond minimally to a request for returning the contents of
274 * a cache lock, since someone out there thinks you're a Cache
278 * struct rx_call *rxcall: Ptr to the associated Rx call structure.
284 * Nothing interesting.
288 *------------------------------------------------------------------------*/
291 SRXAFSCB_GetLock(struct rx_call
* rxcall
, afs_int32 index
, AFSDBLock
* lock
)
292 { /*SRXAFSCB_GetLock */
294 #if XSTAT_FS_CALLBACK_VERBOSE
295 static char rn
[] = "SRXAFSCB_GetLock"; /*Routine name */
296 char hostName
[256]; /*Host name buffer */
297 char *hostNameResult
; /*Ptr to static */
299 if (rxcall
!= (struct rx_call
*)0) {
301 hostutil_GetNameByINet((afs_int32
) (rxcall
->conn
->peer
->host
));
302 strcpy(hostName
, hostNameResult
);
303 fprintf(stderr
, "[%s:%s] Called from host %s, port %d\n", mn
, rn
,
304 hostName
, rxcall
->conn
->peer
->port
);
305 } /*Valid rxcall param */
306 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
310 } /*SRXAFSCB_GetLock */
313 /*------------------------------------------------------------------------
314 * SRXAFSCB_XStatsVersion
317 * Respond minimally to a request for fetching the version of
318 * extended Cache Manager statistics offered, since someone out
319 * there thinks you're a Cache Manager.
322 * struct rx_call *rxcall: Ptr to the associated Rx call structure.
328 * Nothing interesting.
332 *------------------------------------------------------------------------*/
335 SRXAFSCB_XStatsVersion(struct rx_call
* rxcall
, afs_int32
* versionNumberP
)
336 { /*SRXAFSCB_XStatsVersion */
338 #if XSTAT_FS_CALLBACK_VERBOSE
339 static char rn
[] = "SRXAFSCB_XStatsVersion"; /*Routine name */
340 char hostName
[256]; /*Host name buffer */
341 char *hostNameResult
; /*Ptr to static */
343 if (rxcall
!= (struct rx_call
*)0) {
345 hostutil_GetNameByINet((afs_int32
) (rxcall
->conn
->peer
->host
));
346 strcpy(hostName
, hostNameResult
);
347 fprintf(stderr
, "[%s:%s] Called from host %s, port %d\n", mn
, rn
,
348 hostName
, rxcall
->conn
->peer
->port
);
349 } /*Valid rxcall param */
350 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
354 } /*SRXAFSCB_XStatsVersion */
357 /*------------------------------------------------------------------------
361 * Respond minimally to a request for returning extended
362 * statistics for a Cache Manager, since someone out there thinks
363 * you're a Cache Manager.
366 * struct rx_call *rxcall: Ptr to the associated Rx call structure.
372 * Nothing interesting.
376 *------------------------------------------------------------------------*/
379 SRXAFSCB_GetXStats(struct rx_call
* rxcall
, afs_int32 clientVN
,
380 afs_int32 collN
, afs_int32
* srvVNP
, afs_int32
* timeP
,
381 AFSCB_CollData
* dataP
)
382 { /*SRXAFSCB_GetXStats */
384 #if XSTAT_FS_CALLBACK_VERBOSE
385 static char rn
[] = "SRXAFSCB_GetXStats"; /*Routine name */
386 char hostName
[256]; /*Host name buffer */
387 char *hostNameResult
; /*Ptr to static */
389 if (rxcall
!= (struct rx_call
*)0) {
391 hostutil_GetNameByINet((afs_int32
) (rxcall
->conn
->peer
->host
));
392 strcpy(hostName
, hostNameResult
);
393 fprintf(stderr
, "[%s:%s] Called from host %s, port %d\n", mn
, rn
,
394 hostName
, rxcall
->conn
->peer
->port
);
395 } /*Valid rxcall param */
396 #endif /* XSTAT_FS_CALLBACK_VERBOSE */
400 } /*SRXAFSCB_GetXStats */
402 /*------------------------------------------------------------------------
403 * EXPORTED SRXAFSCB_InitCallBackState2
406 * This routine was used in the AFS 3.5 beta release, but not anymore.
407 * It has since been replaced by SRXAFSCB_InitCallBackState3.
410 * rxcall : Ptr to Rx call on which this request came in.
413 * RXGEN_OPCODE (always).
416 * Nothing interesting.
420 *------------------------------------------------------------------------*/
423 SRXAFSCB_InitCallBackState2(struct rx_call
* rxcall
,
424 struct interfaceAddr
* addr
)
427 #if FSPROBE_CALLBACK_VERBOSE
428 static char rn
[] = "SRXAFSCB_InitCallBackState2"; /*Routine name */
429 char hostName
[256]; /*Host name buffer */
430 char *hostNameResult
; /*Ptr to static */
432 if (rxcall
!= (struct rx_call
*)0) {
434 hostutil_GetNameByINet((afs_int32
) (rxcall
->conn
->peer
->host
));
435 strcpy(hostName
, hostNameResult
);
436 fprintf(stderr
, "[%s:%s] Called from host %s, port %d\n", mn
, rn
,
437 hostName
, rxcall
->conn
->peer
->port
);
438 } /*Valid rxcall param */
439 #endif /* FSPROBE_CALLBACK_VERBOSE */
443 /*------------------------------------------------------------------------
444 * EXPORTED SRXAFSCB_WhoAreYou
447 * Routine called by the server-side callback RPC interface to
448 * obtain a unique identifier for the client. The server uses
449 * this identifier to figure out whether or not two RX connections
450 * are from the same client, and to find out which addresses go
451 * with which clients.
454 * rxcall : Ptr to Rx call on which this request came in.
455 * addr: Ptr to return the list of interfaces for this client.
461 * Nothing interesting.
465 *------------------------------------------------------------------------*/
468 SRXAFSCB_WhoAreYou(struct rx_call
* rxcall
, struct interfaceAddr
* addr
)
471 #if FSPROBE_CALLBACK_VERBOSE
472 static char rn
[] = "SRXAFSCB_WhoAreYou"; /*Routine name */
473 char hostName
[256]; /*Host name buffer */
474 char *hostNameResult
; /*Ptr to static */
476 if (rxcall
!= (struct rx_call
*)0) {
478 hostutil_GetNameByINet((afs_int32
) (rxcall
->conn
->peer
->host
));
479 strcpy(hostName
, hostNameResult
);
480 fprintf(stderr
, "[%s:%s] Called from host %s, port %d\n", mn
, rn
,
481 hostName
, rxcall
->conn
->peer
->port
);
482 } /*Valid rxcall param */
483 #endif /* FSPROBE_CALLBACK_VERBOSE */
485 if (rxcall
&& addr
) {
488 *addr
= afs_cb_interface
;
492 * Return successfully.
498 /*------------------------------------------------------------------------
499 * EXPORTED SRXAFSCB_InitCallBackState3
502 * Routine called by the server-side callback RPC interface to
503 * implement clearing all callbacks from this host.
506 * rxcall : Ptr to Rx call on which this request came in.
512 * Nothing interesting.
516 *------------------------------------------------------------------------*/
519 SRXAFSCB_InitCallBackState3(struct rx_call
* rxcall
, afsUUID
* uuidp
)
521 #if FSPROBE_CALLBACK_VERBOSE
522 static char rn
[] = "SRXAFSCB_InitCallBackState2"; /*Routine name */
523 char hostName
[256]; /*Host name buffer */
524 char *hostNameResult
; /*Ptr to static */
526 if (rxcall
!= (struct rx_call
*)0) {
528 hostutil_GetNameByINet((afs_int32
) (rxcall
->conn
->peer
->host
));
529 strcpy(hostName
, hostNameResult
);
530 fprintf(stderr
, "[%s:%s] Called from host %s, port %d\n", mn
, rn
,
531 hostName
, rxcall
->conn
->peer
->port
);
532 } /*Valid rxcall param */
533 #endif /* FSPROBE_CALLBACK_VERBOSE */
536 * Return successfully.
542 /*------------------------------------------------------------------------
543 * EXPORTED SRXAFSCB_ProbeUuid
546 * Routine called by the server-side callback RPC interface to
547 * implement ``probing'' the Cache Manager, just making sure it's
548 * still there is still the same client it used to be.
551 * rxcall : Ptr to Rx call on which this request came in.
552 * uuidp : Ptr to UUID that must match the client's UUID.
555 * 0 if uuidp matches the UUID for this client
559 * Nothing interesting.
563 *------------------------------------------------------------------------*/
566 SRXAFSCB_ProbeUuid(struct rx_call
* rxcall
, afsUUID
* uuidp
)
570 #if FSPROBE_CALLBACK_VERBOSE
571 static char rn
[] = "SRXAFSCB_ProbeUuid"; /*Routine name */
572 char hostName
[256]; /*Host name buffer */
573 char *hostNameResult
; /*Ptr to static */
575 if (rxcall
!= (struct rx_call
*)0) {
577 hostutil_GetNameByINet((afs_int32
) (rxcall
->conn
->peer
->host
));
578 strcpy(hostName
, hostNameResult
);
579 fprintf(stderr
, "[%s:%s] Called from host %s, port %d\n", mn
, rn
,
580 hostName
, rxcall
->conn
->peer
->port
);
581 } /*Valid rxcall param */
582 #endif /* FSPROBE_CALLBACK_VERBOSE */
586 if (!afs_uuid_equal(uuidp
, &afs_cb_interface
.uuid
))
587 code
= 1; /* failure */
591 /*------------------------------------------------------------------------
592 * EXPORTED SRXAFSCB_GetServerPrefs
595 * Routine to list server preferences used by this client.
598 * a_call : Ptr to Rx call on which this request came in.
599 * a_index : Input server index
600 * a_srvr_addr : Output server address (0xffffffff on last server)
601 * a_srvr_rank : Output server rank
607 * Nothing interesting.
611 *------------------------------------------------------------------------*/
614 SRXAFSCB_GetServerPrefs(struct rx_call
* a_call
, afs_int32 a_index
,
615 afs_int32
* a_srvr_addr
, afs_int32
* a_srvr_rank
)
617 *a_srvr_addr
= 0xffffffff;
618 *a_srvr_rank
= 0xffffffff;
622 /*------------------------------------------------------------------------
623 * EXPORTED SRXAFSCB_GetCellServDB
626 * Routine to list cells configured for this client
629 * a_call : Ptr to Rx call on which this request came in.
630 * a_index : Input cell index
631 * a_name : Output cell name ("" on last cell)
632 * a_hosts : Output cell database servers
635 * RXGEN_OPCODE (always)
638 * Nothing interesting.
642 *------------------------------------------------------------------------*/
645 SRXAFSCB_GetCellServDB(struct rx_call
* a_call
, afs_int32 a_index
,
646 char **a_name
, serverList
* a_hosts
)
652 SRXAFSCB_GetCellByNum(struct rx_call
* a_call
, afs_int32 a_cellnum
,
653 char **a_name
, serverList
* a_hosts
)
658 /*------------------------------------------------------------------------
659 * EXPORTED SRXAFSCB_GetLocalCell
662 * Routine to return name of client's local cell
665 * a_call : Ptr to Rx call on which this request came in.
666 * a_name : Output cell name
669 * RXGEN_OPCODE (always)
672 * Nothing interesting.
676 *------------------------------------------------------------------------*/
679 SRXAFSCB_GetLocalCell(struct rx_call
* a_call
, char **a_name
)
685 /*------------------------------------------------------------------------
686 * EXPORTED SRXAFSCB_GetCacheConfig
689 * Routine to return parameters used to initialize client cache.
690 * Client may request any format version. Server may not return
691 * format version greater than version requested by client.
694 * a_call: Ptr to Rx call on which this request came in.
695 * callerVersion: Data format version desired by the client.
696 * serverVersion: Data format version of output data.
697 * configCount: Number bytes allocated for output data.
698 * config: Client cache configuration.
701 * RXGEN_OPCODE (always)
704 * Nothing interesting.
708 *------------------------------------------------------------------------*/
711 SRXAFSCB_GetCacheConfig(struct rx_call
* a_call
, afs_uint32 callerVersion
,
712 afs_uint32
* serverVersion
, afs_uint32
* configCount
,
713 cacheConfig
* config
)
719 SRXAFSCB_TellMeAboutYourself(struct rx_call
* rxcall
,
720 struct interfaceAddr
* addr
,
721 Capabilities
* capabilities
)
723 #if FSPROBE_CALLBACK_VERBOSE
724 static char rn
[] = "SRXAFSCB_TellMeAboutYourself"; /*Routine name */
725 char hostName
[256]; /*Host name buffer */
726 char *hostNameResult
; /*Ptr to static */
728 if (rxcall
!= (struct rx_call
*)0) {
730 hostutil_GetNameByINet((afs_int32
) (rxcall
->conn
->peer
->host
));
731 strcpy(hostName
, hostNameResult
);
732 fprintf(stderr
, "[%s:%s] Called from host %s, port %d\n", mn
, rn
,
733 hostName
, rxcall
->conn
->peer
->port
);
734 } /*Valid rxcall param */
735 #endif /* FSPROBE_CALLBACK_VERBOSE */
737 if (rxcall
&& addr
) {
740 *addr
= afs_cb_interface
;
744 * Return successfully.
749 int SRXAFSCB_GetDE(struct rx_call
*a_call
, afs_int32 a_index
,
750 afs_int32 addr
, afs_int32 inode
, afs_int32 flags
,
751 afs_int32 time
, char ** fileName
)