diff options
-rw-r--r-- | epan/dissectors/packet-tcp.c | 35 | ||||
-rw-r--r-- | epan/emem.c | 23 | ||||
-rw-r--r-- | epan/emem.h | 2 |
3 files changed, 53 insertions, 7 deletions
diff --git a/epan/dissectors/packet-tcp.c b/epan/dissectors/packet-tcp.c index f1e2ab3827..7f8538b0cf 100644 --- a/epan/dissectors/packet-tcp.c +++ b/epan/dissectors/packet-tcp.c @@ -316,13 +316,20 @@ scan_for_next_pdu(tvbuff_t *tvb, proto_tree *tcp_tree, packet_info *pinfo, int o if(!pinfo->fd->flags.visited){ msp=se_tree_lookup32_le(tcpd->fwd->multisegment_pdus, seq-1); if(msp){ + /* If this is a continuation of a PDU started in a + * previous segment we need to update the last_frame + * variables. + */ + if(seq>msp->seq && seq<msp->nxtpdu){ + msp->last_frame=pinfo->fd->num; + msp->last_frame_time=pinfo->fd->abs_ts; + print_pdu_tracking_data(pinfo, tvb, tcp_tree, msp); + } + /* If this segment is completely within a previous PDU * then we just skip this packet */ if(seq>msp->seq && nxtseq<=msp->nxtpdu){ - msp->last_frame=pinfo->fd->num; - msp->last_frame_time=pinfo->fd->abs_ts; - print_pdu_tracking_data(pinfo, tvb, tcp_tree, msp); return -1; } if(seq<msp->nxtpdu && nxtseq>msp->nxtpdu){ @@ -332,9 +339,20 @@ scan_for_next_pdu(tvbuff_t *tvb, proto_tree *tcp_tree, packet_info *pinfo, int o } } else { - msp=se_tree_lookup32_le(tcpd->fwd->multisegment_pdus, seq-1); + /* First we try to find the start and transfer time for a PDU. + * We only print this for the very first segment of a PDU + * and only for PDUs spanning multiple segments. + * Se we look for if there was any multisegment PDU started + * just BEFORE the end of this segment. I.e. either inside this + * segment or in a previous segment. + * Since this might also match PDUs that are completely within + * this segment we also verify that the found PDU does span + * beyond the end of this segment. + */ + msp=se_tree_lookup32_le(tcpd->fwd->multisegment_pdus, nxtseq-1); if(msp){ - if(pinfo->fd->num==msp->first_frame){ + if( (pinfo->fd->num==msp->first_frame) + ){ proto_item *item; nstime_t ns; @@ -346,7 +364,13 @@ scan_for_next_pdu(tvbuff_t *tvb, proto_tree *tcp_tree, packet_info *pinfo, int o tvb, 0, 0, &ns); PROTO_ITEM_SET_GENERATED(item); } + } + /* Second we check if this segment is part of a PDU started + * prior to the segment (seq-1) + */ + msp=se_tree_lookup32_le(tcpd->fwd->multisegment_pdus, seq-1); + if(msp){ /* If this segment is completely within a previous PDU * then we just skip this packet */ @@ -360,6 +384,7 @@ scan_for_next_pdu(tvbuff_t *tvb, proto_tree *tcp_tree, packet_info *pinfo, int o return offset; } } + } return offset; } diff --git a/epan/emem.c b/epan/emem.c index e1a4615b87..90dbc64e8e 100644 --- a/epan/emem.c +++ b/epan/emem.c @@ -744,7 +744,6 @@ se_free_all(void) #endif /* DEBUG_USE_CANARIES */ #endif - /* move all used chunks over to the free list */ while(se_packet_mem.used_list){ npc=se_packet_mem.used_list; @@ -1501,3 +1500,25 @@ emem_tree_lookup_string(emem_tree_t* se_tree, const gchar* k) { return emem_tree_lookup32_array(se_tree, key); } + + +static void +emem_tree_print_nodes(emem_tree_node_t* node, int level) +{ + int i; + for(i=0;i<level;i++){ + printf(" "); + } + printf("NODE:%08x parent:%08x left:0x%08x right:%08x key:%d data:0x%08x\n",(int)node,(int)node->parent,(int)node->left,(int)node->right,node->key32,(int)node->data); + if(node->left) + emem_tree_print_nodes(node->left, level+1); + if(node->right) + emem_tree_print_nodes(node->right, level+1); +} +void +emem_print_tree(emem_tree_t* emem_tree) +{ + printf("EMEM tree type:%d name:%s tree:0x%08x\n",emem_tree->type,emem_tree->name,(int)emem_tree->tree); + if(emem_tree->tree) + emem_tree_print_nodes(emem_tree->tree, 0); +} diff --git a/epan/emem.h b/epan/emem.h index 65c87322cd..ff871bbc95 100644 --- a/epan/emem.h +++ b/epan/emem.h @@ -343,7 +343,7 @@ void* emem_tree_lookup_string(emem_tree_t* h, const gchar* k); - +void emem_print_tree(emem_tree_t* emem_tree); |