wireshark/epan/tvbuff-int.h
Guy Harris 0efcd0632b When we're dissecting the beginning of a fragmented packet that we
haven't reassembled, we're probably moving sequentially through the
packet, which means that we'll run past the end of the fragment rather
than past the end of what would have been the reassembled packet had we
reassembled it.

I.e., there's little reason to care whether we're past the end of the
fragment but not past the end of the packet, or whether we're past the
end of the packet; in either case, we're past the end of the fragment,
and if somebody wants to know whether the packet is malformed by
stopping short of certain fields, they should enable reassembly.

So we get rid of the explicit fragment length in tvbuffs and, instead,
have a "this is a fragment" flag; if that flag is set, we throw
FragmentBoundsError rather than ReportedBoundsError if we run past the
end of the reported data.

(This also means we could flag the tvbuff even if we don't know how
large the reassembled packet will be, e.g. when doing IP reassembly.)

Replace tvb_new_subset_length_fragment() with tvb_new_subset_length()
and a new "set the "this is a fragment flag"" routine.

svn path=/trunk/; revision=48940
2013-04-20 02:53:57 +00:00

96 lines
2.4 KiB
C

/* tvbuff-int.h
*
* Structures that most TVB users should not be accessing directly.
*
* $Id$
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef __TVBUFF_INT_H__
#define __TVBUFF_INT_H__
typedef struct {
/** The backing tvbuff_t */
struct tvbuff *tvb;
/** The offset of 'tvb' to which I'm privy */
guint offset;
/** The length of 'tvb' to which I'm privy */
guint length;
} tvb_backing_t;
typedef struct {
GSList *tvbs;
/* Used for quick testing to see if this
* is the tvbuff that a COMPOSITE is
* interested in. */
guint *start_offsets;
guint *end_offsets;
} tvb_comp_t;
/*
* Tvbuff flags.
*/
#define TVBUFF_FRAGMENT 0x00000001 /* this is a fragment */
struct tvbuff {
/* Doubly linked list pointers */
tvbuff_t *next;
tvbuff_t *previous;
/* Record-keeping */
tvbuff_type type;
gboolean initialized;
guint flags;
struct tvbuff *ds_tvb; /**< data source top-level tvbuff */
/** TVBUFF_SUBSET and TVBUFF_COMPOSITE keep track
* of the other tvbuff's they use */
union {
tvb_backing_t subset;
tvb_comp_t composite;
} tvbuffs;
/** We're either a TVBUFF_REAL_DATA or a
* TVBUFF_SUBSET that has a backing buffer that
* has real_data != NULL, or a TVBUFF_COMPOSITE
* which has flattened its data due to a call
* to tvb_get_ptr().
*/
const guint8 *real_data;
/** Length of virtual buffer (and/or real_data). */
guint length;
/** Reported length. */
guint reported_length;
/* Offset from beginning of first TVBUFF_REAL. */
gint raw_offset;
/** Func to call when actually freed */
tvbuff_free_cb_t free_cb;
};
#endif