diff options
author | Guy Harris <guy@alum.mit.edu> | 2003-08-28 04:19:29 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2003-08-28 04:19:29 +0000 |
commit | a2246980423a0f99fdfd45fccf229eb5fc3263b3 (patch) | |
tree | 7de7a1b7c6732a147c2d02b7f228baf1b5131637 | |
parent | f3d64a2c3834a26a87ec266a4397f43b21b62a70 (diff) |
Make "process_reassembled_data()" do the check for fragmentation not
being complete and for fragmentation being trivial (i.e., the packet in
question is both the first and last fragment). Have its callers *not*
do that check - this lets "process_reassembled_data()" put in the
"Reassembled in" item for fragments other than the last fragment.
Add a "Reassembled in" field to TDS.
svn path=/trunk/; revision=8295
-rw-r--r-- | packet-atalk.c | 16 | ||||
-rw-r--r-- | packet-clnp.c | 11 | ||||
-rw-r--r-- | packet-ieee80211.c | 34 | ||||
-rw-r--r-- | packet-ip.c | 11 | ||||
-rw-r--r-- | packet-ipv6.c | 9 | ||||
-rw-r--r-- | packet-tds.c | 26 | ||||
-rw-r--r-- | reassemble.c | 80 | ||||
-rw-r--r-- | reassemble.h | 6 |
8 files changed, 79 insertions, 114 deletions
diff --git a/packet-atalk.c b/packet-atalk.c index 67bbc07b13..f4267d2e22 100644 --- a/packet-atalk.c +++ b/packet-atalk.c @@ -2,7 +2,7 @@ * Routines for AppleTalk packet disassembly: LLAP, DDP, NBP, ATP, ASP, * RTMP. * - * $Id: packet-atalk.c,v 1.88 2003/04/20 11:36:11 guy Exp $ + * $Id: packet-atalk.c,v 1.89 2003/08/28 04:19:28 guy Exp $ * * Simon Wilkinson <sxw@dcs.ed.ac.uk> * @@ -857,17 +857,9 @@ dissect_atp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { frag_number, len, more_fragment); - if (fd_head != NULL) { - if (fd_head->next != NULL) { - new_tvb = process_reassembled_data(tvb, pinfo, "Reassembled ATP", - fd_head, &atp_frag_items, NULL, atp_tree); - } - else - new_tvb = tvb_new_subset(tvb, ATP_HDRSIZE -1, -1, -1); - } - else { - new_tvb = NULL; - } + new_tvb = process_reassembled_data(tvb, ATP_HDRSIZE -1, pinfo, + "Reassembled ATP", fd_head, &atp_frag_items, + NULL, atp_tree); } else { /* full packet */ diff --git a/packet-clnp.c b/packet-clnp.c index b0d3fda625..37738f1950 100644 --- a/packet-clnp.c +++ b/packet-clnp.c @@ -1,7 +1,7 @@ /* packet-clnp.c * Routines for ISO/OSI network and transport protocol packet disassembly * - * $Id: packet-clnp.c,v 1.76 2003/05/28 22:58:46 guy Exp $ + * $Id: packet-clnp.c,v 1.77 2003/08/28 04:19:28 guy Exp $ * Laurent Deniel <laurent.deniel@free.fr> * Ralf Schneider <Ralf.Schneider@t-online.de> * @@ -1981,13 +1981,8 @@ static void dissect_clnp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) segment_length - cnf_hdr_len, cnf_type & CNF_MORE_SEGS); - if (fd_head != NULL) { - next_tvb = process_reassembled_data(tvb, pinfo, "Reassembled CLNP", - fd_head, &clnp_frag_items, &update_col_info, clnp_tree); - } else { - /* We don't have the complete reassembled payload. */ - next_tvb = NULL; - } + next_tvb = process_reassembled_data(tvb, offset, pinfo, "Reassembled CLNP", + fd_head, &clnp_frag_items, &update_col_info, clnp_tree); } else { /* If this is the first segment, dissect its contents, otherwise just show it as a segment. diff --git a/packet-ieee80211.c b/packet-ieee80211.c index d44b232c77..1ad7822ee7 100644 --- a/packet-ieee80211.c +++ b/packet-ieee80211.c @@ -3,7 +3,7 @@ * Copyright 2000, Axis Communications AB * Inquiries/bugreports should be sent to Johan.Jorgensen@axis.com * - * $Id: packet-ieee80211.c,v 1.95 2003/08/26 06:18:17 guy Exp $ + * $Id: packet-ieee80211.c,v 1.96 2003/08/28 04:19:28 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -1893,35 +1893,9 @@ dissect_ieee80211_common (tvbuff_t * tvb, packet_info * pinfo, frag_number, reported_len, more_frags); - if (fd_head != NULL) { - /* - * Either this is reassembled or it wasn't fragmented - * (see comment above about some networking interfaces). - * In either case, it's now in the table of reassembled - * packets. - * - * If the "fragment_data" structure doesn't have a list of - * fragments, we assume it's a placeholder to mark those - * not-really-fragmented packets, and just treat this as - * a non-fragmented frame. - */ - if (fd_head->next != NULL) { - next_tvb = process_reassembled_data(tvb, pinfo, "Reassembled 802.11", - fd_head, &frag_items, NULL, hdr_tree); - } else { - /* - * Not fragmented, really. - * Show it as a regular frame. - */ - next_tvb = tvb_new_subset (next_tvb, hdr_len, len, reported_len); - } - - /* It's not fragmented. */ - pinfo->fragmented = FALSE; - } else { - /* We don't have the complete reassembled payload. */ - next_tvb = NULL; - } + next_tvb = process_reassembled_data(tvb, hdr_len, pinfo, + "Reassembled 802.11", fd_head, + &frag_items, NULL, hdr_tree); } else { /* * If this is the first fragment, dissect its contents, otherwise diff --git a/packet-ip.c b/packet-ip.c index 2a625868c9..93d04aa161 100644 --- a/packet-ip.c +++ b/packet-ip.c @@ -1,7 +1,7 @@ /* packet-ip.c * Routines for IP and miscellaneous IP protocol packet disassembly * - * $Id: packet-ip.c,v 1.196 2003/08/26 19:41:09 guy Exp $ + * $Id: packet-ip.c,v 1.197 2003/08/28 04:19:28 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -1029,13 +1029,8 @@ dissect_ip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) pinfo->iplen - pinfo->iphdrlen, iph->ip_off & IP_MF); - if (ipfd_head != NULL) { - next_tvb = process_reassembled_data(tvb, pinfo, "Reassembled IPv4", - ipfd_head, &ip_frag_items, &update_col_info, ip_tree); - } else { - /* We don't have the complete reassembled payload. */ - next_tvb = NULL; - } + next_tvb = process_reassembled_data(tvb, offset, pinfo, "Reassembled IPv4", + ipfd_head, &ip_frag_items, &update_col_info, ip_tree); } else { /* If this is the first fragment, dissect its contents, otherwise just show it as a fragment. diff --git a/packet-ipv6.c b/packet-ipv6.c index 313364e57c..d82d30a383 100644 --- a/packet-ipv6.c +++ b/packet-ipv6.c @@ -1,7 +1,7 @@ /* packet-ipv6.c * Routines for IPv6 packet disassembly * - * $Id: packet-ipv6.c,v 1.99 2003/07/11 09:30:48 guy Exp $ + * $Id: packet-ipv6.c,v 1.100 2003/08/28 04:19:28 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -746,13 +746,8 @@ again: plen, offlg & IP6F_MORE_FRAG); - if (ipfd_head != NULL) { - next_tvb = process_reassembled_data(tvb, pinfo, "Reassembled IPv6", + next_tvb = process_reassembled_data(tvb, offset, pinfo, "Reassembled IPv6", ipfd_head, &ipv6_frag_items, &update_col_info, ipv6_tree); - } else { - /* We don't have the complete reassembled payload. */ - next_tvb = NULL; - } } else { /* If this is the first fragment, dissect its contents, otherwise just show it as a fragment. diff --git a/packet-tds.c b/packet-tds.c index 4e9dd8a320..ca4c12e985 100644 --- a/packet-tds.c +++ b/packet-tds.c @@ -3,7 +3,7 @@ * Copyright 2000-2002, Brian Bruns <camber@ais.org> * Copyright 2002, Steve Langasek <vorlon@netexpress.net> * - * $Id: packet-tds.c,v 1.18 2003/08/28 02:19:00 guy Exp $ + * $Id: packet-tds.c,v 1.19 2003/08/28 04:19:29 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -120,7 +120,7 @@ * opposed to more than one server response item) per NETLIB packet? Or is * all the data in a NETLIB packet put into a single TDS PDU? If so, then * we can reassemble NETLIB packets using the standard TCP desegmentation - * code, and can reassemble TDS PDUs using "fragment_add_seq_next()", + * code, and can reassemble TDS PDUs using "fragment_add_seq_check()", * and more cleanly separate the NETLIB and TDS dissectors (although the * "is this NETLIB" heuristic would have to look at TDS information past * the NETLIB header, in order to make the heuristic strong enough not @@ -265,6 +265,7 @@ static int hf_tds_size = -1; static int hf_tds_channel = -1; static int hf_tds_packet_number = -1; static int hf_tds_window = -1; +static int hf_tds_reassembled_in = -1; static int hf_tds_fragments = -1; static int hf_tds_fragment = -1; static int hf_tds_fragment_overlap = -1; @@ -307,7 +308,7 @@ static const fragment_items tds_frag_items = { &hf_tds_fragment_multiple_tails, &hf_tds_fragment_too_long_fragment, &hf_tds_fragment_error, - NULL, + &hf_tds_reassembled_in, "fragments" }; @@ -1002,17 +1003,9 @@ dissect_netlib_buffer(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) fd_head = fragment_add_seq_check(tvb, offset, pinfo, channel, tds_fragment_table, tds_reassembled_table, packet_number - 1, len, status == STATUS_NOT_LAST_BUFFER); - if (fd_head != NULL) { - if (fd_head->next != NULL) { - next_tvb = process_reassembled_data(tvb, - pinfo, "Reassembled TDS", fd_head, - &tds_frag_items, NULL, tds_tree); - } else { - next_tvb = tvb_new_subset(tvb, offset, -1, -1); - } - } else { - next_tvb = NULL; - } + next_tvb = process_reassembled_data(tvb, offset, pinfo, + "Reassembled TDS", fd_head, &tds_frag_items, NULL, + tds_tree); } else { /* * If this isn't the last buffer, just show it as a fragment. @@ -1400,6 +1393,11 @@ proto_register_netlib(void) FT_NONE, BASE_NONE, NULL, 0x0, "TDS Fragments", HFILL } }, + { &hf_tds_reassembled_in, + { "Reassembled TDS in frame", "tds.reassembled_in", + FT_FRAMENUM, BASE_NONE, NULL, 0x0, + "This TDS packet is reassembled in this frame", HFILL } + }, { &hf_tds7_login_total_size, { "Total Packet Length", "tds7login.total_len", FT_UINT32, BASE_DEC, NULL, 0x0, diff --git a/reassemble.c b/reassemble.c index 5ea9e3ec7a..674b7dace4 100644 --- a/reassemble.c +++ b/reassemble.c @@ -1,7 +1,7 @@ /* reassemble.c * Routines for {fragment,segment} reassembly * - * $Id: reassemble.c,v 1.40 2003/07/31 21:55:22 guy Exp $ + * $Id: reassemble.c,v 1.41 2003/08/28 04:19:29 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -1434,44 +1434,59 @@ fragment_add_seq_next(tvbuff_t *tvb, int offset, packet_info *pinfo, * just put a "reassembled in" item into the protocol tree. */ tvbuff_t * -process_reassembled_data(tvbuff_t *tvb, packet_info *pinfo, char *name, - fragment_data *fd_head, const fragment_items *fit, +process_reassembled_data(tvbuff_t *tvb, int offset, packet_info *pinfo, + char *name, fragment_data *fd_head, const fragment_items *fit, gboolean *update_col_infop, proto_tree *tree) { tvbuff_t *next_tvb; gboolean update_col_info; - if (pinfo->fd->num == fd_head->reassembled_in) { + if (fd_head != NULL && pinfo->fd->num == fd_head->reassembled_in) { /* - * OK, we have the complete reassembled payload. - * Allocate a new tvbuff, referring to the reassembled - * payload. + * OK, we've reassembled this. + * Is this something that's been reassembled from more + * than one fragment? */ - 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 - * 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); - - /* Add the defragmented data to the data source list. */ - add_new_data_source(pinfo, next_tvb, name); + if (fd_head->next != NULL) { + /* + * 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); + } - /* show all fragments */ - if (fd_head->flags & FD_BLOCKSEQUENCE) { - update_col_info = !show_fragment_seq_tree(fd_head, - fit, tree, pinfo, next_tvb); + /* + * Add 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); + + /* Add the defragmented data to the data source list. */ + add_new_data_source(pinfo, next_tvb, name); + + /* show all fragments */ + if (fd_head->flags & FD_BLOCKSEQUENCE) { + update_col_info = !show_fragment_seq_tree( + fd_head, fit, tree, pinfo, next_tvb); + } else { + update_col_info = !show_fragment_tree(fd_head, + fit, tree, pinfo, next_tvb); + } } else { - update_col_info = !show_fragment_tree(fd_head, - fit, tree, pinfo, next_tvb); + /* + * No. + * Return a tvbuff with the payload. + */ + next_tvb = tvb_new_subset(tvb, offset, -1, -1); + pinfo->fragmented = FALSE; /* one-fragment packet */ + update_col_info = TRUE; } if (update_col_infop != NULL) *update_col_infop = update_col_info; @@ -1480,11 +1495,12 @@ process_reassembled_data(tvbuff_t *tvb, packet_info *pinfo, char *name, next_tvb = NULL; /* - * If there's a field to use for the number of + * If we know what frame this was reassembled in, + * and if there's a field to use for the number of * the frame in which the packet was reassembled, * add it to the protocol tree. */ - if (fit->hf_reassembled_in != NULL) { + if (fd_head != NULL && fit->hf_reassembled_in != NULL) { proto_tree_add_uint(tree, *(fit->hf_reassembled_in), tvb, 0, 0, fd_head->reassembled_in); diff --git a/reassemble.h b/reassemble.h index 397ce241a8..76900524aa 100644 --- a/reassemble.h +++ b/reassemble.h @@ -1,7 +1,7 @@ /* reassemble.h * Declarations of outines for {fragment,segment} reassembly * - * $Id: reassemble.h,v 1.19 2003/06/04 05:41:37 guy Exp $ + * $Id: reassemble.h,v 1.20 2003/08/28 04:19:29 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -212,8 +212,8 @@ typedef struct _fragment_items { } fragment_items; extern tvbuff_t * -process_reassembled_data(tvbuff_t *tvb, packet_info *pinfo, char *name, - fragment_data *fd_head, const fragment_items *fit, +process_reassembled_data(tvbuff_t *tvb, int offset, packet_info *pinfo, + char *name, fragment_data *fd_head, const fragment_items *fit, gboolean *update_col_infop, proto_tree *tree); extern gboolean |