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
11 * afs_mariner.c - fetch/store monitoring facility.
16 #include "../afs/param.h" /*Should be always first*/
17 #include <afsconfig.h>
21 #include "../afs/sysincludes.h" /*Standard vendor system headers*/
22 #include "../afs/afsincludes.h" /*AFS-based standard headers*/
23 #include "../afs/afs_stats.h" /* statistics */
25 /* Exported variables */
26 struct rx_service *afs_server;
29 #define SMAR 20 /* size of a mariner name */
30 #define NMAR 10 /* number of mariner names */
31 static char marinerNames[NMAR][SMAR];
32 static struct vcache *marinerVCs[NMAR];
33 static int marinerPtr = 0; /* pointer to next mariner slot to use */
35 /* Exported variables */
36 afs_int32 afs_mariner = 0;
37 afs_int32 afs_marinerHost = 0;
39 afs_AddMarinerName(aname, avc)
41 register struct vcache *avc; {
45 AFS_STATCNT(afs_AddMarinerName);
52 strncpy(tp, aname, SMAR);
58 char *afs_GetMariner(avc)
59 register struct vcache *avc; {
61 AFS_STATCNT(afs_GetMariner);
62 for(i=0; i<NMAR; i++) {
63 if (marinerVCs[i] == avc) {
64 return marinerNames[i];
70 void afs_MarinerLogFetch(avc, off, bytes, idx)
71 register struct vcache *avc;
72 register afs_int32 off, bytes, idx;
74 struct sockaddr_in taddr;
75 register char *tp, *tp1, *tp2;
80 AFS_STATCNT(afs_MarinerLog);
81 taddr.sin_family = AF_INET;
82 taddr.sin_addr.s_addr = afs_marinerHost;
83 taddr.sin_port = htons(2106);
85 taddr.sin_len = sizeof(taddr);
86 #endif /* AFS_OSF_ENV */
87 tp = tp1 = (char *) osi_AllocSmallSpace(AFS_SMALLOCSIZ);
88 strcpy(tp, "fetch$Fetching ");
89 tp += 15; /* change it if string changes */
90 tp2 = afs_GetMariner(avc);
94 /* note, console doesn't want a terminating null */
95 len = strlen(tp1) - 1;
96 /* I don't care if mariner packets fail to be sent */
100 (void) osi_NetSend(afs_server->socket, &taddr, &dvec, 1, len, 0);
102 osi_FreeSmallSpace(tp1);
103 } /*afs_MarinerLogFetch*/
105 void afs_MarinerLog(astring, avc)
106 register struct vcache *avc;
107 register char *astring;
109 struct sockaddr_in taddr;
110 register char *tp, *tp1, *buf;
113 AFS_STATCNT(afs_MarinerLog);
114 taddr.sin_family = AF_INET;
115 taddr.sin_addr.s_addr = afs_marinerHost;
116 taddr.sin_port = htons(2106);
117 tp = buf = (char *) osi_AllocSmallSpace(AFS_SMALLOCSIZ);
120 tp += strlen(astring);
122 tp1 = afs_GetMariner(avc);
126 /* note, console doesn't want a terminating null */
127 /* I don't care if mariner packets fail to be sent */
129 dvec.iov_len = tp-buf;
131 (void) osi_NetSend(afs_server->socket, &taddr, &dvec, 1, tp-buf, 0);
133 osi_FreeSmallSpace(buf);
136 void shutdown_mariner(void)
143 for (i=0; i<NMAR; i++)