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 <afsconfig.h>
17 #include "afs/param.h"
22 #include "afs/sysincludes.h" /*Standard vendor system headers */
23 #include "afsincludes.h" /*AFS-based standard headers */
24 #include "afs/afs_stats.h" /* statistics */
26 /* Exported variables */
27 struct rx_service *afs_server;
30 #define SMAR 20 /* size of a mariner name */
31 #define NMAR 10 /* number of mariner names */
32 static char marinerNames[NMAR][SMAR];
33 static struct vcache *marinerVCs[NMAR];
34 static int marinerPtr = 0; /* pointer to next mariner slot to use */
36 /* Exported variables */
37 afs_int32 afs_mariner = 0;
38 afs_int32 afs_marinerHost = 0;
41 afs_AddMarinerName(register char *aname, register struct vcache *avc)
46 AFS_STATCNT(afs_AddMarinerName);
53 strncpy(tp, aname, SMAR);
60 afs_GetMariner(register struct vcache *avc)
63 AFS_STATCNT(afs_GetMariner);
64 for (i = 0; i < NMAR; i++) {
65 if (marinerVCs[i] == avc) {
66 return marinerNames[i];
73 afs_MarinerLogFetch(register struct vcache *avc, register afs_int32 off,
74 register afs_int32 bytes, register afs_int32 idx)
76 struct sockaddr_in taddr;
77 register char *tp, *tp1, *tp2;
82 AFS_STATCNT(afs_MarinerLog);
83 taddr.sin_family = AF_INET;
84 taddr.sin_addr.s_addr = afs_marinerHost;
85 taddr.sin_port = htons(2106);
86 #ifdef STRUCT_SOCKADDR_HAS_SA_LEN
87 taddr.sin_len = sizeof(taddr);
88 #endif /* AFS_OSF_ENV */
89 tp = tp1 = (char *)osi_AllocSmallSpace(AFS_SMALLOCSIZ);
90 strcpy(tp, "fetch$Fetching ");
91 tp += 15; /* change it if string changes */
92 tp2 = afs_GetMariner(avc);
96 /* note, console doesn't want a terminating null */
97 len = strlen(tp1) - 1;
98 /* I don't care if mariner packets fail to be sent */
102 (void)osi_NetSend(afs_server->socket, (struct sockaddr_storage *) &taddr,
103 sizeof(taddr), &dvec, 1, len, 0);
105 osi_FreeSmallSpace(tp1);
106 } /*afs_MarinerLogFetch */
109 afs_MarinerLog(register char *astring, register struct vcache *avc)
111 struct sockaddr_in taddr;
112 register char *tp, *tp1, *buf;
115 AFS_STATCNT(afs_MarinerLog);
116 taddr.sin_family = AF_INET;
117 taddr.sin_addr.s_addr = afs_marinerHost;
118 taddr.sin_port = htons(2106);
119 #ifdef STRUCT_SOCKADDR_HAS_SA_LEN
120 taddr.sin_len = sizeof(taddr);
121 #endif /* AFS_OSF_ENV */
122 tp = buf = (char *)osi_AllocSmallSpace(AFS_SMALLOCSIZ);
125 tp += strlen(astring);
127 tp1 = afs_GetMariner(avc);
131 /* note, console doesn't want a terminating null */
132 /* I don't care if mariner packets fail to be sent */
134 dvec.iov_len = tp - buf;
136 (void)osi_NetSend(afs_server->socket, (struct sockaddr_storage *) &taddr,
137 sizeof(taddr), &dvec, 1, tp - buf, 0);
139 osi_FreeSmallSpace(buf);
140 } /*afs_MarinerLog */
143 shutdown_mariner(void)
150 for (i = 0; i < NMAR; i++)