summaryrefslogtreecommitdiff
path: root/wiretap/iseries.c
AgeCommit message (Collapse)AuthorFilesLines
2017-06-05Allow bigger snapshot lengths for D-Bus captures.Guy Harris1-2/+2
Use WTAP_MAX_PACKET_SIZE_STANDARD, set to 256KB, for everything except for D-Bus captures. Use WTAP_MAX_PACKET_SIZE_DBUS, set to 128MB, for them, because that's the largest possible D-Bus message size. See https://bugs.freedesktop.org/show_bug.cgi?id=100220 for an example of the problems caused by limiting the snapshot length to 256KB for D-Bus. Have a snapshot length of 0 in a capture_file structure mean "there is no snapshot length for the file"; we don't need the has_snap field in that case, a value of 0 mean "no, we don't have a snapshot length". In dumpcap, start out with a pipe buffer size of 2KB, and grow it as necessary. When checking for a too-big packet from a pipe, check against the appropriate maximum - 128MB for DLT_DBUS, 256KB for everything else. Change-Id: Ib2ce7a0cf37b971fbc0318024fd011e18add8b20 Reviewed-on: https://code.wireshark.org/review/21952 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-09-15iseries: rework the read routine.Dario Lombardo1-37/+21
Change the way a line is read in iseries. Instead of reading a string then convert it with atoi, parse it as an integer and convert it to nsecs. Change-Id: Id8e8e9866dbcef3b1612a608f9647bc490263dae Reviewed-on: https://code.wireshark.org/review/17558 Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-05-02Remove trailing blank.Guy Harris1-1/+1
Change-Id: I57017b3e574983dac9107712a0dd6b243b62bb80 Reviewed-on: https://code.wireshark.org/review/15240 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-05-02Add some more checks, clean up length handling.Guy Harris1-6/+49
Check for destination or source MAC addresses that aren't 12 characters (hex dump of 6 octets) long and type/length fields that aren't 4 characters (hex dump of 2 octets) long. The buffer into which we copy the hex dump characters doesn't need to be null-terminated, so don't bother to null-terminate it. Use the final offset into the buffer as the buffer length, rather than using strlen(). Just memcpy the MAC addresses and type/length fields into the buffer; the buffer is guaranteed to be big enough for all of them, and, as noted, it doesn't need to be null-terminated. Change-Id: I790e953542ae8443af01c81229a8deb877448ee3 Reviewed-on: https://code.wireshark.org/review/15239 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-05-02Don't assume packets will be no larger than ISERIES_MAX_PACKET_LEN.Guy Harris1-8/+6
We don't check against it. Insteead, use phdr->caplen as the buffer size; that's based on the number of hex digits we've found. While we're at it, also get rid of ISERIES_PKT_ALLOC_SIZE - it makes it less obvious that it's based on the packet length from the packet header. Change-Id: I8ad6306c62e7bc4cf896b335f39a5a77780fb2ea Reviewed-on: https://code.wireshark.org/review/15236 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-05-02Make sure the packet length isn't > WTAP_MAX_PACKET_SIZE.Guy Harris1-0/+18
Change-Id: I65c1e87e2fcff93b3db998666ff51f19ecd71b55 Reviewed-on: https://code.wireshark.org/review/15233 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-03-29Assorted cleanups.Guy Harris1-17/+29
1) Handle the ASCII and Unicode magic numbers the same way - as static const char arrays. Note that Unicode specifically means little-endian UCS-2 (or UTF-16, but they probably use few if any characters outside of ASCII, much less the Basic Multilingual Plane). 2) Treat all seek errors as open errors rather than "not my file type". 3) Fix capitalization of "Unicode". Change-Id: I47b7e057ccada00347499a6b17f8f8fc44e7c503 Reviewed-on: https://code.wireshark.org/review/14689 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-01-20Note that using file_gets() for UCS-2 files is a bit of a hack.Guy Harris1-0/+4
Change-Id: I09cb8c8ea86c83f079c0882ca2f28e2f7c338b51 Reviewed-on: https://code.wireshark.org/review/13429 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-01-20Fix indentation.Guy Harris1-31/+31
Change-Id: I9fc0b8f98439ac37d4356e742d8c411e2dce473f Reviewed-on: https://code.wireshark.org/review/13425 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-01-17[iseries] fix iseries_check_file_type()Martin Kaiser1-6/+15
check that we have a line that contains OBJECT PROTOCOL ETHERNET (at the moment, we fail if there's a line containing OBJECT PROTOCOL but not ETHERNET and succeed otherwise -> a file with some random lines will be identified as iseries) initialize our line buffer with 0s to make sure we don't access uninitialized data while parsing don't set wth->priv unless the file is really an iseries file free the iseries struct if the file is not our type Bug: 11985 Change-Id: I0ac7003c047f54ca025d02e59b56d1ff4e2a6be7 Reviewed-on: https://code.wireshark.org/review/13360 Petri-Dish: Martin Kaiser <wireshark@kaiser.cx> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2016-01-17[iseries] return WTAP_OPEN_ERROR if file_seek() failsMartin Kaiser1-1/+1
like it's done for the other file types Change-Id: I8caa360b9c527ea642ee6b5102759ad341ad0030 Reviewed-on: https://code.wireshark.org/review/13359 Reviewed-by: Martin Kaiser <wireshark@kaiser.cx>
2015-11-30Treat invalid (negative or too-large) values in the packet header as errors.Guy Harris1-1/+61
Change-Id: I86564c485aacd3fcba3f3d8d9da492e0100155e8 Reviewed-on: https://code.wireshark.org/review/12299 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-11-28Sanity check iSeries packet length to prevent heap-based buffer overflow.Michael Mann1-1/+1
Bug: 11798 Change-Id: I7aebe709ef4014a385819835ef6effabbb4f0ca4 Reviewed-on: https://code.wireshark.org/review/12238 Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-01-03Remove unnecessary includes from wiretap folderMartin Mathieson1-2/+0
Change-Id: I10d3057801673bc1c8ea78f144215869cc4b1851 Reviewed-on: https://code.wireshark.org/review/6217 Petri-Dish: Martin Mathieson <martin.r.mathieson@googlemail.com> Reviewed-by: Martin Mathieson <martin.r.mathieson@googlemail.com>
2014-10-17Don't use ctype.h routines.Guy Harris1-3/+2
That avoids locale dependency and handles possibly-signed chars (which we weren't doing before). Change-Id: I70f3d993c9a8fbf870901f12b430d733968c3fa8 Reviewed-on: https://code.wireshark.org/review/4781 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-10-09Use an enum for the open-routine return value, as per Evan Huus's suggestion.Guy Harris1-14/+14
Clean up some things we ran across while making those changes. Change-Id: Ic0d8943d36e6e120d7af0a6148fad98015d1e83e Reviewed-on: https://code.wireshark.org/review/4581 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-10-07No need for WTAP_ERR_CANT_READ.Guy Harris1-1/+0
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-07Make the code a bit more like the pre-API change code.Guy Harris1-6/+3
Change-Id: I9a8bd2c7ce97993c1b72caf63254d024950f8b94 Reviewed-on: https://code.wireshark.org/review/4520 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-10-07Add some higher-level file-read APIs and use them.Guy Harris1-7/+7
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/+2
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-08-02Rename buffer_ routines to ws_buffer_ to avoid name collisions.Guy Harris1-2/+2
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-07-11Avoid sign-extending bytes before handing them to <ctype.h> macros.Guy Harris1-1/+1
Pointed out by the Visual Studio code analyzer. Change-Id: Idd429b4d0fb3db11ce171c3a5b38bdc55cc53c15 Reviewed-on: https://code.wireshark.org/review/2988 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-06-16Explicitly declare/cast 'unsigned <variable>' as 'unsigned int <variable>'AndersBroman1-1/+1
Applying part of Bug 7825 Change-Id: I460b5c61b04d793ccc27c25debbd5e8f08bc6974 Reviewed-on: https://code.wireshark.org/review/2280 Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-05-24Allow wtap_read() and wtap_seek_read() to return records other than packets.Guy Harris1-0/+1
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/+14
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-14/+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-09Revert "Refactor Wiretap"Guy Harris1-48/+46
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-46/+48
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-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-3/+2
wtap_seek_read(). svn path=/trunk/; revision=54570
2013-12-12Appease Visual Studio Code Analysis by ensuring that the string in csec[] is ↵Chris Maynard1-0/+1
NULL-terminated. svn path=/trunk/; revision=53995
2013-11-08(Trivial) whitespace cleanup (mostly trailing whitespace).Bill Meier1-2/+2
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-06-17Merge "read record header" and "read packet data" routines into a singleGuy Harris1-20/+7
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-20/+10
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-17Have iseries_parse_packet() fill in a struct wtap_pkthdr; that means itGuy Harris1-55/+41
doesn't need to return the number of bytes of captured packet data (it can just stuff that into the struct wtap_pkthdr), so have it return a Boolean success/failure indication. svn path=/trunk/; revision=49376
2013-05-17If iseries_seek_next_packet() hits the EOF, *err will be set to 0; justGuy Harris1-13/+5
have it return -1 for errors or EOF, and have iseries_read() check for a negative return value and return FALSE. That simplifies it a bit, and handles the "no more records in the file" case (iseries_seek_next_packet() will hit EOF and return -1 with *err set to 0, which is what the callers of a read routine expect at EOF). Get rid of duplicate (and incorrect before the change) comment. svn path=/trunk/; revision=49375
2013-03-19From beroset:Anders Broman1-1/+1
remove C++ incompatibilities https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8416 svn path=/trunk/; revision=48424
2012-12-27Errors take precedence over EOF; use file_error() after operations thatGuy Harris1-60/+50
return an "EOF or error" indication - an EOF without an error will return 0. In iseries_seek_next_packet(), return an error code of WTAP_ERR_BAD_FILE and an appropriate error message if we don't find a packet header within the next ISERIES_MAX_TRACE_LEN lines, don't just return -1 and leave the error information unchanged. Setting an argument variable before returning has no effect, so don't do it (so that we don't leave the mistaken impression that it *is* doing something). Clean up indentation. svn path=/trunk/; revision=46819
2012-12-27Do not call wtap_file_read_unknown_bytes() orGuy Harris1-37/+34
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-12-26OK, does *this* convince the compiler that the loop isn't ever going toGuy Harris1-5/+1
be infinite? svn path=/trunk/; revision=46757
2012-12-26Widen an argument to match its (theoretical) widest possible width. SeeGuy Harris1-5/+6
if that squelches a loop-optimization warning. svn path=/trunk/; revision=46752
2012-10-18Handle the fractions-of-a-second part of the time stamp correctly. Guy Harris1-17/+39
Extract it as a string, not a number, and determine the resolution based on the length of the string, i.e. on the number of digits presented. (If you base it on the numerical value, leading zeroes will not be taken into account, but they aren't any different from other digits when determining the resolution.) The resolution is 1/10^ndigits seconds, so we have to multiply it by 10^(9-ndigits) to convert the number to nanoseconds. svn path=/trunk/; revision=45627
2012-10-18Redo the processing of lines in iSeries text packet dumps.Guy Harris1-311/+208
Process several different flavors of header lines the same: "IP Header", "IPv6 Header", "ARP Header", "TCP Header", "UDP Header", "ICMP Header", "ICMPv6 Hdr", "Option Hdr" - the hex data for all of them should be included in the packet data. Process continuation lines if those headers wrap over more than one line. Do not assume, or require, that *any* of those be present; there is no guarantee that "IP Header" or "IPv6 Header" will be present (there's at least one IBM page showing a packet with "ARP Header" in a trace), and there is no guarantee that "TCP Header" will be present (there are traces with "UDP Header" and "ICMPv6 Hdr"). Do not impose limits, other than the overall line limit, on the amount of hex data in header or data lines; there is no guarantee that, for example, a TCP header is 20 bytes long (if there are TCP options, it *will* have more than 20 bytes). Make sure we have an even number of hex digits. Set "caplen" to the actual number of bytes we've read, even if that's less than the purported packet length. svn path=/trunk/; revision=45626
2012-10-16Add wtap_pseudo_header union to wtap_pkthdr structure.Jakub Zawadzki1-3/+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-05-04file_seek() used to be a wrapper around fseek() or gzseek(), both ofGuy Harris1-3/+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-22Fix a buildbot compile warning.Bill Meier1-1/+1
svn path=/trunk/; revision=42197