*/
-#ifdef HAVE_CONFIG_H
#include <config.h>
-#endif
#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
#include "netdissect-stdinc.h"
static const struct tok afs_fs_errors[] = {
{ 101, "salvage volume" },
- { 102, "no such vnode" },
- { 103, "no such volume" },
- { 104, "volume exist" },
- { 105, "no service" },
- { 106, "volume offline" },
- { 107, "voline online" },
- { 108, "diskfull" },
- { 109, "diskquota exceeded" },
- { 110, "volume busy" },
- { 111, "volume moved" },
- { 112, "AFS IO error" },
+ { 102, "no such vnode" },
+ { 103, "no such volume" },
+ { 104, "volume exist" },
+ { 105, "no service" },
+ { 106, "volume offline" },
+ { 107, "voline online" },
+ { 108, "diskfull" },
+ { 109, "diskquota exceeded" },
+ { 110, "volume busy" },
+ { 111, "volume moved" },
+ { 112, "AFS IO error" },
{ 0xffffff9c, "restarting fileserver" }, /* -100, sic! */
{ 0, NULL }
};
uint32_t callnum; /* Call number (net order) */
uint32_t client; /* client IP address (net order) */
uint32_t server; /* server IP address (net order) */
- u_int dport; /* server port (host order) */
+ uint16_t dport; /* server UDP port (host order) */
uint16_t serviceId; /* Service identifier (net order) */
uint32_t opcode; /* RX opcode (host order) */
};
static uint32_t rx_cache_next = 0;
static uint32_t rx_cache_hint = 0;
-static void rx_cache_insert(netdissect_options *, const u_char *, const struct ip *, u_int);
+static void rx_cache_insert(netdissect_options *, const u_char *, const struct ip *, uint16_t);
static int rx_cache_find(netdissect_options *, const struct rx_header *,
- const struct ip *, uint32_t, uint32_t *);
+ const struct ip *, uint16_t, uint32_t *);
static void fs_print(netdissect_options *, const u_char *, u_int);
static void fs_reply_print(netdissect_options *, const u_char *, u_int, uint32_t);
-static void acl_print(netdissect_options *, u_char *, u_char *);
+static void acl_print(netdissect_options *, u_char *, const u_char *);
static void cb_print(netdissect_options *, const u_char *, u_int);
static void cb_reply_print(netdissect_options *, const u_char *, u_int, uint32_t);
static void prot_print(netdissect_options *, const u_char *, u_int);
void
rx_print(netdissect_options *ndo,
- const u_char *bp, u_int length, u_int sport, u_int dport,
+ const u_char *bp, u_int length, uint16_t sport, uint16_t dport,
const u_char *bp2)
{
const struct rx_header *rxh;
static void
rx_cache_insert(netdissect_options *ndo,
- const u_char *bp, const struct ip *ip, u_int dport)
+ const u_char *bp, const struct ip *ip, uint16_t dport)
{
struct rx_cache_entry *rxent;
const struct rx_header *rxh = (const struct rx_header *) bp;
static int
rx_cache_find(netdissect_options *ndo, const struct rx_header *rxh,
- const struct ip *ip, u_int sport, uint32_t *opcode)
+ const struct ip *ip, uint16_t sport, uint32_t *opcode)
{
uint32_t i;
struct rx_cache_entry *rxent;
}
#define STROUT(MAX) { uint32_t _i; \
- ND_TCHECK_LEN(bp, sizeof(uint32_t)); \
_i = GET_BE_U_4(bp); \
if (_i > (MAX)) \
goto trunc; \
}
#define INTOUT() { int32_t _i; \
- ND_TCHECK_4(bp); \
_i = GET_BE_S_4(bp); \
bp += sizeof(int32_t); \
ND_PRINT(" %d", _i); \
}
#define UINTOUT() { uint32_t _i; \
- ND_TCHECK_4(bp); \
_i = GET_BE_U_4(bp); \
bp += sizeof(uint32_t); \
ND_PRINT(" %u", _i); \
}
#define UINT64OUT() { uint64_t _i; \
- ND_TCHECK_LEN(bp, sizeof(uint64_t)); \
_i = GET_BE_U_8(bp); \
bp += sizeof(uint64_t); \
ND_PRINT(" %" PRIu64, _i); \
}
-#define DATEOUT() { time_t _t; struct tm *tm; char str[256]; \
- ND_TCHECK_4(bp); \
+#define DATEOUT() { time_t _t; char str[256]; \
_t = (time_t) GET_BE_S_4(bp); \
bp += sizeof(int32_t); \
- tm = localtime(&_t); \
- strftime(str, 256, "%Y/%m/%d %H:%M:%S", tm); \
- ND_PRINT(" %s", str); \
+ ND_PRINT(" %s", \
+ nd_format_time(str, sizeof(str), \
+ "%Y-%m-%d %H:%M:%S", localtime(&_t))); \
}
#define STOREATTROUT() { uint32_t mask, _i; \
* gleaned from fsint/afsint.xg
*/
- ND_TCHECK_4(bp + sizeof(struct rx_header));
fs_op = GET_BE_U_4(bp + sizeof(struct rx_header));
ND_PRINT(" fs call %s", tok2str(fs_req, "op#%u", fs_op));
{
char a[AFSOPAQUEMAX+1];
FIDOUT();
- ND_TCHECK_4(bp);
i = GET_BE_U_4(bp);
bp += sizeof(uint32_t);
ND_TCHECK_LEN(bp, i);
- i = min(AFSOPAQUEMAX, i);
+ i = ND_MIN(AFSOPAQUEMAX, i);
strncpy(a, (const char *) bp, i);
a[i] = '\0';
acl_print(ndo, (u_char *) a, (u_char *) a + i);
case 65536: /* Inline bulk stat */
{
uint32_t j;
- ND_TCHECK_4(bp);
j = GET_BE_U_4(bp);
bp += sizeof(uint32_t);
case 131: /* Fetch ACL */
{
char a[AFSOPAQUEMAX+1];
- ND_TCHECK_4(bp);
i = GET_BE_U_4(bp);
bp += sizeof(uint32_t);
ND_TCHECK_LEN(bp, i);
- i = min(AFSOPAQUEMAX, i);
+ i = ND_MIN(AFSOPAQUEMAX, i);
strncpy(a, (const char *) bp, i);
a[i] = '\0';
acl_print(ndo, (u_char *) a, (u_char *) a + i);
*/
int32_t errcode;
- ND_TCHECK_4(bp);
errcode = GET_BE_S_4(bp);
bp += sizeof(int32_t);
* representing a logical OR of all the ACL permission bits
*/
+#define XSTRINGIFY(x) #x
#define NUMSTRINGIFY(x) XSTRINGIFY(x)
static void
acl_print(netdissect_options *ndo,
- u_char *s, u_char *end)
+ u_char *s, const u_char *end)
{
int pos, neg, acl;
int n, i;
* gleaned from fsint/afscbint.xg
*/
- ND_TCHECK_4(bp + sizeof(struct rx_header));
cb_op = GET_BE_U_4(bp + sizeof(struct rx_header));
ND_PRINT(" cb call %s", tok2str(cb_req, "op#%u", cb_op));
case 204: /* Callback */
{
uint32_t j, t;
- ND_TCHECK_4(bp);
j = GET_BE_U_4(bp);
bp += sizeof(uint32_t);
if (j == 0)
ND_PRINT(" <none!>");
- ND_TCHECK_4(bp);
j = GET_BE_U_4(bp);
bp += sizeof(uint32_t);
INTOUT();
ND_PRINT(" expires");
DATEOUT();
- ND_TCHECK_4(bp);
t = GET_BE_U_4(bp);
bp += sizeof(uint32_t);
tok2str(cb_types, "type %u", t);
* gleaned from ptserver/ptint.xg
*/
- ND_TCHECK_4(bp + sizeof(struct rx_header));
pt_op = GET_BE_U_4(bp + sizeof(struct rx_header));
ND_PRINT(" pt");
case 504: /* Name to ID */
{
uint32_t j;
- ND_TCHECK_4(bp);
j = GET_BE_U_4(bp);
bp += sizeof(uint32_t);
{
uint32_t j;
ND_PRINT(" ids:");
- ND_TCHECK_4(bp);
i = GET_BE_U_4(bp);
bp += sizeof(uint32_t);
for (j = 0; j < i; j++)
{
uint32_t j;
ND_PRINT(" ids:");
- ND_TCHECK_4(bp);
i = GET_BE_U_4(bp);
bp += sizeof(uint32_t);
for (j = 0; j < i; j++)
case 505: /* ID to name */
{
uint32_t j;
- ND_TCHECK_4(bp);
j = GET_BE_U_4(bp);
bp += sizeof(uint32_t);
case 519: /* Get host CPS */
{
uint32_t j;
- ND_TCHECK_4(bp);
j = GET_BE_U_4(bp);
bp += sizeof(uint32_t);
for (i = 0; i < j; i++) {
* gleaned from vlserver/vldbint.xg
*/
- ND_TCHECK_4(bp + sizeof(struct rx_header));
vldb_op = GET_BE_U_4(bp + sizeof(struct rx_header));
ND_PRINT(" vldb");
case 518: /* Get entry by ID N */
ND_PRINT(" volid");
INTOUT();
- ND_TCHECK_4(bp);
i = GET_BE_U_4(bp);
bp += sizeof(uint32_t);
if (i <= 2)
case 520: /* Replace entry N */
ND_PRINT(" volid");
INTOUT();
- ND_TCHECK_4(bp);
i = GET_BE_U_4(bp);
bp += sizeof(uint32_t);
if (i <= 2)
ND_TCHECK_4(bp);
bp += sizeof(uint32_t);
ND_PRINT(" numservers");
- ND_TCHECK_4(bp);
nservers = GET_BE_U_4(bp);
bp += sizeof(uint32_t);
ND_PRINT(" %u", nservers);
}
ND_PRINT(" partitions");
for (i = 0; i < 8; i++) {
- ND_TCHECK_4(bp);
j = GET_BE_U_4(bp);
if (i < nservers && j <= 26)
ND_PRINT(" %c", 'a' + j);
{ uint32_t nservers, j;
VECOUT(VLNAMEMAX);
ND_PRINT(" numservers");
- ND_TCHECK_4(bp);
nservers = GET_BE_U_4(bp);
bp += sizeof(uint32_t);
ND_PRINT(" %u", nservers);
}
ND_PRINT(" partitions");
for (i = 0; i < 13; i++) {
- ND_TCHECK_4(bp);
j = GET_BE_U_4(bp);
if (i < nservers && j <= 26)
ND_PRINT(" %c", 'a' + j);
{ uint32_t nservers, j;
VECOUT(VLNAMEMAX);
ND_PRINT(" numservers");
- ND_TCHECK_4(bp);
nservers = GET_BE_U_4(bp);
bp += sizeof(uint32_t);
ND_PRINT(" %u", nservers);
bp += 4 * 13;
ND_PRINT(" partitions");
for (i = 0; i < 13; i++) {
- ND_TCHECK_4(bp);
j = GET_BE_U_4(bp);
if (i < nservers && j <= 26)
ND_PRINT(" %c", 'a' + j);
* gleaned from kauth/kauth.rg
*/
- ND_TCHECK_4(bp + sizeof(struct rx_header));
kauth_op = GET_BE_U_4(bp + sizeof(struct rx_header));
ND_PRINT(" kauth");
INTOUT();
ND_PRINT(" domain");
STROUT(KANAMEMAX);
- ND_TCHECK_4(bp);
i = GET_BE_U_4(bp);
bp += sizeof(uint32_t);
ND_TCHECK_LEN(bp, i);
ND_PRINT(" errcode");
INTOUT();
}
-
- return;
-
-trunc:
- ND_PRINT(" [|kauth]");
}
/*
* gleaned from volser/volint.xg
*/
- ND_TCHECK_4(bp + sizeof(struct rx_header));
vol_op = GET_BE_U_4(bp + sizeof(struct rx_header));
ND_PRINT(" vol call %s", tok2str(vol_req, "op#%u", vol_op));
DATEOUT();
{
uint32_t i, j;
- ND_TCHECK_4(bp);
j = GET_BE_U_4(bp);
bp += sizeof(uint32_t);
for (i = 0; i < j; i++) {
case 121: /* List one volume */
{
uint32_t i, j;
- ND_TCHECK_4(bp);
j = GET_BE_U_4(bp);
bp += sizeof(uint32_t);
for (i = 0; i < j; i++) {
* gleaned from bozo/bosint.xg
*/
- ND_TCHECK_4(bp + sizeof(struct rx_header));
bos_op = GET_BE_U_4(bp + sizeof(struct rx_header));
ND_PRINT(" bos call %s", tok2str(bos_req, "op#%u", bos_op));
ND_PRINT(" errcode");
INTOUT();
}
-
- return;
-
-trunc:
- ND_PRINT(" [|bos]");
}
/*
switch (ubik_op) {
case 10000: /* Beacon */
- ND_TCHECK_4(bp);
temp = GET_BE_U_4(bp);
bp += sizeof(uint32_t);
ND_PRINT(" syncsite %s", temp ? "yes" : "no");
INTOUT();
ND_PRINT(" length");
INTOUT();
- ND_TCHECK_4(bp);
temp = GET_BE_U_4(bp);
bp += sizeof(uint32_t);
tok2str(ubik_lock_types, "type %u", temp);