aboutsummaryrefslogtreecommitdiffstats
path: root/mergecap.c
AgeCommit message (Collapse)AuthorFilesLines
2016-03-06To see whether a string equals another string, just use strcmp().Guy Harris1-1/+1
The goal here is to see whether out_filename is "-" or not; there's no good reason to use strncmp() here. Fixes Coverity CID 1316605. Change-Id: I851eee869afed58ac091982b8d303b0eda276c2e Reviewed-on: https://code.wireshark.org/review/14361 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-03-03We need to include <wsutil/privileges.h> for those functions.Guy Harris1-0/+1
Change-Id: I2c51ae467e1fcfb325bfac5d6fe52ef08b4429a6 Reviewed-on: https://code.wireshark.org/review/14335 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-03-03Add missing initialization calls.Guy Harris1-1/+8
Do the same thing editcap does; we need to know, for example, whether we were invoked with elevated privileges, so we know whether to pay attention to environment variables when loading plugins. Fix program name, and add a comment from editcap, while we're at it. Change-Id: Ia092331de129d86783a2600be21cff746d4ed5e3 Reviewed-on: https://code.wireshark.org/review/14334 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-03-03Refactor wiretap option block types into a registration system.Michael Mann1-0/+43
Also required mergecap to look for plugins to initialize wiretap option blocks. Change-Id: I4208d1028dd0f94f185393801d72025329266cb7 Reviewed-on: https://code.wireshark.org/review/14300 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-01-06Clean up more includes of wtap.h.Guy Harris1-1/+2
Change-Id: Ie53b64f7e5b39a50dffb62fc0b886da71e0a3bd2 Reviewed-on: https://code.wireshark.org/review/13066 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-12-12Remove -Wwrite-strings compiler flagJoão Valverde1-4/+2
The "-Wwrite-strings" flag produces nuisance warnings. These warnings are not useful, they're impossible to fix in a sane way and therefore are being handled with casts of static strings to (char *). This just moves the warning to [-Wcast-qual] and a compiler pragma is in turn required (and used) to squelch that warning. Remove the Wwrite-strings warning. Let that responsibility fall on the programmer (as is done by casting). Change-Id: I5a44dfd9decd6d80797a521a3373593074962fb5 Reviewed-on: https://code.wireshark.org/review/12162 Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com> Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-11-11Update user guide for development releasePascal Quantin1-1/+1
Change-Id: I9b4c5ab2e98ad6daa618bcda20b53a23467e16e0 Reviewed-on: https://code.wireshark.org/review/11734 Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2015-11-07Clean up includes of unistd.h, fcntl.h, and sys/stat.h.Guy Harris1-8/+0
Have wsutil/file_util.h include them on UN*X, just as it includes io.h on Windows, so we can have a rule of "if you do file operations, include <wsutil/file_util.h> and use the routines in it". Remove includes of unistd.h, fcntl.h, and sys/stat.h that aren't necessary (whether because of the addition of them to wsutil/file_util.h or because they weren't needed in the first place). Change-Id: Ie241dd74deff284e39a5f690a297dbb6e1dc485f Reviewed-on: https://code.wireshark.org/review/11619 Petri-Dish: Guy Harris <guy@alum.mit.edu> Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-08-18Improve file merging for mergecap and wiresharkHadriel Kaplan1-336/+127
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>
2015-08-06Pcapng: support Name Resolution Block optionsHadriel Kaplan1-1/+1
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>
2015-06-25mergecap: check input files time precision before exporting to pcapng formatPascal Quantin1-2/+39
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>
2015-05-10mergecap: fix merge of files with different encapsulation typesPascal Quantin1-1/+52
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>
2015-02-28Remove some unneeded includes of <sys/time.h>.Guy Harris1-4/+0
Change-Id: I9e4e6efa9f8c7dbff7627f8d5fc3278ab383618d Reviewed-on: https://code.wireshark.org/review/7441 Petri-Dish: Guy Harris <guy@alum.mit.edu> Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-02-20Suppress a bunch of cast-qual warnings.Gerald Combs1-2/+5
Squelch warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual] similar to g630f54f. Change strtod to g_ascii_strtod to squelch a checkAPIs error. Change-Id: Ib2d26ef89f08827a5adc07e35eaf876cd7b8d14e Reviewed-on: https://code.wireshark.org/review/7269 Reviewed-by: Gerald Combs <gerald@wireshark.org>
2015-02-09(Trivial) Fix printf-related 'Mismatch on sign' warningsBill Meier1-1/+1
Found by MSVC2013 Code Analysis Change-Id: I58063946dd558e98308c87b36eeac0ddbe1a6e79 Reviewed-on: https://code.wireshark.org/review/7045 Reviewed-by: Bill Meier <wmeier@newsguy.com>
2014-12-31Do the full string in get_{compiled,runtime}_version_info().Guy Harris1-6/+4
Have them start the string with "Compiled" or "Running on", and return the string when done. Change-Id: Ic4d290c963621fa0385dc5aab766fd4ad31d3810 Reviewed-on: https://code.wireshark.org/review/6155 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-12-31Move the version_info.c stuff to wsutil/ws_version_info.c.Guy Harris1-2/+0
Change-Id: I3a5c7e219974bfb924819b43b4d445eaf00e5bde Reviewed-on: https://code.wireshark.org/review/6153 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-12-25Only include <wsutil/os_version_info.h> if we need it.Guy Harris1-1/+0
Change-Id: Idee0e7205969ac2e7b33c4748a1463a0bfffe0a6 Reviewed-on: https://code.wireshark.org/review/6051 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-12-25Check for getopt_long(), not getopt().Guy Harris1-1/+1
We support three types of platforms: 1) UN*Xes that have both getopt() and getopt_long(); 2) UN*Xes that have getopt() but not getopt_long(); 3) Windows, which has neither. Checking for getopt_long() lets us distinguish between 1) and 2) and build getopt_long() for them. Change-Id: Iaf0f142f9bebaa2eed2128d544ec9786711def45 Reviewed-on: https://code.wireshark.org/review/6045 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-12-24Move twelve show_version() functions from the varoius programs andStephen Fisher1-16/+1
Wireshark UI files into a single one in wsutil. Change-Id: I0a64f0cc8106bd681bd185289c36272c4c43baad Reviewed-on: https://code.wireshark.org/review/6026 Reviewed-by: Stephen Fisher <sfisher@sdf.org>
2014-12-22Fix The left operand of '!=' is a garbage value issue found by Clang AnalyzerAlexis La Goutte1-1/+1
Change-Id: Ia555fc8eca2a7288c159983578cbc88dc0bebbc2 Reviewed-on: https://code.wireshark.org/review/5952 Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-12-18Make sure err_info is always set, and print it iff it's non-null.Guy Harris1-11/+3
Change-Id: Ib5c600c491a3d8adcfa91c00fa9445283610545b Reviewed-on: https://code.wireshark.org/review/5830 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-12-18WTAP_ERR_UNWRITABLE_ errors aren't returned by reads or open-for-reading.Guy Harris1-4/+0
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>
2014-12-18Rename WTAP_ERR_REC_TYPE_UNSUPPORTED to WTAP_ERR_UNWRITABLE_REC_TYPE.Guy Harris1-1/+1
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>
2014-12-18Handle "I can't map this for that file format" better.Guy Harris1-3/+29
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>
2014-12-17Rename WTAP_ERR_UNSUPPORTED_ENCAP to WTAP_ERR_UNWRITABLE_ENCAP.Guy Harris1-3/+3
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>
2014-10-29Rename the strnatcmp.c routines and make them use the g_ascii_XXX() routines.Guy Harris1-2/+2
Rename strnatcmp()/strnatcasecmp() to ws_ascii_XXX(), and make them use the g_ascii_XXX() routines rather than ctype.h routines, to eliminate locale-dependent behavior. (If you want locale-dependent "natural order" sorting, you probably want "dictionary order" sorting, which is more complicated than just natural order sorting.) Change-Id: I837f2776b2a909b547dc9a6072e497911b5380e5 Reviewed-on: https://code.wireshark.org/review/4985 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-09-22Ensure pcapng application name is always dynamically allocatedEvan Huus1-1/+1
Change-Id: I408944dfb0fa35bae6019ed0d6d810525b2ffcae Reviewed-on: https://code.wireshark.org/review/4254 Reviewed-by: Evan Huus <eapache@gmail.com>
2014-08-24Modify includes of config.h so that out-of-tree builds, i.e. CMakeGraham Bloice1-1/+1
don't pick up the in-tree copy. Change-Id: I7ec473876cdba1a025c52362d7f6adc62d24ce71 Reviewed-on: https://code.wireshark.org/review/3798 Petri-Dish: Graham Bloice <graham.bloice@trihedral.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Roland Knall <rknall@gmail.com> Reviewed-by: Graham Bloice <graham.bloice@trihedral.com>
2014-08-05Fix whitespace/indentation to match editor modelines.Bill Meier1-1/+1
Change-Id: I3445ae22f10584582d465bf632942e016f5f70ca Reviewed-on: https://code.wireshark.org/review/3452 Reviewed-by: Bill Meier <wmeier@newsguy.com>
2014-07-03Use get_*_int() from wsutil, rather than defining our own.Guy Harris1-39/+25
Change-Id: I4811d87a903cc3cea93e12883edf25bcd1271a53 Reviewed-on: https://code.wireshark.org/review/2795 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-07-03Make --help and --version information a bit more uniform.Guy Harris1-23/+73
Have --version print the version number, the copyright information, the "compiled with" information, the "running on/with" information, and the compiler information. Have --help print the version number, a one-line summary of what the program does, a reference to http://www.wireshark.org for more information, a Usage: line, and a list of command-line options. This means programs doing that don't need to include version.h; that's left up to get_ws_vcs_version_info() to do. Change-Id: Idac641bc10e4dfd04c9914d379b3a3e0cc5ca8cb Reviewed-on: https://code.wireshark.org/review/2794 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-07-03More getopt_long, to add --help and --version support.Guy Harris1-1/+10
Change-Id: I946067b972a70154f02ab561bc0fd029a7a5abc4 Reviewed-on: https://code.wireshark.org/review/2791 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-06-21Add command-line argument to request the version to a number of the utilities.Jeff Morriss1-6/+17
In some cases "-v" was already used so "-V" is the option. Note that the version information in these utilities is much shorter than what is presented by the big programs. As requested by https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=5804 Bug: 5804 Change-Id: I35db35a4eace2797afd895f9be7322ef39928480 Reviewed-on: https://code.wireshark.org/review/2489 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-05-09Revert "Refactor Wiretap"Guy Harris1-8/+8
This reverts commit 1abeb277f5e6bd27fbaebfecc8184e37ba9d008a. This isn't building, and looks as if it requires significant work to fix. Change-Id: I622b1bb243e353e874883a302ab419532b7601f2 Reviewed-on: https://code.wireshark.org/review/1568 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-05-09Refactor WiretapMichael Mann1-8/+8
Start of refactoring Wiretap and breaking structures down into "generally useful fields for dissection" and "capture specific". Since this in intended as a "base" for Wiretap and Filetap, the "wft" prefix is used for "common" functionality. The "architectural" changes can be found in cfile.h, wtap.h, wtap-int.h and (new file) wftap-int.h. Most of the other (painstaking) changes were really just the result of compiling those new architecture changes. bug:9607 Change-Id: Ife858a61760d7a8a03be073546c0e7e582cab2ae Reviewed-on: https://code.wireshark.org/review/1485 Reviewed-by: Michael Mann <mmann78@netscape.net>
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-25Fix mergecap.c: Dereference of null pointer (clang analyzer)Hadriel Kaplan1-2/+2
Change-Id: I89076388db8522c5fbdf72505f50e1380f1ab391 Reviewed-on: https://code.wireshark.org/review/369 Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com> Tested-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2014-02-07Replace "svn" with "git" all over the place.Gerald Combs1-3/+3
Rename "SVNPATH" to "GITBRANCH" since that seems more appropriate. Rename "svnversion.h" to "version.h" as Evan suggested. Update some URLs. In make-version.pl, make sure we don't set an improper upstream branch name. Use the number of commits + short hash from `git describe` for package names by default. Change-Id: I922bba8d83eabdf49284a119f55b4076bc469b96 Reviewed-on: https://code.wireshark.org/review/139 Reviewed-by: Gerald Combs <gerald@wireshark.org>
2014-01-22Don't write out packets that have a "captured length" bigger than we'reGuy Harris1-4/+17
willing to read or that's bigger than will fit in the file format; instead, report an error. For the "I can't write a packet of that type in that file type" error, report the file type in question. svn path=/trunk/; revision=54882
2014-01-21Check the return of wtap_dump_close() even if we've gotten a read error;Guy Harris1-3/+10
the only reason not to check it is if we've already gotten a write error and another write error would be superfluous (either "you got two of the same error" or "you got an I/O error *and* you ran out of disk space/disk quota" is of limited interest). Discard the return value of wtap_dump_close() in the case where we've already gotten a write error, in the hopes of squelching a Coverity warning. svn path=/trunk/; revision=54872
2014-01-03For -h option: output to stdout and exit(0) as per convention;Bill Meier1-45/+54
Do some whitespace changes; Change editor-modelines tab-width & etc to 8. svn path=/trunk/; revision=54582
2013-11-08The "file types" we have are actually combinations of types andGuy Harris1-9/+9
subtypes, e.g. Network Monitor version 1 and Network Monitor version 2 are separate "file types", even though they both come from Network Monitor. Rename various functions, #defines, and variables appropriately. svn path=/trunk/; revision=53166
2013-09-06Whitespace cleanup, sort options, add modelines.Chris Maynard1-75/+82
svn path=/trunk/; revision=51804
2013-07-16Move merge.{h,c} into wiretap: these modules use wiretap to merge files.Jeff Morriss1-8/+4
svn path=/trunk/; revision=50656
2013-07-16Move strnatcmp.{h,c} from epan into wsutil: there's nothing epan-specificJeff Morriss1-1/+2
there and moving it avoids having to recompile the file for use in editcap and mergecap (which don't link against libwireshark). svn path=/trunk/; revision=50650
2013-07-10Add strnatcmp by Martin Pool for 'natural order' string comparisons, and ↵Chris Maynard1-1/+14
make use of it in editcap and mergecap for listing encapsulation types. For example: Before: user0 - USER 0 user1 - USER 1 user10 - USER 10 user11 - USER 11 user12 - USER 12 user13 - USER 13 user14 - USER 14 user15 - USER 15 user2 - USER 2 user3 - USER 3 user4 - USER 4 user5 - USER 5 user6 - USER 6 user7 - USER 7 user8 - USER 8 user9 - USER 9 After: user0 - USER 0 user1 - USER 1 user2 - USER 2 user3 - USER 3 user4 - USER 4 user5 - USER 5 user6 - USER 6 user7 - USER 7 user8 - USER 8 user9 - USER 9 user10 - USER 10 user11 - USER 11 user12 - USER 12 user13 - USER 13 user14 - USER 14 user15 - USER 15 svn path=/trunk/; revision=50482
2013-03-10Only cast the variable after checking it.Michael Tüxen1-3/+3
svn path=/trunk/; revision=48222
2013-03-05Use explicit casts.Anders Broman1-2/+2
svn path=/trunk/; revision=48108
2013-02-20When any of our executables start on Windows create or open a "WiresharkGerald Combs1-0/+1
is running" mutex. Have the NSIS installer check for this mutex and ask the user to close Wireshark if it's found. While not perfect this makes the WinSparkle update process much less annoying. svn path=/trunk/; revision=47758