aboutsummaryrefslogtreecommitdiffstats
path: root/file.c
Commit message (Collapse)AuthorAgeFilesLines
* Qt: Add check for field extractorsStig Bjørlykke2016-02-051-5/+5
| | | | | | | | | | | | | | | | | | | | | The proto tree is needed in several cases when using Lua field extractors, because they fetch values from the tree. Without a valid field extractor a Lua plugin may misbehave and display wrong column info. This fixes column issues when: - Calling resetColumns() in Qt. This involves adding a display filter, change time display format, change name resolution and other changes in UI which requires column updates. - Print summary lines. - Export as CSV and PSML. Change-Id: Ieed6f8578cdf2759f1f836cd8413a4529b7bbd80 Reviewed-on: https://code.wireshark.org/review/13708 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com> Reviewed-on: https://code.wireshark.org/review/13722 Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
* Don’t adjust time column widths in cf_openStig Bjørlykke2016-02-051-3/+0
| | | | | | | | | | | | | | | | | | | | | The time column widths should not be adjusted in cf_open() because we don’t have any packets yet and Qt resizeColumnToContents() will not adjust any widths but emits a sectionResized() with invalid or default values (new_width seems to always be 32). This will in some cases (when start capturing packets) give wrong width values which is later stored in the recent file, and the time columns may end up narrow the next time the recent file is read. This fix is related to the column with issues previously compensated for in PacketList::sectionResized() (g4980d505). Change-Id: Id3b49069fe5d2b55d608cc7a6d32fe7851369bf9 Reviewed-on: https://code.wireshark.org/review/13712 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com> (cherry picked from commit 651d860d9038a30de1453c5315eb09a95622c199) Reviewed-on: https://code.wireshark.org/review/13720
* GTK: plugin_if_goto_frame can cause an Access ViolationPaul Offord2016-01-101-2/+2
| | | | | | | | | | | | | | | | This is a fix for bug 11989. This patch fixes the problem for the GTK variant of Wireshark and matches the Qt bug reported by bug 11810 and fixed by change 12306. Bug: 11989 Change-Id: Ib9af8ba745394ebd31825003361ec637c45d75d6 Reviewed-on: https://code.wireshark.org/review/13152 Petri-Dish: Roland Knall <rknall@gmail.com> Reviewed-by: Roland Knall <rknall@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> (cherry picked from commit 9c3044e1641a72b5c2b7b0959f28d9600c39f62a) Reviewed-on: https://code.wireshark.org/review/13162 Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
* Fix to avoid protection exception in cf_goto_framePaul Offord2015-12-011-0/+6
| | | | | | | | | | | | | | | | | A call to plugin_if_goto_frame when there is no capture file loaded causes a protection exception in cf_goto_file. This fix avoids that problem. Bug: 11810 Change-Id: I7e6f31690a4b0d8d4252b41d8d438979cb253050 Reviewed-on: https://code.wireshark.org/review/12306 Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com> Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Reviewed-by: Roland Knall <rknall@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com> (cherry picked from commit f15bc8f78eae74bca57ebf7063b6a7b1979c5c08) Reviewed-on: https://code.wireshark.org/review/12342
* epan: Free pointers to deallocated memoryStig Bjørlykke2015-11-231-0/+6
| | | | | | | | | | | | | | | | | When redissecting packets we call epan_free() which deallocates wmem_file_scope memory. Such memory may be used in proto_data for the currently selected packet (cf->edt) and leaves pointers to deallocated memory (cf->edt->pi.fd->pfd). Free them after epan_free() to avoid unintended usage in packet_list_clear(). Bug: 11740 Change-Id: Ia3bc54f3f34e644a98b8a7eb1addd19b8aeeaab9 Reviewed-on: https://code.wireshark.org/review/11996 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com> (cherry picked from commit 391f11a7ec16045ed5909d617edcaada1f8f9afc) Reviewed-on: https://code.wireshark.org/review/12053
* Revert: Free cf->edt before free cf->epan when redissecting.Gerald Combs2015-11-181-4/+0
| | | | | | | | | | | | | | | | | Instead of freeing cf->edt before clearing the packet list, add an extra check to MainWindow::setMenusForSelectedTreeRow. Semi-blind attempt at fixing bug 11719. This reverts commit 8c211d51ef66b64c708f7ad079e7e7e913ac9f14. This reverts commit da71ccbf778cca5d9c48e010597570a40fd190c0. Bug: 11719 Change-Id: Ifd07be414ffd03a40bdfa7110395c9542bd86fc4 Reviewed-on: https://code.wireshark.org/review/11943 Petri-Dish: Gerald Combs <gerald@wireshark.org> Reviewed-by: Gerald Combs <gerald@wireshark.org> (cherry picked from commit 3d3eb159a757c1b7f3abc0d2c81f8e38e206243b) Reviewed-on: https://code.wireshark.org/review/11953
* epan: Check for valid cf->edt before free.Stig Bjørlykke2015-11-181-2/+4
| | | | | | | | | | | | | Added a check for a valid cf->edt before calling epan_dissect_free(), as this will give an unintended assert. This is related to da71ccbf778cca5d9c48e010597570a40fd190c0. Change-Id: I7f7ceb1b25cfa2400063947f674df10ed6a93e9d Reviewed-on: https://code.wireshark.org/review/11934 Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org> (cherry picked from commit 8c211d51ef66b64c708f7ad079e7e7e913ac9f14) Reviewed-on: https://code.wireshark.org/review/11935
* epan: Free cf->edt before free cf->epan when redissecting.Stig Bjørlykke2015-11-131-0/+2
| | | | | | | | | | | | | | This because cf->edt->pi is pointing to data allocated in wmem_file_scope and epan_free() will free all data in wmem_file_scope. In Qt packet_list_clear() we check and use cf->edt, which will give a heap-use-after-free error. Change-Id: I97d532ba976b7bc5fe2995a224ca168edf3da38b Reviewed-on: https://code.wireshark.org/review/11803 Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org> (cherry picked from commit da71ccbf778cca5d9c48e010597570a40fd190c0) Reviewed-on: https://code.wireshark.org/review/11806
* file.c: do not try to close a file descriptor that was previously already closedPascal Quantin2015-11-101-1/+4
| | | | | | | | | | | | | Bug: 11684 Change-Id: Iaaa5958ea6192ef52b669c687082469b8c7c0219 Reviewed-on: https://code.wireshark.org/review/11656 Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com> Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Jim Young <jim.young.ws@gmail.com> Reviewed-by: Anders Broman <a.broman58@gmail.com> (cherry picked from commit 20a7e7fe42dfa9e5de91ebfffc2cfd128099fa6a) Reviewed-on: https://code.wireshark.org/review/11668
* file.c: fix resource leak reported by Coverity (CID 1159387)Pascal Quantin2015-10-051-1/+1
| | | | | | | | | | Change-Id: I24f85f41bcb0c3a0dda0b6658dbfdb4098eb64b9 Reviewed-on: https://code.wireshark.org/review/10796 Reviewed-by: Dario Lombardo <lomato@gmail.com> Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com> Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
* file.c: do not rescan packets is no capture file is openedPascal Quantin2015-09-291-4/+6
| | | | | | | | | | | | Otherwise we will end up calling cf_cb_file_rescan_started and cf_cb_file_rescan_finished callbacks while no capture file is available Bug: 11552 Change-Id: Ib6fd7b13ce1b083d5f5b4e05d80152112c1451f6 Reviewed-on: https://code.wireshark.org/review/10692 Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com> Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Gerald Combs <gerald@wireshark.org>
* Call cf_cb_file_rescan_* callbacks in rescan_packets.Gerald Combs2015-09-201-0/+4
| | | | | | | | | | | | | | We call cf_cb_file_rescan_{started,finished} in rescan_file. Do the same in rescan_packets. In the Qt UI this ensures that flushVisibleRows gets called so that packet_list_select_row_from_data works as expected. Change-Id: I425b7beb0f97a7d5b84c979fca65b877673b4722 Reviewed-on: https://code.wireshark.org/review/10569 Reviewed-by: Gerald Combs <gerald@wireshark.org> Petri-Dish: Gerald Combs <gerald@wireshark.org> Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
* Rework tapping in Qt dialogs.Gerald Combs2015-08-261-0/+4
| | | | | | | | | | | | | | | | | | | | | | Add cf_cb_file_retap_started and cf_cb_file_retap_finished to file.[ch]. Add their associated signals to CaptureFile. Add registerTapListener and removeTapListeners to WiresharkDialog, which collect and automatically remove tap listeners. Add beginRetapPackets and endRetapPackets, which can be used to wrap critical sections so that we don't delete ourselves while tapping. Don't cancel tapping on close in WiresharkDialog. Use beginRetapPackets and endRetapPackets in WiresharkDialog and FollowStreamDialog. We will likely need to add them elsewhere. Update comments. Change-Id: I1788a6ade0817c31aa3419216df96be5e36b2178 Reviewed-on: https://code.wireshark.org/review/10261 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Gerald Combs <gerald@wireshark.org>
* Improve file merging for mergecap and wiresharkHadriel Kaplan2015-08-181-371/+144
| | | | | | | | | | | | | | | | | | | | | | | | Refactor the file merging code by removing the duplicate logic from mergecap.c and file.c's cf_merge_files(), into a new merge_files() function in merge.c. Also the following user-visible changes: * Removed the '-T' encap type option from mergecap, as it's illogical for mergecap and would complicate common merge code. * Input files with IDBs of different name, speed, tsprecision, etc., will produce an output PCAPNG file with separate IDBs, even if their encap types are the same. * Added a '-I' IDB merge mode option for mergecap, to control how IDBs are merged. * Changed Wireshark's drag-and-drop merging to use PCAPNG instead of PCAP. Bug: 8795 Bug: 7381 Change-Id: Icc30d217e093d6f40114422204afd2e332834f71 Reviewed-on: https://code.wireshark.org/review/10058 Petri-Dish: Hadriel Kaplan <hadrielk@yahoo.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
* Pcapng: clean up Section Header Block handlingHadriel Kaplan2015-08-181-27/+10
| | | | | | | | | Change-Id: I8516d0c561ed0b63e49a3594027c9c15bb789258 Reviewed-on: https://code.wireshark.org/review/9726 Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com> Petri-Dish: Hadriel Kaplan <hadrielk@yahoo.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
* Pcapng: support Name Resolution Block optionsHadriel Kaplan2015-08-061-8/+18
| | | | | | | | | | | | Make pcapng decode options in an NRB during read, and store the comment option, and write it back out as well. Also make it handle plugin handlers for unknown options in received NRB(s). Change-Id: I81863ef8d85cb1c8b5ba6673ba0e562efe77714f Reviewed-on: https://code.wireshark.org/review/9723 Petri-Dish: Hadriel Kaplan <hadrielk@yahoo.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
* Do error checking on simple_error_message_box() calls and fix errors.Guy Harris2015-07-041-2/+2
| | | | | | | | | It's a printf-like routine, so give it the right declaration. Fix errors that this finds. Change-Id: I7e8c100ff9e16ba89743ce744cbf548aae705b77 Reviewed-on: https://code.wireshark.org/review/9487 Reviewed-by: Guy Harris <guy@alum.mit.edu>
* Take all epan_column_info members that always get allocated to "number of ↵Michael Mann2015-06-291-10/+12
| | | | | | | | | | columns" to share their own data structure. Change-Id: Ib982662db6cf68730a7d121eac60d9bc5ae67429 Reviewed-on: https://code.wireshark.org/review/9195 Petri-Dish: Michael Mann <mmann78@netscape.net> Reviewed-by: Anders Broman <a.broman58@gmail.com> Reviewed-by: Michael Mann <mmann78@netscape.net>
* mergecap: check input files time precision before exporting to pcapng formatPascal Quantin2015-06-251-1/+1
| | | | | | | | | | | Bug: 11202 Change-Id: I0891235e9fd41687a12eb8c7e05048e25de3d8b9 Reviewed-on: https://code.wireshark.org/review/9137 Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com> Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Reviewed-by: Evan Huus <eapache@gmail.com> Reviewed-by: Peter Wu <peter@lekensteyn.nl> Reviewed-by: Anders Broman <a.broman58@gmail.com>
* Qt: fix crashes when Wireshark is closed while running a captureMartin Kaiser2015-06-251-1/+1
| | | | | | | | | | | | | | | | | | | | if we haven't captured any packets yet, don't display a warning about unsaved changes make sure that we're not running into a scenario where MainWindow::testCaptureFileClose() tries to close the capture file at the same time as the pipe handler who sees an eof on the pipe cf_has_unsaved_data() should return false if we have a temporary file that contains no packets Change-Id: I18d75bd658b85d45dd3313d49e2cd654c6300de5 Reviewed-on: https://code.wireshark.org/review/9109 Reviewed-by: Evan Huus <eapache@gmail.com> Petri-Dish: Anders Broman <a.broman58@gmail.com> Petri-Dish: Gerald Combs <gerald@wireshark.org> Petri-Dish: Martin Kaiser <wireshark@kaiser.cx> Reviewed-by: Anders Broman <a.broman58@gmail.com>
* file.c: fix Fix Branch condition evaluates to a garbage value found by Clang ↵Alexis La Goutte2015-06-241-1/+1
| | | | | | | | Analyzer Change-Id: Ib7c9e114973f78775cf17889b6aeab217cb6d0ef Reviewed-on: https://code.wireshark.org/review/9101 Reviewed-by: Anders Broman <a.broman58@gmail.com>
* Morph ProgressBar into CaptureProgressFrame.Gerald Combs2015-06-231-24/+20
| | | | | | | | | | | | | | | | | Switch from a plain QProgressBar to a QFrame with a QProgressBar and a stop button. Add a stop_flag boolean to the capture_file struct. To do: - Start adding the progress bar to dialogs. - Don't complain so loudly when the user stops a capture. Change-Id: Iedd1d7d79f2044f1a53e4fb22186d25930a3ef03 Reviewed-on: https://code.wireshark.org/review/9029 Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Petri-Dish: Gerald Combs <gerald@wireshark.org> Reviewed-by: Gerald Combs <gerald@wireshark.org>
* Qt: Update the status bar when saving.Gerald Combs2015-05-231-5/+4
| | | | | | | | | | | | | | | | Plumb in more capture file callbacks. Add common functions for setting the status bar file information. Add and update code to match the GTK+ status bar behavior. Make sure we update the capture file length when rescanning. Bug: 10943 Change-Id: Ie84c7a57ee421d57ba3477f8dde3847aaafa1cd1 Reviewed-on: https://code.wireshark.org/review/8594 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Gerald Combs <gerald@wireshark.org>
* Fix some files to pass the pre-commit hook script.Joerg Mayer2015-05-171-5/+5
| | | | | | Change-Id: I105bf4e03fcf95cf7541f6377215809759fd933e Reviewed-on: https://code.wireshark.org/review/8502 Reviewed-by: Jörg Mayer <jmayer@loplof.de>
* mergecap: fix merge of files with different encapsulation typesPascal Quantin2015-05-101-23/+31
| | | | | | | | | | | Issue reported on https://ask.wireshark.org/questions/42061/merging-captures-on-1995 Change-Id: I0697a03221972f2d1616da52aecc6257f0bc5b88 Reviewed-on: https://code.wireshark.org/review/8293 Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com> Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Evan Huus <eapache@gmail.com>
* Revert "Don't rescan packets when a display filter is added if we are ↵Michael Mann2015-04-071-3/+0
| | | | | | | | | | capturing without "Updating list of packets in real time". There are no displayed packets to filter!" This reverts commit a11f7a75486abe3b2fdb7e8ba61e41b40b738dee. Change-Id: If3ae617c8e35439d0a77d2a2ded50288e2e6f5d7 Reviewed-on: https://code.wireshark.org/review/7961 Reviewed-by: Michael Mann <mmann78@netscape.net>
* Don't rescan packets when a display filter is added if we are capturing ↵Michael Mann2015-04-071-0/+3
| | | | | | | | | without "Updating list of packets in real time". There are no displayed packets to filter! Bug: 6217 Change-Id: Ie4a90ff8a738d6c970d51598bf14b4b51ea069ce Reviewed-on: https://code.wireshark.org/review/7918 Reviewed-by: Michael Mann <mmann78@netscape.net>
* Keep a captured-packet count in a capture_session and use that.Guy Harris2015-04-061-7/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | Have the count in a cfile_t structure always reflect the actual number of packets that have been read from the file, rather than, when doing a non-update-list-of-packets-in-real-time capture, falsely increasing the count in the cfile_t to reflect the number of packets captured but not yet read. Have the status bar base its captured-packet count on the count in the capture_session structure, and base the "sorry, no packets were captured" message on the count in the capture_session structure, as we're no longer using the count in the cfile_t structure to count anything in the process of a non-update-list-of-packets-in-real-time capture. That way, we preserve the invariant that the "frames" member of a cfile_t will be non-null if the "count" member is non-zero, fixing bug 6217. It also means we can get rid of cf_set_packet_count(), as we only set the count in the capture-file-reading code. Bug: 6217 Change-Id: I72c0e2c07c30782bad777995370b7c19e1460cc2 Reviewed-on: https://code.wireshark.org/review/7950 Reviewed-by: Guy Harris <guy@alum.mit.edu>
* Reduce epan dependence on dissectors by having print module "cache" the ↵Michael Mann2015-03-201-1/+0
| | | | | | | | | | | protocol and field ids that it needs. Change-Id: I4ec48067e9ca2cbe88e1cf2e6c9dc1e382379221 Reviewed-on: https://code.wireshark.org/review/7767 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>
* Change a lot of http:// URLs to https://.Gerald Combs2015-03-101-2/+2
| | | | | | | | | | | Most of our sites are now HTTPS-only. Update URLs accordingly. Update other URLs while we're at it. Remove or comment out dead links. Change-Id: I7c4f323e6585d22760bb90bf28fc0faa6b893a33 Reviewed-on: https://code.wireshark.org/review/7621 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Gerald Combs <gerald@wireshark.org>
* Qt: Automatically scroll the packet list.Michal Labedzki2015-02-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Add an "Auto Scroll in Live Capture" action to the Go menu. It's in the View menu in the GTK+ UI but it seems to make more sense as a navigation item. Use a timeout interval for automatic scrolling. I haven't run any tests to see if this makes a difference but it would seem that the less drawing we do during a high speed capture the better, particularly for remote displays. Update the x-stay-last icons. Note that we might want to make prefs.capture_auto_scroll a "recent" setting. Mark auto_scroll_live and packet_list_check_end GTK+ only. Bug: 10601 Co-authored-by: Gerald Combs <gerald@wireshark.org> Change-Id: I645d27c0814f0e4a0d5b01ae68be366847e2522d Reviewed-on: https://code.wireshark.org/review/7292 Reviewed-by: Gerald Combs <gerald@wireshark.org>
* Clean up ftype-conversion and dfilter error message string handling.Guy Harris2015-01-181-7/+9
| | | | | | | | | | | | | | | | | | | Have dfilter_compile() take an additional gchar ** argument, pointing to a gchar * item that, on error, gets set to point to a g_malloc()ed error string. That removes one bit of global state from the display filter parser, and doesn't impose a fixed limit on the error message strings. Have fvalue_from_string() and fvalue_from_unparsed() take a gchar ** argument, pointer to a gchar * item, rather than an error-reporting function, and set the gchar * item to point to a g_malloc()ed error string on an error. Allow either gchar ** argument to be null; if the argument is null, no error message is allocated or provided. Change-Id: Ibd36b8aaa9bf4234aa6efa1e7fb95f7037493b4c Reviewed-on: https://code.wireshark.org/review/6608 Reviewed-by: Guy Harris <guy@alum.mit.edu>
* Don't include signal.h unless we need it.Guy Harris2014-12-311-1/+0
| | | | | | Change-Id: I3965e0951eee919720f780b5e52732fd18fd9786 Reviewed-on: https://code.wireshark.org/review/6194 Reviewed-by: Guy Harris <guy@alum.mit.edu>
* Fix The left operand of '!=' is a garbage value issue found by Clang AnalyzerAlexis La Goutte2014-12-221-1/+1
| | | | | | Change-Id: Ia555fc8eca2a7288c159983578cbc88dc0bebbc2 Reviewed-on: https://code.wireshark.org/review/5952 Reviewed-by: Anders Broman <a.broman58@gmail.com>
* Qt: Add a CaptureFile class.Gerald Combs2014-12-201-2/+2
| | | | | | | | | | | | | | Wrap the capture_file struct in a QObject which translates cf_cb_* and capture_cb_* events into signals. Move the global cfile to capture_file.cpp. Don't use a void pointer for the capture file struct. Change-Id: Ic5d5efb4bb1db64aa0247245890e5669b1da723a Reviewed-on: https://code.wireshark.org/review/5885 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Gerald Combs <gerald@wireshark.org>
* Make sure err_info is always set, and print it iff it's non-null.Guy Harris2014-12-181-22/+36
| | | | | | Change-Id: Ib5c600c491a3d8adcfa91c00fa9445283610545b Reviewed-on: https://code.wireshark.org/review/5830 Reviewed-by: Guy Harris <guy@alum.mit.edu>
* WTAP_ERR_UNWRITABLE_ errors aren't returned by reads or open-for-reading.Guy Harris2014-12-181-36/+2
| | | | | | | | Check for them *only* on opening for writing and writes. Change-Id: I4b537d511ec04bcfc81f69166a2b9a2ee9310067 Reviewed-on: https://code.wireshark.org/review/5827 Reviewed-by: Guy Harris <guy@alum.mit.edu>
* Rename WTAP_ERR_REC_TYPE_UNSUPPORTED to WTAP_ERR_UNWRITABLE_REC_TYPE.Guy Harris2014-12-181-2/+2
| | | | | | | | | | That indicates that it's a problem specific to *writing* capture files; we've already converted some errors to that style, and added a new one in that style. Change-Id: I8268316fd8b1a9e301bf09ae970b4b1fbcb35c9d Reviewed-on: https://code.wireshark.org/review/5826 Reviewed-by: Guy Harris <guy@alum.mit.edu>
* Handle "I can't map this for that file format" better.Guy Harris2014-12-181-3/+58
| | | | | | | | | | | | | | | | For cases where record (meta)data is something that can't be written out in a particular file format, return WTAP_ERR_UNWRITABLE_REC_DATA along with an err_info string. Report (and free) that err_info string in cases where WTAP_ERR_UNWRITABLE_REC_DATA is returned. Clean up some other error reporting cases, and flag with an XXX some cases where we aren't reporting errors at all, while we're at it. Change-Id: I91d02093af0d42c24ec4634c2c773b30f3d39ab3 Reviewed-on: https://code.wireshark.org/review/5823 Reviewed-by: Guy Harris <guy@alum.mit.edu>
* Fix another incorrect message for WTAP_ERR_UNSUPPORTED.Guy Harris2014-12-171-1/+1
| | | | | | | | | | | | | | | WTAP_ERR_FILE_UNKNOWN_FORMAT is reported if the file is in a format that libwiretap doesn't know about (either because it's not a capture file at all or because it's a capture file in a format it doesn't support). WTAP_ERR_UNSUPPORTED is for files in a *known* format that are using features or file format elements (record type, link-layer header type, etc.) that libwireshark doesn't support. Fix another copy-and-pasteo causing WTAP_ERR_UNSUPPORTED to be reported with a message appropriate for WTAP_ERR_FILE_UNKNOWN_FORMAT. Change-Id: Ib35e2a6b6c62517887e0386f0fed1795db335439 Reviewed-on: https://code.wireshark.org/review/5810 Reviewed-by: Guy Harris <guy@alum.mit.edu>
* Rename WTAP_ERR_UNSUPPORTED_FILE_TYPE to WTAP_ERR_UNWRITABLE_FILE_TYPE.Guy Harris2014-12-171-1/+1
| | | | | | | | | That makes it clearer what the problem is, and that it should only be returned by the dump code path, not by the read code path. Change-Id: I22d407efe3ae9fba7aa25f08f050317549866442 Reviewed-on: https://code.wireshark.org/review/5798 Reviewed-by: Guy Harris <guy@alum.mit.edu>
* Rename WTAP_ERR_UNSUPPORTED_ENCAP to WTAP_ERR_UNWRITABLE_ENCAP.Guy Harris2014-12-171-7/+7
| | | | | | | | | That makes it clearer what the problem is, and that it should only be returned by the dump code path, not by the read code path. Change-Id: Icc5c9cff43be6c073f0467607555fa7138c5d074 Reviewed-on: https://code.wireshark.org/review/5797 Reviewed-by: Guy Harris <guy@alum.mit.edu>
* Add a Buffer to wtap_pkthdr to hold file-type-specific packet metadata.Guy Harris2014-12-011-4/+15
| | | | | | | | | For example, this can be used for pcap-ng options not mapped to file-type-independent metadata values. Change-Id: I398b324c62c1cc1cc61eb5e9631de00481b4aadc Reviewed-on: https://code.wireshark.org/review/5549 Reviewed-by: Guy Harris <guy@alum.mit.edu>
* Clean up routine names, don't pass capture_file into libwireshark.Guy Harris2014-11-291-25/+11
| | | | | | | | | | | | | | | | | | | | | | | Give all routines in epan/print.c that write a particular format a name beginning with write_{formatname}. If routines write columns, rather than the raw protocol tree, don't give it a name containing proto_tree. Get rid of empty preamble/finale routines. For CSV, the preamble routine writes out column titles, so call it write_csv_column_titles(). For C arrays, the body routine writes out raw hex data, so call it write_carrays_hex_data(). capture_file isn't a structure defined by libwireshark, so don't make it an argument passed into libwireshark. Change-Id: I5a7e04de9382cf51a59d9d9802f815b8b3558332 Reviewed-on: https://code.wireshark.org/review/5536 Reviewed-by: Guy Harris <guy@alum.mit.edu>
* Get rid of another global in the print code.Guy Harris2014-11-221-1/+1
| | | | | | | | | Pass the "output only these protocols" hash table as an argument, instead. Change-Id: Id8540943037e7b9bbfe377120c3f60dbe54fe0f1 Reviewed-on: https://code.wireshark.org/review/5440 Reviewed-by: Guy Harris <guy@alum.mit.edu>
* Get rid of write_headers global variable.Guy Harris2014-11-221-2/+2
| | | | | | | | | | Have write_psml_preamble() and write_csv_preamble() take a capture_file * as an argument, so they can print the column titles themselves, rather than having to defer it to the routine that prints packet data. Change-Id: Ifd1b7a13062be8ad46846315976922a752778153 Reviewed-on: https://code.wireshark.org/review/5438 Reviewed-by: Guy Harris <guy@alum.mit.edu>
* Fix support for writing out edited records.Guy Harris2014-10-201-1/+45
| | | | | | | | | | | | | | | Add a cf_set_frame_edited() routine to set the record header and data for a record; have it do all the non-GUI work, and have it set the file's "unsaved changes" flag. Have the GUI code just call that routine and then update the title bar to reflect the unsaved changes. While we're at it, unmark a no-longer-unused argument to save_record(). Change-Id: Ieb513fdf423b388519527621ecec4cf634b98caf Reviewed-on: https://code.wireshark.org/review/4885 Reviewed-by: Guy Harris <guy@alum.mit.edu>
* No need for WTAP_ERR_CANT_READ.Guy Harris2014-10-071-18/+0
| | | | | | | | | | | | | | | Unlike the standard I/O routines, the code we introduced that supports fast random seeking on gzipped files will always supply some specific error code for read errors, so we don't need WTAP_ERR_CANT_READ. Add WTAP_ERR_CANT_WRITE for writing, as we're still using the standard I/O routines for that. Set errno to WTAP_ERR_CANT_WRITE before calling fwrite() in wtap_dump_file_write(), so that it's used if fwrite() fails without setting errno. Change-Id: I6bf066a6838284a532737aa65fd0c9bb3639ad63 Reviewed-on: https://code.wireshark.org/review/4540 Reviewed-by: Guy Harris <guy@alum.mit.edu>
* Make the time stamp resolution per-packet.Guy Harris2014-09-281-34/+0
| | | | | | | | | | | | | | | | | | Pcap-ng files don't have a per-file time stamp resolution, they have a per-interface time stamp resolution. Add new time stamp resolution types of "unknown" and "per-packet", add the time stamp resolution to struct wtap_pkthdr, have the libwiretap core initialize it to the per-file time stamp resolution, and have pcap-ng do the same thing with the resolution that it does with the packet encapsulation. Get rid of the TS_PREC_AUTO_XXX values; just have TS_PREC_AUTO, which means "use the packet's resolution to determine how many significant digits to display". Rename all the WTAP_FILE_TSPREC_XXX values to WTAP_TSPREC_XXX, as they're also used for per-packet values. Change-Id: If9fd8f799b19836a5104aaa0870a951498886c69 Reviewed-on: https://code.wireshark.org/review/4349 Reviewed-by: Guy Harris <guy@alum.mit.edu>
* Update the simple dialog code.Gerald Combs2014-09-251-9/+9
| | | | | | | | | | | | | | Rename simple_dialog_qt.{cpp,h} to simple_dialog.{cpp,h}. Make it a subclass of QMessageBox. Queue messages at startup similar to GTK+. Move the GTK+-specific simple_dialog declarations to gtk/simple_dialog.h. Don't yell at the user so much. Replace exclamation points with periods. Change-Id: I1cc771106222d5e06f1f52d67ac29d6dc367cce4 Reviewed-on: https://code.wireshark.org/review/4288 Reviewed-by: Gerald Combs <gerald@wireshark.org>