aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/wtap-int.h
AgeCommit message (Collapse)AuthorFilesLines
2014-10-07Add some higher-level file-read APIs and use them.Guy Harris1-27/+37
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-4/+12
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-05-23Revert "Allow wtap_read() and wtap_seek_read() to return non-packet records."Guy Harris1-4/+4
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-4/+4
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-1/+0
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-0/+54
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-54/+0
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-19Add capture file reader/writer support for Lua so scripts can implement new ↵Michael Mann1-5/+8
capture file formats. This enables a Lua script to implement a brand new capture file format reader/writer, so that for example one could write a script to read from vendor-specific "logs" of packets, and show them as normal packets in wireshark. Change-Id: Id394edfffa94529f39789844c382b7ab6cc2d814 Reviewed-on: https://code.wireshark.org/review/431 Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com> Reviewed-by: Michael Mann <mmann78@netscape.net> 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-01-02No seek-read routines use the length argument, so eliminate it fromGuy Harris1-1/+1
wtap_seek_read(). svn path=/trunk/; revision=54570
2013-12-03wiretap: start using <wsutil/pint.h>Jakub Zawadzki1-71/+2
svn path=/trunk/; revision=53764
2013-11-29Replace macros: BSWAP16, BSWAP32, BSWAP64 with glib-version.Jakub Zawadzki1-19/+0
XXX, people are not aware that expression of this macros might be evaluated multiple times, like: - BSWAP16(tvb_get_letohs(tvb, off)) : \ + GUINT16_SWAP_LE_BE(tvb_get_letohs(tvb, off)) : \ Should be tvb_get_ntohs() called? svn path=/trunk/; revision=53653
2013-11-29Expand macros: htoles(), htolel(), htolell()Jakub Zawadzki1-5/+0
svn path=/trunk/; revision=53651
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-09-22Get rid of struct addrinfo, use the hastables for name resolution instead.Anders Broman1-1/+1
svn path=/trunk/; revision=52176
2013-06-16Have the seek-read routines take a Buffer rather than a guint8 pointerGuy Harris1-1/+14
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-03-17From beroset:Anders Broman1-2/+2
implemented wtap_dump_file_seek() and _tell() implemented the previously declared but unimplemented wtap_dump_file_seek() and wtap_dump_file_tell() functions and used them in the seven files that had previously used a plain ftell or fseek and added error checking as appropriate. I also added a new error WTAP_ERR_CANT_SEEK_COMPRESSED and put it next to WTAP_ERR_CANT_SEEK causing renumbering of two of the existing error codes. https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8416 svn path=/trunk/; revision=48348
2013-03-01Export libwireshark symbols using WS_DLL_PUBLIC defineBalint Reczey1-3/+0
Also remove old WS_VAR_IMPORT define and related Makefile magic everywhere in the project. svn path=/trunk/; revision=47992
2013-02-28Export libwiretap symbols using WS_DLL_PUBLIC defineBalint Reczey1-1/+5
TODO: hide flex-generated functions svn path=/trunk/; revision=47948
2012-10-18Wrap lines a little differently.Guy Harris1-2/+3
svn path=/trunk/; revision=45654
2012-10-16Add wtap_pseudo_header union to wtap_pkthdr structure.Jakub Zawadzki1-3/+1
Use pkthdr instead of pseudo_header as argument for dissecting. svn path=/trunk/; revision=45601
2012-06-28Update Free Software Foundation address.Jakub Zawadzki1-1/+1
(COPYING will be updated in next commit) svn path=/trunk/; revision=43536
2012-05-04file_seek() used to be a wrapper around fseek() or gzseek(), both ofGuy Harris1-2/+0
which could use lseek() and were thus expensive due to system call overhead. To avoid making a system call for every packet on a sequential read, we maintained a data_offset field in the wtap structure for sequential reads. It's now a routine that just returns information from the FILE_T data structure, so it's cheap. Use it, rather than maintaining the data_offset field. Readers for some file formats need to maintain file offset themselves; have them do so in their private data structures. svn path=/trunk/; revision=42423
2012-04-26Put the pseudo-header information for Veriwave packets into the bufferGuy Harris1-0/+10
in little-endian byte order, as that's what the dissector expects. Add a pletohl() macro for that purpose. Fix comments (the Veriwave code is *not* writing data to a file!) and clean up indentation. svn path=/trunk/; revision=42255
2012-04-18Fix some indentation errors from the previous change.Guy Harris1-3/+3
svn path=/trunk/; revision=42118
2012-04-18Get rid of tabs, so we don't have to worry about 4-space vs. 8-space tabs.Guy Harris1-160/+161
svn path=/trunk/; revision=42117
2012-02-20Handle reading and writing of multiple IDB:s, write IDB options and use ↵Anders Broman1-3/+11
correct lengt for strings, handle more than 100 char comment svn path=/trunk/; revision=41082
2012-02-15Make it possible to get inforamtion from the read SHB to the one to write out.Anders Broman1-3/+5
svn path=/trunk/; revision=41032
2012-02-13White space changes.Anders Broman1-4/+4
svn path=/trunk/; revision=41015
2012-02-11Add the abillity to read and write option comments unedited.Anders Broman1-21/+21
This is POC we may want to have more efficient use of the frame data structure etc. But this allows for work to be done on the GUI to actually add comments. svn path=/trunk/; revision=40969
2012-02-09Add pcapng variables to wtap_pkthdr.Anders Broman1-4/+6
svn path=/trunk/; revision=40947
2012-01-21Replace wtap_file_extensions_string() with a routine that returns aGuy Harris1-0/+3
GSList of extensions for a file type, including extensions for the compressed versions of those file types that we can read. svn path=/trunk/; revision=40623
2011-11-17Rename pletonll() to reflect what it actually does, namely convert aGuy Harris1-2/+2
host-byte-order 64-bit integral quantity to little-endian byte order. svn path=/trunk/; revision=39900
2011-11-17A new macro needed by the WTAP_ENCAP_PER_PACKET support for writingGuy Harris1-0/+8
NetMon files. svn path=/trunk/; revision=39899
2011-09-21Fix ex "modeline" so it works;Bill Meier1-1/+1
See https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=5748 svn path=/trunk/; revision=39081
2011-09-01Use guint8 rather than guchar for raw octets and pointers to arrays ofGuy Harris1-1/+1
same. Add to wiretap/pcap-common.c a routine to fill in the pseudo-header for ATM (by looking at the VPI, VCI, and packet data, and guessing) and Ethernet (setting the FCS length appropriately). Use it for both pcap and pcap-ng files. svn path=/trunk/; revision=38840
2011-06-09The only place where we care about zlib is file_wrappers.c; includeGuy Harris1-4/+0
<zlib.h> there, rather than wtap-int.h. That obviates the need to include config.h earlier in ascend_scanner.l; revert the previous change, so we don't require a version of Flex that supports %top. svn path=/trunk/; revision=37640
2011-06-04Fix wiretap headers to allow error-free ABI dumping.Balint Reczey1-2/+0
svn path=/trunk/; revision=37543
2011-05-31Declare the snapshot_length as unsigned.Chris Maynard1-1/+1
svn path=/trunk/; revision=37479
2011-05-09Get rid of the fd member of a wth structure; the FILE_T's in thatGuy Harris1-1/+4
structure include a file descriptor. Add a wtap_fstat() for the file readers that use file times to generate time stamps (we really need a way to say "this file has no time stamps" or "this file has only relative time stamps). svn path=/trunk/; revision=37026
2011-04-21Add a new WTAP_ERR_DECOMPRESS error, and use that for errors discoveredGuy Harris1-4/+4
by the gunzipping code. Have it also supply a err_info string, and report it. Have file_error() supply an err_info string. Put "the file" - or, for WTAP_ERR_DECOMPRESS, "the compressed file", to suggest a decompression error - into the rawshark and tshark errors, along the lines of what other programs print. Fix a case in the Netscaler code where we weren't fetching the error code on a read failure. svn path=/trunk/; revision=36748
2011-04-12From Jakub Zawadzki: speed up random access to gzipped files, as per theGuy Harris1-0/+1
zran.c example in the zlib source. This means that problems in the file's contents might not be reported when a packet is read, as long as there's no problem in the contents of the file up to the last bit of compressed data for the packet; we now check for errors after finishing the sequential read of the file, at least in some programs, so that shouldn't be an issue (the other programs need to be changed to do so as well). This is necessary in order to be able to read all the packets we saw in the sequential pass; it also lets us get a few more packets from truncated files in some cases. svn path=/trunk/; revision=36577
2011-04-10Move the definition of the structure pointed to by a FILE_T intoGuy Harris1-26/+1
wiretap/file_wrappers.c; nothing outside of file_wrappers.c needs to know what it looks like, it just passes around pointers to it. svn path=/trunk/; revision=36538
2011-04-08Just make the fh member of a wtap_dumper_t a void * for now, and, in allGuy Harris1-3/+5
calls that use it, cast it to whatever it's supposed to be. Making it a gzFile means you can't use any stdio macros that reach inside the structure; making it a FILE *, as it used to be, amounts to trying to use a FILE * as a void * if we're writing a compressed file out. svn path=/trunk/; revision=36521
2011-04-08From Jakub Zawadzki:Guy Harris1-3/+30
Steal file_wrappers functions from zlib v2. svn path=/trunk/; revision=36513
2011-04-06From Jakub Zawadzki:Guy Harris1-2/+2
file_read(buf, bsize, count, file) macro is compilant with fread function and takes elements count+ size of each element, however to make it compilant with gzread() it always returns number of bytes. In wiretap file_read() this is not really used, file_read is called either with bsize set to 1 or count to 1. Attached patch remove bsize argument from macro. svn path=/trunk/; revision=36491
2011-03-24Add initial pcapng name resolution record support. Wireshark has readGerald Combs1-2/+21
support; TShark has read+write support. Additionally TShark can read a "hosts" file and write those records to a capture file. This uses "struct addrinfo" in many places and probably won't compile on some platforms. svn path=/trunk/; revision=36318
2010-06-06Move the seekback stuff out of esc_read() to the one place where it'sGuy Harris1-0/+9
done. Use the wtap_dump_file_ routines to write out capture files, and check for errors. Use the phton macros, when available, to translate to big-endian byte order. Add a new phton24() macro. Clean up indentation. svn path=/trunk/; revision=33114
2010-06-06Rename wtap_dump_file_write_all() to wtap_dump_file_write(), and haveGuy Harris1-3/+2
everybody use it; the places using the old wtap_dump_file_write() were using it in the same way the old wtap_dump_file_write_all() did. That also lets us get rid of wtap_dump_file_ferror(). Also, have the new wtap_dump_file_write() check for errors from gzwrite() and fwrite() differently - the former returns 0 on error, the latter can return a short write on error. svn path=/trunk/; revision=33113
2010-04-21From Chris Maynard:Guy Harris1-1/+17
Support PPP-over-USB. Don't remove the USB pseudo-header from the packet data for Linux USB packets, just byte-swap it if necessary and have the USB dissector fetch the pseudo-header from the raw packet data. Update USB language ID values. svn path=/trunk/; revision=32534