aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap
diff options
context:
space:
mode:
authorGilbert Ramirez <gram@alumni.rice.edu>1999-01-21 05:03:56 +0000
committerGilbert Ramirez <gram@alumni.rice.edu>1999-01-21 05:03:56 +0000
commit10c23c3cd254a80c095eea6a4afebcf5cfe6c353 (patch)
tree35e13734ec9d158cc9e8dd638eb9fcec5f225d4d /wiretap
parent43a8b4b5a50e5d41b574dedcf10caaee28be30e8 (diff)
I changed the wtap_open_offline() function so that it takes only the
filename as the parameter. So far all the filetypes that wiretap can read can be inferred from the first few bytes of the file, so we never have to give wiretap a hint as to the file type. svn path=/trunk/; revision=173
Diffstat (limited to 'wiretap')
-rw-r--r--wiretap/file.c96
-rw-r--r--wiretap/wtap.h4
2 files changed, 28 insertions, 72 deletions
diff --git a/wiretap/file.c b/wiretap/file.c
index 28f1adf076..041a5c7a46 100644
--- a/wiretap/file.c
+++ b/wiretap/file.c
@@ -1,6 +1,6 @@
/* file.c
*
- * $Id: file.c,v 1.6 1999/01/17 09:33:15 guy Exp $
+ * $Id: file.c,v 1.7 1999/01/21 05:03:56 gram Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@verdict.uthscsa.edu>
@@ -38,7 +38,7 @@
* WTAP_FILE_UNKNOWN */
/* Opens a file and prepares a wtap struct */
-wtap* wtap_open_offline(char *filename, int filetype)
+wtap* wtap_open_offline(char *filename)
{
wtap *wth;
@@ -49,79 +49,35 @@ wtap* wtap_open_offline(char *filename, int filetype)
return NULL;
}
- /* If the filetype is unknown, try all my file types */
- if (filetype == WTAP_FILE_UNKNOWN) {
- /* WTAP_FILE_PCAP */
- if ((wth->file_type = libpcap_open(wth)) != WTAP_FILE_UNKNOWN) {
- goto success;
- }
- /* WTAP_FILE_NGSNIFFER */
- if ((wth->file_type = ngsniffer_open(wth)) != WTAP_FILE_UNKNOWN) {
- goto success;
- }
- /* WTAP_FILE_LANALYZER */
- if ((wth->file_type = lanalyzer_open(wth)) != WTAP_FILE_UNKNOWN) {
- goto success;
- }
- /* WTAP_FILE_SNOOP */
- if ((wth->file_type = snoop_open(wth)) != WTAP_FILE_UNKNOWN) {
- goto success;
- }
- /* WTAP_FILE_IPTRACE */
- if ((wth->file_type = iptrace_open(wth)) != WTAP_FILE_UNKNOWN) {
- goto success;
- }
- /* WTAP_FILE_NETMON */
- if ((wth->file_type = netmon_open(wth)) != WTAP_FILE_UNKNOWN) {
- goto success;
- }
+ /* Try all my file types */
- printf("failed\n");
- /* WTAP_FILE_UNKNOWN */
- goto failure;
+ /* WTAP_FILE_PCAP */
+ if ((wth->file_type = libpcap_open(wth)) != WTAP_FILE_UNKNOWN) {
+ goto success;
}
-
- /* If the user tells us what the file is supposed to be, check it */
- switch (filetype) {
- case WTAP_FILE_PCAP:
- if ((wth->file_type = libpcap_open(wth)) != WTAP_FILE_UNKNOWN) {
- goto success;
- }
- break;
- case WTAP_FILE_NGSNIFFER:
- if ((wth->file_type = ngsniffer_open(wth)) != WTAP_FILE_UNKNOWN) {
- goto success;
- }
- break;
- case WTAP_FILE_LANALYZER:
- if ((wth->file_type = lanalyzer_open(wth)) != WTAP_FILE_UNKNOWN) {
- goto success;
- }
- break;
- case WTAP_FILE_SNOOP:
- if ((wth->file_type = snoop_open(wth)) != WTAP_FILE_UNKNOWN) {
- goto success;
- }
- break;
- case WTAP_FILE_IPTRACE:
- if ((wth->file_type = iptrace_open(wth)) != WTAP_FILE_UNKNOWN) {
- goto success;
- }
- break;
- case WTAP_FILE_NETMON:
- if ((wth->file_type = netmon_open(wth)) != WTAP_FILE_UNKNOWN) {
- goto success;
- }
- break;
- default:
- goto failure;
+ /* WTAP_FILE_NGSNIFFER */
+ if ((wth->file_type = ngsniffer_open(wth)) != WTAP_FILE_UNKNOWN) {
+ goto success;
+ }
+ /* WTAP_FILE_LANALYZER */
+ if ((wth->file_type = lanalyzer_open(wth)) != WTAP_FILE_UNKNOWN) {
+ goto success;
+ }
+ /* WTAP_FILE_SNOOP */
+ if ((wth->file_type = snoop_open(wth)) != WTAP_FILE_UNKNOWN) {
+ goto success;
+ }
+ /* WTAP_FILE_IPTRACE */
+ if ((wth->file_type = iptrace_open(wth)) != WTAP_FILE_UNKNOWN) {
+ goto success;
+ }
+ /* WTAP_FILE_NETMON */
+ if ((wth->file_type = netmon_open(wth)) != WTAP_FILE_UNKNOWN) {
+ goto success;
}
- /* If we made it through the switch() statement w/o going to "success",
- * then we failed. */
- goto failure;
-failure:
+/* failure: */
fclose(wth->fh);
free(wth);
wth = NULL;
diff --git a/wiretap/wtap.h b/wiretap/wtap.h
index 45afc04ac9..9a0613268e 100644
--- a/wiretap/wtap.h
+++ b/wiretap/wtap.h
@@ -1,6 +1,6 @@
/* wtap.h
*
- * $Id: wtap.h,v 1.11 1999/01/17 09:33:15 guy Exp $
+ * $Id: wtap.h,v 1.12 1999/01/21 05:03:56 gram Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@verdict.uthscsa.edu>
@@ -110,7 +110,7 @@ typedef struct wtap {
} wtap;
-wtap* wtap_open_offline(char *filename, int filetype);
+wtap* wtap_open_offline(char *filename);
void wtap_loop(wtap *wth, int, wtap_handler, u_char*);
FILE* wtap_file(wtap *wth);