Commit Graph

53 Commits

Author SHA1 Message Date
Guy Harris 272c011d19 On an I/O error, merge_read_packet() and merge_append_read_packet() need
to return a pointer to the merge_in_file_t that got the error.  Set *err
to 0 on success and an error code on an err, treat a null return as an
EOF indication, and if we don't get a null return check for a non-zero
error code and treat that as an I/O error.

svn path=/trunk/; revision=39964
2011-11-21 06:26:03 +00:00
Guy Harris 2929c93ea2 When reporting "sorry, *this* packet can't be written to a file of that
type" when writing out a capture file (i.e., writing a
per-packet-encapsulation capture to a file type that supports it but
doesn't support one of the packet's encapsulations), report the packet
number and, when doing this in a merge operation, report the file from
which it came.

When reporting "sorry, that file can't be written to a file of that
type, period", show the file type rather than the input file link-layer
type that causes the problem.  (We could show both.  We could be
*really* ambitious and iterate through all possible file types and show
the ones that will or at least might work....)

file_write_error_message() is documented as handling only UNIX-style
errnos, and libwireshark should be usable without libwiretap, so leave
it up to its callers to handle Wiretap errors such as
WTAP_ERR_SHORT_WRITE.

Clean up indentation.

svn path=/trunk/; revision=39949
2011-11-19 20:18:01 +00:00
Jeff Morriss bf95c7b5e4 Fix https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=5608 :
getopt() can/should normally be found in unistd.h, so:

- When testing for getopt(), define that we HAVE_GETOPT instead of
  HAVE_GETOPT_H (to avoid confusion).
- Don't attempt to include getopt.h: not all OS's have it (for example,
  Solaris 9 does not).
- (All the places which need getopt already include unistd.h (if we have it).)

If this breaks things on some OS, we might need (a real) HAVE_GETOPT_H check.

svn path=/trunk/; revision=38437
2011-08-09 21:02:10 +00:00
Stig Bjørlykke 8443bbbf75 Replace all strerror() with g_strerror().
Remove our local strerror implementation.
Mark strerror as locale unsafe API.

This fixes bug 5715.

svn path=/trunk/; revision=37812
2011-06-28 09:00:11 +00:00
Gerald Combs 4d603719d0 Have mergecap, tshark, and editcap write pcap-ng files by default. This
is mainly an attempt to fix the currently-broken "test.sh" step on the
XP buildbot. If this causes too many problems we might want to have
suite-capture.sh:capture_step_snapshot pass "-P" to dumpcap instead.

svn path=/trunk/; revision=37736
2011-06-20 23:31:26 +00:00
Gerald Combs a24687ce8e Move the Windows argument list conversion code to a common routine.
svn path=/trunk/; revision=37372
2011-05-24 00:07:56 +00:00
Gerald Combs 3bc1fc3802 On Windows, convert all of our command-line arguments from UTF-16 to
UTF-8 where we don't already do so. In Wireshark use g_utf16_to_utf8
instead of utf_16to8. This should fix bug 5520.

svn path=/trunk/; revision=35411
2011-01-06 23:28:58 +00:00
Jeff Morriss 47e2d75820 Move some code (including the optional objects) into libwsutil
svn path=/trunk/; revision=33012
2010-05-28 20:19:55 +00:00
Stig Bjørlykke 98024a007f Invert check for getopt: NEED_GETOPT_H -> HAVE_GETOPT_H
Rename getopt.[ch] -> wsgetopt.[ch] to avoid name collision.

svn path=/trunk/; revision=30370
2009-10-06 16:01:18 +00:00
Stig Bjørlykke 41a8561936 Fixed a int/long warning.
svn path=/trunk/; revision=30330
2009-10-05 15:22:34 +00:00
Gerald Combs 1e93d53b56 Use "svn info" to fetch the version by default. Fetch the repository path as
well. Add the repository path to the version strings.

svn path=/trunk/; revision=29171
2009-07-22 23:59:15 +00:00
Bill Meier fa920e48ed Minor cleanup of "-h" output text.
svn path=/trunk/; revision=28334
2009-05-12 16:06:14 +00:00
Jeff Morriss a5cee04fad Move the file utility functions from wiretap to libwsutil so that
libwireshark (and the plugins using those functions) do not depend on
wiretap on Windows.

While doing that, rename the eth_* functions to ws_*.

svn path=/trunk/; revision=25354
2008-05-22 15:46:27 +00:00
Stig Bjørlykke 11a9f57c1a Fixed some malloc -> g_malloc, free -> g_free, strdup -> g_strdup.
svn path=/trunk/; revision=24179
2008-01-24 19:09:30 +00:00
Anders Broman f68d6e4c8c Ethereal->Wireshark
svn path=/trunk/; revision=18235
2006-05-28 20:28:20 +00:00
Anders Broman 901f07af60 From Martin Mathieson:
wiretap/README.developer
- the referenced default seek_read function doesn't exist now

wiretap/wtap.c
- a "hole" in encap_table was causing the wrong encap value for later 
types to be looked up (by name)

mergecap.c
- fix a couple of program name copy+paste errors from editcap.c

svn path=/trunk/; revision=17765
2006-03-30 04:58:06 +00:00
Ulf Lamping 41c3bca696 same command line related changes as recently done with editcap
svn path=/trunk/; revision=16994
2006-01-10 23:06:05 +00:00
Ulf Lamping c3187174bf replace *a lot* of file related calls by their GLib counterparts. This is necessary for the switch to GTK 2.6 (at least on WIN32).
to do this, I've added file_util.h to wiretap (would file_compat.h be a better name?), and provide compat_macros like eth_open() instead of open(). While at it, move other file related things there, like #include <io.h>, definition of O_BINARY and alike, so it's all in one place.

deleted related things from config.h.win32

As of these massive changes, I'm almost certain that this will break the Unix build. I'll keep an eye on the buildbot so hopefully everything is working again soon.

svn path=/trunk/; revision=16403
2005-11-06 22:43:25 +00:00
Ulf Lamping 84cf7ce767 added compression support for capture file output. The Save/As dialog now has a checkbox "Compress with gzip"
currently limited to Ethereal and all the variants of libpcap filetypes only.

We might want to add output compression support to the other tools as well (tethereal, mergecap, ...).

We might also want to add support for the other filetypes, but this is only possible if the filetype functions doesn't use special output operations like fseek.

One bug is still left: if the input and output filetypes while saving are the same, Ethereal currently optimizes this by simply copy the binary file instead of using wiretap (so it will be faster but it will ignore the compress setting). 

Don't know a good workaround for this, as I don't know a way to find out if the input file is currently compressed or not. One idea might be to use a heuristic on the filesize (compared to the packet size summmary). Another workaround I see is to remove this optimization, which is of course not the way I like to do it ...

svn path=/trunk/; revision=15804
2005-09-14 21:57:30 +00:00
Guy Harris f1deabed56 Make the tone of the error messages a bit less formal, by using
contractions.  (Safari does, at least when you're trying to open a file
to which you don't have read access.)

svn path=/trunk/; revision=12852
2004-12-29 01:08:20 +00:00
Guy Harris e09e12621a The common merge code merely needs to offer the abstraction of routines
that return the next packet from a set of {chronologically sorted,
sequential-by-file} packets; it doesn't need to have a loop over all
those packets, or any code to write packets.

Supply those abstractions, change the code that merges packets to do its
own writing, and have the Ethereal version manage a progress bar and
have the mergecap version print packet numbers in verbose mode, as the
common merge code used to do.

svn path=/trunk/; revision=12427
2004-10-29 00:36:52 +00:00
Guy Harris 66e85e4e43 Make "merge_files()" and "merge_append_files()" return a tri-state
indication - success, read failure, write failure - and have their
callers handle read failures by looking for the file that got the read
failure and reporting the failure in question.

Free up the err_info string returned by "wtap_read()" after using it.

svn path=/trunk/; revision=12423
2004-10-28 01:52:05 +00:00
Guy Harris dc2280bc1e Remove all the verbose-mode code from merge.c, and put most of it in
mergecap.c (get rid of the verbose printing of information for each
packet).

Have "merge_append_files()" return FALSE only on a write error, as
"merge_files()" does.

Sort the routines in "merge.c" in the order from "merge.h".

svn path=/trunk/; revision=12422
2004-10-28 01:06:11 +00:00
Guy Harris b48b8847b1 Change some of the merge.c APIs to return more information on failure,
and use that information to provide better error messages.

Have "merge_open_outfile()" do all the work of filling in the
merge_out_file_t structure, with the values to use passed as arguments. 
Get rid of some structure members that used to be used solely to pass
information to "merge_open_outfile()".

Add a "cf_merge_files()" routine to do the merging and reporting of errors.

svn path=/trunk/; revision=12420
2004-10-27 23:28:37 +00:00
Guy Harris 62988d944a Check whether any input files were specified, and print an error for
that - otherwise, you get a "No valid input files" message, which
perhaps doesn't make it clear enough that the problem is that there were
no input files, period.

svn path=/trunk/; revision=12410
2004-10-27 19:36:22 +00:00
Guy Harris 8a8b883450 Set the svn:eol-style property on all text files to "native", so that
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-18 00:24:25 +00:00
Gerald Combs 8106dc0862 Convert make-version.pl and the associated cvsversion.h and CVSVERSION
definition to Subversion.  "svn info" prints out the last changed date
of the repository, so we don't have to go hunting through "CVS/Entries"
files anymore.


svn path=/trunk/; revision=11379
2004-07-15 21:09:33 +00:00
Guy Harris aaac0102cb If we fail to open the output file, report the reason why.
svn path=/trunk/; revision=11371
2004-07-13 05:58:15 +00:00
Ulf Lamping 4492f58213 bugfix to a bug reported by jprakashbabu@hotpop.com:
mergecap didn't created a new output file

svn path=/trunk/; revision=11368
2004-07-12 21:00:40 +00:00
Guy Harris 99cec606fa Initialize "out_filename" to NULL, so it's set to NULL if it's not set
by a "-w" flag.

svn path=/trunk/; revision=11277
2004-06-30 07:04:42 +00:00
Guy Harris 272a2055ab On at least some platforms, a #define of O_BINARY is needed even if
<fcntl.h> is included, as <fcntl.h> doesn't define it.

svn path=/trunk/; revision=11276
2004-06-30 06:58:59 +00:00
Ulf Lamping 19c7f04794 avoid using tmpnam() for security reasons.
instead of giving the merge stuff a filename,
give it an already opened file descriptor

svn path=/trunk/; revision=11273
2004-06-29 20:59:24 +00:00
Ulf Lamping a43f7d1f88 merge: remove code duplication in merge.c and mergecap.c (put it in merge.c),
and doing some more code cleanup

svn path=/trunk/; revision=11176
2004-06-18 10:01:59 +00:00
Jörg Mayer de66318723 Undo an unnecessary change
svn path=/trunk/; revision=10297
2004-03-04 08:20:46 +00:00
Jörg Mayer 76ff7e4a66 Bill Guyton: mergecap can write to stdout by using the special filename -
svn path=/trunk/; revision=10289
2004-03-03 22:14:10 +00:00
Gerald Combs 058dbba4b9 Add support for a "version.conf" file in the main directory which can
be used to adjust version preferences.  It understands two configuration
directives: "enable", which can be 0 or 1, and "format", which can be any
strftime()-compatible string, e.g. "V12-powered on %A %Y-%m-%d %H:%M:%S".

If no configuration file is present, the configuration defaults to

enable: 1
format: CVS %Y%m%d%H%M%S

svn path=/trunk/; revision=10139
2004-02-20 20:36:14 +00:00
Guy Harris d6c17f144b Free the error info string after using it.
svn path=/trunk/; revision=9855
2004-01-25 22:21:39 +00:00
Guy Harris d6cd61061e Have the Wiretap open, read, and seek-and-read routines return, in
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-25 21:55:17 +00:00
Jörg Mayer e68ca30d10 Fix warnings found by -Wstrict-prototypes
svn path=/trunk/; revision=9722
2004-01-18 16:21:12 +00:00
Jörg Mayer 82cf1b015d Output the result of -h to stdout, not stderr
svn path=/trunk/; revision=9702
2004-01-18 02:12:59 +00:00
Olivier Biot 8db6fb47cd Nice rendering of the CVS version as "(cvs 200401181200003000)".
The make-version.pl script only defines CVSVERSION if this was a build
from CVS.

svn path=/trunk/; revision=9701
2004-01-18 01:41:14 +00:00
Jörg Mayer 0ac74ed036 In case of CVS sources, add the date of the last change to the version
number.

2do: Add support to Makefile.nmake
     Enforce the generation of cvsversion.h on each run of make

svn path=/trunk/; revision=9679
2004-01-16 20:04:21 +00:00
Jörg Mayer 7c4176d868 Removed trailing whitespaces from .h and .c files using the
winapi_cleanup tool written by Patrik Stridvall for the wine
project.

svn path=/trunk/; revision=6117
2002-08-28 21:04:11 +00:00
Jörg Mayer 173fe5aef4 Replace the types from sys/types.h and netinet/in.h by their glib.h
equivalents for the toplevel directory. The removal of winsock2.h will
hopefully not cause any problems under MSVC++, as those files using
struct timeval still include wtap.h, which still includes winsock2.h.

svn path=/trunk/; revision=5932
2002-08-02 23:36:07 +00:00
Guy Harris 73ef5a2753 WinPcap 2.3's <pcap.h> includes <packet32.h>, and WinPcap 2.3's
<packet32.h> includes <winsock2.h>; we include that rather than
<winsock.h>, to avoid errors due to conflicting declarations in
<winsock.h> and <winsock2.h>.

svn path=/trunk/; revision=5742
2002-06-23 10:32:36 +00:00
Guy Harris 6bc1cb1c7d From Joerg Mayer: mark function arguments as unused.
svn path=/trunk/; revision=5051
2002-03-31 20:59:47 +00:00
Guy Harris 309e86246e From Peter Valchev: fix editcap to assign the result of "getopt()" to an
"int" and to check "getopt()"s return value with -1 rather than EOF.

Fix other "getopt()" loops to check against -1 as well (EOF is -1 on
most if not all platforms, but the Single UNIX Specification says
"getopt()" returns -1, so we should check against -1, not EOF).

svn path=/trunk/; revision=4793
2002-02-24 01:26:45 +00:00
Guy Harris 89a4acb438 Have Wiretap set the snapshot length to 0 if it can't be derived from
reading the capture file.  Have callers of "wtap_snapshot_length()"
treat a value of 0 as "unknown", and default to WTAP_MAX_PACKET_SIZE (so
that, when writing a capture file in a format that *does* store the
snapshot length, we can at least put *something* in the file).

If we don't know the snapshot length of the current capture file, don't
display a value in the summary window.

Don't use "cfile.snap" as the snapshot length option when capturing -
doing so causes Ethereal to default, when capturing, to the snapshot
length of the last capture file that you read in, rather than to the
snapshot length of the last capture you did (or the initial default of
"no snapshot length").

Redo the "Capture Options" dialog box to group options into sections
with frames around them, and add units to the snapshot length, maximum
file size, and capture duration options, as per a suggestion by Ulf
Lamping.  Also add units to the capture count option.

Make the snapshot length, capture count, maximum file size, and capture
duration options into a combination of a check box and a spin button.
If the check box is not checked, the limit in question is inactive
(snapshot length of 65535, no max packet count, no max file size, no max
capture duration); if it's checked, the spinbox specifies the limit.
Default all of the check boxes to "not checked" and all of the spin
boxes to small values.

Use "gtk_toggle_button_get_active()" rather than directly fetching the
state of a check box.

svn path=/trunk/; revision=4709
2002-02-08 10:07:41 +00:00
Guy Harris 3c9efdf478 Use longs as file offsets, so that on platforms with 64-bit "long" we
can handle capture files bigger than 2GB.

svn path=/trunk/; revision=3993
2001-10-04 08:30:36 +00:00
Guy Harris e17c3efe32 Get rid of some unused variables.
svn path=/trunk/; revision=3745
2001-07-20 07:22:40 +00:00