| File: | rxdebug/rxdebug.c |
| Location: | line 267, column 6 |
| Description: | Value stored to 'withRxStats' is never read |
| 1 | /* |
| 2 | * Copyright 2000, International Business Machines Corporation and others. |
| 3 | * All Rights Reserved. |
| 4 | * |
| 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 |
| 8 | */ |
| 9 | |
| 10 | #include <afsconfig.h> |
| 11 | #include <afs/param.h> |
| 12 | #include <afs/stds.h> |
| 13 | |
| 14 | #include <roken.h> |
| 15 | |
| 16 | #include <afs/afsutil.h> |
| 17 | #include <afs/cmd.h> |
| 18 | |
| 19 | #include <rx/rx_user.h> |
| 20 | #include <rx/rx_clock.h> |
| 21 | #include <rx/rx_queue.h> |
| 22 | #include <rx/rx.h> |
| 23 | #include <rx/rx_globals.h> |
| 24 | |
| 25 | |
| 26 | #define TIMEOUT20 20 |
| 27 | |
| 28 | static short |
| 29 | PortNumber(char *aport) |
| 30 | { |
| 31 | int tc; |
| 32 | short total; |
| 33 | |
| 34 | total = 0; |
| 35 | while ((tc = *aport++)) { |
| 36 | if (tc < '0' || tc > '9') |
| 37 | return -1; /* bad port number */ |
| 38 | total *= 10; |
| 39 | total += tc - (int)'0'; |
| 40 | } |
| 41 | return htons(total)(__builtin_constant_p(total) ? (__uint16_t)(((__uint16_t)(total )) << 8 | ((__uint16_t)(total)) >> 8) : __bswap16_var (total)); |
| 42 | } |
| 43 | |
| 44 | static short |
| 45 | PortName(char *aname) |
| 46 | { |
| 47 | struct servent *ts; |
| 48 | ts = getservbyname(aname, NULL((void *)0)); |
| 49 | if (!ts) |
| 50 | return -1; |
| 51 | return ts->s_port; /* returns it in network byte order */ |
| 52 | } |
| 53 | |
| 54 | int |
| 55 | MainCommand(struct cmd_syndesc *as, void *arock) |
| 56 | { |
| 57 | int i; |
| 58 | osi_socket s; |
| 59 | int j; |
| 60 | struct sockaddr_in taddr; |
| 61 | afs_int32 host; |
| 62 | struct in_addr hostAddr; |
| 63 | short port; |
| 64 | struct hostent *th; |
| 65 | afs_int32 code; |
| 66 | int nodally; |
| 67 | int allconns; |
| 68 | int rxstats; |
| 69 | int onlyClient, onlyServer; |
| 70 | afs_int32 onlyHost; |
| 71 | short onlyPort; |
| 72 | int onlyAuth; |
| 73 | int flag; |
| 74 | int dallyCounter; |
| 75 | int withSecStats; |
| 76 | int withAllConn; |
| 77 | int withRxStats; |
| 78 | int withWaiters; |
| 79 | int withIdleThreads; |
| 80 | int withWaited; |
| 81 | int withPeers; |
| 82 | int withPackets; |
| 83 | struct rx_debugStats tstats; |
| 84 | char *portName, *hostName; |
| 85 | char hoststr[20]; |
| 86 | struct rx_debugConn tconn; |
| 87 | short noConns; |
| 88 | short showPeers; |
| 89 | short showLong; |
| 90 | int version_flag; |
| 91 | char version[64]; |
| 92 | afs_int32 length = 64; |
| 93 | |
| 94 | afs_uint32 supportedDebugValues = 0; |
| 95 | afs_uint32 supportedStatValues = 0; |
| 96 | afs_uint32 supportedConnValues = 0; |
| 97 | afs_uint32 supportedPeerValues = 0; |
| 98 | afs_int32 nextconn = 0; |
| 99 | afs_int32 nextpeer = 0; |
| 100 | |
| 101 | nodally = (as->parms[2].items ? 1 : 0); |
| 102 | allconns = (as->parms[3].items ? 1 : 0); |
| 103 | rxstats = (as->parms[4].items ? 1 : 0); |
| 104 | onlyServer = (as->parms[5].items ? 1 : 0); |
| 105 | onlyClient = (as->parms[6].items ? 1 : 0); |
| 106 | version_flag = (as->parms[10].items ? 1 : 0); |
| 107 | noConns = (as->parms[11].items ? 1 : 0); |
| 108 | showPeers = (as->parms[12].items ? 1 : 0); |
| 109 | showLong = (as->parms[13].items ? 1 : 0); |
| 110 | |
| 111 | if (as->parms[0].items) |
| 112 | hostName = as->parms[0].items->data; |
| 113 | else |
| 114 | hostName = NULL((void *)0); |
| 115 | |
| 116 | if (as->parms[1].items) |
| 117 | portName = as->parms[1].items->data; |
| 118 | else |
| 119 | portName = NULL((void *)0); |
| 120 | |
| 121 | if (as->parms[7].items) { |
| 122 | char *name = as->parms[7].items->data; |
| 123 | if ((onlyPort = PortNumber(name)) == -1) |
| 124 | onlyPort = PortName(name); |
| 125 | if (onlyPort == -1) { |
| 126 | printf("rxdebug: can't resolve port name %s\n", name); |
| 127 | exit(1); |
| 128 | } |
| 129 | } else |
| 130 | onlyPort = -1; |
| 131 | |
| 132 | if (as->parms[8].items) { |
| 133 | char *name = as->parms[8].items->data; |
| 134 | struct hostent *th; |
| 135 | th = hostutil_GetHostByName(name); |
| 136 | if (!th) { |
| 137 | printf("rxdebug: host %s not found in host table\n", name); |
| 138 | exit(1); |
| 139 | } |
| 140 | memcpy(&onlyHost, th->h_addrh_addr_list[0], sizeof(afs_int32)); |
| 141 | } else |
| 142 | onlyHost = -1; |
| 143 | |
| 144 | if (as->parms[9].items) { |
| 145 | char *name = as->parms[9].items->data; |
| 146 | if (strcmp(name, "clear") == 0) |
| 147 | onlyAuth = 0; |
| 148 | else if (strcmp(name, "auth") == 0) |
| 149 | onlyAuth = 1; |
| 150 | else if (strcmp(name, "crypt") == 0) |
| 151 | onlyAuth = 2; |
| 152 | else if ((strcmp(name, "null") == 0) || (strcmp(name, "none") == 0) |
| 153 | || (strncmp(name, "noauth", 6) == 0) |
| 154 | || (strncmp(name, "unauth", 6) == 0)) |
| 155 | onlyAuth = -1; |
| 156 | else { |
| 157 | fprintf(stderr__stderrp, "Unknown authentication level: %s\n", name); |
| 158 | exit(1); |
| 159 | } |
| 160 | } else |
| 161 | onlyAuth = 999; |
| 162 | |
| 163 | /* lookup host */ |
| 164 | if (hostName) { |
| 165 | th = hostutil_GetHostByName(hostName); |
| 166 | if (!th) { |
| 167 | printf("rxdebug: host %s not found in host table\n", hostName); |
| 168 | exit(1); |
| 169 | } |
| 170 | memcpy(&host, th->h_addrh_addr_list[0], sizeof(afs_int32)); |
| 171 | } else |
| 172 | host = htonl(0x7f000001)(__builtin_constant_p(0x7f000001) ? ((((__uint32_t)(0x7f000001 )) >> 24) | ((((__uint32_t)(0x7f000001)) & (0xff << 16)) >> 8) | ((((__uint32_t)(0x7f000001)) & (0xff << 8)) << 8) | (((__uint32_t)(0x7f000001)) << 24)) : __bswap32_var(0x7f000001)); /* IP localhost */ |
| 173 | |
| 174 | if (!portName) |
| 175 | port = htons(7000)(__builtin_constant_p(7000) ? (__uint16_t)(((__uint16_t)(7000 )) << 8 | ((__uint16_t)(7000)) >> 8) : __bswap16_var (7000)); /* default is fileserver */ |
| 176 | else { |
| 177 | if ((port = PortNumber(portName)) == -1) |
| 178 | port = PortName(portName); |
| 179 | if (port == -1) { |
| 180 | printf("rxdebug: can't resolve port name %s\n", portName); |
| 181 | exit(1); |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | dallyCounter = 0; |
| 186 | |
| 187 | hostAddr.s_addr = host; |
| 188 | afs_inet_ntoa_r(hostAddr.s_addr, hoststr); |
| 189 | printf("Trying %s (port %d):\n", hoststr, ntohs(port)(__builtin_constant_p(port) ? (__uint16_t)(((__uint16_t)(port )) << 8 | ((__uint16_t)(port)) >> 8) : __bswap16_var (port))); |
| 190 | s = socket(AF_INET2, SOCK_DGRAM2, IPPROTO_UDP17); |
| 191 | if (s == OSI_NULLSOCKET((osi_socket) -1)) { |
| 192 | #ifdef AFS_NT40_ENV |
| 193 | fprintf(stderr__stderrp, "socket() failed with error %u\n", WSAGetLastError()); |
| 194 | #else |
| 195 | perror("socket"); |
| 196 | #endif |
| 197 | exit(1); |
| 198 | } |
| 199 | taddr.sin_family = AF_INET2; |
| 200 | taddr.sin_port = 0; |
| 201 | taddr.sin_addr.s_addr = 0; |
| 202 | #ifdef STRUCT_SOCKADDR_HAS_SA_LEN1 |
| 203 | taddr.sin_len = sizeof(struct sockaddr_in); |
| 204 | #endif |
| 205 | code = bind(s, (struct sockaddr *)&taddr, sizeof(struct sockaddr_in)); |
| 206 | if (code) { |
| 207 | #ifdef AFS_NT40_ENV |
| 208 | fprintf(stderr__stderrp, "bind() failed with error %u\n", WSAGetLastError()); |
| 209 | #else |
| 210 | perror("bind"); |
| 211 | #endif |
| 212 | exit(1); |
| 213 | } |
| 214 | |
| 215 | if (version_flag) { |
| 216 | |
| 217 | code = rx_GetServerVersion(s, host, port, length, version); |
| 218 | if (code < 0) { |
| 219 | printf("get version call failed with code %d, errno %d\n", code, |
| 220 | errno(* __error())); |
| 221 | exit(1); |
| 222 | } |
| 223 | printf("AFS version: %s\n", version); |
| 224 | fflush(stdout__stdoutp); |
| 225 | |
| 226 | exit(0); |
| 227 | |
| 228 | } |
| 229 | |
| 230 | |
| 231 | code = rx_GetServerDebug(s, host, port, &tstats, &supportedDebugValues); |
| 232 | if (code < 0) { |
| 233 | printf("getstats call failed with code %d\n", code); |
| 234 | exit(1); |
| 235 | } |
| 236 | |
| 237 | withSecStats = (supportedDebugValues & RX_SERVER_DEBUG_SEC_STATS0x1); |
| 238 | withAllConn = (supportedDebugValues & RX_SERVER_DEBUG_ALL_CONN0x2); |
| 239 | withRxStats = (supportedDebugValues & RX_SERVER_DEBUG_RX_STATS0x4); |
| 240 | withWaiters = (supportedDebugValues & RX_SERVER_DEBUG_WAITER_CNT0x8); |
| 241 | withIdleThreads = (supportedDebugValues & RX_SERVER_DEBUG_IDLE_THREADS0x10); |
| 242 | withWaited = (supportedDebugValues & RX_SERVER_DEBUG_WAITED_CNT0x100); |
| 243 | withPeers = (supportedDebugValues & RX_SERVER_DEBUG_ALL_PEER0x80); |
| 244 | withPackets = (supportedDebugValues & RX_SERVER_DEBUG_PACKETS_CNT0x200); |
| 245 | |
| 246 | if (withPackets) |
| 247 | printf("Free packets: %d/%d, packet reclaims: %d, calls: %d, used FDs: %d\n", |
| 248 | tstats.nFreePackets, tstats.nPackets, tstats.packetReclaims, |
| 249 | tstats.callsExecuted, tstats.usedFDs); |
| 250 | else |
| 251 | printf("Free packets: %d, packet reclaims: %d, calls: %d, used FDs: %d\n", |
| 252 | tstats.nFreePackets, tstats.packetReclaims, tstats.callsExecuted, |
| 253 | tstats.usedFDs); |
| 254 | if (!tstats.waitingForPackets) |
| 255 | printf("not "); |
| 256 | printf("waiting for packets.\n"); |
| 257 | if (withWaiters) |
| 258 | printf("%d calls waiting for a thread\n", tstats.nWaiting); |
| 259 | if (withIdleThreads) |
| 260 | printf("%d threads are idle\n", tstats.idleThreads); |
| 261 | if (withWaited) |
| 262 | printf("%d calls have waited for a thread\n", tstats.nWaited); |
| 263 | |
| 264 | if (rxstats) { |
| 265 | if (!withRxStats) { |
| 266 | noRxStats: |
| 267 | withRxStats = 0; |
Value stored to 'withRxStats' is never read | |
| 268 | fprintf(stderr__stderrp, |
| 269 | "WARNING: Server doesn't support retrieval of Rx statistics\n"); |
| 270 | } else { |
| 271 | struct rx_statistics rxstats; |
| 272 | |
| 273 | /* should gracefully handle the case where rx_stats grows */ |
| 274 | code = |
| 275 | rx_GetServerStats(s, host, port, &rxstats, |
| 276 | &supportedStatValues); |
| 277 | if (code < 0) { |
| 278 | printf("rxstats call failed with code %d\n", code); |
| 279 | exit(1); |
| 280 | } |
| 281 | if (code != sizeof(rxstats)) { |
| 282 | struct rx_debugIn debug; |
| 283 | memcpy(&debug, &rxstats, sizeof(debug)); |
| 284 | if (debug.type == RX_DEBUGI_BADTYPE(-8)) |
| 285 | goto noRxStats; |
| 286 | printf |
| 287 | ("WARNING: returned Rx statistics of unexpected size (got %d)\n", |
| 288 | code); |
| 289 | /* handle other versions?... */ |
| 290 | } |
| 291 | |
| 292 | rx_PrintTheseStats(stdout__stdoutp, &rxstats, sizeof(rxstats), |
| 293 | tstats.nFreePackets, tstats.version); |
| 294 | } |
| 295 | } |
| 296 | |
| 297 | if (!noConns) { |
| 298 | if (allconns) { |
| 299 | if (!withAllConn) |
| 300 | fprintf(stderr__stderrp, |
| 301 | "WARNING: Server doesn't support retrieval of all connections,\n getting only interesting instead.\n"); |
| 302 | } |
| 303 | |
| 304 | if (onlyServer) |
| 305 | printf("Showing only server connections\n"); |
| 306 | if (onlyClient) |
| 307 | printf("Showing only client connections\n"); |
| 308 | if (onlyAuth != 999) { |
| 309 | static char *name[] = |
| 310 | { "unauthenticated", "rxkad_clear", "rxkad_auth", |
| 311 | "rxkad_crypt" |
| 312 | }; |
| 313 | printf("Showing only %s connections\n", name[onlyAuth + 1]); |
| 314 | } |
| 315 | if (onlyHost != -1) { |
| 316 | hostAddr.s_addr = onlyHost; |
| 317 | afs_inet_ntoa_r(hostAddr.s_addr, hoststr); |
| 318 | printf("Showing only connections from host %s\n", |
| 319 | hoststr); |
| 320 | } |
| 321 | if (onlyPort != -1) |
| 322 | printf("Showing only connections on port %u\n", ntohs(onlyPort)(__builtin_constant_p(onlyPort) ? (__uint16_t)(((__uint16_t)( onlyPort)) << 8 | ((__uint16_t)(onlyPort)) >> 8) : __bswap16_var(onlyPort))); |
| 323 | |
| 324 | for (i = 0;; i++) { |
| 325 | code = |
| 326 | rx_GetServerConnections(s, host, port, &nextconn, allconns, |
| 327 | supportedDebugValues, &tconn, |
| 328 | &supportedConnValues); |
| 329 | if (code < 0) { |
| 330 | printf("getconn call failed with code %d\n", code); |
| 331 | break; |
| 332 | } |
| 333 | if (tconn.cid == (afs_int32) 0xffffffff) { |
| 334 | printf("Done.\n"); |
| 335 | break; |
| 336 | } |
| 337 | |
| 338 | /* see if we're in nodally mode and all calls are dallying */ |
| 339 | if (nodally) { |
| 340 | flag = 0; |
| 341 | for (j = 0; j < RX_MAXCALLS4; j++) { |
| 342 | if (tconn.callState[j] != RX_STATE_NOTINIT0 |
| 343 | && tconn.callState[j] != RX_STATE_DALLY3) { |
| 344 | flag = 1; |
| 345 | break; |
| 346 | } |
| 347 | } |
| 348 | if (flag == 0) { |
| 349 | /* this call looks too ordinary, bump skipped count and go |
| 350 | * around again */ |
| 351 | dallyCounter++; |
| 352 | continue; |
| 353 | } |
| 354 | } |
| 355 | if ((onlyHost != -1) && (onlyHost != tconn.host)) |
| 356 | continue; |
| 357 | if ((onlyPort != -1) && (onlyPort != tconn.port)) |
| 358 | continue; |
| 359 | if (onlyServer && (tconn.type != RX_SERVER_CONNECTION1)) |
| 360 | continue; |
| 361 | if (onlyClient && (tconn.type != RX_CLIENT_CONNECTION0)) |
| 362 | continue; |
| 363 | if (onlyAuth != 999) { |
| 364 | if (onlyAuth == -1) { |
| 365 | if (tconn.securityIndex != 0) |
| 366 | continue; |
| 367 | } else { |
| 368 | if (tconn.securityIndex != 2) |
| 369 | continue; |
| 370 | if (withSecStats && (tconn.secStats.type == 3) |
| 371 | && (tconn.secStats.level != onlyAuth)) |
| 372 | continue; |
| 373 | } |
| 374 | } |
| 375 | |
| 376 | /* now display the connection */ |
| 377 | hostAddr.s_addr = tconn.host; |
| 378 | afs_inet_ntoa_r(hostAddr.s_addr, hoststr); |
| 379 | printf("Connection from host %s, port %hu, ", hoststr, |
| 380 | ntohs(tconn.port)(__builtin_constant_p(tconn.port) ? (__uint16_t)(((__uint16_t )(tconn.port)) << 8 | ((__uint16_t)(tconn.port)) >> 8) : __bswap16_var(tconn.port))); |
| 381 | if (tconn.epoch) |
| 382 | printf("Cuid %x/%x", tconn.epoch, tconn.cid); |
| 383 | else |
| 384 | printf("cid %x", tconn.cid); |
| 385 | if (tconn.error) |
| 386 | printf(", error %d", tconn.error); |
| 387 | printf("\n serial %d, ", tconn.serial); |
| 388 | printf(" natMTU %d, ", tconn.natMTU); |
| 389 | |
| 390 | if (tconn.flags) { |
| 391 | printf("flags"); |
| 392 | if (tconn.flags & RX_CONN_MAKECALL_WAITING1) |
| 393 | printf(" MAKECALL_WAITING"); |
| 394 | if (tconn.flags & RX_CONN_DESTROY_ME2) |
| 395 | printf(" DESTROYED"); |
| 396 | if (tconn.flags & RX_CONN_USING_PACKET_CKSUM4) |
| 397 | printf(" pktCksum"); |
| 398 | if (tconn.flags & RX_CONN_KNOW_WINDOW8) |
| 399 | printf(" knowWindow"); |
| 400 | if (tconn.flags & RX_CONN_RESET16) |
| 401 | printf(" reset"); |
| 402 | if (tconn.flags & RX_CONN_BUSY32) |
| 403 | printf(" busy"); |
| 404 | if (tconn.flags & RX_CONN_ATTACHWAIT64) |
| 405 | printf(" attachWait"); |
| 406 | printf(", "); |
| 407 | } |
| 408 | printf("security index %d, ", tconn.securityIndex); |
| 409 | if (tconn.type == RX_CLIENT_CONNECTION0) |
| 410 | printf("client conn\n"); |
| 411 | else |
| 412 | printf("server conn\n"); |
| 413 | |
| 414 | if (withSecStats) { |
| 415 | switch ((int)tconn.secStats.type) { |
| 416 | case 0: |
| 417 | if (tconn.securityIndex == 2) |
| 418 | printf |
| 419 | (" no GetStats procedure for security object\n"); |
| 420 | break; |
| 421 | case 1: |
| 422 | printf(" rxnull level=%d, flags=%d\n", |
| 423 | tconn.secStats.level, tconn.secStats.flags); |
| 424 | break; |
| 425 | case 2: |
| 426 | printf(" rxvab level=%d, flags=%d\n", |
| 427 | tconn.secStats.level, tconn.secStats.flags); |
| 428 | break; |
| 429 | case 3:{ |
| 430 | char *level; |
| 431 | char flags = tconn.secStats.flags; |
| 432 | if (tconn.secStats.level == 0) |
| 433 | level = "clear"; |
| 434 | else if (tconn.secStats.level == 1) |
| 435 | level = "auth"; |
| 436 | else if (tconn.secStats.level == 2) |
| 437 | level = "crypt"; |
| 438 | else |
| 439 | level = "unknown"; |
| 440 | printf(" rxkad: level %s", level); |
| 441 | if (flags) |
| 442 | printf(", flags"); |
| 443 | if (flags & 1) |
| 444 | printf(" unalloc"); |
| 445 | if (flags & 2) |
| 446 | printf(" authenticated"); |
| 447 | if (flags & 4) |
| 448 | printf(" expired"); |
| 449 | if (flags & 8) |
| 450 | printf(" pktCksum"); |
| 451 | if (tconn.secStats.expires) |
| 452 | /* Apparently due to a bug in the RT compiler that |
| 453 | * prevents (afs_uint32)0xffffffff => (double) from working, |
| 454 | * this code produces negative lifetimes when run on the |
| 455 | * RT. */ |
| 456 | printf(", expires in %.1f hours", |
| 457 | ((afs_uint32) tconn.secStats.expires - |
| 458 | time(0)) / 3600.0); |
| 459 | if (!(flags & 1)) { |
| 460 | printf("\n Received %u bytes in %u packets\n", |
| 461 | tconn.secStats.bytesReceived, |
| 462 | tconn.secStats.packetsReceived); |
| 463 | printf(" Sent %u bytes in %u packets\n", |
| 464 | tconn.secStats.bytesSent, |
| 465 | tconn.secStats.packetsSent); |
| 466 | } else |
| 467 | printf("\n"); |
| 468 | break; |
| 469 | } |
| 470 | |
| 471 | default: |
| 472 | printf(" unknown\n"); |
| 473 | } |
| 474 | } |
| 475 | |
| 476 | for (j = 0; j < RX_MAXCALLS4; j++) { |
| 477 | printf(" call %d: # %d, state ", j, tconn.callNumber[j]); |
| 478 | if (tconn.callState[j] == RX_STATE_NOTINIT0) { |
| 479 | printf("not initialized\n"); |
| 480 | continue; |
| 481 | } else if (tconn.callState[j] == RX_STATE_PRECALL1) |
| 482 | printf("precall, "); |
| 483 | else if (tconn.callState[j] == RX_STATE_ACTIVE2) |
| 484 | printf("active, "); |
| 485 | else if (tconn.callState[j] == RX_STATE_DALLY3) |
| 486 | printf("dally, "); |
| 487 | else if (tconn.callState[j] == RX_STATE_HOLD4) |
| 488 | printf("hold, "); |
| 489 | else if (tconn.callState[j] == RX_STATE_RESET5) |
| 490 | printf("reset, "); |
| 491 | printf("mode: "); |
| 492 | if (tconn.callMode[j] == RX_MODE_SENDING1) |
| 493 | printf("sending"); |
| 494 | else if (tconn.callMode[j] == RX_MODE_RECEIVING2) |
| 495 | printf("receiving"); |
| 496 | else if (tconn.callMode[j] == RX_MODE_ERROR3) |
| 497 | printf("error"); |
| 498 | else if (tconn.callMode[j] == RX_MODE_EOF4) |
| 499 | printf("eof"); |
| 500 | else |
| 501 | printf("unknown"); |
| 502 | if (tconn.callFlags[j]) { |
| 503 | printf(", flags:"); |
| 504 | if (tconn.callFlags[j] & RX_CALL_READER_WAIT1) |
| 505 | printf(" reader_wait"); |
| 506 | if (tconn.callFlags[j] & RX_CALL_WAIT_WINDOW_ALLOC2) |
| 507 | printf(" window_alloc"); |
| 508 | if (tconn.callFlags[j] & RX_CALL_WAIT_WINDOW_SEND4) |
| 509 | printf(" window_send"); |
| 510 | if (tconn.callFlags[j] & RX_CALL_WAIT_PACKETS8) |
| 511 | printf(" wait_packets"); |
| 512 | if (tconn.callFlags[j] & RX_CALL_WAIT_PROC16) |
| 513 | printf(" waiting_for_process"); |
| 514 | if (tconn.callFlags[j] & RX_CALL_RECEIVE_DONE32) |
| 515 | printf(" receive_done"); |
| 516 | if (tconn.callFlags[j] & RX_CALL_CLEARED64) |
| 517 | printf(" call_cleared"); |
| 518 | } |
| 519 | if (tconn.callOther[j] & RX_OTHER_IN1) |
| 520 | printf(", has_input_packets"); |
| 521 | if (tconn.callOther[j] & RX_OTHER_OUT2) |
| 522 | printf(", has_output_packets"); |
| 523 | printf("\n"); |
| 524 | } |
| 525 | } |
| 526 | if (nodally) |
| 527 | printf("Skipped %d dallying connections.\n", dallyCounter); |
| 528 | } |
| 529 | if (showPeers && withPeers) { |
| 530 | for (i = 0;; i++) { |
| 531 | struct rx_debugPeer tpeer; |
| 532 | code = |
| 533 | rx_GetServerPeers(s, host, port, &nextpeer, allconns, &tpeer, |
| 534 | &supportedPeerValues); |
| 535 | if (code < 0) { |
| 536 | printf("getpeer call failed with code %d\n", code); |
| 537 | break; |
| 538 | } |
| 539 | if (tpeer.host == 0xffffffff) { |
| 540 | printf("Done.\n"); |
| 541 | break; |
| 542 | } |
| 543 | |
| 544 | if ((onlyHost != -1) && (onlyHost != tpeer.host)) |
| 545 | continue; |
| 546 | if ((onlyPort != -1) && (onlyPort != tpeer.port)) |
| 547 | continue; |
| 548 | |
| 549 | /* now display the peer */ |
| 550 | hostAddr.s_addr = tpeer.host; |
| 551 | afs_inet_ntoa_r(hostAddr.s_addr, hoststr); |
| 552 | printf("Peer at host %s, port %hu\n", hoststr, |
| 553 | ntohs(tpeer.port)(__builtin_constant_p(tpeer.port) ? (__uint16_t)(((__uint16_t )(tpeer.port)) << 8 | ((__uint16_t)(tpeer.port)) >> 8) : __bswap16_var(tpeer.port))); |
| 554 | printf("\tifMTU %hu\tnatMTU %hu\tmaxMTU %hu\n", tpeer.ifMTU, |
| 555 | tpeer.natMTU, tpeer.maxMTU); |
| 556 | printf("\tpackets sent %u\tpacket resends %u\n", tpeer.nSent, |
| 557 | tpeer.reSends); |
| 558 | printf("\tbytes sent high %u low %u\n", tpeer.bytesSent.high, |
| 559 | tpeer.bytesSent.low); |
| 560 | printf("\tbytes received high %u low %u\n", |
| 561 | tpeer.bytesReceived.high, tpeer.bytesReceived.low); |
| 562 | printf("\trtt %u msec, rtt_dev %u msec\n", tpeer.rtt >> 3, |
| 563 | tpeer.rtt_dev >> 2); |
| 564 | printf("\ttimeout %u.%03u sec\n", tpeer.timeout.sec, |
| 565 | tpeer.timeout.usec / 1000); |
| 566 | if (!showLong) |
| 567 | continue; |
| 568 | |
| 569 | printf("\tin/out packet skew: %d/%d\n", tpeer.inPacketSkew, |
| 570 | tpeer.outPacketSkew); |
| 571 | printf("\tcongestion window %d, MTU %d\n", tpeer.cwind, |
| 572 | tpeer.MTU); |
| 573 | printf("\tcurrent/if/max jumbogram size: %d/%d/%d\n", |
| 574 | tpeer.nDgramPackets, tpeer.ifDgramPackets, |
| 575 | tpeer.maxDgramPackets); |
| 576 | } |
| 577 | } |
| 578 | exit(0); |
| 579 | } |
| 580 | |
| 581 | /* simple main program */ |
| 582 | #ifndef AFS_NT40_ENV |
| 583 | #include "AFS_component_version_number.c" |
| 584 | #endif |
| 585 | int |
| 586 | main(int argc, char **argv) |
| 587 | { |
| 588 | struct cmd_syndesc *ts; |
| 589 | |
| 590 | #ifdef RXDEBUG |
| 591 | rxi_DebugInit(); |
| 592 | #endif |
| 593 | #ifdef AFS_NT40_ENV |
| 594 | if (afs_winsockInit() < 0) { |
| 595 | printf("%s: Couldn't initialize winsock. Exiting...\n", argv[0]); |
| 596 | return 1; |
| 597 | } |
| 598 | #endif |
| 599 | |
| 600 | ts = cmd_CreateSyntax(NULL((void *)0), MainCommand, NULL((void *)0), "probe RX server"); |
| 601 | cmd_AddParm(ts, "-servers", CMD_SINGLE2, CMD_REQUIRED0, "server machine"); |
| 602 | cmd_AddParm(ts, "-port", CMD_SINGLE2, CMD_OPTIONAL1, "IP port"); |
| 603 | cmd_AddParm(ts, "-nodally", CMD_FLAG1, CMD_OPTIONAL1, |
| 604 | "don't show dallying conns"); |
| 605 | cmd_AddParm(ts, "-allconnections", CMD_FLAG1, CMD_OPTIONAL1, |
| 606 | "don't filter out uninteresting connections on server"); |
| 607 | cmd_AddParm(ts, "-rxstats", CMD_FLAG1, CMD_OPTIONAL1, "show Rx statistics"); |
| 608 | cmd_AddParm(ts, "-onlyserver", CMD_FLAG1, CMD_OPTIONAL1, |
| 609 | "only show server conns"); |
| 610 | cmd_AddParm(ts, "-onlyclient", CMD_FLAG1, CMD_OPTIONAL1, |
| 611 | "only show client conns"); |
| 612 | cmd_AddParm(ts, "-onlyport", CMD_SINGLE2, CMD_OPTIONAL1, |
| 613 | "show only <port>"); |
| 614 | cmd_AddParm(ts, "-onlyhost", CMD_SINGLE2, CMD_OPTIONAL1, |
| 615 | "show only <host>"); |
| 616 | cmd_AddParm(ts, "-onlyauth", CMD_SINGLE2, CMD_OPTIONAL1, |
| 617 | "show only <auth level>"); |
| 618 | |
| 619 | cmd_AddParm(ts, "-version", CMD_FLAG1, CMD_OPTIONAL1, |
| 620 | "show AFS version id"); |
| 621 | cmd_AddParm(ts, "-noconns", CMD_FLAG1, CMD_OPTIONAL1, |
| 622 | "show no connections"); |
| 623 | cmd_AddParm(ts, "-peers", CMD_FLAG1, CMD_OPTIONAL1, "show peers"); |
| 624 | cmd_AddParm(ts, "-long", CMD_FLAG1, CMD_OPTIONAL1, "detailed output"); |
| 625 | |
| 626 | cmd_Dispatch(argc, argv); |
| 627 | exit(0); |
| 628 | } |