| Wireshark 4.7.0 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
reassemble.h
Go to the documentation of this file.
1
11/* make sure that all flags that are set in a fragment entry is also set for
12 * the flags field of fd_head !!!
13 */
14
15#ifndef REASSEMBLE_H
16#define REASSEMBLE_H
17
18#include <epan/packet_info.h>
19#include <epan/proto.h>
20#include "ws_symbol_export.h"
21
22#ifdef __cplusplus
23 extern "C" {
24#endif
25
26/* only in fd_head: packet is defragmented */
27#define FD_DEFRAGMENTED 0x0001
28
29/* there are overlapping fragments */
30#define FD_OVERLAP 0x0002
31
32/* overlapping fragments contain different data */
33#define FD_OVERLAPCONFLICT 0x0004
34
35/* more than one fragment which indicates end-of data */
36#define FD_MULTIPLETAILS 0x0008
37
38/* fragment starts before the end of the datagram but extends
39 past the end of the datagram */
40#define FD_TOOLONGFRAGMENT 0x0010
41
42/* fragment tvb is subset, don't tvb_free() it */
43#define FD_SUBSET_TVB 0x0020
44
45/* this flag is used to request fragment_add to continue the reassembly process */
46#define FD_PARTIAL_REASSEMBLY 0x0040
47
48/* fragment offset is indicated by sequence number and not byte offset
49 into the defragmented packet */
50#define FD_BLOCKSEQUENCE 0x0100
51
52/* This flag is set in (only) fd_head to denote that datalen has been set to a valid value.
53 * It's implied by FD_DEFRAGMENTED (we must know the total length of the
54 * datagram if we have defragmented it...)
55 */
56#define FD_DATALEN_SET 0x0400
57
58 struct dissector_handle;
59
60 typedef struct _fragment_item {
61 struct _fragment_item *next;
62 uint32_t frame;
63 uint32_t offset;
65 uint32_t len;
66 uint32_t flags;
69 tvbuff_t *tvb_data;
70} fragment_item;
71
72 typedef struct _fragment_head {
73 struct _fragment_item *next;
74 struct _fragment_item *first_gap;
76 unsigned ref_count;
77 uint32_t contiguous_len;
78 uint32_t frame;
79 uint32_t len;
82 uint32_t fragment_nr_offset;
85 uint32_t datalen;
91 uint32_t reassembled_in;
93 uint8_t reas_in_layer_num;
97 uint32_t flags;
100 tvbuff_t *tvb_data;
105 const char *error;
106} fragment_head;
107
108/*
109 * Flags for fragment_add_seq_*
110 */
111
112/* we don't have any sequence numbers - fragments are assumed to appear in
113 * order */
114#define REASSEMBLE_FLAGS_NO_FRAG_NUMBER 0x0001
115
116/* a special fudge for the 802.11 dissector */
117#define REASSEMBLE_FLAGS_802_11_HACK 0x0002
118
119/*
120 * Flags for fragment_add_seq_single_*
121 */
122
123/* we want to age off old packets */
124#define REASSEMBLE_FLAGS_AGING 0x0001
125
126/*
127 * Generates a fragment identifier based on the given parameters. "data" is an
128 * opaque type whose interpretation is up to the caller of fragment_add*
129 * functions and the fragment key function (possibly NULL if you do not care).
130 *
131 * Keys returned by this function are only used within this packet scope.
132 */
133 typedef void * (*fragment_temporary_key)(const packet_info *pinfo,
134 const uint32_t id, const void *data);
135
136/*
137 * Like fragment_temporary_key, but used for identifying reassembled fragments
138 * which may persist through multiple packets.
139 */
140 typedef void * (*fragment_persistent_key)(const packet_info *pinfo,
141 const uint32_t id, const void *data);
142
143/*
144 * Data structure to keep track of fragments and reassemblies.
145 */
146 typedef struct {
147 GHashTable *fragment_table;
148 GHashTable *reassembled_table;
149 fragment_temporary_key temporary_key_func;
150 fragment_persistent_key persistent_key_func;
151 GDestroyNotify free_temporary_key_func; /* temporary key destruction function */
152} reassembly_table;
153
154/*
155 * Table of functions for a reassembly table.
156 */
157 typedef struct {
158 /* Functions for fragment table */
159 GHashFunc hash_func; /* hash function */
160 GEqualFunc equal_func; /* comparison function */
161 fragment_temporary_key temporary_key_func; /* temporary key creation function */
162 fragment_persistent_key persistent_key_func; /* persistent key creation function */
163 GDestroyNotify free_temporary_key_func; /* temporary key destruction function */
164 GDestroyNotify free_persistent_key_func; /* persistent key destruction function */
165} reassembly_table_functions;
166
167/*
168 * Tables of functions exported for the benefit of dissectors that
169 * don't need special items in their keys.
170 */
171WS_DLL_PUBLIC const reassembly_table_functions
172 addresses_reassembly_table_functions; /* keys have endpoint addresses and an ID */
173WS_DLL_PUBLIC const reassembly_table_functions
174 addresses_ports_reassembly_table_functions; /* keys have endpoint addresses and ports and an ID */
175
176/*
177 * Register a reassembly table. By registering the table with epan, the creation and
178 * destruction of the table can be managed by epan and not the dissector.
179 */
180WS_DLL_PUBLIC void
181reassembly_table_register(reassembly_table *table,
182 const reassembly_table_functions *funcs);
183
184/*
185 * Initialize/destroy a reassembly table.
186 *
187 * init: If table doesn't exist: create table;
188 * else: just remove any entries;
189 * destroy: remove entries and destroy table;
190 */
191WS_DLL_PUBLIC void
192reassembly_table_init(reassembly_table *table,
193 const reassembly_table_functions *funcs);
194WS_DLL_PUBLIC void
195reassembly_table_destroy(reassembly_table *table);
196
197/*
198 * This function adds a new fragment to the reassembly table
199 * If this is the first fragment seen for this datagram, a new entry
200 * is created in the table, otherwise this fragment is just added
201 * to the linked list of fragments for this packet.
202 * The list of fragments for a specific datagram is kept sorted for
203 * easier handling.
204 *
205 * Datagrams (messages) are identified by a key generated by
206 * fragment_temporary_key or fragment_persistent_key, based on the "pinfo", "id"
207 * and "data" pairs. (This is the sole purpose of "data".)
208 *
209 * Fragments are identified by "frag_offset".
210 *
211 * Returns a pointer to the head of the fragment data list if we have all the
212 * fragments, NULL otherwise. Note that the reassembled fragments list may have
213 * a non-zero fragment offset, the only guarantee is that no gaps exist within
214 * the list.
215 *
216 * @note Reused keys are assumed to refer to the same reassembled message
217 * (i.e., retransmission). If the same "id" is used more than once on a
218 * connection, then "data" and custom reassembly_table_functions should be
219 * used so that the keys hash differently.
220 */
221WS_DLL_PUBLIC fragment_head *
222fragment_add(reassembly_table *table, tvbuff_t *tvb, const int offset,
223 const packet_info *pinfo, const uint32_t id, const void *data,
224 const uint32_t frag_offset, const uint32_t frag_data_len,
225 const bool more_frags);
226/*
227 * Like fragment_add, except that the fragment may be added to multiple
228 * reassembly tables. This is needed when multiple protocol layers try
229 * to add the same packet to the reassembly table.
230 */
231WS_DLL_PUBLIC fragment_head *
232fragment_add_multiple_ok(reassembly_table *table, tvbuff_t *tvb,
233 const int offset, const packet_info *pinfo,
234 const uint32_t id, const void *data,
235 const uint32_t frag_offset,
236 const uint32_t frag_data_len,
237 const bool more_frags);
238
239/*
240 * Like fragment_add, except that the fragment may originate from a frame
241 * other than pinfo->num. For use when you are adding an out of order segment
242 * that arrived in an earlier frame, so that show_fragment_tree will display
243 * the correct fragment numbers.
244 *
245 * This is for protocols like TCP, where the correct reassembly to add a
246 * segment to cannot be determined without processing previous segments
247 * in sequence order, including handing them to subdissectors.
248 *
249 * Note that pinfo is still used to set reassembled_in if we have all the
250 * fragments, so that results on subsequent passes can be the same as the
251 * first pass.
252 */
253WS_DLL_PUBLIC fragment_head *
254fragment_add_out_of_order(reassembly_table *table, tvbuff_t *tvb,
255 const int offset, const packet_info *pinfo,
256 const uint32_t id, const void *data,
257 const uint32_t frag_offset,
258 const uint32_t frag_data_len,
259 const bool more_frags, const uint32_t frag_frame);
260/*
261 * Like fragment_add, but maintains a table for completed reassemblies.
262 *
263 * If the packet was seen before, return the head of the fully reassembled
264 * fragments list (NULL if there was none).
265 *
266 * Otherwise (if reassembly was not possible before), try to add the new
267 * fragment to the fragments table. If reassembly is now possible, remove all
268 * (reassembled) fragments from the fragments table and store it as a completed
269 * reassembly. The head of this reassembled fragments list is returned.
270 *
271 * Otherwise (if reassembly is still not possible after adding this fragment),
272 * return NULL.
273 *
274 * @note Completed reassemblies are removed from the in-progress table, so
275 * key can be reused to begin a new reassembled message. Conversely,
276 * dissectors SHOULD NOT call this with a retransmitted fragment of a
277 * completed reassembly. Dissectors atop a reliable protocol like TCP
278 * may assume that the lower layer dissector handles retransmission,
279 * but other dissectors (e.g., atop UDP or Ethernet) will have to handle
280 * that situation themselves.
281 */
282WS_DLL_PUBLIC fragment_head *
283fragment_add_check(reassembly_table *table, tvbuff_t *tvb, const int offset,
284 const packet_info *pinfo, const uint32_t id,
285 const void *data, const uint32_t frag_offset,
286 const uint32_t frag_data_len, const bool more_frags);
287
288/*
289 * Like fragment_add_check, but handles retransmissions after reassembly.
290 *
291 * Start new reassembly only if there is no reassembly in progress and there
292 * is no completed reassembly reachable from fallback_frame. If there is
293 * completed reassembly (reachable from fallback_frame), simply links this
294 * packet into the list, updating the flags if necessary (however actual data
295 * and reassembled in frame won't be modified).
296 */
297WS_DLL_PUBLIC fragment_head *
298fragment_add_check_with_fallback(reassembly_table *table, tvbuff_t *tvb, const int offset,
299 const packet_info *pinfo, const uint32_t id,
300 const void *data, const uint32_t frag_offset,
301 const uint32_t frag_data_len, const bool more_frags,
302 const uint32_t fallback_frame);
303
304/*
305 * Like fragment_add, but fragments have a block sequence number starting from
306 * zero (for the first fragment of each datagram). This differs from
307 * fragment_add for which the fragment may start at any offset.
308 *
309 * If this is the first fragment seen for this datagram, a new
310 * "fragment_head" structure is allocated to refer to the reassembled
311 * packet, and:
312 *
313 * if "more_frags" is false, and either we have no sequence numbers, or
314 * are using the 802.11 hack (via fragment_add_seq_802_11), it is assumed that
315 * this is the only fragment in the datagram. The structure is not added to the
316 * hash table, and not given any fragments to refer to, but is just returned.
317 *
318 * In this latter case reassembly wasn't done (since there was only one
319 * fragment in the packet); dissectors can check the 'next' pointer on the
320 * returned list to see if this case was hit or not.
321 *
322 * Otherwise, this fragment is just added to the linked list of fragments
323 * for this packet; the fragment_item is also added to the fragment hash if
324 * necessary.
325 *
326 * If this packet completes assembly, these functions return the head of the
327 * fragment data; otherwise, they return null.
328 *
329 * @note Reused keys are assumed to refer to the same reassembled message
330 * (i.e., retransmission). If the same "id" is used more than once on a
331 * connection, then "data" and custom reassembly_table_functions should be
332 * used so that the keys hash differently.
333 */
334WS_DLL_PUBLIC fragment_head *
335fragment_add_seq(reassembly_table *table, tvbuff_t *tvb, const int offset,
336 const packet_info *pinfo, const uint32_t id, const void *data,
337 const uint32_t frag_number, const uint32_t frag_data_len,
338 const bool more_frags, const uint32_t flags);
339
340/*
341 * Like fragment_add_seq, but maintains a table for completed reassemblies
342 * just like fragment_add_check.
343 *
344 * @note Completed reassemblies are removed from the in-progress table, so
345 * key can be reused to begin a new reassembled message. Conversely,
346 * dissectors SHOULD NOT call this with a retransmitted fragment of a
347 * completed reassembly. Dissectors atop a reliable protocol like TCP
348 * may assume that the lower layer dissector handles retransmission,
349 * but other dissectors (e.g., atop UDP or Ethernet) will have to handle
350 * that situation themselves.
351 */
352WS_DLL_PUBLIC fragment_head *
353fragment_add_seq_check(reassembly_table *table, tvbuff_t *tvb, const int offset,
354 const packet_info *pinfo, const uint32_t id,
355 const void *data,
356 const uint32_t frag_number, const uint32_t frag_data_len,
357 const bool more_frags);
358
359/*
360 * Like fragment_add_seq_check, but immediately returns a fragment list for a
361 * new fragment. This is a workaround specific for the 802.11 dissector, do not
362 * use it elsewhere.
363 */
364WS_DLL_PUBLIC fragment_head *
365fragment_add_seq_802_11(reassembly_table *table, tvbuff_t *tvb,
366 const int offset, const packet_info *pinfo,
367 const uint32_t id, const void *data,
368 const uint32_t frag_number, const uint32_t frag_data_len,
369 const bool more_frags);
370
371/*
372 * Like fragment_add_seq_check, but without explicit fragment number. Fragments
373 * are simply appended until no "more_frags" is false.
374 *
375 * @note Out of order fragments will not be reassembled correctly.
376 * Dissectors atop a reliable protocol like TCP may rely on the lower
377 * level dissector reordering out or order segments (if the appropriate
378 * out of order reassembly preference is enabled), but other dissectors
379 * will have to handle out of order fragments themselves, if possible.
380 */
381WS_DLL_PUBLIC fragment_head *
382fragment_add_seq_next(reassembly_table *table, tvbuff_t *tvb, const int offset,
383 const packet_info *pinfo, const uint32_t id,
384 const void *data, const uint32_t frag_data_len,
385 const bool more_frags);
386
387/*
388 * Like fragment_add_seq_check, but for protocols like PPP MP with a single
389 * sequence number that increments for each fragment, thus acting like the sum
390 * of the PDU sequence number and explicit fragment number in other protocols.
391 * See Appendix A of RFC 4623 (PWE3 Fragmentation and Reassembly) for a list
392 * of protocols that use this style, including PPP MP (RFC 1990), PWE3 MPLS
393 * (RFC 4385), L2TPv2 (RFC 2661), L2TPv3 (RFC 3931), ATM, and Frame Relay.
394 * It is guaranteed to reassemble a packet split up to "max_frags" in size,
395 * but may manage to reassemble more in certain cases.
396 */
397WS_DLL_PUBLIC fragment_head *
398fragment_add_seq_single(reassembly_table *table, tvbuff_t *tvb,
399 const int offset, const packet_info *pinfo, const uint32_t id,
400 const void* data, const uint32_t frag_data_len,
401 const bool first, const bool last,
402 const uint32_t max_frags);
403
404/*
405 * A variation on the above that ages off fragments that have not been
406 * reassembled. Useful if the sequence number loops to deal with leftover
407 * fragments from the beginning of the capture or missing fragments.
408 */
409WS_DLL_PUBLIC fragment_head *
410fragment_add_seq_single_aging(reassembly_table *table, tvbuff_t *tvb,
411 const int offset, const packet_info *pinfo, const uint32_t id,
412 const void* data, const uint32_t frag_data_len,
413 const bool first, const bool last,
414 const uint32_t max_frags, const uint32_t max_age);
415
416/*
417 * Start a reassembly, expecting "tot_len" as the number of given fragments (not
418 * the number of bytes). Data can be added later using fragment_add_seq_check.
419 */
420WS_DLL_PUBLIC void
421fragment_start_seq_check(reassembly_table *table, const packet_info *pinfo,
422 const uint32_t id, const void *data,
423 const uint32_t tot_len);
424
425/*
426 * Mark end of reassembly and returns the reassembled fragment (if completed).
427 * Use it when fragments were added with "more_flags" set while you discovered
428 * that no more fragments have to be added.
429 * This is for fragments added with add_seq_next; it doesn't check for gaps,
430 * and doesn't set datalen correctly for the fragment_add family.
431 */
432WS_DLL_PUBLIC fragment_head *
433fragment_end_seq_next(reassembly_table *table, const packet_info *pinfo,
434 const uint32_t id, const void *data);
435
436/* To specify the offset for the fragment numbering, the first fragment is added with 0, and
437 * afterwards this offset is set. All additional calls to off_seq_check will calculate
438 * the number in sequence in regards to the offset */
439WS_DLL_PUBLIC void
440fragment_add_seq_offset(reassembly_table *table, const packet_info *pinfo, const uint32_t id,
441 const void *data, const uint32_t fragment_offset);
442
443/*
444 * Sets the expected index for the last block (for fragment_add_seq functions)
445 * or the expected number of bytes (for fragment_add functions). A reassembly
446 * must already have started.
447 *
448 * Note that for FD_BLOCKSEQUENCE tot_len is the index for the tail fragment.
449 * i.e. since the block numbers start at 0, if we specify tot_len==2, that
450 * actually means we want to defragment 3 blocks, block 0, 1 and 2.
451 */
452WS_DLL_PUBLIC void
453fragment_set_tot_len(reassembly_table *table, const packet_info *pinfo,
454 const uint32_t id, const void *data, const uint32_t tot_len);
455
456/*
457 * Similar to fragment_set_tot_len, it sets the expected number of bytes (for
458 * fragment_add functions) for a previously started reassembly. If the specified
459 * length already matches the reassembled length, then nothing will be done.
460 *
461 * If the fragments were previously reassembled, then this state will be
462 * cleared, allowing new fragments to extend the reassembled result again.
463 */
464WS_DLL_PUBLIC void
465fragment_reset_tot_len(reassembly_table *table, const packet_info *pinfo,
466 const uint32_t id, const void *data, const uint32_t tot_len);
467
468/*
469 * Truncates the size of an already defragmented reassembly to tot_len,
470 * discarding past that point, including splitting any fragments in the
471 * middle as necessary. The specified length must be less than or equal
472 * to the reassembled length. (If it already matches the reassembled length,
473 * then nothing will be done.)
474 *
475 * Used for continuous streams like TCP, where the length of a segment cannot
476 * be determined without first reassembling and handing to a subdissector.
477 */
478WS_DLL_PUBLIC void
479fragment_truncate(reassembly_table *table, const packet_info *pinfo,
480 const uint32_t id, const void *data, const uint32_t tot_len);
481
482/*
483 * Return the expected index for the last block (for fragment_add_seq functions)
484 * or the expected number of bytes (for fragment_add functions).
485 */
486WS_DLL_PUBLIC uint32_t
487fragment_get_tot_len(reassembly_table *table, const packet_info *pinfo,
488 const uint32_t id, const void *data);
489
490/*
491 * This function will set the partial reassembly flag(FD_PARTIAL_REASSEMBLY) for a fh.
492 * When this function is called, the fh MUST already exist, i.e.
493 * the fh MUST be created by the initial call to fragment_add() before
494 * this function is called. Also note that this function MUST be called to indicate
495 * a fh will be extended (increase the already stored data). After calling this function,
496 * and if FD_DEFRAGMENTED is set, the reassembly process will be continued.
497 */
498WS_DLL_PUBLIC void
499fragment_set_partial_reassembly(reassembly_table *table,
500 const packet_info *pinfo, const uint32_t id,
501 const void *data);
502
503/* This function is used to check if there is partial or completed reassembly state
504 * matching this packet. I.e. Are there reassembly going on or not for this packet?
505 */
506WS_DLL_PUBLIC fragment_head *
507fragment_get(reassembly_table *table, const packet_info *pinfo,
508 const uint32_t id, const void *data);
509
510/* The same for the reassemble table */
511WS_DLL_PUBLIC fragment_head *
512fragment_get_reassembled_id(reassembly_table *table, const packet_info *pinfo,
513 const uint32_t id);
514
515/* This will free up all resources and delete reassembly state for this PDU.
516 * Except if the PDU is completely reassembled, then it would NOT deallocate the
517 * buffer holding the reassembled data but instead return the TVB
518 *
519 * So, if you call fragment_delete and it returns non-NULL, YOU are responsible to
520 * tvb_free() .
521 */
522WS_DLL_PUBLIC tvbuff_t *
523fragment_delete(reassembly_table *table, const packet_info *pinfo,
524 const uint32_t id, const void *data);
525
526/* This struct holds references to all the tree and field handles used when
527 * displaying the reassembled fragment tree in the packet details view. A
528 * dissector will populate this structure with its own tree and field handles
529 * and then invoke show_fragment_tree to have those items added to the packet
530 * details tree.
531 */
532 typedef struct _fragment_items {
533 int *ett_fragment;
534 int *ett_fragments;
535
536 int *hf_fragments; /* FT_NONE */
537 int *hf_fragment; /* FT_FRAMENUM */
538 int *hf_fragment_overlap; /* FT_BOOLEAN */
539 int *hf_fragment_overlap_conflict; /* FT_BOOLEAN */
540 int *hf_fragment_multiple_tails; /* FT_BOOLEAN */
541 int *hf_fragment_too_long_fragment; /* FT_BOOLEAN */
542 int *hf_fragment_error; /* FT_FRAMENUM */
543 int *hf_fragment_count; /* FT_UINT32 */
544 int *hf_reassembled_in; /* FT_FRAMENUM */
545 int *hf_reassembled_length; /* FT_UINT32 */
546 int *hf_reassembled_data; /* FT_BYTES */
547
548 const char *tag;
549} fragment_items;
550
551WS_DLL_PUBLIC tvbuff_t *
552process_reassembled_data(tvbuff_t *tvb, const int offset, packet_info *pinfo,
553 const char *name, fragment_head *fd_head, const fragment_items *fit,
554 bool *update_col_infop, proto_tree *tree);
555
556WS_DLL_PUBLIC bool
557show_fragment_tree(fragment_head *ipfd_head, const fragment_items *fit,
558 proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb, proto_item **fi);
559
560WS_DLL_PUBLIC bool
561show_fragment_seq_tree(fragment_head *ipfd_head, const fragment_items *fit,
562 proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb, proto_item **fi);
563
564/* Initialize internal structures
565 */
566 extern void reassembly_tables_init(void);
567
568/* Cleanup internal structures
569 */
570 extern void
571reassembly_table_cleanup(void);
572
573/* ===================== Streaming data reassembly helper ===================== */
600#define REASSEMBLE_ITEMS_DEFINE(var_prefix, name_prefix) \
601 static int ett_##var_prefix##_fragment; \
602 static int ett_##var_prefix##_fragments; \
603 static int hf_##var_prefix##_fragments; \
604 static int hf_##var_prefix##_fragment; \
605 static int hf_##var_prefix##_fragment_overlap; \
606 static int hf_##var_prefix##_fragment_overlap_conflicts; \
607 static int hf_##var_prefix##_fragment_multiple_tails; \
608 static int hf_##var_prefix##_fragment_too_long_fragment; \
609 static int hf_##var_prefix##_fragment_error; \
610 static int hf_##var_prefix##_fragment_count; \
611 static int hf_##var_prefix##_reassembled_in; \
612 static int hf_##var_prefix##_reassembled_length; \
613 static int hf_##var_prefix##_reassembled_data; \
614 static int hf_##var_prefix##_segment; \
615 static const fragment_items var_prefix##_fragment_items = { \
616 &ett_##var_prefix##_fragment, \
617 &ett_##var_prefix##_fragments, \
618 &hf_##var_prefix##_fragments, \
619 &hf_##var_prefix##_fragment, \
620 &hf_##var_prefix##_fragment_overlap, \
621 &hf_##var_prefix##_fragment_overlap_conflicts, \
622 &hf_##var_prefix##_fragment_multiple_tails, \
623 &hf_##var_prefix##_fragment_too_long_fragment, \
624 &hf_##var_prefix##_fragment_error, \
625 &hf_##var_prefix##_fragment_count, \
626 &hf_##var_prefix##_reassembled_in, \
627 &hf_##var_prefix##_reassembled_length, \
628 &hf_##var_prefix##_reassembled_data, \
629 name_prefix " fragments" \
630 }
631
679#define REASSEMBLE_INIT_HF_ITEMS(var_prefix, name_prefix, abbrev_prefix) \
680 { &hf_##var_prefix##_fragments, \
681 { "Reassembled " name_prefix " fragments", abbrev_prefix ".fragments", \
682 FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL } \
683 }, \
684 { &hf_##var_prefix##_fragment, \
685 { name_prefix " fragment", abbrev_prefix ".fragment", \
686 FT_FRAMENUM, BASE_NONE, NULL, 0x0, NULL, HFILL } \
687 }, \
688 { &hf_##var_prefix##_fragment_overlap, \
689 { name_prefix " fragment overlap", abbrev_prefix ".fragment.overlap", \
690 FT_BOOLEAN, BASE_NONE, NULL, 0x0, NULL, HFILL } \
691 }, \
692 { &hf_##var_prefix##_fragment_overlap_conflicts, \
693 { name_prefix " fragment overlapping with conflicting data", abbrev_prefix ".fragment.overlap.conflicts", \
694 FT_BOOLEAN, BASE_NONE, NULL, 0x0, NULL, HFILL } \
695 }, \
696 { &hf_##var_prefix##_fragment_multiple_tails, \
697 { name_prefix " has multiple tail fragments", abbrev_prefix ".fragment.multiple_tails", \
698 FT_BOOLEAN, BASE_NONE, NULL, 0x0, NULL, HFILL } \
699 }, \
700 { &hf_##var_prefix##_fragment_too_long_fragment, \
701 { name_prefix " fragment too long", abbrev_prefix ".fragment.too_long_fragment", \
702 FT_BOOLEAN, BASE_NONE, NULL, 0x0, NULL, HFILL } \
703 }, \
704 { &hf_##var_prefix##_fragment_error, \
705 { name_prefix " defragment error", abbrev_prefix ".fragment.error", \
706 FT_FRAMENUM, BASE_NONE, NULL, 0x0, NULL, HFILL } \
707 }, \
708 { &hf_##var_prefix##_fragment_count, \
709 { name_prefix " fragment count", abbrev_prefix ".fragment.count", \
710 FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } \
711 }, \
712 { &hf_##var_prefix##_reassembled_in, \
713 { "Reassembled in", abbrev_prefix ".reassembled.in", \
714 FT_FRAMENUM, BASE_NONE, NULL, 0x0, NULL, HFILL } \
715 }, \
716 { &hf_##var_prefix##_reassembled_length, \
717 { "Reassembled length", abbrev_prefix ".reassembled.length", \
718 FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } \
719 }, \
720 { &hf_##var_prefix##_reassembled_data, \
721 { "Reassembled data", abbrev_prefix ".reassembled.data", \
722 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } \
723 }, \
724 { &hf_##var_prefix##_segment, \
725 { name_prefix " segment", abbrev_prefix ".segment", \
726 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} \
727 }
728
760#define REASSEMBLE_INIT_ETT_ITEMS(var_prefix) \
761 &ett_##var_prefix##_fragment, \
762 &ett_##var_prefix##_fragments
763
765 typedef struct streaming_reassembly_info_t streaming_reassembly_info_t;
766
770WS_DLL_PUBLIC streaming_reassembly_info_t*
771 streaming_reassembly_info_new(void);
772
1138WS_DLL_PUBLIC int
1139 reassemble_streaming_data_and_call_subdissector(
1140 tvbuff_t* tvb, packet_info* pinfo, unsigned offset, int length,
1141 proto_tree* segment_tree, proto_tree* reassembled_tree, reassembly_table streaming_reassembly_table,
1142 streaming_reassembly_info_t* reassembly_info, uint64_t cur_frame_num,
1143 struct dissector_handle* subdissector_handle, proto_tree* subdissector_tree, void* subdissector_data,
1144 const char* label, const fragment_items* frag_hf_items, int hf_segment_data
1145);
1146
1160 static inline uint64_t
1161get_virtual_frame_num64(tvbuff_t* tvb, packet_info* pinfo, int offset)
1162{
1163 return (((uint64_t)pinfo->num) << 32) + (((uint64_t)pinfo->curr_layer_num) << 24)
1164 + ((uint64_t)tvb_raw_offset(tvb) + offset);
1165}
1166
1174WS_DLL_PUBLIC int
1175 additional_bytes_expected_to_complete_reassembly(streaming_reassembly_info_t* reassembly_info);
1176
1177/* ========================================================================= */
1178
1179#ifdef __cplusplus
1180}
1181#endif
1182
1183#endif
tvb_raw_offset
unsigned tvb_raw_offset(tvbuff_t *tvb)
Returns the offset from the first byte of real data.
Definition tvbuff.c:5213
packet_info.h
proto.h
streaming_reassembly_info_new
WS_DLL_PUBLIC streaming_reassembly_info_t * streaming_reassembly_info_new(void)
Definition reassemble.c:3232
additional_bytes_expected_to_complete_reassembly
WS_DLL_PUBLIC int additional_bytes_expected_to_complete_reassembly(streaming_reassembly_info_t *reassembly_info)
Definition reassemble.c:3556
reassemble_streaming_data_and_call_subdissector
WS_DLL_PUBLIC int reassemble_streaming_data_and_call_subdissector(tvbuff_t *tvb, packet_info *pinfo, unsigned offset, int length, proto_tree *segment_tree, proto_tree *reassembled_tree, reassembly_table streaming_reassembly_table, streaming_reassembly_info_t *reassembly_info, uint64_t cur_frame_num, struct dissector_handle *subdissector_handle, proto_tree *subdissector_tree, void *subdissector_data, const char *label, const fragment_items *frag_hf_items, int hf_segment_data)
_fragment_head
Definition reassemble.h:72
_fragment_head::ref_count
unsigned ref_count
Definition reassemble.h:76
_fragment_head::flags
uint32_t flags
Definition reassemble.h:97
_fragment_head::error
const char * error
Definition reassemble.h:105
_fragment_head::first_gap
struct _fragment_item * first_gap
Definition reassemble.h:74
_fragment_head::len
uint32_t len
Definition reassemble.h:79
_fragment_head::contiguous_len
uint32_t contiguous_len
Definition reassemble.h:77
_fragment_head::datalen
uint32_t datalen
Definition reassemble.h:85
_fragment_head::reassembled_in
uint32_t reassembled_in
Definition reassemble.h:91
_fragment_head::fragment_nr_offset
uint32_t fragment_nr_offset
Definition reassemble.h:82
_fragment_head::reas_in_layer_num
uint8_t reas_in_layer_num
Definition reassemble.h:93
_fragment_head::frame
uint32_t frame
Definition reassemble.h:78
_fragment_item
Definition reassemble.h:60
_fragment_item::frame
uint32_t frame
Definition reassemble.h:62
_fragment_item::flags
uint32_t flags
Definition reassemble.h:66
_fragment_item::len
uint32_t len
Definition reassemble.h:65
_fragment_item::offset
uint32_t offset
Definition reassemble.h:63
_fragment_items
Definition reassemble.h:532
_packet_info
Definition packet_info.h:43
_packet_info::num
uint32_t num
Definition packet_info.h:47
_packet_info::curr_layer_num
uint8_t curr_layer_num
Definition packet_info.h:150
_proto_node
Definition proto.h:907
dissector_handle
Definition packet.c:852
reassembly_table_functions
Definition reassemble.h:157
reassembly_table
Definition reassemble.h:146
streaming_reassembly_info_t
Definition reassemble.c:3209
tvbuff
Definition tvbuff-int.h:36