3 * $Id: file.c,v 1.9 1999/03/01 18:57:04 gram Exp $
6 * Copyright (c) 1998 by Gilbert Ramirez <gram@verdict.uthscsa.edu>
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29 #include "lanalyzer.h"
30 #include "ngsniffer.h"
37 /* The open_file_* routines should return the WTAP_FILE_* type
38 * that they are checking for if the file is successfully recognized
39 * as such. If the file is not of that type, the routine should return
40 * WTAP_FILE_UNKNOWN */
42 /* Opens a file and prepares a wtap struct */
43 wtap* wtap_open_offline(char *filename)
47 wth = (wtap*)malloc(sizeof(wtap));
50 if (!(wth->fh = fopen(filename, "rb"))) {
55 wth->file_encap = WTAP_ENCAP_NONE;
56 wth->filter.offline = NULL;
57 wth->filter_type = WTAP_FILTER_NONE;
58 wth->filter_length = 0;
59 wth->offline_filter_lengths = NULL;
61 /* Try all file types */
64 if ((wth->file_type = libpcap_open(wth)) != WTAP_FILE_UNKNOWN) {
67 /* WTAP_FILE_NGSNIFFER */
68 if ((wth->file_type = ngsniffer_open(wth)) != WTAP_FILE_UNKNOWN) {
71 /* WTAP_FILE_LANALYZER */
72 if ((wth->file_type = lanalyzer_open(wth)) != WTAP_FILE_UNKNOWN) {
76 if ((wth->file_type = snoop_open(wth)) != WTAP_FILE_UNKNOWN) {
79 /* WTAP_FILE_IPTRACE */
80 if ((wth->file_type = iptrace_open(wth)) != WTAP_FILE_UNKNOWN) {
83 /* WTAP_FILE_NETMON */
84 if ((wth->file_type = netmon_open(wth)) != WTAP_FILE_UNKNOWN) {
87 /* WTAP_FILE_NETXRAY */
88 if ((wth->file_type = netxray_open(wth)) != WTAP_FILE_UNKNOWN) {
100 wth->frame_buffer = g_malloc(sizeof(struct Buffer));
101 buffer_init(wth->frame_buffer, 1500);