2 * Declarations of outines for {fragment,segment} reassembly
4 * $Id: reassemble.h,v 1.2 2001/11/24 09:36:40 guy Exp $
6 * Ethereal - Network traffic analyzer
7 * By Gerald Combs <gerald@ethereal.com>
8 * Copyright 1998 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 /* make sure that all flags that are set in a fragment entry is also set for
26 * the flags field of fd_head !!!
29 /* only in fd_head: packet is defragmented */
30 #define FD_DEFRAGMENTED 0x0001
32 /* there are overlapping fragments */
33 #define FD_OVERLAP 0x0002
35 /* overlapping fragments contain different data */
36 #define FD_OVERLAPCONFLICT 0x0004
38 /* more than one fragment which indicates end-of data */
39 #define FD_MULTIPLETAILS 0x0008
41 /* fragment contains data past the end of the datagram */
42 #define FD_TOOLONGFRAGMENT 0x0010
44 typedef struct _fragment_data {
45 struct _fragment_data *next;
49 guint32 datalen; /*Only valid in first item of list */
55 * Initialize a fragment table.
57 void fragment_table_init(GHashTable **fragment_table);
60 * Free up all space allocated for fragment keys and data.
62 void reassemble_init(void);
65 * This function adds a new fragment to the fragment hash table.
66 * If this is the first fragment seen for this datagram, a new entry
67 * is created in the hash table, otherwise this fragment is just added
68 * to the linked list of fragments for this packet.
69 * The list of fragments for a specific datagram is kept sorted for
72 * Returns a pointer to the head of the fragment data list if we have all the
73 * fragments, NULL otherwise.
75 fragment_data *fragment_add(tvbuff_t *tvb, int offset, packet_info *pinfo,
76 guint32 id, GHashTable *fragment_table, guint32 frag_offset,
77 guint32 frag_data_len, gboolean more_frags);
79 /* to specify how much to reassemble, for fragmentation where last fragment can not be
80 * identified by flags or such.
83 fragment_set_tot_len(packet_info *pinfo, guint32 id, GHashTable *fragment_table,
86 /* This function is used to check if there is partial or completed reassembly state
87 * matching this packet. I.e. Are there reassembly going on or not for this packet?
90 fragment_get(packet_info *pinfo, guint32 id, GHashTable *fragment_table);
92 /* This will free up all resources and delete reassembly state for this PDU.
93 * Except if the PDU is completely reassembled, then it would NOT deallocate the
94 * buffer holding the reassembled data but instead return the pointer to that
97 * So, if you call fragment_delete and it returns non-NULL, YOU are responsible to
98 * g_free() that buffer.
101 fragment_delete(packet_info *pinfo, guint32 id, GHashTable *fragment_table);