Correct incorrect type-punning fixes
[openafs.git] / src / rxdebug / rxdebug.c
index a42f5c7..86f105b 100644 (file)
@@ -10,8 +10,6 @@
 #include <afsconfig.h>
 #include <afs/param.h>
 
-RCSID
-    ("$Header$");
 
 #include <sys/types.h>
 #include <errno.h>
@@ -32,39 +30,31 @@ RCSID
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
-#ifdef HAVE_STRING_H
 #include <string.h>
-#else
-#ifdef HAVE_STRINGS_H
-#include <strings.h>
-#endif
-#endif
 #include <sys/stat.h>
+#include <afs/afsutil.h>
 #include <afs/stds.h>
 #include <afs/cmd.h>
 
 #include <stdio.h>
 
-#include "rx_user.h"
-#include "rx_clock.h"
-#include "rx_queue.h"
-#include "rx.h"
-#include "rx_globals.h"
+#include <rx/rx_user.h>
+#include <rx/rx_clock.h>
+#include <rx/rx_queue.h>
+#include <rx/rx.h>
+#include <rx/rx_globals.h>
 
 
 #define        TIMEOUT     20
 
-extern struct hostent *hostutil_GetHostByName();
-
 static short
-PortNumber(aport)
-     register char *aport;
+PortNumber(char *aport)
 {
     register int tc;
     register short total;
 
     total = 0;
-    while (tc = *aport++) {
+    while ((tc = *aport++)) {
        if (tc < '0' || tc > '9')
            return -1;          /* bad port number */
        total *= 10;
@@ -74,8 +64,7 @@ PortNumber(aport)
 }
 
 static short
-PortName(aname)
-     register char *aname;
+PortName(char *aname)
 {
     register struct servent *ts;
     ts = getservbyname(aname, NULL);
@@ -85,9 +74,7 @@ PortName(aname)
 }
 
 int
-MainCommand(as, arock)
-     char *arock;
-     struct cmd_syndesc *as;
+MainCommand(struct cmd_syndesc *as, void *arock)
 {
     register int i;
     osi_socket s;
@@ -114,6 +101,7 @@ MainCommand(as, arock)
     int withIdleThreads;
     int withWaited;
     int withPeers;
+    int withPackets;
     struct rx_debugStats tstats;
     char *portName, *hostName;
     char hoststr[20];
@@ -263,10 +251,16 @@ MainCommand(as, arock)
     withIdleThreads = (supportedDebugValues & RX_SERVER_DEBUG_IDLE_THREADS);
     withWaited = (supportedDebugValues & RX_SERVER_DEBUG_WAITED_CNT);
     withPeers = (supportedDebugValues & RX_SERVER_DEBUG_ALL_PEER);
+    withPackets = (supportedDebugValues & RX_SERVER_DEBUG_PACKETS_CNT);
 
-    printf("Free packets: %d, packet reclaims: %d, calls: %d, used FDs: %d\n",
-          tstats.nFreePackets, tstats.packetReclaims, tstats.callsExecuted,
-          tstats.usedFDs);
+    if (withPackets)
+        printf("Free packets: %d/%d, packet reclaims: %d, calls: %d, used FDs: %d\n",
+               tstats.nFreePackets, tstats.nPackets, tstats.packetReclaims, 
+               tstats.callsExecuted, tstats.usedFDs);
+    else
+        printf("Free packets: %d, packet reclaims: %d, calls: %d, used FDs: %d\n",
+               tstats.nFreePackets, tstats.packetReclaims, tstats.callsExecuted,
+               tstats.usedFDs);
     if (!tstats.waitingForPackets)
        printf("not ");
     printf("waiting for packets.\n");
@@ -284,7 +278,7 @@ MainCommand(as, arock)
            fprintf(stderr,
                    "WARNING: Server doesn't support retrieval of Rx statistics\n");
        } else {
-           struct rx_stats rxstats;
+           struct rx_statistics rxstats;
 
            /* should gracefully handle the case where rx_stats grows */
            code =
@@ -295,8 +289,9 @@ MainCommand(as, arock)
                exit(1);
            }
            if (code != sizeof(rxstats)) {
-               if ((((struct rx_debugIn *)(&rxstats))->type ==
-                    RX_DEBUGI_BADTYPE))
+               struct rx_debugIn debug;
+               memcpy(&debug, &rxstats, sizeof(debug));
+               if (debug.type == RX_DEBUGI_BADTYPE)
                    goto noRxStats;
                printf
                    ("WARNING: returned Rx statistics of unexpected size (got %d)\n",
@@ -410,6 +405,14 @@ MainCommand(as, arock)
                    printf(" DESTROYED");
                if (tconn.flags & RX_CONN_USING_PACKET_CKSUM)
                    printf(" pktCksum");
+                if (tconn.flags & RX_CONN_KNOW_WINDOW)
+                    printf(" knowWindow");
+                if (tconn.flags & RX_CONN_RESET)
+                    printf(" reset");
+                if (tconn.flags & RX_CONN_BUSY)
+                    printf(" busy");
+                if (tconn.flags & RX_CONN_ATTACHWAIT)
+                    printf(" attachWait");
                printf(", ");
            }
            printf("security index %d, ", tconn.securityIndex);
@@ -493,6 +496,8 @@ MainCommand(as, arock)
                    printf("dally, ");
                else if (tconn.callState[j] == RX_STATE_HOLD)
                    printf("hold, ");
+               else if (tconn.callState[j] == RX_STATE_RESET)
+                   printf("reset, ");
                printf("mode: ");
                if (tconn.callMode[j] == RX_MODE_SENDING)
                    printf("sending");
@@ -588,9 +593,7 @@ MainCommand(as, arock)
 #include "AFS_component_version_number.c"
 #endif
 int
-main(argc, argv)
-     int argc;
-     char **argv;
+main(int argc, char **argv)
 {
     struct cmd_syndesc *ts;
 
@@ -604,7 +607,7 @@ main(argc, argv)
     }
 #endif
 
-    ts = cmd_CreateSyntax(NULL, MainCommand, 0, "probe RX server");
+    ts = cmd_CreateSyntax(NULL, MainCommand, NULL, "probe RX server");
     cmd_AddParm(ts, "-servers", CMD_SINGLE, CMD_REQUIRED, "server machine");
     cmd_AddParm(ts, "-port", CMD_SINGLE, CMD_OPTIONAL, "IP port");
     cmd_AddParm(ts, "-nodally", CMD_FLAG, CMD_OPTIONAL,