Pull much of the processing done after a call to "fragment_add_check()"
into a subroutine, for use in other dissectors. Use it in the IPv6 and CLNP dissectors. svn path=/trunk/; revision=7510
This commit is contained in:
parent
56cd2c741b
commit
87dfb09b12
|
@ -1,7 +1,7 @@
|
|||
/* packet-clnp.c
|
||||
* Routines for ISO/OSI network and transport protocol packet disassembly
|
||||
*
|
||||
* $Id: packet-clnp.c,v 1.71 2003/04/20 00:21:17 guy Exp $
|
||||
* $Id: packet-clnp.c,v 1.72 2003/04/20 08:06:00 guy Exp $
|
||||
* Laurent Deniel <laurent.deniel@free.fr>
|
||||
* Ralf Schneider <Ralf.Schneider@t-online.de>
|
||||
*
|
||||
|
@ -68,6 +68,7 @@ static int hf_clnp_segment_overlap_conflict = -1;
|
|||
static int hf_clnp_segment_multiple_tails = -1;
|
||||
static int hf_clnp_segment_too_long_segment = -1;
|
||||
static int hf_clnp_segment_error = -1;
|
||||
static int hf_clnp_reassembled_in = -1;
|
||||
|
||||
static int proto_cotp = -1;
|
||||
static gint ett_cotp = -1;
|
||||
|
@ -1884,27 +1885,9 @@ static void dissect_clnp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|||
clnp_reassembled_table, segment_offset,
|
||||
segment_length - cnf_hdr_len,
|
||||
cnf_type & CNF_MORE_SEGS);
|
||||
|
||||
if (fd_head != NULL) {
|
||||
/* OK, we have the complete reassembled payload.
|
||||
Allocate a new tvbuff, referring to the reassembled payload. */
|
||||
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, "Reassembled CLNP");
|
||||
|
||||
update_col_info = !show_fragment_tree(fd_head, &clnp_frag_items,
|
||||
clnp_tree, pinfo, next_tvb);
|
||||
} else {
|
||||
/* We don't have the complete reassembled payload. */
|
||||
next_tvb = NULL;
|
||||
}
|
||||
next_tvb = process_reassembled_data(tvb, pinfo, "Reassembled CLNP",
|
||||
fd_head, &clnp_frag_items, hf_clnp_reassembled_in, &update_col_info,
|
||||
clnp_tree);
|
||||
} else {
|
||||
/* If this is the first segment, dissect its contents, otherwise
|
||||
just show it as a segment.
|
||||
|
@ -2081,6 +2064,10 @@ void proto_register_clnp(void)
|
|||
{ &hf_clnp_segments,
|
||||
{ "CLNP Segments", "clnp.segments", FT_NONE, BASE_DEC, NULL, 0x0,
|
||||
"CLNP Segments", HFILL }},
|
||||
|
||||
{ &hf_clnp_reassembled_in,
|
||||
{ "Reassembled CLNP in frame", "clnp.reassembled_in", FT_FRAMENUM, BASE_NONE, NULL, 0x0,
|
||||
"This CLNP packet is reassembled in this frame", HFILL }}
|
||||
};
|
||||
static gint *ett[] = {
|
||||
&ett_clnp,
|
||||
|
|
65
packet-ip.c
65
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.188 2003/04/20 00:11:28 guy Exp $
|
||||
* $Id: packet-ip.c,v 1.189 2003/04/20 08:06:00 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -1033,66 +1033,9 @@ dissect_ip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|||
(iph->ip_off & IP_OFFSET)*8,
|
||||
pinfo->iplen - pinfo->iphdrlen,
|
||||
iph->ip_off & IP_MF);
|
||||
|
||||
if (ipfd_head != NULL) {
|
||||
/*
|
||||
* XXX - Now that we're using "fragment_add_check()", so that we don't
|
||||
* get confused by reused IP IDs, reassembled fragments are
|
||||
* hashed by the number of the frame in whch they're reassembled, so
|
||||
* the only one of the frames for which we'll get the frame info
|
||||
* is the one in which it's reassembled.
|
||||
*
|
||||
* That means we can't put the "reassembled in" information into the
|
||||
* protocol tree or Info column for packets other than the last
|
||||
* fragment. In order to do that, we'd need to hash the entry into
|
||||
* the hash table multiple times - or retroactively attach the
|
||||
* entry to all the other frames with, say, "p_add_proto_data()"
|
||||
* and use that. (That could only be done by the reassembly code
|
||||
* in "reassemble.c" if we either guaranteed that no protocol
|
||||
* doing reassembly attached its own per-protocol data or if
|
||||
* we added another list of reassembly data to all frames, growing
|
||||
* the per-frame overhead by one pointer.)
|
||||
*
|
||||
* Note that putting it into the Info column doesn't work when
|
||||
* the file is read in or reprocessed; it works only when the
|
||||
* capture is filtered. If we switch to a scheme in which the
|
||||
* column text is generated on the fly, by having the column
|
||||
* list widget get the text to draw by calling back to a routine
|
||||
* that would read and re-dissect the packet, that problem would
|
||||
* go away, although doing so without running the risk of dragging
|
||||
* the scroll bar causing stalls requires fast random access even
|
||||
* to gzipped files and fast generation of protocol trees. The
|
||||
* former can probably be done by saving the string dictionary at
|
||||
* "checkpoint" locations; the latter may require that we build
|
||||
* protocol trees using our own code, as "g_node_append()" is
|
||||
* linear in the length of the list to which it's appending.)
|
||||
*/
|
||||
if (pinfo->fd->num == ipfd_head->reassembled_in) {
|
||||
/* OK, we have the complete reassembled payload.
|
||||
Allocate a new tvbuff, referring to the reassembled payload. */
|
||||
next_tvb = tvb_new_real_data(ipfd_head->data, ipfd_head->datalen,
|
||||
ipfd_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, "Reassembled IPv4");
|
||||
|
||||
/* show all fragments */
|
||||
update_col_info = !show_fragment_tree(ipfd_head, &ip_frag_items,
|
||||
ip_tree, pinfo, next_tvb);
|
||||
} else {
|
||||
/* We don't have the complete reassembled payload. */
|
||||
next_tvb = NULL;
|
||||
proto_tree_add_uint(ip_tree, hf_ip_reassembled_in, tvb, 0, 0, ipfd_head->reassembled_in);
|
||||
}
|
||||
} else {
|
||||
/* We don't have the complete reassembled payload. */
|
||||
next_tvb = NULL;
|
||||
}
|
||||
next_tvb = process_reassembled_data(tvb, pinfo, "Reassembled IPv4",
|
||||
ipfd_head, &ip_frag_items, hf_ip_reassembled_in, &update_col_info,
|
||||
ip_tree);
|
||||
} else {
|
||||
/* If this is the first fragment, dissect its contents, otherwise
|
||||
just show it as a fragment.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* packet-ipv6.c
|
||||
* Routines for IPv6 packet disassembly
|
||||
*
|
||||
* $Id: packet-ipv6.c,v 1.95 2003/04/20 00:21:17 guy Exp $
|
||||
* $Id: packet-ipv6.c,v 1.96 2003/04/20 08:06:01 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -71,6 +71,7 @@ static int hf_ipv6_fragment_overlap_conflict = -1;
|
|||
static int hf_ipv6_fragment_multiple_tails = -1;
|
||||
static int hf_ipv6_fragment_too_long_fragment = -1;
|
||||
static int hf_ipv6_fragment_error = -1;
|
||||
static int hf_ipv6_reassembled_in = -1;
|
||||
|
||||
static int hf_ipv6_mipv6_type = -1;
|
||||
static int hf_ipv6_mipv6_length = -1;
|
||||
|
@ -644,28 +645,9 @@ again:
|
|||
offlg & IP6F_OFF_MASK,
|
||||
plen,
|
||||
offlg & IP6F_MORE_FRAG);
|
||||
|
||||
if (ipfd_head != NULL) {
|
||||
/* OK, we have the complete reassembled payload.
|
||||
Allocate a new tvbuff, referring to the reassembled payload. */
|
||||
next_tvb = tvb_new_real_data(ipfd_head->data, ipfd_head->datalen,
|
||||
ipfd_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, "Reassembled IPv6");
|
||||
|
||||
/* show all fragments */
|
||||
update_col_info = !show_fragment_tree(ipfd_head, &ipv6_frag_items,
|
||||
ipv6_tree, pinfo, next_tvb);
|
||||
} else {
|
||||
/* We don't have the complete reassembled payload. */
|
||||
next_tvb = NULL;
|
||||
}
|
||||
next_tvb = process_reassembled_data(tvb, pinfo, "Reassembled IPv6",
|
||||
ipfd_head, &ipv6_frag_items, hf_ipv6_reassembled_in, &update_col_info,
|
||||
ipv6_tree);
|
||||
} else {
|
||||
/* If this is the first fragment, dissect its contents, otherwise
|
||||
just show it as a fragment.
|
||||
|
@ -810,6 +792,11 @@ proto_register_ipv6(void)
|
|||
FT_NONE, BASE_NONE, NULL, 0x0,
|
||||
"IPv6 Fragments", HFILL }},
|
||||
|
||||
{ &hf_ipv6_reassembled_in,
|
||||
{ "Reassembled IPv6 in frame", "ipv6.reassembled_in",
|
||||
FT_FRAMENUM, BASE_NONE, NULL, 0x0,
|
||||
"This IPv6 packet is reassembled in this frame", HFILL }},
|
||||
|
||||
/* Mobile IPv6 */
|
||||
{ &hf_ipv6_mipv6_type,
|
||||
{ "Option Type ", "ipv6.mipv6_type",
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*
|
||||
* Copyright 2001, Michael Tuexen <tuexen [AT] fh-muenster.de>
|
||||
*
|
||||
* $Id: packet-mtp2.c,v 1.5 2003/04/19 20:13:22 tuexen Exp $
|
||||
* $Id: packet-mtp2.c,v 1.6 2003/04/20 08:06:01 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -73,12 +73,12 @@ static void
|
|||
dissect_mtp2_header(tvbuff_t *su_tvb, proto_item *mtp2_tree)
|
||||
{
|
||||
if (mtp2_tree) {
|
||||
proto_tree_add_item(mtp2_tree, hf_mtp2_bsn, su_tvb, BSN_BIB_OFFSET, BSN_BIB_LENGTH, LITTLE_ENDIAN);
|
||||
proto_tree_add_item(mtp2_tree, hf_mtp2_bib, su_tvb, BSN_BIB_OFFSET, BSN_BIB_LENGTH, LITTLE_ENDIAN);
|
||||
proto_tree_add_item(mtp2_tree, hf_mtp2_fsn, su_tvb, FSN_FIB_OFFSET, FSN_FIB_LENGTH, LITTLE_ENDIAN);
|
||||
proto_tree_add_item(mtp2_tree, hf_mtp2_fib, su_tvb, FSN_FIB_OFFSET, FSN_FIB_LENGTH, LITTLE_ENDIAN);
|
||||
proto_tree_add_item(mtp2_tree, hf_mtp2_li, su_tvb, LI_OFFSET, LI_LENGTH, LITTLE_ENDIAN);
|
||||
proto_tree_add_item(mtp2_tree, hf_mtp2_spare, su_tvb, LI_OFFSET, LI_LENGTH, LITTLE_ENDIAN);
|
||||
proto_tree_add_item(mtp2_tree, hf_mtp2_bsn, su_tvb, BSN_BIB_OFFSET, BSN_BIB_LENGTH, TRUE);
|
||||
proto_tree_add_item(mtp2_tree, hf_mtp2_bib, su_tvb, BSN_BIB_OFFSET, BSN_BIB_LENGTH, TRUE);
|
||||
proto_tree_add_item(mtp2_tree, hf_mtp2_fsn, su_tvb, FSN_FIB_OFFSET, FSN_FIB_LENGTH, TRUE);
|
||||
proto_tree_add_item(mtp2_tree, hf_mtp2_fib, su_tvb, FSN_FIB_OFFSET, FSN_FIB_LENGTH, TRUE);
|
||||
proto_tree_add_item(mtp2_tree, hf_mtp2_li, su_tvb, LI_OFFSET, LI_LENGTH, TRUE);
|
||||
proto_tree_add_item(mtp2_tree, hf_mtp2_spare, su_tvb, LI_OFFSET, LI_LENGTH, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,9 +118,9 @@ dissect_mtp2_lssu(tvbuff_t *su_tvb, packet_info *pinfo, proto_item *mtp2_tree)
|
|||
if (mtp2_tree) {
|
||||
li = tvb_get_guint8(su_tvb, LI_OFFSET);
|
||||
if ((li & LI_MASK) == 1)
|
||||
proto_tree_add_item(mtp2_tree, hf_mtp2_sf, su_tvb, SF_OFFSET, SF_LENGTH, LITTLE_ENDIAN);
|
||||
proto_tree_add_item(mtp2_tree, hf_mtp2_sf, su_tvb, SF_OFFSET, SF_LENGTH, TRUE);
|
||||
else
|
||||
proto_tree_add_item(mtp2_tree, hf_mtp2_long_sf, su_tvb, SF_OFFSET, LONG_SF_LENGTH, LITTLE_ENDIAN);
|
||||
proto_tree_add_item(mtp2_tree, hf_mtp2_long_sf, su_tvb, SF_OFFSET, LONG_SF_LENGTH, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
87
reassemble.c
87
reassemble.c
|
@ -1,7 +1,7 @@
|
|||
/* reassemble.c
|
||||
* Routines for {fragment,segment} reassembly
|
||||
*
|
||||
* $Id: reassemble.c,v 1.34 2003/04/20 00:27:29 guy Exp $
|
||||
* $Id: reassemble.c,v 1.35 2003/04/20 08:06:01 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -1330,6 +1330,91 @@ fragment_add_seq_next(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
|||
more_frags, TRUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Process reassembled data; if we're on the frame in which the data
|
||||
* was reassembled, put the fragment information into the protocol
|
||||
* tree, and construct a tvbuff with the reassembled data, otherwise
|
||||
* 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 *frag_items,
|
||||
int hf_reassembled_in, gboolean *update_col_infop, proto_tree *tree)
|
||||
{
|
||||
tvbuff_t *next_tvb;
|
||||
|
||||
if (fd_head != NULL) {
|
||||
/*
|
||||
* XXX - Now that we're using "fragment_add_check()",
|
||||
* so that we don't get confused by reused IP IDs,
|
||||
* reassembled fragments are hashed by the number of
|
||||
* the frame in whch they're reassembled, so the only
|
||||
* one of the frames for which we'll get the frame info
|
||||
* is the one in which it's reassembled.
|
||||
*
|
||||
* That means we can't put the "reassembled in" information
|
||||
* into the protocol tree or Info column for packets other
|
||||
* than the last fragment. In order to do that, we'd need
|
||||
* to hash the entry into the hash table multiple times - or
|
||||
* retroactively attach the entry to all the other frames
|
||||
* with, say, "p_add_proto_data()" and use that. (That could
|
||||
* only be done by the reassembly code in "reassemble.c" if
|
||||
* we either guaranteed that no protocol doing reassembly
|
||||
* attached its own per-protocol data or if we added another
|
||||
* list of reassembly data to all frames, growing the
|
||||
* per-frame overhead by one pointer.)
|
||||
*
|
||||
* Note that putting it into the Info column doesn't work
|
||||
* when the file is read in or reprocessed; it works only
|
||||
* when the capture is filtered. If we switch to a scheme
|
||||
* in which the column text is generated on the fly, by
|
||||
* having the column list widget get the text to draw by
|
||||
* calling back to a routine that would read and re-dissect
|
||||
* the packet, that problem would go away, although doing so
|
||||
* without running the risk of dragging the scroll bar
|
||||
* causing stalls requires fast random access even to
|
||||
* gzipped files and fast generation of protocol trees.
|
||||
* The former can probably be done by saving the string
|
||||
* dictionary at "checkpoint" locations; the latter may
|
||||
* require that we build protocol trees using our own code,
|
||||
* as "g_node_append()" is linear in the length of the list
|
||||
* to which it's appending.)
|
||||
*/
|
||||
if (pinfo->fd->num == fd_head->reassembled_in) {
|
||||
/*
|
||||
* OK, we have the complete reassembled payload.
|
||||
* Allocate a new tvbuff, referring to the reassembled
|
||||
* payload.
|
||||
*/
|
||||
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);
|
||||
|
||||
/* show all fragments */
|
||||
*update_col_infop = !show_fragment_tree(fd_head,
|
||||
frag_items, tree, pinfo, next_tvb);
|
||||
} else {
|
||||
/* We don't have the complete reassembled payload. */
|
||||
next_tvb = NULL;
|
||||
proto_tree_add_uint(tree, hf_reassembled_in, tvb, 0, 0,
|
||||
fd_head->reassembled_in);
|
||||
}
|
||||
} else {
|
||||
/* We don't have the complete reassembled payload. */
|
||||
next_tvb = NULL;
|
||||
}
|
||||
return next_tvb;
|
||||
}
|
||||
|
||||
/*
|
||||
* Show a single fragment in a fragment subtree.
|
||||
*/
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* reassemble.h
|
||||
* Declarations of outines for {fragment,segment} reassembly
|
||||
*
|
||||
* $Id: reassemble.h,v 1.16 2003/04/20 00:27:29 guy Exp $
|
||||
* $Id: reassemble.h,v 1.17 2003/04/20 08:06:01 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -218,6 +218,11 @@ typedef struct _fragment_items {
|
|||
char *tag;
|
||||
} fragment_items;
|
||||
|
||||
extern tvbuff_t *
|
||||
process_reassembled_data(tvbuff_t *tvb, packet_info *pinfo, char *name,
|
||||
fragment_data *fd_head, const fragment_items *frag_items,
|
||||
int hf_reassembled_in, gboolean *update_col_infop, proto_tree *tree);
|
||||
|
||||
extern gboolean
|
||||
show_fragment_tree(fragment_data *ipfd_head, const fragment_items *fit,
|
||||
proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb);
|
||||
|
|
Loading…
Reference in New Issue