diff --git a/wiretap/file.c b/wiretap/file.c index 47158af9ad..063bfb0c33 100644 --- a/wiretap/file.c +++ b/wiretap/file.c @@ -1,6 +1,6 @@ /* file.c * - * $Id: file.c,v 1.32 1999/12/04 05:37:36 guy Exp $ + * $Id: file.c,v 1.33 1999/12/04 08:32:11 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez @@ -171,6 +171,114 @@ success: return wth; } +/* Table of the file types we know about. */ +const static struct file_type_info { + const char *name; + int (*can_dump_encap)(int, int); + int (*dump_open)(wtap_dumper *, int *); +} dump_open_table[WTAP_NUM_FILE_TYPES] = { + /* WTAP_FILE_UNKNOWN */ + { NULL, + NULL, NULL }, + + /* WTAP_FILE_WTAP */ + { "Wiretap (Ethereal)", + NULL, NULL }, + + /* WTAP_FILE_PCAP */ + { "libpcap (tcpdump)", + libpcap_dump_can_dump_encap, libpcap_dump_open }, + + /* WTAP_FILE_PCAP_MODIFIED */ + { "modified libpcap (tcpdump)", + NULL, NULL }, + + /* WTAP_FILE_LANALYZER */ + { "Novell LANalyzer", + NULL, NULL }, + + /* WTAP_FILE_NGSNIFFER */ + { "Network Associates Sniffer (DOS-based)", + NULL, NULL }, + + /* WTAP_FILE_SNOOP */ + { "snoop", + snoop_dump_can_dump_encap, snoop_dump_open }, + + /* WTAP_FILE_IPTRACE_1_0 */ + { "AIX iptrace 1.0", + NULL, NULL }, + + /* WTAP_FILE_IPTRACE_2_0 */ + { "AIX iptrace 2.0", + NULL, NULL }, + + /* WTAP_FILE_NETMON_1_x */ + { "Microsoft Network Monitor 1.x", + netmon_dump_can_dump_encap, netmon_dump_open }, + + /* WTAP_FILE_NETMON_2_x */ + { "Microsoft Network Monitor 2.x", + NULL, NULL }, + + /* WTAP_FILE_NETXRAY_1_0 */ + { "Cinco Networks NetXRay", + NULL, NULL }, + + /* WTAP_FILE_NETXRAY_1_1 */ + { "Network Associates Sniffer (Windows-based) 1.1", + NULL, NULL }, + + /* WTAP_FILE_NETXRAY_2_001 */ + { "Network Associates Sniffer (Windows-based) 2.001", + NULL, NULL }, + + /* WTAP_FILE_RADCOM */ + { "RADCOM WAN/LAN analyzer", + NULL, NULL }, + + /* WTAP_FILE_ASCEND */ + { "Lucent/Ascend access server trace", + NULL, NULL }, + + /* WTAP_FILE_NETTL */ + { "HP-UX nettl trace", + NULL, NULL }, + + /* WTAP_FILE_TOSHIBA */ + { "Toshiba Compact ISDN Router snoop trace", + NULL, NULL } +}; + +const char *wtap_file_type_string(wtap *wth) +{ + if (wth->file_type < 0 || wth->file_type >= WTAP_NUM_ENCAP_TYPES) { + g_error("Unknown capture file type %d", wth->file_type); + return NULL; + } else + return dump_open_table[wth->file_type].name; +} + +gboolean wtap_can_open(int filetype) +{ + if (filetype < 0 || filetype >= WTAP_NUM_ENCAP_TYPES + || dump_open_table[filetype].dump_open == NULL) + return FALSE; + + return TRUE; +} + +gboolean wtap_can_dump_encap(int filetype, int encap) +{ + if (filetype < 0 || filetype >= WTAP_NUM_ENCAP_TYPES + || dump_open_table[filetype].can_dump_encap == NULL) + return FALSE; + + if ((*dump_open_table[filetype].can_dump_encap)(filetype, encap) != 0) + return FALSE; + + return TRUE; +} static wtap_dumper* wtap_dump_open_common(FILE *fh, int filetype, int encap, int snaplen, int *err); @@ -207,22 +315,33 @@ wtap_dumper* wtap_dump_fdopen(int fd, int filetype, int encap, int snaplen, return wtap_dump_open_common(fh, filetype, encap, snaplen, err); } -const static struct dump_type { - guint type; - int (*dump_open)(wtap_dumper *, int *); -} dump_open_table[] = { - { WTAP_FILE_PCAP, libpcap_dump_open }, - { WTAP_FILE_SNOOP, snoop_dump_open }, - { WTAP_FILE_NETMON_1_x, netmon_dump_open }, - { 0, NULL } -}; - static wtap_dumper* wtap_dump_open_common(FILE *fh, int filetype, int encap, int snaplen, int *err) { wtap_dumper *wdh; - const struct dump_type *dtp; + if (filetype < 0 || filetype >= WTAP_NUM_ENCAP_TYPES + || dump_open_table[filetype].dump_open == NULL) { + /* Invalid type, or type we don't know how to write. */ + *err = WTAP_ERR_UNSUPPORTED_FILE_TYPE; + /* NOTE: this means the FD handed to "wtap_dump_fdopen()" + will be closed if we can't write that file type. */ + fclose(fh); + return NULL; + } + + /* OK, we know how to write that type; can we write the specified + encapsulation type? */ + *err = (*dump_open_table[filetype].can_dump_encap)(filetype, encap); + if (*err != 0) { + /* NOTE: this means the FD handed to "wtap_dump_fdopen()" + will be closed if we can't write that encapsulation type. */ + fclose(fh); + return NULL; + } + + /* OK, we can write the specified encapsulation type. Allocate + a data structure for the output stream. */ wdh = g_malloc(sizeof (wtap_dumper)); if (wdh == NULL) { *err = errno; @@ -235,24 +354,21 @@ static wtap_dumper* wtap_dump_open_common(FILE *fh, int filetype, int encap, wdh->file_type = filetype; wdh->snaplen = snaplen; wdh->encap = encap; - wdh->private.opaque = NULL; - for (dtp = &dump_open_table[0]; dtp->dump_open != NULL; dtp++) { - if (filetype == dtp->type) { - if (!(*dtp->dump_open)(wdh, err)) { - /* The attempt failed. */ - g_free(wdh); - fclose(fh); - return NULL; - } - return wdh; /* success! */ - } + wdh->subtype_write = NULL; + wdh->subtype_close = NULL; + + /* Now try to open the file for writing. */ + if (!(*dump_open_table[filetype].dump_open)(wdh, err)) { + /* The attempt failed. */ + g_free(wdh); + /* NOTE: this means the FD handed to "wtap_dump_fdopen()" + will be closed if the open fails. */ + fclose(fh); + return NULL; } - *err = WTAP_ERR_UNSUPPORTED_FILE_TYPE; - g_free(wdh); - fclose(fh); - return NULL; + return wdh; /* success! */ } FILE* wtap_dump_file(wtap_dumper *wdh) @@ -270,8 +386,11 @@ gboolean wtap_dump_close(wtap_dumper *wdh, int *err) { gboolean ret = TRUE; - if (!(wdh->subtype_close)(wdh, err)) - ret = FALSE; + if (wdh->subtype_close != NULL) { + /* There's a close routine for this dump stream. */ + if (!(wdh->subtype_close)(wdh, err)) + ret = FALSE; + } errno = WTAP_ERR_CANT_CLOSE; if (fclose(wdh->fh) == EOF) { if (ret) { diff --git a/wiretap/libpcap.c b/wiretap/libpcap.c index 550b43ddc1..85ee54d29d 100644 --- a/wiretap/libpcap.c +++ b/wiretap/libpcap.c @@ -1,6 +1,6 @@ /* libpcap.c * - * $Id: libpcap.c,v 1.24 1999/12/04 05:14:38 guy Exp $ + * $Id: libpcap.c,v 1.25 1999/12/04 08:32:13 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez @@ -100,7 +100,6 @@ static int libpcap_read(wtap *wth, int *err); static void adjust_header(wtap *wth, struct pcaprec_hdr *hdr); static gboolean libpcap_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, const u_char *pd, int *err); -static gboolean libpcap_dump_close(wtap_dumper *wdh, int *err); /* * XXX - this is a bit of a mess. OpenBSD, and perhaps NetBSD, and @@ -460,46 +459,49 @@ int wtap_pcap_encap_to_wtap_encap(int encap) return pcap_encap[encap]; } +static const int wtap_encap[] = { + -1, /* WTAP_ENCAP_UNKNOWN -> unsupported */ + 1, /* WTAP_ENCAP_ETHERNET -> DLT_EN10MB */ + 6, /* WTAP_ENCAP_TR -> DLT_IEEE802 */ + 8, /* WTAP_ENCAP_SLIP -> DLT_SLIP */ + 9, /* WTAP_ENCAP_PPP -> DLT_PPP */ + 10, /* WTAP_ENCAP_FDDI -> DLT_FDDI */ + 10, /* WTAP_ENCAP_FDDI_BITSWAPPED -> DLT_FDDI */ + 12, /* WTAP_ENCAP_RAW_IP -> DLT_RAW */ + 7, /* WTAP_ENCAP_ARCNET -> DLT_ARCNET */ + 11, /* WTAP_ENCAP_ATM_RFC1483 -> DLT_ATM_RFC1483 */ + 19, /* WTAP_ENCAP_LINUX_ATM_CLIP */ + -1, /* WTAP_ENCAP_LAPB -> unsupported*/ + -1, /* WTAP_ENCAP_ATM_SNIFFER -> unsupported */ + 0 /* WTAP_ENCAP_NULL -> DLT_NULL */ +}; +#define NUM_WTAP_ENCAPS (sizeof wtap_encap / sizeof wtap_encap[0]) + +/* Returns 0 if we could write the specified encapsulation type, + an error indication otherwise. */ +int libpcap_dump_can_dump_encap(int filetype, int encap) +{ + /* Per-packet encapsulations aren't supported. */ + if (encap == WTAP_ENCAP_PER_PACKET) + return WTAP_ERR_ENCAP_PER_PACKET_UNSUPPORTED; + + if (encap < 0 || encap >= NUM_WTAP_ENCAPS || wtap_encap[encap] == -1) + return WTAP_ERR_UNSUPPORTED_ENCAP; + + return 0; +} + /* Returns TRUE on success, FALSE on failure; sets "*err" to an error code on failure */ gboolean libpcap_dump_open(wtap_dumper *wdh, int *err) { static const guint32 pcap_magic = PCAP_MAGIC; struct pcap_hdr file_hdr; - static const int wtap_encap[] = { - -1, /* WTAP_ENCAP_UNKNOWN -> unsupported */ - 1, /* WTAP_ENCAP_ETHERNET -> DLT_EN10MB */ - 6, /* WTAP_ENCAP_TR -> DLT_IEEE802 */ - 8, /* WTAP_ENCAP_SLIP -> DLT_SLIP */ - 9, /* WTAP_ENCAP_PPP -> DLT_PPP */ - 10, /* WTAP_ENCAP_FDDI -> DLT_FDDI */ - 10, /* WTAP_ENCAP_FDDI_BITSWAPPED -> DLT_FDDI */ - 12, /* WTAP_ENCAP_RAW_IP -> DLT_RAW */ - 7, /* WTAP_ENCAP_ARCNET -> DLT_ARCNET */ - 11, /* WTAP_ENCAP_ATM_RFC1483 -> DLT_ATM_RFC1483 */ - 19, /* WTAP_ENCAP_LINUX_ATM_CLIP */ - -1, /* WTAP_ENCAP_LAPB -> unsupported*/ - -1, /* WTAP_ENCAP_ATM_SNIFFER -> unsupported */ - 0 /* WTAP_ENCAP_NULL -> DLT_NULL */ - }; - #define NUM_WTAP_ENCAPS (sizeof wtap_encap / sizeof wtap_encap[0]) int nwritten; - /* Per-packet encapsulations aren't supported. */ - if (wdh->encap == WTAP_ENCAP_PER_PACKET) { - *err = WTAP_ERR_ENCAP_PER_PACKET_UNSUPPORTED; - return FALSE; - } - - if (wdh->encap < 0 || wdh->encap >= NUM_WTAP_ENCAPS - || wtap_encap[wdh->encap] == -1) { - *err = WTAP_ERR_UNSUPPORTED_ENCAP; - return FALSE; - } - /* This is a libpcap file */ wdh->subtype_write = libpcap_dump; - wdh->subtype_close = libpcap_dump_close; + wdh->subtype_close = NULL; /* Write the file header. */ nwritten = fwrite(&pcap_magic, 1, sizeof pcap_magic, wdh->fh); @@ -560,11 +562,3 @@ static gboolean libpcap_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, } return TRUE; } - -/* Finish writing to a dump file. - Returns TRUE on success, FALSE on failure. */ -static gboolean libpcap_dump_close(wtap_dumper *wdh, int *err) -{ - /* Nothing to do here. */ - return TRUE; -} diff --git a/wiretap/libpcap.h b/wiretap/libpcap.h index cf0ead2a27..7cc0cfbda0 100644 --- a/wiretap/libpcap.h +++ b/wiretap/libpcap.h @@ -1,6 +1,6 @@ /* libpcap.h * - * $Id: libpcap.h,v 1.4 1999/12/04 05:14:39 guy Exp $ + * $Id: libpcap.h,v 1.5 1999/12/04 08:32:13 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez @@ -23,3 +23,4 @@ int libpcap_open(wtap *wth, int *err); gboolean libpcap_dump_open(wtap_dumper *wdh, int *err); +int libpcap_dump_can_dump_encap(int filetype, int encap); diff --git a/wiretap/netmon.c b/wiretap/netmon.c index 6e1db29a96..0921e24a43 100644 --- a/wiretap/netmon.c +++ b/wiretap/netmon.c @@ -1,6 +1,6 @@ /* netmon.c * - * $Id: netmon.c,v 1.19 1999/12/04 06:21:45 guy Exp $ + * $Id: netmon.c,v 1.20 1999/12/04 08:32:12 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez @@ -388,22 +388,24 @@ static const int wtap_encap[] = { }; #define NUM_WTAP_ENCAPS (sizeof wtap_encap / sizeof wtap_encap[0]) +/* Returns 0 if we could write the specified encapsulation type, + an error indication otherwise. */ +int netmon_dump_can_dump_encap(int filetype, int encap) +{ + /* Per-packet encapsulations aren't supported. */ + if (encap == WTAP_ENCAP_PER_PACKET) + return WTAP_ERR_ENCAP_PER_PACKET_UNSUPPORTED; + + if (encap < 0 || encap >= NUM_WTAP_ENCAPS || wtap_encap[encap] == -1) + return WTAP_ERR_UNSUPPORTED_ENCAP; + + return 0; +} + /* Returns TRUE on success, FALSE on failure; sets "*err" to an error code on failure */ gboolean netmon_dump_open(wtap_dumper *wdh, int *err) { - /* Per-packet encapsulations aren't supported. */ - if (wdh->encap == WTAP_ENCAP_PER_PACKET) { - *err = WTAP_ERR_ENCAP_PER_PACKET_UNSUPPORTED; - return FALSE; - } - - if (wdh->encap < 0 || wdh->encap >= NUM_WTAP_ENCAPS - || wtap_encap[wdh->encap] == -1) { - *err = WTAP_ERR_UNSUPPORTED_ENCAP; - return FALSE; - } - /* This is a netmon file */ wdh->subtype_write = netmon_dump; wdh->subtype_close = netmon_dump_close; diff --git a/wiretap/netmon.h b/wiretap/netmon.h index 468d6775ad..0efd7abe7d 100644 --- a/wiretap/netmon.h +++ b/wiretap/netmon.h @@ -1,6 +1,6 @@ /* netmon.h * - * $Id: netmon.h,v 1.3 1999/12/04 05:14:39 guy Exp $ + * $Id: netmon.h,v 1.4 1999/12/04 08:32:12 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez @@ -23,3 +23,4 @@ int netmon_open(wtap *wth, int *err); gboolean netmon_dump_open(wtap_dumper *wdh, int *err); +int netmon_dump_can_dump_encap(int filetype, int encap); diff --git a/wiretap/snoop.c b/wiretap/snoop.c index 0a36c3a8a3..b7fea213a6 100644 --- a/wiretap/snoop.c +++ b/wiretap/snoop.c @@ -1,6 +1,6 @@ /* snoop.c * - * $Id: snoop.c,v 1.19 1999/12/04 05:14:39 guy Exp $ + * $Id: snoop.c,v 1.20 1999/12/04 08:32:12 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez @@ -58,7 +58,6 @@ struct snooprec_hdr { static int snoop_read(wtap *wth, int *err); static gboolean snoop_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, const u_char *pd, int *err); -static gboolean snoop_dump_close(wtap_dumper *wdh, int *err); /* * See @@ -350,45 +349,48 @@ static int snoop_read(wtap *wth, int *err) return data_offset; } +static const int wtap_encap[] = { + -1, /* WTAP_ENCAP_UNKNOWN -> unsupported */ + 0x04, /* WTAP_ENCAP_ETHERNET -> DL_ETHER */ + 0x02, /* WTAP_ENCAP_TR -> DL_TPR */ + -1, /* WTAP_ENCAP_SLIP -> unsupported */ + -1, /* WTAP_ENCAP_PPP -> unsupported */ + 0x08, /* WTAP_ENCAP_FDDI -> DL_FDDI */ + 0x08, /* WTAP_ENCAP_FDDI_BITSWAPPED -> DL_FDDI */ + -1, /* WTAP_ENCAP_RAW_IP -> unsupported */ + -1, /* WTAP_ENCAP_ARCNET -> unsupported */ + -1, /* WTAP_ENCAP_ATM_RFC1483 -> unsupported */ + -1, /* WTAP_ENCAP_LINUX_ATM_CLIP -> unsupported */ + -1, /* WTAP_ENCAP_LAPB -> unsupported*/ + -1, /* WTAP_ENCAP_ATM_SNIFFER -> unsupported */ + 0 /* WTAP_ENCAP_NULL -> DLT_NULL */ +}; +#define NUM_WTAP_ENCAPS (sizeof wtap_encap / sizeof wtap_encap[0]) + +/* Returns 0 if we could write the specified encapsulation type, + an error indication otherwise. */ +int snoop_dump_can_dump_encap(int filetype, int encap) +{ + /* Per-packet encapsulations aren't supported. */ + if (encap == WTAP_ENCAP_PER_PACKET) + return WTAP_ERR_ENCAP_PER_PACKET_UNSUPPORTED; + + if (encap < 0 || encap >= NUM_WTAP_ENCAPS || wtap_encap[encap] == -1) + return WTAP_ERR_UNSUPPORTED_ENCAP; + + return 0; +} + /* Returns TRUE on success, FALSE on failure; sets "*err" to an error code on failure */ gboolean snoop_dump_open(wtap_dumper *wdh, int *err) { struct snoop_hdr file_hdr; - static const int wtap_encap[] = { - -1, /* WTAP_ENCAP_UNKNOWN -> unsupported */ - 0x04, /* WTAP_ENCAP_ETHERNET -> DL_ETHER */ - 0x02, /* WTAP_ENCAP_TR -> DL_TPR */ - -1, /* WTAP_ENCAP_SLIP -> unsupported */ - -1, /* WTAP_ENCAP_PPP -> unsupported */ - 0x08, /* WTAP_ENCAP_FDDI -> DL_FDDI */ - 0x08, /* WTAP_ENCAP_FDDI_BITSWAPPED -> DL_FDDI */ - -1, /* WTAP_ENCAP_RAW_IP -> unsupported */ - -1, /* WTAP_ENCAP_ARCNET -> unsupported */ - -1, /* WTAP_ENCAP_ATM_RFC1483 -> unsupported */ - -1, /* WTAP_ENCAP_LINUX_ATM_CLIP -> unsupported */ - -1, /* WTAP_ENCAP_LAPB -> unsupported*/ - -1, /* WTAP_ENCAP_ATM_SNIFFER -> unsupported */ - 0 /* WTAP_ENCAP_NULL -> DLT_NULL */ - }; - #define NUM_WTAP_ENCAPS (sizeof wtap_encap / sizeof wtap_encap[0]) int nwritten; - /* Per-packet encapsulations aren't supported. */ - if (wdh->encap == WTAP_ENCAP_PER_PACKET) { - *err = WTAP_ERR_ENCAP_PER_PACKET_UNSUPPORTED; - return FALSE; - } - - if (wdh->encap < 0 || wdh->encap >= NUM_WTAP_ENCAPS - || wtap_encap[wdh->encap] == -1) { - *err = WTAP_ERR_UNSUPPORTED_ENCAP; - return FALSE; - } - /* This is a snoop file */ wdh->subtype_write = snoop_dump; - wdh->subtype_close = snoop_dump_close; + wdh->subtype_close = NULL; /* Write the file header. */ nwritten = fwrite(&snoop_magic, 1, sizeof snoop_magic, wdh->fh); @@ -467,11 +469,3 @@ static gboolean snoop_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, } return TRUE; } - -/* Finish writing to a dump file. - Returns TRUE on success, FALSE on failure. */ -static gboolean snoop_dump_close(wtap_dumper *wdh, int *err) -{ - /* Nothing to do here. */ - return TRUE; -} diff --git a/wiretap/snoop.h b/wiretap/snoop.h index a740d1b62c..4e104da02f 100644 --- a/wiretap/snoop.h +++ b/wiretap/snoop.h @@ -1,6 +1,6 @@ /* snoop.h * - * $Id: snoop.h,v 1.4 1999/12/04 05:14:39 guy Exp $ + * $Id: snoop.h,v 1.5 1999/12/04 08:32:13 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez @@ -23,3 +23,4 @@ int snoop_open(wtap *wth, int *err); gboolean snoop_dump_open(wtap_dumper *wdh, int *err); +int snoop_dump_can_dump_encap(int filetype, int encap); diff --git a/wiretap/wtap.c b/wiretap/wtap.c index c141bb9693..85afa247d4 100644 --- a/wiretap/wtap.c +++ b/wiretap/wtap.c @@ -1,6 +1,6 @@ /* wtap.c * - * $Id: wtap.c,v 1.31 1999/11/26 17:57:14 gram Exp $ + * $Id: wtap.c,v 1.32 1999/12/04 08:32:13 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez @@ -57,66 +57,6 @@ int wtap_file_encap(wtap *wth) return wth->file_encap; } -const char *wtap_file_type_string(wtap *wth) -{ - switch (wth->file_type) { - case WTAP_FILE_WTAP: - return "wiretap"; - - case WTAP_FILE_PCAP: - return "pcap"; - - case WTAP_FILE_PCAP_MODIFIED: - return "pcap-modified"; - - case WTAP_FILE_LANALYZER: - return "Novell LANalyzer"; - - case WTAP_FILE_NGSNIFFER: - return "Network Associates Sniffer (DOS-based)"; - - case WTAP_FILE_SNOOP: - return "snoop"; - - case WTAP_FILE_IPTRACE_1_0: - return "AIX iptrace 1.0"; - - case WTAP_FILE_IPTRACE_2_0: - return "AIX iptrace 2.0"; - - case WTAP_FILE_NETMON_1_x: - return "Microsoft Network Monitor 1.x"; - - case WTAP_FILE_NETMON_2_x: - return "Microsoft Network Monitor 2.x"; - - case WTAP_FILE_NETXRAY_1_0: - return "Cinco Networks NetXRay"; - - case WTAP_FILE_NETXRAY_1_1: - return "Network Associates Sniffer (Windows-based) 1.1"; - - case WTAP_FILE_NETXRAY_2_001: - return "Network Associates Sniffer (Windows-based) 2.001"; - - case WTAP_FILE_RADCOM: - return "RADCOM WAN/LAN analyzer"; - - case WTAP_FILE_ASCEND: - return "Lucent/Ascend access server trace"; - - case WTAP_FILE_NETTL: - return "HP-UX nettl trace"; - - case WTAP_FILE_TOSHIBA: - return "Toshiba Compact ISDN Router snoop trace"; - - default: - g_error("Unknown capture file type %d", wth->file_type); - return NULL; - } -} - static const char *wtap_errlist[] = { "The file isn't a plain file", "The file isn't a capture file in a known format", diff --git a/wiretap/wtap.h b/wiretap/wtap.h index 721f2701bd..58883ab1b3 100644 --- a/wiretap/wtap.h +++ b/wiretap/wtap.h @@ -1,6 +1,6 @@ /* wtap.h * - * $Id: wtap.h,v 1.51 1999/12/04 05:22:21 guy Exp $ + * $Id: wtap.h,v 1.52 1999/12/04 08:32:14 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez @@ -118,6 +118,9 @@ #define WTAP_FILE_NETTL 16 #define WTAP_FILE_TOSHIBA 17 +/* last WTAP_FILE_ value + 1 */ +#define WTAP_NUM_FILE_TYPES 18 + /* * Maximum packet size we'll support. */ @@ -385,6 +388,8 @@ void wtap_close(wtap *wth); int wtap_seek_read (int file_type, FILE *fh, int seek_off, guint8 *pd, int len); int wtap_def_seek_read (FILE *fh, int seek_off, guint8 *pd, int len); +gboolean wtap_dump_can_open(int filetype); +gboolean wtap_dump_can_write_encap(int filetype, int encap); wtap_dumper* wtap_dump_open(const char *filename, int filetype, int encap, int snaplen, int *err); wtap_dumper* wtap_dump_fdopen(int fd, int filetype, int encap, int snaplen,