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"
20 #include "afs/sysincludes.h" /*Standard vendor system headers */
21 #include "afsincludes.h" /*AFS-based standard headers */
22 #include "afs/afs_stats.h" /* statistics */
24 /* Exported variables */
25 struct rx_service
*afs_server
;
28 #define SMAR 20 /* size of a mariner name */
29 #define NMAR 10 /* number of mariner names */
30 static char marinerNames
[NMAR
][SMAR
];
31 static struct vcache
*marinerVCs
[NMAR
];
32 static int marinerPtr
= 0; /* pointer to next mariner slot to use */
34 /* Exported variables */
35 afs_int32 afs_mariner
= 0;
36 afs_int32 afs_marinerHost
= 0;
39 afs_AddMarinerName(char *aname
, struct vcache
*avc
)
44 AFS_STATCNT(afs_AddMarinerName
);
51 strncpy(tp
, aname
, SMAR
);
58 afs_GetMariner(struct vcache
*avc
)
61 AFS_STATCNT(afs_GetMariner
);
62 for (i
= 0; i
< NMAR
; i
++) {
63 if (marinerVCs
[i
] == avc
) {
64 return marinerNames
[i
];
71 afs_MarinerLogFetch(struct vcache
*avc
, afs_int32 off
,
72 afs_int32 bytes
, afs_int32 idx
)
74 afs_MarinerLog("fetch$Fetching", avc
);
75 } /*afs_MarinerLogFetch */
78 afs_MarinerLog(char *astring
, struct vcache
*avc
)
80 struct sockaddr_in taddr
;
84 AFS_STATCNT(afs_MarinerLog
);
85 taddr
.sin_family
= AF_INET
;
86 taddr
.sin_addr
.s_addr
= afs_marinerHost
;
87 taddr
.sin_port
= htons(2106);
88 #ifdef STRUCT_SOCKADDR_HAS_SA_LEN
89 taddr
.sin_len
= sizeof(taddr
);
91 tp
= buf
= osi_AllocSmallSpace(AFS_SMALLOCSIZ
);
94 tp
+= strlen(astring
);
97 tp1
= afs_GetMariner(avc
);
102 /* note, console doesn't want a terminating null */
103 /* I don't care if mariner packets fail to be sent */
105 dvec
.iov_len
= tp
- buf
;
107 (void)osi_NetSend(afs_server
->socket
, &taddr
, &dvec
, 1, tp
- buf
, 0);
109 osi_FreeSmallSpace(buf
);
110 } /*afs_MarinerLog */
113 shutdown_mariner(void)
120 for (i
= 0; i
< NMAR
; i
++)