aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/file.c
Commit message (Collapse)AuthorAgeFilesLines
* Fixed small memory leak in wiretap (frame_buffer wasn't being freed),Gilbert Ramirez1999-11-101-9/+9
| | | | | | | and aligned g_malloc calls with g_free calls (i.e, we no longer mix-and-match C-library malloc with GLIB g_free, and vice-versa). svn path=/trunk/; revision=1000
* The answer to the question "why pass err to open_routines[i]() if err isGuy Harris1999-10-311-4/+1
| | | | | | | | overwritten here?" is probably "because I was cutting-and-pasting text to insert the error-handling code, and didn't remove the "*err = errno" from that particular case. Remove it now. svn path=/trunk/; revision=955
* Add a module to wiretap to be able to read trace files from Toshiba'sGilbert Ramirez1999-10-311-2/+19
| | | | | | | | | | | | | | | | | | line of ISDN routers. Much like the ascend reader, this module reads an ASCII hex dump of trace data. Rearranged the order in which wiretap tries trace files, to keep the ASCII-readers (ascend and toshiba) at the end, and put the binary-readers (everything else) at the front of the list. If a telnet session of and ascend trace or toshiba trace were captured near the beginning of another trace, wiretap might think the trace was ascend or toshiba if it tried that module first. Fixed the way wtap_seek_read() selects functions to call. It was using the encap type instead of the file type. We got lucky because WTAP_ENCAP_ASCEND == WTAP_FILE_ASCEND svn path=/trunk/; revision=952
* Olivier Abad's patches to add:Guy Harris1999-10-181-2/+4
| | | | | | | | | | | | more display filters for X.25; no LCN in X.25 RESTART / DIAGNOSTIC / REGISTRATION packets; support for nettl file format (nettl is a trace tool for HP-UX). For now, it only supports traces for X.25 interfaces (tested with HP-UX 10.20). svn path=/trunk/; revision=879
* Better handle errors from zlib:Guy Harris1999-10-051-1/+38
| | | | | | | | | | | Assign a range of Wiretap errors for zlib errors, and have "wtap_strerror()" use "zError()" to get an error message for them. Have the internal "file_error()" routine return 0 for no error and a Wiretap error code for an error. svn path=/trunk/; revision=769
* Fix it so that it builds with "--disable-zlib".Guy Harris1999-09-241-3/+2
| | | | | | | | | The "fh" member of a "wtap" structure points to something constructed from the "fd" member of that structure, so that closing the stream referred to by "fh" also closes the underlying file descriptor; get rid of an unnecessary close of "wth->fd". svn path=/trunk/; revision=720
* When reading a capture file, we can detect whether it's compressed orGuy Harris1999-09-231-9/+9
| | | | | | | | | | | | | | | | not, so it's OK to use "zlib" to read capture files, as it handles uncompressed files correctly. When *writing* capture files, however, we can't detect automatically whether the user wanted to write the file out as a compressed file or not, so we should *NOT* use "zlib" until we add a flag to the API specifying whether to write the file out as a compressed file or not. Furthermore, the code in Ethereal that implements the "-S" flag depends on being able to get the "FILE *" for a capture file being written, so that it can "fflush()" it. svn path=/trunk/; revision=703
* Adds progress bar functionality back for loading files (it was changed toAshok Narayanan1999-09-231-2/+9
| | | | | | | | bounce bar for compressed file support). Note that the progress bar may not grow smoothly for compressed files, but it should be reasonably accurate for files which are large enough to matter. svn path=/trunk/; revision=701
* This commit contains support for reading capture files compressed usingAshok Narayanan1999-09-221-14/+15
| | | | | | | | | | | | | | | | | | | | | | | | gzip. The zLib library is used for this purpose. If zLib is not available (or it's use is disabled by the --disable-zlib option to configure), you can still compile Ethereal but it will be unable to read compressed capture files. IMPORTANT: Now all file accesses to capture files should be done through special macros. Specifically, for any use of the following functions on capture files, replace them. The arguments for the right-side functions are exactly the same as for the original stdio functions. fopen file_open fdopen filed_open fread file_read fwrite file_write fseek file_seek fclose file_close ferror file_error svn path=/trunk/; revision=695
* Added support for Lucent/Ascend packet traces. The MAX and Pipeline routerGerald Combs1999-09-111-2/+10
| | | | | | | | | | | | | | family has a set of debug commands that allow you to log the traffic on a WAN or dialup connection as text, e.g. RECV-iguana:241:(task: B04E12C0, time: 1975358.50) 15 octets @ 8003D634 [0000]: FF 03 00 3D C0 06 C9 96 2D 04 C1 72 00 05 B8 Created wtap_seek_read() which parses the textual data for and Ascend trace, and does a normal fseek() and fread() for any other file type. The fseek()/fread() pairs in file.c were replaced with the new function. svn path=/trunk/; revision=652
* Keep in the "wtap" structure the current offset into the file beingGuy Harris1999-08-281-1/+2
| | | | | | | | | read, and maintain it ourselves as we read through the file, rather than calling "ftell()" for every packet we read - "ftell()" may involve an "lseek()" call, which could add a noticeable CPU overhead when reading a large file. svn path=/trunk/; revision=596
* Get rid of some cruft left in by previous checkins as placeholders.Guy Harris1999-08-221-2/+2
| | | | | | | | | | | | | | | | Get rid of WTAP_ENCAP_NONE; replace it with WTAP_ENCAP_UNKNOWN, which means "I can't handle that file, it's using an encapsulation I don't support". Check for encapsulations we don't support, and return an error (as is already done in "libpcap.c"). Check for too-large packet sizes, and return an error (as is already done in "libpcap.c"). Print unsigned quantities in Wiretap messages with "%u", not "%d". svn path=/trunk/; revision=544
* Have the per-capture-file-type open routines "wtap_open_offline()" callsGuy Harris1999-08-191-38/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | return 1 on success, -1 if they got an error, and 0 if the file isn't of the type that file is checking for, and supply an error code if they return -1; have "wtap_open_offline()" use that error code. Also, have the per-capture-file-type open routines treat errors accessing the file as errors, and return -1, rather than just returning 0 so that we try another file type. Have the per-capture-file-type read routines "wtap_loop()" calls return -1 and supply an error code on error (and not, as they did in some cases, call "g_error()" and abort), and have "wtap_loop()", if the read routine returned an error, return FALSE (and pass an error-code-pointer argument onto the read routines, so they fill it in), and return TRUE on success. Add some new error codes for them to return. Now that "wtap_loop()" can return a success/failure indication and an error code, in "read_cap_file()" put up a message box if we get an error reading the file, and return the error code. Handle the additional errors we can get when opening a capture file. If the attempt to open a capture file succeeds, but the attempt to read it fails, don't treat that as a complete failure - we may have managed to read some of the capture file, and we should display what we managed to read. svn path=/trunk/; revision=516
* In "wtap_dump_close()", don't shove the return value of "fclose()" intoGuy Harris1999-08-181-3/+2
| | | | | | | | | the variable for the return value of "wtap_dump_close()", just check it against EOF; shoving it into "ret" means it gets set to 0 on a successful close, but a return value of 0 means "wtap_dump_close()" failed. svn path=/trunk/; revision=514
* Make "wtap_dump()" and "wtap_dump_close()" return error codes, and checkGuy Harris1999-08-181-7/+22
| | | | | | | | | | | | | for errors when closing a file to which we've written packets (we don't bother checking if we're giving up on a capture). Add some more error checks in Wiretap. Make a single list of all Wiretap error codes, giving them all different values (some can be returned by more than one routine, so they shouldn't be per-routine). svn path=/trunk/; revision=510
* Add to Wiretap the ability to write capture files; for now, it can onlyGuy Harris1999-08-181-4/+102
| | | | | | | | | | | | | | | | | write them in "libpcap" format, but the mechanism can have other formats added. When creating the temporary file for a capture, use "create_tempfile()", to close a security hole opened by the fact that "tempnam()" creates a temporary file, but doesn't open it, and we open the file with the name it gives us - somebody could remove the file and plant a link to some file, and, if as may well be the case when Ethereal is capturing packets, it's running as "root", that means we write a capture on top of that file.... (The aforementioned changes to Wiretap let you open a capture file for writing given an file descriptor, "fdopen()"-style, which this change requires.) svn path=/trunk/; revision=509
* Have "wtap_open_offline()" return, on failure, an indication of theGuy Harris1999-08-151-4/+21
| | | | | | | | | | | | | reason for the failure, and have it do the checks to make sure the file being opened is a plain file or a pipe. Have "open_cap_file()" make use of that. Don't automatically set "last_open_dir" if a "-r" flag was specified on the command line - do so only if the file in question could actually be opened. svn path=/trunk/; revision=495
* Check in Olivier Abad's patch to add dissectors for LAP-B and X.25, andGuy Harris1999-08-021-1/+6
| | | | | | | | | | | | | | | | | | | | | | | wiretap support for RADCOM Ltd.'s WAN/LAN analyzers (see http://www.radcom-inc.com/ ). Note: as I remember, IEEE 802.2/ISO 8022 LLC has somewhat of an SDLC flavor to it, just as I think LAP, LAPB, LAPD, and so on do, so we may be able to combine some of the LLC dissection and the LAPB dissection into common code that could, conceivably be used for other SDLC-flavored protocols. Make "S" a mnemonic for "Summary" in the "Tools" menu. Move the routine, used for the "Tools/Summary" display, that turns a wiretap file type into a descriptive string for it into the wiretap library itself, expand on some of its descriptions, and add an entry for files from a RADCOM analyzer. Have "Tools/Summary" display the snapshot length for the capture. svn path=/trunk/; revision=416
* Added support for compiling on win32 with Visual C and 'nmake'. It compiles,Gilbert Ramirez1999-07-131-2/+4
| | | | | | | | | | | | but does not link. Perhaps someone who understands the MS tools can help out. I made it link a few months ago, but with different version of glib/gtk+. I can't remember how I made it link. Most of the compatibility issues were resolved with adding #ifdef HAVE_UNISTD_H the the source code. Please be sure to add this to all future code. svn path=/trunk/; revision=359
* Created a new protocol tree implementation and a new display filterGilbert Ramirez1999-07-071-5/+1
| | | | | | | mechanism that is built into ethereal. Wiretap is now used to read all file formats. Libpcap is used only for capturing. svn path=/trunk/; revision=342
* Added display filters to wiretap.Gilbert Ramirez1999-03-011-5/+12
| | | | svn path=/trunk/; revision=198
* Add support for Cinco Networks NetXRay - which is, after their acquisionGuy Harris1999-02-201-1/+6
| | | | | | | | | by Network General (subsequently merged with McAfee Associates into Network Associates), called "Sniffer Basic". A similar format appears to be used by the Windows Sniffer Pro. svn path=/trunk/; revision=194
* I changed the wtap_open_offline() function so that it takes only theGilbert Ramirez1999-01-211-70/+26
| | | | | | | | filename as the parameter. So far all the filetypes that wiretap can read can be inferred from the first few bytes of the file, so we never have to give wiretap a hint as to the file type. svn path=/trunk/; revision=173
* Add suppport for Microsoft Network Monitor Ethernet capture files.Guy Harris1999-01-171-1/+11
| | | | svn path=/trunk/; revision=171
* Added the iptrace (AIX's packet-capture tool) file format to wiretap.Gilbert Ramirez1999-01-021-1/+11
| | | | | | | This necessitated a change in ethereal because iptrace supports multi-NIC packet capturing, including multi-datalink-type capturing. svn path=/trunk/; revision=145
* Add support to wiretap for reading Sun "snoop" capture files.Guy Harris1998-11-151-68/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | That requires that, in the packet-reading loop, we pass to the callback routine the offset in the file of a packet's data, because we can no longer compute that offset by subtracting the size of the captured packet data from the offset in the file after the data was read - "snoop" may stick padding in after the packet data to align packet headers on 4-byte boundaries. Doing that required that we arrange that we do that for "libpcap" capture files as well; the cleanest way to do that was to write our own code for reading "libpcap" capture files, rather than using the "libpcap" code to do it. Make "wtap_dispatch_cb()" and "pcap_dispatch_cb()" static to "file.c", as they're not used elsewhere. If we're using wiretap, don't define in "file.h" stuff used only when we're not using wiretap. Update the wiretap README to reflect Gilbert's and my recent changes. Clean up some memory leaks in "wiretap/lanalyzer.c" and "wiretap/ngsniffer.c", where the capture-file-format-specific data wasn't freed if the open failed. svn path=/trunk/; revision=91
* More patches from Guy, cleaning up warnings when using gcc -Wall.Gilbert Ramirez1998-11-121-8/+9
| | | | svn path=/trunk/; revision=86
* I added the LANalzyer file format to wiretap. I cleaned up some code in theGilbert Ramirez1998-11-121-71/+31
| | | | | | | | wiretap functions to be more generic and therefore allow an easier integration of more packet-capture file types. I also put in all the GPL copyrights in the wiretap code. svn path=/trunk/; revision=83
* A lengthy patch to add the wiretap library. Wiretap is not used by defaultGilbert Ramirez1998-11-121-0/+208
because it is still in its infancy, but it can be compiled in optionally. The library exists in its own subdirectory ethereal/wiretap. This patch also edits all the packet-*.c files to remove the #include <pcap.h> line which is unnecessary in these files. In the ethereal code, file.c is the most heavily modified with #ifdef WITH_WIRETAP lines for the optional library. svn path=/trunk/; revision=82