diff options
author | Evan Huus <eapache@gmail.com> | 2013-09-07 18:20:52 +0000 |
---|---|---|
committer | Evan Huus <eapache@gmail.com> | 2013-09-07 18:20:52 +0000 |
commit | 9fd46c37a89dce1de754087bbc1154c5593108b0 (patch) | |
tree | b0fcc2a31e3345178e2cab84bb08d448bb251749 | |
parent | 6a4364bb40a1b2c6a164d31d7ef9de6321a940ba (diff) |
- no need for a doubly-linked list of TVBs, single is simpler
- support merging chains in tvb_add_to_chain
- when we have an old reassembled TVB, just merge the chains rather than
freeing it (we may still need it as it may already be a data source)
- modelines
Fixes https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9027
#BACKPORT, but it's gonna be messy...
svn path=/trunk/; revision=51825
-rw-r--r-- | epan/reassemble.c | 4 | ||||
-rw-r--r-- | epan/tvbuff-int.h | 1 | ||||
-rw-r--r-- | epan/tvbuff.c | 32 |
3 files changed, 25 insertions, 12 deletions
diff --git a/epan/reassemble.c b/epan/reassemble.c index 954f04d781..65912ffce0 100644 --- a/epan/reassemble.c +++ b/epan/reassemble.c @@ -30,6 +30,8 @@ #include <epan/reassemble.h> +#include <epan/tvbuff-int.h> + /* * Functions for reassembly tables where the endpoint addresses, and a * fragment ID, are used as the key. @@ -1183,7 +1185,7 @@ fragment_add_work(fragment_head *fd_head, tvbuff_t *tvb, const int offset, } if (old_tvb_data) - tvb_free(old_tvb_data); + tvb_add_to_chain(tvb, old_tvb_data); /* mark this packet as defragmented. allows us to skip any trailing fragments */ fd_head->flags |= FD_DEFRAGMENTED; diff --git a/epan/tvbuff-int.h b/epan/tvbuff-int.h index e57d176528..fcac4cf48b 100644 --- a/epan/tvbuff-int.h +++ b/epan/tvbuff-int.h @@ -49,7 +49,6 @@ struct tvb_ops { struct tvbuff { /* Doubly linked list pointers */ tvbuff_t *next; - tvbuff_t *previous; /* Record-keeping */ const struct tvb_ops *ops; diff --git a/epan/tvbuff.c b/epan/tvbuff.c index 99a51b9863..e3e35e0dc6 100644 --- a/epan/tvbuff.c +++ b/epan/tvbuff.c @@ -64,7 +64,6 @@ tvb_new(const struct tvb_ops *ops) tvb = (tvbuff_t *) g_slice_alloc(size); - tvb->previous = NULL; tvb->next = NULL; tvb->ops = ops; tvb->initialized = FALSE; @@ -109,10 +108,8 @@ tvb_free_chain(tvbuff_t *tvb) { tvbuff_t *next_tvb; DISSECTOR_ASSERT(tvb); - DISSECTOR_ASSERT_HINT(tvb->previous==NULL, "tvb_free_chain(): tvb must be initial tvb in chain"); while (tvb) { next_tvb=tvb->next; - DISSECTOR_ASSERT_HINT((next_tvb==NULL) || (tvb==next_tvb->previous), "tvb_free_chain(): corrupt tvb chain ?"); tvb_free_internal(tvb); tvb = next_tvb; } @@ -130,15 +127,18 @@ tvb_new_chain(tvbuff_t *parent, tvbuff_t *backing) void tvb_add_to_chain(tvbuff_t *parent, tvbuff_t *child) { + tvbuff_t *tmp = child; + DISSECTOR_ASSERT(parent); DISSECTOR_ASSERT(child); - DISSECTOR_ASSERT(!child->next); - DISSECTOR_ASSERT(!child->previous); - child->next = parent->next; - child->previous = parent; - if (parent->next) - parent->next->previous = child; - parent->next = child; + + while (child) { + tmp = child; + child = child->next; + + tmp->next = parent->next; + parent->next = tmp; + } } /* @@ -3261,3 +3261,15 @@ tvb_get_ds_tvb(tvbuff_t *tvb) return(tvb->ds_tvb); } +/* + * Editor modelines - http://www.wireshark.org/tools/modelines.html + * + * Local variables: + * c-basic-offset: 8 + * tab-width: 8 + * indent-tabs-mode: t + * End: + * + * vi: set shiftwidth=8 tabstop=8 noexpandtab: + * :indentSize=8:tabSize=8:noTabs=false: + */ |