3 * $Id: file.c,v 1.10 1999/07/07 22:52:54 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;
57 /* Try all file types */
60 if ((wth->file_type = libpcap_open(wth)) != WTAP_FILE_UNKNOWN) {
63 /* WTAP_FILE_NGSNIFFER */
64 if ((wth->file_type = ngsniffer_open(wth)) != WTAP_FILE_UNKNOWN) {
67 /* WTAP_FILE_LANALYZER */
68 if ((wth->file_type = lanalyzer_open(wth)) != WTAP_FILE_UNKNOWN) {
72 if ((wth->file_type = snoop_open(wth)) != WTAP_FILE_UNKNOWN) {
75 /* WTAP_FILE_IPTRACE */
76 if ((wth->file_type = iptrace_open(wth)) != WTAP_FILE_UNKNOWN) {
79 /* WTAP_FILE_NETMON */
80 if ((wth->file_type = netmon_open(wth)) != WTAP_FILE_UNKNOWN) {
83 /* WTAP_FILE_NETXRAY */
84 if ((wth->file_type = netxray_open(wth)) != WTAP_FILE_UNKNOWN) {
96 wth->frame_buffer = g_malloc(sizeof(struct Buffer));
97 buffer_init(wth->frame_buffer, 1500);