Use WTAP_ERR_UNSUPPORTED_ENCAP for all attempts to open or read a

capture file for an unsupported link-layer encapsulation type (as the
nettl reader does), and report it correctly if it occurs on an open or
read attempt rather than a save attempt.

svn path=/trunk/; revision=1647
This commit is contained in:
Guy Harris 2000-02-19 08:00:08 +00:00
parent 1b401fa9e1
commit 585268e3e1
10 changed files with 36 additions and 23 deletions

12
file.c
View File

@ -1,7 +1,7 @@
/* file.c
* File I/O routines
*
* $Id: file.c,v 1.164 2000/02/18 13:41:24 oabad Exp $
* $Id: file.c,v 1.165 2000/02/19 07:59:53 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -342,6 +342,10 @@ read_cap_file(capture_file *cf)
if any. */
switch (err) {
case WTAP_ERR_UNSUPPORTED_ENCAP:
errmsg = "The capture file is for a network type that Ethereal doesn't support.";
break;
case WTAP_ERR_CANT_READ:
errmsg = "An attempt to read from the file failed for"
" some unknown reason.";
@ -1525,8 +1529,10 @@ file_open_error_message(int err, int for_writing)
case WTAP_ERR_UNSUPPORTED_ENCAP:
case WTAP_ERR_ENCAP_PER_PACKET_UNSUPPORTED:
/* Seen only when opening a capture file for writing. */
errmsg = "Ethereal cannot save this capture in that format.";
if (for_writing)
errmsg = "Ethereal cannot save this capture in that format.";
else
errmsg = "The file \"%s\" is a capture for a network type that Ethereal doesn't support.";
break;
case WTAP_ERR_BAD_RECORD:

View File

@ -1,6 +1,6 @@
/* tethereal.c
*
* $Id: tethereal.c,v 1.18 2000/02/16 01:38:56 gram Exp $
* $Id: tethereal.c,v 1.19 2000/02/19 07:59:54 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -690,6 +690,11 @@ load_cap_file(capture_file *cf, int out_file_type)
the line. */
switch (err) {
case WTAP_ERR_UNSUPPORTED_ENCAP:
fprintf(stderr,
"tethereal: The capture file is for a network type that Tethereal doesn't support.\n");
break;
case WTAP_ERR_CANT_READ:
fprintf(stderr,
"tethereal: An attempt to read from the file failed for some unknown reason.\n");
@ -913,8 +918,10 @@ file_open_error_message(int err, int for_writing)
case WTAP_ERR_UNSUPPORTED_ENCAP:
case WTAP_ERR_ENCAP_PER_PACKET_UNSUPPORTED:
/* Seen only when opening a capture file for writing. */
errmsg = "Tethereal cannot save this capture in that format.";
if (for_writing)
errmsg = "Tethereal cannot save this capture in that format.";
else
errmsg = "The file \"%s\" is a capture for a network type that Tethereal doesn't support.";
break;
case WTAP_ERR_BAD_RECORD:

View File

@ -1,6 +1,6 @@
/* iptrace.c
*
* $Id: iptrace.c,v 1.24 2000/01/22 06:22:37 guy Exp $
* $Id: iptrace.c,v 1.25 2000/02/19 08:00:06 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@xiexie.org>
@ -147,7 +147,7 @@ static int iptrace_read_1_0(wtap *wth, int *err)
if (wth->phdr.pkt_encap == WTAP_ENCAP_UNKNOWN) {
g_message("iptrace: interface type IFT=0x%02x unknown or unsupported",
pkt_hdr.if_type);
*err = WTAP_ERR_UNSUPPORTED;
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
return -1;
}
@ -251,7 +251,7 @@ static int iptrace_read_2_0(wtap *wth, int *err)
if (wth->phdr.pkt_encap == WTAP_ENCAP_UNKNOWN) {
g_message("iptrace: interface type IFT=0x%02x unknown or unsupported",
pkt_hdr.if_type);
*err = WTAP_ERR_UNSUPPORTED;
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
return -1;
}

View File

@ -1,6 +1,6 @@
/* libpcap.c
*
* $Id: libpcap.c,v 1.31 2000/01/22 06:22:39 guy Exp $
* $Id: libpcap.c,v 1.32 2000/02/19 08:00:06 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@xiexie.org>
@ -247,7 +247,7 @@ int libpcap_open(wtap *wth, int *err)
|| pcap_encap[hdr.network] == WTAP_ENCAP_UNKNOWN) {
g_message("pcap: network type %u unknown or unsupported",
hdr.network);
*err = WTAP_ERR_UNSUPPORTED;
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
return -1;
}

View File

@ -1,6 +1,6 @@
/* netmon.c
*
* $Id: netmon.c,v 1.24 2000/01/22 06:22:40 guy Exp $
* $Id: netmon.c,v 1.25 2000/02/19 08:00:05 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@xiexie.org>
@ -172,7 +172,7 @@ int netmon_open(wtap *wth, int *err)
|| netmon_encap[hdr.network] == WTAP_ENCAP_UNKNOWN) {
g_message("netmon: network type %u unknown or unsupported",
hdr.network);
*err = WTAP_ERR_UNSUPPORTED;
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
return -1;
}

View File

@ -1,6 +1,6 @@
/* netxray.c
*
* $Id: netxray.c,v 1.23 2000/01/29 05:10:06 gram Exp $
* $Id: netxray.c,v 1.24 2000/02/19 08:00:04 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@xiexie.org>
@ -178,7 +178,7 @@ int netxray_open(wtap *wth, int *err)
|| netxray_encap[hdr.network] == WTAP_ENCAP_UNKNOWN) {
g_message("netxray: network type %u unknown or unsupported",
hdr.network);
*err = WTAP_ERR_UNSUPPORTED;
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
return -1;
}

View File

@ -1,6 +1,6 @@
/* ngsniffer.c
*
* $Id: ngsniffer.c,v 1.35 2000/01/22 06:22:41 guy Exp $
* $Id: ngsniffer.c,v 1.36 2000/02/19 08:00:07 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@xiexie.org>
@ -355,7 +355,7 @@ int ngsniffer_open(wtap *wth, int *err)
&& version.network != 7)) {
g_message("ngsniffer: network type %u unknown or unsupported",
version.network);
*err = WTAP_ERR_UNSUPPORTED;
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
return -1;
}

View File

@ -1,6 +1,6 @@
/* radcom.c
*
* $Id: radcom.c,v 1.17 2000/01/22 06:22:43 guy Exp $
* $Id: radcom.c,v 1.18 2000/02/19 08:00:04 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@xiexie.org>
@ -180,7 +180,7 @@ int radcom_open(wtap *wth, int *err)
wth->file_encap = WTAP_ENCAP_ETHERNET;
else {
g_message("pcap: network type \"%.4s\" unknown", search_encap);
*err = WTAP_ERR_UNSUPPORTED;
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
return -1;
}

View File

@ -1,6 +1,6 @@
/* snoop.c
*
* $Id: snoop.c,v 1.24 2000/01/22 06:22:43 guy Exp $
* $Id: snoop.c,v 1.25 2000/02/19 08:00:04 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@xiexie.org>
@ -187,7 +187,7 @@ int snoop_open(wtap *wth, int *err)
|| snoop_encap[hdr.network] == WTAP_ENCAP_UNKNOWN) {
g_message("snoop: network type %u unknown or unsupported",
hdr.network);
*err = WTAP_ERR_UNSUPPORTED;
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
return -1;
}

View File

@ -1,6 +1,6 @@
/* wtap.h
*
* $Id: wtap.h,v 1.63 2000/01/22 06:22:44 guy Exp $
* $Id: wtap.h,v 1.64 2000/02/19 08:00:08 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@xiexie.org>
@ -450,7 +450,7 @@ int wtap_pcap_encap_to_wtap_encap(int encap);
#define WTAP_ERR_UNSUPPORTED_FILE_TYPE -5
/* Wiretap can't save files in the specified format */
#define WTAP_ERR_UNSUPPORTED_ENCAP -6
/* Wiretap can't save files in the specified format with the
/* Wiretap can't read or save files in the specified format with the
specified encapsulation */
#define WTAP_ERR_ENCAP_PER_PACKET_UNSUPPORTED -7
/* The specified format doesn't support per-packet encapsulations */