X-Git-Url: http://git.samba.org/samba.git/?p=obnox%2Fwireshark%2Fwip.git;a=blobdiff_plain;f=reassemble.h;h=85c66942c9c43dff0d9c964b1e2eab618beedbb3;hp=4fc8daad7328df51dddc1b7aea95239e0dd29b04;hb=18b97a36eec5b4f3d97e0cf7593be7cdce62bd37;hpb=daea9a75c1cf9df2fe47f53bf9900a7c83dd9981 diff --git a/reassemble.h b/reassemble.h index 4fc8daad73..85c66942c9 100644 --- a/reassemble.h +++ b/reassemble.h @@ -1,22 +1,22 @@ /* reassemble.h * Declarations of outines for {fragment,segment} reassembly * - * $Id: reassemble.h,v 1.6 2002/04/17 08:25:05 guy Exp $ + * $Id$ * * Ethereal - Network traffic analyzer * By Gerald Combs * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. @@ -32,8 +32,8 @@ /* there are overlapping fragments */ #define FD_OVERLAP 0x0002 -/* overlapping fragments contain different data */ -#define FD_OVERLAPCONFLICT 0x0004 +/* overlapping fragments contain different data */ +#define FD_OVERLAPCONFLICT 0x0004 /* more than one fragment which indicates end-of data */ #define FD_MULTIPLETAILS 0x0008 @@ -57,6 +57,9 @@ typedef struct _fragment_data { guint32 offset; guint32 len; guint32 datalen; /*Only valid in first item of list */ + guint32 reassembled_in; /* frame where this PDU was reassembled, + only valid in the first item of the list + and when FD_DEFRAGMENTED is set*/ guint32 flags; unsigned char *data; } fragment_data; @@ -64,12 +67,13 @@ typedef struct _fragment_data { /* * Initialize a fragment table. */ -void fragment_table_init(GHashTable **fragment_table); +extern void fragment_table_init(GHashTable **fragment_table); +extern void dcerpc_fragment_table_init(GHashTable **fragment_table); /* * Initialize a reassembled-packet table. */ -void reassembled_table_init(GHashTable **reassembled_table); +extern void reassembled_table_init(GHashTable **reassembled_table); /* * Free up all space allocated for fragment keys and data. @@ -87,82 +91,154 @@ void reassemble_init(void); * Returns a pointer to the head of the fragment data list if we have all the * fragments, NULL otherwise. */ -fragment_data *fragment_add(tvbuff_t *tvb, int offset, packet_info *pinfo, +extern fragment_data *fragment_add(tvbuff_t *tvb, int offset, packet_info *pinfo, guint32 id, GHashTable *fragment_table, guint32 frag_offset, guint32 frag_data_len, gboolean more_frags); +extern fragment_data *fragment_add_multiple_ok(tvbuff_t *tvb, int offset, + packet_info *pinfo, guint32 id, GHashTable *fragment_table, + guint32 frag_offset, guint32 frag_data_len, gboolean more_frags); + +extern fragment_data *fragment_add_check(tvbuff_t *tvb, int offset, + packet_info *pinfo, guint32 id, GHashTable *fragment_table, + GHashTable *reassembled_table, guint32 frag_offset, + guint32 frag_data_len, gboolean more_frags); /* same as fragment_add() but this one assumes frag_number is a block sequence number. note that frag_number is 0 for the first fragment. */ -fragment_data *fragment_add_seq(tvbuff_t *tvb, int offset, packet_info *pinfo, +extern fragment_data *fragment_add_seq(tvbuff_t *tvb, int offset, packet_info *pinfo, guint32 id, GHashTable *fragment_table, guint32 frag_number, guint32 frag_data_len, gboolean more_frags); +extern fragment_data * +fragment_add_dcerpc(tvbuff_t *tvb, int offset, packet_info *pinfo, guint32 id, + void *act_id, + GHashTable *fragment_table, guint32 frag_number, + guint32 frag_data_len, gboolean more_frags); + /* - * This function adds a new fragment to the fragment hash table. + * These functions add a new fragment to the fragment hash table. * If this is the first fragment seen for this datagram, a new * "fragment_data" structure is allocated to refer to the reassembled, * packet, and: * - * if "more_frags" is false, the structure is not added to - * the hash table, and not given any fragments to refer to, - * but is just returned; + * in "fragment_add_seq_802_11()", if "more_frags" is false, + * the structure is not added to the hash table, and not given + * any fragments to refer to, but is just returned; * - * if "more_frags" is true, this fragment is added to the linked - * list of fragments for this packet, and the "fragment_data" - * structure is put into the hash table. + * otherwise, this fragment is added to the linked list of fragments + * for this packet, and the "fragment_data" structure is put into + * the hash table. * * Otherwise, this fragment is just added to the linked list of fragments * for this packet. * - * Returns a pointer to the head of the fragment data list, and removes - * that from the fragment hash table if necessary and adds it to the - * table of reassembled fragments, if we have all the fragments or if - * this is the only fragment and "more_frags" is false, returns NULL - * otherwise. + * If, after processing this fragment, we have all the fragments, they + * remove that from the fragment hash table if necessary and add it + * to the table of reassembled fragments, and return a pointer to the + * head of the fragment list. + * + * If this is the first fragment we've seen, and "more_frags" is false, + * "fragment_add_seq_802_11()" does nothing to the fragment data list, + * and returns a pointer to the head of that (empty) list. The other + * routines return NULL. * - * This function assumes frag_number being a block sequence number. + * Otherwise, they return NULL. + * + * "fragment_add_seq_check()" and "fragment_add_seq_802_11()" assume + * frag_number is a block sequence number. * The bsn for the first block is 0. + * + * "fragment_add_seq_next()" is for protocols with no sequence number, + * and assumes fragments always appear in sequence. */ -fragment_data * +extern fragment_data * fragment_add_seq_check(tvbuff_t *tvb, int offset, packet_info *pinfo, guint32 id, GHashTable *fragment_table, GHashTable *reassembled_table, guint32 frag_number, guint32 frag_data_len, gboolean more_frags); -/* to specify how much to reassemble, for fragmentation where last fragment can not be +extern fragment_data * +fragment_add_seq_802_11(tvbuff_t *tvb, int offset, packet_info *pinfo, + guint32 id, GHashTable *fragment_table, + GHashTable *reassembled_table, guint32 frag_number, + guint32 frag_data_len, gboolean more_frags); + +extern fragment_data * +fragment_add_seq_next(tvbuff_t *tvb, int offset, packet_info *pinfo, guint32 id, + GHashTable *fragment_table, GHashTable *reassembled_table, + guint32 frag_data_len, gboolean more_frags); + +/* to specify how much to reassemble, for fragmentation where last fragment can not be * identified by flags or such. * note that for FD_BLOCKSEQUENCE tot_len is the index for the tail fragment. - * i.e. since the block numbers start at 0, if we specify tot_len==2, that + * i.e. since the block numbers start at 0, if we specify tot_len==2, that * actually means we want to defragment 3 blocks, block 0, 1 and 2. * */ -void -fragment_set_tot_len(packet_info *pinfo, guint32 id, GHashTable *fragment_table, +extern void +fragment_set_tot_len(packet_info *pinfo, guint32 id, GHashTable *fragment_table, guint32 tot_len); + +/* to resad whatever totlen previously set */ +extern guint32 +fragment_get_tot_len(packet_info *pinfo, guint32 id, GHashTable *fragment_table); + /* * This function will set the partial reassembly flag(FD_PARTIAL_REASSEMBLY) for a fh. * When this function is called, the fh MUST already exist, i.e. * the fh MUST be created by the initial call to fragment_add() before - * this function is called. Also note that this function MUST be called to indicate + * this function is called. Also note that this function MUST be called to indicate * a fh will be extended (increase the already stored data). After calling this function, * and if FD_DEFRAGMENTED is set, the reassembly process will be continued. */ -void +extern void fragment_set_partial_reassembly(packet_info *pinfo, guint32 id, GHashTable *fragment_table); /* This function is used to check if there is partial or completed reassembly state * matching this packet. I.e. Are there reassembly going on or not for this packet? */ -fragment_data * +extern fragment_data * fragment_get(packet_info *pinfo, guint32 id, GHashTable *fragment_table); /* This will free up all resources and delete reassembly state for this PDU. * Except if the PDU is completely reassembled, then it would NOT deallocate the * buffer holding the reassembled data but instead return the pointer to that * buffer. - * - * So, if you call fragment_delete and it returns non-NULL, YOU are responsible to + * + * So, if you call fragment_delete and it returns non-NULL, YOU are responsible to * g_free() that buffer. */ -unsigned char * +extern unsigned char * fragment_delete(packet_info *pinfo, guint32 id, GHashTable *fragment_table); + +/* hf_fragment, hf_fragment_error, and hf_reassembled_in should be + FT_FRAMENUM, the others should be FT_BOOLEAN +*/ +typedef struct _fragment_items { + gint *ett_fragment; + gint *ett_fragments; + + int *hf_fragments; + int *hf_fragment; + int *hf_fragment_overlap; + int *hf_fragment_overlap_conflict; + int *hf_fragment_multiple_tails; + int *hf_fragment_too_long_fragment; + int *hf_fragment_error; + int *hf_reassembled_in; + + char *tag; +} fragment_items; + +extern tvbuff_t * +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 +show_fragment_tree(fragment_data *ipfd_head, const fragment_items *fit, + proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb); + +extern gboolean +show_fragment_seq_tree(fragment_data *ipfd_head, const fragment_items *fit, + proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb);