diff options
author | Guy Harris <guy@alum.mit.edu> | 2011-04-27 02:54:44 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2011-04-27 02:54:44 +0000 |
commit | c9b9dd690bac14b7402283e178d4c3b00f200d41 (patch) | |
tree | 979c246af1b4c25a9281402994c2545eb869eb96 /tshark.c | |
parent | 6c09e1cf9566a6d21cb0f0df47bf391c2e2ffc84 (diff) |
Create a new frame_data_sequence data type; it represents a dense
sequence of frame_data structures, indexed by the frame number. Extract
the relevant bits of the capture_file data structure and move them to
the frame_data_sequence, and move the relevant code from cfile.c and
tweak it to handle frame_data_sequence structures.
Have a possibly-null pointer to a frame_data_sequence structure in the
capture_file structure; if it's null, we aren't keeping a sequence of
frame_data structures (we don't keep that sequence when we're doing
one-pass processing in TShark).
Nothing in libwireshark should care about a capture_file structure; get
rid of some unnecessary includes of cfile.h.
svn path=/trunk/; revision=36881
Diffstat (limited to 'tshark.c')
-rw-r--r-- | tshark.c | 20 |
1 files changed, 10 insertions, 10 deletions
@@ -1816,14 +1816,10 @@ main(int argc, char *argv[]) g_free(cf_name); - /* XXX - hack to avoid a crash in one-pass mode, where we update - cfile.count but don't allocate any frame_data structures. - We may want to more cleanly separate the "capture file" and - "collection of frames" stuff, to handle cases such as TShark - one-pass mode where we care about the former but don't care - about the latter. */ - if (cfile.ptree_root != NULL) - cap_file_free_frames(&cfile); + if (cfile.frames != NULL) { + free_frame_data_sequence(cfile.frames); + cfile.frames = NULL; + } draw_tap_listeners(TRUE); funnel_dump_all_text_windows(); @@ -2441,7 +2437,8 @@ process_packet_first_pass(capture_file *cf, if (passed) { frame_data_set_after_dissect(&fdlocal, &cum_bytes, &prev_dis_ts); - cap_file_add_fdata(cf, &fdlocal); + frame_data_sequence_add(cf->frames, &fdlocal); + cf->count++; } if (do_dissection) @@ -2650,6 +2647,9 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type, frame_data *fdata; int old_max_packet_count = max_packet_count; + /* Allocate a frame_data_sequence for all the frames. */ + cf->frames = new_frame_data_sequence(); + while (wtap_read(cf->wth, &err, &err_info, &data_offset)) { if (process_packet_first_pass(cf, data_offset, wtap_phdr(cf->wth), wtap_pseudoheader(cf->wth), wtap_buf_ptr(cf->wth))) { @@ -2675,7 +2675,7 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type, max_packet_count = old_max_packet_count; for (framenum = 1; err == 0 && framenum <= cf->count; framenum++) { - fdata = cap_file_find_fdata(cf, framenum); + fdata = frame_data_sequence_find(cf->frames, framenum); if (wtap_seek_read(cf->wth, fdata->file_off, &cf->pseudo_header, cf->pd, fdata->cap_len, &err, &err_info)) { if (process_packet_second_pass(cf, fdata, |