aboutsummaryrefslogtreecommitdiffstats
path: root/reassemble.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2003-04-20 11:36:16 +0000
committerGuy Harris <guy@alum.mit.edu>2003-04-20 11:36:16 +0000
commitd359286841fb9221400bcc64bf8bbcc88e3127fd (patch)
tree7ed0620519b78e1ad0b8f6a83d488e1dd856bb3f /reassemble.c
parent4af58d8967aecdaea73d618ea7d6310183e6ffd2 (diff)
Add a pointer to an hf_ value for a "reassembled_in" field (which can be
null) to the "fragment_items" structure, and don't pass that value into "process_reassembled_data()", just have it use the value in the "fragment_items" structure passed to it. Make "process_reassembled_data()" capable of handling reassembly done by "fragment_add_seq_check()", and use it in the ATP and 802.11 dissectors; give them "reassembled_in" fields. Make "process_reassembled_data()" handle only the case of a completed reassembly (fd_head != NULL) so that we can use it in those dissectors without gunking the code up too much. svn path=/trunk/; revision=7513
Diffstat (limited to 'reassemble.c')
-rw-r--r--reassemble.c89
1 files changed, 60 insertions, 29 deletions
diff --git a/reassemble.c b/reassemble.c
index a039ccb897..b15de7e4e3 100644
--- a/reassemble.c
+++ b/reassemble.c
@@ -1,7 +1,7 @@
/* reassemble.c
* Routines for {fragment,segment} reassembly
*
- * $Id: reassemble.c,v 1.36 2003/04/20 08:40:45 guy Exp $
+ * $Id: reassemble.c,v 1.37 2003/04/20 11:36:16 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -434,7 +434,8 @@ fragment_unhash(GHashTable *fragment_table, fragment_key *key)
/*
* This function adds fragment_data structure to a reassembled-packet
* hash table, using the frame numbers of each of the frames from
- * which it was reassembled as keys.
+ * which it was reassembled as keys, and sets the "reassembled_in"
+ * frame number.
*/
void
fragment_reassembled(fragment_data *fd_head, packet_info *pinfo,
@@ -442,10 +443,23 @@ fragment_reassembled(fragment_data *fd_head, packet_info *pinfo,
{
fragment_data *fd;
- for (fd = fd_head->next; fd != NULL; fd = fd->next){
- g_hash_table_insert(reassembled_table, (gpointer)fd->frame,
+ if (fd_head->next == NULL) {
+ /*
+ * This was not fragmented, so there's no fragment
+ * table; just hash it using the current frame number.
+ */
+ g_hash_table_insert(reassembled_table, (gpointer)pinfo->fd->num,
fd_head);
+ } else {
+ /*
+ * Hash it with the frame numbers for all the frames.
+ */
+ for (fd = fd_head->next; fd != NULL; fd = fd->next){
+ g_hash_table_insert(reassembled_table,
+ (gpointer)fd->frame, fd_head);
+ }
}
+ fd_head->reassembled_in = pinfo->fd->num;
}
/*
@@ -1353,43 +1367,60 @@ fragment_add_seq_next(tvbuff_t *tvb, int offset, packet_info *pinfo,
*/
tvbuff_t *
process_reassembled_data(tvbuff_t *tvb, packet_info *pinfo, char *name,
- fragment_data *fd_head, const fragment_items *frag_items,
- int hf_reassembled_in, gboolean *update_col_infop, proto_tree *tree)
+ fragment_data *fd_head, const fragment_items *fit,
+ gboolean *update_col_infop, proto_tree *tree)
{
tvbuff_t *next_tvb;
+ gboolean update_col_info;
- if (fd_head != NULL) {
- if (pinfo->fd->num == fd_head->reassembled_in) {
- /*
- * OK, we have the complete reassembled payload.
- * Allocate a new tvbuff, referring to the reassembled
- * payload.
- */
+ if (pinfo->fd->num == fd_head->reassembled_in) {
+ /*
+ * OK, we have the complete reassembled payload.
+ * Allocate a new tvbuff, referring to the reassembled
+ * payload.
+ */
+ if (fd_head->flags & FD_BLOCKSEQUENCE) {
next_tvb = tvb_new_real_data(fd_head->data,
- fd_head->datalen, fd_head->datalen);
+ fd_head->len, fd_head->len);
+ } else {
+ next_tvb = tvb_new_real_data(fd_head->data,
+ fd_head->datalen, fd_head->datalen);
+ }
- /*
- * Add the tvbuff to the list of tvbuffs to which
- * the tvbuff we were handed refers, so it'll get
- * cleaned up when that tvbuff is cleaned up.
- */
- tvb_set_child_real_data_tvbuff(tvb, next_tvb);
+ /*
+ * Add the tvbuff to the list of tvbuffs to which
+ * the tvbuff we were handed refers, so it'll get
+ * cleaned up when that tvbuff is cleaned up.
+ */
+ tvb_set_child_real_data_tvbuff(tvb, next_tvb);
- /* Add the defragmented data to the data source list. */
- add_new_data_source(pinfo, next_tvb, name);
+ /* Add the defragmented data to the data source list. */
+ add_new_data_source(pinfo, next_tvb, name);
- /* show all fragments */
- *update_col_infop = !show_fragment_tree(fd_head,
- frag_items, tree, pinfo, next_tvb);
+ /* show all fragments */
+ if (fd_head->flags & FD_BLOCKSEQUENCE) {
+ update_col_info = !show_fragment_seq_tree(fd_head,
+ fit, tree, pinfo, next_tvb);
} else {
- /* We don't have the complete reassembled payload. */
- next_tvb = NULL;
- proto_tree_add_uint(tree, hf_reassembled_in, tvb, 0, 0,
- fd_head->reassembled_in);
+ update_col_info = !show_fragment_tree(fd_head,
+ fit, tree, pinfo, next_tvb);
}
+ if (update_col_infop != NULL)
+ *update_col_infop = update_col_info;
} else {
/* We don't have the complete reassembled payload. */
next_tvb = NULL;
+
+ /*
+ * If there's a field to use for the number of
+ * the frame in which the packet was reassembled,
+ * add it to the protocol tree.
+ */
+ if (fit->hf_reassembled_in != NULL) {
+ proto_tree_add_uint(tree,
+ *(fit->hf_reassembled_in), tvb,
+ 0, 0, fd_head->reassembled_in);
+ }
}
return next_tvb;
}