diff options
author | Pascal Quantin <pascal.quantin@gmail.com> | 2015-03-09 21:28:24 +0100 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2015-03-10 21:52:59 +0000 |
commit | 0bbbda713d88497933c51485e08abc98f63386f7 (patch) | |
tree | 664bdd48aab0297f6a4807533f6dd74ccdfd80b1 | |
parent | cac102eee3db8d498b1e2d91ee2b49cfe4f531e4 (diff) | |
download | wireshark-0bbbda713d88497933c51485e08abc98f63386f7.tar.gz wireshark-0bbbda713d88497933c51485e08abc98f63386f7.tar.bz2 wireshark-0bbbda713d88497933c51485e08abc98f63386f7.zip |
TCP: use curr_num_layer as key for p_(add|get)_proto_data
It allows to properly handle a use case were several TCP connections would be encapsulated
Note that it is safe to use the same key for struct tcp_analysis and proto_tree as they are not using the same scope (and thus list)
Change-Id: I37423eca225960f2e72817f6faf543f6676cf489
Reviewed-on: https://code.wireshark.org/review/7606
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
-rw-r--r-- | epan/dissectors/packet-tcp.c | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/epan/dissectors/packet-tcp.c b/epan/dissectors/packet-tcp.c index f2e00ec57a..37e8148e25 100644 --- a/epan/dissectors/packet-tcp.c +++ b/epan/dissectors/packet-tcp.c @@ -826,7 +826,7 @@ tcp_calculate_timestamps(packet_info *pinfo, struct tcp_analysis *tcpd, { if( !tcppd ) { tcppd = wmem_new(wmem_file_scope(), struct tcp_per_packet_data_t); - p_add_proto_data(wmem_file_scope(), pinfo, proto_tcp, 0, tcppd); + p_add_proto_data(wmem_file_scope(), pinfo, proto_tcp, pinfo->curr_layer_num, tcppd); } if (!tcpd) @@ -857,7 +857,7 @@ tcp_print_timestamps(packet_info *pinfo, tvbuff_t *tvb, proto_tree *parent_tree, PROTO_ITEM_SET_GENERATED(item); if( !tcppd ) - tcppd = (struct tcp_per_packet_data_t *)p_get_proto_data(wmem_file_scope(), pinfo, proto_tcp, 0); + tcppd = (struct tcp_per_packet_data_t *)p_get_proto_data(wmem_file_scope(), pinfo, proto_tcp, pinfo->curr_layer_num); if( tcppd ) { item = proto_tree_add_time(tree, hf_tcp_ts_delta, tvb, 0, 0, @@ -2320,6 +2320,8 @@ tcp_dissect_pdus(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, tvbuff_t *next_tvb; proto_item *item=NULL; const char *saved_proto; + guint8 curr_layer_num; + wmem_list_frame_t *frame; while (tvb_reported_length_remaining(tvb, offset) > 0) { /* @@ -2423,15 +2425,12 @@ tcp_dissect_pdus(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, } } - /* - * Do not display the the PDU length if it crosses the boundary of the - * packet and no more packets are available. - * - * XXX - we don't necessarily know whether more packets are - * available; we might be doing a one-pass read through the - * capture in TShark, or we might be doing a live capture in - * Wireshark. - */ + curr_layer_num = pinfo->curr_layer_num-1; + frame = wmem_list_frame_prev(wmem_list_tail(pinfo->layers)); + while (frame && (proto_tcp != (gint) GPOINTER_TO_UINT(wmem_list_frame_data(frame)))) { + frame = wmem_list_frame_prev(frame); + curr_layer_num--; + } #if 0 if (captured_length_remaining >= plen || there are more packets) { @@ -2439,13 +2438,13 @@ tcp_dissect_pdus(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, /* * Display the PDU length as a field */ - item=proto_tree_add_uint((proto_tree *)p_get_proto_data(pinfo->pool, pinfo, proto_tcp, 1), + item=proto_tree_add_uint((proto_tree *)p_get_proto_data(pinfo->pool, pinfo, proto_tcp, curr_layer_num), hf_tcp_pdu_size, tvb, offset, plen, plen); PROTO_ITEM_SET_GENERATED(item); #if 0 } else { - item = proto_tree_add_expert_format((proto_tree *)p_get_proto_data(pinfo->pool, pinfo, proto_tcp, 1), + item = proto_tree_add_expert_format((proto_tree *)p_get_proto_data(pinfo->pool, pinfo, proto_tcp, curr_layer_num), tvb, offset, -1, "PDU Size: %u cut short at %u",plen,captured_length_remaining); PROTO_ITEM_SET_GENERATED(item); @@ -4366,7 +4365,7 @@ dissect_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) ti = proto_tree_add_item(tree, proto_tcp, tvb, 0, -1, ENC_NA); } tcp_tree = proto_item_add_subtree(ti, ett_tcp); - p_add_proto_data(pinfo->pool, pinfo, proto_tcp, 1, tcp_tree); + p_add_proto_data(pinfo->pool, pinfo, proto_tcp, pinfo->curr_layer_num, tcp_tree); proto_tree_add_uint_format_value(tcp_tree, hf_tcp_srcport, tvb, offset, 2, tcph->th_sport, "%s (%u)", src_port_str, tcph->th_sport); @@ -4447,7 +4446,7 @@ dissect_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /* Do we need to calculate timestamps relative to the tcp-stream? */ if (tcp_calculate_ts) { - tcppd = (struct tcp_per_packet_data_t *)p_get_proto_data(wmem_file_scope(), pinfo, proto_tcp, 0); + tcppd = (struct tcp_per_packet_data_t *)p_get_proto_data(wmem_file_scope(), pinfo, proto_tcp, pinfo->curr_layer_num); /* * Calculate the timestamps relative to this conversation (but only on the |