aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/lanalyzer.c
AgeCommit message (Collapse)AuthorFilesLines
2013-08-10Fix error when build with clang 3.0Alexis La Goutte1-1/+1
wiretap/lanalyzer.c:643:24: error: implicit conversion loses integer precision: 'const __suseconds_t' (aka 'const long') to 'gint32' (aka 'int') [-Werror,-Wshorten-64-to-32] gint32 usec = a->tv_usec; ~~~~ ~~~^~~~~~~ svn path=/trunk/; revision=51249
2013-06-17Merge "read record header" and "read packet data" routines into a singleGuy Harris1-21/+15
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-28/+6
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-05-18Put the code to read trace record headers into a common routine used byGuy Harris1-55/+65
both the read and the seek-read routines. Have the read routine return the offset of the record header as the record's offset, so that the seek-read routine can read that header. svn path=/trunk/; revision=49397
2013-03-25Wiretap file open routines should not free wth->priv on error, since thatEvan Huus1-10/+0
leads to a double-free in wtap_close. Fix all the instances I found via manual code review, and add a brief comment to the list of open routines in file_access.c Fixes https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8518 svn path=/trunk/; revision=48552
2013-03-17From beroset:Anders Broman1-5/+11
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
2012-12-27Do not call wtap_file_read_unknown_bytes() orGuy Harris1-22/+23
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-16Add wtap_pseudo_header union to wtap_pkthdr structure.Jakub Zawadzki1-4/+4
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-06-02Try to squelch warningsAnders Broman1-1/+1
svn path=/trunk/; revision=42998
2012-05-04file_seek() used to be a wrapper around fseek() or gzseek(), both ofGuy Harris1-12/+1
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-13Remove doubled semicolons and semicolons outside function.Jakub Zawadzki1-1/+1
svn path=/trunk/; revision=42053
2012-02-26For LANalyzer files, make the "File type name" be the file comment.Guy Harris1-7/+41
Display the file comment in the Summary dialog. svn path=/trunk/; revision=41188
2012-02-25Add a presence flag field to the packet information structure filled inGuy Harris1-0/+2
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-3/+3
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-12-13Check for a bogus record size. Fixes bug 6670.Guy Harris1-0/+10
svn path=/trunk/; revision=40169
2011-09-01Use guint8 rather than guchar for raw octets and pointers to arrays ofGuy Harris1-3/+3
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-07-10Move the definitions of LANalyzer records to lanalyzer.c.Guy Harris1-14/+155
Use LA_RecordHeaderSize rather than sizeof, to squelch some compiler complaints. svn path=/trunk/; revision=37956
2011-07-10Define a structure for the record header, and read into that, and thenGuy Harris1-33/+18
extract values from it. svn path=/trunk/; revision=37954
2011-07-10At that point in the code, bytes_read isn't the total number of recordGuy Harris1-3/+3
header bytes read, as we're reading the two header fields separately and checking the byte count for each read. We *do*, however, know that the record header is 4 bytes long, so we can just seek back 4 bytes. svn path=/trunk/; revision=37953
2011-05-10file_read() can return -1; don't just blindly add it to a previousGuy Harris1-6/+23
file_read() return value. Use wtap_file_read_expected_bytes() in a number of places. svn path=/trunk/; revision=37053
2011-04-21Add a new WTAP_ERR_DECOMPRESS error, and use that for errors discoveredGuy Harris1-9/+9
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-12"This file format can't be written to a pipe" and "this file formatGuy Harris1-9/+1
can't be saved in compress form" are both equivalent to "this file file format requires seeking when writing it". Change the "can compress" Boolean in the file format table to "writing requires seeking", give all the entries the proper value, and do the checks for attempting to write a file format to a pipe or write it in compressed format to common code. This means we don't need to pass the "can't seek" flag to the dump open routines. svn path=/trunk/; revision=36575
2011-04-06From Jakub Zawadzki:Guy Harris1-10/+10
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-02-25From Robert Bullen: Fix "Potential access violation when writing to ↵Bill Meier1-1/+13
LANalyzer files" https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=5698 (Note from me: Before the fix "File ! Save As" in Lanalyzer format crashed quite consistently on my Windows 7) svn path=/trunk/; revision=36061
2011-02-25Revert SVN #36059; patch from Bug #5698 to be used insteadBill Meier1-2/+1
svn path=/trunk/; revision=36060
2011-02-25Fix Bug #5698: "Potential access violation when writing to LANalyzer files"Bill Meier1-1/+2
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=5698 Note: before fix File ! SaveAs in Lanalyzer format crashed quite consistently on Windows. svn path=/trunk/; revision=36059
2010-06-06Don't use fwrite directly when writing a dump file; call it throughGuy Harris1-192/+100
wtap_dump_file_write(). Replace various wrappers around fwrite() with wtap_dump_file_write(), or at least make the wrappers call wtap_dump_file_write(). svn path=/trunk/; revision=33116
2010-02-26Move the definitions of all the private data structures out ofGuy Harris1-22/+14
wtap-int.h, and change the unions of pointers to those private data structures into just void *'s. Have the generic wtap close routine free up the private data, rather than the type-specific close routine, just as the wtap_dumper close routine does for its private data. Get rid of close routines that don't do anything any more. svn path=/trunk/; revision=32015
2010-02-24Define the private data structures for some particular capture fileGuy Harris1-11/+19
types in the modules for those capture file types, not in wtap-int.h, so wtap-int.h doesn't have to change when the code to handle that particular capture type changes, or a new capture file type is added. (Ultimately, we should do this for all the private data structures.) svn path=/trunk/; revision=31974
2009-10-26Update URL for LANalyzer file format.Guy Harris1-1/+1
svn path=/trunk/; revision=30717
2009-03-09P64 fixes.Gerald Combs1-1/+1
svn path=/trunk/; revision=27683
2007-03-21set compiler option "treat warnings as errors" - to prevent new warnings for ↵Ulf Lamping1-2/+2
wiretap remove all compiler warnings: a) prevent wrong malloc/free definitions by lex/yacc generated files b) add int/time_t casts - MSVC2005 is more "sensitive" about this than MSVC6 svn path=/trunk/; revision=21078
2006-11-05change all file offsets from long to gint64 so we can - theoretically - ↵Ulf Lamping1-4/+4
handle files > 2GB correct. Please distclean Win32 builds! svn path=/trunk/; revision=19814
2005-08-28Ethereal requires 64-bit integrer support; do the time stampGuy Harris1-12/+10
calculations with integers, which avoids some floating-point inaccuracy. svn path=/trunk/; revision=15602
2005-08-25timestamp display precision:Ulf Lamping1-0/+1
- automatic adjustment depending on file format - manual adjustment through menu items save the setting in the recent file svn path=/trunk/; revision=15534
2005-08-24EVERYTHING IN THE BUILDBOT IS GOING TO BE RED!!! Sorry! Ulf Lamping1-5/+9
I've done more than a day to change the timestamp resolution from microseconds to nanoseconds. As I really don't want to loose those changes, I'm going to check in the changes I've done so far. Hopefully someone else will give me a helping hand with the things left ... What's done: I've changed the timestamp resolution from usec to nsec in almost any place in the sources. I've changed parts of the implementation in nstime.s/.h and a lot of places elsewhere. As I don't understand the editcap source (well, I'm maybe just too tired right now), hopefully someone else might be able to fix this soon. Doing all those changes, we get native nanosecond timestamp resolution in Ethereal. After fixing all the remaining issues, I'll take a look how to display this in a convenient way... As I've also changed the wiretap timestamp resolution from usec to nsec we might want to change the wiretap version number... svn path=/trunk/; revision=15520
2004-07-18Set the svn:eol-style property on all text files to "native", so thatGuy Harris1-1/+1
they have LF at the end of the line on UN*X and CR/LF on Windows; hopefully this means that if a CR/LF version is checked in on Windows, the CRs will be stripped so that they show up only when checked out on Windows, not on UN*X. svn path=/trunk/; revision=11400
2004-07-08If we don't know the board type in a Lanayzer capture, returnGuy Harris1-2/+2
WTAP_ERR_UNSUPPORTED_ENCAP, not WTAP_ERR_UNSUPPORTED, as it presumably means the capture was done on some type of device we don't know about. svn path=/trunk/; revision=11339
2004-03-03Have "wtap_read()" set "wth->phdr.pkt_encap" to "wth->file_encap",Guy Harris1-2/+1
rather than requiring individual capture file type handlers to do it (unless they're doing per-packet encapsulation, in which case we check to make sure they didn't *leave* it as WTAP_ENCAP_PER_PACKET). svn path=/trunk/; revision=10290
2004-01-25Have the Wiretap open, read, and seek-and-read routines return, inGuy Harris1-11/+15
addition to an error code, an error info string, for WTAP_ERR_UNSUPPORTED, WTAP_ERR_UNSUPPORTED_ENCAP, and WTAP_ERR_BAD_RECORD errors. Replace the error messages logged with "g_message()" for those errors with g_strdup()ed or g_strdup_printf()ed strings returned as the error info string, and change the callers of those routines to, for those errors, put the info string into the printed message or alert box for the error. Add messages for cases where those errors were returned without printing an additional message. Nobody uses the error code from "cf_read()" - "cf_read()" puts up the alert box itself for failures; get rid of the error code, so it just returns a success/failure indication. Rename "file_read_error_message()" to "cf_read_error_message()", as it handles read errors from Wiretap, and have it take an error info string as an argument. (That handles a lot of the work of putting the info string into the error message.) Make some variables in "ascend-grammar.y" static. Check the return value of "erf_read_header()" in "erf_seek_read()". Get rid of an unused #define in "i4btrace.c". svn path=/trunk/; revision=9852
2004-01-07The year in a LANalyzer capture's trace summary record is a 2-byte yearGuy Harris1-7/+5
number. svn path=/trunk/; revision=9583
2004-01-05 removed some MSVC warnings (level 3)Ulf Lamping1-2/+2
svn path=/trunk/; revision=9558
2003-12-29Make all the byte arrays for writing out stuff "guint8" rather thanGuy Harris1-11/+11
"gint8" - there's no reason for them to be signed, and making them signed can cause compiler warnings if a value won't fit in 8 bits if sign-extended. svn path=/trunk/; revision=9467
2003-12-28removed some MSVC warnings (warning level 2)Ulf Lamping1-3/+3
svn path=/trunk/; revision=9459
2003-12-11prevent MSVC warning:Ulf Lamping1-13/+13
"warning C4761: Gr��enkonflikt im Argument. Konvertierung vorgenommen" -> size conflict in argument, conversion done svn path=/trunk/; revision=9244
2003-10-01Have a pseudo-header for Ethernet packets, giving the size of the FCS -Guy Harris1-2/+42
0 means "there is no FCS in the packet data", 4 means "there is an FCS in the packet data", -1 means "I don't know whether there's an FCS in the packet data, guess based on the packet size". Assume that Ethernet encapsulated inside other protocols has no FCS, by having the "eth" dissector assume that (and not check for an Ethernet pseudo-header). Have "ethertype()" take an argument giving the FCS size; pass 0 when appropriate. Fix up Wiretap routines to set the pseudo-header. This means we no longer use the "generic" seek-and-read routine, so get rid of it. svn path=/trunk/; revision=8574
2003-07-29Don't free "wdh->dump.opaque" in the close routine - "wtap_dump_close()"Guy Harris1-6/+2
does it for you. "wdh->dump.opaque" should never be null, so unconditionally call "lanalyzer_dump_header()". svn path=/trunk/; revision=8095
2003-06-30Use the "rx_frm_len" field from the trace packet data record header,Guy Harris1-2/+25
rathe than the record length minus the record header length, as the number of available (captured) bytes in the packet. Check to make sure that value isn't bigger than the record length minus the header length. Only subtract the 4-byte FCS length from the purported length of the packet on the wire if that would leave the on-the-wire length >= the number of captured bytes, so that we can better handle capture files from programs that produce LANalyzer-format captures where the on-the-wire length *doesn't* include the FCS. svn path=/trunk/; revision=7948