* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
/*
* This code unmangles RX packets. RX is the mutant form of RPC that AFS
* uses to communicate between clients and servers.
/*
* This code unmangles RX packets. RX is the mutant form of RPC that AFS
* uses to communicate between clients and servers.
#define RX_PACKET_TYPE_DATA 1
#define RX_PACKET_TYPE_ACK 2
#define RX_PACKET_TYPE_BUSY 3
#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
#define RX_PACKET_TYPE_DEBUG 8
#define RX_PACKET_TYPE_PARAMS 9
#define RX_PACKET_TYPE_VERSION 13
#define RX_FREE_PACKET 16
#define RX_SLOW_START_OK 32
#define RX_JUMBO_PACKET 32
#define RX_FREE_PACKET 16
#define RX_SLOW_START_OK 32
#define RX_JUMBO_PACKET 32
- uint8_t userStatus;
- uint8_t securityIndex;
- uint16_t spare; /* How clever: even though the AFS */
- uint16_t serviceId; /* header files indicate that the */
+ nd_uint8_t userStatus;
+ nd_uint8_t securityIndex;
+ nd_uint16_t spare; /* How clever: even though the AFS */
+ nd_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! */
}; /* serviceId is first, it's really */
/* encoded _after_ the spare field */
/* I wasted a day figuring that out! */
- (int) EXTRACT_32BITS(&rxh->cid),
- (int) EXTRACT_32BITS(&rxh->callNumber)));
+ (int) EXTRACT_BE_32BITS(&rxh->cid),
+ (int) EXTRACT_BE_32BITS(&rxh->callNumber)));
- (int) EXTRACT_32BITS(&rxh->seq),
- (int) EXTRACT_32BITS(&rxh->serial)));
+ (int) EXTRACT_BE_32BITS(&rxh->seq),
+ (int) EXTRACT_BE_32BITS(&rxh->serial)));
if (ndo->ndo_vflag > 2)
ND_PRINT((ndo, " secindex %d serviceid %hu",
(int) rxh->securityIndex,
if (ndo->ndo_vflag > 2)
ND_PRINT((ndo, " secindex %d serviceid %hu",
(int) rxh->securityIndex,
rxh->type == RX_PACKET_TYPE_ABORT) &&
(rxh->flags & RX_CLIENT_INITIATED) == 0 &&
rx_cache_find(rxh, (const struct ip *) bp2,
rxh->type == RX_PACKET_TYPE_ABORT) &&
(rxh->flags & RX_CLIENT_INITIATED) == 0 &&
rx_cache_find(rxh, (const struct ip *) bp2,
- rxent->callnum = rxh->callNumber;
- rxent->client = ip->ip_src;
- rxent->server = ip->ip_dst;
+ rxent->callnum = EXTRACT_BE_32BITS(&rxh->callNumber);
+ UNALIGNED_MEMCPY(&rxent->client, &ip->ip_src, sizeof(uint32_t));
+ UNALIGNED_MEMCPY(&rxent->server, &ip->ip_dst, sizeof(uint32_t));
- rxent->serviceId = rxh->serviceId;
- rxent->opcode = EXTRACT_32BITS(bp + sizeof(struct rx_header));
+ rxent->serviceId = EXTRACT_BE_32BITS(&rxh->serviceId);
+ rxent->opcode = EXTRACT_BE_32BITS(bp + sizeof(struct rx_header));
- uint32_t clip = ip->ip_dst.s_addr;
- uint32_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));
#define FIDOUT() { unsigned long n1, n2, n3; \
ND_TCHECK2(bp[0], sizeof(int32_t) * 3); \
#define FIDOUT() { unsigned long n1, n2, n3; \
ND_TCHECK2(bp[0], sizeof(int32_t) * 3); \
bp += sizeof(int32_t); \
ND_PRINT((ndo, " fid %d/%d/%d", (int) n1, (int) n2, (int) n3)); \
}
#define STROUT(MAX) { unsigned int _i; \
ND_TCHECK2(bp[0], sizeof(int32_t)); \
bp += sizeof(int32_t); \
ND_PRINT((ndo, " fid %d/%d/%d", (int) n1, (int) n2, (int) n3)); \
}
#define STROUT(MAX) { unsigned int _i; \
ND_TCHECK2(bp[0], sizeof(int32_t)); \
#define INTOUT() { int _i; \
ND_TCHECK2(bp[0], sizeof(int32_t)); \
#define INTOUT() { int _i; \
ND_TCHECK2(bp[0], sizeof(int32_t)); \
bp += sizeof(int32_t); \
ND_PRINT((ndo, " %d", _i)); \
}
#define UINTOUT() { unsigned long _i; \
ND_TCHECK2(bp[0], sizeof(int32_t)); \
bp += sizeof(int32_t); \
ND_PRINT((ndo, " %d", _i)); \
}
#define UINTOUT() { unsigned long _i; \
ND_TCHECK2(bp[0], sizeof(int32_t)); \
bp += sizeof(int32_t); \
ND_PRINT((ndo, " %lu", _i)); \
}
#define UINT64OUT() { uint64_t _i; \
ND_TCHECK2(bp[0], sizeof(uint64_t)); \
bp += sizeof(int32_t); \
ND_PRINT((ndo, " %lu", _i)); \
}
#define UINT64OUT() { uint64_t _i; \
ND_TCHECK2(bp[0], sizeof(uint64_t)); \
bp += sizeof(uint64_t); \
ND_PRINT((ndo, " %" PRIu64, _i)); \
}
#define DATEOUT() { time_t _t; struct tm *tm; char str[256]; \
ND_TCHECK2(bp[0], sizeof(int32_t)); \
bp += sizeof(uint64_t); \
ND_PRINT((ndo, " %" PRIu64, _i)); \
}
#define DATEOUT() { time_t _t; struct tm *tm; char str[256]; \
ND_TCHECK2(bp[0], sizeof(int32_t)); \
- strftime(str, 256, "%Y/%m/%d %T", tm); \
+ strftime(str, 256, "%Y/%m/%d %H:%M:%S", tm); \
ND_PRINT((ndo, " %s", str)); \
}
#define STOREATTROUT() { unsigned long mask, _i; \
ND_TCHECK2(bp[0], (sizeof(int32_t)*6)); \
ND_PRINT((ndo, " %s", str)); \
}
#define STOREATTROUT() { unsigned long mask, _i; \
ND_TCHECK2(bp[0], (sizeof(int32_t)*6)); \
if (mask) ND_PRINT((ndo, " StoreStatus")); \
if (mask & 1) { ND_PRINT((ndo, " date")); DATEOUT(); } \
else bp += sizeof(int32_t); \
if (mask) ND_PRINT((ndo, " StoreStatus")); \
if (mask & 1) { ND_PRINT((ndo, " date")); DATEOUT(); } \
else 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")); \
if (mask & 16) ND_PRINT((ndo, " segsize %lu", _i)); \
/* undocumented in 3.3 docu */ \
if (mask & 1024) ND_PRINT((ndo, " fsync")); \
#define UBIK_VERSIONOUT() {int32_t epoch; int32_t counter; \
ND_TCHECK2(bp[0], sizeof(int32_t) * 2); \
#define UBIK_VERSIONOUT() {int32_t epoch; int32_t counter; \
ND_TCHECK2(bp[0], sizeof(int32_t) * 2); \
bp += sizeof(int32_t); \
ND_PRINT((ndo, " %d.%d", epoch, counter)); \
}
#define AFSUUIDOUT() {uint32_t temp; int _i; \
ND_TCHECK2(bp[0], 11*sizeof(uint32_t)); \
bp += sizeof(int32_t); \
ND_PRINT((ndo, " %d.%d", epoch, counter)); \
}
#define AFSUUIDOUT() {uint32_t temp; int _i; \
ND_TCHECK2(bp[0], 11*sizeof(uint32_t)); \
bp += sizeof(uint32_t); \
ND_PRINT((ndo, " %08x", temp)); \
bp += sizeof(uint32_t); \
ND_PRINT((ndo, " %08x", temp)); \
bp += sizeof(uint32_t); \
ND_PRINT((ndo, "%04x", temp)); \
bp += sizeof(uint32_t); \
ND_PRINT((ndo, "%04x", temp)); \
bp += sizeof(uint32_t); \
ND_PRINT((ndo, "%04x", temp)); \
for (_i = 0; _i < 8; _i++) { \
bp += sizeof(uint32_t); \
ND_PRINT((ndo, "%04x", temp)); \
for (_i = 0; _i < 8; _i++) { \
bp += sizeof(uint32_t); \
ND_PRINT((ndo, "%02x", (unsigned char) temp)); \
} \
bp += sizeof(uint32_t); \
ND_PRINT((ndo, "%02x", (unsigned char) temp)); \
} \
ND_TCHECK2(bp[0], (MAX) * sizeof(int32_t)); \
sp = s; \
for (k = 0; k < (MAX); k++) { \
ND_TCHECK2(bp[0], (MAX) * sizeof(int32_t)); \
sp = s; \
for (k = 0; k < (MAX); k++) { \
#define DESTSERVEROUT() { unsigned long n1, n2, n3; \
ND_TCHECK2(bp[0], sizeof(int32_t) * 3); \
#define DESTSERVEROUT() { unsigned long n1, n2, n3; \
ND_TCHECK2(bp[0], sizeof(int32_t) * 3); \
bp += sizeof(int32_t); \
ND_PRINT((ndo, " server %d:%d:%d", (int) n1, (int) n2, (int) n3)); \
}
bp += sizeof(int32_t); \
ND_PRINT((ndo, " server %d:%d:%d", (int) n1, (int) n2, (int) n3)); \
}
ND_PRINT((ndo, " fs call %s", tok2str(fs_req, "op#%d", fs_op)));
ND_PRINT((ndo, " fs call %s", tok2str(fs_req, "op#%d", fs_op)));
* Otherwise, just print out the return code
*/
ND_TCHECK2(bp[0], sizeof(int32_t));
* Otherwise, just print out the return code
*/
ND_TCHECK2(bp[0], sizeof(int32_t));
bp += sizeof(int32_t);
ND_PRINT((ndo, " error %s", tok2str(afs_fs_errors, "#%d", i)));
bp += sizeof(int32_t);
ND_PRINT((ndo, " error %s", tok2str(afs_fs_errors, "#%d", i)));
*
* "positive" and "negative" are integers which contain the number of
* positive and negative ACL's in the string. The uid/aclbits pair are
*
* "positive" and "negative" are integers which contain the number of
* positive and negative ACL's in the string. The uid/aclbits pair are
ND_PRINT((ndo, " cb call %s", tok2str(cb_req, "op#%d", cb_op)));
ND_PRINT((ndo, " cb call %s", tok2str(cb_req, "op#%d", cb_op)));
ND_PRINT((ndo, " volid"));
INTOUT();
ND_TCHECK2(bp[0], sizeof(int32_t));
ND_PRINT((ndo, " volid"));
INTOUT();
ND_TCHECK2(bp[0], sizeof(int32_t));
ND_PRINT((ndo, " volid"));
INTOUT();
ND_TCHECK2(bp[0], sizeof(int32_t));
ND_PRINT((ndo, " volid"));
INTOUT();
ND_TCHECK2(bp[0], sizeof(int32_t));
bp += sizeof(int32_t);
ND_PRINT((ndo, " numservers"));
ND_TCHECK2(bp[0], sizeof(int32_t));
bp += sizeof(int32_t);
ND_PRINT((ndo, " numservers"));
ND_TCHECK2(bp[0], sizeof(int32_t));
bp += sizeof(int32_t);
ND_PRINT((ndo, " %lu", nservers));
ND_PRINT((ndo, " servers"));
bp += sizeof(int32_t);
ND_PRINT((ndo, " %lu", nservers));
ND_PRINT((ndo, " servers"));
ND_PRINT((ndo, " partitions"));
for (i = 0; i < 8; i++) {
ND_TCHECK2(bp[0], sizeof(int32_t));
ND_PRINT((ndo, " partitions"));
for (i = 0; i < 8; i++) {
ND_TCHECK2(bp[0], sizeof(int32_t));
if (i < nservers && j <= 26)
ND_PRINT((ndo, " %c", 'a' + (int)j));
else if (i < nservers)
if (i < nservers && j <= 26)
ND_PRINT((ndo, " %c", 'a' + (int)j));
else if (i < nservers)
VECOUT(VLNAMEMAX);
ND_PRINT((ndo, " numservers"));
ND_TCHECK2(bp[0], sizeof(int32_t));
VECOUT(VLNAMEMAX);
ND_PRINT((ndo, " numservers"));
ND_TCHECK2(bp[0], sizeof(int32_t));
bp += sizeof(int32_t);
ND_PRINT((ndo, " %lu", nservers));
ND_PRINT((ndo, " servers"));
bp += sizeof(int32_t);
ND_PRINT((ndo, " %lu", nservers));
ND_PRINT((ndo, " servers"));
ND_PRINT((ndo, " partitions"));
for (i = 0; i < 13; i++) {
ND_TCHECK2(bp[0], sizeof(int32_t));
ND_PRINT((ndo, " partitions"));
for (i = 0; i < 13; i++) {
ND_TCHECK2(bp[0], sizeof(int32_t));
if (i < nservers && j <= 26)
ND_PRINT((ndo, " %c", 'a' + (int)j));
else if (i < nservers)
if (i < nservers && j <= 26)
ND_PRINT((ndo, " %c", 'a' + (int)j));
else if (i < nservers)
VECOUT(VLNAMEMAX);
ND_PRINT((ndo, " numservers"));
ND_TCHECK2(bp[0], sizeof(int32_t));
VECOUT(VLNAMEMAX);
ND_PRINT((ndo, " numservers"));
ND_TCHECK2(bp[0], sizeof(int32_t));
bp += sizeof(int32_t);
ND_PRINT((ndo, " %lu", nservers));
ND_PRINT((ndo, " servers"));
bp += sizeof(int32_t);
ND_PRINT((ndo, " %lu", nservers));
ND_PRINT((ndo, " servers"));
ND_PRINT((ndo, " partitions"));
for (i = 0; i < 13; i++) {
ND_TCHECK2(bp[0], sizeof(int32_t));
ND_PRINT((ndo, " partitions"));
for (i = 0; i < 13; i++) {
ND_TCHECK2(bp[0], sizeof(int32_t));
if (i < nservers && j <= 26)
ND_PRINT((ndo, " %c", 'a' + (int)j));
else if (i < nservers)
if (i < nservers && j <= 26)
ND_PRINT((ndo, " %c", 'a' + (int)j));
else if (i < nservers)
ND_PRINT((ndo, " domain"));
STROUT(KANAMEMAX);
ND_TCHECK2(bp[0], sizeof(int32_t));
ND_PRINT((ndo, " domain"));
STROUT(KANAMEMAX);
ND_TCHECK2(bp[0], sizeof(int32_t));
ND_PRINT((ndo, " vol call %s", tok2str(vol_req, "op#%d", vol_op)));
ND_PRINT((ndo, " vol call %s", tok2str(vol_req, "op#%d", vol_op)));
bp += sizeof(int32_t);
for (i = 0; i < j; i++) {
ND_PRINT((ndo, " name"));
bp += sizeof(int32_t);
for (i = 0; i < j; i++) {
ND_PRINT((ndo, " name"));
ND_PRINT((ndo, " bos call %s", tok2str(bos_req, "op#%d", bos_op)));
ND_PRINT((ndo, " bos call %s", tok2str(bos_req, "op#%d", bos_op)));
- ubik_op = EXTRACT_32BITS(bp + sizeof(struct rx_header));
+ /* Every function that calls this function first makes a bounds check
+ * for (sizeof(rx_header) + 4) bytes, so long as it remains this way
+ * the line below will not over-read.
+ */
+ ubik_op = EXTRACT_BE_32BITS(bp + sizeof(struct rx_header));
ND_PRINT((ndo, " ubik call %s", tok2str(ubik_req, "op#%d", ubik_op)));
ND_PRINT((ndo, " ubik call %s", tok2str(ubik_req, "op#%d", ubik_op)));
bp += sizeof(int32_t);
ND_PRINT((ndo, " syncsite %s", temp ? "yes" : "no"));
ND_PRINT((ndo, " votestart"));
bp += sizeof(int32_t);
ND_PRINT((ndo, " syncsite %s", temp ? "yes" : "no"));
ND_PRINT((ndo, " votestart"));
- (int) EXTRACT_16BITS(&rxa->bufferSpace),
- (int) EXTRACT_16BITS(&rxa->maxSkew)));
+ (int) EXTRACT_BE_16BITS(&rxa->bufferSpace),
+ (int) EXTRACT_BE_16BITS(&rxa->maxSkew)));