rxdebug: Add rxgk support 40/12940/7
authorAndrew Deason <adeason@sinenomine.net>
Fri, 2 Mar 2018 06:24:54 +0000 (00:24 -0600)
committerBenjamin Kaduk <kaduk@mit.edu>
Sun, 24 Mar 2019 06:18:03 +0000 (02:18 -0400)
Change-Id: I6ffeb7b36f41816ca1c3d12bb5e8097dd5d7a3fd
Reviewed-on: https://gerrit.openafs.org/12940
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

Makefile.in
src/rxdebug/rxdebug.c

index f0cdb2f..9e3fdd8 100644 (file)
@@ -194,7 +194,7 @@ rxstat: rx rxstat_depinstall
        +${COMPILE_PART1} rxstat ${COMPILE_PART2}
 
 rxtests: rxdebug
-rxdebug: rx sys
+rxdebug: rx sys rxgk
        +${COMPILE_PART1} rxdebug ${COMPILE_PART2}
 
 fsint: cmd comerr rxgen rx lwp fsint_depinstall
index 3d4bf0a..5cd30b2 100644 (file)
 #include <rx/rx.h>
 #include <rx/rx_globals.h>
 
+#ifdef ENABLE_RXGK
+# include <rx/rxgk.h>
+#endif
+
 
 #define        TIMEOUT     20
 
@@ -143,6 +147,10 @@ MainCommand(struct cmd_syndesc *as, void *arock)
 
     if (as->parms[9].items) {
        char *name = as->parms[9].items->data;
+        /* Note that this assumes that the security levels for rxkad and rxgk
+         * use the same constants (0, 1, and 2). Perhaps a little ugly, but the
+         * constants being identical makes it really convenient to do it this
+         * way. */
        if (strcmp(name, "clear") == 0)
            onlyAuth = 0;
        else if (strcmp(name, "auth") == 0)
@@ -309,8 +317,8 @@ MainCommand(struct cmd_syndesc *as, void *arock)
            printf("Showing only client connections\n");
        if (onlyAuth != 999) {
            static char *name[] =
-               { "unauthenticated", "rxkad_clear", "rxkad_auth",
-               "rxkad_crypt"
+               { "unauthenticated", "clear", "auth",
+               "crypt"
            };
            printf("Showing only %s connections\n", name[onlyAuth + 1]);
        }
@@ -367,11 +375,20 @@ MainCommand(struct cmd_syndesc *as, void *arock)
                    if (tconn.securityIndex != RX_SECIDX_NULL)
                        continue;
                } else {
-                   if (tconn.securityIndex != RX_SECIDX_KAD)
-                       continue;
+                   if (tconn.securityIndex != RX_SECIDX_KAD) {
+#ifdef ENABLE_RXGK
+                        if (tconn.securityIndex != RX_SECIDX_GK)
+#endif
+                            continue;
+                    }
                    if (withSecStats && (tconn.secStats.type == RX_SECTYPE_KAD)
                        && (tconn.secStats.level != onlyAuth))
                        continue;
+#ifdef ENABLE_RXGK
+                   if (withSecStats && (tconn.secStats.type == RX_SECTYPE_GK)
+                       && (tconn.secStats.level != onlyAuth))
+                       continue;
+#endif
                }
            }
 
@@ -469,6 +486,41 @@ MainCommand(struct cmd_syndesc *as, void *arock)
                            printf("\n");
                        break;
                    }
+#ifdef ENABLE_RXGK
+                case RX_SECTYPE_GK: {
+                       char *level;
+                       char flags = tconn.secStats.flags;
+                       if (tconn.secStats.level == RXGK_LEVEL_CLEAR)
+                           level = "clear";
+                       else if (tconn.secStats.level == RXGK_LEVEL_AUTH)
+                           level = "auth";
+                       else if (tconn.secStats.level == RXGK_LEVEL_CRYPT)
+                           level = "crypt";
+                       else
+                           level = "unknown";
+                       printf("  rxgk: level %s", level);
+                       if (flags)
+                           printf(", flags");
+                       if ((flags & RXGK_STATS_UNALLOC))
+                           printf(" unalloc");
+                       if ((flags & RXGK_STATS_AUTH))
+                           printf(" authenticated");
+                       if (tconn.secStats.expires)
+                           printf(", expires in %.1f hours",
+                                  ((afs_uint32) tconn.secStats.expires -
+                                   time(0)) / 3600.0);
+                       if (!(flags & RXGK_STATS_UNALLOC)) {
+                           printf("\n  Received %u bytes in %u packets\n",
+                                  tconn.secStats.bytesReceived,
+                                  tconn.secStats.packetsReceived);
+                           printf("  Sent %u bytes in %u packets\n",
+                                  tconn.secStats.bytesSent,
+                                  tconn.secStats.packetsSent);
+                       } else
+                           printf("\n");
+                       break;
+                    }
+#endif /* ENABLE_RXGK */
 
                default:
                    printf("  unknown\n");