Do the special "if the first fragment we see is also the final fragment,
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Sat, 20 Dec 2003 03:21:20 +0000 (03:21 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Sat, 20 Dec 2003 03:21:20 +0000 (03:21 +0000)
treat it as a reassembled frame" hack *only* for 802.11, as that's the
only protocol we know of that requires it.

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

packet-ieee80211.c
reassemble.c
reassemble.h

index ab3f8433323fb00ab81bb4f15c21d948774cc78e..03f284249f9ea81cc920f26cb4d847dfc859c385 100644 (file)
@@ -3,7 +3,7 @@
  * Copyright 2000, Axis Communications AB
  * Inquiries/bugreports should be sent to Johan.Jorgensen@axis.com
  *
- * $Id: packet-ieee80211.c,v 1.101 2003/09/24 23:35:39 guy Exp $
+ * $Id: packet-ieee80211.c,v 1.102 2003/12/20 03:21:19 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -1864,7 +1864,7 @@ dissect_ieee80211_common (tvbuff_t * tvb, packet_info * pinfo,
    * Fragments" indicator set *but* with a non-zero fragment
    * number.
    *
-   * "fragment_add_seq_check()" handles that; we want to call it
+   * "fragment_add_seq_802_11()" handles that; we want to call it
    * even if we have a short frame, so that it does those checks - if
    * the frame is short, it doesn't do reassembly on it.
    *
@@ -1882,7 +1882,7 @@ dissect_ieee80211_common (tvbuff_t * tvb, packet_info * pinfo,
      * whatever reassembly is in progress, if any, and see
      * if it's done.
      */
-    fd_head = fragment_add_seq_check(next_tvb, hdr_len, pinfo, seq_number,
+    fd_head = fragment_add_seq_802_11(next_tvb, hdr_len, pinfo, seq_number,
                                     wlan_fragment_table,
                                     wlan_reassembled_table,
                                     frag_number,
index e03ad728085e0bb82777d367f5760c5d627ed2b6..d0b5f32994a0d4f470731fabdd7acd3fee5ac200 100644 (file)
@@ -1,7 +1,7 @@
 /* reassemble.c
  * Routines for {fragment,segment} reassembly
  *
- * $Id: reassemble.c,v 1.43 2003/09/25 01:50:41 tpot Exp $
+ * $Id: reassemble.c,v 1.44 2003/12/20 03:21:19 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -1239,29 +1239,36 @@ fragment_add_seq(tvbuff_t *tvb, int offset, packet_info *pinfo, guint32 id,
  * "fragment_data" structure is allocated to refer to the reassembled,
  * packet, and:
  *
- *     if "more_frags" is false, the structure is not added to
- *     the hash table, and not given any fragments to refer to,
- *     but is just returned;
+ *     if "more_frags" is false and "frag_802_11_hack" is true, the
+ *     structure is not added to the hash table, and not given any
+ *     fragments to refer to, but is just returned - this is a special
+ *     hack for the 802.11 dissector (see packet-80211.c);
  *
- *     if "more_frags" is true, this fragment is added to the linked
- *     list of fragments for this packet, and the "fragment_data"
- *     structure is put into the hash table.
+ *     otherwise, this fragment is added to the linked list of fragments
+ *     for this packet, and the "fragment_data" structure is put into
+ *     the hash table.
  *
  * Otherwise, this fragment is just added to the linked list of fragments
  * for this packet.
  *
- * Returns a pointer to the head of the fragment data list, and removes
- * that from the fragment hash table if necessary and adds it to the
- * table of reassembled fragments, if we have all the fragments or if
- * this is the only fragment and "more_frags" is false, returns NULL
- * otherwise.
+ * If, after processing this fragment, we have all the fragments,
+ * "fragment_add_seq_check_work()" removes that from the fragment hash
+ * table if necessary and adds it to the table of reassembled fragments,
+ * and returns a pointer to the head of the fragment list.
+ *
+ * If this is the first fragment we've seen, and "more_frags" is false
+ * and "frag_802_11_hack" is true, "fragment_add_seq_check_work()" does
+ * nothing to the fragment data list, and returns a pointer to the head
+ * of that (empty) list.
+ *
+ * Otherwise, it returns NULL.
  */
-fragment_data *
+static fragment_data *
 fragment_add_seq_check_work(tvbuff_t *tvb, int offset, packet_info *pinfo,
             guint32 id, GHashTable *fragment_table,
             GHashTable *reassembled_table, guint32 frag_number,
             guint32 frag_data_len, gboolean more_frags,
-            gboolean no_frag_number)
+            gboolean no_frag_number, gboolean frag_802_11_hack)
 {
        reassembled_key reass_key;
        fragment_key key, *new_key, *old_key;
@@ -1302,12 +1309,14 @@ fragment_add_seq_check_work(tvbuff_t *tvb, int offset, packet_info *pinfo,
                fd_head->data=NULL;
                fd_head->reassembled_in=0;
 
-               if (!more_frags) {
+               if (frag_802_11_hack && !more_frags) {
                        /*
                         * This is the last snooped fragment for this
-                        * packet as well; that means it's the only
-                        * fragment.  Just add it to the table of
-                        * reassembled packets, and return it.
+                        * packet as well, and is the only one we've
+                        * seen.  We're doing special 802.11 processing;
+                        * just add the fragment to the table of
+                        * reassembled packets, and return a pointer
+                        * to the head of the list.
                         */
                        fragment_reassembled(fd_head, pinfo,
                               reassembled_table, id);
@@ -1413,7 +1422,18 @@ fragment_add_seq_check(tvbuff_t *tvb, int offset, packet_info *pinfo,
 {
        return fragment_add_seq_check_work(tvb, offset, pinfo, id,
            fragment_table, reassembled_table, frag_number, frag_data_len,
-           more_frags, FALSE);
+           more_frags, FALSE, FALSE);
+}
+
+fragment_data *
+fragment_add_seq_802_11(tvbuff_t *tvb, int offset, packet_info *pinfo,
+            guint32 id, GHashTable *fragment_table,
+            GHashTable *reassembled_table, guint32 frag_number,
+            guint32 frag_data_len, gboolean more_frags)
+{
+       return fragment_add_seq_check_work(tvb, offset, pinfo, id,
+           fragment_table, reassembled_table, frag_number, frag_data_len,
+           more_frags, FALSE, TRUE);
 }
 
 fragment_data *
@@ -1424,7 +1444,7 @@ fragment_add_seq_next(tvbuff_t *tvb, int offset, packet_info *pinfo,
 {
        return fragment_add_seq_check_work(tvb, offset, pinfo, id,
            fragment_table, reassembled_table, 0, frag_data_len,
-           more_frags, TRUE);
+           more_frags, TRUE, FALSE);
 }
 
 /*
index 76900524aa844ab152aad7d0385828398065e66d..7e836f4df11072dde56473b47b07bda6f09c281f 100644 (file)
@@ -1,7 +1,7 @@
 /* reassemble.h
  * Declarations of outines for {fragment,segment} reassembly
  *
- * $Id: reassemble.h,v 1.20 2003/08/28 04:19:29 guy Exp $
+ * $Id: reassemble.h,v 1.21 2003/12/20 03:21:20 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -114,27 +114,33 @@ extern fragment_data *fragment_add_seq(tvbuff_t *tvb, int offset, packet_info *p
  * "fragment_data" structure is allocated to refer to the reassembled,
  * packet, and:
  *
- *     if "more_frags" is false, the structure is not added to
- *     the hash table, and not given any fragments to refer to,
- *     but is just returned;
+ *     in "fragment_add_seq_802_11()", if "more_frags" is false,
+ *     the structure is not added to the hash table, and not given
+ *     any fragments to refer to, but is just returned;
  *
- *     if "more_frags" is true, this fragment is added to the linked
- *     list of fragments for this packet, and the "fragment_data"
- *     structure is put into the hash table.
+ *     otherwise, this fragment is added to the linked list of fragments
+ *     for this packet, and the "fragment_data" structure is put into
+ *     the hash table.
  *
  * Otherwise, this fragment is just added to the linked list of fragments
  * for this packet.
  *
- * They return a pointer to the head of the fragment data list, and removes
- * that from the fragment hash table if necessary and adds it to the
- * table of reassembled fragments, if we have all the fragments or if
- * this is the only fragment and "more_frags" is false, returns NULL
- * otherwise.
+ * If, after processing this fragment, we have all the fragments, they
+ * remove that from the fragment hash table if necessary and add it
+ * to the table of reassembled fragments, and return a pointer to the
+ * head of the fragment list.
  *
- * They assumes frag_number is a block sequence number.
+ * If this is the first fragment we've seen, and "more_frags" is false,
+ * "fragment_add_seq_802_11()" does nothing to the fragment data list,
+ * and returns a pointer to the head of that (empty) list.  The other
+ * routines return NULL.
+ *
+ * Otherwise, they return NULL.
+ *
+ * "fragment_add_seq_check()" and "fragment_add_seq_802_11()" assume
+ * frag_number is a block sequence number.
  * The bsn for the first block is 0.
  *
- * "fragment_add_seq_check()" takes the sequence number as an argument;
  * "fragment_add_seq_next()" is for protocols with no sequence number,
  * and assumes fragments always appear in sequence.
  */
@@ -144,6 +150,12 @@ fragment_add_seq_check(tvbuff_t *tvb, int offset, packet_info *pinfo,
             GHashTable *reassembled_table, guint32 frag_number,
             guint32 frag_data_len, gboolean more_frags);
 
+extern fragment_data *
+fragment_add_seq_802_11(tvbuff_t *tvb, int offset, packet_info *pinfo,
+            guint32 id, GHashTable *fragment_table,
+            GHashTable *reassembled_table, guint32 frag_number,
+            guint32 frag_data_len, gboolean more_frags);
+
 extern fragment_data *
 fragment_add_seq_next(tvbuff_t *tvb, int offset, packet_info *pinfo, guint32 id,
             GHashTable *fragment_table, GHashTable *reassembled_table,