* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
+
+/* \summary: AFS RX printer */
+
/*
* This code unmangles RX packets. RX is the mutant form of RPC that AFS
* uses to communicate between clients and servers.
*/
-#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
#define PRSFS_ADMINISTER 64 /* Change ACL's */
struct rx_header {
- u_int32_t epoch;
- u_int32_t cid;
- u_int32_t callNumber;
- u_int32_t seq;
- u_int32_t serial;
- u_int8_t type;
+ uint32_t epoch;
+ uint32_t cid;
+ uint32_t callNumber;
+ uint32_t seq;
+ uint32_t serial;
+ uint8_t type;
#define RX_PACKET_TYPE_DATA 1
#define RX_PACKET_TYPE_ACK 2
#define RX_PACKET_TYPE_BUSY 3
#define RX_PACKET_TYPE_DEBUG 8
#define RX_PACKET_TYPE_PARAMS 9
#define RX_PACKET_TYPE_VERSION 13
- u_int8_t flags;
+ uint8_t flags;
#define RX_CLIENT_INITIATED 1
#define RX_REQUEST_ACK 2
#define RX_LAST_PACKET 4
#define RX_FREE_PACKET 16
#define RX_SLOW_START_OK 32
#define RX_JUMBO_PACKET 32
- u_int8_t userStatus;
- u_int8_t securityIndex;
- u_int16_t spare; /* How clever: even though the AFS */
- u_int16_t serviceId; /* header files indicate that the */
+ uint8_t userStatus;
+ uint8_t securityIndex;
+ uint16_t spare; /* How clever: even though the AFS */
+ uint16_t serviceId; /* header files indicate that the */
}; /* serviceId is first, it's really */
/* encoded _after_ the spare field */
/* I wasted a day figuring that out! */
#define RX_MAXACKS 255
struct rx_ackPacket {
- u_int16_t bufferSpace; /* Number of packet buffers available */
- u_int16_t maxSkew; /* Max diff between ack'd packet and */
+ uint16_t bufferSpace; /* Number of packet buffers available */
+ uint16_t maxSkew; /* Max diff between ack'd packet and */
/* highest packet received */
- u_int32_t firstPacket; /* The first packet in ack list */
- u_int32_t previousPacket; /* Previous packet recv'd (obsolete) */
- u_int32_t serial; /* # of packet that prompted the ack */
- u_int8_t reason; /* Reason for acknowledgement */
- u_int8_t nAcks; /* Number of acknowledgements */
- u_int8_t acks[RX_MAXACKS]; /* Up to RX_MAXACKS acknowledgements */
+ uint32_t firstPacket; /* The first packet in ack list */
+ uint32_t previousPacket; /* Previous packet recv'd (obsolete) */
+ uint32_t serial; /* # of packet that prompted the ack */
+ uint8_t reason; /* Reason for acknowledgement */
+ uint8_t nAcks; /* Number of acknowledgements */
+ uint8_t acks[RX_MAXACKS]; /* Up to RX_MAXACKS acknowledgements */
};
/*
*/
struct rx_cache_entry {
- u_int32_t callnum; /* Call number (net order) */
+ uint32_t callnum; /* Call number (net order) */
struct in_addr client; /* client IP address (net order) */
struct in_addr server; /* server IP address (net order) */
int dport; /* server port (host order) */
u_short serviceId; /* Service identifier (net order) */
- u_int32_t opcode; /* RX opcode (host order) */
+ uint32_t opcode; /* RX opcode (host order) */
};
#define RX_CACHE_SIZE 64
static void rx_ack_print(netdissect_options *, const u_char *, int);
-static int is_ubik(u_int32_t);
+static int is_ubik(uint32_t);
/*
* Handle the rx-level packet. See if we know what port it's going to so
void
rx_print(netdissect_options *ndo,
register const u_char *bp, int length, int sport, int dport,
- u_char *bp2)
+ const u_char *bp2)
{
- register struct rx_header *rxh;
+ register const struct rx_header *rxh;
int i;
int32_t opcode;
return;
}
- rxh = (struct rx_header *) bp;
+ rxh = (const struct rx_header *) bp;
ND_PRINT((ndo, " rx %s", tok2str(rx_types, "type %d", rxh->type)));
rx_cache_next = 0;
rxent->callnum = rxh->callNumber;
- rxent->client = ip->ip_src;
- rxent->server = ip->ip_dst;
+ UNALIGNED_MEMCPY(&rxent->client, &ip->ip_src, sizeof(uint32_t));
+ UNALIGNED_MEMCPY(&rxent->server, &ip->ip_dst, sizeof(uint32_t));
rxent->dport = dport;
rxent->serviceId = rxh->serviceId;
rxent->opcode = EXTRACT_32BITS(bp + sizeof(struct rx_header));
{
int i;
struct rx_cache_entry *rxent;
- u_int32_t clip = ip->ip_dst.s_addr;
- u_int32_t sip = ip->ip_src.s_addr;
+ uint32_t clip;
+ uint32_t sip;
+
+ UNALIGNED_MEMCPY(&clip, &ip->ip_dst, sizeof(uint32_t));
+ UNALIGNED_MEMCPY(&sip, &ip->ip_src, sizeof(uint32_t));
/* Start the search where we last left off */
ND_PRINT((ndo, " fid %d/%d/%d", (int) n1, (int) n2, (int) n3)); \
}
-#define STROUT(MAX) { unsigned int i; \
+#define STROUT(MAX) { unsigned int _i; \
ND_TCHECK2(bp[0], sizeof(int32_t)); \
- i = EXTRACT_32BITS(bp); \
- if (i > (MAX)) \
+ _i = EXTRACT_32BITS(bp); \
+ if (_i > (MAX)) \
goto trunc; \
bp += sizeof(int32_t); \
ND_PRINT((ndo, " \"")); \
- if (fn_printn(bp, i, ndo->ndo_snapend)) \
+ if (fn_printn(ndo, bp, _i, ndo->ndo_snapend)) \
goto trunc; \
ND_PRINT((ndo, "\"")); \
- bp += ((i + sizeof(int32_t) - 1) / sizeof(int32_t)) * sizeof(int32_t); \
+ bp += ((_i + sizeof(int32_t) - 1) / sizeof(int32_t)) * sizeof(int32_t); \
}
-#define INTOUT() { int i; \
+#define INTOUT() { int _i; \
ND_TCHECK2(bp[0], sizeof(int32_t)); \
- i = (int) EXTRACT_32BITS(bp); \
+ _i = (int) EXTRACT_32BITS(bp); \
bp += sizeof(int32_t); \
- ND_PRINT((ndo, " %d", i)); \
+ ND_PRINT((ndo, " %d", _i)); \
}
-#define UINTOUT() { unsigned long i; \
+#define UINTOUT() { unsigned long _i; \
ND_TCHECK2(bp[0], sizeof(int32_t)); \
- i = EXTRACT_32BITS(bp); \
+ _i = EXTRACT_32BITS(bp); \
bp += sizeof(int32_t); \
- ND_PRINT((ndo, " %lu", i)); \
+ ND_PRINT((ndo, " %lu", _i)); \
}
-#define UINT64OUT() { u_int64_t i; \
- ND_TCHECK2(bp[0], sizeof(u_int64_t)); \
- i = EXTRACT_64BITS(bp); \
- bp += sizeof(u_int64_t); \
- ND_PRINT((ndo, " %" PRIu64, i)); \
+#define UINT64OUT() { uint64_t _i; \
+ ND_TCHECK2(bp[0], sizeof(uint64_t)); \
+ _i = EXTRACT_64BITS(bp); \
+ bp += sizeof(uint64_t); \
+ ND_PRINT((ndo, " %" PRIu64, _i)); \
}
-#define DATEOUT() { time_t t; struct tm *tm; char str[256]; \
+#define DATEOUT() { time_t _t; struct tm *tm; char str[256]; \
ND_TCHECK2(bp[0], sizeof(int32_t)); \
- t = (time_t) EXTRACT_32BITS(bp); \
+ _t = (time_t) EXTRACT_32BITS(bp); \
bp += sizeof(int32_t); \
- tm = localtime(&t); \
- strftime(str, 256, "%Y/%m/%d %T", tm); \
+ tm = localtime(&_t); \
+ strftime(str, 256, "%Y/%m/%d %H:%M:%S", tm); \
ND_PRINT((ndo, " %s", str)); \
}
-#define STOREATTROUT() { unsigned long mask, i; \
+#define STOREATTROUT() { unsigned long mask, _i; \
ND_TCHECK2(bp[0], (sizeof(int32_t)*6)); \
mask = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
if (mask) ND_PRINT((ndo, " StoreStatus")); \
if (mask & 1) { ND_PRINT((ndo, " date")); DATEOUT(); } \
else bp += sizeof(int32_t); \
- i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
- if (mask & 2) ND_PRINT((ndo, " owner %lu", i)); \
- i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
- if (mask & 4) ND_PRINT((ndo, " group %lu", i)); \
- i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
- if (mask & 8) ND_PRINT((ndo, " mode %lo", i & 07777)); \
- i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
- if (mask & 16) ND_PRINT((ndo, " segsize %lu", i)); \
+ _i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
+ if (mask & 2) ND_PRINT((ndo, " owner %lu", _i)); \
+ _i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
+ if (mask & 4) ND_PRINT((ndo, " group %lu", _i)); \
+ _i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
+ if (mask & 8) ND_PRINT((ndo, " mode %lo", _i & 07777)); \
+ _i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
+ if (mask & 16) ND_PRINT((ndo, " segsize %lu", _i)); \
/* undocumented in 3.3 docu */ \
if (mask & 1024) ND_PRINT((ndo, " fsync")); \
}
ND_PRINT((ndo, " %d.%d", epoch, counter)); \
}
-#define AFSUUIDOUT() {u_int32_t temp; int i; \
- ND_TCHECK2(bp[0], 11*sizeof(u_int32_t)); \
+#define AFSUUIDOUT() {uint32_t temp; int _i; \
+ ND_TCHECK2(bp[0], 11*sizeof(uint32_t)); \
temp = EXTRACT_32BITS(bp); \
- bp += sizeof(u_int32_t); \
+ bp += sizeof(uint32_t); \
ND_PRINT((ndo, " %08x", temp)); \
temp = EXTRACT_32BITS(bp); \
- bp += sizeof(u_int32_t); \
+ bp += sizeof(uint32_t); \
ND_PRINT((ndo, "%04x", temp)); \
temp = EXTRACT_32BITS(bp); \
- bp += sizeof(u_int32_t); \
+ bp += sizeof(uint32_t); \
ND_PRINT((ndo, "%04x", temp)); \
- for (i = 0; i < 8; i++) { \
+ for (_i = 0; _i < 8; _i++) { \
temp = EXTRACT_32BITS(bp); \
- bp += sizeof(u_int32_t); \
+ bp += sizeof(uint32_t); \
ND_PRINT((ndo, "%02x", (unsigned char) temp)); \
} \
}
} \
s[(MAX)] = '\0'; \
ND_PRINT((ndo, " \"")); \
- fn_print(s, NULL); \
+ fn_print(ndo, s, NULL); \
ND_PRINT((ndo, "\"")); \
}
bp += sizeof(int32_t);
ND_TCHECK2(bp[0], i);
i = min(AFSOPAQUEMAX, i);
- strncpy(a, (char *) bp, i);
+ strncpy(a, (const char *) bp, i);
a[i] = '\0';
acl_print(ndo, (u_char *) a, sizeof(a), (u_char *) a + i);
break;
register const u_char *bp, int length, int32_t opcode)
{
unsigned long i;
- struct rx_header *rxh;
+ const struct rx_header *rxh;
if (length <= (int)sizeof(struct rx_header))
return;
- rxh = (struct rx_header *) bp;
+ rxh = (const struct rx_header *) bp;
/*
* Print out the afs call we're invoking. The table used here was
bp += sizeof(int32_t);
ND_TCHECK2(bp[0], i);
i = min(AFSOPAQUEMAX, i);
- strncpy(a, (char *) bp, i);
+ strncpy(a, (const char *) bp, i);
a[i] = '\0';
acl_print(ndo, (u_char *) a, sizeof(a), (u_char *) a + i);
break;
;
}
} else if (rxh->type == RX_PACKET_TYPE_ABORT) {
- int i;
-
/*
* Otherwise, just print out the return code
*/
*
* "positive" and "negative" are integers which contain the number of
* positive and negative ACL's in the string. The uid/aclbits pair are
- * ASCII strings containing the UID/PTS record and and a ascii number
+ * ASCII strings containing the UID/PTS record and an ASCII number
* representing a logical OR of all the ACL permission bits
*/
goto finish;
s += n;
ND_PRINT((ndo, " +{"));
- fn_print((u_char *)user, NULL);
+ fn_print(ndo, (u_char *)user, NULL);
ND_PRINT((ndo, " "));
ACLOUT(acl);
ND_PRINT((ndo, "}"));
goto finish;
s += n;
ND_PRINT((ndo, " -{"));
- fn_print((u_char *)user, NULL);
+ fn_print(ndo, (u_char *)user, NULL);
ND_PRINT((ndo, " "));
ACLOUT(acl);
ND_PRINT((ndo, "}"));
cb_reply_print(netdissect_options *ndo,
register const u_char *bp, int length, int32_t opcode)
{
- struct rx_header *rxh;
+ const struct rx_header *rxh;
if (length <= (int)sizeof(struct rx_header))
return;
- rxh = (struct rx_header *) bp;
+ rxh = (const struct rx_header *) bp;
/*
* Print out the afs call we're invoking. The table used here was
prot_reply_print(netdissect_options *ndo,
register const u_char *bp, int length, int32_t opcode)
{
- struct rx_header *rxh;
+ const struct rx_header *rxh;
unsigned long i;
if (length < (int)sizeof(struct rx_header))
return;
- rxh = (struct rx_header *) bp;
+ rxh = (const struct rx_header *) bp;
/*
* Print out the afs call we're invoking. The table used here was
vldb_reply_print(netdissect_options *ndo,
register const u_char *bp, int length, int32_t opcode)
{
- struct rx_header *rxh;
+ const struct rx_header *rxh;
unsigned long i;
if (length < (int)sizeof(struct rx_header))
return;
- rxh = (struct rx_header *) bp;
+ rxh = (const struct rx_header *) bp;
/*
* Print out the afs call we're invoking. The table used here was
ND_TCHECK2(bp[0], sizeof(int32_t));
if (i < nservers)
ND_PRINT((ndo, " %s",
- intoa(((struct in_addr *) bp)->s_addr)));
+ intoa(((const struct in_addr *) bp)->s_addr)));
bp += sizeof(int32_t);
}
ND_PRINT((ndo, " partitions"));
ND_TCHECK2(bp[0], sizeof(int32_t));
if (i < nservers)
ND_PRINT((ndo, " %s",
- intoa(((struct in_addr *) bp)->s_addr)));
+ intoa(((const struct in_addr *) bp)->s_addr)));
bp += sizeof(int32_t);
}
ND_PRINT((ndo, " partitions"));
bp += sizeof(struct rx_header) + 4;
switch (kauth_op) {
- case 1: /* Authenticate old */;
+ case 1: /* Authenticate old */
case 21: /* Authenticate */
case 22: /* Authenticate-V2 */
case 2: /* Change PW */
kauth_reply_print(netdissect_options *ndo,
register const u_char *bp, int length, int32_t opcode)
{
- struct rx_header *rxh;
+ const struct rx_header *rxh;
if (length <= (int)sizeof(struct rx_header))
return;
- rxh = (struct rx_header *) bp;
+ rxh = (const struct rx_header *) bp;
/*
* Print out the afs call we're invoking. The table used here was
vol_reply_print(netdissect_options *ndo,
register const u_char *bp, int length, int32_t opcode)
{
- struct rx_header *rxh;
+ const struct rx_header *rxh;
if (length <= (int)sizeof(struct rx_header))
return;
- rxh = (struct rx_header *) bp;
+ rxh = (const struct rx_header *) bp;
/*
* Print out the afs call we're invoking. The table used here was
bos_reply_print(netdissect_options *ndo,
register const u_char *bp, int length, int32_t opcode)
{
- struct rx_header *rxh;
+ const struct rx_header *rxh;
if (length <= (int)sizeof(struct rx_header))
return;
- rxh = (struct rx_header *) bp;
+ rxh = (const struct rx_header *) bp;
/*
* Print out the afs call we're invoking. The table used here was
*/
static int
-is_ubik(u_int32_t opcode)
+is_ubik(uint32_t opcode)
{
if ((opcode >= VOTE_LOW && opcode <= VOTE_HIGH) ||
(opcode >= DISK_LOW && opcode <= DISK_HIGH))
ubik_reply_print(netdissect_options *ndo,
register const u_char *bp, int length, int32_t opcode)
{
- struct rx_header *rxh;
+ const struct rx_header *rxh;
if (length < (int)sizeof(struct rx_header))
return;
- rxh = (struct rx_header *) bp;
+ rxh = (const struct rx_header *) bp;
/*
* Print out the ubik call we're invoking. This table was gleaned
rx_ack_print(netdissect_options *ndo,
register const u_char *bp, int length)
{
- struct rx_ackPacket *rxa;
+ const struct rx_ackPacket *rxa;
int i, start, last;
- u_int32_t firstPacket;
+ uint32_t firstPacket;
if (length < (int)sizeof(struct rx_header))
return;
ND_TCHECK2(bp[0], sizeof(struct rx_ackPacket) - RX_MAXACKS);
- rxa = (struct rx_ackPacket *) bp;
+ rxa = (const struct rx_ackPacket *) bp;
bp += (sizeof(struct rx_ackPacket) - RX_MAXACKS);
/*
}
/*
- * Otherwise, if the there is a skip in
+ * Otherwise, if there is a skip in
* the range (such as an nacked packet in
* the middle of some acked packets),
* then print the current packet number