aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>1999-12-04 11:32:25 +0000
committerGuy Harris <guy@alum.mit.edu>1999-12-04 11:32:25 +0000
commitaef39cc00fbb22e3182d7dec9d29de501fea0e38 (patch)
tree9b73eccad5cbeeb7b207a17633570ae787387708
parent0dcade26341d2cfaebdbb033333caf0f8c76f5b3 (diff)
To find out the file's packet encapsulation type (which could be
WTAP_ENCAP_PER_PACKET, if there's more than one type of packet in the file, or could be WTAP_ENCAP_UNKNOWN, if the file is of a type that doesn't put an encapsulation type in the file header, and it has no packets), we just need to call "wtap_file_encap()" when we're done reading the file. svn path=/trunk/; revision=1205
-rw-r--r--file.c27
-rw-r--r--file.h3
2 files changed, 13 insertions, 17 deletions
diff --git a/file.c b/file.c
index fc3b8c1b68..d30b3600ad 100644
--- a/file.c
+++ b/file.c
@@ -1,7 +1,7 @@
/* file.c
* File I/O routines
*
- * $Id: file.c,v 1.133 1999/12/04 08:59:12 guy Exp $
+ * $Id: file.c,v 1.134 1999/12/04 11:32:24 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -163,7 +163,6 @@ open_cap_file(char *fname, gboolean is_tempfile, capture_file *cf)
cf->user_saved = !is_tempfile;
cf->cd_t = wtap_file_type(cf->wth);
- cf->first_packet = TRUE;
cf->count = 0;
cf->drops = 0;
cf->esec = 0;
@@ -308,6 +307,11 @@ read_cap_file(capture_file *cf)
freeze_clist(cf);
proto_tree_is_visible = FALSE;
success = wtap_loop(cf->wth, 0, wtap_dispatch_cb, (u_char *) cf, &err);
+ /* Set the file encapsulation type now; we don't know what it is until
+ we've looked at all the packets, as we don't know until then whether
+ there's more than one type (and thus whether it's
+ WTAP_ENCAP_PER_PACKET). */
+ cf->lnk_t = wtap_file_encap(cf->wth);
wtap_close(cf->wth);
cf->wth = NULL;
cf->filed = open(cf->filename, O_RDONLY);
@@ -454,6 +458,12 @@ finish_tail_cap_file(capture_file *cf)
gtk_clist_moveto(GTK_CLIST(packet_list),
cf->plist_end->row, -1, 1.0, 1.0);
+ /* Set the file encapsulation type now; we don't know what it is until
+ we've looked at all the packets, as we don't know until then whether
+ there's more than one type (and thus whether it's
+ WTAP_ENCAP_PER_PACKET). */
+ cf->lnk_t = wtap_file_encap(cf->wth);
+
/* There's nothing more to read from the capture file - close it. */
wtap_close(cf->wth);
cf->wth = NULL;
@@ -897,19 +907,6 @@ wtap_dispatch_cb(u_char *user, const struct wtap_pkthdr *phdr, int offset,
gtk_main_iteration();
}
- if (cf->first_packet) {
- /* Tentatively make the encapsulation type the type of the first
- packet. */
- cf->lnk_t = phdr->pkt_encap;
- } else {
- /* If this packet's encapsulation type isn't the same as the type
- type we've chosen so far, make the type for this file
- WTAP_ENCAP_PER_PACKET, because there is no single encapsulation
- type for the entire file. */
- if (cf->lnk_t != phdr->pkt_encap)
- cf->lnk_t = WTAP_ENCAP_PER_PACKET;
- }
-
/* Allocate the next list entry, and add it to the list. */
fdata = (frame_data *) g_malloc(sizeof(frame_data));
diff --git a/file.h b/file.h
index 6680467cc1..6953eb8516 100644
--- a/file.h
+++ b/file.h
@@ -1,7 +1,7 @@
/* file.h
* Definitions for file structures and routines
*
- * $Id: file.h,v 1.59 1999/12/04 08:59:13 guy Exp $
+ * $Id: file.h,v 1.60 1999/12/04 11:32:25 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -81,7 +81,6 @@ typedef struct _capture_file {
gboolean user_saved;/* If capture file is temporary, has it been saved by user yet? */
long f_len; /* Length of capture file */
guint16 cd_t; /* File type of capture file */
- gboolean first_packet; /* TRUE if we're looking at the first packet */
int lnk_t; /* Link-layer type with which to save capture */
guint32 vers; /* Version. For tcpdump minor is appended to major */
guint32 count; /* Packet count */