aboutsummaryrefslogtreecommitdiffstats
path: root/ui/text_import.c
AgeCommit message (Collapse)AuthorFilesLines
2019-04-20text import: make TCP dest port truly direction dependantJaap Keuter1-1/+0
During introduction of proper direction support this line was left over, causing TCP dest port to remain independant of direction. This change simply drops the line. See CID 1444115 Change-Id: I4ff362925e422bc57cfa3842127ddaf8695cf303 Reviewed-on: https://code.wireshark.org/review/32902 Petri-Dish: Anders Broman <a.broman58@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-03-20Clean up comments and white space.Guy Harris1-4/+4
This is a collection of routines, not a program. Change-Id: I76296576443602b7ea016c5311e66a52a73ee941 Reviewed-on: https://code.wireshark.org/review/32491 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-03-20Put back EOF rule, but without exporting write_current_packet().Guy Harris1-3/+15
Instead, add a new T_EOF token type, call parse_token() with it when we get an EOF, and, in parse_token(), write the current packet if we get a T_EOF token. That's a bit simpler, and would let us treat EOFs in different places differently, if, for example, we want to report warnings for half-finished packets. Change-Id: Ie41a8a1dedf91c34300468e073f18bf806e01892 Reviewed-on: https://code.wireshark.org/review/32489 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-03-20Write out the last packet in text_import().Guy Harris1-1/+4
Write out the last packet after text_import_scan() returns, if it returned successfully, the same way that it's done in text2pcap. This means we can get rid of the EOF rule in the lexer - the lexer just finishes and returns 0 to text_import_scan(), which then returns a success indication to text_import() - and make write_current_packet() static. Change-Id: Ibafdbe01da6bb33a213a32847f1981bc943290a1 Reviewed-on: https://code.wireshark.org/review/32486 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-03-11Flip MAC and IP addresses, and TCP/UDP/SCTP ports, for outgoing packets.Guy Harris1-11/+61
If we have direction indications, flip the source and destination for outgoing packets. Also, generate sequence numbers for TCP. Code lifted from text2pcap. Bug: 15561 Change-Id: I869c45e88bf635f3277dbeeb08aff88dbfc8edef Reviewed-on: https://code.wireshark.org/review/32383 Petri-Dish: Guy Harris <guy@alum.mit.edu> Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-02-13Add macros for the pack_flags field.Guy Harris1-4/+4
Add macros to extract the direction, reception type, and FCS length fields of the pack_flags field, and add definitions for different directions and reception types. Add a macro to construct a pack_flags field value from subfields; this is for use by non-pcapng file readers (the pack_flags field is just a copy of the EPB flags option, so that's not needed for pcapng). Move some #defines for that field from packet-frame.c to wtap.h, and rename them to match the new macros. Use the macros rather than rolling our own code. Fix a variable name in text2pcap.c that apparently had the wrong name, given the value that was being tested. Change-Id: Ia788ca4e9f5fabd8d24e6ead5ff1817509f54827 Reviewed-on: https://code.wireshark.org/review/32010 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-01-23text import: cleanup type usageJaap Keuter1-7/+7
The glib gboolean and integer types are used interchangably, while a proper use is easily achievable. Change-Id: I8943bb90c9f23c0e58c296ad3b45153d0364953c Signed-off-by: Jaap Keuter <jaap.keuter@xs4all.nl> Reviewed-on: https://code.wireshark.org/review/31708 Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-01-21Text Import: update code comments and help textsJaap Keuter1-10/+10
From the updates to text2pcap take the updates to the code comments and apply them here as well. This also applies to the User Guide help texts. Change-Id: I4e73fb1372ea0c1866c6d0fee7c14bc645fbe1b1 Signed-off-by: Jaap Keuter <jaap.keuter@xs4all.nl> Reviewed-on: https://code.wireshark.org/review/31636 Tested-by: Petri Dish Buildbot Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2018-12-06Update comments, get rid of IMPORT_MAX_PACKET.Guy Harris1-4/+5
Get rid of the IMPORT_MAX_PACKET #define; just directly use WTAP_MAX_PACKET_SIZE_STANDARD, to match what text2pcap.c does. Update comments in text2pcap.c and ui/text_import.c to say the maximum packet size is WTAP_MAX_PACKET_SIZE_STANDARD. Change-Id: I34118f76426d1416fccf43b2a356ad8d200de19b Ping-Bug: 15292 Reviewed-on: https://code.wireshark.org/review/30945 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-10-31text_import: fix wrong int type.Dario Lombardo1-2/+2
Regressed in ge655b9a. Change-Id: I5aeb9e1935bc1064797db8ac6acaa852d9a07c98 Reviewed-on: https://code.wireshark.org/review/30445 Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-10-31import: add export_pdu dummy header feature.Dario Lombardo1-1/+37
When importing a file from hex dump, this change adds a way to add a custom dummy header. It's an export_pdu header which uses one single tag: the protocol name. This allows to call directly a dissector without more dummy headers. Example: it can be used to call the DNS dissector without fake eth/ip/udp headers. Change-Id: I12fd6d09a131acd9bd1f0d7c4c8aefcd0d718b26 Reviewed-on: https://code.wireshark.org/review/30403 Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-02-18Fix some source headers, reformat SPDX license lines in comment block.Jaap Keuter1-1/+2
Change-Id: Ibae6a64a9915003435a3fb17763535a3844143be Reviewed-on: https://code.wireshark.org/review/25891 Petri-Dish: Jaap Keuter <jaap.keuter@xs4all.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Michael Mann <mmann78@netscape.net>
2018-02-16Squelch redundant declaration warnings.Guy Harris1-15/+2
Have the text-to-pcap scanners define a routine that the main code calls, which both allocates and destroys the scanner. Don't declare the Lex-generated routines in a header file we create, declare that routine, instead. Change-Id: Icad6a83db1a0dea8ac390315af72383fc99f8513 Reviewed-on: https://code.wireshark.org/review/25822 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-02-09Generalize wtap_pkthdr into a structure for packet and non-packet records.Guy Harris1-10/+10
Separate the stuff that any record could have from the stuff that only particular record types have; put the latter into a union, and put all that into a wtap_rec structure. Add some record-type checks as necessary. Change-Id: Id6b3486858f826fce4b096c59231f463e44bfaa2 Reviewed-on: https://code.wireshark.org/review/25696 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-02-08replace SPDX identifier GPL-2.0+ with GPL-2.0-or-later.Dario Lombardo1-1/+1
The first is deprecated, as per https://spdx.org/licenses/. Change-Id: I8e21e1d32d09b8b94b93a2dc9fbdde5ffeba6bed Reviewed-on: https://code.wireshark.org/review/25661 Petri-Dish: Anders Broman <a.broman58@gmail.com> Petri-Dish: Dario Lombardo <lomato@gmail.com> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-02-02ui: use SPDX identifiers.Dario Lombardo1-15/+1
Change-Id: I6b05399395bcc35e59b73b4030ba4a05711a7b1a Reviewed-on: https://code.wireshark.org/review/25565 Petri-Dish: Michael Mann <mmann78@netscape.net> Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-04-17Check for localtime() failing.Guy Harris1-2/+12
It "shouldn't happen", but at least this squelches a Coverity complaint, CID 1398224. Change-Id: I9555f71a50574e9386a3c96d52143d838f7f121f Reviewed-on: https://code.wireshark.org/review/21160 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-10-22More checks for localtime() and gmtime() returning NULL.Guy Harris1-0/+1
And some comments in the case where we're converting the result of time() - if your machine's idea of time predates January 1, 1970, 00:00:00 UTC, it'll crash on Windows, but that's not a case where a *file* can cause the problem due either to a bad file time stamp or bad time stamps in the file. Change-Id: I837a438e4b875dd8c4f3ec2137df7a16ee4e9498 Reviewed-on: https://code.wireshark.org/review/18369 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-06-13Qt: Multi line import from hex dump without offsetsStig Bjørlykke1-0/+6
Fix importing hex dump without offsets with multiple lines. Change-Id: I7a7339e375b3125688f5b5d29f493704c7b9944a Reviewed-on: https://code.wireshark.org/review/15868 Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2016-06-12Qt: Add import from hex dump without offsetsStig Bjørlykke1-1/+9
Added support for importing from hex dump without offsets. This will create one packet with all hex values found in the file. Change-Id: I0414441721078befeb59aa6a87b9412646cfcf5c Reviewed-on: https://code.wireshark.org/review/15743 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>
2016-04-03Make the Flex scanners and YACC parser in libraries reentrant.Guy Harris1-3/+17
master-branch libpcap now generates a reentrant Flex scanner and Bison/Berkeley YACC parser for capture filter expressions, so it requires versions of Flex and Bison/Berkeley YACC that support that. We might as well do the same. For libwiretap, it means we could actually have multiple K12 text or Ascend/Lucent text files open at the same time. For libwireshark, it might not be as useful, as we only read configuration files at startup (which should only happen once, in one thread) or on demand (in which case, if we ever support multiple threads running libwireshark, we'd need a mutex to ensure that only one file reads it), but it's still the right thing to do. We also require a version of Flex that can write out a header file, so we change the runlex script to generate the header file ourselves. This means we require a version of Flex new enough to support --header-file. Clean up some other stuff encountered in the process. Change-Id: Id23078c6acea549a52fc687779bb55d715b55c16 Reviewed-on: https://code.wireshark.org/review/14719 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-03-27Pull the invocation of the Lex scanner into common code.Guy Harris1-9/+6
Instead of text_import_setup() and text_import_cleanup() routines, and the actual scanner invocation being done in the dialog box, have a text_import() routine that does all the work. Change-Id: Ifd8a999618dbb411d613e6596484e4c2e013431d Reviewed-on: https://code.wireshark.org/review/14647 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-12-13text_import: Argument with 'nonnull' attribute passed null found by Clang ↵Alexis La Goutte1-0/+4
Analyzer Change-Id: Ie070aa0f58cca156661ddd5689596e29ad56b128 Reviewed-on: https://code.wireshark.org/review/12412 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-11-07Clean up includes of unistd.h, fcntl.h, and sys/stat.h.Guy Harris1-4/+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>
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-11-19[pedantic] Replace usage of 'long' and 'long long'Bill Meier1-1/+1
Change-Id: I78fc82c1a83eb04d78a11fc76710c92dfc916208 Reviewed-on: https://code.wireshark.org/review/5395 Reviewed-by: Bill Meier <wmeier@newsguy.com>
2014-10-17Remove unnecessary includes of <ctype.h>.Guy Harris1-1/+0
Change-Id: I8eacec5fa8d57b10d40a3627197461dae89c6cb2 Reviewed-on: https://code.wireshark.org/review/4768 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-07-29Fix Argument with 'nonnull' attribute passed null found by ClangAlexis La Goutte1-0/+5
Change-Id: I719d8adeb4bc6dbd1e34fe56f7cf68e4c6286dc9 Reviewed-on: https://code.wireshark.org/review/3246 Reviewed-by: Evan Huus <eapache@gmail.com>
2014-07-06Clean up handling of missing functions.Guy Harris1-1/+1
With autotools, CMake, and nmake, if we have a function, #define HAVE_{function_name_in_all_caps}, otherwise don't #define it. If we provide our own version of a function in libwsutil, make sure we have a header that declares it, and *ONLY* include that header if HAVE_{function_name_in_all_caps} is *NOT* defined, so that we don't have the system declaration and our declaration colliding. Check for inet_aton, strncasecmp, and strptime with CMake, just as we do with autotools. Simplify the addition of {function_name_in_all_caps}_LO to libwsutil in autotools. Change-Id: Id5be5c73f79f81919a3a865324e400eca7b88889 Reviewed-on: https://code.wireshark.org/review/2903 Reviewed-by: Guy Harris <guy@alum.mit.edu>
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-09Revert "Refactor Wiretap"Guy Harris1-1/+1
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-1/+1
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-27Fix bug9931 'Encapsulated ethernet packets sometimes show invalid FCS'Hadriel Kaplan1-5/+2
This fixes part-1 of bug9931: the uninitialized use of a wtap_pkthdr struct. The second part of the bug deals with dissectors calling the Ethernet dissector for ecnapsulated Ethernet packets but using the wrong dissector handle to do so. That's unrelated to the issue this commit addresses, so I'm splitting them up. Change-Id: I87be7b736f82dd74d8c261062f88143372b5344c Reviewed-on: https://code.wireshark.org/review/848 Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com> Reviewed-by: Anders Broman <a.broman58@gmail.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>
2013-12-23From Ville Skyttä: Spelling FixesBill Meier1-1/+1
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9591 svn path=/trunk/; revision=54387
2013-09-02Fix some Dead Store (Dead assignement/Dead increment) Warning found by ClangAlexis La Goutte1-1/+1
svn path=/trunk/; revision=51682
2013-04-05Match the new text2pcap max packet import size of 65KiB-1 from r48738.Chris Maynard1-2/+2
svn path=/trunk/; revision=48750
2013-04-05Don't forget to move the trailing '\0'.Michael Tüxen1-1/+2
svn path=/trunk/; revision=48746
2013-04-02Add support for the initial direction indication. Irene will hookMichael Tüxen1-6/+37
it up to the GUI soon. svn path=/trunk/; revision=48696
2012-12-26Fix a bunch of warnings.Guy Harris1-45/+45
Cast away some implicit 64-bit-to-32-bit conversion errors due to use of sizeof. Cast away some implicit 64-bit-to-32-bit conversion errors due to use of strtol() and strtoul(). Change some data types to avoid those implicit conversion warnings. When assigning a constant to a float, make sure the constant isn't a double, by appending "f" to the constant. Constify a bunch of variables, parameters, and return values to eliminate warnings due to strings being given const qualifiers. Cast away those warnings in some cases where an API we don't control forces us to do so. Enable a bunch of additional warnings by default. Note why at least some of the other warnings aren't enabled. randpkt.c and text2pcap.c are used to build programs, so they don't need to be in EXTRA_DIST. If the user specifies --enable-warnings-as-errors, add -Werror *even if the user specified --enable-extra-gcc-flags; assume they know what they're doing and are willing to have the compile fail due to the extra GCC warnings being treated as errors. svn path=/trunk/; revision=46748
2012-12-05Fix numerous instances of a variable/parameter name "shadowing" a library ↵Bill Meier1-1/+2
function name; (At least some (gcc ?) compilers give a "shadow" warning for these). svn path=/trunk/; revision=46402
2012-10-24Fix indent and add Modelines info for new common ui source file(s)Alexis La Goutte1-106/+119
svn path=/trunk/; revision=45763
2012-10-16Add wtap_pseudo_header union to wtap_pkthdr structure.Jakub Zawadzki1-1/+1
Use pkthdr instead of pseudo_header as argument for dissecting. svn path=/trunk/; revision=45601
2012-09-20Have File->import write pcapng files.Anders Broman1-0/+6
svn path=/trunk/; revision=45025
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-09-14Create a common libui using CMake similar to what we do with Autotools.Gerald Combs1-0/+976
Move the GTK+ text import code to the common UI directory. Create wtap_encap_requires_phdr() from code in file_import_dlg.c. svn path=/trunk/; revision=44904