aboutsummaryrefslogtreecommitdiffstats
path: root/epan/reassemble_test.c
AgeCommit message (Collapse)AuthorFilesLines
2023-09-17reassemble: Set overlap flags instead of throwing exceptionJohn Thacker1-50/+7
Have the byte offset based fragment_add() routines work like the fragment sequence number based _seq() routines and set overlap flags instead of throwing a ReassemblyError for a new fragment after the reassembly is finished. It's not that unusual to have a retransmission in such a case, and adding a Malformed expert info seems worse than linking to the frame number of the original reassembly. Change the reassemble test to account for that. Add some comments to the header file for the reassembly functions about when to use each function and their respective limitations.
2022-11-14epan: Separate fragment_head and fragment_itemJohn Thacker1-44/+23
Separate fragment_head and fragment_item into two different types of structs. Remove "offset" from fragment_head, which was unused, making fragment heads 4 bytes smaller. Remove fragment_nr_offset, datalen, reassembled_in, reas_in_layer_num, and error from fragment_item, making them 24 bytes smaller. Change a few dissectors which were using fragment_head and fragment_item indistinguishably. Ping #17311
2021-12-22Corrects repeated words throughout the code.Moshe Kaplan1-2/+2
Repeated words were found with: egrep "(\b[a-zA-Z]+) +\1\b" . -Ir and then manually reviewed. Non-displayed strings (e.g., in comments) were also corrected, to ease future review.
2021-09-25reassemble_test: Add an explicit cast [-Wformat=]João Valverde1-1/+1
2021-06-19Replace g_assert() with ws_assert()João Valverde1-2/+2
2021-02-21Fix reassemble_test's additional debug mode.Darius Davis1-74/+79
It has bit-rotted. Replace a bunch of compile-out "#if 0" with runtime "if (0)", and the "#ifdef debug" with a static const, both of which should reduce the chance of this bit-rotting again in future by ensuring that these code paths will at least be compiled -- even if they are not actively used. The default is kept at FALSE, so the behavior is unchanged, and toggling it still requires recompilation. fd->data no longer exists; The nearest equivalent uses (dangerous!) tvb_get_ptr to dump the address of the first byte of the tvb data, in case that is somehow useful... I'm guessing it exists for live debugging. We no longer have access to the structures for the hash keys. For the time being, let's just #ifdef out the code that tries to print those keys. Maybe we should move the key structures to an epan/reassemble-int.h so that we can access them from this test code again...? And zap an extra comma which snuck into a table... Clearly this code hasn't been compiled in a while. Tested with debug=FALSE and debug=TRUE, under Valgrind as well as natively, on a Linux host.
2020-12-10Reassembly: Flag duplicate packets as overlaps in offset based reassemblyJohn Thacker1-1/+1768
fragment_add_work() should flag duplicate packets and overlapping packets that are subsets of the existing reassembly as overlaps (and flag them if there are conflicts), instead of silently adding them to the reassembly. Currently the checks are only performed when the new segment is adding additional bytes to the reassembly. This is particularly useful for identifying when an earlier reassembly isn't fully contained in the capture, and the identification / offset number has wrapped around so that segments during two different reassemblies are being mixed together. Closes #16872 and #15569.
2020-07-01tests: Try to squelch [-Wpointer-sign] warnings.Anders Broman1-2/+2
Change-Id: I78bba8e39c14c1f6c5b31a79e327cbaf21473a17 Reviewed-on: https://code.wireshark.org/review/37633 Petri-Dish: Anders Broman <a.broman58@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-06-01Fix some cppcheck issues:Martin Mathieson1-2/+2
- Some redundant assignments or tests. - Some declarations were changed to match definitions in terms of including _U_ for the same parameters - Some parenthesis added/changed to made precedence more obvious epan/color_filters.c:533: style: Variable 'name' is reassigned a value before the old one has been used. epan/color_filters.c:534: style: Variable 'filter_exp' is reassigned a value before the old one has been used. asn1/tcap/packet-tcap-template.c:2199: warning: Function 'dissect_tcap_ITU_ComponentPDU' argument order different: declaration '_U_, tvb, offset, _U_, tree, _U_' definition '_U_, tvb, offset, actx, tree, _U_' epan/dissectors/packet-aim.c:2546: warning: Function 'dissect_aim_tlv_value_icq' argument order different: declaration 'ti, subtype, tvb, _U_' definition 'ti, _U_, tvb, pinfo' epan/dissectors/packet-arp.c:1133: style: Clarify calculation precedence for '&' and '?'. epan/dissectors/packet-arp.c:1143: style: Clarify calculation precedence for '&' and '?'. epan/dissectors/packet-arp.c:1158: style: Clarify calculation precedence for '&' and '?'. epan/dissectors/packet-arp.c:1168: style: Clarify calculation precedence for '&' and '?'. epan/dissectors/packet-gtpv2.c:5997: warning: Function 'dissect_gtpv2_mbms_service_area' argument order different: declaration 'tvb, _U_, tree, _U_, _U_, _U_, _U_, _U_' definition 'tvb, _U_, tree, item, _U_, _U_, _U_, _U_' epan/dissectors/packet-gtpv2.c:6291: warning: Function 'dissect_gtpv2_mbms_time_to_data_xfer' argument order different: declaration 'tvb, _U_, tree, _U_, _U_, _U_, _U_, _U_' definition 'tvb, _U_, tree, item, _U_, _U_, _U_, _U_' epan/dissectors/packet-gtpv2.c:6369: warning: Function 'dissect_gtpv2_epc_timer' argument order different: declaration 'tvb, _U_, tree, _U_, _U_, _U_, _U_, _U_' definition 'tvb, _U_, tree, item, _U_, message_type, _U_, _U_' epan/dissectors/packet-knxip.c:2939: style: Condition 'mac_error' is always false (just added comment) epan/dissectors/packet-mac-lte.c:4386: style: Clarify calculation precedence for '&' and '?'. epan/dissectors/packet-nas_5gs.c:1828: style: Variable 'nas5gs_data->payload_container_type' is reassigned a value before the old one has been used. (noted confusing recursion) epan/dissectors/packet-rpcrdma.c:587: warning: Identical condition 'offset>max_offset', second condition is always false epan/dissectors/packet-rsl.c:2098: style: Assignment of function parameter has no effect outside the function. Change-Id: Ib5c9a04cfb6e6233972bc041434601c8ef09c969 Reviewed-on: https://code.wireshark.org/review/37343 Petri-Dish: Martin Mathieson <martin.r.mathieson@googlemail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Martin Mathieson <martin.r.mathieson@googlemail.com>
2019-07-26HTTPS (almost) everywhere.Guy Harris1-1/+1
Change all wireshark.org URLs to use https. Fix some broken links while we're at it. Change-Id: I161bf8eeca43b8027605acea666032da86f5ea1c Reviewed-on: https://code.wireshark.org/review/34089 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-03-19reassemble_test: Fix some compiler warnings.Gerald Combs1-2/+2
Fix ../epan/reassemble_test.c:394:23: warning: cast from 'const unsigned char *' to 'void *' drops const qualifier [-Wcast-qual] ASSERT_EQ_POINTER(tvb_get_ptr(fd_head->tvb_data,0,0),tvb_get_ptr(fd->tvb_data,0,0)); ^ ../epan/reassemble_test.c:394:58: warning: cast from 'const unsigned char *' to 'void *' drops const qualifier [-Wcast-qual] ASSERT_EQ_POINTER(tvb_get_ptr(fd_head->tvb_data,0,0),tvb_get_ptr(fd->tvb_data,0,0)); ^ ../epan/reassemble_test.c:429:23: warning: cast from 'const unsigned char *' to 'void *' drops const qualifier [-Wcast-qual] ASSERT_EQ_POINTER(tvb_get_ptr(fd_head->tvb_data,0,0),tvb_get_ptr(fd->tvb_data,0,0)); ^ ../epan/reassemble_test.c:429:58: warning: cast from 'const unsigned char *' to 'void *' drops const qualifier [-Wcast-qual] ASSERT_EQ_POINTER(tvb_get_ptr(fd_head->tvb_data,0,0),tvb_get_ptr(fd->tvb_data,0,0)); Change-Id: I17c4a28b1d2893b1c2acae14dec498baadfd0646 Reviewed-on: https://code.wireshark.org/review/32477 Reviewed-by: Gerald Combs <gerald@wireshark.org> Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-12-27Try to squeeze some bytes out of the frame_data structure.Guy Harris1-10/+10
Make the time stamp precision a 4-bit bitfield, so, when combined with the other bitfields, we have 32 bits. That means we put the flags at the same structure level as the time stamp precision, so they can be combined; that gets rid of an extra "flags." for references to the flags. Put the two pointers next to each other, and after a multiple of 8 bytes worth of other fields, so that there's no padding before or between them. It's still not down to 64 bytes, which is the next lower power of 2, so there's more work to do. Change-Id: I6f3e9d9f6f48137bbee8f100c152d2c42adb8fbe Reviewed-on: https://code.wireshark.org/review/31213 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-07-23reassemble_test: Fix argument type warnings.Gerald Combs1-2/+2
Try to fix ../epan/reassemble_test.c:70:16: warning: format '%p' expects argument of type 'void *', but argument 6 has type 'fragment_head * {aka struct _fragment_item *}' [-Wformat=] and similar warnings. Change-Id: Ied2d2f7b7a3e6fa29d51c10f17199decdecfa81c Reviewed-on: https://code.wireshark.org/review/28839 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-05-17reasemble_test: fix issue found by PVS Studio (V519)Alexis La Goutte1-1/+1
The 'fd_head' variable is assigned values twice successively. Change-Id: Ia30f4135f35d5ece369b9648db3ebe5a13e8ccaa Reviewed-on: https://code.wireshark.org/review/27592 Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-02-08epan: use SPDX indentifiers.Dario Lombardo1-13/+1
Skipping dissectors dir for now. Change-Id: I717b66bfbc7cc81b83f8c2cbc011fcad643796aa Reviewed-on: https://code.wireshark.org/review/25694 Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-11-03Fragmentation reassembly as in PPP MP (RFC 1990/2686)John A. Thacker1-14/+14
Add support for defragmentation of fragments that use the defragmentation scheme of PPP MP (RFC 1990). Instead of getting "sequence_number, fragment_number, last" as in other protocols, PPP MP provides a single sequence number that is effectively "seqnum + fragnum", though it provides flags for both the first and last fragment of a reassembly. See Appendix A of RFC 4623 (PWE3 Fragmentation and Reassembly) for a list of protocols that use this style, including PPP MP (RFC 1990), PWE3 MPLS (RFC 4385), L2TPv2 (RFC 2661), L2TPv3 (RFC 3931), ATM, and Frame Relay. Also add support for the Multi-class Extension to Multilink PPP (RFC 2686), which uses some of the previously reserved bits as classes that distinguish otherwise identical sequence numbers. Bug: 12548 Change-Id: Ic2ce3c50e61ab2eb50e4d92fd353ca4d2a48fe18 Reviewed-on: https://code.wireshark.org/review/16327 Reviewed-by: Michael Mann <mmann78@netscape.net> Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-07-16Another attempt to squash warnings from printf use in reassemble_test.cMichael Mann1-1/+1
Change-Id: Ieae9466c6785cf931fc96f8e216c0c1383a5b6a2 Reviewed-on: https://code.wireshark.org/review/16489 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-07-15reassemble_test.c: Fix checking macros with correct printf style arguments.Michael Mann1-172/+178
Complaints of VS Code Analysis Change-Id: Ib5a4649b78ae4c9109249e915c04481ae7fa5524 Reviewed-on: https://code.wireshark.org/review/16472 Petri-Dish: Michael Mann <mmann78@netscape.net> Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-07-15reassemble_test.c: Reorder macro behavior to make it clearer we have NULL ↵Michael Mann1-21/+20
checks in place. Trying to pacify VS Code Analysis. Change-Id: I76379b23a5d4c772b91d6113af3974e105e4da88 Reviewed-on: https://code.wireshark.org/review/16448 Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-04-03reassemble: remove special treatment for truncated dataPeter Wu1-1/+6
Do not try to recover from truncated tvbs for fragment_add_seq-like functions: - If it is the first block and the dissector requested frag_data_len number of bytes, we should not lie and pretend that we are fully reassembled. - For other blocks, returning NULL as no reassembly was possible makes sense. But other fragments in the list should not be cleared as there may be partial fragments which were returned before. It seems that this special behavior was introduced in b2c11b5e13248b1c98ee5104eab411e842911e19 (freeing fragments and returning NULL as an optimization when fragments are deemed not needed anymore) and faeb2c2ee16e61e54c880163e98d6528dd0c5619 (for returning fd_head for the first fragment, "so the first fragment gets dissected as fragmented packet"). Now in theory unused fragments could stick around, but that also possible with the normal fragment_add functions. Bug: 11799 Change-Id: I20829c54e1b2eee25a91fe4de51b19b1458c7789 Reviewed-on: https://code.wireshark.org/review/14082 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Peter Wu <peter@lekensteyn.nl> Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-01-24Fix reassembly test broken by gbc5a037Pascal Quantin1-2/+2
Change-Id: I8bcde5fd5039b77eccd9327cb7f0558b4fdedc36 Reviewed-on: https://code.wireshark.org/review/13515 Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2016-01-24Add the packet number to the packet_info structure, and use it.Guy Harris1-50/+50
That removes most of the uses of the frame number field in the frame_data structure. Change-Id: Ie22e4533e87f8360d7c0a61ca6ffb796cc233f22 Reviewed-on: https://code.wireshark.org/review/13509 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-10-22Use address functions instead of ADDRESS macros in asn1 and epanGerald Combs1-2/+2
Replace CMP_ADDRESS, COPY_ADDRESS, et al with their lower-case equivalents in the asn1 and epan directories. Change-Id: I4043b0931d4353d60cffbd829e30269eb8d08cf4 Reviewed-on: https://code.wireshark.org/review/11200 Petri-Dish: Michal Labedzki <michal.labedzki@tieto.com> Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-02-06More emem removal.Jeff Morriss1-5/+0
Remove emem's 8-byte-memory-alignment configure check as well as references to all the environment variables emem used. Change-Id: I897aec9e9c68e064454561e7a9f066b18892ec66 Reviewed-on: https://code.wireshark.org/review/6950 Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-02-04emem is dead! Long live wmem!Michael Mann1-4/+0
Change-Id: Iddd1200e62bf3200cb1a68408378dd9d47120b77 Reviewed-on: https://code.wireshark.org/review/6939 Reviewed-by: Michael Mann <mmann78@netscape.net> Petri-Dish: Michael Mann <mmann78@netscape.net> Reviewed-by: Evan Huus <eapache@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-01-18This currently requires emem.h.Guy Harris1-0/+1
Change-Id: I55cca8de9be07fbec4e771c0f6d50075fc75bef8 Reviewed-on: https://code.wireshark.org/review/6642 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-01-18Remove some apparently-unnecessary includes of emem.h.Guy Harris1-1/+0
Change-Id: Ib7d1b587b439ff21ec6b7f1756ce6ccf25b66f80 Reviewed-on: https://code.wireshark.org/review/6635 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-10-10Add editor modelines; Adjust whitespace as needed.Bill Meier1-4/+17
Change-Id: I3dc57f4c2ca57585103e3b71503ac4c332903e50 Reviewed-on: https://code.wireshark.org/review/4594 Reviewed-by: Bill Meier <wmeier@newsguy.com>
2014-03-04Remove all $Id$ from top of fileAlexis La Goutte1-2/+0
(Using sed : sed -i '/^ \* \$Id\$/,+1 d') Fix manually some typo (in export_object_dicom.c and crc16-plain.c) Change-Id: I4c1ae68d1c4afeace8cb195b53c715cf9e1227a8 Reviewed-on: https://code.wireshark.org/review/497 Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-02-25Remove trailing whitespaceBill Meier1-2/+2
Change-Id: I8116f63ff88687c8db3fd6e8e23b22ab2f759af0 Reviewed-on: https://code.wireshark.org/review/385 Reviewed-by: Bill Meier <wmeier@newsguy.com> Tested-by: Bill Meier <wmeier@newsguy.com>
2013-07-17Remove fragment_data, add fragment_head, fragment_item - for now alias it to ↵Jakub Zawadzki1-23/+24
the same structure. This is begin of work to split fragment head and fragments items. svn path=/trunk/; revision=50708
2013-07-14Rewrite reassemble API to use TVBs instead of raw data.Jakub Zawadzki1-91/+91
(it seems to be working for TCP ^^) svn path=/trunk/; revision=50580
2013-07-14Squelch a "not permitted in C++" warning.Guy Harris1-1/+1
svn path=/trunk/; revision=50574
2013-03-23Get rid of the DCE RPC stuff; these tests should test the code path forGuy Harris1-101/+2
all types of keys. Make the tables in main static, so we don't initialize them at run time; perhaps that'll help figure out why reassemble_test is crashing on Windows apparently before even calling emem_init(). svn path=/trunk/; revision=48513
2013-03-23Update to match the changes made to the reassembly code APIs.Guy Harris1-221/+217
svn path=/trunk/; revision=48493
2012-09-20We always HAVE_CONFIG_H so don't bother checking whether we have it or not.Jeff Morriss1-3/+1
svn path=/trunk/; revision=45016
2012-06-28Update Free Software Foundation address.Jakub Zawadzki1-1/+1
(COPYING will be updated in next commit) svn path=/trunk/; revision=43536
2012-02-28OK, to heck with it - link reassemble_test with libwireshark. Trying toGuy Harris1-50/+0
selectively pick up particular object files is just too much of a mess. Alas, this requires that we add some additional symbols to the list exported by libwireshark; the DCE RPC ones shouldn't be global, but reassemble_test uses them, so.... Get rid of stubs in reassemble_test.c - they just stub out routines from libwireshark, but that's not necessary any more. svn path=/trunk/; revision=41223
2011-07-11More GLIB_CHECK_VERSION cleanups. Update the minimum GLib/GTK+ versionsGerald Combs1-2/+0
in README.devloper. Remove g_gnuc.h since it's no longer needed. Remove tvbuff_init(), tvbuff_cleanup(), reassemble_init(), and reassemble_cleanup() since they were only used for older GLib versions which didn't support GSlices. Assume we always support the "matches" operator. svn path=/trunk/; revision=37978
2011-03-03Add more duplicate fragment tests.Jeff Morriss1-14/+212
svn path=/trunk/; revision=36132
2011-03-03When reassembling fragments, don't stop looking at fragments just because theJeff Morriss1-0/+203
current fragment pushes us past the reassembled size: it may be that the current fragment is a duplicate/retransmission and will be ignored. Also, if we detect a conflict between a previous and the current fragment, flag the current (conflicting) fragment as FD_OVERLAPCONFLICT. Do *not* flag the fragment that got us into the reassembly routine (probably the final fragment): it is not (may not be) the guilty fragment. Clean up some spacing. Also add reassembly tests for duplicate/retransmitted fragments. svn path=/trunk/; revision=36131
2010-12-10Additions to allow the valgrind to test for reassembly.c memory leaks.Bill Meier1-6/+240
Specifically: free all dynamically allocated memory after each test (or at program completion). Also: add some debug functions (conditionally enabled) to print information about the fragment_table and reassembled_table fd-chains. svn path=/trunk/; revision=35172
2010-10-30Rev 29427 added packet_add_new_data_source() with a comment indicating thatJeff Morriss1-4/+0
the data source does not need to be allocated if (!tree). Rev 30158 took the if (!tree) check out indicating that the check was invalid. So: (since packet_add_new_data_source() now only calls add_new_data_source()), remove packet_add_new_data_source(). svn path=/trunk/; revision=34717
2010-09-30Get reassemble_test building again (after 34285).Jeff Morriss1-0/+5
svn path=/trunk/; revision=34296
2010-09-08Fake proto_item_prepend_text() in reassemble_test.Stig Bjørlykke1-0/+3
svn path=/trunk/; revision=34075
2010-05-24Use the new name for the last argument to proto_tree_add_item().Guy Harris1-1/+1
svn path=/trunk/; revision=32935
2010-05-24Fix reassemble_test's (copy of the) proto_tree_add_item() prototype to get itJeff Morriss1-4/+4
compiling again. fragment_add_seq_check(), fragment_add_seq_802_11(), and fragment_add_seq_next() all call fragment_add_seq_check_work() so make their prototypes match each other in const-ness. This fixes a warning when compiling reassemble_test. svn path=/trunk/; revision=32933
2010-04-04Fix to match changes to the signatures of the real versions of thoseGuy Harris1-6/+7
functions. svn path=/trunk/; revision=32370
2010-02-24Mark variables as staticKovarththanan Rajaratnam1-5/+6
svn path=/trunk/; revision=31983
2010-02-24We already pull in glib.h so use gboolean instead of int to declare boolean ↵Kovarththanan Rajaratnam1-2/+3
types. svn path=/trunk/; revision=31982