aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--asn1/t38/packet-t38-template.c15
-rw-r--r--epan/dissectors/packet-ber.c2
-rw-r--r--epan/dissectors/packet-dcerpc.c8
-rw-r--r--epan/dissectors/packet-dcp-etsi.c2
-rw-r--r--epan/dissectors/packet-eap.c4
-rw-r--r--epan/dissectors/packet-fc.c4
-rw-r--r--epan/dissectors/packet-gssapi.c4
-rw-r--r--epan/dissectors/packet-iax2.c2
-rw-r--r--epan/dissectors/packet-mime-encap.c6
-rw-r--r--epan/dissectors/packet-mp2t.c2
-rw-r--r--epan/dissectors/packet-mq.c2
-rw-r--r--epan/dissectors/packet-ncp2222.inc3
-rw-r--r--epan/dissectors/packet-ndps.c3
-rw-r--r--epan/dissectors/packet-netbios.c3
-rw-r--r--epan/dissectors/packet-ppi.c7
-rw-r--r--epan/dissectors/packet-q931.c2
-rw-r--r--epan/dissectors/packet-rpc.c3
-rw-r--r--epan/dissectors/packet-smb-pipe.c6
-rw-r--r--epan/dissectors/packet-smb.c9
-rw-r--r--epan/dissectors/packet-sna.c3
-rw-r--r--epan/dissectors/packet-ssl.c4
-rw-r--r--epan/dissectors/packet-t38.c21
-rw-r--r--epan/dissectors/packet-tcp.c6
-rw-r--r--epan/dissectors/packet-x25.c4
-rw-r--r--epan/reassemble.c137
-rw-r--r--epan/reassemble.h13
-rw-r--r--epan/reassemble_test.c182
-rw-r--r--epan/tvbuff-int.h2
-rw-r--r--epan/tvbuff.c9
-rw-r--r--epan/tvbuff.h2
-rw-r--r--epan/tvbuff_subset.c6
31 files changed, 235 insertions, 241 deletions
diff --git a/asn1/t38/packet-t38-template.c b/asn1/t38/packet-t38-template.c
index 84f130b111..943a5fab57 100644
--- a/asn1/t38/packet-t38-template.c
+++ b/asn1/t38/packet-t38-template.c
@@ -299,6 +299,7 @@ force_reassemble_seq(reassembly_table *table, packet_info *pinfo, guint32 id)
fragment_data *fd_i;
fragment_data *last_fd;
guint32 dfpos, size, packet_lost, burst_lost, seq_num;
+ char *data;
fd_head = fragment_get(table, pinfo, id, NULL);
@@ -341,7 +342,9 @@ force_reassemble_seq(reassembly_table *table, packet_info *pinfo, guint32 id)
}
last_fd=fd_i;
}
- fd_head->data = (char *)g_malloc(size);
+
+ data = g_malloc(size);
+ fd_head->tvb_data = tvb_new_real_data(data, size, size);
fd_head->len = size; /* record size for caller */
/* add all data fragments */
@@ -350,14 +353,14 @@ force_reassemble_seq(reassembly_table *table, packet_info *pinfo, guint32 id)
for (fd_i=fd_head->next;fd_i && fd_i->len + dfpos <= size;fd_i=fd_i->next) {
if (fd_i->len) {
if(!last_fd || last_fd->offset!=fd_i->offset){
- memcpy(fd_head->data+dfpos,fd_i->data,fd_i->len);
+ memcpy(data+dfpos,tvb_get_ptr(fd_i->tvb_data,0,fd_i->len),fd_i->len);
dfpos += fd_i->len;
} else {
/* duplicate/retransmission/overlap */
fd_i->flags |= FD_OVERLAP;
fd_head->flags |= FD_OVERLAP;
if( (last_fd->len!=fd_i->datalen)
- || memcmp(last_fd->data, fd_i->data, last_fd->len) ){
+ || tvb_memeql(last_fd->tvb_data, 0, tvb_get_ptr(fd_i->tvb_data, 0, last_fd->len), last_fd->len) ){
fd_i->flags |= FD_OVERLAPCONFLICT;
fd_head->flags |= FD_OVERLAPCONFLICT;
}
@@ -368,9 +371,9 @@ force_reassemble_seq(reassembly_table *table, packet_info *pinfo, guint32 id)
/* we have defragmented the pdu, now free all fragments*/
for (fd_i=fd_head->next;fd_i;fd_i=fd_i->next) {
- if(fd_i->data){
- g_free(fd_i->data);
- fd_i->data=NULL;
+ if(fd_i->tvb_data){
+ tvb_free(fd_i->tvb_data);
+ fd_i->tvb_data=NULL;
}
}
diff --git a/epan/dissectors/packet-ber.c b/epan/dissectors/packet-ber.c
index b2898e26c4..f6b5f11413 100644
--- a/epan/dissectors/packet-ber.c
+++ b/epan/dissectors/packet-ber.c
@@ -1423,7 +1423,7 @@ reassemble_octet_string(asn1_ctx_t *actx, proto_tree *tree, gint hf_id, tvbuff_t
proto_tree *next_tree;
proto_item *frag_tree_item;
- reassembled_tvb = tvb_new_child_real_data(next_tvb, fd_head->data, fd_head->len, fd_head->len);
+ reassembled_tvb = tvb_new_chain(next_tvb, fd_head->tvb_data);
actx->created_item = proto_tree_add_item(tree, hf_id, reassembled_tvb, 0, -1, ENC_BIG_ENDIAN);
next_tree = proto_item_add_subtree (actx->created_item, ett_ber_reassembled_octet_string);
diff --git a/epan/dissectors/packet-dcerpc.c b/epan/dissectors/packet-dcerpc.c
index 24106f709d..f7f5cf192e 100644
--- a/epan/dissectors/packet-dcerpc.c
+++ b/epan/dissectors/packet-dcerpc.c
@@ -3434,8 +3434,8 @@ end_cn_stub:
tvbuff_t *next_tvb;
proto_item *frag_tree_item;
- next_tvb = tvb_new_child_real_data((decrypted_tvb)?decrypted_tvb:payload_tvb,
- fd_head->data, fd_head->len, fd_head->len);
+ next_tvb = tvb_new_chain((decrypted_tvb)?decrypted_tvb:payload_tvb,
+ fd_head->tvb_data);
add_new_data_source(pinfo, next_tvb, "Reassembled DCE/RPC");
show_fragment_tree(fd_head, &dcerpc_frag_items,
@@ -4069,7 +4069,7 @@ dissect_dcerpc_cn_fault(tvbuff_t *tvb, gint offset, packet_info *pinfo,
tvbuff_t *next_tvb;
proto_item *frag_tree_item;
- next_tvb = tvb_new_child_real_data(tvb, fd_head->data, fd_head->len, fd_head->len);
+ next_tvb = tvb_new_chain(tvb, fd_head->tvb_data);
add_new_data_source(pinfo, next_tvb, "Reassembled DCE/RPC");
show_fragment_tree(fd_head, &dcerpc_frag_items,
dcerpc_tree, pinfo, next_tvb, &frag_tree_item);
@@ -5063,7 +5063,7 @@ dissect_dcerpc_dg_stub(tvbuff_t *tvb, int offset, packet_info *pinfo,
/* We completed reassembly... */
if (pinfo->fd->num == fd_head->reassembled_in) {
/* ...and this is the reassembled RPC PDU */
- next_tvb = tvb_new_child_real_data(tvb, fd_head->data, fd_head->len, fd_head->len);
+ next_tvb = tvb_new_chain(tvb, fd_head->tvb_data);
add_new_data_source(pinfo, next_tvb, "Reassembled DCE/RPC");
show_fragment_seq_tree(fd_head, &dcerpc_frag_items,
tree, pinfo, next_tvb, &pi);
diff --git a/epan/dissectors/packet-dcp-etsi.c b/epan/dissectors/packet-dcp-etsi.c
index a344c5a6e4..1a35ef58c9 100644
--- a/epan/dissectors/packet-dcp-etsi.c
+++ b/epan/dissectors/packet-dcp-etsi.c
@@ -293,7 +293,7 @@ dissect_pft_fec_detailed(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree,
/* make a list of the findex (offset) numbers of the fragments we have */
fd = fragment_get(&dcp_reassembly_table, pinfo, seq, NULL);
for (fd_head = fd; fd_head != NULL && fragments < fcount; fd_head = fd_head->next) {
- if(fd_head->data) {
+ if(fd_head->tvb_data) {
got[fragments++] = fd_head->offset; /* this is the findex of the fragment */
}
}
diff --git a/epan/dissectors/packet-eap.c b/epan/dissectors/packet-eap.c
index 09f6975461..2261b26117 100644
--- a/epan/dissectors/packet-eap.c
+++ b/epan/dissectors/packet-eap.c
@@ -1016,9 +1016,7 @@ dissect_eap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
proto_item *frag_tree_item;
- next_tvb = tvb_new_child_real_data(tvb, fd_head->data,
- fd_head->len,
- fd_head->len);
+ next_tvb = tvb_new_chain(tvb, fd_head->tvb_data);
add_new_data_source(pinfo, next_tvb, "Reassembled EAP-TLS");
show_fragment_seq_tree(fd_head, &eap_tls_frag_items,
diff --git a/epan/dissectors/packet-fc.c b/epan/dissectors/packet-fc.c
index 828d739201..7cde39d6d4 100644
--- a/epan/dissectors/packet-fc.c
+++ b/epan/dissectors/packet-fc.c
@@ -1171,9 +1171,7 @@ dissect_fc_helper (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean
!is_lastframe_inseq);
if (fcfrag_head) {
- next_tvb = tvb_new_child_real_data(tvb, fcfrag_head->data,
- fcfrag_head->datalen,
- fcfrag_head->datalen);
+ next_tvb = tvb_new_chain(tvb, fcfrag_head->tvb_data);
/* Add the defragmented data to the data source list. */
add_new_data_source(pinfo, next_tvb, "Reassembled FC");
diff --git a/epan/dissectors/packet-gssapi.c b/epan/dissectors/packet-gssapi.c
index d42fd3ab62..7e2fb4f4ad 100644
--- a/epan/dissectors/packet-gssapi.c
+++ b/epan/dissectors/packet-gssapi.c
@@ -271,7 +271,7 @@ dissect_gssapi_work(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
gss_info->do_reassembly=FALSE;
fi->reassembled_in=pinfo->fd->num;
- gss_tvb=tvb_new_child_real_data(tvb, fd_head->data, fd_head->datalen, fd_head->datalen);
+ gss_tvb=tvb_new_chain(tvb, fd_head->tvb_data);
add_new_data_source(pinfo, gss_tvb, "Reassembled GSSAPI");
}
/* We have seen this packet before.
@@ -286,7 +286,7 @@ dissect_gssapi_work(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
if(fd_head && (fd_head->flags&FD_DEFRAGMENTED)){
if(pinfo->fd->num==fi->reassembled_in){
proto_item *frag_tree_item;
- gss_tvb=tvb_new_child_real_data(tvb, fd_head->data, fd_head->datalen, fd_head->datalen);
+ gss_tvb=tvb_new_chain(tvb, fd_head->tvb_data);
add_new_data_source(pinfo, gss_tvb, "Reassembled GSSAPI");
show_fragment_tree(fd_head, &gssapi_frag_items, tree, pinfo, tvb, &frag_tree_item);
} else {
diff --git a/epan/dissectors/packet-iax2.c b/epan/dissectors/packet-iax2.c
index 89827b765b..51b94feee5 100644
--- a/epan/dissectors/packet-iax2.c
+++ b/epan/dissectors/packet-iax2.c
@@ -2202,7 +2202,7 @@ static void desegment_iax(tvbuff_t *tvb, packet_info *pinfo, proto_tree *iax2_tr
if (fd_head && (pinfo->fd->num == fd_head->reassembled_in)) {
gint32 old_len;
- tvbuff_t *next_tvb = tvb_new_child_real_data(tvb, fd_head->data, fd_head->datalen, fd_head->datalen);
+ tvbuff_t *next_tvb = tvb_new_chain(tvb, fd_head->tvb_data);
add_new_data_source(pinfo, next_tvb, "Reassembled IAX2");
process_iax_pdu(next_tvb, pinfo, tree, video, iax_packet);
diff --git a/epan/dissectors/packet-mime-encap.c b/epan/dissectors/packet-mime-encap.c
index 46000e440f..4ea57a55cb 100644
--- a/epan/dissectors/packet-mime-encap.c
+++ b/epan/dissectors/packet-mime-encap.c
@@ -89,12 +89,8 @@ dissect_mime_encap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
* on it, which would append to whole_tvb chain and would be freed only in mime_encap_init.
*
* So we create some tvb which pass all calls to whole_tvb, but chain with tvb (which is freed in dissection cleanup)
- *
- * BIG FAT NOTE: YOU NORMALLY DON'T WANT TO DO IT, SO DON'T COPY THIS CODE!!!!!111
*/
- tvbuff_t *tmp_tvb = tvb_new_temporary(whole_tvb);
-
- tvb_add_to_chain(tvb, tmp_tvb);
+ tvbuff_t *tmp_tvb = tvb_new_chain(tvb, whole_tvb);
proto_item_append_text(item, " (Final)");
diff --git a/epan/dissectors/packet-mp2t.c b/epan/dissectors/packet-mp2t.c
index 7dc0dc519d..3be3c959e6 100644
--- a/epan/dissectors/packet-mp2t.c
+++ b/epan/dissectors/packet-mp2t.c
@@ -486,7 +486,7 @@ mp2t_get_packet_length(tvbuff_t *tvb, guint offset, packet_info *pinfo,
} else {
/* Create a composite tvb out of the two */
- frag_tvb = tvb_new_real_data(frag->data, frag->len, frag->len);
+ frag_tvb = tvb_new_proxy(frag->tvb_data);
len_tvb = tvb_new_composite();
tvb_composite_append(len_tvb, frag_tvb);
diff --git a/epan/dissectors/packet-mq.c b/epan/dissectors/packet-mq.c
index 2067312f39..0e6bebefb8 100644
--- a/epan/dissectors/packet-mq.c
+++ b/epan/dissectors/packet-mq.c
@@ -2397,7 +2397,7 @@ reassemble_mq(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
if (fd_head->next != NULL)
{
/* 2 or more fragments */
- next_tvb = tvb_new_child_real_data(tvb, fd_head->data, fd_head->len, fd_head->len);
+ next_tvb = tvb_new_chain(tvb, fd_head->tvb_data);
add_new_data_source(pinfo, next_tvb, "Reassembled MQ");
}
else
diff --git a/epan/dissectors/packet-ncp2222.inc b/epan/dissectors/packet-ncp2222.inc
index 0396134023..478dd8e491 100644
--- a/epan/dissectors/packet-ncp2222.inc
+++ b/epan/dissectors/packet-ncp2222.inc
@@ -7271,8 +7271,7 @@ nds_defrag(tvbuff_t *tvb, packet_info *pinfo, guint32 nw_connection, guint8 sequ
/* Is this the last fragment? nds_frag will indicate */
if (fd_head->next != NULL && !request_value->nds_frag)
{
- frag_tvb = tvb_new_child_real_data(tvb, fd_head->data,
- fd_head->len, fd_head->len);
+ frag_tvb = tvb_new_chain(tvb, fd_head->tvb_data);
add_new_data_source(pinfo,
frag_tvb,
"Reassembled NDS");
diff --git a/epan/dissectors/packet-ndps.c b/epan/dissectors/packet-ndps.c
index 7c404bf7ae..8dc1f83855 100644
--- a/epan/dissectors/packet-ndps.c
+++ b/epan/dissectors/packet-ndps.c
@@ -4401,8 +4401,7 @@ ndps_defrag(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
proto_item *frag_tree_item;
- next_tvb = tvb_new_child_real_data(tvb, fd_head->data,
- fd_head->len, fd_head->len);
+ next_tvb = tvb_new_chain(tvb, fd_head->tvb_data);
add_new_data_source(pinfo,
next_tvb,
"Reassembled NDPS");
diff --git a/epan/dissectors/packet-netbios.c b/epan/dissectors/packet-netbios.c
index e774e7c91f..b3bdbeaca0 100644
--- a/epan/dissectors/packet-netbios.c
+++ b/epan/dissectors/packet-netbios.c
@@ -1170,8 +1170,7 @@ dissect_netbios(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
len, command == NB_DATA_FIRST_MIDDLE);
if (fd_head != NULL) {
if (fd_head->next != NULL) {
- next_tvb = tvb_new_child_real_data(tvb, fd_head->data,
- fd_head->len, fd_head->len);
+ next_tvb = tvb_new_chain(tvb, fd_head->tvb_data);
add_new_data_source(pinfo,
next_tvb,
"Reassembled NetBIOS");
diff --git a/epan/dissectors/packet-ppi.c b/epan/dissectors/packet-ppi.c
index 7faf954efc..31bac84b1b 100644
--- a/epan/dissectors/packet-ppi.c
+++ b/epan/dissectors/packet-ppi.c
@@ -936,7 +936,7 @@ dissect_ppi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
seg_tree = proto_item_add_subtree(ti, ett_ampdu_segments);
while (ft_fdh) {
- if (ft_fdh->data && ft_fdh->len) {
+ if (ft_fdh->tvb_data && ft_fdh->len) {
last_frame = ft_fdh->frame;
if (!first_mpdu)
proto_item_append_text(ti, ",");
@@ -966,12 +966,11 @@ dissect_ppi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
}
while (fd_head) {
- if (fd_head->data && fd_head->len) {
+ if (fd_head->tvb_data && fd_head->len) {
mpdu_count++;
mpdu_str = ep_strdup_printf("MPDU #%d", mpdu_count);
- next_tvb = tvb_new_child_real_data(tvb, fd_head->data,
- fd_head->len, fd_head->len);
+ next_tvb = tvb_new_chain(tvb, fd_head->tvb_data);
add_new_data_source(pinfo, next_tvb, mpdu_str);
if (agg_tree) {
diff --git a/epan/dissectors/packet-q931.c b/epan/dissectors/packet-q931.c
index 6389c367a0..37b1154317 100644
--- a/epan/dissectors/packet-q931.c
+++ b/epan/dissectors/packet-q931.c
@@ -2676,7 +2676,7 @@ dissect_q931_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
if (fd_head) {
if (pinfo->fd->num == fd_head->reassembled_in) { /* last fragment */
if (fd_head->next != NULL) { /* 2 or more segments */
- next_tvb = tvb_new_child_real_data(tvb, fd_head->data, fd_head->len, fd_head->len);
+ next_tvb = tvb_new_chain(tvb, fd_head->tvb_data);
add_new_data_source(pinfo, next_tvb, "Reassembled Q.931 IEs");
/* Show all fragments. */
if (tree) {
diff --git a/epan/dissectors/packet-rpc.c b/epan/dissectors/packet-rpc.c
index 7a3e333b77..ecdef223b6 100644
--- a/epan/dissectors/packet-rpc.c
+++ b/epan/dissectors/packet-rpc.c
@@ -3430,8 +3430,7 @@ dissect_rpc_fragment(tvbuff_t *tvb, int offset, packet_info *pinfo,
* Create a new TVB structure for
* defragmented data.
*/
- rec_tvb = tvb_new_child_real_data(tvb, ipfd_head->data,
- ipfd_head->datalen, ipfd_head->datalen);
+ rec_tvb = tvb_new_chain(tvb, ipfd_head->tvb_data);
/*
* Add defragmented data to the data source list.
diff --git a/epan/dissectors/packet-smb-pipe.c b/epan/dissectors/packet-smb-pipe.c
index faeade271a..f9fffcac88 100644
--- a/epan/dissectors/packet-smb-pipe.c
+++ b/epan/dissectors/packet-smb-pipe.c
@@ -3381,8 +3381,7 @@ dissect_pipe_dcerpc(tvbuff_t *d_tvb, packet_info *pinfo, proto_tree *parent_tree
/* if we completed reassembly */
if(fd_head){
- new_tvb = tvb_new_child_real_data(d_tvb, fd_head->data,
- fd_head->datalen, fd_head->datalen);
+ new_tvb = tvb_new_chain(d_tvb, fd_head->tvb_data);
add_new_data_source(pinfo, new_tvb,
"DCERPC over SMB");
pinfo->fragmented=FALSE;
@@ -3431,8 +3430,7 @@ dissect_pipe_dcerpc(tvbuff_t *d_tvb, packet_info *pinfo, proto_tree *parent_tree
/* display the reassembled pdu */
- new_tvb = tvb_new_child_real_data(d_tvb, fd_head->data,
- fd_head->datalen, fd_head->datalen);
+ new_tvb = tvb_new_chain(d_tvb, fd_head->tvb_data);
add_new_data_source(pinfo, new_tvb,
"DCERPC over SMB");
pinfo->fragmented=FALSE;
diff --git a/epan/dissectors/packet-smb.c b/epan/dissectors/packet-smb.c
index 6b9b6cc8ab..6850b620dd 100644
--- a/epan/dissectors/packet-smb.c
+++ b/epan/dissectors/packet-smb.c
@@ -9147,8 +9147,7 @@ dissect_nt_transaction_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tr
if (r_fd) {
proto_item *frag_tree_item;
- pd_tvb = tvb_new_child_real_data(tvb, r_fd->data, r_fd->datalen,
- r_fd->datalen);
+ pd_tvb = tvb_new_chain(tvb, r_fd->tvb_data);
add_new_data_source(pinfo, pd_tvb, "Reassembled SMB");
show_fragment_tree(r_fd, &smb_frag_items, tree, pinfo, pd_tvb, &frag_tree_item);
@@ -9698,8 +9697,7 @@ dissect_nt_transaction_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *t
if (r_fd) {
proto_item *frag_tree_item;
- pd_tvb = tvb_new_child_real_data(tvb, r_fd->data, r_fd->datalen,
- r_fd->datalen);
+ pd_tvb = tvb_new_chain(tvb, r_fd->tvb_data);
add_new_data_source(pinfo, pd_tvb, "Reassembled SMB");
show_fragment_tree(r_fd, &smb_frag_items, tree, pinfo, pd_tvb, &frag_tree_item);
@@ -16691,8 +16689,7 @@ dissect_transaction_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree
if (r_fd) {
proto_item *frag_tree_item;
- pd_tvb = tvb_new_child_real_data(tvb, r_fd->data, r_fd->datalen,
- r_fd->datalen);
+ pd_tvb = tvb_new_chain(tvb, r_fd->tvb_data);
add_new_data_source(pinfo, pd_tvb, "Reassembled SMB");
show_fragment_tree(r_fd, &smb_frag_items, tree, pinfo, pd_tvb, &frag_tree_item);
}
diff --git a/epan/dissectors/packet-sna.c b/epan/dissectors/packet-sna.c
index f73fc48e5a..23cc6a52bb 100644
--- a/epan/dissectors/packet-sna.c
+++ b/epan/dissectors/packet-sna.c
@@ -1701,8 +1701,7 @@ defragment_by_sequence(packet_info *pinfo, tvbuff_t *tvb, int offset, int mpf,
if (fd_head != NULL) {
/* We have the complete reassembled payload. */
- rh_tvb = tvb_new_child_real_data(tvb, fd_head->data,
- fd_head->len, fd_head->len);
+ rh_tvb = tvb_new_chain(tvb, fd_head->tvb_data);
/* Add the defragmented data to the data
* source list. */
diff --git a/epan/dissectors/packet-ssl.c b/epan/dissectors/packet-ssl.c
index 8f38d451b9..0418f398e3 100644
--- a/epan/dissectors/packet-ssl.c
+++ b/epan/dissectors/packet-ssl.c
@@ -1129,9 +1129,7 @@ again:
int old_len;
/* create a new TVB structure for desegmented data */
- next_tvb = tvb_new_child_real_data(tvb, ipfd_head->data,
- ipfd_head->datalen,
- ipfd_head->datalen);
+ next_tvb = tvb_new_chain(tvb, ipfd_head->tvb_data);
/* add desegmented data to the data source list */
add_new_data_source(pinfo, next_tvb, "Reassembled SSL");
diff --git a/epan/dissectors/packet-t38.c b/epan/dissectors/packet-t38.c
index 1259313480..63be9bee96 100644
--- a/epan/dissectors/packet-t38.c
+++ b/epan/dissectors/packet-t38.c
@@ -344,6 +344,7 @@ force_reassemble_seq(reassembly_table *table, packet_info *pinfo, guint32 id)
fragment_data *fd_i;
fragment_data *last_fd;
guint32 dfpos, size, packet_lost, burst_lost, seq_num;
+ char *data;
fd_head = fragment_get(table, pinfo, id, NULL);
@@ -386,7 +387,9 @@ force_reassemble_seq(reassembly_table *table, packet_info *pinfo, guint32 id)
}
last_fd=fd_i;
}
- fd_head->data = (char *)g_malloc(size);
+
+ data = g_malloc(size);
+ fd_head->tvb_data = tvb_new_real_data(data, size, size);
fd_head->len = size; /* record size for caller */
/* add all data fragments */
@@ -395,14 +398,14 @@ force_reassemble_seq(reassembly_table *table, packet_info *pinfo, guint32 id)
for (fd_i=fd_head->next;fd_i && fd_i->len + dfpos <= size;fd_i=fd_i->next) {
if (fd_i->len) {
if(!last_fd || last_fd->offset!=fd_i->offset){
- memcpy(fd_head->data+dfpos,fd_i->data,fd_i->len);
+ memcpy(data+dfpos,tvb_get_ptr(fd_i->tvb_data,0,fd_i->len),fd_i->len);
dfpos += fd_i->len;
} else {
/* duplicate/retransmission/overlap */
fd_i->flags |= FD_OVERLAP;
fd_head->flags |= FD_OVERLAP;
if( (last_fd->len!=fd_i->datalen)
- || memcmp(last_fd->data, fd_i->data, last_fd->len) ){
+ || tvb_memeql(last_fd->tvb_data, 0, tvb_get_ptr(fd_i->tvb_data, 0, last_fd->len), last_fd->len) ){
fd_i->flags |= FD_OVERLAPCONFLICT;
fd_head->flags |= FD_OVERLAPCONFLICT;
}
@@ -413,9 +416,9 @@ force_reassemble_seq(reassembly_table *table, packet_info *pinfo, guint32 id)
/* we have defragmented the pdu, now free all fragments*/
for (fd_i=fd_head->next;fd_i;fd_i=fd_i->next) {
- if(fd_i->data){
- g_free(fd_i->data);
- fd_i->data=NULL;
+ if(fd_i->tvb_data){
+ tvb_free(fd_i->tvb_data);
+ fd_i->tvb_data=NULL;
}
}
@@ -977,7 +980,7 @@ static int dissect_UDPTLPacket_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, pr
/*--- End of included file: packet-t38-fn.c ---*/
-#line 391 "../../asn1/t38/packet-t38-template.c"
+#line 394 "../../asn1/t38/packet-t38-template.c"
/* initialize the tap t38_info and the conversation */
static void
@@ -1333,7 +1336,7 @@ proto_register_t38(void)
"OCTET_STRING", HFILL }},
/*--- End of included file: packet-t38-hfarr.c ---*/
-#line 670 "../../asn1/t38/packet-t38-template.c"
+#line 673 "../../asn1/t38/packet-t38-template.c"
{ &hf_t38_setup,
{ "Stream setup", "t38.setup", FT_STRING, BASE_NONE,
NULL, 0x0, "Stream setup, method and frame number", HFILL }},
@@ -1394,7 +1397,7 @@ proto_register_t38(void)
&ett_t38_T_fec_data,
/*--- End of included file: packet-t38-ettarr.c ---*/
-#line 717 "../../asn1/t38/packet-t38-template.c"
+#line 720 "../../asn1/t38/packet-t38-template.c"
&ett_t38_setup,
&ett_data_fragment,
&ett_data_fragments
diff --git a/epan/dissectors/packet-tcp.c b/epan/dissectors/packet-tcp.c
index 2f4b958641..74676a6918 100644
--- a/epan/dissectors/packet-tcp.c
+++ b/epan/dissectors/packet-tcp.c
@@ -1792,9 +1792,7 @@ again:
int old_len;
/* create a new TVB structure for desegmented data */
- next_tvb = tvb_new_child_real_data(tvb, ipfd_head->data,
- ipfd_head->datalen,
- ipfd_head->datalen);
+ next_tvb = tvb_new_chain(tvb, ipfd_head->tvb_data);
/* add desegmented data to the data source list */
add_new_data_source(pinfo, next_tvb, "Reassembled TCP");
@@ -4673,7 +4671,7 @@ dissect_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
/* create a new TVB structure for desegmented data
* datalen-1 to strip the dummy FIN byte off
*/
- next_tvb = tvb_new_child_real_data(tvb, ipfd_head->data, ipfd_head->datalen, ipfd_head->datalen);
+ next_tvb = tvb_new_chain(tvb, ipfd_head->tvb_data);
/* add desegmented data to the data source list */
add_new_data_source(pinfo, next_tvb, "Reassembled TCP");
diff --git a/epan/dissectors/packet-x25.c b/epan/dissectors/packet-x25.c
index 5bf75062db..0060674bd7 100644
--- a/epan/dissectors/packet-x25.c
+++ b/epan/dissectors/packet-x25.c
@@ -1959,9 +1959,7 @@ dissect_x25_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
proto_item *frag_tree_item;
/* This is the last packet */
- next_tvb = tvb_new_child_real_data(tvb, fd_head->data,
- fd_head->len,
- fd_head->len);
+ next_tvb = tvb_new_chain(tvb, fd_head->tvb_data);
add_new_data_source(pinfo, next_tvb, "Reassembled X.25");
if (x25_tree) {
show_fragment_seq_tree(fd_head,
diff --git a/epan/reassemble.c b/epan/reassemble.c
index 413fa8e385..98fd8b97c9 100644
--- a/epan/reassemble.c
+++ b/epan/reassemble.c
@@ -339,8 +339,8 @@ free_all_fragments(gpointer key_arg _U_, gpointer value, gpointer user_data _U_)
for (fd_head = (fragment_data *)value; fd_head != NULL; fd_head = tmp_fd) {
tmp_fd=fd_head->next;
- if(fd_head->data && !(fd_head->flags&FD_NOT_MALLOCED))
- g_free(fd_head->data);
+ if(fd_head->tvb_data && !(fd_head->flags&FD_SUBSET_TVB))
+ tvb_free(fd_head->tvb_data);
g_slice_free(fragment_data, fd_head);
}
@@ -383,8 +383,8 @@ free_all_reassembled_fragments(gpointer key_arg, gpointer value,
* free_fragments()
*/
if (fd_head->flags != FD_VISITED_FREE) {
- if (fd_head->flags & FD_NOT_MALLOCED)
- fd_head->data = NULL;
+ if (fd_head->flags & FD_SUBSET_TVB)
+ fd_head->tvb_data = NULL;
g_ptr_array_add(allocated_fragments, fd_head);
fd_head->flags = FD_VISITED_FREE;
}
@@ -400,7 +400,8 @@ free_fragments(gpointer data, gpointer user_data _U_)
{
fragment_data *fd_head = (fragment_data *) data;
- g_free(fd_head->data);
+ if (fd_head->tvb_data)
+ tvb_free(fd_head->tvb_data);
g_slice_free(fragment_data, fd_head);
}
@@ -568,14 +569,14 @@ insert_fd_head(reassembly_table *table, fragment_data *fd_head,
* Othervise the function will return NULL.
*
* So, if you call fragment_delete and it returns non-NULL, YOU are responsible to
- * g_free() that buffer.
+ * tvb_free() that buffer.
*/
-unsigned char *
+tvbuff_t *
fragment_delete(reassembly_table *table, const packet_info *pinfo,
const guint32 id, const void *data)
{
fragment_data *fd_head, *fd;
- unsigned char *fd_data=NULL;
+ tvbuff_t *fd_tvb_data=NULL;
gpointer key;
fd_head = lookup_fd_head(table, pinfo, id, data, &key);
@@ -584,21 +585,21 @@ fragment_delete(reassembly_table *table, const packet_info *pinfo,
return NULL;
}
- fd_data=fd_head->data;
+ fd_tvb_data=fd_head->tvb_data;
/* loop over all partial fragments and free any buffers */
for(fd=fd_head->next;fd;){
fragment_data *tmp_fd;
tmp_fd=fd->next;
- if( !(fd->flags&FD_NOT_MALLOCED) )
- g_free(fd->data);
+ if (fd->tvb_data && !(fd->flags & FD_SUBSET_TVB))
+ tvb_free(fd->tvb_data);
g_slice_free(fragment_data, fd);
fd=tmp_fd;
}
g_slice_free(fragment_data, fd_head);
g_hash_table_remove(table->fragment_table, key);
- return fd_data;
+ return fd_tvb_data;
}
/* This function is used to check if there is partial or completed reassembly state
@@ -862,7 +863,8 @@ fragment_add_work(fragment_data *fd_head, tvbuff_t *tvb, const int offset,
fragment_data *fd;
fragment_data *fd_i;
guint32 max, dfpos, fraglen;
- unsigned char *old_data;
+ tvbuff_t *old_tvb_data;
+ char *data;
/* create new fd describing this fragment */
fd = g_slice_new(fragment_data);
@@ -872,7 +874,7 @@ fragment_add_work(fragment_data *fd_head, tvbuff_t *tvb, const int offset,
fd->offset = frag_offset;
fd->fragment_nr_offset = 0; /* will only be used with sequence */
fd->len = frag_data_len;
- fd->data = NULL;
+ fd->tvb_data = NULL;
fd->error = NULL;
/*
@@ -896,9 +898,9 @@ fragment_add_work(fragment_data *fd_head, tvbuff_t *tvb, const int offset,
* point old fds to malloc'ed data.
*/
for(fd_i=fd_head->next; fd_i; fd_i=fd_i->next){
- if( !fd_i->data ) {
- fd_i->data = fd_head->data + fd_i->offset;
- fd_i->flags |= FD_NOT_MALLOCED;
+ if( !fd_i->tvb_data ) {
+ fd_i->tvb_data = tvb_new_subset_remaining(fd_head->tvb_data, fd_i->offset);
+ fd_i->flags |= FD_SUBSET_TVB;
}
fd_i->flags &= (~FD_TOOLONGFRAGMENT) & (~FD_MULTIPLETAILS);
}
@@ -995,7 +997,7 @@ fragment_add_work(fragment_data *fd_head, tvbuff_t *tvb, const int offset,
fd_head->flags |= FD_TOOLONGFRAGMENT;
}
/* make sure it doesn't conflict with previous data */
- else if ( memcmp(fd_head->data+fd->offset,
+ else if ( tvb_memeql(fd_head->tvb_data, fd->offset,
tvb_get_ptr(tvb,offset,fd->len),fd->len) ){
fd->flags |= FD_OVERLAPCONFLICT;
fd_head->flags |= FD_OVERLAPCONFLICT;
@@ -1012,8 +1014,7 @@ fragment_add_work(fragment_data *fd_head, tvbuff_t *tvb, const int offset,
* XXX - what if we didn't capture the entire fragment due
* to a too-short snapshot length?
*/
- fd->data = (unsigned char *)g_malloc(fd->len);
- tvb_memcpy(tvb, fd->data, offset, fd->len);
+ fd->tvb_data = tvb_clone_offset_len(tvb, offset, fd->len);
LINK_FRAG(fd_head,fd);
@@ -1056,8 +1057,10 @@ fragment_add_work(fragment_data *fd_head, tvbuff_t *tvb, const int offset,
* free all fragments
*/
/* store old data just in case */
- old_data=fd_head->data;
- fd_head->data = (unsigned char *)g_malloc(fd_head->datalen);
+ old_tvb_data=fd_head->tvb_data;
+ data = g_malloc(fd_head->datalen);
+ fd_head->tvb_data = tvb_new_real_data(data, fd_head->datalen, fd_head->datalen);
+ tvb_set_free_cb(fd_head->tvb_data, g_free);
/* add all data fragments */
for (dfpos=0,fd_i=fd_head;fd_i;fd_i=fd_i->next) {
@@ -1113,7 +1116,7 @@ fragment_add_work(fragment_data *fd_head, tvbuff_t *tvb, const int offset,
fd_head->error = "dfpos < offset";
} else if (dfpos - fd_i->offset > fd_i->len)
fd_head->error = "dfpos - offset > len";
- else if (!fd_head->data)
+ else if (!fd_head->tvb_data)
fd_head->error = "no data";
else {
fraglen = fd_i->len;
@@ -1137,12 +1140,14 @@ fragment_add_work(fragment_data *fd_head, tvbuff_t *tvb, const int offset,
fraglen = fd_head->datalen - fd_i->offset;
}
if (fd_i->offset < dfpos) {
+ guint32 cmp_len = MIN(fd_i->len,(dfpos-fd_i->offset));
+
fd_i->flags |= FD_OVERLAP;
fd_head->flags |= FD_OVERLAP;
- if ( memcmp(fd_head->data+fd_i->offset,
- fd_i->data,
- MIN(fd_i->len,(dfpos-fd_i->offset))
- ) ) {
+ if ( memcmp(data + fd_i->offset,
+ tvb_get_ptr(fd_i->tvb_data, 0, cmp_len),
+ cmp_len)
+ ) {
fd_i->flags |= FD_OVERLAPCONFLICT;
fd_head->flags |= FD_OVERLAPCONFLICT;
}
@@ -1153,8 +1158,8 @@ fragment_add_work(fragment_data *fd_head, tvbuff_t *tvb, const int offset,
*/
fd_head->error = "fraglen < dfpos - offset";
} else {
- memcpy(fd_head->data+dfpos,
- fd_i->data+(dfpos-fd_i->offset),
+ memcpy(data+dfpos,
+ tvb_get_ptr(fd_i->tvb_data, (dfpos-fd_i->offset), fraglen-(dfpos-fd_i->offset)),
fraglen-(dfpos-fd_i->offset));
dfpos=MAX(dfpos, (fd_i->offset + fraglen));
}
@@ -1165,15 +1170,18 @@ fragment_add_work(fragment_data *fd_head, tvbuff_t *tvb, const int offset,
fd_head->error = "offset + len < offset";
}
}
- if (fd_i->flags & FD_NOT_MALLOCED)
- fd_i->flags &= ~FD_NOT_MALLOCED;
- else
- g_free(fd_i->data);
- fd_i->data=NULL;
+
+ if (fd_i->flags & FD_SUBSET_TVB)
+ fd_i->flags &= ~FD_SUBSET_TVB;
+ else if (fd_i->tvb_data)
+ tvb_free(fd_i->tvb_data);
+
+ fd_i->tvb_data=NULL;
}
}
- g_free(old_data);
+ if (old_tvb_data)
+ tvb_free(old_tvb_data);
/* mark this packet as defragmented.
allows us to skip any trailing fragments */
fd_head->flags |= FD_DEFRAGMENTED;
@@ -1474,7 +1482,8 @@ fragment_defragment_and_free (fragment_data *fd_head, const packet_info *pinfo)
fragment_data *fd_i = NULL;
fragment_data *last_fd = NULL;
guint32 dfpos = 0, size = 0;
- void *old_data = NULL;
+ tvbuff_t *old_tvb_data = NULL;
+ char *data;
for(fd_i=fd_head->next;fd_i;fd_i=fd_i->next) {
if(!last_fd || last_fd->offset!=fd_i->offset){
@@ -1484,8 +1493,10 @@ fragment_defragment_and_free (fragment_data *fd_head, const packet_info *pinfo)
}
/* store old data in case the fd_i->data pointers refer to it */
- old_data=fd_head->data;
- fd_head->data = (unsigned char *)g_malloc(size);
+ old_tvb_data=fd_head->tvb_data;
+ data = g_malloc(size);
+ fd_head->tvb_data = tvb_new_real_data(data, size, size);
+ tvb_set_free_cb(fd_head->tvb_data, g_free);
fd_head->len = size; /* record size for caller */
/* add all data fragments */
@@ -1494,14 +1505,14 @@ fragment_defragment_and_free (fragment_data *fd_head, const packet_info *pinfo)
if (fd_i->len) {
if(!last_fd || last_fd->offset != fd_i->offset) {
/* First fragment or in-sequence fragment */
- memcpy(fd_head->data+dfpos, fd_i->data, fd_i->len);
+ memcpy(data+dfpos, tvb_get_ptr(fd_i->tvb_data, 0, fd_i->len), fd_i->len);
dfpos += fd_i->len;
} else {
/* duplicate/retransmission/overlap */
fd_i->flags |= FD_OVERLAP;
fd_head->flags |= FD_OVERLAP;
if(last_fd->len != fd_i->len
- || memcmp(last_fd->data, fd_i->data, last_fd->len) ) {
+ || tvb_memeql(last_fd->tvb_data, 0, tvb_get_ptr(fd_i->tvb_data, 0, last_fd->len), last_fd->len) ) {
fd_i->flags |= FD_OVERLAPCONFLICT;
fd_head->flags |= FD_OVERLAPCONFLICT;
}
@@ -1512,13 +1523,14 @@ fragment_defragment_and_free (fragment_data *fd_head, const packet_info *pinfo)
/* we have defragmented the pdu, now free all fragments*/
for (fd_i=fd_head->next;fd_i;fd_i=fd_i->next) {
- if( fd_i->flags & FD_NOT_MALLOCED )
- fd_i->flags &= ~FD_NOT_MALLOCED;
- else
- g_free(fd_i->data);
- fd_i->data=NULL;
+ if (fd_i->flags & FD_SUBSET_TVB)
+ fd_i->flags &= ~FD_SUBSET_TVB;
+ else if (fd_i->tvb_data)
+ tvb_free(fd_i->tvb_data);
+ fd_i->tvb_data=NULL;
}
- g_free(old_data);
+ if (old_tvb_data)
+ tvb_free(old_tvb_data);
/* mark this packet as defragmented.
* allows us to skip any trailing fragments.
@@ -1564,17 +1576,17 @@ fragment_add_seq_work(fragment_data *fd_head, tvbuff_t *tvb, const int offset,
guint32 lastdfpos = 0;
dfpos = 0;
for(fd_i=fd_head->next; fd_i; fd_i=fd_i->next){
- if( !fd_i->data ) {
+ if( !fd_i->tvb_data ) {
if( fd_i->flags & FD_OVERLAP ) {
/* this is a duplicate of the previous
* fragment. */
- fd_i->data = fd_head->data + lastdfpos;
+ fd_i->tvb_data = tvb_new_subset_remaining(fd_head->tvb_data, lastdfpos);
} else {
- fd_i->data = fd_head->data + dfpos;
+ fd_i->tvb_data = tvb_new_subset_remaining(fd_head->tvb_data, dfpos);
lastdfpos = dfpos;
dfpos += fd_i->len;
}
- fd_i->flags |= FD_NOT_MALLOCED;
+ fd_i->flags |= FD_SUBSET_TVB;
}
fd_i->flags &= (~FD_TOOLONGFRAGMENT) & (~FD_MULTIPLETAILS);
}
@@ -1592,7 +1604,7 @@ fragment_add_seq_work(fragment_data *fd_head, tvbuff_t *tvb, const int offset,
fd->frame = pinfo->fd->num;
fd->offset = frag_number_work;
fd->len = frag_data_len;
- fd->data = NULL;
+ fd->tvb_data = NULL;
fd->error = NULL;
if (!more_frags) {
@@ -1659,7 +1671,7 @@ fragment_add_seq_work(fragment_data *fd_head, tvbuff_t *tvb, const int offset,
return TRUE;
}
DISSECTOR_ASSERT(fd_head->len >= dfpos + fd->len);
- if ( memcmp(fd_head->data+dfpos,
+ if (tvb_memeql(fd_head->tvb_data, dfpos,
tvb_get_ptr(tvb,offset,fd->len),fd->len) ){
/*
* They have the same length, but the
@@ -1717,8 +1729,7 @@ fragment_add_seq_work(fragment_data *fd_head, tvbuff_t *tvb, const int offset,
*/
/* check len, there may be a fragment with 0 len, that is actually the tail */
if (fd->len) {
- fd->data = (unsigned char *)g_malloc(fd->len);
- tvb_memcpy(tvb, fd->data, offset, fd->len);
+ fd->tvb_data = tvb_clone_offset_len(tvb, offset, fd->len);
}
LINK_FRAG(fd_head,fd);
@@ -2063,7 +2074,7 @@ fragment_start_seq_check(reassembly_table *table, const packet_info *pinfo,
fd_head->fragment_nr_offset = 0;
fd_head->len = 0;
fd_head->flags = FD_BLOCKSEQUENCE|FD_DATALEN_SET;
- fd_head->data = NULL;
+ fd_head->tvb_data = NULL;
fd_head->reassembled_in = 0;
fd_head->error = NULL;
@@ -2154,22 +2165,12 @@ process_reassembled_data(tvbuff_t *tvb, const int offset, packet_info *pinfo,
/*
* Yes.
* 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->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
+ * reassembled payload, and set
+ * 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);
+ next_tvb = tvb_new_chain(tvb, fd_head->tvb_data);
/* Add the defragmented data to the data source list. */
add_new_data_source(pinfo, next_tvb, name);
diff --git a/epan/reassemble.h b/epan/reassemble.h
index 833b545a64..62efa3fc79 100644
--- a/epan/reassemble.h
+++ b/epan/reassemble.h
@@ -47,8 +47,8 @@
past the end of the datagram */
#define FD_TOOLONGFRAGMENT 0x0010
-/* fragment data not alloc'ed, fd->data pointing to fd_head->data+fd->offset */
-#define FD_NOT_MALLOCED 0x0020
+/* fragment tvb is subset, don't tvb_free() it */
+#define FD_SUBSET_TVB 0x0020
/* this flag is used to request fragment_add to continue the reassembly process */
#define FD_PARTIAL_REASSEMBLY 0x0040
@@ -89,7 +89,7 @@ typedef struct _fragment_data {
guint32 flags; /* XXX - do some of these apply only to reassembly
heads and others only to fragments within
a reassembly? */
- guint8 *data;
+ tvbuff_t *tvb_data;
/*
* Null if the reassembly had no error; non-null if it had
@@ -336,13 +336,12 @@ fragment_get_reassembled_id(reassembly_table *table, const packet_info *pinfo,
/* This will free up all resources and delete reassembly state for this PDU.
* Except if the PDU is completely reassembled, then it would NOT deallocate the
- * buffer holding the reassembled data but instead return the pointer to that
- * buffer.
+ * buffer holding the reassembled data but instead return the TVB
*
* So, if you call fragment_delete and it returns non-NULL, YOU are responsible to
- * g_free() that buffer.
+ * tvb_free() .
*/
-WS_DLL_PUBLIC unsigned char *
+WS_DLL_PUBLIC tvbuff_t *
fragment_delete(reassembly_table *table, const packet_info *pinfo,
const guint32 id, const void *data);
diff --git a/epan/reassemble_test.c b/epan/reassemble_test.c
index 09c9d0f00c..14a40f541b 100644
--- a/epan/reassemble_test.c
+++ b/epan/reassemble_test.c
@@ -116,7 +116,7 @@ static struct _fd_flags {
} fd_flags[] = {
{FD_DEFRAGMENTED ,"DF"},
{FD_DATALEN_SET ,"DS"},
- {FD_NOT_MALLOCED ,"NM"},
+ {FD_SUBSET_TVB, ,"ST"},
{FD_BLOCKSEQUENCE ,"BS"},
{FD_DATA_NOT_PRESENT ,"NP"},
{FD_PARTIAL_REASSEMBLY ,"PR"},
@@ -262,34 +262,34 @@ test_simple_fragment_add_seq(void)
ASSERT_EQ(2,fd_head->datalen); /* seqno of the last fragment we have */
ASSERT_EQ(4,fd_head->reassembled_in);
ASSERT_EQ(FD_DEFRAGMENTED|FD_BLOCKSEQUENCE|FD_DATALEN_SET,fd_head->flags);
- ASSERT_NE(NULL,fd_head->data);
+ ASSERT_NE(NULL,fd_head->tvb_data);
ASSERT_NE(NULL,fd_head->next);
ASSERT_EQ(1,fd_head->next->frame);
ASSERT_EQ(0,fd_head->next->offset); /* seqno */
ASSERT_EQ(50,fd_head->next->len); /* segment length */
ASSERT_EQ(0,fd_head->next->flags);
- ASSERT_EQ(NULL,fd_head->next->data);
+ ASSERT_EQ(NULL,fd_head->next->tvb_data);
ASSERT_NE(NULL,fd_head->next->next);
ASSERT_EQ(4,fd_head->next->next->frame);
ASSERT_EQ(1,fd_head->next->next->offset); /* seqno */
ASSERT_EQ(60,fd_head->next->next->len); /* segment length */
ASSERT_EQ(0,fd_head->next->next->flags);
- ASSERT_EQ(NULL,fd_head->next->next->data);
+ ASSERT_EQ(NULL,fd_head->next->next->tvb_data);
ASSERT_NE(NULL,fd_head->next->next->next);
ASSERT_EQ(3,fd_head->next->next->next->frame);
ASSERT_EQ(2,fd_head->next->next->next->offset); /* seqno */
ASSERT_EQ(60,fd_head->next->next->next->len); /* segment length */
ASSERT_EQ(0,fd_head->next->next->next->flags);
- ASSERT_EQ(NULL,fd_head->next->next->next->data);
+ ASSERT_EQ(NULL,fd_head->next->next->next->tvb_data);
ASSERT_EQ(NULL,fd_head->next->next->next->next);
/* test the actual reassembly */
- ASSERT(!memcmp(fd_head->data,data+10,50));
- ASSERT(!memcmp(fd_head->data+50,data+15,60));
- ASSERT(!memcmp(fd_head->data+110,data+5,60));
+ ASSERT(!tvb_memeql(fd_head->tvb_data,0,data+10,50));
+ ASSERT(!tvb_memeql(fd_head->tvb_data,50,data+15,60));
+ ASSERT(!tvb_memeql(fd_head->tvb_data,110,data+5,60));
#if 0
print_fragment_table();
@@ -361,18 +361,18 @@ test_fragment_add_seq_partial_reassembly(void)
ASSERT_EQ(0,fd_head->datalen); /* seqno of the last fragment we have */
ASSERT_EQ(1,fd_head->reassembled_in);
ASSERT_EQ(FD_DEFRAGMENTED|FD_BLOCKSEQUENCE|FD_DATALEN_SET,fd_head->flags);
- ASSERT_NE(NULL,fd_head->data);
+ ASSERT_NE(NULL,fd_head->tvb_data);
ASSERT_NE(NULL,fd_head->next);
ASSERT_EQ(1,fd_head->next->frame);
ASSERT_EQ(0,fd_head->next->offset); /* seqno */
ASSERT_EQ(50,fd_head->next->len); /* segment length */
ASSERT_EQ(0,fd_head->next->flags);
- ASSERT_EQ(NULL,fd_head->next->data);
+ ASSERT_EQ(NULL,fd_head->next->tvb_data);
ASSERT_EQ(NULL,fd_head->next->next);
/* test the actual reassembly */
- ASSERT(!memcmp(fd_head->data,data+10,50));
+ ASSERT(!tvb_memeql(fd_head->tvb_data,0,data+10,50));
/* now we announce that the reassembly wasn't complete after all. */
fragment_set_partial_reassembly(&test_reassembly_table, &pinfo, 12, NULL);
@@ -398,15 +398,15 @@ test_fragment_add_seq_partial_reassembly(void)
ASSERT_EQ(0,fd_head->datalen); /* seqno of the last fragment we have */
ASSERT_EQ(0,fd_head->reassembled_in);
ASSERT_EQ(FD_BLOCKSEQUENCE,fd_head->flags);
- ASSERT_NE(NULL,fd_head->data);
+ ASSERT_NE(NULL,fd_head->tvb_data);
ASSERT_NE(NULL,fd_head->next);
fd=fd_head->next;
ASSERT_EQ(1,fd->frame);
ASSERT_EQ(0,fd->offset); /* seqno */
ASSERT_EQ(50,fd->len); /* segment length */
- ASSERT_EQ(FD_NOT_MALLOCED,fd->flags);
- ASSERT_EQ(fd_head->data,fd->data);
+ ASSERT_EQ(FD_SUBSET_TVB,fd->flags);
+ ASSERT_EQ(tvb_get_ptr(fd_head->tvb_data,0,0),tvb_get_ptr(fd->tvb_data,0,0));
ASSERT_NE(NULL,fd->next);
fd=fd->next;
@@ -414,7 +414,7 @@ test_fragment_add_seq_partial_reassembly(void)
ASSERT_EQ(1,fd->offset); /* seqno */
ASSERT_EQ(40,fd->len); /* segment length */
ASSERT_EQ(0,fd->flags);
- ASSERT_NE(NULL,fd->data);
+ ASSERT_NE(NULL,fd->tvb_data);
ASSERT_EQ(NULL,fd->next);
/* Another copy of the second segment.
@@ -433,15 +433,15 @@ test_fragment_add_seq_partial_reassembly(void)
ASSERT_EQ(0,fd_head->datalen); /* seqno of the last fragment we have */
ASSERT_EQ(0,fd_head->reassembled_in);
ASSERT_EQ(FD_BLOCKSEQUENCE,fd_head->flags);
- ASSERT_NE(NULL,fd_head->data);
+ ASSERT_NE(NULL,fd_head->tvb_data);
ASSERT_NE(NULL,fd_head->next);
fd=fd_head->next;
ASSERT_EQ(1,fd->frame);
ASSERT_EQ(0,fd->offset); /* seqno */
ASSERT_EQ(50,fd->len); /* segment length */
- ASSERT_EQ(FD_NOT_MALLOCED,fd->flags);
- ASSERT_EQ(fd_head->data,fd->data);
+ ASSERT_EQ(FD_SUBSET_TVB,fd->flags);
+ ASSERT_EQ(tvb_get_ptr(fd_head->tvb_data,0,0),tvb_get_ptr(fd->tvb_data,0,0));
ASSERT_NE(NULL,fd->next);
fd=fd->next;
@@ -449,7 +449,7 @@ test_fragment_add_seq_partial_reassembly(void)
ASSERT_EQ(1,fd->offset); /* seqno */
ASSERT_EQ(40,fd->len); /* segment length */
ASSERT_EQ(0,fd->flags);
- ASSERT_NE(NULL,fd->data);
+ ASSERT_NE(NULL,fd->tvb_data);
ASSERT_NE(NULL,fd->next);
fd=fd->next;
@@ -457,7 +457,7 @@ test_fragment_add_seq_partial_reassembly(void)
ASSERT_EQ(1,fd->offset); /* seqno */
ASSERT_EQ(40,fd->len); /* segment length */
ASSERT_EQ(0,fd->flags);
- ASSERT_NE(NULL,fd->data);
+ ASSERT_NE(NULL,fd->tvb_data);
ASSERT_EQ(NULL,fd->next);
@@ -477,7 +477,7 @@ test_fragment_add_seq_partial_reassembly(void)
ASSERT_EQ(2,fd_head->datalen); /* seqno of the last fragment we have */
ASSERT_EQ(4,fd_head->reassembled_in);
ASSERT_EQ(FD_DEFRAGMENTED|FD_BLOCKSEQUENCE|FD_DATALEN_SET|FD_OVERLAP,fd_head->flags);
- ASSERT_NE(NULL,fd_head->data);
+ ASSERT_NE(NULL,fd_head->tvb_data);
ASSERT_NE(NULL,fd_head->next);
fd=fd_head->next;
@@ -485,7 +485,7 @@ test_fragment_add_seq_partial_reassembly(void)
ASSERT_EQ(0,fd->offset); /* seqno */
ASSERT_EQ(50,fd->len); /* segment length */
ASSERT_EQ(0,fd->flags);
- ASSERT_EQ(NULL,fd->data);
+ ASSERT_EQ(NULL,fd->tvb_data);
ASSERT_NE(NULL,fd->next);
fd=fd->next;
@@ -493,7 +493,7 @@ test_fragment_add_seq_partial_reassembly(void)
ASSERT_EQ(1,fd->offset); /* seqno */
ASSERT_EQ(40,fd->len); /* segment length */
ASSERT_EQ(0,fd->flags);
- ASSERT_EQ(NULL,fd->data);
+ ASSERT_EQ(NULL,fd->tvb_data);
ASSERT_NE(NULL,fd->next);
fd=fd->next;
@@ -501,7 +501,7 @@ test_fragment_add_seq_partial_reassembly(void)
ASSERT_EQ(1,fd->offset); /* seqno */
ASSERT_EQ(40,fd->len); /* segment length */
ASSERT_EQ(FD_OVERLAP,fd->flags);
- ASSERT_EQ(NULL,fd->data);
+ ASSERT_EQ(NULL,fd->tvb_data);
ASSERT_NE(NULL,fd->next);
fd=fd->next;
@@ -509,13 +509,13 @@ test_fragment_add_seq_partial_reassembly(void)
ASSERT_EQ(2,fd->offset); /* seqno */
ASSERT_EQ(100,fd->len); /* segment length */
ASSERT_EQ(0,fd->flags);
- ASSERT_EQ(NULL,fd->data);
+ ASSERT_EQ(NULL,fd->tvb_data);
ASSERT_EQ(NULL,fd->next);
/* test the actual reassembly */
- ASSERT(!memcmp(fd_head->data,data+10,50));
- ASSERT(!memcmp(fd_head->data+50,data,40));
- ASSERT(!memcmp(fd_head->data+90,data+20,100));
+ ASSERT(!tvb_memeql(fd_head->tvb_data,0,data+10,50));
+ ASSERT(!tvb_memeql(fd_head->tvb_data,50,data,40));
+ ASSERT(!tvb_memeql(fd_head->tvb_data,90,data+20,100));
/* do it again (this time it is more complicated, with an overlap in the
@@ -535,7 +535,7 @@ test_fragment_add_seq_partial_reassembly(void)
ASSERT_EQ(3,fd_head->datalen); /* seqno of the last fragment we have */
ASSERT_EQ(5,fd_head->reassembled_in);
ASSERT_EQ(FD_DEFRAGMENTED|FD_BLOCKSEQUENCE|FD_DATALEN_SET|FD_OVERLAP,fd_head->flags);
- ASSERT_NE(NULL,fd_head->data);
+ ASSERT_NE(NULL,fd_head->tvb_data);
ASSERT_NE(NULL,fd_head->next);
fd=fd_head->next;
@@ -543,7 +543,7 @@ test_fragment_add_seq_partial_reassembly(void)
ASSERT_EQ(0,fd->offset); /* seqno */
ASSERT_EQ(50,fd->len); /* segment length */
ASSERT_EQ(0,fd->flags);
- ASSERT_EQ(NULL,fd->data);
+ ASSERT_EQ(NULL,fd->tvb_data);
ASSERT_NE(NULL,fd->next);
fd=fd->next;
@@ -551,7 +551,7 @@ test_fragment_add_seq_partial_reassembly(void)
ASSERT_EQ(1,fd->offset); /* seqno */
ASSERT_EQ(40,fd->len); /* segment length */
ASSERT_EQ(0,fd->flags);
- ASSERT_EQ(NULL,fd->data);
+ ASSERT_EQ(NULL,fd->tvb_data);
ASSERT_NE(NULL,fd->next);
fd=fd->next;
@@ -559,7 +559,7 @@ test_fragment_add_seq_partial_reassembly(void)
ASSERT_EQ(1,fd->offset); /* seqno */
ASSERT_EQ(40,fd->len); /* segment length */
ASSERT_EQ(FD_OVERLAP,fd->flags);
- ASSERT_EQ(NULL,fd->data);
+ ASSERT_EQ(NULL,fd->tvb_data);
ASSERT_NE(NULL,fd->next);
fd=fd->next;
@@ -567,7 +567,7 @@ test_fragment_add_seq_partial_reassembly(void)
ASSERT_EQ(2,fd->offset); /* seqno */
ASSERT_EQ(100,fd->len); /* segment length */
ASSERT_EQ(0,fd->flags);
- ASSERT_EQ(NULL,fd->data);
+ ASSERT_EQ(NULL,fd->tvb_data);
ASSERT_NE(NULL,fd->next);
fd=fd->next;
@@ -575,14 +575,14 @@ test_fragment_add_seq_partial_reassembly(void)
ASSERT_EQ(3,fd->offset); /* seqno */
ASSERT_EQ(40,fd->len); /* segment length */
ASSERT_EQ(0,fd->flags);
- ASSERT_EQ(NULL,fd->data);
+ ASSERT_EQ(NULL,fd->tvb_data);
ASSERT_EQ(NULL,fd->next);
/* test the actual reassembly */
- ASSERT(!memcmp(fd_head->data,data+10,50));
- ASSERT(!memcmp(fd_head->data+50,data,40));
- ASSERT(!memcmp(fd_head->data+90,data+20,100));
- ASSERT(!memcmp(fd_head->data+190,data,40));
+ ASSERT(!tvb_memeql(fd_head->tvb_data,0,data+10,50));
+ ASSERT(!tvb_memeql(fd_head->tvb_data,50,data,40));
+ ASSERT(!tvb_memeql(fd_head->tvb_data,90,data+20,100));
+ ASSERT(!tvb_memeql(fd_head->tvb_data,190,data,40));
}
/* Test case for fragment_add_seq with duplicated (e.g., retransmitted) data.
@@ -642,41 +642,41 @@ test_fragment_add_seq_duplicate_first(void)
ASSERT_EQ(2,fd_head->datalen); /* seqno of the last fragment we have */
ASSERT_EQ(3,fd_head->reassembled_in);
ASSERT_EQ(FD_DEFRAGMENTED|FD_BLOCKSEQUENCE|FD_DATALEN_SET|FD_OVERLAP,fd_head->flags);
- ASSERT_NE(NULL,fd_head->data);
+ ASSERT_NE(NULL,fd_head->tvb_data);
ASSERT_NE(NULL,fd_head->next);
ASSERT_EQ(1,fd_head->next->frame);
ASSERT_EQ(0,fd_head->next->offset); /* seqno */
ASSERT_EQ(50,fd_head->next->len); /* segment length */
ASSERT_EQ(0,fd_head->next->flags);
- ASSERT_EQ(NULL,fd_head->next->data);
+ ASSERT_EQ(NULL,fd_head->next->tvb_data);
ASSERT_NE(NULL,fd_head->next->next);
ASSERT_EQ(4,fd_head->next->next->frame);
ASSERT_EQ(0,fd_head->next->next->offset); /* seqno */
ASSERT_EQ(50,fd_head->next->next->len); /* segment length */
ASSERT_EQ(FD_OVERLAP,fd_head->next->next->flags);
- ASSERT_EQ(NULL,fd_head->next->next->data);
+ ASSERT_EQ(NULL,fd_head->next->next->tvb_data);
ASSERT_NE(NULL,fd_head->next->next->next);
ASSERT_EQ(2,fd_head->next->next->next->frame);
ASSERT_EQ(1,fd_head->next->next->next->offset); /* seqno */
ASSERT_EQ(60,fd_head->next->next->next->len); /* segment length */
ASSERT_EQ(0,fd_head->next->next->next->flags);
- ASSERT_EQ(NULL,fd_head->next->next->next->data);
+ ASSERT_EQ(NULL,fd_head->next->next->next->tvb_data);
ASSERT_NE(NULL,fd_head->next->next->next->next);
ASSERT_EQ(3,fd_head->next->next->next->next->frame);
ASSERT_EQ(2,fd_head->next->next->next->next->offset); /* seqno */
ASSERT_EQ(40,fd_head->next->next->next->next->len); /* segment length */
ASSERT_EQ(0,fd_head->next->next->next->next->flags);
- ASSERT_EQ(NULL,fd_head->next->next->next->next->data);
+ ASSERT_EQ(NULL,fd_head->next->next->next->next->tvb_data);
ASSERT_EQ(NULL,fd_head->next->next->next->next->next);
/* test the actual reassembly */
- ASSERT(!memcmp(fd_head->data,data+10,50));
- ASSERT(!memcmp(fd_head->data+50,data+5,60));
- ASSERT(!memcmp(fd_head->data+110,data+5,40));
+ ASSERT(!tvb_memeql(fd_head->tvb_data,0,data+10,50));
+ ASSERT(!tvb_memeql(fd_head->tvb_data,50,data+5,60));
+ ASSERT(!tvb_memeql(fd_head->tvb_data,110,data+5,40));
#if 0
print_fragment_table();
@@ -741,41 +741,41 @@ test_fragment_add_seq_duplicate_middle(void)
ASSERT_EQ(2,fd_head->datalen); /* seqno of the last fragment we have */
ASSERT_EQ(4,fd_head->reassembled_in);
ASSERT_EQ(FD_DEFRAGMENTED|FD_BLOCKSEQUENCE|FD_DATALEN_SET|FD_OVERLAP,fd_head->flags);
- ASSERT_NE(NULL,fd_head->data);
+ ASSERT_NE(NULL,fd_head->tvb_data);
ASSERT_NE(NULL,fd_head->next);
ASSERT_EQ(1,fd_head->next->frame);
ASSERT_EQ(0,fd_head->next->offset); /* seqno */
ASSERT_EQ(50,fd_head->next->len); /* segment length */
ASSERT_EQ(0,fd_head->next->flags);
- ASSERT_EQ(NULL,fd_head->next->data);
+ ASSERT_EQ(NULL,fd_head->next->tvb_data);
ASSERT_NE(NULL,fd_head->next->next);
ASSERT_EQ(2,fd_head->next->next->frame);
ASSERT_EQ(1,fd_head->next->next->offset); /* seqno */
ASSERT_EQ(60,fd_head->next->next->len); /* segment length */
ASSERT_EQ(0,fd_head->next->next->flags);
- ASSERT_EQ(NULL,fd_head->next->next->data);
+ ASSERT_EQ(NULL,fd_head->next->next->tvb_data);
ASSERT_NE(NULL,fd_head->next->next->next);
ASSERT_EQ(3,fd_head->next->next->next->frame);
ASSERT_EQ(1,fd_head->next->next->next->offset); /* seqno */
ASSERT_EQ(60,fd_head->next->next->next->len); /* segment length */
ASSERT_EQ(FD_OVERLAP,fd_head->next->next->next->flags);
- ASSERT_EQ(NULL,fd_head->next->next->next->data);
+ ASSERT_EQ(NULL,fd_head->next->next->next->tvb_data);
ASSERT_NE(NULL,fd_head->next->next->next->next);
ASSERT_EQ(4,fd_head->next->next->next->next->frame);
ASSERT_EQ(2,fd_head->next->next->next->next->offset); /* seqno */
ASSERT_EQ(40,fd_head->next->next->next->next->len); /* segment length */
ASSERT_EQ(0,fd_head->next->next->next->next->flags);
- ASSERT_EQ(NULL,fd_head->next->next->next->next->data);
+ ASSERT_EQ(NULL,fd_head->next->next->next->next->tvb_data);
ASSERT_EQ(NULL,fd_head->next->next->next->next->next);
/* test the actual reassembly */
- ASSERT(!memcmp(fd_head->data,data+10,50));
- ASSERT(!memcmp(fd_head->data+50,data+5,60));
- ASSERT(!memcmp(fd_head->data+110,data+5,40));
+ ASSERT(!tvb_memeql(fd_head->tvb_data,0,data+10,50));
+ ASSERT(!tvb_memeql(fd_head->tvb_data,50,data+5,60));
+ ASSERT(!tvb_memeql(fd_head->tvb_data,110,data+5,40));
#if 0
print_fragment_table();
@@ -839,41 +839,41 @@ test_fragment_add_seq_duplicate_last(void)
ASSERT_EQ(2,fd_head->datalen); /* seqno of the last fragment we have */
ASSERT_EQ(3,fd_head->reassembled_in);
ASSERT_EQ(FD_DEFRAGMENTED|FD_BLOCKSEQUENCE|FD_DATALEN_SET|FD_OVERLAP,fd_head->flags);
- ASSERT_NE(NULL,fd_head->data);
+ ASSERT_NE(NULL,fd_head->tvb_data);
ASSERT_NE(NULL,fd_head->next);
ASSERT_EQ(1,fd_head->next->frame);
ASSERT_EQ(0,fd_head->next->offset); /* seqno */
ASSERT_EQ(50,fd_head->next->len); /* segment length */
ASSERT_EQ(0,fd_head->next->flags);
- ASSERT_EQ(NULL,fd_head->next->data);
+ ASSERT_EQ(NULL,fd_head->next->tvb_data);
ASSERT_NE(NULL,fd_head->next->next);
ASSERT_EQ(2,fd_head->next->next->frame);
ASSERT_EQ(1,fd_head->next->next->offset); /* seqno */
ASSERT_EQ(60,fd_head->next->next->len); /* segment length */
ASSERT_EQ(0,fd_head->next->next->flags);
- ASSERT_EQ(NULL,fd_head->next->next->data);
+ ASSERT_EQ(NULL,fd_head->next->next->tvb_data);
ASSERT_NE(NULL,fd_head->next->next->next);
ASSERT_EQ(3,fd_head->next->next->next->frame);
ASSERT_EQ(2,fd_head->next->next->next->offset); /* seqno */
ASSERT_EQ(40,fd_head->next->next->next->len); /* segment length */
ASSERT_EQ(0,fd_head->next->next->next->flags);
- ASSERT_EQ(NULL,fd_head->next->next->next->data);
+ ASSERT_EQ(NULL,fd_head->next->next->next->tvb_data);
ASSERT_NE(NULL,fd_head->next->next->next->next);
ASSERT_EQ(4,fd_head->next->next->next->next->frame);
ASSERT_EQ(2,fd_head->next->next->next->next->offset); /* seqno */
ASSERT_EQ(40,fd_head->next->next->next->next->len); /* segment length */
ASSERT_EQ(FD_OVERLAP,fd_head->next->next->next->next->flags);
- ASSERT_EQ(NULL,fd_head->next->next->next->next->data);
+ ASSERT_EQ(NULL,fd_head->next->next->next->next->tvb_data);
ASSERT_EQ(NULL,fd_head->next->next->next->next->next);
/* test the actual reassembly */
- ASSERT(!memcmp(fd_head->data,data+10,50));
- ASSERT(!memcmp(fd_head->data+50,data+5,60));
- ASSERT(!memcmp(fd_head->data+110,data+5,40));
+ ASSERT(!tvb_memeql(fd_head->tvb_data,0,data+10,50));
+ ASSERT(!tvb_memeql(fd_head->tvb_data,50,data+5,60));
+ ASSERT(!tvb_memeql(fd_head->tvb_data,110,data+5,40));
#if 0
print_fragment_table();
@@ -941,41 +941,41 @@ test_fragment_add_seq_duplicate_conflict(void)
ASSERT_EQ(2,fd_head->datalen); /* seqno of the last fragment we have */
ASSERT_EQ(4,fd_head->reassembled_in);
ASSERT_EQ(FD_DEFRAGMENTED|FD_BLOCKSEQUENCE|FD_DATALEN_SET|FD_OVERLAP|FD_OVERLAPCONFLICT,fd_head->flags);
- ASSERT_NE(NULL,fd_head->data);
+ ASSERT_NE(NULL,fd_head->tvb_data);
ASSERT_NE(NULL,fd_head->next);
ASSERT_EQ(1,fd_head->next->frame);
ASSERT_EQ(0,fd_head->next->offset); /* seqno */
ASSERT_EQ(50,fd_head->next->len); /* segment length */
ASSERT_EQ(0,fd_head->next->flags);
- ASSERT_EQ(NULL,fd_head->next->data);
+ ASSERT_EQ(NULL,fd_head->next->tvb_data);
ASSERT_NE(NULL,fd_head->next->next);
ASSERT_EQ(2,fd_head->next->next->frame);
ASSERT_EQ(1,fd_head->next->next->offset); /* seqno */
ASSERT_EQ(60,fd_head->next->next->len); /* segment length */
ASSERT_EQ(0,fd_head->next->next->flags);
- ASSERT_EQ(NULL,fd_head->next->next->data);
+ ASSERT_EQ(NULL,fd_head->next->next->tvb_data);
ASSERT_NE(NULL,fd_head->next->next->next);
ASSERT_EQ(3,fd_head->next->next->next->frame);
ASSERT_EQ(1,fd_head->next->next->next->offset); /* seqno */
ASSERT_EQ(60,fd_head->next->next->next->len); /* segment length */
ASSERT_EQ(FD_OVERLAP|FD_OVERLAPCONFLICT,fd_head->next->next->next->flags);
- ASSERT_EQ(NULL,fd_head->next->next->next->data);
+ ASSERT_EQ(NULL,fd_head->next->next->next->tvb_data);
ASSERT_NE(NULL,fd_head->next->next->next->next);
ASSERT_EQ(4,fd_head->next->next->next->next->frame);
ASSERT_EQ(2,fd_head->next->next->next->next->offset); /* seqno */
ASSERT_EQ(40,fd_head->next->next->next->next->len); /* segment length */
ASSERT_EQ(0,fd_head->next->next->next->next->flags);
- ASSERT_EQ(NULL,fd_head->next->next->next->next->data);
+ ASSERT_EQ(NULL,fd_head->next->next->next->next->tvb_data);
ASSERT_EQ(NULL,fd_head->next->next->next->next->next);
/* test the actual reassembly */
- ASSERT(!memcmp(fd_head->data,data+10,50));
- ASSERT(!memcmp(fd_head->data+50,data+5,60));
- ASSERT(!memcmp(fd_head->data+110,data+5,40));
+ ASSERT(!tvb_memeql(fd_head->tvb_data,0,data+10,50));
+ ASSERT(!tvb_memeql(fd_head->tvb_data,50,data+5,60));
+ ASSERT(!tvb_memeql(fd_head->tvb_data,110,data+5,40));
#if 0
print_fragment_table();
@@ -1053,34 +1053,34 @@ test_fragment_add_seq_check_work(fragment_data *(*fn)(reassembly_table *,
ASSERT_EQ(2,fd_head->datalen); /* seqno of the last fragment we have */
ASSERT_EQ(4,fd_head->reassembled_in);
ASSERT_EQ(FD_DEFRAGMENTED|FD_BLOCKSEQUENCE|FD_DATALEN_SET,fd_head->flags);
- ASSERT_NE(NULL,fd_head->data);
+ ASSERT_NE(NULL,fd_head->tvb_data);
ASSERT_NE(NULL,fd_head->next);
ASSERT_EQ(1,fd_head->next->frame);
ASSERT_EQ(0,fd_head->next->offset); /* seqno */
ASSERT_EQ(50,fd_head->next->len); /* segment length */
ASSERT_EQ(0,fd_head->next->flags);
- ASSERT_EQ(NULL,fd_head->next->data);
+ ASSERT_EQ(NULL,fd_head->next->tvb_data);
ASSERT_NE(NULL,fd_head->next->next);
ASSERT_EQ(4,fd_head->next->next->frame);
ASSERT_EQ(1,fd_head->next->next->offset); /* seqno */
ASSERT_EQ(60,fd_head->next->next->len); /* segment length */
ASSERT_EQ(0,fd_head->next->next->flags);
- ASSERT_EQ(NULL,fd_head->next->next->data);
+ ASSERT_EQ(NULL,fd_head->next->next->tvb_data);
ASSERT_NE(NULL,fd_head->next->next->next);
ASSERT_EQ(3,fd_head->next->next->next->frame);
ASSERT_EQ(2,fd_head->next->next->next->offset); /* seqno */
ASSERT_EQ(60,fd_head->next->next->next->len); /* segment length */
ASSERT_EQ(0,fd_head->next->next->next->flags);
- ASSERT_EQ(NULL,fd_head->next->next->next->data);
+ ASSERT_EQ(NULL,fd_head->next->next->next->tvb_data);
ASSERT_EQ(NULL,fd_head->next->next->next->next);
/* test the actual reassembly */
- ASSERT(!memcmp(fd_head->data,data+10,50));
- ASSERT(!memcmp(fd_head->data+50,data+15,60));
- ASSERT(!memcmp(fd_head->data+110,data+5,60));
+ ASSERT(!tvb_memeql(fd_head->tvb_data,0,data+10,50));
+ ASSERT(!tvb_memeql(fd_head->tvb_data,50,data+15,60));
+ ASSERT(!tvb_memeql(fd_head->tvb_data,110,data+5,60));
#if 0
print_tables();
@@ -1132,26 +1132,26 @@ test_fragment_add_seq_check_1(void)
ASSERT_EQ(1,fd_head->datalen); /* seqno of the last fragment we have */
ASSERT_EQ(2,fd_head->reassembled_in);
ASSERT_EQ(FD_DEFRAGMENTED|FD_BLOCKSEQUENCE|FD_DATALEN_SET,fd_head->flags);
- ASSERT_NE(NULL,fd_head->data);
+ ASSERT_NE(NULL,fd_head->tvb_data);
ASSERT_NE(NULL,fd_head->next);
ASSERT_EQ(2,fd_head->next->frame);
ASSERT_EQ(0,fd_head->next->offset); /* seqno */
ASSERT_EQ(60,fd_head->next->len); /* segment length */
ASSERT_EQ(0,fd_head->next->flags);
- ASSERT_EQ(NULL,fd_head->next->data);
+ ASSERT_EQ(NULL,fd_head->next->tvb_data);
ASSERT_NE(NULL,fd_head->next->next);
ASSERT_EQ(1,fd_head->next->next->frame);
ASSERT_EQ(1,fd_head->next->next->offset); /* seqno */
ASSERT_EQ(50,fd_head->next->next->len); /* segment length */
ASSERT_EQ(0,fd_head->next->next->flags);
- ASSERT_EQ(NULL,fd_head->next->next->data);
+ ASSERT_EQ(NULL,fd_head->next->next->tvb_data);
ASSERT_EQ(NULL,fd_head->next->next->next);
/* test the actual reassembly */
- ASSERT(!memcmp(fd_head->data,data+5,60));
- ASSERT(!memcmp(fd_head->data+60,data+10,50));
+ ASSERT(!tvb_memeql(fd_head->tvb_data,0,data+5,60));
+ ASSERT(!tvb_memeql(fd_head->tvb_data,60,data+10,50));
}
/**********************************************************************************
@@ -1187,7 +1187,7 @@ test_fragment_add_seq_802_11_0(void)
ASSERT_EQ(0,fd_head->datalen); /* unused */
ASSERT_EQ(1,fd_head->reassembled_in);
ASSERT_EQ(FD_DEFRAGMENTED|FD_BLOCKSEQUENCE,fd_head->flags);
- ASSERT_EQ(NULL,fd_head->data);
+ ASSERT_EQ(NULL,fd_head->tvb_data);
ASSERT_EQ(NULL,fd_head->next);
}
@@ -1325,26 +1325,26 @@ test_simple_fragment_add_seq_next(void)
ASSERT_EQ(1,fd_head->datalen); /* seqno of the last fragment we have */
ASSERT_EQ(3,fd_head->reassembled_in);
ASSERT_EQ(FD_DEFRAGMENTED|FD_BLOCKSEQUENCE|FD_DATALEN_SET,fd_head->flags);
- ASSERT_NE(NULL,fd_head->data);
+ ASSERT_NE(NULL,fd_head->tvb_data);
ASSERT_NE(NULL,fd_head->next);
ASSERT_EQ(1,fd_head->next->frame);
ASSERT_EQ(0,fd_head->next->offset); /* seqno */
ASSERT_EQ(50,fd_head->next->len); /* segment length */
ASSERT_EQ(0,fd_head->next->flags);
- ASSERT_EQ(NULL,fd_head->next->data);
+ ASSERT_EQ(NULL,fd_head->next->tvb_data);
ASSERT_NE(NULL,fd_head->next->next);
ASSERT_EQ(3,fd_head->next->next->frame);
ASSERT_EQ(1,fd_head->next->next->offset); /* seqno */
ASSERT_EQ(60,fd_head->next->next->len); /* segment length */
ASSERT_EQ(0,fd_head->next->next->flags);
- ASSERT_EQ(NULL,fd_head->next->next->data);
+ ASSERT_EQ(NULL,fd_head->next->next->tvb_data);
ASSERT_EQ(NULL,fd_head->next->next->next);
/* test the actual reassembly */
- ASSERT(!memcmp(fd_head->data,data+10,50));
- ASSERT(!memcmp(fd_head->data+50,data+5,60));
+ ASSERT(!tvb_memeql(fd_head->tvb_data,0,data+10,50));
+ ASSERT(!tvb_memeql(fd_head->tvb_data,50,data+5,60));
}
@@ -1375,7 +1375,7 @@ test_missing_data_fragment_add_seq_next(void)
ASSERT_EQ(0,fd_head->datalen); /* seqno of the last fragment we have */
ASSERT_EQ(0,fd_head->reassembled_in);
ASSERT_EQ(FD_BLOCKSEQUENCE,fd_head->flags & 0x1ff);
- ASSERT_EQ(NULL,fd_head->data);
+ ASSERT_EQ(NULL,fd_head->tvb_data);
ASSERT_EQ(NULL,fd_head->next);
/* add another fragment (with all data present) */
@@ -1498,7 +1498,7 @@ test_missing_data_fragment_add_seq_next_3(void)
ASSERT_EQ(0,fd_head->datalen); /* seqno of the last fragment we have */
ASSERT_EQ(20,fd_head->reassembled_in);
ASSERT_EQ(FD_BLOCKSEQUENCE|FD_DEFRAGMENTED,fd_head->flags);
- ASSERT_EQ(NULL,fd_head->data);
+ ASSERT_EQ(NULL,fd_head->tvb_data);
ASSERT_EQ(NULL,fd_head->next);
/* revisiting the packet ought to produce the same result. */
@@ -1517,7 +1517,7 @@ test_missing_data_fragment_add_seq_next_3(void)
ASSERT_EQ(0,fd_head->datalen); /* seqno of the last fragment we have */
ASSERT_EQ(20,fd_head->reassembled_in);
ASSERT_EQ(FD_BLOCKSEQUENCE|FD_DEFRAGMENTED,fd_head->flags);
- ASSERT_EQ(NULL,fd_head->data);
+ ASSERT_EQ(NULL,fd_head->tvb_data);
ASSERT_EQ(NULL,fd_head->next);
}
diff --git a/epan/tvbuff-int.h b/epan/tvbuff-int.h
index 890138f8d4..550ee5d30d 100644
--- a/epan/tvbuff-int.h
+++ b/epan/tvbuff-int.h
@@ -94,7 +94,7 @@ struct tvb_composite {
WS_DLL_PUBLIC tvbuff_t *tvb_new(const struct tvb_ops *ops);
-tvbuff_t *tvb_new_temporary(tvbuff_t *backing);
+tvbuff_t *tvb_new_proxy(tvbuff_t *backing);
void tvb_add_to_chain(tvbuff_t *parent, tvbuff_t *child);
diff --git a/epan/tvbuff.c b/epan/tvbuff.c
index b99e467891..be666e834b 100644
--- a/epan/tvbuff.c
+++ b/epan/tvbuff.c
@@ -142,6 +142,15 @@ tvb_free_chain(tvbuff_t *tvb)
}
}
+tvbuff_t *
+tvb_new_chain(tvbuff_t *parent, tvbuff_t *backing)
+{
+ tvbuff_t *tvb = tvb_new_proxy(backing);
+
+ tvb_add_to_chain(parent, tvb);
+ return tvb;
+}
+
void
tvb_add_to_chain(tvbuff_t *parent, tvbuff_t *child)
{
diff --git a/epan/tvbuff.h b/epan/tvbuff.h
index c747de846b..f2334a577d 100644
--- a/epan/tvbuff.h
+++ b/epan/tvbuff.h
@@ -119,6 +119,8 @@ typedef void (*tvbuff_free_cb_t)(void*);
*/
WS_DLL_PUBLIC tvbuff_t* tvb_new_octet_aligned(tvbuff_t *tvb, guint32 bit_offset, gint32 no_of_bits);
+WS_DLL_PUBLIC tvbuff_t *tvb_new_chain(tvbuff_t *parent, tvbuff_t *backing);
+
WS_DLL_PUBLIC tvbuff_t *tvb_clone(tvbuff_t *tvb);
WS_DLL_PUBLIC tvbuff_t *tvb_clone_offset_len(tvbuff_t *tvb, guint offset, guint len);
diff --git a/epan/tvbuff_subset.c b/epan/tvbuff_subset.c
index a06d60ea09..c37b63b0c2 100644
--- a/epan/tvbuff_subset.c
+++ b/epan/tvbuff_subset.c
@@ -96,7 +96,9 @@ subset_pbrk_guint8(tvbuff_t *tvb, guint abs_offset, guint limit, const guint8 *n
static tvbuff_t *
subset_clone(tvbuff_t *tvb, guint abs_offset, guint abs_length)
{
- return tvb_clone_offset_len(tvb, abs_offset, abs_length);
+ struct tvb_subset *subset_tvb = (struct tvb_subset *) tvb;
+
+ return tvb_clone_offset_len(subset_tvb->subset.tvb, abs_offset, abs_length);
}
static const struct tvb_ops tvb_subset_ops = {
@@ -222,7 +224,7 @@ tvb_new_subset_remaining(tvbuff_t *backing, const gint backing_offset)
}
tvbuff_t *
-tvb_new_temporary(tvbuff_t *backing)
+tvb_new_proxy(tvbuff_t *backing)
{
return tvb_new_with_subset(backing, backing->reported_length, 0, backing->length);
}