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
9 * Portions Copyright (c) 2003 Apple Computer, Inc.
13 * This file contains sample code for the rxstats interface
16 #include <afsconfig.h>
17 #include <afs/param.h>
26 #include <rx/rxstat.h>
28 #include <afs/afs_Admin.h>
29 #include <afs/afs_clientAdmin.h>
30 #include <afs/afs_utilAdmin.h>
35 fprintf(stderr
, "Usage: rxdebug_conns <host> <port>\n");
40 ParseArgs(int argc
, char *argv
[], char **srvrName
, long *srvrPort
)
46 *srvrName
= *(argp
++);
49 *srvrPort
= strtol(*(argp
++), NULL
, 0);
50 if (*srvrPort
<= 0 || *srvrPort
>= 65536)
57 main(int argc
, char *argv
[])
61 rxdebugHandle_p handle
;
65 struct rx_debugConn conn
;
66 afs_uint32 supportedStats
;
67 afs_uint32 supportedValues
;
71 ParseArgs(argc
, argv
, &srvrName
, &srvrPort
);
73 rc
= afsclient_Init(&st
);
75 fprintf(stderr
, "afsclient_Init, status %d\n", st
);
79 rc
= afsclient_RXDebugOpenPort(srvrName
, srvrPort
, &handle
, &st
);
81 fprintf(stderr
, "afsclient_RXDebugOpenPort, status %d\n", st
);
85 rc
= util_RXDebugSupportedStats(handle
, &supportedStats
, &st
);
87 fprintf(stderr
, "util_RXDebugSupportedStats, status %d\n", st
);
91 rc
= util_RXDebugConnectionsBegin(handle
, allconns
, &iterator
, &st
);
92 if (!rc
&& st
== ADMCLIENTRXDEBUGNOTSUPPORTED
) {
94 rc
= util_RXDebugConnectionsBegin(handle
, allconns
, &iterator
, &st
);
97 fprintf(stderr
, "util_RXDebugConnectionsBegin, status %d\n", st
);
103 printf("Listing all connections for server %s (port %ld)\n", srvrName
,
107 ("Listing only interesting connections for server %s (port %ld)\n",
111 while (util_RXDebugConnectionsNext
112 (iterator
, &conn
, &supportedValues
, &st
)) {
114 printf("host: %u.%u.%u.%u\n",
115 (conn
.host
>> 24) & 0xff, (conn
.host
>> 16) & 0xff,
116 (conn
.host
>> 8) & 0xff, conn
.host
& 0xff);
117 printf("cid: %08x\n", conn
.cid
);
118 printf("serial: %08x\n", conn
.serial
);
119 printf("error: %u\n", conn
.error
);
120 printf("port: %u\n", conn
.port
);
121 printf("flags: %x\n", conn
.flags
);
122 printf("type: %u\n", conn
.type
);
123 printf("securityIndex: %u\n", conn
.securityIndex
);
124 for (i
= 0; i
< RX_MAXCALLS
; i
++) {
125 printf("callNumber[%u]: %u\n", i
, conn
.callNumber
[i
]);
126 printf("callState[%u]: %u\n", i
, conn
.callState
[i
]);
127 printf("callMode[%u]: %u\n", i
, conn
.callMode
[i
]);
128 printf("callFlags[%u]: %x\n", i
, conn
.callFlags
[i
]);
129 printf("callOther[%u]: %x\n", i
, conn
.callOther
[i
]);
131 if (supportedStats
& RX_SERVER_DEBUG_SEC_STATS
) {
132 printf("secStats.type: %u\n", conn
.secStats
.type
);
133 printf("secStats.level: %u\n", conn
.secStats
.level
);
134 printf("secStats.flags: %x\n", conn
.secStats
.flags
);
135 printf("secStats.expires: %x\n", conn
.secStats
.expires
);
136 printf("secStats.packetsReceived: %x\n",
137 conn
.secStats
.packetsReceived
);
138 printf("secStats.packetsSent: %x\n",
139 conn
.secStats
.packetsSent
);
140 printf("secStats.bytesReceived: %x\n",
141 conn
.secStats
.bytesReceived
);
142 printf("secStats.bytesSent: %x\n", conn
.secStats
.bytesSent
);
143 printf("natMTU: %u\n", conn
.natMTU
);
144 printf("epoch: %08x\n", conn
.epoch
);
147 if (st
!= ADMITERATORDONE
) {
148 fprintf(stderr
, "util_RXDebugConnectionsNext, status %d\n", st
);
153 rc
= util_RXDebugConnectionsDone(iterator
, &st
);
155 fprintf(stderr
, "util_RXDebugConnectionsDone, status %d\n", st
);
159 rc
= afsclient_RXDebugClose(handle
, &st
);
161 fprintf(stderr
, "afsclient_RXDebugClose, status %d\n", st
);