aboutsummaryrefslogtreecommitdiffstats
path: root/file.c
AgeCommit message (Collapse)AuthorFilesLines
2000-09-27First step in moving core Ethereal routines to libepan.Gilbert Ramirez1-3/+5
svn path=/trunk/; revision=2458
2000-09-17The correct way to check for an error (rather than an EOF) from a failedGuy Harris1-4/+4
attempt to read from a capture file is to check whether the error returned was 0 - if it is, it's an EOF. We no longer guarantee that the data offset supplied will be negative on an error and 0 on an EOF. svn path=/trunk/; revision=2445
2000-09-12It's "GSList", not "GSlist".Guy Harris1-2/+2
svn path=/trunk/; revision=2417
2000-09-12Also free the GSLists for per-frame data on frames we haven'tGuy Harris1-8/+6
re-dissected on a rescan. svn path=/trunk/; revision=2416
2000-09-11Fix the problem with resetting per-frame state info problems that thereRichard Sharpe1-8/+7
seemed to be ... svn path=/trunk/; revision=2412
2000-09-11We have to free up the per-frame data when we rescan, because we haveRichard Sharpe1-1/+10
called packet_init_proto, which blows away the items the list points to. svn path=/trunk/; revision=2408
2000-09-10Compute and display negative relative and delta time stamps correctly,Guy Harris1-19/+14
just in case time goes backwards (yes, it sometimes does happen in captures). svn path=/trunk/; revision=2407
2000-09-09"redraw_hex_dump()" can't use "cfile.pd" or "cfile.current_frame", as itGuy Harris1-3/+2
may be redrawing a packet window that displays a frame other than the current frame; give it arguments to specify the raw frame data and "frame_data" structure for the frame. This requires that each packet window have, associated with it, a pointer to the "frame_data" structure; that replaces the "cap_len" and "encoding" fields in a "PacketWinData" structure, as those are just copies of fields from the frame's "frame_data" structure. "packet_hex_print()" needn't be passed both the start and length values from a "field_info" structure - just pass it a pointer to that structure, or NULL for "no field is selected in the packet". It also needn't, any longer, be passed the "cap_len" and "flags.encoding" fields of a "frame_data" structure - just pass it a pointer to that structure. In "redraw_hex_dump_all()", don't redraw the hex dump pane of the main window if there is no current frame. svn path=/trunk/; revision=2404
2000-09-08Redraw:Guy Harris1-3/+2
the text in all "Follow TCP Stream" windows; the text in the help window if we have one up; all hex dump windows; when GUI preference changes are to be applied, so that font changes and "Follow TCP Stream" color changes show up. Update both the Roman and bold font when the font is changed. Don't decrement the reference counts on the old Roman and bold fonts until that's all done. svn path=/trunk/; revision=2401
2000-09-08Graham Bloice's patch to support inverse video rather than boldfaceGuy Harris1-2/+3
highlighting of the bytes, in the hex dump window, corresponding to a selected field. Also, make "remember_ptree_widget()" static, as it's not used outside "gtk/proto_draw.c". svn path=/trunk/; revision=2399
2000-09-07Change wtap_read() API so that the data offset is set via a pointer, andGilbert Ramirez1-4/+4
a "keep reading" boolean value is returned from the function. This avoids having to hack around the fact that some file formats truly do have records that start at offset 0. (i4btrace and csids have no file header. Neither does the pppdump-style file that I'm looking at right now). svn path=/trunk/; revision=2392
2000-08-24If we've thrown away saved state before a rescan of the frames in aGuy Harris1-2/+21
capture, clear the per-frame data pointers of all frames in the capture, as those pointers now refer to data that's been freed. Do that to all frames even if the user stops the rescan in the middle - and clear the "visited" flag for all frames as well. svn path=/trunk/; revision=2361
2000-08-24Actually, we do have to clear all the dissector information if we'reGuy Harris1-8/+34
redissecting the packets due to some preference changing, as the preference may affect what state information gets constructed as a result of some particular frame being dissected. We don't have to do it when filtering the packets, or colorizing them, however. svn path=/trunk/; revision=2359
2000-08-24Instead of keeping in the information about an RPC call a count of theGuy Harris1-14/+1
number of replies seen, keep the frame number of the first request seen for that call and the first reply seen for that call. Use that to determine whether a request or reply is a duplicate or not. That means that we don't have to reset the table of RPC calls on a rescan of the capture (which didn't even fix all the cases where we'd have misreported the original call or reply as a duplicate due to having seen it once on the initial pass through the file and once again when, for example, the user clicked on the packet); doing so causes plenty of other problems, so don't do that - and don't clear the "visited" flag on frames on a rescan, either, as that's only done because we were clearing out conversations and calling all protocols' "init" routines. As a free bonus, this means that, for a reply, we know what frame the request was in; put that information into the protocol tree for the reply, snoop-style. Make the table of RPC call information, and the routines that manipulate it, static to "packet-rpc.c"; nobody outside "packet-rpc.c" uses them. svn path=/trunk/; revision=2358
2000-08-21Add prefs.gui_marked_[fb]g color preferences for theLaurent Deniel1-4/+3
color of marked frames. They are currently only available from preferences file, but I will add the color selection in GUI later. svn path=/trunk/; revision=2327
2000-08-21Frames in the packet list can now be marked by the user usingLaurent Deniel1-9/+22
the middle mouse button. The marked packets are displayed in reverse video but this should change in the future (the color should be configurable via the GUI). Then, the marked packets can be saved (via the "Save as" window dialog). Other features will be added in the future (I am waiting for your comments and wishes). svn path=/trunk/; revision=2322
2000-08-19Fix potential buffer overflows.Laurent Deniel1-3/+4
svn path=/trunk/; revision=2298
2000-08-15Oups. Forgot some set_menus_for_selected_tree_row calls.Laurent Deniel1-1/+2
svn path=/trunk/; revision=2277
2000-08-11Miscellaneous code cleaningLaurent Deniel1-8/+9
- add <stdarg.h> or <varargs.h> in snprintf.h and remove those inclusions in the other #ifdef NEED_SNPRINTF_H codes - remove the check of multiple inclusions in source (.c) code (there is a bit loss of _cpp_ performance, but I prefer the gain of code reading and maintenance; and nowadays, disk caches and VM are correctly optimized ;-). - protect all (well almost) header files against multiple inclusions - add header (i.e. GPL license) in some include files - reorganize a bit the way header files are included: First: #include <system_include_files> #include <external_package_include_files (e.g. gtk, glib etc.)> Then #include "ethereal_include_files" with the correct HAVE_XXX or NEED_XXX protections. - add some HAVE_XXX checks before including some system header files - add the same HAVE_XXX in wiretap as in ethereal Please forgive me, if I break something (I've only compiled and regression tested on Linux). svn path=/trunk/; revision=2254
2000-08-09Make copy_binary_file() static since follow_dlg.c no longer uses it.Gilbert Ramirez1-2/+3
svn path=/trunk/; revision=2237
2000-08-03Add a "Save As" feature to the TCP Follow dialogue, to save the streamGilbert Ramirez1-54/+76
file to a user-specified file. Move the file-copy routine in save_cap_file() to an indepenent function in file.c (copy_binary_file()) so that follow_dlg.c can use it. Remove #include "follow.h" from the C files that don't need it. svn path=/trunk/; revision=2200
2000-08-03Replace calls to sprintf() with snprintf() in file_*_error_message routines,Gilbert Ramirez1-6/+11
as a long filename may overflow the buffer. svn path=/trunk/; revision=2199
2000-07-26When rescanning a file, all state information for the frames hasGilbert Ramirez1-1/+5
been deleted. So we have to set fdata->flags.visited to 0 for each frame, denoting a "fresh" scan. svn path=/trunk/; revision=2161
2000-07-20In Tethereal:Guy Harris1-2/+2
When capturing, report errors trying to create the output file with "file_open_error_message()". Make the "for_writing" argument to "file_open_error_message()" a "gboolean", as it's either TRUE (if the file is being opened for writing) or FALSE (if it's being opened for reading). Report EISDIR as "XXX is a directory (folder), not a file.". When checking whether an "open()" of a capture file succeeded, check whether "open()" returns a negative number, not whether it returns 0. In "wtap_open_offline()", if the file to be opened is a directory, return EISDIR, not WTAP_ERR_NOT_REGULAR_FILE, so that the error message can say "that's a directory, not a file". If "wtap_open_offline()" returns WTAP_ERR_NOT_REGULAR_FILE, don't just say the file is "invalid", say it's a "special file" or socket or some other weird type of file. svn path=/trunk/; revision=2144
2000-07-20Use ESD_TYPE_CRIT for most errors (the model used by various GUIs seemsGuy Harris1-13/+17
to use "warning" dialog boxes only to warn the user "if you do that, bad things may happen" *and* to offer them the option either to drive on or quit, so perhaps ESD_TYPE_CRIT should be used for all errors). However, put "Ethereal: Error" rather than "Ethereal: Critical" in the title bar, in the hopes that it'll make it clearer that Something Bad Happened. If the user specifies that captures should be saved to a user-specified file rather than a temporary file, report errors trying to create that file with "file_open_error_message()". Make the "for_writing" argument to "file_open_error_message()" a "gboolean", as it's either TRUE (if the file is being opened for writing) or FALSE (if it's being opened for reading). Report EISDIR as "XXX is a directory (folder), not a file.". svn path=/trunk/; revision=2143
2000-07-09Put up a progress dialog when changing the time display; it can take aGuy Harris1-1/+47
long time on a large capture. If the user is changing the setting of "Display TOS as DiffServ" *and* the time stamp format, don't bother doing the time display update - we'll regenerate the entire display anyway because we changed the setting of "Display TOS as DiffServ". svn path=/trunk/; revision=2130
2000-07-09Turn the code of "colorize_packet()" into a static routine that is givenGuy Harris1-35/+74
a word to use in the progress dialog, and a flag indicating whether the display filter is to be reevaluated or not, and: have "colorize_packet()" call that routine with "Colorizing" and FALSE as those arguments; have the filtering code call that routine with "Filtering" and TRUE as those arguments; add an exported routine to call that routine with "Reprocessing" and TRUE as those arguments, to use to re-generate the packet list and to re-filter the packets if a protocol preference has been changed. Keep track of whether preferences are changed from their initial value by a preferences file or a command-line option, or from their previous value by the "Preferences" dialog box; have "prefs_apply_all()" only call the "apply" callback for a module if they have. Call "prefs_apply_all()" after the command-line arguments have been parsed and after "OK" has been clicked in the "Preferences" dialog box, to notify modules of preference changes if they've registered a callback for that. After "OK" has been clicked in the "Preferences" dialog box, if any preferences have changed, call the reprocessing routine, as the summary line for some frames and/or the current display filter's value when applied to some frames may have changed as a result of a preference change. Do the same after "OK" or "Apply" has been clicked in the "Display Options" dialog box (as it controls a protocol preferences item. svn path=/trunk/; revision=2126
2000-07-07If the progress dialog gets a "delete" event, have the handler returnGuy Harris1-4/+5
TRUE, meaning "don't delete this", and if its "stop this operation" button gets clicked, don't have its handler delete the progress dialog; instead, leave the deletion of the window up to the code using the dialog, as it'll do so when it stops the operation. Make the "read file" operation destroy the dialog; all the other operations already did so (as they just broke out of the loop doing the operation, rather than returning). Don't catch the "destroy" operation on the dialog box - its handler appeared never to get called; we can just free the "progdlg_t" for the dialog in "destroy_progress_dlg()", right after destroying the dialog box widget. svn path=/trunk/; revision=2122
2000-07-07Use "progdlg_t *" rather than "void *" as the handle for a progressGuy Harris1-18/+19
dialog box; that lets us do some type-checking, but we can still typedef it to an incompletely-defined structure to hide the implementation details from the caller. Make "create_progress_dlg()" take, as an argument, the title to put in the "stop the operation" button, and use "Stop" rather than "Cancel" if stopping the operation doesn't undo all the work it's done. Thaw the clist if we break out of a "read the file" operation, as we freeze it before the operation. Have the handler for the "delete" event on the progress dialog box return FALSE, to let GTK+ know that it should, in fact, delete the window. ("delete" event handlers should return TRUE if the window shouldn't actually be deleted, FALSE if it should; they should not return "void".) svn path=/trunk/; revision=2120
2000-07-03If the user clicks the "Cancel" button in a progress-bar dialog box forGuy Harris1-4/+5
reading a capture file, we should just clean up and return so that Ethereal continues running with no capture file loaded, unless the read is being done as a result of Ethereal being run with the "-r" flag, in which case we still exit (although we may eventually choose to continue running with no capture file loaded even in that case). svn path=/trunk/; revision=2104
2000-07-03Remove the progress bar from the status line, and, instead, for anyGuy Harris1-60/+91
potentially long-running operation that has a progress indicator, pop up a modal dialog box with an indication of what is being done; a progress bar; a "Cancel" button to stop the operation. This: leaves more room on the status line for a filter expression; provides a mechanism to allow the user to cancel long-running operations (although the way we do so may not back out of them as nicely as the user might like, if it's not obvious what the "right" way is or if the "right" way is difficult to implement or involves doing as much work as letting the operation continue); means that, because the dialog box is modal, we don't have to worry about the user performing arbitrary UI operations out from under the operation and changing arbitrary bits of state being used by that operation. svn path=/trunk/; revision=2103
2000-06-27Don't pass a pointer to the packet data buffer to "read_packet()"; letGuy Harris1-7/+8
it, rather than its callers, get that pointer from "cf->wth". svn path=/trunk/; revision=2096
2000-06-27Add routines to Wiretap to allow a client of Wiretap to get:Guy Harris1-32/+114
a pointer to the "wtap_pkthdr" structure for an open capture file; a pointer to the "wtap_pseudo_header" union for an open capture file; a pointer to the packet buffer for an open capture file; so that a program using "wtap_read()" in a loop can get at those items. Keep, in a "capture_file" structure, an indicator of whether: no file is open; a file is open, and being read; a file is open, and is being read, but the user tried to quit out of reading the file (e.g., by doing "File/Quit"); a file is open, and has been completely read. Abort if we try to close a capture that's being read if the user hasn't tried to quit out of the read. Have "File/Quit" check if a file is being read; if so, just set the state indicator to "user tried to quit out of it", so that the code reading the file can do what's appropriate to clean up, rather than closing the file out from under that code and causing crashes. Have "read_cap_file()" read the capture file with a loop using "wtap_read()", rather than by using "wtap_loop()"; have it check after reading each packet whether the user tried to abort the read and, if so, close the capture and return an indication that the read was aborted by the user. Otherwise, return an indication of whether the read completely succeeded or failed in the middle (and, if it failed, return the error code through a pointer). Have "continue_tail_cap_file()" read the capture file with a loop using "wtap_read()", rather than by using "wtap_loop()"; have it check after reading each packet whether the user tried to abort the read and, if so, quit the loop, and after the loop finishes (even if it read no packets), return an indication that the read was aborted by the user if that happened. Otherwise, return an indication of whether the read completely succeeded or failed in the middle (and, if it failed, return the error code through a pointer). Have "finish_tail_cap_file()" read the capture file with a loop using "wtap_read()", rather than by using "wtap_loop()"; have it check after reading each packet whether the user tried to abort the read and, if so, quit the loop, and after the loop finishes (even if it read no packets), close the capture and return an indication that the read was aborted by the user if that happened. Otherwise, return an indication of whether the read completely succeeded or failed in the middle (and, if it failed, return the error code through a pointer). Have their callers check whether the read was aborted or not and, if it was, bail out in the appropriate fashion (exit if it's reading a file specified by "-r" on the command line; exit the main loop if it's reading a file specified with File->Open; kill the capture child if it's "continue_tail_cap_file()"; exit the main loop if it's "finish_tail_cap_file()". svn path=/trunk/; revision=2095
2000-06-27Patch from Ben Fowler to rename the global variable "cf" to "cfile", toGuy Harris1-1/+2
make it easier to use grep to find all references to it without getting a lot of false hits and to check, after allocating the memory chunk for "frame_data" structures, that the allocation succeeded. svn path=/trunk/; revision=2092
2000-05-19Add wtap-int.h. Move definitions relevant to the internal workins of wiretapGilbert Ramirez1-5/+5
to that file, leave public definitions in wtap.h. Rename "union pseudo_header" to "union wtap_pseudo_header". Make the wtap_pseudo_header pointer available in packet_info struct. svn path=/trunk/; revision=1989
2000-05-18Remove the "union pseudo_header" from the "frame_data" structure;Guy Harris1-41/+37
there's no need to keep it around in memory - when the frame data is read in when handing a frame, read in the information, if any, necessary to reconstruct the frame header, and reconstruct it. This saves some memory. This requires that the seek-and-read function be implemented inside Wiretap, and that the Wiretap handle remain open even after we've finished reading the file sequentially. This also points out that we can't really do X.25-over-Ethernet correctly, as we don't know where the direction (DTE->DCE or DCE->DTE) flag is stored; it's not clear how the Ethernet type 0x0805 for X.25 Layer 3 is supposed to be handled in any case. We eliminate X.25-over-Ethernet support (until we find out what we're supposed to do). svn path=/trunk/; revision=1975
2000-05-18Have "proto_tree_is_visible" false except when we're in the middle ofGuy Harris1-7/+9
doing something that requires that the text for protocol tree entries be generated, i.e. 1) initialize it to FALSE; 2) have every routine that sets it clear it when it's done; 3) when printing packets, set it to TRUE only if we're not just printing packet summary lines; and then get rid of settings to FALSE made unnecessary as a result of those changes. This makes sure it's not set when it doesn't have to be (which causes the protocol tree code to format the text when it doesn't have to, wasting CPU time). svn path=/trunk/; revision=1973
2000-05-15We can't trust "cf->current_frame" to refer to the frame that wasGuy Harris1-50/+63
selected before we started re-colorizing or re-filtering the display, as when the first row is added to the clist, that may be selected and thus made the current frame. This means that we can't find the row corresponding to the previously-selected frame, if any, by checking as each packet is colorized/filtered and see whether its "frame_data" structure is equal to "cf->current_frame", as that'll always say that the first frame in the display is the selected frame. Instead, we recored the value of "cf->current_frame" before we do anything to the clist, have "add_packet_to_packet_list()" return either the row number of the frame (if it passed the filter and thus was added to the clist) or -1 (if it didn't pass the filter and thus wasn't added to the clist), and, after "add_packet_to_packet_list()", if the current frame is the one that was the selected row, remember its row number (if any), and, when we're finished colorizing/filtering the display, make that row the current row if it's not -1 (-1 means that the selected row didn't pass the filter). Also, don't do that until after we've thawed the clist, as the vertical adjustment for the clist doesn't reflect reality until then, and attempting to go to a given row won't work right until the vertical adjustment for the clist reflects reality. Shove all the code to set the selected and focus rows, and to make said row visible, into a routine, so the "Find Frame" and "Go To Frame" code can use it as well. svn path=/trunk/; revision=1959
2000-05-12Ben Fowler <wapdev@leedsnet.com>'s "usage of fd" patch.Gilbert Ramirez1-59/+59
svn path=/trunk/; revision=1952
2000-05-06Fix indentation so that it looks correct if tabs are every 8 spaces,Guy Harris1-3/+3
that being the UNIX default. svn path=/trunk/; revision=1911
2000-04-14Change dfilter_apply() to 4-argument function. 4th argument is not yet used,Gilbert Ramirez1-5/+7
but will be in the future, and it's easier for me to keep my local branch in sync with the source with the calls to dfilter_apply() already modified tothe 4-arg format. Add a CPP macro to ipv4.h to define ipv4_addr_ne(). Use it in dfilter.c svn path=/trunk/; revision=1854
2000-04-13Consolidate flags in struct frame_data, and add "visited" flag. UseGilbert Ramirez1-12/+13
it in SOCKS dissector. (Okay, how many times am I going to modify packet.h today, forcing you to re-compile everything? :-) svn path=/trunk/; revision=1850
2000-04-07When searching for a frame that matches a filter expression, weGuy Harris1-7/+7
shouldn't stop the search as soon as we get back to the starting frame, we should stop the search if the filter expression doesn't match and the frame we tried it on was the starting frame - it's OK if we find the starting frame, it's just not OK to continue if we don't find that frame. svn path=/trunk/; revision=1815
2000-04-07Plug a memory leak in the "Find Frame" code - we weren't freeing theGuy Harris1-2/+5
protocol tree after checking whether it matched the filter we supplied. svn path=/trunk/; revision=1814
2000-04-06After destroying the mem chunk for the packet list, null out the pointerGuy Harris1-2/+4
pointing to it, so that if we call "close_cap_file()" again, we don't try to destroy an already-destroyed mem chunk. svn path=/trunk/; revision=1806
2000-04-04Allocate the new mem chunk for the capture in "open_cap_file()", ratherGuy Harris1-9/+6
than duplicating the allocation code in "read_cap_file()" and "start_tail_cap_file()". svn path=/trunk/; revision=1784
2000-04-03Set cf->plist_chunk in the other place where needed. Guy's experiencingGilbert Ramirez1-2/+10
some network problems today, so I checked this in for him. svn path=/trunk/; revision=1782
2000-04-03Note that it didn't seem to save a significant amount of time or spaceGuy Harris1-2/+6
to use a G_ALLOC_ONLY memory chunk rather than a G_ALLOC_AND_FREE memory chunk. svn path=/trunk/; revision=1777
2000-04-03Use a GMemChunk for allocating and freeing "frame_data" structures; itGuy Harris1-10/+15
reduces the memory required for one big capture file I have by about 10 megabytes, and speeds up the reading in of that file, presumably because it amortizes the memory-allocator space and CPU time overhead over a set of several "frame_data" structures. svn path=/trunk/; revision=1776
2000-03-31Add a counter : "enabled_plugins_number", to record how many plugins areOlivier Abad1-2/+2
enabled. The counter is incremented in enable_plugin() and decremented in disable_plugin(). In add_packet_to_packet_list(), we check this counter (instead of plugin_list) to see if there is at least one enabled plugin. If this is the case, we must build the protocol tree. svn path=/trunk/; revision=1770