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 "../afs/sysincludes.h" /*Standard vendor system headers*/
18 #include "../afs/afsincludes.h" /*AFS-based standard headers*/
19 #include "../afs/afs_stats.h" /* statistics */
21 /* Exported variables */
22 struct rx_service *afs_server;
25 #define SMAR 20 /* size of a mariner name */
26 #define NMAR 10 /* number of mariner names */
27 static char marinerNames[NMAR][SMAR];
28 static struct vcache *marinerVCs[NMAR];
29 static int marinerPtr = 0; /* pointer to next mariner slot to use */
31 /* Exported variables */
32 afs_int32 afs_mariner = 0;
33 afs_int32 afs_marinerHost = 0;
35 afs_AddMarinerName(aname, avc)
37 register struct vcache *avc; {
41 AFS_STATCNT(afs_AddMarinerName);
48 strncpy(tp, aname, SMAR);
54 char *afs_GetMariner(avc)
55 register struct vcache *avc; {
57 AFS_STATCNT(afs_GetMariner);
58 for(i=0; i<NMAR; i++) {
59 if (marinerVCs[i] == avc) {
60 return marinerNames[i];
66 void afs_MarinerLogFetch(avc, off, bytes, idx)
67 register struct vcache *avc;
68 register afs_int32 off, bytes, idx;
70 struct sockaddr_in taddr;
71 register char *tp, *tp1, *tp2;
76 AFS_STATCNT(afs_MarinerLog);
77 taddr.sin_family = AF_INET;
78 taddr.sin_addr.s_addr = afs_marinerHost;
79 taddr.sin_port = htons(2106);
81 taddr.sin_len = sizeof(taddr);
82 #endif /* AFS_OSF_ENV */
83 tp = tp1 = (char *) osi_AllocSmallSpace(AFS_SMALLOCSIZ);
84 strcpy(tp, "fetch$Fetching ");
85 tp += 15; /* change it if string changes */
86 tp2 = afs_GetMariner(avc);
90 /* note, console doesn't want a terminating null */
91 len = strlen(tp1) - 1;
92 /* I don't care if mariner packets fail to be sent */
96 (void) osi_NetSend(afs_server->socket, &taddr, &dvec, 1, len, 0);
98 osi_FreeSmallSpace(tp1);
99 } /*afs_MarinerLogFetch*/
101 void afs_MarinerLog(astring, avc)
102 register struct vcache *avc;
103 register char *astring;
105 struct sockaddr_in taddr;
106 register char *tp, *tp1, *buf;
109 AFS_STATCNT(afs_MarinerLog);
110 taddr.sin_family = AF_INET;
111 taddr.sin_addr.s_addr = afs_marinerHost;
112 taddr.sin_port = htons(2106);
113 tp = buf = (char *) osi_AllocSmallSpace(AFS_SMALLOCSIZ);
116 tp += strlen(astring);
118 tp1 = afs_GetMariner(avc);
122 /* note, console doesn't want a terminating null */
123 /* I don't care if mariner packets fail to be sent */
125 dvec.iov_len = tp-buf;
127 (void) osi_NetSend(afs_server->socket, &taddr, &dvec, 1, tp-buf, 0);
129 osi_FreeSmallSpace(buf);
132 void shutdown_mariner(void)
139 for (i=0; i<NMAR; i++)