/*
* Copyright 2000, International Business Machines Corporation and others.
* All Rights Reserved.
- *
+ *
* This software has been released under the terms of the IBM Public
* License. For details, see the LICENSE file in the top-level source
* directory or online at http://www.openafs.org/dl/license10.html
#include <afsconfig.h>
#include <afs/param.h>
+#include <afs/stds.h>
+#include <roken.h>
-#include <sys/types.h>
-#include <errno.h>
-#ifdef AFS_NT40_ENV
-#include <winsock2.h>
-#else
-#include <sys/socket.h>
-#include <sys/file.h>
-#include <netdb.h>
-#include <arpa/inet.h>
-#endif
-#ifdef HAVE_NETINET_IN_H
-#include <netinet/in.h>
-#endif
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <string.h>
-#include <sys/stat.h>
#include <afs/afsutil.h>
-#include <afs/stds.h>
#include <afs/cmd.h>
-#include <stdio.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>
-#include "rx_user.h"
-#include "rx_clock.h"
-#include "rx_queue.h"
-#include "rx.h"
-#include "rx_globals.h"
+#ifdef ENABLE_RXGK
+# include <rx/rxgk.h>
+#endif
#define TIMEOUT 20
static short
PortNumber(char *aport)
{
- register int tc;
- register short total;
+ int tc;
+ short total;
total = 0;
while ((tc = *aport++)) {
static short
PortName(char *aname)
{
- register struct servent *ts;
+ struct servent *ts;
ts = getservbyname(aname, NULL);
if (!ts)
return -1;
int
MainCommand(struct cmd_syndesc *as, void *arock)
{
- register int i;
+ int i;
osi_socket s;
int j;
struct sockaddr_in taddr;
struct in_addr hostAddr;
short port;
struct hostent *th;
- register afs_int32 code;
+ afs_int32 code;
int nodally;
int allconns;
int rxstats;
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)
hostAddr.s_addr = host;
afs_inet_ntoa_r(hostAddr.s_addr, hoststr);
printf("Trying %s (port %d):\n", hoststr, ntohs(port));
- s = socket(AF_INET, SOCK_DGRAM, 0);
+ s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+ if (s == OSI_NULLSOCKET) {
+#ifdef AFS_NT40_ENV
+ fprintf(stderr, "socket() failed with error %u\n", WSAGetLastError());
+#else
+ perror("socket");
+#endif
+ exit(1);
+ }
taddr.sin_family = AF_INET;
taddr.sin_port = 0;
taddr.sin_addr.s_addr = 0;
#endif
code = bind(s, (struct sockaddr *)&taddr, sizeof(struct sockaddr_in));
if (code) {
+#ifdef AFS_NT40_ENV
+ fprintf(stderr, "bind() failed with error %u\n", WSAGetLastError());
+#else
perror("bind");
+#endif
exit(1);
}
if (version_flag) {
+ memset(version, 0, sizeof(version));
code = rx_GetServerVersion(s, host, port, length, version);
if (code < 0) {
errno);
exit(1);
}
+ version[sizeof(version) - 1] = '\0';
printf("AFS version: %s\n", version);
fflush(stdout);
if (withPackets)
printf("Free packets: %d/%d, packet reclaims: %d, calls: %d, used FDs: %d\n",
- tstats.nFreePackets, tstats.nPackets, tstats.packetReclaims,
+ tstats.nFreePackets, tstats.nPackets, tstats.packetReclaims,
tstats.callsExecuted, tstats.usedFDs);
else
printf("Free packets: %d, packet reclaims: %d, calls: %d, used FDs: %d\n",
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",
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]);
}
continue;
if (onlyAuth != 999) {
if (onlyAuth == -1) {
- if (tconn.securityIndex != 0)
+ if (tconn.securityIndex != RX_SECIDX_NULL)
continue;
} else {
- if (tconn.securityIndex != 2)
+ 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;
- if (withSecStats && (tconn.secStats.type == 3)
+#ifdef ENABLE_RXGK
+ if (withSecStats && (tconn.secStats.type == RX_SECTYPE_GK)
&& (tconn.secStats.level != onlyAuth))
continue;
+#endif
}
}
if (withSecStats) {
switch ((int)tconn.secStats.type) {
- case 0:
- if (tconn.securityIndex == 2)
+ case RX_SECTYPE_UNK:
+ if (tconn.securityIndex == RX_SECIDX_KAD)
printf
(" no GetStats procedure for security object\n");
break;
- case 1:
+ case RX_SECTYPE_NULL:
printf(" rxnull level=%d, flags=%d\n",
tconn.secStats.level, tconn.secStats.flags);
break;
- case 2:
+ case RX_SECTYPE_VAB:
printf(" rxvab level=%d, flags=%d\n",
tconn.secStats.level, tconn.secStats.flags);
break;
- case 3:{
+ case RX_SECTYPE_KAD:{
char *level;
char flags = tconn.secStats.flags;
if (tconn.secStats.level == 0)
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");
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");
/* now display the peer */
hostAddr.s_addr = tpeer.host;
afs_inet_ntoa_r(hostAddr.s_addr, hoststr);
- printf("Peer at host %s, port %hu\n", hoststr,
+ printf("Peer at host %s, port %hu\n", hoststr,
ntohs(tpeer.port));
printf("\tifMTU %hu\tnatMTU %hu\tmaxMTU %hu\n", tpeer.ifMTU,
tpeer.natMTU, tpeer.maxMTU);
}
#endif
- ts = cmd_CreateSyntax(NULL, MainCommand, NULL, "probe RX server");
+ ts = cmd_CreateSyntax(NULL, MainCommand, NULL, 0, "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,