* Portions based on information/specs retrieved from the OpenAFS sources at
* www.openafs.org, Copyright IBM.
*
- * $Id: packet-afs.c,v 1.30 2001/05/27 01:48:23 guy Exp $
+ * $Id: packet-afs.c,v 1.36 2001/12/10 00:25:26 guy Exp $
*
* Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@zing.org>
+ * By Gerald Combs <gerald@ethereal.com>
* Copyright 1998 Gerald Combs
*
* Copied from packet-tftp.c
/*
* Dissector prototypes
*/
-static int dissect_acl(tvbuff_t *tvb, packet_info *pinfo,
+static int dissect_acl(tvbuff_t *tvb, struct rxinfo *rxinfo,
proto_tree *tree, int offset);
-static void dissect_fs_reply(tvbuff_t *tvb, packet_info *pinfo,
+static void dissect_fs_reply(tvbuff_t *tvb, struct rxinfo *rxinfo,
proto_tree *tree, int offset, int opcode);
-static void dissect_fs_request(tvbuff_t *tvb, packet_info *pinfo,
+static void dissect_fs_request(tvbuff_t *tvb, struct rxinfo *rxinfo,
proto_tree *tree, int offset, int opcode);
-static void dissect_bos_reply(tvbuff_t *tvb, packet_info *pinfo,
+static void dissect_bos_reply(tvbuff_t *tvb, struct rxinfo *rxinfo,
proto_tree *tree, int offset, int opcode);
-static void dissect_bos_request(tvbuff_t *tvb, packet_info *pinfo,
+static void dissect_bos_request(tvbuff_t *tvb, struct rxinfo *rxinfo,
proto_tree *tree, int offset, int opcode);
-static void dissect_vol_reply(tvbuff_t *tvb, packet_info *pinfo,
+static void dissect_vol_reply(tvbuff_t *tvb, struct rxinfo *rxinfo,
proto_tree *tree, int offset, int opcode);
-static void dissect_vol_request(tvbuff_t *tvb, packet_info *pinfo,
+static void dissect_vol_request(tvbuff_t *tvb, struct rxinfo *rxinfo,
proto_tree *tree, int offset, int opcode);
-static void dissect_kauth_reply(tvbuff_t *tvb, packet_info *pinfo,
+static void dissect_kauth_reply(tvbuff_t *tvb, struct rxinfo *rxinfo,
proto_tree *tree, int offset, int opcode);
-static void dissect_kauth_request(tvbuff_t *tvb, packet_info *pinfo,
+static void dissect_kauth_request(tvbuff_t *tvb, struct rxinfo *rxinfo,
proto_tree *tree, int offset, int opcode);
-static void dissect_cb_reply(tvbuff_t *tvb, packet_info *pinfo,
+static void dissect_cb_reply(tvbuff_t *tvb, struct rxinfo *rxinfo,
proto_tree *tree, int offset, int opcode);
-static void dissect_cb_request(tvbuff_t *tvb, packet_info *pinfo,
+static void dissect_cb_request(tvbuff_t *tvb, struct rxinfo *rxinfo,
proto_tree *tree, int offset, int opcode);
-static void dissect_prot_reply(tvbuff_t *tvb, packet_info *pinfo,
+static void dissect_prot_reply(tvbuff_t *tvb, struct rxinfo *rxinfo,
proto_tree *tree, int offset, int opcode);
-static void dissect_prot_request(tvbuff_t *tvb, packet_info *pinfo,
+static void dissect_prot_request(tvbuff_t *tvb, struct rxinfo *rxinfo,
proto_tree *tree, int offset, int opcode);
-static void dissect_vldb_reply(tvbuff_t *tvb, packet_info *pinfo,
+static void dissect_vldb_reply(tvbuff_t *tvb, struct rxinfo *rxinfo,
proto_tree *tree, int offset, int opcode);
-static void dissect_vldb_request(tvbuff_t *tvb, packet_info *pinfo,
+static void dissect_vldb_request(tvbuff_t *tvb, struct rxinfo *rxinfo,
proto_tree *tree, int offset, int opcode);
-static void dissect_ubik_reply(tvbuff_t *tvb, packet_info *pinfo,
+static void dissect_ubik_reply(tvbuff_t *tvb, struct rxinfo *rxinfo,
proto_tree *tree, int offset, int opcode);
-static void dissect_ubik_request(tvbuff_t *tvb, packet_info *pinfo,
+static void dissect_ubik_request(tvbuff_t *tvb, struct rxinfo *rxinfo,
proto_tree *tree, int offset, int opcode);
-static void dissect_backup_reply(tvbuff_t *tvb, packet_info *pinfo,
+static void dissect_backup_reply(tvbuff_t *tvb, struct rxinfo *rxinfo,
proto_tree *tree, int offset, int opcode);
-static void dissect_backup_request(tvbuff_t *tvb, packet_info *pinfo,
+static void dissect_backup_request(tvbuff_t *tvb, struct rxinfo *rxinfo,
proto_tree *tree, int offset, int opcode);
/*
* Dissection routines
*/
-void
+static void
dissect_afs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
+ struct rxinfo *rxinfo = pinfo->private_data;
int reply = 0;
conversation_t *conversation;
struct afs_request_key request_key, *new_request_key;
int port, node, typenode, opcode;
value_string const *vals;
int offset = 0;
- void (*dissector)(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int opcode);
+ void (*dissector)(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode);
- if (check_col(pinfo->fd, COL_PROTOCOL)) {
- col_set_str(pinfo->fd, COL_PROTOCOL, "AFS (RX)");
+ if (check_col(pinfo->cinfo, COL_PROTOCOL)) {
+ col_set_str(pinfo->cinfo, COL_PROTOCOL, "AFS (RX)");
}
- if (check_col(pinfo->fd, COL_INFO)) {
- col_clear(pinfo->fd, COL_INFO);
+ if (check_col(pinfo->cinfo, COL_INFO)) {
+ col_clear(pinfo->cinfo, COL_INFO);
}
- reply = (pinfo->ps.rx.flags & RX_CLIENT_INITIATED) == 0;
+ reply = (rxinfo->flags & RX_CLIENT_INITIATED) == 0;
port = ((reply == 0) ? pinfo->destport : pinfo->srcport );
/*
if (conversation == NULL) {
/* It's not part of any conversation - create a new one. */
conversation = conversation_new(&pinfo->src, &pinfo->dst,
- pinfo->ptype, pinfo->srcport, pinfo->destport, NULL, 0);
+ pinfo->ptype, pinfo->srcport, pinfo->destport, 0);
}
request_key.conversation = conversation->index;
- request_key.service = pinfo->ps.rx.serviceid;
- request_key.callnumber = pinfo->ps.rx.callnumber;
+ request_key.service = rxinfo->serviceid;
+ request_key.callnumber = rxinfo->callnumber;
request_val = (struct afs_request_val *) g_hash_table_lookup(
afs_request_hash, &request_key);
if ( VALID_OPCODE(opcode) ) {
if ( vals ) {
- if (check_col(pinfo->fd, COL_INFO))
- col_add_fstr(pinfo->fd, COL_INFO, "%s%s %s: %s (%d)",
+ if (check_col(pinfo->cinfo, COL_INFO))
+ col_add_fstr(pinfo->cinfo, COL_INFO, "%s%s %s: %s (%d)",
typenode == hf_afs_ubik ? "UBIK-" : "",
val_to_str(port, port_types_short, "Unknown(%d)"),
reply ? "Reply" : "Request",
val_to_str(opcode, vals, "Unknown(%d)"), opcode);
} else {
- if (check_col(pinfo->fd, COL_INFO))
- col_add_fstr(pinfo->fd, COL_INFO, "%s%s %s: Unknown(%d)",
+ if (check_col(pinfo->cinfo, COL_INFO))
+ col_add_fstr(pinfo->cinfo, COL_INFO, "%s%s %s: Unknown(%d)",
typenode == hf_afs_ubik ? "UBIK-" : "",
val_to_str(port, port_types_short, "Unknown(%d)"),
reply ? "Reply" : "Request",
opcode);
}
} else {
- if (check_col(pinfo->fd, COL_INFO))
- col_add_fstr(pinfo->fd, COL_INFO, "Encrypted %s %s",
+ if (check_col(pinfo->cinfo, COL_INFO))
+ col_add_fstr(pinfo->cinfo, COL_INFO, "Encrypted %s %s",
val_to_str(port, port_types_short, "Unknown(%d)"),
reply ? "Reply" : "Request"
);
/* Process the packet according to what service it is */
if ( dissector ) {
- (*dissector)(tvb, pinfo, afs_op_tree, offset, opcode);
+ (*dissector)(tvb, rxinfo, afs_op_tree, offset, opcode);
}
}
}
/* if it's the last packet, and it's a reply, remove opcode
from hash */
/* ignoring for now, I'm not sure how the chunk deallocation works */
- if ( pinfo->ps.rx.flags & RX_LAST_PACKET && reply ){
+ if ( rxinfo->flags & RX_LAST_PACKET && reply ){
}
}
*/
/* FIXME: sscanf is probably quite dangerous if we run outside the packet. */
static int
-dissect_acl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
+dissect_acl(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset)
{
int old_offset;
- guint32 bytes;
+ gint32 bytes;
int i, n, pos, neg, acl;
char user[128]; /* Be sure to adjust sscanf()s below if length is changed... */
*/
static void
-dissect_fs_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int opcode)
+dissect_fs_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
{
- if ( pinfo->ps.rx.type == RX_PACKET_TYPE_DATA )
+ if ( rxinfo->type == RX_PACKET_TYPE_DATA )
{
switch ( opcode )
{
case 130: /* fetch data */
/* only on first packet */
- if ( pinfo->ps.rx.seq == 1 )
+ if ( rxinfo->seq == 1 )
{
OUT_FS_AFSFetchStatus("Status");
OUT_FS_AFSCallBack();
OUT_BYTES_ALL(hf_afs_fs_data);
break;
case 131: /* fetch acl */
- offset = dissect_acl(tvb, pinfo, tree, offset);
+ offset = dissect_acl(tvb, rxinfo, tree, offset);
OUT_FS_AFSFetchStatus("Status");
OUT_FS_AFSVolSync();
break;
break;
}
}
- else if ( pinfo->ps.rx.type == RX_PACKET_TYPE_ABORT )
+ else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
{
OUT_UINT(hf_afs_fs_errcode);
}
}
static void
-dissect_fs_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int opcode)
+dissect_fs_request(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
{
offset += 4; /* skip the opcode */
break;
case 134: /* Store ACL */
OUT_FS_AFSFid("Target");
- offset = dissect_acl(tvb, pinfo, tree, offset);
+ offset = dissect_acl(tvb, rxinfo, tree, offset);
break;
case 135: /* Store Status */
OUT_FS_AFSFid("Target");
* BOS Helpers
*/
static void
-dissect_bos_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int opcode)
+dissect_bos_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
{
- if ( pinfo->ps.rx.type == RX_PACKET_TYPE_DATA )
+ if ( rxinfo->type == RX_PACKET_TYPE_DATA )
{
switch ( opcode )
{
break;
}
}
- else if ( pinfo->ps.rx.type == RX_PACKET_TYPE_ABORT )
+ else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
{
OUT_UINT(hf_afs_bos_errcode);
}
}
static void
-dissect_bos_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int opcode)
+dissect_bos_request(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
{
offset += 4; /* skip the opcode */
* VOL Helpers
*/
static void
-dissect_vol_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int opcode)
+dissect_vol_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
{
- if ( pinfo->ps.rx.type == RX_PACKET_TYPE_DATA )
+ if ( rxinfo->type == RX_PACKET_TYPE_DATA )
{
switch ( opcode )
{
break;
}
}
- else if ( pinfo->ps.rx.type == RX_PACKET_TYPE_ABORT )
+ else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
{
OUT_UINT(hf_afs_vol_errcode);
}
}
static void
-dissect_vol_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int opcode)
+dissect_vol_request(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
{
offset += 4; /* skip the opcode */
* KAUTH Helpers
*/
static void
-dissect_kauth_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int opcode)
+dissect_kauth_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
{
- if ( pinfo->ps.rx.type == RX_PACKET_TYPE_DATA )
+ if ( rxinfo->type == RX_PACKET_TYPE_DATA )
{
switch ( opcode )
{
}
}
- else if ( pinfo->ps.rx.type == RX_PACKET_TYPE_ABORT )
+ else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
{
OUT_UINT(hf_afs_kauth_errcode);
}
}
static void
-dissect_kauth_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int opcode)
+dissect_kauth_request(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
{
offset += 4; /* skip the opcode */
* CB Helpers
*/
static void
-dissect_cb_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int opcode)
+dissect_cb_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
{
- if ( pinfo->ps.rx.type == RX_PACKET_TYPE_DATA )
+ if ( rxinfo->type == RX_PACKET_TYPE_DATA )
{
switch ( opcode )
{
}
}
- else if ( pinfo->ps.rx.type == RX_PACKET_TYPE_ABORT )
+ else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
{
OUT_UINT(hf_afs_cb_errcode);
}
}
static void
-dissect_cb_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int opcode)
+dissect_cb_request(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
{
offset += 4; /* skip the opcode */
* PROT Helpers
*/
static void
-dissect_prot_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int opcode)
+dissect_prot_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
{
- if ( pinfo->ps.rx.type == RX_PACKET_TYPE_DATA )
+ if ( rxinfo->type == RX_PACKET_TYPE_DATA )
{
switch ( opcode )
{
break;
}
}
- else if ( pinfo->ps.rx.type == RX_PACKET_TYPE_ABORT )
+ else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
{
OUT_UINT(hf_afs_prot_errcode);
}
}
static void
-dissect_prot_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int opcode)
+dissect_prot_request(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
{
offset += 4; /* skip the opcode */
* VLDB Helpers
*/
static void
-dissect_vldb_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int opcode)
+dissect_vldb_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
{
- if ( pinfo->ps.rx.type == RX_PACKET_TYPE_DATA )
+ if ( rxinfo->type == RX_PACKET_TYPE_DATA )
{
switch ( opcode )
{
break;
}
}
- else if ( pinfo->ps.rx.type == RX_PACKET_TYPE_ABORT )
+ else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
{
OUT_UINT(hf_afs_vldb_errcode);
}
}
static void
-dissect_vldb_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int opcode)
+dissect_vldb_request(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
{
offset += 4; /* skip the opcode */
* UBIK Helpers
*/
static void
-dissect_ubik_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int opcode)
+dissect_ubik_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
{
switch ( opcode )
{
}
static void
-dissect_ubik_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int opcode)
+dissect_ubik_request(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
{
offset += 4; /* skip the opcode */
* BACKUP Helpers
*/
static void
-dissect_backup_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int opcode)
+dissect_backup_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
{
- if ( pinfo->ps.rx.type == RX_PACKET_TYPE_DATA )
+ if ( rxinfo->type == RX_PACKET_TYPE_DATA )
{
switch ( opcode )
{
}
}
- else if ( pinfo->ps.rx.type == RX_PACKET_TYPE_ABORT )
+ else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
{
OUT_UINT(hf_afs_backup_errcode);
}
}
static void
-dissect_backup_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int opcode)
+dissect_backup_request(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
{
offset += 4; /* skip the opcode */
proto_register_field_array(proto_afs, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
register_init_routine(&afs_init_protocol);
-}
+ register_dissector("afs", dissect_afs, proto_afs);
+}