aboutsummaryrefslogtreecommitdiffstats
path: root/randpkt.c
AgeCommit message (Collapse)AuthorFilesLines
2017-04-08Clean up handling of enabled/disabled protocols/heuristic dissectors.Guy Harris1-5/+7
Add a "report a warning message" routine to the "report_err" code in libwsutil, and rename files and routines appropriately, as they don't only handle errors any more. Have a routine read_enabled_and_disabled_protos() that reads all the files that enable or disable protocols or heuristic dissectors, enables and disables them based on the contents of those files, and reports errors itself (as warnings) using the new "report a warning message" routine. Fix that error reporting to report separately on the disabled protocols, enabled protocols, and heuristic dissectors files. Have a routine to set up the enabled and disabled protocols and heuristic dissectors from the command-line arguments, so it's done the same way in all programs. If we try to enable or disable an unknown heuristic dissector via a command-line argument, report an error. Update a bunch of comments. Update the name of disabled_protos_cleanup(), as it cleans up information for disabled *and* enabled protocols and for heuristic dissectors. Support the command-line flags to enable and disable protocols and heuristic dissectors in tfshark. Change-Id: I9b8bd29947cccdf6dc34a0540b5509ef941391df Reviewed-on: https://code.wireshark.org/review/20966 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-02-14wiretap: add cleanup routine.Dario Lombardo1-15/+39
The cleanup routine has been added to exit section of the applications. Those which required a exit restyle have been patched as well. Change-Id: I3a8787f0718ac7fef00dc58176869c7510fda7b1 Reviewed-on: https://code.wireshark.org/review/19949 Petri-Dish: Dario Lombardo <lomato@gmail.com> Reviewed-by: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Dario Lombardo <lomato@gmail.com>
2016-12-05Clean up initialization code for programs.Guy Harris1-19/+23
Make the init_progfile_dir() call unconditionally, even if plugins aren't supported, as that doesn't necessarily mean nobody uses the directory containing the executable. Report the error the same way in all programs, and free the error string after we're finished with it. Make the error - and the comment before the code - reflect what init_progfile_dir() is actually doing (the goal is to get the full pathname of the directory *containing* the executable; that's generally done by getting the pathname of the executable and stripping off the name of the executable, but that's won't necessarily always be the case). Also note for TShark that we won't be able to capture traffic, just as we do for Wireshark (if we don't have the pathname of the program file, we don't have a pathname to use to find dumpcap). Have the plugin scanner just fail silently if we weren't able to get the plugin directory path, so we don't have to worry about calling it if init_progfile_dir() fails. Clean up white space while we're at it. Change-Id: I8e580c719aab6fbf74a764bf6629962394fff7c8 Reviewed-on: https://code.wireshark.org/review/19076 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-12-04Have a routine to do all the work of initializing libwiretap.Guy Harris1-4/+2
Have programs that use libwiretap call that routine rather than separately calling some or all of init_open_routines(), wtap_register_plugin_types(), and wtap_opttypes_initialize(). Also don't have routines internal to libwiretap call those. Yes, this means doing some initialization work when it isn't necessary, but scattering on-demand calls throughout the code is a great way to forget to make those calls. Change-Id: I5828e1c5591c9d94fbb3eb0a0e54591e8fc61710 Reviewed-on: https://code.wireshark.org/review/19069 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-09-06Return after calling cmdarg_err().Guy Harris1-0/+1
cmdarg_err() prints a message, but it doesn't exit. Change-Id: I887d96bce483f873a4375cb6b5254915d014f1b1 Reviewed-on: https://code.wireshark.org/review/17509 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-09-06Use get_positive_int() to parse signed positive arguments.Guy Harris1-11/+22
Clean up indentation while we're at it. Change-Id: Ie7223f96c758bd71d2435203635db9c2b28e2249 Reviewed-on: https://code.wireshark.org/review/17508 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-09-05Have scan_plugins() take an argument specify what to do on load failures.Guy Harris1-7/+12
That's a less gross hack to suppress load failures due to not having libwiretap than providing a no-op failure-message routine, as it at least allows other code using a failure-message routine, such as cmdarg_err() and routines that call it, to be used. We really should put libwiretap and libwireshark plugins into separate subdirectories of the plugin directories, and avoid even looking at libwireshark plugins in programs that don't use libwireshark. Change-Id: I0a6ec01ecb4e718ed36233cfaf638a317f839a73 Reviewed-on: https://code.wireshark.org/review/17506 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-07-09randpkt_core: change rand() to g_rand_int (CID 1355360).Dario Lombardo1-2/+0
Change-Id: I48560cbb6007eb16aa545a3e8e6a0e8e3b206930 Reviewed-on: https://code.wireshark.org/review/16326 Petri-Dish: João Valverde <j@v6e.pt> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Petri-Dish: Dario Lombardo <lomato@gmail.com> Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2016-04-04Include ws_diag_control.h in config.hJoão Valverde1-1/+2
Change-Id: Ia394071710ecda3b0e6686a51fbca45a8ff20317 Reviewed-on: https://code.wireshark.org/review/14749 Petri-Dish: João Valverde <j@v6e.pt> Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: João Valverde <j@v6e.pt>
2016-04-01randpkt: restyle the list generation to get rid of the const compiler warning.Dario Lombardo1-8/+10
Change-Id: Id7c62ef18f919ba8a476898bc88c02fd3b6bf5a1 Reviewed-on: https://code.wireshark.org/review/14730 Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-03-22Fix randpkt and reordercap.Gerald Combs1-0/+50
Copy over recent wiretap plugin changes from mergecap, otherwise randpkt and reordercap will crash. Change-Id: I70111ded3d9a5c4380b964b2c5b626599eebc327 Reviewed-on: https://code.wireshark.org/review/14546 Reviewed-by: Gerald Combs <gerald@wireshark.org> Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-02-15Build the extcap programs in the extcap directory.Guy Harris1-2/+2
That lets the version of Wireshark built with autotools find the extcap programs. Don't install the extcap programs under ${datadir} - that puts it under a share directory, and share directories are for platform-independent files, which executable images aren't (they're instruction-set dependent, hence platform-dependent). Change-Id: I992eeb984bdbe6b3476777f7114628c83df6080f Reviewed-on: https://code.wireshark.org/review/13943 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-12-12Remove -Wwrite-strings compiler flagJoão Valverde1-3/+1
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-11randpkt: split into a core and an app.Dario Lombardo1-804/+33
This will allow other apps to use the random packet generation features. Change-Id: I7e9af58cbe39da4908242b5fbb292f473e03b4f2 Reviewed-on: https://code.wireshark.org/review/11579 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-11-10Skip only the actual file descriptor close when writing to stdout.Guy Harris1-1/+1
Have a "this is stdout" flag for a wtap_dumper, and have "open the standard output for dumping" routines that set that flag. When closing a wtap_dumper, do most of the work regardless of whether we're writing to the standard output or not (so that everything gets written out) and only skip the closing of the underlying file descriptor. Change-Id: I9f7e4d142b3bd598055d806b7ded1cb4c378de8e Reviewed-on: https://code.wireshark.org/review/11673 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-11-10Treat "-" as "standard input" in the CLI, not in libwiretap.Guy Harris1-36/+127
That's a UI convention, and the GUI shouldn't honor that convention - a user might get confused if they try to save to "-" and end up with nothing (and with a ton of crap in a log file if programs launched from the GUI end up with their standard output and error logged). While we're at it, make randcap report write and close errors. Change-Id: I9c450f0ca0320ce4c36d13d209b56d72edb43012 Reviewed-on: https://code.wireshark.org/review/11666 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-11-09randpkt: fix no previous prototype for 'randpkt_*' [-Wmissing-prototypes]Alexis La Goutte1-4/+4
randpkt.c:556:1: warning: no previous prototype for ‘randpkt_seed’ randpkt.c:610:6: warning: no previous prototype for ‘randpkt_example_init’ randpkt.c:632:6: warning: no previous prototype for ‘randpkt_example_close’ randpkt.c:638:6: warning: no previous prototype for ‘randpkt_loop’ Change-Id: Ieab604a22fa7ebf5c049ab497abd56af0a788d36 Reviewed-on: https://code.wireshark.org/review/11654 Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Reviewed-by: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com> Reviewed-by: Michael Mann <mmann78@netscape.net>
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-11-05randpkt: code restyle.Dario Lombardo1-197/+301
Code has been restyled towards a more modular approach. This will allow the split of the code into a core and an app. Once splitted the code can be reused by other apps, useful for testing. Change-Id: I96083a7cc1a3417d10961700e5c7c27d32e350e8 Reviewed-on: https://code.wireshark.org/review/11355 Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.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-20Suppress a bunch of cast-qual warnings.Gerald Combs1-0/+3
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>
2014-12-25Use getopt_long().Guy Harris1-1/+9
Change-Id: I8ff74de7cedee64bc46d88f23a6d1e771d4a4a10 Reviewed-on: https://code.wireshark.org/review/6048 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-18Make sure err_info is always set, and print it iff it's non-null.Guy Harris1-8/+1
Change-Id: Ib5c600c491a3d8adcfa91c00fa9445283610545b Reviewed-on: https://code.wireshark.org/review/5830 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-12-18Handle "I can't map this for that file format" better.Guy Harris1-1/+13
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-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-05-24Allow wtap_read() and wtap_seek_read() to return records other than packets.Guy Harris1-0/+1
Add a "record type" field to "struct wtap_pkthdr"; currently, it can be REC_TYPE_PACKET, for a record containing a packet, or REC_TYPE_FILE_TYPE_SPECIFIC, for records containing file-type-specific data. Modify code that reads packets to be able to handle non-packet records, even if that just means ignoring them. Rename some routines to indicate that they handle more than just packets. We don't yet have any libwiretap code that supplies records other than REC_TYPE_PACKET or that supporting writing records other than REC_TYPE_PACKET, or any code to support plugins for handling REC_TYPE_FILE_TYPE_SPECIFIC records; this is just the first step for bug 8590. Change-Id: Idb40b78f17c2c3aea72031bcd252abf9bc11c813 Reviewed-on: https://code.wireshark.org/review/1773 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-05-23Set the presence flags.Guy Harris1-0/+1
If we're going to stuff a time stamp in there, let's at least indicate that it's there. Change-Id: Idc3d4ba5fdc109b21b5c6034906664a763b2ddda Reviewed-on: https://code.wireshark.org/review/1767 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-05-09Revert "Refactor Wiretap"Guy Harris1-2/+2
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-2/+2
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>
2013-12-31Follow convention for -h option:Bill Meier1-15/+38
Output to stdout & then exit(0). Add editor modelines. svn path=/trunk/; revision=54513
2013-11-08The "file types" we have are actually combinations of types andGuy Harris1-1/+1
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-05-19Trivial change so all longnames are aligned.Chris Maynard1-1/+1
svn path=/trunk/; revision=49417
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
2012-10-16Add wtap_pseudo_header union to wtap_pkthdr structure.Jakub Zawadzki1-6/+5
Use pkthdr instead of pseudo_header as argument for dissecting. svn path=/trunk/; revision=45601
2012-09-20We always HAVE_CONFIG_H so don't bother checking whether we have it or not.Jeff Morriss1-2/+0
svn path=/trunk/; revision=45015
2012-06-28Update Free Software Foundation address.Jakub Zawadzki1-1/+1
(COPYING will be updated in next commit) svn path=/trunk/; revision=43536
2011-08-09Fix https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=5608 :Jeff Morriss1-6/+4
getopt() can/should normally be found in unistd.h, so: - When testing for getopt(), define that we HAVE_GETOPT instead of HAVE_GETOPT_H (to avoid confusion). - Don't attempt to include getopt.h: not all OS's have it (for example, Solaris 9 does not). - (All the places which need getopt already include unistd.h (if we have it).) If this breaks things on some OS, we might need (a real) HAVE_GETOPT_H check. svn path=/trunk/; revision=38437
2011-06-28Replace all strerror() with g_strerror().Stig Bjørlykke1-2/+2
Remove our local strerror implementation. Mark strerror as locale unsafe API. This fixes bug 5715. svn path=/trunk/; revision=37812
2011-06-23Use ws_open/ws_read to avoid prohibited APIs.Stig Bjørlykke1-2/+4
Close file handle after usage. svn path=/trunk/; revision=37769
2011-05-24Move the Windows argument list conversion code to a common routine.Gerald Combs1-15/+2
svn path=/trunk/; revision=37372
2011-01-06On Windows, convert all of our command-line arguments from UTF-16 toGerald Combs1-0/+22
UTF-8 where we don't already do so. In Wireshark use g_utf16_to_utf8 instead of utf_16to8. This should fix bug 5520. svn path=/trunk/; revision=35411
2010-05-28Move some code (including the optional objects) into libwsutilJeff Morriss1-1/+1
svn path=/trunk/; revision=33012
2010-01-06Use /dev/urandom (which is non-blocking) instead of /dev/random (whichGerald Combs1-6/+8
can block forever) for our seed. This fixes a problem with our new Linux build slave, which is running Linux 2.6 as a VM guest, and which was timing out waiting for entropy. Add a comment about using CryptGenRandom on Windows. svn path=/trunk/; revision=31456
2009-10-06Invert check for getopt: NEED_GETOPT_H -> HAVE_GETOPT_HStig Bjørlykke1-5/+4
Rename getopt.[ch] -> wsgetopt.[ch] to avoid name collision. svn path=/trunk/; revision=30370
2009-05-17From Márton Németh via bug 2137:Gerald Combs1-25/+90
Currently the randpkt random packet generator does not have support to generate WTAP_ENCAP_USB and WTAP_ENCAP_USB_LINUX type packets. svn path=/trunk/; revision=28388
2008-11-17Make "-h" a valid flag.Gerald Combs1-1/+2
svn path=/trunk/; revision=26799
2008-10-31On non-Windows systems, try /dev/random and, if it exists, use it,Guy Harris1-23/+53
otherwise fall back on time(). Print error messages to stderr, and put the name of the program in them. Exit with 1 on command-line syntax errors, 2 on other errors. Fix indentation. svn path=/trunk/; revision=26661
2008-10-31Fixed some "ignoring return value" warnings.Stig Bjørlykke1-1/+2
This is the last commit to make it compile clean on Ubuntu 8.10. svn path=/trunk/; revision=26654
2007-05-25From Mike Harvey: Support for WiMAX and the WiMAX M2M encapsulation protocol.Gerald Combs1-8/+20
Add support for WiMAX and M2M to various makefiles and installer files. Add basic support for M2M to randpkt. svn path=/trunk/; revision=21945