aboutsummaryrefslogtreecommitdiffstats
path: root/reassemble.h
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2002-04-17 08:25:05 +0000
committerGuy Harris <guy@alum.mit.edu>2002-04-17 08:25:05 +0000
commited3b0cae650759d673f0898febb1f6518774c9f6 (patch)
tree621bae3a8d9d7445807c25615036ede4a0beac26 /reassemble.h
parent8241e67243d65ff53072dadb2bcfa7c0dc06f316 (diff)
Add a separate hash table to the reassembly code for reassembled
packets, using the reassembly ID and the frame number of the final frame as the key. There is no guarantee that reassembly IDs won't be reused, even when talking between the same source and destination address; if, once reassembly is complete, the "fragment_data" structure is moved to the latter hash table, this will keep reused reassembly IDs from causing mis-reassembly. Add a routine "fragment_add_seq_check()", which if a fragment has the "more fragments" flag not set but is the first fragment of a reassembly, treats that as a non-fragmented frame, allocating a "fragment_data" structure for the reassembly but not attaching any fragment to it, and adding it to a reassembled packet list; if a packet has been reassembled, removes it from the table of reassemblies and moves it to the table of reassembled packets; if the frame's been seen already, looks it up in the table of reassembled packets rather than the table of reassemblies. Add reassembly support for fragmented 802.11 frames. Use "fragment_add_seq_check()" to cope with the fact that some hardware+drivers apparently hands us reassembled frames with a non-zero fragment number and the "more fragments" bit clear (as if it puts the 802.11 header of the *last* fragment onto the reassembled data). svn path=/trunk/; revision=5177
Diffstat (limited to 'reassemble.h')
-rw-r--r--reassemble.h41
1 files changed, 38 insertions, 3 deletions
diff --git a/reassemble.h b/reassemble.h
index 522fc0abef..4fc8daad73 100644
--- a/reassemble.h
+++ b/reassemble.h
@@ -1,7 +1,7 @@
/* reassemble.h
* Declarations of outines for {fragment,segment} reassembly
*
- * $Id: reassemble.h,v 1.5 2002/04/17 04:54:30 guy Exp $
+ * $Id: reassemble.h,v 1.6 2002/04/17 08:25:05 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -67,6 +67,11 @@ typedef struct _fragment_data {
void fragment_table_init(GHashTable **fragment_table);
/*
+ * Initialize a reassembled-packet table.
+ */
+void reassembled_table_init(GHashTable **reassembled_table);
+
+/*
* Free up all space allocated for fragment keys and data.
*/
void reassemble_init(void);
@@ -92,6 +97,38 @@ fragment_data *fragment_add_seq(tvbuff_t *tvb, int offset, packet_info *pinfo,
guint32 id, GHashTable *fragment_table, guint32 frag_number,
guint32 frag_data_len, gboolean more_frags);
+/*
+ * This function adds a new fragment to the fragment hash table.
+ * If this is the first fragment seen for this datagram, a new
+ * "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 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 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.
+ *
+ * This function assumes frag_number being a block sequence number.
+ * The bsn for the first block is 0.
+ */
+fragment_data *
+fragment_add_seq_check(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);
+
/* to specify how much to reassemble, for fragmentation where last fragment can not be
* identified by flags or such.
* note that for FD_BLOCKSEQUENCE tot_len is the index for the tail fragment.
@@ -129,5 +166,3 @@ fragment_get(packet_info *pinfo, guint32 id, GHashTable *fragment_table);
*/
unsigned char *
fragment_delete(packet_info *pinfo, guint32 id, GHashTable *fragment_table);
-
-