aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/ber.c
AgeCommit message (Collapse)AuthorFilesLines
2013-06-17Merge "read record header" and "read packet data" routines into a singleGuy Harris1-29/+25
routine, used both by read and seek-read routines. svn path=/trunk/; revision=49988
2013-06-16Have the seek-read routines take a Buffer rather than a guint8 pointerGuy Harris1-11/+5
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
2012-12-27Do not call wtap_file_read_unknown_bytes() orGuy Harris1-1/+3
wtap_file_read_expected_bytes() from an open routine - open routines are supposed to return -1 on error, 0 if the file doesn't appear to be a file of the specified type, or 1 if the file does appear to be a file of the specified type, but those macros will cause the caller to return FALSE on errors (so that, even if there's an I/O error, it reports "the file isn't a file of the specified type" rather than "we got an error trying to read the file"). When doing reads in an open routine before we've concluded that the file is probably of the right type, return 0, rather than -1, if we get WTAP_ERR_SHORT_READ - if we don't have enough data to check whether a file is of a given type, we should keep trying other types, not give up. For reads done *after* we've concluded the file is probably of the right type, if a read doesn't return the number of bytes we asked for, but returns an error of 0, return WTAP_ERR_SHORT_READ - the file is apparently cut short. For NetMon and NetXRay/Windows Sniffer files, use a #define for the magic number size, and use that for both magic numbers. svn path=/trunk/; revision=46803
2012-10-19Hoist the code to set the wtap_pkthdr into a routine, and call it inGuy Harris1-8/+15
both the read and the seek-read routine, now that a pointer to the wtap_pkthdr is passed to the seek-read routine. svn path=/trunk/; revision=45655
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-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
2012-05-04file_seek() used to be a wrapper around fseek() or gzseek(), both ofGuy Harris1-4/+5
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-02-25Add a presence flag field to the packet information structure filled inGuy Harris1-5/+3
by Wiretap, to indicate whether certain fields in that structure actually have data in them. Use the "time stamp present" flag to omit showing time stamp information for packets (and "packets") that don't have time stamps; don't bother working very hard to "fake" a time stamp for data files. Use the "interface ID present" flag to omit the interface ID for packets that don't have an interface ID. We don't use the "captured length, separate from packet length, present" flag to omit the captured length; that flag might be present but equal to the packet length, and if you want to know if a packet was cut short by a snapshot length, comparing the values would be the way to do that. More work is needed to have wiretap/pcapng.c properly report the flags, e.g. reporting no time stamp being present for a Simple Packet Block. svn path=/trunk/; revision=41185
2011-12-13Rename WTAP_ERR_BAD_RECORD to WTAP_ERR_BAD_FILE; it really reports anyGuy Harris1-1/+1
form of corruption/bogosity in a file, including in a file header as well as in records in the file. Change the error message wtap_strerror() returns for it to reflect that. Use it for some file header problems for which it wasn't already being used - WTAP_ERR_UNSUPPORTED shouldn't be used for that, it should only be used for files that we have no reason to believe are invalid but that have a version number we don't know about or some other non-link-layer-encapsulation-type value we don't know about. svn path=/trunk/; revision=40175
2011-05-09Get rid of the fd member of a wth structure; the FILE_T's in thatGuy Harris1-4/+2
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-5/+5
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-06From Jakub Zawadzki:Guy Harris1-1/+1
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
2010-02-23Don't use C++ keywords as variable names - prepend "ber_" in front ofGuy Harris1-11/+11
variables with BER metadata. svn path=/trunk/; revision=31956
2009-06-02Better heuristics for detecting BER encoded file, especially when initial ↵Graeme Lunt1-17/+19
tag is indefinite length encoded. Checked that the I4B traces reported in http://bugs.wireshark.org/bugzilla/show_bug.cgi?id=1972 still loads as expected. svn path=/trunk/; revision=28595
2009-01-04Minor rewording of a few comments; fix a few typos.Bill Meier1-1/+1
svn path=/trunk/; revision=27151
2007-11-05Strengthen BER and ERF heuristics to solve:Anders Broman1-0/+3
Fail to load I4B traces http://bugs.wireshark.org/bugzilla/show_bug.cgi?id=1972 svn path=/trunk/; revision=23367
2006-11-05change all file offsets from long to gint64 so we can - theoretically - ↵Ulf Lamping1-2/+2
handle files > 2GB correct. Please distclean Win32 builds! svn path=/trunk/; revision=19814
2006-09-12Get rid of a compiler warning.Gerald Combs1-8/+9
svn path=/trunk/; revision=19224
2006-06-17fix coverity "bug" 184 (false positive)Ronnie Sahlberg1-2/+1
the contract for wiretap ..._read() functions are that the *err pointer MUST always be provided as a valid pointer and not a NULL pointer. ber.c contained a spurios and redundant check for the pointer being non-NULL wich triggered coverity to detect this as a false positive. this redundant test if the pointer is NULL has been revoved. svn path=/trunk/; revision=18492
2006-05-15Fix some compiler warnings.Guy Harris1-5/+7
That requires that we define G_GINT64_MODIFIER ourselves if glib.h doesn't define it for us, as that's what should be used to print 64-bit integral values in any calls that use any of the GLib printf functions (directly or indirectly). svn path=/trunk/; revision=18154
2006-05-08Basic Encoding Rules (BER) encoded file reading. Not really a packet trace ↵Graeme Lunt1-0/+187
format but still useful for dissecting arbitrary BER/DER ASN.1. svn path=/trunk/; revision=18110