Commit Graph

197 Commits

Author SHA1 Message Date
Gerald Combs df007c001d Fix "file.h:56:21: warning: comma at end of enumerator list".
svn path=/trunk/; revision=46889
2013-01-02 01:35:08 +00:00
Jakub Zawadzki d127d974f5 volatile fixes.
svn path=/trunk/; revision=45729
2012-10-22 21:22:35 +00:00
Jakub Zawadzki 7ba01c587a Fix warning: file.c(776) : warning C4028: formal parameter 2 different from declaration
svn path=/trunk/; revision=45725
2012-10-22 19:46:30 +00:00
Jakub Zawadzki 78631020b8 Add wtap_pseudo_header union to wtap_pkthdr structure.
Use pkthdr instead of pseudo_header as argument for dissecting.

svn path=/trunk/; revision=45601
2012-10-16 21:50:57 +00:00
Gerald Combs 71ed773862 Add a capture_file * element to packet_range_t and pass it explicitly in
packet_range_init(). Get rid of global cfile references in
packet-range.c. C++-ize packet-range.h. Shuffle some includes around.

svn path=/trunk/; revision=45333
2012-10-05 18:52:42 +00:00
Gerald Combs 998da54456 Add a cf_cb_file_opened callback and use it instead of calling
fileset_file_opened directly from file.c. This makes the code a bit more
consistenent and makes it easier to port the File Set dialog to Qt.

svn path=/trunk/; revision=45162
2012-09-26 23:33:11 +00:00
Jakub Zawadzki bf81b42e1e Update Free Software Foundation address.
(COPYING will be updated in next commit)

svn path=/trunk/; revision=43536
2012-06-28 22:56:06 +00:00
Guy Harris f272aaeb80 Only allow "Save" if
the file has unsaved changes, and we can save it in some format
	through Wiretap

or

	the file is a temporary file and has no unsaved changes (so that
	"saving" it just means copying it).

Only allow "Save As" if

	we can save it in some format through Wiretap

or

	the file is a temporary file and has no unsaved changes (so that
	"saving" it just means copying it).

This means that we don't support using "Save As" for just copying the
file unless we can do that with Wiretap; copying the file byte-for-byte
only works as "saving" if there are no unsaved changes *and* we're
saving it in the same format that it's in *and* we're saving it with the
same form of compression (if any) that it has.

Rename cf_can_save_as() to cf_can_write_with_wiretap() to better reflect
what it really does.

svn path=/trunk/; revision=43477
2012-06-25 18:37:52 +00:00
Guy Harris 750d666e73 Handle the case where the user has added comments to a file that's not
in a format that supports comments and they do a "Save" by popping up a
similar question to the one we pop up in the "Save As" case and, if they
say "choose another format", pop up a "Save As" dialog box.

svn path=/trunk/; revision=43395
2012-06-20 04:44:14 +00:00
Guy Harris 06474b4330 If the file has an SHB comment or any packet comments, and the user
tries to do "Save As" in a format for which we don't support comments
(currently, we only support them for pcap-ng), ask whether they want to
discard the comments and save anyway or, *if* the file can be saved in a
format for which we *do* support comments, they want to save the file in
some other format.

Keep a count of packet comments so that we don't have to scan all the
frame_data structures to determine whether we have any comments.

svn path=/trunk/; revision=43392
2012-06-20 01:11:01 +00:00
Guy Harris 9fe3d4b4f3 If we do a Save or Save As with a move, don't reread the capture file,
just tweak the elements in the capture_file structure as necessary and
poke the UI to update stuff such as the windows title.

If we do a Save or Save As with a copy, don't reread the capture file,
just close the old wtap, open a wtap for the copy, and tweak the
elements in the capture_file structure as necessary and poke the UI to
update stuff such as the windows title.

Otherwise, don't do a full read-and-dissect pass on the capture file,
just close the old wtap, open a wtap for the new file, tweak the
elements in the capture_file structure as necessary and poke the UI to
update stuff such as the windows title, and rescan the file to update
the packet offsets (and cause Wiretap to regenerate, for a gzipped file,
the information needed to support fast random access to the gzipped
file).

This should speed up Save and Save As a bit, as well as removing some
glitches in the UI (e.g., you won't see the packet list disappear and
reappear).

svn path=/trunk/; revision=43101
2012-06-05 06:52:18 +00:00
Guy Harris 99536cc8da Distinguish between "failed" and "user stopped it" for "save as" and
"export specified packets".  For "failed", let the user try again with a
different file, in case it failed due to, for example, running out of
space or quota (probably the most likely failure mode for writing, and
trying to a different volume might be the best workaround).  For "user
stopped it", presumably they don't want to try again (the most likely
reason is "it was taking too damn long").
 
Put "Exporting to: ...", not "Saving: ..." in the statusbar if we're
doing "export specified packets".

In process_specified_packets(), allow a null range pointer to be
specified, meaning "save 'em all"; that avoids the possibly-expensive
(with a large capture) operation of initializing the range.

If a "safe save" atop an existing file fails or is stopped, get rid of
the temporary file we created.

svn path=/trunk/; revision=43095
2012-06-05 02:46:54 +00:00
Guy Harris dbfb305368 g_filename_display_basename() returns a g_mallocated string, so its
callers either need to free it or their callers need to free it or....

This means that cf_get_display_name() must always return a g_mallocated
string and its callers or... must free it.

For some of those callers, create a new set_window_title() routine to do
the work - they're all using the same pattern.

svn path=/trunk/; revision=43047
2012-06-03 22:03:05 +00:00
Guy Harris 6014035703 Use GTK+'s GtkMessageDialog for the questions we ask in the process of
saving files, and run it modal (which we're already doing with the
GtkFileChooserDialog); this means less callback-based state machine
stuff, simplifying the code paths a bit.

If we're saving a file before closing it, don't bother reloading it
after saving it.

svn path=/trunk/; revision=42855
2012-05-25 21:25:55 +00:00
Guy Harris b655197a9d In the "Save As" and "Export Specified Packets" code path, do a "safe
save" if the destination file exists.

Don't forbid overwriting an existing file in either of those cases (we
still forbid overwriting the current capture file) - the GUI asks the
user whether they want to do the overwrite, and allows them to cancel
out of it - and don't remove the file before writing to it (doing so
makes the save *un*safe).

Attempt to do a save of an unedited temporary file by just moving the
file on Windows as well as on UN*X - ws_rename() will remove the target
if necessary on Windows (and won't do it as a separate operation before
attempting the rename), so it behaves like ws_rename() on UN*X (which is
just a wrapper around rename()).

svn path=/trunk/; revision=42816
2012-05-24 02:16:53 +00:00
Guy Harris c2bb7956c2 "Save As" always saves everything and, when the save is done, makes the
new file the current file, as is the case in most if not all other GUI
applications.

A new "Export Specified Packets" menu option allows you to specify which
packets to write out, with the default being the displayed packets (and
those on which the displayed packets depend for, e.g.  reassembly), and
never makes the resulting file the current file.

The two operations are conceptually distinct.  Lumping them into one
menu item, with the default for "Save As" being "displayed packets only"
and thus making it behave like the latter operation, was causing some
confusion; see, for example, bug 6640.

Make the dialog popped up if you try to "Save As" or "Export Specified
Packets" on top of an existing file ask the "do you want to do this?"
question in the main part of the message, and note in the secondary text
that doing that will overwrite what's in the file; that matches what
TextEdit on OS X and the GNOME text editor say.

svn path=/trunk/; revision=42792
2012-05-22 22:17:57 +00:00
Guy Harris ae7d57d5fa We're an editor now, as we let you add, delete, and edit frame comments,
so "Save" should, for non-temporary files, mean "save the current state
of the capture file on top of the existing file" without prompting for a
file name.

That means we have to do a "safe save" - i.e, write the capture out to a
new file and, if that succeeds, rename the new file on top of the old
file - as the actual packet data to write out is in the file we're
overwriting, not in memory.  (We'd want to do that anyway, of
course....)

Update some comments.

Clean up indentation slightly, and get rid of an unnecessary variable
(in all the cases where we use it, we assign it the same value, and that
value isn't modified out from under us before we use it).

Note that after a "Save", or a "Save As" that writes out all captured
packets, we shouldn't have to close the current file and open the new
file and reread it - we should be able to open the new file and update
the frame offsets in the frame_data structures.

Note that we need to do some a better job of reporting rename failures.

svn path=/trunk/; revision=42777
2012-05-22 10:36:40 +00:00
Guy Harris 90c43120ca The GUI's state machine requires that, when reloading a capture after a
save, we post capture file callback events similar to the ones posted
when reading a capture - otherwise, the reload will leave the welcome
screen up.

Rename cf_cb_file_save_reload_finished to cf_cb_file_reload_finished,
add a cf_cb_file_reload_started callback, have them work similarly to
read_finished and read_started except that the reload uses "Reloading"
in the progress bar and status bar.

Clean up some indentation while we're at it.

svn path=/trunk/; revision=42764
2012-05-22 03:52:12 +00:00
Anders Broman d24fad6371 - Add a LED in the statusbar to indicate that capture comments exists,
clickable to open an edit window.
- Add checks for NULL pointers.

Help with a different color LED possibly with Jeff's (c) in it apreceated.
Should the LED be placed elsewhere or the whole thing done differently?

svn path=/trunk/; revision=41242
2012-02-29 16:51:32 +00:00
Gerald Combs 6b178bd415 Add 'extern "C"' wrappers and #include guards to various header files.
svn path=/trunk/; revision=40321
2011-12-29 00:08:47 +00:00
Guy Harris da1403c6dd This ain't C++; you have to put "void" in as the argument list of
functions that take no arguments, otherwise the function is treated as a
crufty old C function with undeclared arguments.

svn path=/trunk/; revision=37211
2011-05-17 21:26:25 +00:00
Sake Blok 307c0d70fb Removal of the old packet-list in favor of the new packet list.
It compiles with "./configure without options" on my Mac. Let's see what the buildbots have to say about it :-)


svn path=/trunk/; revision=36161
2011-03-08 01:52:25 +00:00
Anders Broman b7527dd063 From Cal Turney:
Bug 5621 - With String in Packet details searches, highlight row in tree 
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=5621

svn path=/trunk/; revision=35718
2011-01-31 12:19:15 +00:00
Anders Broman d4e0b348cf Doxygen fixes.
svn path=/trunk/; revision=33942
2010-08-26 20:31:09 +00:00
Guy Harris 2a328da4ef Instead of using a Boolean for the search direction, use an enum, so
that you can tell from examination whether the search is forward or
backward.

Make the cf_find_packet routines take the direction as an explicit
argument, rather than, in the cases where you don't want to permanently
set the direction, saving the direction in the capture_file structure,
changing it, doing the search, and restoring the saved direction.  Give
more information in the Doxygen comments for those routines.

Add a cf_find_packet_dfilter_string() routine, which takes a filter
string rather than a compiled filter as an argument.  Replace
find_previous_next_frame_with_filter() with it.

Have cf_read_frame_r() and cf_read_frame() pop up the error dialog if
the read fails, rather than leaving that up to its caller.  That lets us
eliminate cf_read_error_message(), by swallowing its code into
cf_read_frame_r().  Add Doxygen comments for cf_read_frame_r() and
cf_read_frame().

Don't have find_packet() read the packet before calling the callback
routine; leave that up to the callback routine.

Add cf_find_packet_marked(), to find the next or previous marked packet,
and cf_find_packet_time_reference(), to find the next or previous time
reference packet.  Those routines do *not* need to read the packet data
to see if it matches; that lets them run much faster.

Clean up indentation.

svn path=/trunk/; revision=33791
2010-08-13 07:39:46 +00:00
Gerald Combs 69d7392467 Add cf_fake_continue_tail() which is called when real-time capture
updates are off and which sets the capture file state to a value that
won't cause an assertion when the user stops capturing. Fixes bug 4035.

svn path=/trunk/; revision=33005
2010-05-27 23:55:04 +00:00
Anders Broman 65ee4e797a From Jakub Zawadzki:
New functions: cf_read_frame_r, cf_read_frame

It's much easier to write:
 cf_read_frame (cf, fdata, &err, &err_info)
Than:
 wtap_seek_read (cf->wth, fdata->file_off, &cf->pseudo_header, cf->pd,
fdata->cap_len, &err, &err_info)

svn path=/trunk/; revision=32980
2010-05-26 19:11:23 +00:00
Gerald Combs cc5d7670bd Keep a copy of the interface description and capture filter around so that
we can use it in the main window title during and after capture. Add a
"-X" option for providing a description for stdin.

svn path=/trunk/; revision=32357
2010-04-01 21:55:01 +00:00
Stig Bjørlykke 47be3577a7 Introduce "Ignore Packet" in the packet list.
This will remove the package from the dissection functions without
removing it from the capture file.

svn path=/trunk/; revision=31287
2009-12-17 01:18:14 +00:00
Jaap Keuter 81b585cf8e From Valerio Messina:
As now, when Wireshark save capture files, it show "Loading" in status bar and
in the dialog box, warning many users of lost them packets. Saving work as expected.
Is simply a GUI use interaction problem.

svn path=/trunk/; revision=31269
2009-12-14 22:05:29 +00:00
Sake Blok 2114ffff4c Some minor corrections in function descriptions
svn path=/trunk/; revision=29625
2009-08-30 10:35:48 +00:00
Anders Broman 2cd2eecd0a Compute the loading time and show it in the main status bar.
(Modified code from Didier Gautheron).

svn path=/trunk/; revision=29592
2009-08-28 05:19:52 +00:00
Anders Broman e464a9bef9 Fix setting of new time format.
svn path=/trunk/; revision=29212
2009-07-28 10:53:57 +00:00
Guy Harris cf91fdf16b Have tap listeners specify whether the "packet" routine requires
a protocol tree;

	the column values.

This includes stats-tree listeners.

Have the routines to build the packet list, and to retap packets, honor
those requirements.  This means that cf_retap_packets() no longer needs
an argument to specify whether to construct the column values or not, so
get rid of that argument.

This also means that there's no need for a tap to have a fake filter
to ensure that the protocol tree will be built, so don't set up a fake
"frame" filter.

While we're at it, clean up some cases where "no filter" was represented
as a null string rather than a null pointer.

Have a routine to return an indication of the number of tap listeners
with filters; use that rather than the global num_tap_filters.

Clean up some indentation and some gboolean vs. gint items.

svn path=/trunk/; revision=28645
2009-06-05 22:42:47 +00:00
Bill Meier 321506c076 (Trivial) Fix some spelling & etc in comments
svn path=/trunk/; revision=27996
2009-04-08 13:41:30 +00:00
Ronnie Sahlberg 24b76bdc14 add a -K command line option to provide the name of the kerberos keytab
file to use for decryption of Krb5 and GSS-KRB


svn path=/trunk/; revision=26343
2008-10-03 05:21:28 +00:00
Guy Harris c4932893e3 Have separate callback mechanisms in file.c and capture.c; pass the
capture callbacks the capture_options * as its second argument in all
cases.  This makes it a bit clearer what arguments callbacks take, and
means we can get rid of all global_capture_opts references in
gtk/main_statusbar.c.

Put the interface between gtk/main.c and gtk/main_statusbar.c into a
private header.

svn path=/trunk/; revision=25576
2008-06-24 08:05:45 +00:00
Guy Harris ffcb641149 Again, the err_info returned from wtap_read() and wtap_seek_read() is a
g_mallocated string, so it's not const.

Fix a comment to reflect reality (err_info is some additional
information about the error returned by Wiretap, e.g. some gory details
about the error, mainly useful to developers and support people).

svn path=/trunk/; revision=25401
2008-05-30 04:03:32 +00:00
Stig Bjørlykke 5800abad46 From Francesco Fondelli (bug 2349):
Attached is a patch to export packets data as "C Arrays".  I often have
the need to [re]send data captured with wireshark using a raw/pf_packet socket.
Output format is one char[] per packet, it looks like almost the same as
the one produced by "Follow TCP stream".

svn path=/trunk/; revision=24604
2008-03-11 18:23:16 +00:00
Ulf Lamping 6b4767bd7f match declaration of cf_continue_tail() with implementation
svn path=/trunk/; revision=21135
2007-03-22 23:44:48 +00:00
Guy Harris 082282b6f4 Don't enable "Save As" if you don't have an unsaved live capture file
and there are no formats in which the file can be saved by some means
other than copying the raw data; "Save As" isn't a very useful function
in that case, and that prevents us from having an empty list of formats
in which the file can be saved.

svn path=/trunk/; revision=21032
2007-03-14 19:30:19 +00:00
Ronnie Sahlberg 89f022b12b name change
svn path=/trunk/; revision=18197
2006-05-21 05:12:17 +00:00
Ulf Lamping 35dd233580 show the number of packets captured, if "Update list of packets ..." isn't used
svn path=/trunk/; revision=17071
2006-01-22 16:26:41 +00:00
Ulf Lamping 831c54c4f5 add two new callbacks:
cf_cb_file_closing (called before closing a capture file) cf_cb_file_closed will be called afterwards, but both only if a file is really closed as cf_close is called more often ...

If we are closing large capture files (~20MB), the screen looks ugly while the file is closed. Change this so the screen will immediately go back to initial state and a dialog (without buttons) is shown that the file is currently closed. As the operation which takes most of the time to close the file is a single eth_clist_clear call, we can't use a progress bar here.

cf_cb_live_capture_stopping: called when the user wants to stop the capture (toolbar or menu clicked). At least on Win32, the time between this and the actual stop completed can be noticeable (1-2 seconds), so the user doesn't know if the button press did anything at all. Do something similar as above, show a dialog box without buttons to inform that the close is in progress.

svn path=/trunk/; revision=15891
2005-09-20 08:42:35 +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 f34e1a97c6 Have cf_retap_packets() take an argument that indicates whether to
generate columns; use cf_retap_packets instead of cf_redissect_packets()
when running taps (the general flow graph stat uses the Info column).

svn path=/trunk/; revision=15793
2005-09-14 08:59:41 +00:00
Ulf Lamping 351214282d the capture child might not respond shortly after bringing it up (especially it will block, if no input coming from an input capture pipe (e.g. mkfifo) is coming in)
to prevent problems, bring the main GUI into "capture mode" right after successfully spawn/exec the capture child, without waiting for any response from it

svn path=/trunk/; revision=14436
2005-05-25 23:28:59 +00:00
Ulf Lamping 7ee0db1080 statusbar changes:
-show the current capture file size, if capturing in real time mode.
-move the packet "Drops" count (if available) from file to packets statusbar part

svn path=/trunk/; revision=14130
2005-04-18 22:05:56 +00:00
Ulf Lamping 61ccc8baf1 various capture code cleanup and fixes:
display filename in statusbar while capturing
print_usage banner fixed
cf_cb_live_capture_prepare no longer needed
rename sync_pipe_do_capture -> sync_pipe_start
bugfix: sync_pipe_input_wait_for_start replaced by former implementation
fix cleanup of old file in capture_input_new_file
fix a tempfile detection bug (named file showed up as tempfile after capture)

svn path=/trunk/; revision=14053
2005-04-11 18:57:19 +00:00
Ulf Lamping 163f2b61a8 fix statusbar messages by splitting into update and fixed messages between capture and main
svn path=/trunk/; revision=14044
2005-04-10 19:36:56 +00:00