Use "tvb_reported_length_remaining()" in "until the end of the packet"

loops, so we mark frames as short if they've been cut short by a
snapshot length.

The user class in buddy list TLVs appears to be 2 bytes, in at least
some captures; make "dissect_aim_userclass()" take the user class value,
and the length of the user class field, as arguments, and have the
caller fetch the value.  Also, display the numerical value of the user
class in hex, as it's a bitset.

Fix the messaging dissector to put stuff under the top-level item rather
than at the top level.

Fix a typo.

Clean up indentation.

svn path=/trunk/; revision=10802
This commit is contained in:
Guy Harris 2004-05-05 09:30:56 +00:00
parent b42f088ae5
commit 85fe1e6dee
4 changed files with 114 additions and 112 deletions

View File

@ -2,7 +2,7 @@
* Routines for AIM (OSCAR) dissection, SNAC BOS
* Copyright 2004, Jelmer Vernooij <jelmer@samba.org>
*
* $Id: packet-aim-bos.c,v 1.3 2004/04/26 18:21:09 obiot Exp $
* $Id: packet-aim-bos.c,v 1.4 2004/05/05 09:30:56 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -100,10 +100,11 @@ static int dissect_aim_bos(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
int offset = 0;
proto_item *ti;
proto_tree *bos_tree = NULL;
guint32 userclass;
if(tree) {
ti = proto_tree_add_text(tree, tvb, 0, -1,"AIM Privacy Management Service");
bos_tree = proto_item_add_subtree(ti, ett_aim_bos);
ti = proto_tree_add_text(tree, tvb, 0, -1,"AIM Privacy Management Service");
bos_tree = proto_item_add_subtree(ti, ett_aim_bos);
}
switch(aiminfo->subtype) {
@ -113,10 +114,11 @@ static int dissect_aim_bos(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
/* No data */
return 0;
case FAMILY_BOS_SET_GROUP_PERM:
ti = proto_tree_add_uint(bos_tree, hf_aim_bos_class, tvb, offset, 4, FALSE);
return dissect_aim_userclass(tvb, offset, bos_tree);
userclass = tvb_get_ntohl(tvb, offset);
ti = proto_tree_add_uint(bos_tree, hf_aim_bos_class, tvb, offset, 4, userclass);
return dissect_aim_userclass(tvb, offset, 4, ti, userclass);
case FAMILY_BOS_RIGHTS:
while(tvb_length_remaining(tvb, offset) > 0) {
while(tvb_reported_length_remaining(tvb, offset) > 0) {
offset = dissect_aim_tlv(tvb, pinfo, offset, bos_tree, privacy_tlvs);
}
return offset;
@ -124,7 +126,7 @@ static int dissect_aim_bos(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
case FAMILY_BOS_DEL_FROM_VISIBLE:
case FAMILY_BOS_ADD_TO_INVISIBLE:
case FAMILY_BOS_DEL_FROM_INVISIBLE:
while(tvb_length_remaining(tvb, offset) > 0) {
while(tvb_reported_length_remaining(tvb, offset) > 0) {
offset = dissect_aim_buddyname(tvb, pinfo, offset, bos_tree);
}
return offset;

View File

@ -4,7 +4,7 @@
* Copyright 2000, Ralf Hoelzer <ralf@well.com>
* Copyright 2004, Devin Heitmueller <dheitmueller@netilla.com>
*
* $Id: packet-aim-messaging.c,v 1.5 2004/04/26 18:21:09 obiot Exp $
* $Id: packet-aim-messaging.c,v 1.6 2004/05/05 09:30:56 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -149,19 +149,19 @@ static int dissect_aim_messaging(tvbuff_t *tvb, packet_info *pinfo,
proto_item *ti = NULL;
proto_tree *msg_tree = NULL;
if(tree) {
ti = proto_tree_add_text(tree, tvb, 0, -1,"AIM Messaging Service");
msg_tree = proto_item_add_subtree(ti, ett_aim_messaging);
}
if(tree) {
ti = proto_tree_add_text(tree, tvb, 0, -1,"AIM Messaging Service");
msg_tree = proto_item_add_subtree(ti, ett_aim_messaging);
}
switch(aiminfo->subtype)
{
case FAMILY_MESSAGING_ERROR:
case FAMILY_MESSAGING_ERROR:
return dissect_aim_snac_error(tvb, pinfo, offset, msg_tree);
case FAMILY_MESSAGING_RESETICBMPARAM:
case FAMILY_MESSAGING_REQPARAMINFO:
/* No data */
return 0;
case FAMILY_MESSAGING_RESETICBMPARAM:
case FAMILY_MESSAGING_REQPARAMINFO:
/* No data */
return 0;
case FAMILY_MESSAGING_OUTGOING:
/* Unknown */
@ -192,53 +192,53 @@ static int dissect_aim_messaging(tvbuff_t *tvb, packet_info *pinfo,
case FAMILY_MESSAGING_INCOMING:
/* ICBM Cookie */
proto_tree_add_item(tree, hf_aim_icbm_cookie, tvb, offset, 8, FALSE);
proto_tree_add_item(msg_tree, hf_aim_icbm_cookie, tvb, offset, 8, FALSE);
offset += 8;
/* Message Channel ID */
proto_tree_add_item(tree, hf_aim_message_channel_id, tvb, offset, 2,
proto_tree_add_item(msg_tree, hf_aim_message_channel_id, tvb, offset, 2,
FALSE);
offset += 2;
offset = dissect_aim_userinfo(tvb, pinfo, offset, tree);
offset = dissect_aim_userinfo(tvb, pinfo, offset, msg_tree);
while(tvb_length_remaining(tvb, offset) > 0) {
offset = dissect_aim_tlv(tvb, pinfo, offset, tree,
while(tvb_reported_length_remaining(tvb, offset) > 0) {
offset = dissect_aim_tlv(tvb, pinfo, offset, msg_tree,
messaging_incoming_ch1_tlvs);
}
return offset;
case FAMILY_MESSAGING_SETICBMPARAM:
case FAMILY_MESSAGING_PARAMINFO:
proto_tree_add_item(msg_tree, hf_aim_icbm_channel, tvb, offset, 2, tvb_get_ntohs(tvb, offset)); offset+=2;
proto_tree_add_item(msg_tree, hf_aim_icbm_msg_flags, tvb, offset, 4, tvb_get_ntoh24(tvb, offset)); offset+=4;
proto_tree_add_item(msg_tree, hf_aim_icbm_max_snac_size, tvb, offset, 2, tvb_get_ntohs(tvb, offset)); offset+=2;
proto_tree_add_item(msg_tree, hf_aim_icbm_max_sender_warnlevel, tvb, offset, 2, tvb_get_ntohs(tvb, offset)); offset+=2;
proto_tree_add_item(msg_tree, hf_aim_icbm_max_receiver_warnlevel, tvb, offset, 2, tvb_get_ntohs(tvb, offset)); offset+=2;
proto_tree_add_item(msg_tree, hf_aim_icbm_min_msg_interval, tvb, offset, 2, tvb_get_ntohs(tvb, offset)); offset+=2;
proto_tree_add_item(msg_tree, hf_aim_icbm_unknown, tvb, offset, 2, tvb_get_ntohs(tvb, offset)); offset+=2;
return offset;
case FAMILY_MESSAGING_EVILREQ:
proto_tree_add_item(msg_tree, hf_aim_icbm_evil, tvb, offset, 2, tvb_get_ntohs(tvb, offset)); offset+=2;
return dissect_aim_buddyname(tvb, pinfo, offset, tree);
case FAMILY_MESSAGING_EVIL:
proto_tree_add_item(msg_tree, hf_aim_evil_warn_level, tvb, offset, 2, tvb_get_ntohs(tvb, offset)); offset+=2;
proto_tree_add_item(msg_tree, hf_aim_evil_new_warn_level, tvb, offset, 2, tvb_get_ntohs(tvb, offset)); offset+=2;
return offset;
case FAMILY_MESSAGING_MINITYPING:
proto_tree_add_item(msg_tree,hf_aim_icbm_notification_cookie, tvb, offset, 8, FALSE); offset+=8;
proto_tree_add_item(msg_tree,hf_aim_icbm_notification_channel, tvb, offset, 2, tvb_get_ntohs(tvb, offset)); offset+=2;
offset = dissect_aim_buddyname(tvb, pinfo, offset, tree);
proto_tree_add_item(msg_tree,hf_aim_icbm_notification_type, tvb, offset, 2, tvb_get_ntohs(tvb, offset)); offset+=2;
return offset;
case FAMILY_MESSAGING_MISSEDCALL:
case FAMILY_MESSAGING_CLIENTAUTORESP:
case FAMILY_MESSAGING_ACK:
/*FIXME*/
case FAMILY_MESSAGING_SETICBMPARAM:
case FAMILY_MESSAGING_PARAMINFO:
proto_tree_add_item(msg_tree, hf_aim_icbm_channel, tvb, offset, 2, tvb_get_ntohs(tvb, offset)); offset+=2;
proto_tree_add_item(msg_tree, hf_aim_icbm_msg_flags, tvb, offset, 4, tvb_get_ntoh24(tvb, offset)); offset+=4;
proto_tree_add_item(msg_tree, hf_aim_icbm_max_snac_size, tvb, offset, 2, tvb_get_ntohs(tvb, offset)); offset+=2;
proto_tree_add_item(msg_tree, hf_aim_icbm_max_sender_warnlevel, tvb, offset, 2, tvb_get_ntohs(tvb, offset)); offset+=2;
proto_tree_add_item(msg_tree, hf_aim_icbm_max_receiver_warnlevel, tvb, offset, 2, tvb_get_ntohs(tvb, offset)); offset+=2;
proto_tree_add_item(msg_tree, hf_aim_icbm_min_msg_interval, tvb, offset, 2, tvb_get_ntohs(tvb, offset)); offset+=2;
proto_tree_add_item(msg_tree, hf_aim_icbm_unknown, tvb, offset, 2, tvb_get_ntohs(tvb, offset)); offset+=2;
return offset;
case FAMILY_MESSAGING_EVILREQ:
proto_tree_add_item(msg_tree, hf_aim_icbm_evil, tvb, offset, 2, tvb_get_ntohs(tvb, offset)); offset+=2;
return dissect_aim_buddyname(tvb, pinfo, offset, tree);
case FAMILY_MESSAGING_EVIL:
proto_tree_add_item(msg_tree, hf_aim_evil_warn_level, tvb, offset, 2, tvb_get_ntohs(tvb, offset)); offset+=2;
proto_tree_add_item(msg_tree, hf_aim_evil_new_warn_level, tvb, offset, 2, tvb_get_ntohs(tvb, offset)); offset+=2;
return offset;
case FAMILY_MESSAGING_MINITYPING:
proto_tree_add_item(msg_tree,hf_aim_icbm_notification_cookie, tvb, offset, 8, FALSE); offset+=8;
proto_tree_add_item(msg_tree,hf_aim_icbm_notification_channel, tvb, offset, 2, tvb_get_ntohs(tvb, offset)); offset+=2;
offset = dissect_aim_buddyname(tvb, pinfo, offset, msg_tree);
proto_tree_add_item(msg_tree,hf_aim_icbm_notification_type, tvb, offset, 2, tvb_get_ntohs(tvb, offset)); offset+=2;
return offset;
case FAMILY_MESSAGING_MISSEDCALL:
case FAMILY_MESSAGING_CLIENTAUTORESP:
case FAMILY_MESSAGING_ACK:
/*FIXME*/
default:
return 0;
default:
return 0;
}
}
@ -249,51 +249,51 @@ proto_register_aim_messaging(void)
/* Setup list of header fields */
static hf_register_info hf[] = {
{ &hf_aim_icbm_channel,
{ "Channel to setup", "aim.icbm.channel", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL },
},
{ &hf_aim_icbm_msg_flags,
{ "Message Flags", "aim.icbm.flags", FT_UINT32, BASE_HEX, NULL, 0x0, "", HFILL },
},
{ &hf_aim_icbm_max_snac_size,
{ "Max SNAC Size", "aim.icbm.max_snac", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL },
},
{ &hf_aim_icbm_max_sender_warnlevel,
{ "Max sender warn level", "aim.icbm.max_sender_warn-level", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL },
},
{ &hf_aim_icbm_channel,
{ "Channel to setup", "aim.icbm.channel", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL },
},
{ &hf_aim_icbm_msg_flags,
{ "Message Flags", "aim.icbm.flags", FT_UINT32, BASE_HEX, NULL, 0x0, "", HFILL },
},
{ &hf_aim_icbm_max_snac_size,
{ "Max SNAC Size", "aim.icbm.max_snac", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL },
},
{ &hf_aim_icbm_max_sender_warnlevel,
{ "Max sender warn level", "aim.icbm.max_sender_warn-level", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL },
},
{ &hf_aim_icbm_max_receiver_warnlevel,
{ "max receiver warn level", "aim.icbm.max_receiver_warnlevel", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL },
},
{ &hf_aim_icbm_min_msg_interval,
{ "Minimum message interval (seconds)", "aim.icbm.min_msg_interval", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL },
},
{ &hf_aim_icbm_unknown,
{ "Uknown parameter", "aim.icbm.unknown", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL },
},
{ "max receiver warn level", "aim.icbm.max_receiver_warnlevel", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL },
},
{ &hf_aim_icbm_min_msg_interval,
{ "Minimum message interval (seconds)", "aim.icbm.min_msg_interval", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL },
},
{ &hf_aim_icbm_unknown,
{ "Unknown parameter", "aim.icbm.unknown", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL },
},
{ &hf_aim_icbm_cookie,
{ "ICBM Cookie", "aim.messaging.icbmcookie", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL }
},
{ &hf_aim_message_channel_id,
{ "Message Channel ID", "aim.messaging.channelid", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL }
},
{ &hf_aim_icbm_evil,
{ "Send Evil Bit As", "aim.evilreq.origin", FT_UINT16, BASE_DEC, VALS(evil_origins), 0x0, "", HFILL },
},
{ &hf_aim_evil_warn_level,
{ "Old warning level", "aim.evil.warn_level", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL },
},
{ &hf_aim_evil_new_warn_level,
{ "New warning level", "aim.evil.new_warn_level", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL },
},
{ &hf_aim_icbm_notification_cookie,
{ "Notification Cookie", "aim.notification.cookie", FT_BYTES, BASE_DEC, NULL, 0x0, "", HFILL },
},
{ &hf_aim_icbm_notification_channel,
{ "Notification Channel", "aim.notification.channel", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL },
},
{ &hf_aim_icbm_notification_type,
{ "Notification Type", "aim.notification.type", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL },
},
{ &hf_aim_icbm_evil,
{ "Send Evil Bit As", "aim.evilreq.origin", FT_UINT16, BASE_DEC, VALS(evil_origins), 0x0, "", HFILL },
},
{ &hf_aim_evil_warn_level,
{ "Old warning level", "aim.evil.warn_level", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL },
},
{ &hf_aim_evil_new_warn_level,
{ "New warning level", "aim.evil.new_warn_level", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL },
},
{ &hf_aim_icbm_notification_cookie,
{ "Notification Cookie", "aim.notification.cookie", FT_BYTES, BASE_DEC, NULL, 0x0, "", HFILL },
},
{ &hf_aim_icbm_notification_channel,
{ "Notification Channel", "aim.notification.channel", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL },
},
{ &hf_aim_icbm_notification_type,
{ "Notification Type", "aim.notification.type", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL },
},
};
/* Setup protocol subtree array */

View File

@ -3,7 +3,7 @@
* Copyright 2000, Ralf Hoelzer <ralf@well.com>
* Copyright 2004, Jelmer Vernooij <jelmer@samba.org>
*
* $Id: packet-aim.c,v 1.40 2004/04/26 21:11:33 obiot Exp $
* $Id: packet-aim.c,v 1.41 2004/05/05 09:30:56 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -561,7 +561,7 @@ static void dissect_aim_newconn(tvbuff_t *tvb, packet_info *pinfo,
if (tvb_length_remaining(tvb, offset) > 0) {
proto_tree_add_item(tree, hf_aim_authcookie, tvb, offset, 4, FALSE);
offset+=4;
while(tvb_length_remaining(tvb, offset) > 0) {
while(tvb_reported_length_remaining(tvb, offset) > 0) {
offset = dissect_aim_tlv(tvb, pinfo, offset, tree, client_tlvs);
}
}
@ -699,7 +699,7 @@ static void dissect_aim_close_conn(tvbuff_t *tvb, packet_info *pinfo,
col_add_fstr(pinfo->cinfo, COL_INFO, "Close Connection");
}
while(tvb_length_remaining(tvb, offset) > 0) {
while(tvb_reported_length_remaining(tvb, offset) > 0) {
offset = dissect_aim_tlv(tvb, pinfo, offset, tree, client_tlvs);
}
}
@ -751,31 +751,31 @@ int dissect_aim_tlv_value_time(proto_item *ti _U_, guint16 valueid _U_, tvbuff_t
return tvb_length(tvb);
}
int dissect_aim_userclass(tvbuff_t *tvb, int offset, proto_item *ti)
int dissect_aim_userclass(tvbuff_t *tvb, int offset, int len, proto_item *ti, guint32 flags)
{
guint32 flags = tvb_get_ntoh24(tvb, offset);
proto_tree *entry;
entry = proto_item_add_subtree(ti, ett_aim_userclass);
proto_tree_add_boolean(entry, hf_aim_userclass_unconfirmed, tvb, offset, 4, flags);
proto_tree_add_boolean(entry, hf_aim_userclass_administrator, tvb, offset, 4, flags);
proto_tree_add_boolean(entry, hf_aim_userclass_aol, tvb, offset, 4, flags);
proto_tree_add_boolean(entry, hf_aim_userclass_commercial, tvb, offset, 4, flags);
proto_tree_add_boolean(entry, hf_aim_userclass_free, tvb, offset, 4, flags);
proto_tree_add_boolean(entry, hf_aim_userclass_away, tvb, offset, 4, flags);
proto_tree_add_boolean(entry, hf_aim_userclass_icq, tvb, offset, 4, flags);
proto_tree_add_boolean(entry, hf_aim_userclass_wireless, tvb, offset, 4, flags);
proto_tree_add_boolean(entry, hf_aim_userclass_unknown100, tvb, offset, 4, flags);
proto_tree_add_boolean(entry, hf_aim_userclass_unknown200, tvb, offset, 4, flags);
proto_tree_add_boolean(entry, hf_aim_userclass_unknown400, tvb, offset, 4, flags);
proto_tree_add_boolean(entry, hf_aim_userclass_unknown800, tvb, offset, 4, flags);
return offset+4;
proto_tree_add_boolean(entry, hf_aim_userclass_unconfirmed, tvb, offset, len, flags);
proto_tree_add_boolean(entry, hf_aim_userclass_administrator, tvb, offset, len, flags);
proto_tree_add_boolean(entry, hf_aim_userclass_aol, tvb, offset, len, flags);
proto_tree_add_boolean(entry, hf_aim_userclass_commercial, tvb, offset, len, flags);
proto_tree_add_boolean(entry, hf_aim_userclass_free, tvb, offset, len, flags);
proto_tree_add_boolean(entry, hf_aim_userclass_away, tvb, offset, len, flags);
proto_tree_add_boolean(entry, hf_aim_userclass_icq, tvb, offset, len, flags);
proto_tree_add_boolean(entry, hf_aim_userclass_wireless, tvb, offset, len, flags);
proto_tree_add_boolean(entry, hf_aim_userclass_unknown100, tvb, offset, len, flags);
proto_tree_add_boolean(entry, hf_aim_userclass_unknown200, tvb, offset, len, flags);
proto_tree_add_boolean(entry, hf_aim_userclass_unknown400, tvb, offset, len, flags);
proto_tree_add_boolean(entry, hf_aim_userclass_unknown800, tvb, offset, len, flags);
return offset+len;
}
int dissect_aim_tlv_value_userclass(proto_item *ti, guint16 valueid, tvbuff_t *tvb)
int dissect_aim_tlv_value_userclass(proto_item *ti, guint16 valueid _U_, tvbuff_t *tvb)
{
dissect_aim_tlv_value_uint32(ti, valueid, tvb);
return dissect_aim_userclass(tvb, 0, ti);
guint16 value16 = tvb_get_ntohs(tvb, 0);
proto_item_set_text(ti, "Value: 0x%04x", value16);
return dissect_aim_userclass(tvb, 0, 2, ti, value16);
}
static int dissect_aim_tlv_value_userstatus(proto_item *ti _U_, guint16 valueid _U_, tvbuff_t *tvb)

View File

@ -1,7 +1,7 @@
/* packet-tcp.h
* Copyright 2004, Jelmer Vernooij <jelmer@samba.org>
*
* $Id: packet-aim.h,v 1.4 2004/04/27 19:54:53 guy Exp $
* $Id: packet-aim.h,v 1.5 2004/05/05 09:30:56 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -63,7 +63,7 @@ int dissect_aim_tlv_value_bytes(proto_item *ti, guint16, tvbuff_t *);
int dissect_aim_tlv_value_ipv4(proto_item *ti, guint16, tvbuff_t *);
int dissect_aim_tlv_value_time(proto_item *ti, guint16, tvbuff_t *);
int dissect_aim_tlv_value_client_capabilities(proto_item *ti, guint16, tvbuff_t *);
int dissect_aim_userclass(tvbuff_t *tvb, int offset, proto_item *ti);
int dissect_aim_userclass(tvbuff_t *tvb, int offset, int len, proto_item *ti, guint32 flags);
int dissect_aim_tlv_value_userclass(proto_item *ti, guint16, tvbuff_t *);
extern const aim_tlv client_tlvs[];