From Devin Heitmueller: improve decoding of outgoing and incoming
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Thu, 3 Jun 2004 04:19:38 +0000 (04:19 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Thu, 3 Jun 2004 04:19:38 +0000 (04:19 +0000)
message blocks.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@11081 f5534014-38df-0310-8fa8-9805f1628bb7

packet-aim-messaging.c
packet-aim.c
packet-aim.h

index 0b8f9dd00891c210b136615dc0949dc575111c03..19b4f6b25c5ba08affe7be260808dde058fd1ffd 100644 (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.8 2004/05/23 01:53:29 guy Exp $
+ * $Id: packet-aim-messaging.c,v 1.9 2004/06/03 04:19:38 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -87,7 +87,7 @@ static const value_string aim_fnac_family_messaging[] = {
 #define INCOMING_CH1_TYPING            0x000b
 
 static const aim_tlv messaging_incoming_ch1_tlvs[] = {
-  { INCOMING_CH1_MESSAGE_BLOCK, "Message Block", dissect_aim_tlv_value_bytes },
+  { INCOMING_CH1_MESSAGE_BLOCK, "Message Block", dissect_aim_tlv_value_messageblock },
   { INCOMING_CH1_SERVER_ACK_REQ, "Server Ack Requested", dissect_aim_tlv_value_bytes },
   { INCOMING_CH1_MESSAGE_AUTH_RESP, "Message is Auto Response", dissect_aim_tlv_value_bytes },
   { INCOMING_CH1_MESSAGE_OFFLINE, "Message was received offline", dissect_aim_tlv_value_bytes },
@@ -165,35 +165,31 @@ static int dissect_aim_messaging(tvbuff_t *tvb, packet_info *pinfo,
       return 0;
     case FAMILY_MESSAGING_OUTGOING:
 
-      /* Unknown */
-      offset += 10;
+      /* ICBM Cookie */
+      proto_tree_add_item(msg_tree, hf_aim_icbm_cookie, tvb, offset, 8, FALSE);
+      offset += 8;
 
-      buddyname_length = aim_get_buddyname( buddyname, tvb, offset, offset + 1 );
-      
-      if (check_col(pinfo->cinfo, COL_INFO))
-       col_append_fstr(pinfo->cinfo, COL_INFO, " to: %s", buddyname);
+      /* Message Channel ID */
+      proto_tree_add_item(msg_tree, hf_aim_message_channel_id, tvb, offset, 2,
+                         FALSE);
+      offset += 2;
 
-      if(msg_tree) {
-       proto_tree_add_text(msg_tree, tvb, offset, buddyname_length + 1,
-                           "Screen Name: %s", buddyname);
+      /* Add the outgoing username to the info column */
+      if (check_col(pinfo->cinfo, COL_INFO)) {
+       buddyname_length = aim_get_buddyname(buddyname, tvb, offset, 
+                                            offset + 1);
+       col_append_fstr(pinfo->cinfo, COL_INFO, " to: %s", buddyname);
       }
 
-      /* Buddyname length and buddyname */
-      offset += buddyname_length + 1;
+      offset = dissect_aim_buddyname(tvb, pinfo, offset, msg_tree);
 
-      /* djh - My test suggest that this is broken.  Need to give this a
-        closer look @@@@@@@@@ */
-      msg_length = tvb_ensure_length_remaining(tvb, offset);
-      aim_get_message( msg, tvb, offset, msg_length );
-      
-      if (check_col(pinfo->cinfo, COL_INFO))
-       col_append_fstr(pinfo->cinfo, COL_INFO, " -> %s", msg);
-      
-      /* XXX - put the message into the protocol tree?
-         In at least one capture, there's a bunch of bytes before the
-         "<HTML>" tag for the message.  "aim_get_message()" skips them,
-         looking for the "<HTML>" tag - are they part of the message,
-         or are they some other unknown field? */
+      while(tvb_reported_length_remaining(tvb, offset) > 0) {
+       /* djh - Note that we reuse the "incoming ch1 tlv" set even though this
+          is outgoing.  We may need to split this to a separate TLV set, but
+          so far I haven't seen the need @@@@@@@@ */
+       offset = dissect_aim_tlv(tvb, pinfo, offset, msg_tree, 
+                                         messaging_incoming_ch1_tlvs);
+      }
 
       return offset;
       
index 860dd99449f61fefb358555dc5820a6a2efe450f..a4842feaa6bdefeb6e385c08065f4150bc2f7ae9 100644 (file)
@@ -2,8 +2,9 @@
  * Routines for AIM Instant Messenger (OSCAR) dissection
  * Copyright 2000, Ralf Hoelzer <ralf@well.com>
  * Copyright 2004, Jelmer Vernooij <jelmer@samba.org>
+ * Copyright 2004, Devin Heitmueller <dheitmueller@netilla.com>
  *
- * $Id: packet-aim.c,v 1.41 2004/05/05 09:30:56 guy Exp $
+ * $Id: packet-aim.c,v 1.42 2004/06/03 04:19:38 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -319,6 +320,15 @@ static int hf_aim_userclass_unknown100 = -1;
 static int hf_aim_userclass_unknown200 = -1;
 static int hf_aim_userclass_unknown400 = -1;
 static int hf_aim_userclass_unknown800 = -1;
+static int hf_aim_messageblock_featuresdes = -1;
+static int hf_aim_messageblock_featureslen = -1;
+static int hf_aim_messageblock_features = -1;
+static int hf_aim_messageblock_info = -1;
+static int hf_aim_messageblock_len = -1;
+static int hf_aim_messageblock_charset = -1;
+static int hf_aim_messageblock_charsubset = -1;
+static int hf_aim_messageblock_message = -1;
+
 
 /* Initialize the subtree pointers */
 static gint ett_aim          = -1;
@@ -326,6 +336,7 @@ static gint ett_aim_buddyname= -1;
 static gint ett_aim_fnac     = -1;
 static gint ett_aim_tlv      = -1;
 static gint ett_aim_userclass = -1;
+static gint ett_aim_messageblock = -1;
 
 /* desegmentation of AIM over TCP */
 static gboolean aim_desegment = TRUE;
@@ -829,6 +840,68 @@ int dissect_aim_tlv_value_uint32 (proto_item *ti, guint16 valueid _U_, tvbuff_t
   return 4;
 }
 
+int dissect_aim_tlv_value_messageblock (proto_item *ti, guint16 valueid _U_, tvbuff_t *tvb){
+  proto_tree *entry;
+  guint8 *buf;
+  guint16 featurelen;
+  guint16 blocklen;
+  int offset=0;
+
+  /* Setup a new subtree */
+  entry = proto_item_add_subtree(ti, ett_aim_messageblock);
+
+  /* Features descriptor */
+  proto_tree_add_item(entry, hf_aim_messageblock_featuresdes, tvb, offset, 2,
+                     FALSE);
+  offset += 2;
+
+  /* Features Length */
+  featurelen = tvb_get_ntohs(tvb, offset);
+  proto_tree_add_item(entry, hf_aim_messageblock_featureslen, tvb, offset, 2,
+                     FALSE);
+  offset += 2;
+
+  /* Features (should be expanded further @@@@@@@ ) */
+  proto_tree_add_item(entry, hf_aim_messageblock_features, tvb, offset, 
+                     featurelen, FALSE);
+  offset += featurelen;
+
+  /* There can be multiple messages in this message block */
+  while (tvb_length_remaining(tvb, offset) > 0) {
+    /* Info field */
+    proto_tree_add_item(entry, hf_aim_messageblock_info, tvb, offset, 2,
+                       FALSE);
+    offset += 2;
+    
+    /* Block length (includes charset and charsubset) */
+    blocklen = tvb_get_ntohs(tvb, offset);
+    proto_tree_add_item(entry, hf_aim_messageblock_len, tvb, offset, 2,
+                       FALSE);
+    offset += 2;
+    
+    /* Character set */
+    proto_tree_add_item(entry, hf_aim_messageblock_charset, tvb, offset, 2,
+                       FALSE);
+    offset += 2;
+    
+    /* Character subset */
+    proto_tree_add_item(entry, hf_aim_messageblock_charsubset, tvb, offset, 2,
+                       FALSE);
+    offset += 2;
+
+    /* The actual message */
+    buf = tvb_get_string(tvb, offset, blocklen - 4 );
+    proto_item_set_text(ti, "Message: %s", buf);
+    proto_tree_add_item(entry, hf_aim_messageblock_message, tvb, offset, 
+                       blocklen-4,
+                       FALSE);
+    offset += tvb_length_remaining(tvb, offset);
+    g_free(buf);
+  }
+
+  return offset;
+}
+
 /* Dissect a TLV value */
 int dissect_aim_tlv(tvbuff_t *tvb, packet_info *pinfo _U_, 
                           int offset, proto_tree *tree, const aim_tlv *tlv)
@@ -1006,6 +1079,30 @@ proto_register_aim(void)
        { &hf_aim_userinfo_warninglevel,
                { "Warning Level", "aim.userinfo.warninglevel", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL },
        },
+    { &hf_aim_messageblock_featuresdes,
+               { "Features", "aim.messageblock.featuresdes", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL },
+       },
+    { &hf_aim_messageblock_featureslen,
+               { "Features Length", "aim.messageblock.featureslen", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL },
+       },
+    { &hf_aim_messageblock_features,
+               { "Features", "aim.messageblock.features", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL },
+       },
+    { &hf_aim_messageblock_info,
+               { "Block info", "aim.messageblock.info", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL },
+       },
+    { &hf_aim_messageblock_len,
+               { "Block length", "aim.messageblock.length", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL },
+       },
+    { &hf_aim_messageblock_charset,
+               { "Block Character set", "aim.messageblock.charset", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL },
+       },
+    { &hf_aim_messageblock_charsubset,
+               { "Block Character subset", "aim.messageblock.charsubset", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL },
+       },
+    { &hf_aim_messageblock_message,
+               { "Message", "aim.messageblock.message", FT_STRING, BASE_NONE, NULL, 0x0, "", HFILL },
+       },
   };
 
   /* Setup protocol subtree array */
@@ -1014,7 +1111,8 @@ proto_register_aim(void)
          &ett_aim_fnac,
          &ett_aim_tlv,
          &ett_aim_buddyname,
-         &ett_aim_userclass
+         &ett_aim_userclass,
+         &ett_aim_messageblock
   };
   module_t *aim_module;
 
index 42693ed9b45d11e0f590b2ca8bb65a30f561fef6..b9800ed54ead942b243d96b72857154f3d1f956a 100644 (file)
@@ -1,7 +1,7 @@
 /* packet-tcp.h
  * Copyright 2004, Jelmer Vernooij <jelmer@samba.org>
  *
- * $Id: packet-aim.h,v 1.5 2004/05/05 09:30:56 guy Exp $
+ * $Id: packet-aim.h,v 1.6 2004/06/03 04:19:38 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -65,6 +65,7 @@ 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, int len, proto_item *ti, guint32 flags);
 int dissect_aim_tlv_value_userclass(proto_item *ti, guint16, tvbuff_t *);
+int dissect_aim_tlv_value_messageblock (proto_item *ti, guint16 valueid _U_, tvbuff_t *tvb);
 
 extern const aim_tlv client_tlvs[];
 extern const aim_tlv onlinebuddy_tlvs[];