diff options
author | Guy Harris <guy@alum.mit.edu> | 2002-08-03 22:28:16 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2002-08-03 22:28:16 +0000 |
commit | 6ed12f6993a949cf7b1c335d5a94f4dc5792dfc9 (patch) | |
tree | 5853c2b6ea60cec5c8cab8bbb728b6ba4a929b03 | |
parent | a7b0159be41462e1da8d651fd4d7c84e995d4a4d (diff) |
Create the TCP protocol tree, and put the source and destination ports
into it, as soon as we've extracted the source and destination ports
from the packet, so that if we throw an exception fetching something
else from the packet, we still have the protocol tree and ports.
svn path=/trunk/; revision=5943
-rw-r--r-- | packet-tcp.c | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/packet-tcp.c b/packet-tcp.c index 8f775f216e..34cbbcba93 100644 --- a/packet-tcp.c +++ b/packet-tcp.c @@ -1,7 +1,7 @@ /* packet-tcp.c * Routines for TCP packet disassembly * - * $Id: packet-tcp.c,v 1.148 2002/08/02 23:36:03 jmayer Exp $ + * $Id: packet-tcp.c,v 1.149 2002/08/03 22:28:16 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -1635,7 +1635,25 @@ dissect_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) col_append_fstr(pinfo->cinfo, COL_INFO, "%s > %s", get_tcp_port(th_sport), get_tcp_port(th_dport)); } - + if (tree) { + if (tcp_summary_in_tree) { + ti = proto_tree_add_protocol_format(tree, proto_tcp, tvb, 0, -1, + "Transmission Control Protocol, Src Port: %s (%u), Dst Port: %s (%u)", + get_tcp_port(th_sport), th_sport, + get_tcp_port(th_dport), th_dport); + } + else { + ti = proto_tree_add_item(tree, proto_tcp, tvb, 0, -1, FALSE); + } + tcp_tree = proto_item_add_subtree(ti, ett_tcp); + proto_tree_add_uint_format(tcp_tree, hf_tcp_srcport, tvb, offset, 2, th_sport, + "Source port: %s (%u)", get_tcp_port(th_sport), th_sport); + proto_tree_add_uint_format(tcp_tree, hf_tcp_dstport, tvb, offset + 2, 2, th_dport, + "Destination port: %s (%u)", get_tcp_port(th_dport), th_dport); + proto_tree_add_uint_hidden(tcp_tree, hf_tcp_port, tvb, offset, 2, th_sport); + proto_tree_add_uint_hidden(tcp_tree, hf_tcp_port, tvb, offset + 2, 2, th_dport); + } + /* Set the source and destination port numbers as soon as we get them, so that they're available to the "Follow TCP Stream" code even if we throw an exception dissecting the rest of the TCP header. */ @@ -1676,25 +1694,6 @@ dissect_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /* Compute the sequence number of next octet after this segment. */ nxtseq = th_seq + seglen; - if (tree) { - if (tcp_summary_in_tree) { - ti = proto_tree_add_protocol_format(tree, proto_tcp, tvb, 0, -1, - "Transmission Control Protocol, Src Port: %s (%u), Dst Port: %s (%u)", - get_tcp_port(th_sport), th_sport, - get_tcp_port(th_dport), th_dport); - } - else { - ti = proto_tree_add_item(tree, proto_tcp, tvb, 0, -1, FALSE); - } - tcp_tree = proto_item_add_subtree(ti, ett_tcp); - proto_tree_add_uint_format(tcp_tree, hf_tcp_srcport, tvb, offset, 2, th_sport, - "Source port: %s (%u)", get_tcp_port(th_sport), th_sport); - proto_tree_add_uint_format(tcp_tree, hf_tcp_dstport, tvb, offset + 2, 2, th_dport, - "Destination port: %s (%u)", get_tcp_port(th_dport), th_dport); - proto_tree_add_uint_hidden(tcp_tree, hf_tcp_port, tvb, offset, 2, th_sport); - proto_tree_add_uint_hidden(tcp_tree, hf_tcp_port, tvb, offset + 2, 2, th_dport); - } - if (check_col(pinfo->cinfo, COL_INFO) || tree) { for (i = 0; i < 8; i++) { bpos = 1 << i; |