summaryrefslogtreecommitdiff
path: root/wiretap/wtap.c
AgeCommit message (Collapse)AuthorFilesLines
2014-10-07Provide an error message for WTAP_ERR_CANT_WRITE.Guy Harris1-1/+1
Change-Id: Iffc762ba60ac523148310ea2a432d4953bc64a94 Reviewed-on: https://code.wireshark.org/review/4541 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-10-07No need for WTAP_ERR_CANT_READ.Guy Harris1-1/+51
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>
2014-10-07Whitespace cleanups.Guy Harris1-2/+2
Change-Id: I92f983b2e04defab30eb31c14c484b9f0f582413 Reviewed-on: https://code.wireshark.org/review/4513 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-10-07Add some higher-level file-read APIs and use them.Guy Harris1-11/+61
Add wtap_read_bytes(), which takes a FILE_T, a pointer, a byte count, an error number pointer, and an error string pointer as arguments, and that treats a short read of any sort, including a read that returns 0 bytes, as a WTAP_ERR_SHORT_READ error, and that returns the error number and string through its last two arguments. Add wtap_read_bytes_or_eof(), which is similar, but that treats a read that returns 0 bytes as an EOF, supplying an error number of 0 as an EOF indication. Use those in file readers; that simplifies the code and makes it less likely that somebody will fail to supply the error number and error string on a file read error. Change-Id: Ia5dba2a6f81151e87b614461349d611cffc16210 Reviewed-on: https://code.wireshark.org/review/4512 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-09-28Make the time stamp resolution per-packet.Guy Harris1-2/+5
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>
2014-09-22pcapng: don't leak block option stringsEvan Huus1-0/+6
I *think* I got all the cases; I got most of them, at any rate, and enough to shut up valgrind in all the test cases I ran. Change-Id: I393bac0756f577b65e400b792f6719fa6ec4056a Reviewed-on: https://code.wireshark.org/review/4244 Reviewed-by: Michael Mann <mmann78@netscape.net> Reviewed-by: Evan Huus <eapache@gmail.com>
2014-08-02Rename buffer_ routines to ws_buffer_ to avoid name collisions.Guy Harris1-4/+4
In particular, epan/wslua/lrexlib.c has its own buffer_ routines, causing some linker warnings on some platforms, as reported in bug 10332. (Not to be backported to 1.12, as that would change the API and ABI of libwsutil and libwiretap. We should also make the buffer_ routines in epan/wslua/lrexlib.c static, which should also address this problem, but the name change avoids other potential namespace collisions.) Change-Id: I1d42c7d1778c7e4c019deb2608d476c52001ce28 Reviewed-on: https://code.wireshark.org/review/3351 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-07-15Only one buffer.c, please.Guy Harris1-1/+1
Otherwise, if you link with both libwiretap and libfiletap, it's anybody's guess which one you get. That means you're wasting memory with two copies of its routines if they're identical, and means surprising behavior if they're not (which showed up when I was debugging a double-free crash - fixing libwiretap's buffer_free() didn't fix the problem, because Wireshark happened to be calling libfiletap' unfixed buffer_free()). There's nothing *tap-specific about Buffers, anyway, so it really belongs in wsutil. Change-Id: I91537e46917e91277981f8f3365a2c0873152870 Reviewed-on: https://code.wireshark.org/review/3066 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-06-19Long and short names are invertedPascal Quantin1-1/+1
Change-Id: Ief3c86562d5eadb845b5a32dc704a61ccd27fdf6 Reviewed-on: https://code.wireshark.org/review/2443 Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2014-06-06IPMI trace dissector (without PCAP-dependent part).U-beauty\bdn1-0/+3
Added KCS and TMode protocol dissectors. Request/response logic has been revised. Saved request data logic has been revised. Added Get Message command response dissector. Added missing PICMG command dissectors. Added new PICMG command dissectors. Added new PPS OEM command entries. Added VITA 46.11 command dissectors. From: Bill Meier: - refs to value_strings/range_strings in hf[] entries, by convention, should use VALS/RVALS macros; - refs to true_false_strings should use TFS(&...) macro. also: true_false_string definitions should not be defined as arrays. - remove some unneeded #includes (packet-ipmi.c). - Do some re-indentation. - Add editor-modelines as needed. bug: 10004 Change-Id: Ib269b35784c0b70892d1e0111bcfb483ea64092c Reviewed-on: https://code.wireshark.org/review/1185 Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-06-04The subtype_seek_read() functions populate *phdr, not wth->phdr.Michael Tüxen1-3/+3
So don't use the values. This problem show up on pcapng files resulting from captures of multiple interfaces. Change-Id: I30b0598602b0b69233107d35be4360475d8648d8 Reviewed-on: https://code.wireshark.org/review/1950 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-05-24Add support for plugins to handle pcap-ng block types.Guy Harris1-1/+1
We rename "file format" plugins to "libwiretap" plugins, as they can register as read handlers for a new file type, read/write handlers for a pcap-ng block type (or both). To register as a pcap-ng block type handler, in the register_wtap_module() routine of your plugin, call register_pcapng_block_type_handler() with the pcap-ng block type and pointers to your routines to read and write those blocks. Those routines should read and write REC_TYPE_FILE_TYPE_SPECIFIC records, with the block type in the pseudo-header for the record in the struct wtap_pkthdr structure, with time stamps stored in that structure, and with a blob of data for the rest of the record. This is for bug 8590. Change-Id: I71847d834854a29ceb85894fd094c2ae91a04273 Reviewed-on: https://code.wireshark.org/review/1775 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-1/+3
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-23Revert "Allow wtap_read() and wtap_seek_read() to return non-packet records."Guy Harris1-14/+8
This reverts commit c0c480d08c175eed4524ea9e73ec86298f468cf4. A better way to do this is to have the record type be part of struct wtap_pkthdr; that keeps the metadata for the record together and requires fewer API changes. That is in-progress. Change-Id: Ic558f163a48e2c6d0df7f55e81a35a5e24b53bc6 Reviewed-on: https://code.wireshark.org/review/1741 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-05-23Allow wtap_read() and wtap_seek_read() to return non-packet records.Guy Harris1-8/+14
This is the first step towards implementing the mechanisms requestd in bug 8590; currently, we don't return any records other than packet records from libwiretap, and just ignore non-packet records in the rest of Wireshark, but this at least gets the ball rolling. Change-Id: I34a45b54dd361f69fdad1a758d8ca4f42d67d574 Reviewed-on: https://code.wireshark.org/review/1736 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-05-17wiretap: remove unused code, drop number_of_interfacesPeter Wu1-8/+5
While investigating an ASAN issue (fixed in commit dcdd076ab0965c346efe90051678ba790eaf7a02), I got greatly confused by three different types having the same "interface_data" field name: * pcapng_t *pn stores an array of interface_data_t objects. * wtap *wth stores an array of wtapng_if_descr_t objects. * pcapng_dump_t should store an array of interface_data_t objects. pcapng_dump_t and friends are unused since commit c7f1a431d23e17a15777652b1252e139f182b0e6, so drop it. To fix the confusion, rename the interface_data_t type to interface_info_t type and use the local variable "iface_info" everywhere. Rename interface_data of pcapng_t to "interfaces" and add a comment what this exactly means (interfaces listed in the capture file). Drop the number_of_interfaces field for interfaces as the array length is already available from GArray. Now interface_data is always initialized for wth (which also gets copied to idb). s/int/guint/g and replace cast at some places. There are no regressions for the in-tree test suite. Change-Id: I2d5985c9f1e43f8230dbb4a73bd1e243c4858170 Reviewed-on: https://code.wireshark.org/review/1656 Reviewed-by: Evan Huus <eapache@gmail.com> Tested-by: Evan Huus <eapache@gmail.com> Reviewed-by: Michael Mann <mmann78@netscape.net>
2014-05-09Revert "Refactor Wiretap"Guy Harris1-103/+69
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-69/+103
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-04-28Add dissector for LINKTYPE_EPONPhilip Rosenberg-Watt1-0/+3
See IEEE Standard 802.3-2012 Section 5, Clause 65 and CableLabs DPoE Security and Certificate Specification 1.0, Section 6. Currently dissects 1G mode. 10G mode will be added when hardware is available. Change-Id: I6232af9bf6807644ef66a120d97e5fa5927988fe Reviewed-on: https://code.wireshark.org/review/1284 Tested-by: Alexis La Goutte <alexis.lagoutte@gmail.com> Reviewed-by: Evan Huus <eapache@gmail.com>
2014-04-25Don't fail if a pcap-NG PB or EPB has caplen > actual len.Guy Harris1-1/+19
We don't fail for other file types; there's no point in failing for pcap-NG. wtap_read() will ensure that caplen <= len. Make wtap_seek_read() ensure that caplen <= len as well. Fixes bug 10037. Change-Id: I41fbcf54341ea0429cef875442ea1f1377177a5f Reviewed-on: https://code.wireshark.org/review/1353 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-04-14Fix wtap displayable namesMichal Labedzki1-12/+12
Also fix indentions. Change-Id: I5440859aaf3ec1dbf416d9da6c1dab71bec803d8 Reviewed-on: https://code.wireshark.org/review/1094 Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2014-04-01Add a dissector for Apple's PKTAP headers.Guy Harris1-0/+3
It automatically works for LINKTYPE_PKTAP and, by default, for LINKTYPE_USER2; if any other dissector is specified for LINKTYPE_USER2, that dissector overrides PKTAP. Change-Id: Ic00ac8a81c6101e45d638d337aef42df3920da12 Reviewed-on: https://code.wireshark.org/review/903 Reviewed-by: Evan Huus <eapache@gmail.com>
2014-04-01Update encap_table_base.Guy Harris1-0/+24
As the comment after the WTAP_ENCAP_ list says, "After adding new item here, please also add new item to encap_table_base array". Change-Id: I918603fa271978b3a81525466c5f4067efc7a783 Reviewed-on: https://code.wireshark.org/review/897 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-03-20Revert "Allow pcapng interface options to be available to dissectors."Anders Broman1-3/+0
This patch causes Wireshark/tshark to segfault if the file is reread(open a file and press reload). The test suite also fails on 2.1.1 Step: Exit status for existing file: "/home/wireshark/builders/trunk/sol10sparc/build/test/captures/dhcp.pcap" must be 0/home/wireshark/builders/trunk/sol10sparc/build/test/suite-clopts.sh: line 149: 6646 Segmentation Fault (core dumped) $TSHARK -r "${CAPTURE_DIR}dhcp.pcap" > ./testout.txt 2>&1 OSX build bot chokes on pcapng.c: In function 'pcapng_destroy_option_value': pcapng.c:377: warning: implicit declaration of function 'g_byte_array_unref' pcapng.c:379: warning: implicit declaration of function 'g_array_unref' pcapng.c: In function 'pcapng_collect_block_option': pcapng.c:419: warning: implicit declaration of function 'g_byte_array_new_take' pcapng.c:419: warning: initialization makes pointer from integer without a cast these functions are glib 2.22 This reverts commit 7b13a3b0f6a5617e0e352f87cc5a20afea226aa8. Change-Id: Ia82fdb2d08287bc2cd2841e1e941ae68cbc2e009 Reviewed-on: https://code.wireshark.org/review/749 Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-03-20Allow pcapng interface options to be available to dissectors.Christopher Kilgour1-0/+3
Interface options[1], and more generally pcapng options[2], are useful information that can provide improved dissector output. Prior to this change, only certain pcapng interface options were interpreted and made available to dissectors, e.g. the interface name or description. This change augments the situation by providing epan_get_interface_option( ), which returns an array of byte arrays if the option code exists (otherwise NULL). Each element of the array is a byte buffer containing the raw data of the option. An array-of-buffers is used because pcapng allows for multiple instances of the same option to be present in the file. All interface options found in a pcapng file are thus made available to the dissector. The implementation also provides infrastructure to collect options from other pcapng blocks such as the section header. Currently these options are discarded, but could be retained in the future to support more features. [1] http://www.winpcap.org/ntar/draft/PCAP-DumpFileFormat.html#sectionidb [2] http://www.winpcap.org/ntar/draft/PCAP-DumpFileFormat.html#sectionopt Change-Id: I944b6f0f03dde9b8e7d1348b76acde6f9d312f37 Reviewed-on: https://code.wireshark.org/review/331 Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-03-16Support to version 3.0 of netscaler packet wire format.Guy Harris1-0/+3
From shekhar.chandra@citrix.com. See bug 9280. Change-Id: If3abbc653bb1f127b151976d4183af4c4f1e71eb Reviewed-on: https://code.wireshark.org/review/658 Reviewed-by: Michael Mann <mmann78@netscape.net>
2014-03-07Introduces two new Bluetooth DLTs for RF-based captures.Christopher Kilgour1-0/+5
Adds support for BLUETOOTH_LE_LL_WITH_PHDR, dissector integrates with existing BTLE dissector. Fixes BTLE dissector to correctly extract packet CRC. Adds CRC checking to BTLE dissector. Provides optional context to BTLE dissector that allows RF captures to provide link-layer hints for dissection details. Significantly, parameters for determining CRC correctness are provided, as well as Access Address validity information. Change-Id: I7d4936b053353a7f9c524021c01f67f5828253fb Reviewed-on: https://code.wireshark.org/review/310 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>
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>
2014-01-22Don't write out packets that have a "captured length" bigger than we'reGuy Harris1-1/+2
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-12Bluetooth/Ubertooth improvements. Bug 9606 ↵Michael Mann1-0/+4
(https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9606) From Michal Labedski 1. add support for new btsnoop "format" introduced by BlueZ team in "btmon" tool 2. Bluetooth: Make EIR, AD and COD more generic 3. Bluetooth: HCI/LL: Update Error Codes to Core 4.1 Specification 4. Ubertooth: Fix response command handling 5. Ubertooth: Update to support firmware version 6. Ubertooth: Dissect by Vendor Id/Product Id svn path=/trunk/; revision=54699
2014-01-02No seek-read routines use the length argument, so eliminate it fromGuy Harris1-4/+2
wtap_seek_read(). svn path=/trunk/; revision=54570
2013-12-17Get rid of trailing periods in some error messages for consistency; theGuy Harris1-1/+1
others don't have trailing periods, and the caller adds a period as desired. svn path=/trunk/; revision=54199
2013-12-07Add WTAP_ENCAP_NETLINK which maps to DLT_NETLINK /253/Jakub Zawadzki1-0/+3
svn path=/trunk/; revision=53834
2013-12-02Space between STANAG and the standard number.Guy Harris1-1/+1
svn path=/trunk/; revision=53739
2013-12-02Fix encap_table_base[] array.Jakub Zawadzki1-3/+6
svn path=/trunk/; revision=53738
2013-12-02Move most of the plugin code from epan to wsutil and remove allGuy Harris1-0/+69
knowledge of particular types of plugins. Instead, let particular types of plugins register with the common plugin code, giving a name and a routine to recognize that type of plugin. In particular applications, only process the relevant plugin types. Add a Makefile.common to the codecs directory. svn path=/trunk/; revision=53710
2013-11-30STANAG 5066 DTS Layer dissector. Bug 9217 ↵Michael Mann1-1/+4
(https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9217) From İbrahim Can Yüce From me: Update to new tcp_dissect_pdus format, minor whitespace issues noticed in wiretap files. svn path=/trunk/; revision=53669
2013-11-08(Trivial) whitespace cleanup (mostly trailing whitespace).Bill Meier1-1/+1
svn path=/trunk/; revision=53172
2013-11-08The "file types" we have are actually combinations of types andGuy Harris1-2/+2
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-10-28Revert SVN #52914;Bill Meier1-4/+0
OSX-10.6-x64 buildbot still givs an error (At least we now know which line of code gives the error). svn path=/trunk/; revision=52915
2013-10-28From Shekhar Chandra: support for version 3.0 of netscaler packet wire format.Bill Meier1-0/+4
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9280 (Revised patch: let's see if this version compiles w/o error on all the buildbots) svn path=/trunk/; revision=52914
2013-10-18Revert SVN #52665.Bill Meier1-4/+0
Compilation fails on (only the ?) OSX-10.6-x64 buildbot with error: netscaler.c: In function 'nstrace_read_v30': netscaler.c:1295: warning: implicit conversion shortens 64-bit value into a 32-bit value (Life is too short for me to dig multiple levels deep into a set of macros to try to see which actual line of code is causing the problem. Maybe the patch submitter can identify the problem). svn path=/trunk/; revision=52666
2013-10-18From Shekhar Chandra: support for version 3.0 of netscaler packet wire format.Bill Meier1-0/+4
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9280 From me: fix indentation(tabs->spaces) and trailing whitespace. svn path=/trunk/; revision=52665
2013-06-28Use newly assigned DLT for PDU export functionalityPascal Quantin1-0/+6
svn path=/trunk/; revision=50212
2013-06-16Have the seek-read routines take a Buffer rather than a guint8 pointerGuy Harris1-14/+31
as the "where to put the packet data" argument. This lets more of the libwiretap code be common between the read and seek-read code paths, and also allows for more flexibility in the "fill in the data" path - we can expand the buffer as needed in both cases. svn path=/trunk/; revision=49949
2013-06-10Allign the error messages.Anders Broman1-0/+1
svn path=/trunk/; revision=49870
2013-05-30From Chris Bontje via https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8644 :Pascal Quantin1-0/+3
SEL RTAC (Real Time Automation Controller) EIA-232 Serial-Line Dissection svn path=/trunk/; revision=49635
2013-05-18Use g_array_index() to get at elements of the encapsulation table array;Guy Harris1-9/+7
this avoids some compiler warnings from clang about alignment. svn path=/trunk/; revision=49398
2013-04-14From Tomasz Mon via https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8503 :Pascal Quantin1-0/+9
Add USBPcap support svn path=/trunk/; revision=48847