aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2014-10-09 16:44:15 -0700
committerGuy Harris <guy@alum.mit.edu>2014-10-09 23:45:30 +0000
commit45e462985db891248ffcb9db21e6b66733de0b84 (patch)
tree90d031f9769c07abaea83330a58dd9d3933eb7b1
parent112c90a04b778958985b02b9663743cea1039f47 (diff)
Use an enum for the open-routine return value, as per Evan Huus's suggestion.
Clean up some things we ran across while making those changes. Change-Id: Ic0d8943d36e6e120d7af0a6148fad98015d1e83e Reviewed-on: https://code.wireshark.org/review/4581 Reviewed-by: Guy Harris <guy@alum.mit.edu>
-rw-r--r--epan/wslua/wslua_file.c12
-rw-r--r--wiretap/5views.c19
-rw-r--r--wiretap/aethra.c12
-rw-r--r--wiretap/ascendtext.c12
-rw-r--r--wiretap/ber.c14
-rw-r--r--wiretap/btsnoop.c22
-rw-r--r--wiretap/camins.c10
-rw-r--r--wiretap/catapult_dct2000.c18
-rw-r--r--wiretap/commview.c12
-rw-r--r--wiretap/cosine.c10
-rw-r--r--wiretap/csids.c25
-rw-r--r--wiretap/daintree-sna.c23
-rw-r--r--wiretap/dbs-etherwatch.c8
-rw-r--r--wiretap/dct3trace.c10
-rw-r--r--wiretap/erf.c42
-rw-r--r--wiretap/eyesdn.c10
-rw-r--r--wiretap/file_access.c58
-rw-r--r--wiretap/hcidump.c18
-rw-r--r--wiretap/i4btrace.c12
-rw-r--r--wiretap/ipfix.c47
-rw-r--r--wiretap/iptrace.c10
-rw-r--r--wiretap/iseries.c28
-rw-r--r--wiretap/k12.c34
-rw-r--r--wiretap/k12text.l8
-rw-r--r--wiretap/lanalyzer.c32
-rw-r--r--wiretap/libpcap.c24
-rw-r--r--wiretap/logcat.c24
-rw-r--r--wiretap/logcat_text.c10
-rw-r--r--wiretap/mime_file.c14
-rw-r--r--wiretap/mp2t.c27
-rw-r--r--wiretap/mpeg.c12
-rw-r--r--wiretap/netmon.c26
-rw-r--r--wiretap/netscaler.c19
-rw-r--r--wiretap/netscreen.c10
-rw-r--r--wiretap/nettl.c18
-rw-r--r--wiretap/network_instruments.c30
-rw-r--r--wiretap/netxray.c38
-rw-r--r--wiretap/ngsniffer.c26
-rw-r--r--wiretap/packetlogger.c16
-rw-r--r--wiretap/pcapng.c16
-rw-r--r--wiretap/peekclassic.c22
-rw-r--r--wiretap/peektagged.c36
-rw-r--r--wiretap/pppdump.c12
-rw-r--r--wiretap/radcom.c55
-rw-r--r--wiretap/snoop.c24
-rw-r--r--wiretap/stanag4607.c10
-rw-r--r--wiretap/tnef.c8
-rw-r--r--wiretap/toshiba.c8
-rw-r--r--wiretap/visual.c16
-rw-r--r--wiretap/vms.c8
-rw-r--r--wiretap/vwr.c8
-rw-r--r--wiretap/wtap.h27
52 files changed, 521 insertions, 529 deletions
diff --git a/epan/wslua/wslua_file.c b/epan/wslua/wslua_file.c
index b2c466cab4..9f6cf2297c 100644
--- a/epan/wslua/wslua_file.c
+++ b/epan/wslua/wslua_file.c
@@ -1652,11 +1652,11 @@ wslua_filehandler_sequential_close(wtap *wth);
* If the routine handles this type of file, it should set the "file_type"
* field in the "struct wtap" to the type of the file.
*/
-static int
+static wtap_open_return_val
wslua_filehandler_open(wtap *wth, int *err, gchar **err_info)
{
FileHandler fh = (FileHandler)(wth->wslua_data);
- int retval = 0;
+ wtap_open_return_val retval = WTAP_OPEN_NOT_MINE;
lua_State* L = NULL;
File *fp = NULL;
CaptureInfo *fc = NULL;
@@ -1681,7 +1681,7 @@ wslua_filehandler_open(wtap *wth, int *err, gchar **err_info)
(*fp)->expired = TRUE;
(*fc)->expired = TRUE;
- if (retval == 1) {
+ if (retval == WTAP_OPEN_MINE) {
/* this is our file type - set the routines and settings into wtap */
if (fh->read_ref != LUA_NOREF) {
@@ -1708,13 +1708,13 @@ wslua_filehandler_open(wtap *wth, int *err, gchar **err_info)
wth->file_type_subtype = fh->file_type;
}
- else if (retval == -1) {
+ else if (retval == WTAP_OPEN_ERROR) {
/* open error - we *must* return an error code! */
if (err) {
*err = WTAP_ERR_CANT_OPEN;
}
}
- else if (retval == 0) {
+ else if (retval == WTAP_OPEN_NOT_MINE) {
/* not our file type */
remove_wth_priv(L, wth);
}
@@ -1724,7 +1724,7 @@ wslua_filehandler_open(wtap *wth, int *err, gchar **err_info)
if (err) {
*err = WTAP_ERR_INTERNAL;
}
- retval = -1;
+ retval = WTAP_OPEN_ERROR;
}
lua_settop(L,0);
diff --git a/wiretap/5views.c b/wiretap/5views.c
index 6e128d4f0e..114e1562fc 100644
--- a/wiretap/5views.c
+++ b/wiretap/5views.c
@@ -110,7 +110,8 @@ static gboolean _5views_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, c
static gboolean _5views_dump_close(wtap_dumper *wdh, int *err);
-int _5views_open(wtap *wth, int *err, gchar **err_info)
+wtap_open_return_val
+_5views_open(wtap *wth, int *err, gchar **err_info)
{
t_5VW_Capture_Header Capture_Header;
int encap = WTAP_ENCAP_UNKNOWN;
@@ -118,14 +119,14 @@ int _5views_open(wtap *wth, int *err, gchar **err_info)
if (!wtap_read_bytes(wth->fh, &Capture_Header.Info_Header,
sizeof(t_5VW_Info_Header), err, err_info)) {
if (*err != WTAP_ERR_SHORT_READ)
- return -1;
- return 0;
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
}
/* Check whether that's 5Views format or not */
if(Capture_Header.Info_Header.Signature != CST_5VW_INFO_HEADER_KEY)
{
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
/* Check Version */
@@ -139,7 +140,7 @@ int _5views_open(wtap *wth, int *err, gchar **err_info)
default:
*err = WTAP_ERR_UNSUPPORTED;
*err_info = g_strdup_printf("5views: header version %u unsupported", Capture_Header.Info_Header.Version);
- return -1;
+ return WTAP_OPEN_ERROR;
}
/* Check File Type */
@@ -149,7 +150,7 @@ int _5views_open(wtap *wth, int *err, gchar **err_info)
{
*err = WTAP_ERR_UNSUPPORTED;
*err_info = g_strdup_printf("5views: file is not a capture file (filetype is %u)", Capture_Header.Info_Header.Version);
- return -1;
+ return WTAP_OPEN_ERROR;
}
/* Check possible Encap */
@@ -164,13 +165,13 @@ int _5views_open(wtap *wth, int *err, gchar **err_info)
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
*err_info = g_strdup_printf("5views: network type %u unknown or unsupported",
Capture_Header.Info_Header.FileType);
- return -1;
+ return WTAP_OPEN_ERROR;
}
/* read the remaining header information */
if (!wtap_read_bytes(wth->fh, &Capture_Header.HeaderDateCreation,
sizeof (t_5VW_Capture_Header) - sizeof(t_5VW_Info_Header), err, err_info))
- return -1;
+ return WTAP_OPEN_ERROR;
/* This is a 5views capture file */
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_5VIEWS;
@@ -180,7 +181,7 @@ int _5views_open(wtap *wth, int *err, gchar **err_info)
wth->snapshot_length = 0; /* not available in header */
wth->file_tsprec = WTAP_TSPREC_NSEC;
- return 1;
+ return WTAP_OPEN_MINE;
}
/* Read the next packet */
diff --git a/wiretap/aethra.c b/wiretap/aethra.c
index 331c6fcfdd..09e4b90025 100644
--- a/wiretap/aethra.c
+++ b/wiretap/aethra.c
@@ -119,7 +119,7 @@ static gboolean aethra_seek_read(wtap *wth, gint64 seek_off,
static gboolean aethra_read_rec_header(wtap *wth, FILE_T fh, struct aethrarec_hdr *hdr,
struct wtap_pkthdr *phdr, int *err, gchar **err_info);
-int aethra_open(wtap *wth, int *err, gchar **err_info)
+wtap_open_return_val aethra_open(wtap *wth, int *err, gchar **err_info)
{
struct aethra_hdr hdr;
struct tm tm;
@@ -129,17 +129,17 @@ int aethra_open(wtap *wth, int *err, gchar **err_info)
if (!wtap_read_bytes(wth->fh, hdr.magic, sizeof hdr.magic, err,
err_info)) {
if (*err != WTAP_ERR_SHORT_READ)
- return -1;
- return 0;
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
}
if (memcmp(hdr.magic, aethra_magic, sizeof aethra_magic) != 0)
- return 0;
+ return WTAP_OPEN_NOT_MINE;
/* Read the rest of the header. */
if (!wtap_read_bytes(wth->fh, (char *)&hdr + sizeof hdr.magic,
sizeof hdr - sizeof hdr.magic, err, err_info))
- return -1;
+ return WTAP_OPEN_ERROR;
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_AETHRA;
aethra = (aethra_t *)g_malloc(sizeof(aethra_t));
wth->priv = (void *)aethra;
@@ -165,7 +165,7 @@ int aethra_open(wtap *wth, int *err, gchar **err_info)
wth->file_encap = WTAP_ENCAP_ISDN;
wth->snapshot_length = 0; /* not available in header */
wth->file_tsprec = WTAP_TSPREC_MSEC;
- return 1;
+ return WTAP_OPEN_MINE;
}
#if 0
diff --git a/wiretap/ascendtext.c b/wiretap/ascendtext.c
index 008afd678f..9bd05f7527 100644
--- a/wiretap/ascendtext.c
+++ b/wiretap/ascendtext.c
@@ -156,7 +156,7 @@ found:
return packet_off;
}
-int ascend_open(wtap *wth, int *err, gchar **err_info)
+wtap_open_return_val ascend_open(wtap *wth, int *err, gchar **err_info)
{
gint64 offset;
ws_statb64 statbuf;
@@ -170,14 +170,14 @@ int ascend_open(wtap *wth, int *err, gchar **err_info)
offset = ascend_seek(wth, err, err_info);
if (offset == -1) {
if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
- return -1;
- return 0;
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
}
/* Do a trial parse of the first packet just found to see if we might really have an Ascend file */
init_parse_ascend();
if (!check_ascend(wth->fh, &wth->phdr)) {
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_ASCEND;
@@ -213,7 +213,7 @@ int ascend_open(wtap *wth, int *err, gchar **err_info)
offset that we can apply to each packet.
*/
if (wtap_fstat(wth, &statbuf, err) == -1) {
- return -1;
+ return WTAP_OPEN_ERROR;
}
ascend->inittime = statbuf.st_ctime;
ascend->adjusted = FALSE;
@@ -221,7 +221,7 @@ int ascend_open(wtap *wth, int *err, gchar **err_info)
init_parse_ascend();
- return 1;
+ return WTAP_OPEN_MINE;
}
/* Read the next packet; called from wtap_read(). */
diff --git a/wiretap/ber.c b/wiretap/ber.c
index bde6234763..74e87d7dbd 100644
--- a/wiretap/ber.c
+++ b/wiretap/ber.c
@@ -103,7 +103,7 @@ static gboolean ber_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *ph
return ber_read_file(wth, wth->random_fh, phdr, buf, err, err_info);
}
-int ber_open(wtap *wth, int *err, gchar **err_info)
+wtap_open_return_val ber_open(wtap *wth, int *err, gchar **err_info)
{
#define BER_BYTES_TO_CHECK 8
guint8 bytes[BER_BYTES_TO_CHECK];
@@ -118,8 +118,8 @@ int ber_open(wtap *wth, int *err, gchar **err_info)
if (!wtap_read_bytes(wth->fh, &bytes, BER_BYTES_TO_CHECK, err, err_info)) {
if (*err != WTAP_ERR_SHORT_READ)
- return -1;
- return 0;
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
}
ber_id = bytes[offset++];
@@ -134,7 +134,7 @@ int ber_open(wtap *wth, int *err, gchar **err_info)
if(!(ber_pc &&
(((ber_class == BER_CLASS_UNI) && ((ber_tag == BER_UNI_TAG_SET) || (ber_tag == BER_UNI_TAG_SEQ))) ||
((ber_class == BER_CLASS_CON) && (ber_tag < 32)))))
- return 0;
+ return WTAP_OPEN_NOT_MINE;
/* now check the length */
oct = bytes[offset++];
@@ -162,7 +162,7 @@ int ber_open(wtap *wth, int *err, gchar **err_info)
file_size = wtap_file_size(wth, err);
if(len != file_size) {
- return 0; /* not ASN.1 */
+ return WTAP_OPEN_NOT_MINE; /* not ASN.1 */
}
} else {
/* Indefinite length encoded - assume it is BER */
@@ -170,7 +170,7 @@ int ber_open(wtap *wth, int *err, gchar **err_info)
/* seek back to the start of the file */
if (file_seek(wth->fh, 0, SEEK_SET, err) == -1)
- return -1;
+ return WTAP_OPEN_ERROR;
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_BER;
wth->file_encap = WTAP_ENCAP_BER;
@@ -180,5 +180,5 @@ int ber_open(wtap *wth, int *err, gchar **err_info)
wth->subtype_seek_read = ber_seek_read;
wth->file_tsprec = WTAP_TSPREC_SEC;
- return 1;
+ return WTAP_OPEN_MINE;
}
diff --git a/wiretap/btsnoop.c b/wiretap/btsnoop.c
index 051589e8f3..2591f78d8e 100644
--- a/wiretap/btsnoop.c
+++ b/wiretap/btsnoop.c
@@ -80,7 +80,7 @@ static gboolean btsnoop_seek_read(wtap *wth, gint64 seek_off,
static gboolean btsnoop_read_record(wtap *wth, FILE_T fh,
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
-int btsnoop_open(wtap *wth, int *err, gchar **err_info)
+wtap_open_return_val btsnoop_open(wtap *wth, int *err, gchar **err_info)
{
char magic[sizeof btsnoop_magic];
struct btsnoop_hdr hdr;
@@ -90,17 +90,17 @@ int btsnoop_open(wtap *wth, int *err, gchar **err_info)
/* Read in the string that should be at the start of a "btsnoop" file */
if (!wtap_read_bytes(wth->fh, magic, sizeof magic, err, err_info)) {
if (*err != WTAP_ERR_SHORT_READ)
- return -1;
- return 0;
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
}
if (memcmp(magic, btsnoop_magic, sizeof btsnoop_magic) != 0) {
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
/* Read the rest of the header. */
if (!wtap_read_bytes(wth->fh, &hdr, sizeof hdr, err, err_info))
- return -1;
+ return WTAP_OPEN_ERROR;
/*
* Make sure it's a version we support.
@@ -109,7 +109,7 @@ int btsnoop_open(wtap *wth, int *err, gchar **err_info)
if (hdr.version != 1) {
*err = WTAP_ERR_UNSUPPORTED;
*err_info = g_strdup_printf("btsnoop: version %u unsupported", hdr.version);
- return -1;
+ return WTAP_OPEN_ERROR;
}
hdr.datalink = g_ntohl(hdr.datalink);
@@ -123,22 +123,22 @@ int btsnoop_open(wtap *wth, int *err, gchar **err_info)
case KHciLoggerDatalinkTypeBCSP:
*err = WTAP_ERR_UNSUPPORTED;
*err_info = g_strdup_printf("btsnoop: BCSP capture logs unsupported");
- return -1;
+ return WTAP_OPEN_ERROR;
case KHciLoggerDatalinkTypeH5:
*err = WTAP_ERR_UNSUPPORTED;
*err_info = g_strdup_printf("btsnoop: H5 capture logs unsupported");
- return -1;
+ return WTAP_OPEN_ERROR;
case KHciLoggerDatalinkLinuxMonitor:
file_encap=WTAP_ENCAP_BLUETOOTH_LINUX_MONITOR;
break;
case KHciLoggerDatalinkBlueZ5Simulator:
*err = WTAP_ERR_UNSUPPORTED;
*err_info = g_strdup_printf("btsnoop: BlueZ 5 Simulator capture logs unsupported");
- return -1;
+ return WTAP_OPEN_ERROR;
default:
*err = WTAP_ERR_UNSUPPORTED;
*err_info = g_strdup_printf("btsnoop: datalink type %u unknown or unsupported", hdr.datalink);
- return -1;
+ return WTAP_OPEN_ERROR;
}
wth->subtype_read = btsnoop_read;
@@ -147,7 +147,7 @@ int btsnoop_open(wtap *wth, int *err, gchar **err_info)
wth->snapshot_length = 0; /* not available in header */
wth->file_tsprec = WTAP_TSPREC_USEC;
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_BTSNOOP;
- return 1;
+ return WTAP_OPEN_MINE;
}
static gboolean btsnoop_read(wtap *wth, int *err, gchar **err_info,
diff --git a/wiretap/camins.c b/wiretap/camins.c
index 82657f2e2b..660bcf4dc3 100644
--- a/wiretap/camins.c
+++ b/wiretap/camins.c
@@ -299,7 +299,7 @@ camins_seek_read(wtap *wth, gint64 seek_off,
-int camins_open(wtap *wth, int *err, gchar **err_info _U_)
+wtap_open_return_val camins_open(wtap *wth, int *err, gchar **err_info _U_)
{
guint8 found_start_blocks = 0;
guint8 count = 0;
@@ -311,7 +311,7 @@ int camins_open(wtap *wth, int *err, gchar **err_info _U_)
if (!wtap_read_bytes(wth->fh, block, sizeof(block), err, err_info)) {
if (*err == WTAP_ERR_SHORT_READ)
break;
- return -1;
+ return WTAP_OPEN_ERROR;
}
if (block[0]==0x00 && block[1] == 0xE1)
@@ -321,11 +321,11 @@ int camins_open(wtap *wth, int *err, gchar **err_info _U_)
} while (count<20);
if (found_start_blocks < 2)
- return 0; /* no CAM Inspector file */
+ return WTAP_OPEN_NOT_MINE; /* no CAM Inspector file */
/* rewind the fh so we re-read from the beginning */
if (-1 == file_seek(wth->fh, 0, SEEK_SET, err))
- return -1;
+ return WTAP_OPEN_ERROR;
wth->file_encap = WTAP_ENCAP_DVBCI;
wth->snapshot_length = 0;
@@ -338,7 +338,7 @@ int camins_open(wtap *wth, int *err, gchar **err_info _U_)
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_CAMINS;
*err = 0;
- return 1;
+ return WTAP_OPEN_MINE;
}
diff --git a/wiretap/catapult_dct2000.c b/wiretap/catapult_dct2000.c
index 2b5ef4e51c..dfeca1de9b 100644
--- a/wiretap/catapult_dct2000.c
+++ b/wiretap/catapult_dct2000.c
@@ -166,7 +166,7 @@ static gboolean free_line_prefix_info(gpointer key, gpointer value, gpointer use
/********************************************/
/* Open file (for reading) */
/********************************************/
-int
+wtap_open_return_val
catapult_dct2000_open(wtap *wth, int *err, gchar **err_info)
{
gint64 offset = 0;
@@ -187,18 +187,18 @@ catapult_dct2000_open(wtap *wth, int *err, gchar **err_info)
if (!read_new_line(wth->fh, &offset, &firstline_length, linebuff,
sizeof linebuff, err, err_info)) {
if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
- return -1;
- return 0;
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
}
if (((size_t)firstline_length < strlen(catapult_dct2000_magic)) ||
firstline_length >= MAX_FIRST_LINE_LENGTH) {
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
/* This file is not for us if it doesn't match our signature */
if (memcmp(catapult_dct2000_magic, linebuff, strlen(catapult_dct2000_magic)) != 0) {
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
/* Make sure table is ready for use */
@@ -227,15 +227,15 @@ catapult_dct2000_open(wtap *wth, int *err, gchar **err_info)
linebuff, sizeof linebuff, err, err_info)) {
g_free(file_externals);
if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
- return -1;
- return 0;
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
}
if ((file_externals->secondline_length >= MAX_TIMESTAMP_LINE_LENGTH) ||
(!get_file_time_stamp(linebuff, &timestamp, &usecs))) {
/* Give up if file time line wasn't valid */
g_free(file_externals);
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
/* Fill in timestamp */
@@ -273,7 +273,7 @@ catapult_dct2000_open(wtap *wth, int *err, gchar **err_info)
wth->priv = (void*)file_externals;
*err = errno;
- return 1;
+ return WTAP_OPEN_MINE;
}
/* Ugly, but much faster than using g_snprintf! */
diff --git a/wiretap/commview.c b/wiretap/commview.c
index 9840041d14..a504a383c4 100644
--- a/wiretap/commview.c
+++ b/wiretap/commview.c
@@ -88,14 +88,14 @@ static gboolean commview_read_header(commview_header_t *cv_hdr, FILE_T fh,
static gboolean commview_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
const guint8 *pd, int *err);
-int commview_open(wtap *wth, int *err, gchar **err_info)
+wtap_open_return_val commview_open(wtap *wth, int *err, gchar **err_info)
{
commview_header_t cv_hdr;
if(!commview_read_header(&cv_hdr, wth->fh, err, err_info)) {
if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
- return -1;
- return 0;
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
}
/* If any of these fields do not match what we expect, bail out. */
@@ -111,11 +111,11 @@ int commview_open(wtap *wth, int *err, gchar **err_info)
((cv_hdr.flags & FLAGS_MEDIUM) != MEDIUM_ETHERNET &&
(cv_hdr.flags & FLAGS_MEDIUM) != MEDIUM_WIFI &&
(cv_hdr.flags & FLAGS_MEDIUM) != MEDIUM_TOKEN_RING))
- return 0; /* Not our kind of file */
+ return WTAP_OPEN_NOT_MINE; /* Not our kind of file */
/* No file header. Reset the fh to 0 so we can read the first packet */
if (file_seek(wth->fh, 0, SEEK_SET, err) == -1)
- return -1;
+ return WTAP_OPEN_ERROR;
/* Set up the pointers to the handlers for this file type */
wth->subtype_read = commview_read;
@@ -125,7 +125,7 @@ int commview_open(wtap *wth, int *err, gchar **err_info)
wth->file_encap = WTAP_ENCAP_PER_PACKET;
wth->file_tsprec = WTAP_TSPREC_USEC;
- return 1; /* Our kind of file */
+ return WTAP_OPEN_MINE; /* Our kind of file */
}
static int
diff --git a/wiretap/cosine.c b/wiretap/cosine.c
index 5d7fff5af0..b7109ff7f9 100644
--- a/wiretap/cosine.c
+++ b/wiretap/cosine.c
@@ -263,17 +263,17 @@ static gboolean cosine_check_file_type(wtap *wth, int *err, gchar **err_info)
}
-int cosine_open(wtap *wth, int *err, gchar **err_info)
+wtap_open_return_val cosine_open(wtap *wth, int *err, gchar **err_info)
{
/* Look for CoSine header */
if (!cosine_check_file_type(wth, err, err_info)) {
if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
- return -1;
- return 0;
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
}
if (file_seek(wth->fh, 0L, SEEK_SET, err) == -1) /* rewind */
- return -1;
+ return WTAP_OPEN_ERROR;
wth->file_encap = WTAP_ENCAP_COSINE;
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_COSINE;
@@ -282,7 +282,7 @@ int cosine_open(wtap *wth, int *err, gchar **err_info)
wth->subtype_seek_read = cosine_seek_read;
wth->file_tsprec = WTAP_TSPREC_CSEC;
- return 1;
+ return WTAP_OPEN_MINE;
}
/* Find the next packet and parse it; called from wtap_read(). */
diff --git a/wiretap/csids.c b/wiretap/csids.c
index 72f4f940a8..7c0551a95c 100644
--- a/wiretap/csids.c
+++ b/wiretap/csids.c
@@ -57,8 +57,7 @@ struct csids_header {
guint16 caplen; /* the capture length */
};
-/* XXX - return -1 on I/O error and actually do something with 'err'. */
-int csids_open(wtap *wth, int *err, gchar **err_info)
+wtap_open_return_val csids_open(wtap *wth, int *err, gchar **err_info)
{
/* There is no file header. There is only a header for each packet
* so we read a packet header and compare the caplen with iplen. They
@@ -77,31 +76,31 @@ int csids_open(wtap *wth, int *err, gchar **err_info)
/* check the file to make sure it is a csids file. */
if( !wtap_read_bytes( wth->fh, &hdr, sizeof( struct csids_header), err, err_info ) ) {
if( *err != WTAP_ERR_SHORT_READ ) {
- return -1;
+ return WTAP_OPEN_ERROR;
}
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
if( hdr.zeropad != 0 || hdr.caplen == 0 ) {
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
hdr.seconds = pntoh32( &hdr.seconds );
hdr.caplen = pntoh16( &hdr.caplen );
if( !wtap_read_bytes( wth->fh, &tmp, 2, err, err_info ) ) {
if( *err != WTAP_ERR_SHORT_READ ) {
- return -1;
+ return WTAP_OPEN_ERROR;
}
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
if( !wtap_read_bytes(wth->fh, &iplen, 2, err, err_info ) ) {
if( *err != WTAP_ERR_SHORT_READ ) {
- return -1;
+ return WTAP_OPEN_ERROR;
}
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
iplen = pntoh16(&iplen);
if ( iplen == 0 )
- return 0;
+ return WTAP_OPEN_NOT_MINE;
/* if iplen and hdr.caplen are equal, default to no byteswap. */
if( iplen > hdr.caplen ) {
@@ -114,7 +113,7 @@ int csids_open(wtap *wth, int *err, gchar **err_info)
byteswap = TRUE;
} else {
/* don't know this one */
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
} else {
byteswap = FALSE;
@@ -122,7 +121,7 @@ int csids_open(wtap *wth, int *err, gchar **err_info)
/* no file header. So reset the fh to 0 so we can read the first packet */
if (file_seek(wth->fh, 0, SEEK_SET, err) == -1)
- return -1;
+ return WTAP_OPEN_ERROR;
csids = (csids_t *)g_malloc(sizeof(csids_t));
wth->priv = (void *)csids;
@@ -134,7 +133,7 @@ int csids_open(wtap *wth, int *err, gchar **err_info)
wth->subtype_seek_read = csids_seek_read;
wth->file_tsprec = WTAP_TSPREC_SEC;
- return 1;
+ return WTAP_OPEN_MINE;
}
/* Find the next packet and parse it; called from wtap_read(). */
diff --git a/wiretap/daintree-sna.c b/wiretap/daintree-sna.c
index 672393dc95..eeddbc800f 100644
--- a/wiretap/daintree-sna.c
+++ b/wiretap/daintree-sna.c
@@ -90,34 +90,31 @@ static gboolean daintree_sna_process_hex_data(struct wtap_pkthdr *phdr,
Buffer *buf, char *readData, int *err, gchar **err_info);
/* Open a file and determine if it's a Daintree file */
-int daintree_sna_open(wtap *wth, int *err, gchar **err_info)
+wtap_open_return_val daintree_sna_open(wtap *wth, int *err, gchar **err_info)
{
char readLine[DAINTREE_MAX_LINE_SIZE];
- guint i;
/* get first line of file header */
if (file_gets(readLine, DAINTREE_MAX_LINE_SIZE, wth->fh)==NULL) {
*err = file_error(wth->fh, err_info);
if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
- return -1;
- return 0;
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
}
/* check magic text */
- i = 0;
- while (i < DAINTREE_MAGIC_TEXT_SIZE) {
- if (readLine[i] != daintree_magic_text[i]) return 0; /* not daintree format */
- i++;
- }
+ if (memcmp(readLine, daintree_magic_text, DAINTREE_MAGIC_TEXT_SIZE) != 0)
+ return WTAP_OPEN_NOT_MINE; /* not daintree format */
/* read second header line */
if (file_gets(readLine, DAINTREE_MAX_LINE_SIZE, wth->fh)==NULL) {
*err = file_error(wth->fh, err_info);
if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
- return -1;
- return 0;
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
}
- if (readLine[0] != COMMENT_LINE) return 0; /* daintree files have a two line header */
+ if (readLine[0] != COMMENT_LINE)
+ return WTAP_OPEN_NOT_MINE; /* daintree files have a two line header */
/* set up the pointers to the handlers for this file type */
wth->subtype_read = daintree_sna_read;
@@ -129,7 +126,7 @@ int daintree_sna_open(wtap *wth, int *err, gchar **err_info)
wth->file_tsprec = WTAP_TSPREC_USEC;
wth->snapshot_length = 0; /* not available in header */
- return 1; /* it's a Daintree file */
+ return WTAP_OPEN_MINE; /* it's a Daintree file */
}
/* Read the capture file sequentially
diff --git a/wiretap/dbs-etherwatch.c b/wiretap/dbs-etherwatch.c
index 576dae7f2b..266ffa4cfc 100644
--- a/wiretap/dbs-etherwatch.c
+++ b/wiretap/dbs-etherwatch.c
@@ -176,13 +176,13 @@ static gboolean dbs_etherwatch_check_file_type(wtap *wth, int *err,
}
-int dbs_etherwatch_open(wtap *wth, int *err, gchar **err_info)
+wtap_open_return_val dbs_etherwatch_open(wtap *wth, int *err, gchar **err_info)
{
/* Look for DBS ETHERWATCH header */
if (!dbs_etherwatch_check_file_type(wth, err, err_info)) {
if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
- return -1;
- return 0;
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
}
wth->file_encap = WTAP_ENCAP_ETHERNET;
@@ -192,7 +192,7 @@ int dbs_etherwatch_open(wtap *wth, int *err, gchar **err_info)
wth->subtype_seek_read = dbs_etherwatch_seek_read;
wth->file_tsprec = WTAP_TSPREC_CSEC;
- return 1;
+ return WTAP_OPEN_MINE;
}
/* Find the next packet and parse it; called from wtap_read(). */
diff --git a/wiretap/dct3trace.c b/wiretap/dct3trace.c
index 7ce51242ac..873d96485b 100644
--- a/wiretap/dct3trace.c
+++ b/wiretap/dct3trace.c
@@ -155,7 +155,7 @@ xml_get_int(int *val, const char *str, const char *pattern)
}
-int dct3trace_open(wtap *wth, int *err, gchar **err_info)
+wtap_open_return_val dct3trace_open(wtap *wth, int *err, gchar **err_info)
{
char line1[64], line2[64];
@@ -165,15 +165,15 @@ int dct3trace_open(wtap *wth, int *err, gchar **err_info)
{
*err = file_error(wth->fh, err_info);
if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
- return -1;
- return 0;
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
}
/* Don't compare line endings */
if( strncmp(dct3trace_magic_line1, line1, strlen(dct3trace_magic_line1)) != 0 ||
strncmp(dct3trace_magic_line2, line2, strlen(dct3trace_magic_line2)) != 0)
{
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
wth->file_encap = WTAP_ENCAP_GSM_UM;
@@ -183,7 +183,7 @@ int dct3trace_open(wtap *wth, int *err, gchar **err_info)
wth->subtype_seek_read = dct3trace_seek_read;
wth->file_tsprec = WTAP_TSPREC_SEC;
- return 1;
+ return WTAP_OPEN_MINE;
}
diff --git a/wiretap/erf.c b/wiretap/erf.c
index cfad9d0a88..52400a96c4 100644
--- a/wiretap/erf.c
+++ b/wiretap/erf.c
@@ -86,7 +86,7 @@ static const struct {
#define NUM_ERF_ENCAPS (sizeof erf_to_wtap_map / sizeof erf_to_wtap_map[0])
-extern int erf_open(wtap *wth, int *err, gchar **err_info)
+extern wtap_open_return_val erf_open(wtap *wth, int *err, gchar **err_info)
{
int i, n, records_for_erf_check = RECORDS_FOR_ERF_CHECK;
int valid_prev = 0;
@@ -128,13 +128,13 @@ extern int erf_open(wtap *wth, int *err, gchar **err_info)
/* ERF header too short accept the file,
only if the very first records have been successfully checked */
if (i < MIN_RECORDS_FOR_ERF_CHECK) {
- return 0;
+ return WTAP_OPEN_NOT_MINE;
} else {
/* BREAK, the last record is too short, and will be ignored */
break;
}
} else {
- return -1;
+ return WTAP_OPEN_ERROR;
}
}
@@ -144,7 +144,7 @@ extern int erf_open(wtap *wth, int *err, gchar **err_info)
/* Test valid rlen >= 16 */
if (rlen < 16) {
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
packet_size = rlen - (guint32)sizeof(header);
@@ -153,13 +153,13 @@ extern int erf_open(wtap *wth, int *err, gchar **err_info)
* Probably a corrupt capture file or a file that's not an ERF file
* but that passed earlier tests.
*/
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
/* Skip PAD records, timestamps may not be set */
if ((header.type & 0x7F) == ERF_TYPE_PAD) {
if (file_seek(wth->fh, packet_size, SEEK_CUR, err) == -1) {
- return -1;
+ return WTAP_OPEN_ERROR;
}
continue;
}
@@ -167,24 +167,24 @@ extern int erf_open(wtap *wth, int *err, gchar **err_info)
/* fail on invalid record type, decreasing timestamps or non-zero pad-bits */
/* Not all types within this range are decoded, but it is a first filter */
if ((header.type & 0x7F) == 0 || (header.type & 0x7F) > ERF_TYPE_MAX ) {
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
/* The ERF_TYPE_MAX is the PAD record, but the last used type is ERF_TYPE_INFINIBAND_LINK */
if ((header.type & 0x7F) > ERF_TYPE_INFINIBAND_LINK) {
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
if ((ts = pletoh64(&header.ts)) < prevts) {
/* reassembled AALx records may not be in time order, also records are not in strict time order between physical interfaces, so allow 1 sec fudge */
if ( ((prevts-ts)>>32) > 1 ) {
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
}
/* Check to see if timestamp increment is > 1 week */
if ( (valid_prev) && (ts > prevts) && (((ts-prevts)>>32) > 3600*24*7) ) {
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
memcpy(&prevts, &ts, sizeof(prevts));
@@ -195,9 +195,9 @@ extern int erf_open(wtap *wth, int *err, gchar **err_info)
if (!wtap_read_bytes(wth->fh,&erf_ext_header,sizeof(erf_ext_header),err,err_info)) {
if (*err == WTAP_ERR_SHORT_READ) {
/* Extension header missing, not an ERF file */
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
- return -1;
+ return WTAP_OPEN_ERROR;
}
packet_size -= (guint32)sizeof(erf_ext_header);
memcpy(&type, &erf_ext_header, sizeof(type));
@@ -217,9 +217,9 @@ extern int erf_open(wtap *wth, int *err, gchar **err_info)
if (!wtap_read_bytes(wth->fh,&mc_hdr,sizeof(mc_hdr),err,err_info)) {
if (*err == WTAP_ERR_SHORT_READ) {
/* Subheader missing, not an ERF file */
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
- return -1;
+ return WTAP_OPEN_ERROR;
}
packet_size -= (guint32)sizeof(mc_hdr);
break;
@@ -229,9 +229,9 @@ extern int erf_open(wtap *wth, int *err, gchar **err_info)
if (!wtap_read_bytes(wth->fh,&eth_hdr,sizeof(eth_hdr),err,err_info)) {
if (*err == WTAP_ERR_SHORT_READ) {
/* Subheader missing, not an ERF file */
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
- return -1;
+ return WTAP_OPEN_ERROR;
}
packet_size -= (guint32)sizeof(eth_hdr);
break;
@@ -246,7 +246,7 @@ extern int erf_open(wtap *wth, int *err, gchar **err_info)
* Probably a corrupt capture file or a file that's not an ERF file
* but that passed earlier tests.
*/
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
buffer=(gchar *)g_malloc(packet_size);
r = wtap_read_bytes(wth->fh, buffer, packet_size, err, err_info);
@@ -255,12 +255,12 @@ extern int erf_open(wtap *wth, int *err, gchar **err_info)
if (!r) {
if (*err != WTAP_ERR_SHORT_READ) {
/* A real error */
- return -1;
+ return WTAP_OPEN_ERROR;
}
/* ERF record too short, accept the file,
only if the very first records have been successfully checked */
if (i < MIN_RECORDS_FOR_ERF_CHECK) {
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
}
@@ -269,7 +269,7 @@ extern int erf_open(wtap *wth, int *err, gchar **err_info)
} /* records_for_erf_check */
if (file_seek(wth->fh, 0L, SEEK_SET, err) == -1) { /* rewind */
- return -1;
+ return WTAP_OPEN_ERROR;
}
/* This is an ERF file */
@@ -287,7 +287,7 @@ extern int erf_open(wtap *wth, int *err, gchar **err_info)
erf_populate_interfaces(wth);
- return 1;
+ return WTAP_OPEN_MINE;
}
/* Read the next packet */
diff --git a/wiretap/eyesdn.c b/wiretap/eyesdn.c
index 2c815d62f1..4350d23644 100644
--- a/wiretap/eyesdn.c
+++ b/wiretap/eyesdn.c
@@ -135,18 +135,18 @@ static gint64 eyesdn_seek_next_packet(wtap *wth, int *err, gchar **err_info)
return -1;
}
-int eyesdn_open(wtap *wth, int *err, gchar **err_info)
+wtap_open_return_val eyesdn_open(wtap *wth, int *err, gchar **err_info)
{
char magic[EYESDN_HDR_MAGIC_SIZE];
/* Look for eyesdn header */
if (!wtap_read_bytes(wth->fh, &magic, sizeof magic, err, err_info)) {
if (*err != WTAP_ERR_SHORT_READ)
- return -1;
- return 0;
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
}
if (memcmp(magic, eyesdn_hdr_magic, EYESDN_HDR_MAGIC_SIZE) != 0)
- return 0;
+ return WTAP_OPEN_NOT_MINE;
wth->file_encap = WTAP_ENCAP_PER_PACKET;
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_EYESDN;
@@ -155,7 +155,7 @@ int eyesdn_open(wtap *wth, int *err, gchar **err_info)
wth->subtype_seek_read = eyesdn_seek_read;
wth->file_tsprec = WTAP_TSPREC_USEC;
- return 1;
+ return WTAP_OPEN_MINE;
}
/* Find the next packet and parse it; called from wtap_read(). */
diff --git a/wiretap/file_access.c b/wiretap/file_access.c
index b2a05b05fe..238820efe2 100644
--- a/wiretap/file_access.c
+++ b/wiretap/file_access.c
@@ -859,16 +859,16 @@ wtap_open_offline(const char *filename, unsigned int type, int *err, char **err_
result = (*open_routines[type - 1].open_routine)(wth, err, err_info);
switch (result) {
- case -1:
- /* I/O error - give up */
+ case WTAP_OPEN_ERROR:
+ /* Error - give up */
wtap_close(wth);
return NULL;
- case 0:
- /* No I/O error, but not that type of file */
+ case WTAP_OPEN_NOT_MINE:
+ /* No error, but not that type of file */
goto fail;
- case 1:
+ case WTAP_OPEN_MINE:
/* We found the file type */
goto success;
}
@@ -884,7 +884,7 @@ wtap_open_offline(const char *filename, unsigned int type, int *err, char **err_
Initialize the data offset while we're at it. */
if (file_seek(wth->fh, 0, SEEK_SET, err) == -1) {
- /* I/O error - give up */
+ /* Error - give up */
wtap_close(wth);
return NULL;
}
@@ -897,16 +897,16 @@ wtap_open_offline(const char *filename, unsigned int type, int *err, char **err_
switch ((*open_routines[i].open_routine)(wth, err, err_info)) {
- case -1:
- /* I/O error - give up */
+ case WTAP_OPEN_ERROR:
+ /* Error - give up */
wtap_close(wth);
return NULL;
- case 0:
- /* No I/O error, but not that type of file */
+ case WTAP_OPEN_NOT_MINE:
+ /* No error, but not that type of file */
break;
- case 1:
+ case WTAP_OPEN_MINE:
/* We found the file type */
goto success;
}
@@ -922,7 +922,7 @@ wtap_open_offline(const char *filename, unsigned int type, int *err, char **err_
if (heuristic_uses_extension(i, extension)) {
/* Yes. */
if (file_seek(wth->fh, 0, SEEK_SET, err) == -1) {
- /* I/O error - give up */
+ /* Error - give up */
g_free(extension);
wtap_close(wth);
return NULL;
@@ -936,17 +936,17 @@ wtap_open_offline(const char *filename, unsigned int type, int *err, char **err_
switch ((*open_routines[i].open_routine)(wth,
err, err_info)) {
- case -1:
- /* I/O error - give up */
+ case WTAP_OPEN_ERROR:
+ /* Error - give up */
g_free(extension);
wtap_close(wth);
return NULL;
- case 0:
- /* No I/O error, but not that type of file */
+ case WTAP_OPEN_NOT_MINE:
+ /* No error, but not that type of file */
break;
- case 1:
+ case WTAP_OPEN_MINE:
/* We found the file type */
g_free(extension);
goto success;
@@ -960,7 +960,7 @@ wtap_open_offline(const char *filename, unsigned int type, int *err, char **err_
if (!heuristic_uses_extension(i, extension)) {
/* No. */
if (file_seek(wth->fh, 0, SEEK_SET, err) == -1) {
- /* I/O error - give up */
+ /* Error - give up */
g_free(extension);
wtap_close(wth);
return NULL;
@@ -974,17 +974,17 @@ wtap_open_offline(const char *filename, unsigned int type, int *err, char **err_
switch ((*open_routines[i].open_routine)(wth,
err, err_info)) {
- case -1:
- /* I/O error - give up */
+ case WTAP_OPEN_ERROR:
+ /* Error - give up */
g_free(extension);
wtap_close(wth);
return NULL;
- case 0:
- /* No I/O error, but not that type of file */
+ case WTAP_OPEN_NOT_MINE:
+ /* No error, but not that type of file */
break;
- case 1:
+ case WTAP_OPEN_MINE:
/* We found the file type */
g_free(extension);
goto success;
@@ -997,7 +997,7 @@ wtap_open_offline(const char *filename, unsigned int type, int *err, char **err_
for (i = heuristic_open_routine_idx; i < open_info_arr->len; i++) {
if (file_seek(wth->fh, 0, SEEK_SET, err) == -1) {
- /* I/O error - give up */
+ /* Error - give up */
wtap_close(wth);
return NULL;
}
@@ -1009,16 +1009,16 @@ wtap_open_offline(const char *filename, unsigned int type, int *err, char **err_
switch ((*open_routines[i].open_routine)(wth, err, err_info)) {
- case -1:
- /* I/O error - give up */
+ case WTAP_OPEN_ERROR:
+ /* Error - give up */
wtap_close(wth);
return NULL;
- case 0:
- /* No I/O error, but not that type of file */
+ case WTAP_OPEN_NOT_MINE:
+ /* No error, but not that type of file */
break;
- case 1:
+ case WTAP_OPEN_MINE:
/* We found the file type */
goto success;
}
diff --git a/wiretap/hcidump.c b/wiretap/hcidump.c
index d4a6d2fc60..5f7634abb2 100644
--- a/wiretap/hcidump.c
+++ b/wiretap/hcidump.c
@@ -85,32 +85,32 @@ static gboolean hcidump_seek_read(wtap *wth, gint64 seek_off,
return hcidump_process_packet(wth->random_fh, phdr, buf, err, err_info);
}
-int hcidump_open(wtap *wth, int *err, gchar **err_info)
+wtap_open_return_val hcidump_open(wtap *wth, int *err, gchar **err_info)
{
struct dump_hdr dh;
guint8 type;
if (!wtap_read_bytes(wth->fh, &dh, DUMP_HDR_SIZE, err, err_info)) {
if (*err != WTAP_ERR_SHORT_READ)
- return -1;
- return 0;
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
}
if ((dh.in != 0 && dh.in != 1) || dh.pad != 0
|| GUINT16_FROM_LE(dh.len) < 1)
- return 0;
+ return WTAP_OPEN_NOT_MINE;
if (!wtap_read_bytes(wth->fh, &type, 1, err, err_info)) {
if (*err != WTAP_ERR_SHORT_READ)
- return -1;
- return 0;
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
}
if (type < 1 || type > 4)
- return 0;
+ return WTAP_OPEN_NOT_MINE;
if (file_seek(wth->fh, 0, SEEK_SET, err) == -1)
- return -1;
+ return WTAP_OPEN_ERROR;
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_HCIDUMP;
wth->file_encap = WTAP_ENCAP_BLUETOOTH_H4_WITH_PHDR;
@@ -120,5 +120,5 @@ int hcidump_open(wtap *wth, int *err, gchar **err_info)
wth->subtype_seek_read = hcidump_seek_read;
wth->file_tsprec = WTAP_TSPREC_USEC;
- return 1;
+ return WTAP_OPEN_MINE;
}
diff --git a/wiretap/i4btrace.c b/wiretap/i4btrace.c
index 6e9ef001dc..8920f10c29 100644
--- a/wiretap/i4btrace.c
+++ b/wiretap/i4btrace.c
@@ -48,7 +48,7 @@ static int i4b_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
(unsigned int)hdr.unit > 4 || (unsigned int)hdr.type > 4 || \
(unsigned int)hdr.dir > 2 || (unsigned int)hdr.trunc > 2048))
-int i4btrace_open(wtap *wth, int *err, gchar **err_info)
+wtap_open_return_val i4btrace_open(wtap *wth, int *err, gchar **err_info)
{
i4b_trace_hdr_t hdr;
gboolean byte_swapped = FALSE;
@@ -57,8 +57,8 @@ int i4btrace_open(wtap *wth, int *err, gchar **err_info)
/* I4B trace files have no magic in the header... Sigh */
if (!wtap_read_bytes(wth->fh, &hdr, sizeof(hdr), err, err_info)) {
if (*err != WTAP_ERR_SHORT_READ)
- return -1;
- return 0;
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
}
/* Silly heuristic... */
@@ -75,7 +75,7 @@ int i4btrace_open(wtap *wth, int *err, gchar **err_info)
/*
* It doesn't look valid in either byte order.
*/
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
/*
@@ -86,7 +86,7 @@ int i4btrace_open(wtap *wth, int *err, gchar **err_info)
}
if (file_seek(wth->fh, 0, SEEK_SET, err) == -1)
- return -1;
+ return WTAP_OPEN_ERROR;
/* Get capture start time */
@@ -102,7 +102,7 @@ int i4btrace_open(wtap *wth, int *err, gchar **err_info)
wth->file_encap = WTAP_ENCAP_ISDN;
wth->file_tsprec = WTAP_TSPREC_USEC;
- return 1;
+ return WTAP_OPEN_MINE;
}
/* Read the next packet */
diff --git a/wiretap/ipfix.c b/wiretap/ipfix.c
index 70afe20311..a0fac7ddb2 100644
--- a/wiretap/ipfix.c
+++ b/wiretap/ipfix.c
@@ -91,8 +91,6 @@ ipfix_read(wtap *wth, int *err, gchar **err_info,
static gboolean
ipfix_seek_read(wtap *wth, gint64 seek_off,
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
-static void
-ipfix_close(wtap *wth);
#define IPFIX_VERSION 10
@@ -182,10 +180,11 @@ ipfix_read_message(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err, g
-/* classic wtap: open capture file. Return 1 on success, 0 on normal failure
- * like malformed format, -1 on bad error like file system
+/* classic wtap: open capture file. Return WTAP_OPEN_MINE on success,
+ * WTAP_OPEN_NOT_MINE on normal failure like malformed format,
+ * WTAP_OPEN_ERROR on bad error like file system
*/
-int
+wtap_open_return_val
ipfix_open(wtap *wth, int *err, gchar **err_info)
{
gint i, n, records_for_ipfix_check = RECORDS_FOR_IPFIX_CHECK;
@@ -217,14 +216,14 @@ ipfix_open(wtap *wth, int *err, gchar **err_info)
*err = 0; /* not actually an error in this case */
g_free(*err_info);
*err_info = NULL;
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
- return -1; /* real failure */
+ return WTAP_OPEN_ERROR; /* real failure */
/* else it's EOF */
if (i < 1) {
/* we haven't seen enough to prove this is a ipfix file */
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
/*
* If we got here, it's EOF and we haven't yet seen anything
@@ -237,7 +236,7 @@ ipfix_open(wtap *wth, int *err, gchar **err_info)
if (file_seek(wth->fh, IPFIX_MSG_HDR_SIZE, SEEK_CUR, err) == -1) {
ipfix_debug1("ipfix_open: failed seek to next message in file, %d bytes away",
msg_hdr.message_length);
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
checked_len = IPFIX_MSG_HDR_SIZE;
@@ -248,18 +247,18 @@ ipfix_open(wtap *wth, int *err, gchar **err_info)
if (*err == WTAP_ERR_SHORT_READ) {
/* Not a valid IPFIX Set, so not an IPFIX file. */
ipfix_debug1("ipfix_open: error %d reading set", *err);
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
/* A real I/O error; fail. */
- return -1;
+ return WTAP_OPEN_ERROR;
}
set_hdr.set_length = g_ntohs(set_hdr.set_length);
if ((set_hdr.set_length < IPFIX_SET_HDR_SIZE) ||
((set_hdr.set_length + checked_len) > msg_hdr.message_length)) {
ipfix_debug1("ipfix_open: found invalid set_length of %d",
set_hdr.set_length);
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
if (file_seek(wth->fh, set_hdr.set_length - IPFIX_SET_HDR_SIZE,
@@ -267,27 +266,27 @@ ipfix_open(wtap *wth, int *err, gchar **err_info)
{
ipfix_debug1("ipfix_open: failed seek to next set in file, %d bytes away",
set_hdr.set_length - IPFIX_SET_HDR_SIZE);
- return -1;
+ return WTAP_OPEN_ERROR;
}
checked_len += set_hdr.set_length;
}
}
+ /* go back to beginning of file */
+ if (file_seek (wth->fh, 0, SEEK_SET, err) != 0)
+ {
+ return WTAP_OPEN_ERROR;
+ }
+
/* all's good, this is a IPFIX file */
wth->file_encap = WTAP_ENCAP_RAW_IPFIX;
wth->snapshot_length = 0;
wth->file_tsprec = WTAP_TSPREC_SEC;
wth->subtype_read = ipfix_read;
wth->subtype_seek_read = ipfix_seek_read;
- wth->subtype_close = ipfix_close;
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_IPFIX;
- /* go back to beginning of file */
- if (file_seek (wth->fh, 0, SEEK_SET, err) != 0)
- {
- return -1;
- }
- return 1;
+ return WTAP_OPEN_MINE;
}
@@ -330,11 +329,3 @@ ipfix_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
}
return TRUE;
}
-
-
-/* classic wtap: close capture file */
-static void
-ipfix_close(wtap *wth _U_)
-{
- ipfix_debug0("ipfix_close: closing file");
-}
diff --git a/wiretap/iptrace.c b/wiretap/iptrace.c
index 317d922215..c652af700d 100644
--- a/wiretap/iptrace.c
+++ b/wiretap/iptrace.c
@@ -49,14 +49,14 @@ static int wtap_encap_ift(unsigned int ift);
#define NAME_SIZE 11
-int iptrace_open(wtap *wth, int *err, gchar **err_info)
+wtap_open_return_val iptrace_open(wtap *wth, int *err, gchar **err_info)
{
char name[NAME_SIZE+1];
if (!wtap_read_bytes(wth->fh, name, NAME_SIZE, err, err_info)) {
if (*err != WTAP_ERR_SHORT_READ)
- return -1;
- return 0;
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
}
name[NAME_SIZE] = '\0';
@@ -73,10 +73,10 @@ int iptrace_open(wtap *wth, int *err, gchar **err_info)
wth->file_tsprec = WTAP_TSPREC_NSEC;
}
else {
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
- return 1;
+ return WTAP_OPEN_MINE;
}
/***********************************************************
diff --git a/wiretap/iseries.c b/wiretap/iseries.c
index 50141f9ab6..e4d306eb93 100644
--- a/wiretap/iseries.c
+++ b/wiretap/iseries.c
@@ -194,7 +194,7 @@ static int iseries_UNICODE_to_ASCII (guint8 * buf, guint bytes);
static gboolean iseries_parse_hex_string (const char * ascii, guint8 * buf,
size_t len);
-int
+wtap_open_return_val
iseries_open (wtap * wth, int *err, gchar ** err_info)
{
gint offset;
@@ -212,8 +212,8 @@ iseries_open (wtap * wth, int *err, gchar ** err_info)
if (!wtap_read_bytes (wth->fh, &magic, sizeof magic, err, err_info))
{
if (*err != WTAP_ERR_SHORT_READ)
- return -1;
- return 0;
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
}
/*
@@ -225,7 +225,7 @@ iseries_open (wtap * wth, int *err, gchar ** err_info)
if (memcmp (magic + offset, unicodemagic, sizeof unicodemagic) == 0) {
if (file_seek (wth->fh, 0, SEEK_SET, err) == -1)
{
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
/*
* Do some basic sanity checking to ensure we can handle the
@@ -234,9 +234,9 @@ iseries_open (wtap * wth, int *err, gchar ** err_info)
if (!iseries_check_file_type (wth, err, err_info, ISERIES_FORMAT_UNICODE))
{
if (*err == 0)
- return 0;
+ return WTAP_OPEN_NOT_MINE;
else
- return -1;
+ return WTAP_OPEN_ERROR;
}
wth->file_encap = WTAP_ENCAP_ETHERNET;
@@ -248,9 +248,9 @@ iseries_open (wtap * wth, int *err, gchar ** err_info)
if (file_seek (wth->fh, 0, SEEK_SET, err) == -1)
{
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
- return 1;
+ return WTAP_OPEN_MINE;
}
offset += 1;
}
@@ -265,7 +265,7 @@ iseries_open (wtap * wth, int *err, gchar ** err_info)
{
if (file_seek (wth->fh, 0, SEEK_SET, err) == -1)
{
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
/*
* Do some basic sanity checking to ensure we can handle the
@@ -274,9 +274,9 @@ iseries_open (wtap * wth, int *err, gchar ** err_info)
if (!iseries_check_file_type (wth, err, err_info, ISERIES_FORMAT_ASCII))
{
if (*err == 0)
- return 0;
+ return WTAP_OPEN_NOT_MINE;
else
- return -1;
+ return WTAP_OPEN_ERROR;
}
wth->file_encap = WTAP_ENCAP_ETHERNET;
@@ -288,15 +288,15 @@ iseries_open (wtap * wth, int *err, gchar ** err_info)
if (file_seek (wth->fh, 0, SEEK_SET, err) == -1)
{
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
- return 1;
+ return WTAP_OPEN_MINE;
}
offset += 1;
}
/* Neither ASCII or UNICODE so not supported */
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
/*
diff --git a/wiretap/k12.c b/wiretap/k12.c
index 39a4eb4e10..17e75534d7 100644
--- a/wiretap/k12.c
+++ b/wiretap/k12.c
@@ -822,7 +822,7 @@ static void k12_close(wtap *wth) {
}
-int k12_open(wtap *wth, int *err, gchar **err_info) {
+wtap_open_return_val k12_open(wtap *wth, int *err, gchar **err_info) {
k12_src_desc_t* rec;
guint8 header_buffer[K12_FILE_HDR_LEN];
guint8* read_buffer;
@@ -855,14 +855,14 @@ int k12_open(wtap *wth, int *err, gchar **err_info) {
if ( !wtap_read_bytes(wth->fh,header_buffer,K12_FILE_HDR_LEN,err,err_info) ) {
K12_DBG(1,("k12_open: FILE HEADER TOO SHORT OR READ ERROR"));
if (*err != WTAP_ERR_SHORT_READ) {
- return -1;
+ return WTAP_OPEN_ERROR;
}
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
if ( memcmp(header_buffer,k12_file_magic,8) != 0 ) {
K12_DBG(1,("k12_open: BAD MAGIC"));
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
offset = K12_FILE_HDR_LEN;
@@ -884,20 +884,20 @@ int k12_open(wtap *wth, int *err, gchar **err_info) {
if ( len < 0 ) {
K12_DBG(1,("k12_open: BAD HEADER RECORD",len));
destroy_k12_file_data(file_data);
- return -1;
+ return WTAP_OPEN_ERROR;
}
if (len == 0) {
K12_DBG(1,("k12_open: BAD HEADER RECORD",len));
*err = WTAP_ERR_SHORT_READ;
destroy_k12_file_data(file_data);
- return -1;
+ return WTAP_OPEN_ERROR;
}
if (len == 0) {
K12_DBG(1,("k12_open: BAD HEADER RECORD",len));
*err = WTAP_ERR_SHORT_READ;
destroy_k12_file_data(file_data);
- return -1;
+ return WTAP_OPEN_ERROR;
}
read_buffer = file_data->seq_read_buff;
@@ -908,7 +908,7 @@ int k12_open(wtap *wth, int *err, gchar **err_info) {
*err = WTAP_ERR_BAD_FILE;
*err_info = g_strdup_printf("k12_open: record length %u < %u",
rec_len, K12_RECORD_TYPE + 4);
- return -1;
+ return WTAP_OPEN_ERROR;
}
type = pntoh32( read_buffer + K12_RECORD_TYPE );
@@ -919,7 +919,7 @@ int k12_open(wtap *wth, int *err, gchar **err_info) {
*/
if (file_seek(wth->fh, offset, SEEK_SET, err) == -1) {
destroy_k12_file_data(file_data);
- return -1;
+ return WTAP_OPEN_ERROR;
}
K12_DBG(5,("k12_open: FIRST PACKET offset=%x",offset));
break;
@@ -933,7 +933,7 @@ int k12_open(wtap *wth, int *err, gchar **err_info) {
rec_len, K12_SRCDESC_STACKLEN + 2);
destroy_k12_file_data(file_data);
g_free(rec);
- return -1;
+ return WTAP_OPEN_ERROR;
}
extra_len = pntoh16( read_buffer + K12_SRCDESC_EXTRALEN );
name_len = pntoh16( read_buffer + K12_SRCDESC_NAMELEN );
@@ -950,7 +950,7 @@ int k12_open(wtap *wth, int *err, gchar **err_info) {
"|| 0x20 + extra_len + name_len + stack_len > rec_len) extra_len=%i name_len=%i stack_len=%i"));
destroy_k12_file_data(file_data);
g_free(rec);
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
if (extra_len) {
@@ -961,7 +961,7 @@ int k12_open(wtap *wth, int *err, gchar **err_info) {
rec_len, K12_SRCDESC_EXTRATYPE + 4);
destroy_k12_file_data(file_data);
g_free(rec);
- return -1;
+ return WTAP_OPEN_ERROR;
}
switch(( rec->input_type = pntoh32( read_buffer + K12_SRCDESC_EXTRATYPE ) )) {
case K12_PORT_DS0S:
@@ -972,7 +972,7 @@ int k12_open(wtap *wth, int *err, gchar **err_info) {
rec_len, K12_SRCDESC_DS0_MASK + 12);
destroy_k12_file_data(file_data);
g_free(rec);
- return -1;
+ return WTAP_OPEN_ERROR;
}
rec->input_info.ds0mask = 0x00000000;
@@ -990,7 +990,7 @@ int k12_open(wtap *wth, int *err, gchar **err_info) {
rec_len, K12_SRCDESC_DS0_MASK + 12);
destroy_k12_file_data(file_data);
g_free(rec);
- return -1;
+ return WTAP_OPEN_ERROR;
}
rec->input_info.atm.vp = pntoh16( read_buffer + K12_SRCDESC_ATM_VPI );
@@ -1008,7 +1008,7 @@ int k12_open(wtap *wth, int *err, gchar **err_info) {
rec_len, K12_SRCDESC_DS0_MASK + 12);
destroy_k12_file_data(file_data);
g_free(rec);
- return -1;
+ return WTAP_OPEN_ERROR;
}
if (read_buffer[K12_SRCDESC_PORT_TYPE] >= 0x14
&& read_buffer[K12_SRCDESC_PORT_TYPE] <= 0x17) {
@@ -1033,7 +1033,7 @@ int k12_open(wtap *wth, int *err, gchar **err_info) {
rec_len, K12_SRCDESC_EXTRATYPE + extra_len + name_len + stack_len);
destroy_k12_file_data(file_data);
g_free(rec);
- return -1;
+ return WTAP_OPEN_ERROR;
}
rec->input_name = (gchar *)g_memdup(read_buffer + K12_SRCDESC_EXTRATYPE + extra_len, name_len);
rec->stack_file = (gchar *)g_memdup(read_buffer + K12_SRCDESC_EXTRATYPE + extra_len + name_len, stack_len);
@@ -1069,7 +1069,7 @@ int k12_open(wtap *wth, int *err, gchar **err_info) {
wth->priv = (void *)file_data;
wth->file_tsprec = WTAP_TSPREC_NSEC;
- return 1;
+ return WTAP_OPEN_MINE;
}
typedef struct {
diff --git a/wiretap/k12text.l b/wiretap/k12text.l
index b281dfe15f..69a2a982ef 100644
--- a/wiretap/k12text.l
+++ b/wiretap/k12text.l
@@ -319,7 +319,7 @@ k12text_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *
return TRUE;
}
-int
+wtap_open_return_val
k12text_open(wtap *wth, int *err, gchar **err_info _U_)
{
k12text_t *k12text;
@@ -329,10 +329,10 @@ k12text_open(wtap *wth, int *err, gchar **err_info _U_)
BEGIN(MAGIC);
yylex();
- if (! is_k12text) return 0;
+ if (! is_k12text) return WTAP_OPEN_NOT_MINE;
if ( file_seek(wth->fh, 0, SEEK_SET, err) == -1) {
- return -1;
+ return WTAP_OPEN_ERROR;
}
k12text = (k12text_t *)g_malloc(sizeof(k12text_t));
@@ -345,7 +345,7 @@ k12text_open(wtap *wth, int *err, gchar **err_info _U_)
wth->subtype_seek_read = k12text_seek_read;
wth->file_tsprec = WTAP_TSPREC_NSEC;
- return 1;
+ return WTAP_OPEN_MINE;
}
diff --git a/wiretap/lanalyzer.c b/wiretap/lanalyzer.c
index 3c3ba09ad9..de51491ee8 100644
--- a/wiretap/lanalyzer.c
+++ b/wiretap/lanalyzer.c
@@ -276,7 +276,7 @@ static gboolean lanalyzer_seek_read(wtap *wth, gint64 seek_off,
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
static gboolean lanalyzer_dump_close(wtap_dumper *wdh, int *err);
-int lanalyzer_open(wtap *wth, int *err, gchar **err_info)
+wtap_open_return_val lanalyzer_open(wtap *wth, int *err, gchar **err_info)
{
LA_RecordHeader rec_header;
char header_fixed[2];
@@ -292,14 +292,14 @@ int lanalyzer_open(wtap *wth, int *err, gchar **err_info)
if (!wtap_read_bytes(wth->fh, &rec_header, LA_RecordHeaderSize,
err, err_info)) {
if (*err != WTAP_ERR_SHORT_READ)
- return -1;
- return 0;
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
}
record_type = pletoh16(rec_header.record_type);
record_length = pletoh16(rec_header.record_length); /* make sure to do this for while() loop */
if (record_type != RT_HeaderRegular && record_type != RT_HeaderCyclic) {
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
/* Read the major and minor version numbers */
@@ -308,13 +308,13 @@ int lanalyzer_open(wtap *wth, int *err, gchar **err_info)
* Not enough room for the major and minor version numbers.
* Just treat that as a "not a LANalyzer file" indication.
*/
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
if (!wtap_read_bytes(wth->fh, &header_fixed, sizeof header_fixed,
err, err_info)) {
if (*err != WTAP_ERR_SHORT_READ)
- return -1;
- return 0;
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
}
record_length -= sizeof header_fixed;
@@ -324,8 +324,8 @@ int lanalyzer_open(wtap *wth, int *err, gchar **err_info)
if (!wtap_read_bytes(wth->fh, comment, record_length,
err, err_info)) {
if (*err != WTAP_ERR_SHORT_READ)
- return -1;
- return 0;
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
}
comment[record_length] = '\0';
wth->shb_hdr.opt_comment = comment;
@@ -351,9 +351,9 @@ int lanalyzer_open(wtap *wth, int *err, gchar **err_info)
* End of file and no packets;
* accept this file.
*/
- return 1;
+ return WTAP_OPEN_MINE;
}
- return -1;
+ return WTAP_OPEN_ERROR;
}
record_type = pletoh16(rec_header.record_type);
@@ -365,7 +365,7 @@ int lanalyzer_open(wtap *wth, int *err, gchar **err_info)
case RT_Summary:
if (!wtap_read_bytes(wth->fh, summary,
sizeof summary, err, err_info))
- return -1;
+ return WTAP_OPEN_ERROR;
/* Assume that the date of the creation of the trace file
* is the same date of the trace. Lanalyzer doesn't
@@ -407,7 +407,7 @@ int lanalyzer_open(wtap *wth, int *err, gchar **err_info)
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
*err_info = g_strdup_printf("lanalyzer: board type %u unknown",
board_type);
- return -1;
+ return WTAP_OPEN_ERROR;
}
break;
@@ -416,13 +416,13 @@ int lanalyzer_open(wtap *wth, int *err, gchar **err_info)
/* Go back header number of bytes so that lanalyzer_read
* can read this header */
if (file_seek(wth->fh, -LA_RecordHeaderSize, SEEK_CUR, err) == -1) {
- return -1;
+ return WTAP_OPEN_ERROR;
}
- return 1;
+ return WTAP_OPEN_MINE;
default:
if (file_seek(wth->fh, record_length, SEEK_CUR, err) == -1) {
- return -1;
+ return WTAP_OPEN_ERROR;
}
break;
}
diff --git a/wiretap/libpcap.c b/wiretap/libpcap.c
index ecdf8922b3..47d1aacbab 100644
--- a/wiretap/libpcap.c
+++ b/wiretap/libpcap.c
@@ -71,7 +71,7 @@ static gboolean libpcap_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
static int libpcap_read_header(wtap *wth, FILE_T fh, int *err, gchar **err_info,
struct pcaprec_ss990915_hdr *hdr);
-int libpcap_open(wtap *wth, int *err, gchar **err_info)
+wtap_open_return_val libpcap_open(wtap *wth, int *err, gchar **err_info)
{
guint32 magic;
struct pcap_hdr hdr;
@@ -107,8 +107,8 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info)
/* Read in the number that should be at the start of a "libpcap" file */
if (!wtap_read_bytes(wth->fh, &magic, sizeof magic, err, err_info)) {
if (*err != WTAP_ERR_SHORT_READ)
- return -1;
- return 0;
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
}
switch (magic) {
@@ -168,12 +168,12 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info)
default:
/* Not a "libpcap" type we know about. */
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
/* Read the rest of the header. */
if (!wtap_read_bytes(wth->fh, &hdr, sizeof hdr, err, err_info))
- return -1;
+ return WTAP_OPEN_ERROR;
if (byte_swapped) {
/* Byte-swap the header fields about which we care. */
@@ -187,7 +187,7 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info)
*err = WTAP_ERR_UNSUPPORTED;
*err_info = g_strdup_printf("pcap: major version %u unsupported",
hdr.version_major);
- return -1;
+ return WTAP_OPEN_ERROR;
}
/*
@@ -256,7 +256,7 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info)
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
*err_info = g_strdup_printf("pcap: network type %u unknown or unsupported",
hdr.network);
- return -1;
+ return WTAP_OPEN_ERROR;
}
/* This is a libpcap file */
@@ -317,7 +317,7 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info)
*/
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_PCAP_AIX;
wth->file_tsprec = WTAP_TSPREC_NSEC;
- return 1;
+ return WTAP_OPEN_MINE;
}
/*
@@ -390,7 +390,7 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info)
* Well, we couldn't even read it.
* Give up.
*/
- return -1;
+ return WTAP_OPEN_ERROR;
}
if (figures_of_merit[i] == 0) {
/*
@@ -398,7 +398,7 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info)
* Put the seek pointer back, and finish.
*/
if (file_seek(wth->fh, first_packet_offset, SEEK_SET, err) == -1) {
- return -1;
+ return WTAP_OPEN_ERROR;
}
goto done;
}
@@ -408,7 +408,7 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info)
* go back to the first packet and try the next one.
*/
if (file_seek(wth->fh, first_packet_offset, SEEK_SET, err) == -1) {
- return -1;
+ return WTAP_OPEN_ERROR;
}
}
@@ -450,7 +450,7 @@ done:
*/
erf_populate_interfaces(wth);
}
- return 1;
+ return WTAP_OPEN_MINE;
}
/* Try to read the first two records of the capture file. */
diff --git a/wiretap/logcat.c b/wiretap/logcat.c
index 63eea918a7..cb6e0067ee 100644
--- a/wiretap/logcat.c
+++ b/wiretap/logcat.c
@@ -236,7 +236,7 @@ static gboolean logcat_seek_read(wtap *wth, gint64 seek_off,
return TRUE;
}
-int logcat_open(wtap *wth, int *err, gchar **err_info)
+wtap_open_return_val logcat_open(wtap *wth, int *err, gchar **err_info)
{
gint version;
gint tmp_version;
@@ -245,29 +245,29 @@ int logcat_open(wtap *wth, int *err, gchar **err_info)
/* check first 3 packets (or 2 or 1 if EOF) versions to check file format is correct */
version = detect_version(wth->fh, err, err_info); /* first packet */
if (version == -1)
- return -1; /* I/O error */
+ return WTAP_OPEN_ERROR; /* I/O error */
if (version == 0)
- return 0; /* not a logcat file */
+ return WTAP_OPEN_NOT_MINE; /* not a logcat file */
if (version == -2)
- return 0; /* empty file, so not any type of file */
+ return WTAP_OPEN_NOT_MINE; /* empty file, so not any type of file */
tmp_version = detect_version(wth->fh, err, err_info); /* second packet */
if (tmp_version == -1)
- return -1; /* I/O error */
+ return WTAP_OPEN_ERROR; /* I/O error */
if (tmp_version == 0)
- return 0; /* not a logcat file */
+ return WTAP_OPEN_NOT_MINE; /* not a logcat file */
if (tmp_version != -2) {
/* we've read two packets; do they have the same version? */
if (tmp_version != version) {
/* no, so this is presumably not a logcat file */
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
tmp_version = detect_version(wth->fh, err, err_info); /* third packet */
if (tmp_version < 0)
- return -1; /* I/O error */
+ return WTAP_OPEN_ERROR; /* I/O error */
if (tmp_version == 0)
- return 0; /* not a logcat file */
+ return WTAP_OPEN_NOT_MINE; /* not a logcat file */
if (tmp_version != -2) {
/*
* we've read three packets and the first two have the same
@@ -275,13 +275,13 @@ int logcat_open(wtap *wth, int *err, gchar **err_info)
*/
if (tmp_version != version) {
/* no, so this is presumably not a logcat file */
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
}
}
if (file_seek(wth->fh, 0, SEEK_SET, err) == -1)
- return -1;
+ return WTAP_OPEN_ERROR;
logcat = (struct logcat_phdr *) g_malloc(sizeof(struct logcat_phdr));
logcat->version = version;
@@ -296,7 +296,7 @@ int logcat_open(wtap *wth, int *err, gchar **err_info)
wth->subtype_seek_read = logcat_seek_read;
wth->file_tsprec = WTAP_TSPREC_USEC;
- return 1;
+ return WTAP_OPEN_MINE;
}
int logcat_dump_can_write_encap(int encap)
diff --git a/wiretap/logcat_text.c b/wiretap/logcat_text.c
index 546fd1c5a5..9b797f38d9 100644
--- a/wiretap/logcat_text.c
+++ b/wiretap/logcat_text.c
@@ -257,12 +257,12 @@ static gboolean logcat_text_seek_read(wtap *wth, gint64 seek_off,
return TRUE;
}
-int logcat_text_open(wtap *wth, int *err, gchar **err_info _U_) {
+wtap_open_return_val logcat_text_open(wtap *wth, int *err, gchar **err_info _U_) {
gchar cbuff[WTAP_MAX_PACKET_SIZE];
gchar *ret = NULL;
if (file_seek(wth->fh, 0, SEEK_SET, err) == -1)
- return -1;
+ return WTAP_OPEN_ERROR;
do {
ret = file_gets(cbuff, WTAP_MAX_PACKET_SIZE, wth->fh);
@@ -300,18 +300,18 @@ int logcat_text_open(wtap *wth, int *err, gchar **err_info _U_) {
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_LOGCAT_LONG;
wth->file_encap = WTAP_ENCAP_LOGCAT_LONG;
} else {
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
if (file_seek(wth->fh, 0, SEEK_SET, err) == -1)
- return -1;
+ return WTAP_OPEN_ERROR;
wth->snapshot_length = 0;
wth->subtype_read = logcat_text_read;
wth->subtype_seek_read = logcat_text_seek_read;
wth->file_tsprec = WTAP_TSPREC_USEC;
- return 1;
+ return WTAP_OPEN_MINE;
}
int logcat_text_brief_dump_can_write_encap(int encap) {
diff --git a/wiretap/mime_file.c b/wiretap/mime_file.c
index 7b67dbe830..f42ac76b9d 100644
--- a/wiretap/mime_file.c
+++ b/wiretap/mime_file.c
@@ -161,7 +161,7 @@ mime_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf
return mime_read_file(wth, wth->random_fh, phdr, buf, err, err_info);
}
-int
+wtap_open_return_val
mime_file_open(wtap *wth, int *err, gchar **err_info)
{
char magic_buf[128]; /* increase buffer size when needed */
@@ -180,10 +180,10 @@ mime_file_open(wtap *wth, int *err, gchar **err_info)
if (bytes_read < 0) {
*err = file_error(wth->fh, err_info);
- return -1;
+ return WTAP_OPEN_ERROR;
}
if (bytes_read == 0)
- return 0;
+ return WTAP_OPEN_NOT_MINE;
found_file = FALSE;
for (i = 0; i < N_MAGIC_TYPES; i++) {
@@ -192,15 +192,15 @@ mime_file_open(wtap *wth, int *err, gchar **err_info)
found_file = TRUE;
/* file_ok = i; */
} else
- return 0; /* many files matched, bad file */
+ return WTAP_OPEN_NOT_MINE; /* many files matched, bad file */
}
}
if (!found_file)
- return 0;
+ return WTAP_OPEN_NOT_MINE;
if (file_seek(wth->fh, 0, SEEK_SET, err) == -1)
- return -1;
+ return WTAP_OPEN_ERROR;
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_MIME;
wth->file_encap = WTAP_ENCAP_MIME;
@@ -209,5 +209,5 @@ mime_file_open(wtap *wth, int *err, gchar **err_info)
wth->subtype_seek_read = mime_seek_read;
wth->snapshot_length = 0;
- return 1;
+ return WTAP_OPEN_MINE;
}
diff --git a/wiretap/mp2t.c b/wiretap/mp2t.c
index 72e566c0d6..da82a2c809 100644
--- a/wiretap/mp2t.c
+++ b/wiretap/mp2t.c
@@ -140,7 +140,7 @@ mp2t_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
return TRUE;
}
-int
+wtap_open_return_val
mp2t_open(wtap *wth, int *err, gchar **err_info)
{
guint8 buffer[MP2T_SIZE+TRAILER_LEN_MAX];
@@ -153,8 +153,8 @@ mp2t_open(wtap *wth, int *err, gchar **err_info)
if (!wtap_read_bytes(wth->fh, buffer, MP2T_SIZE, err, err_info)) {
if (*err != WTAP_ERR_SHORT_READ)
- return -1;
- return 0;
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
}
first = -1;
@@ -165,18 +165,18 @@ mp2t_open(wtap *wth, int *err, gchar **err_info)
}
}
if (-1 == first) {
- return 0; /* wrong file type - not an mpeg2 ts file */
+ return WTAP_OPEN_NOT_MINE; /* wrong file type - not an mpeg2 ts file */
}
if (-1 == file_seek(wth->fh, first, SEEK_SET, err)) {
- return -1;
+ return WTAP_OPEN_ERROR;
}
/* read some packets and make sure they all start with a sync byte */
do {
if (!wtap_read_bytes(wth->fh, buffer, MP2T_SIZE+trailer_len, err, err_info)) {
if (*err != WTAP_ERR_SHORT_READ)
- return -1; /* read error */
- if(sync_steps<2) return 0; /* wrong file type - not an mpeg2 ts file */
+ return WTAP_OPEN_ERROR; /* read error */
+ if(sync_steps<2) return WTAP_OPEN_NOT_MINE; /* wrong file type - not an mpeg2 ts file */
break; /* end of file, that's ok if we're still in sync */
}
if (buffer[0] == MP2T_SYNC_BYTE) {
@@ -189,14 +189,14 @@ mp2t_open(wtap *wth, int *err, gchar **err_info)
/* if we've already detected a trailer field, we must remain in sync
another mismatch means we have no mpeg2 ts file */
if (trailer_len>0)
- return 0;
+ return WTAP_OPEN_NOT_MINE;
/* check if a trailer is appended to the packet */
for (i=0; i<TRAILER_LEN_MAX; i++) {
if (buffer[i] == MP2T_SYNC_BYTE) {
trailer_len = i;
if (-1 == file_seek(wth->fh, first, SEEK_SET, err)) {
- return -1;
+ return WTAP_OPEN_ERROR;
}
sync_steps = 0;
break;
@@ -204,12 +204,12 @@ mp2t_open(wtap *wth, int *err, gchar **err_info)
}
/* no sync byte found in the vicinity, this is no mpeg2 ts file */
if (i==TRAILER_LEN_MAX)
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
} while (sync_steps < SYNC_STEPS);
if (-1 == file_seek(wth->fh, first, SEEK_SET, err)) {
- return -1;
+ return WTAP_OPEN_ERROR;
}
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_MPEG_2_TS;
@@ -220,13 +220,10 @@ mp2t_open(wtap *wth, int *err, gchar **err_info)
wth->snapshot_length = 0;
mp2t = (mp2t_filetype_t*) g_malloc(sizeof(mp2t_filetype_t));
- if (NULL == mp2t) {
- return -1;
- }
wth->priv = mp2t;
mp2t->start_offset = first;
mp2t->trailer_len = trailer_len;
- return 1;
+ return WTAP_OPEN_MINE;
}
diff --git a/wiretap/mpeg.c b/wiretap/mpeg.c
index 00ff23e9bb..304d1d73cc 100644
--- a/wiretap/mpeg.c
+++ b/wiretap/mpeg.c
@@ -231,7 +231,7 @@ struct _mpeg_magic {
{ 0, NULL }
};
-int
+wtap_open_return_val
mpeg_open(wtap *wth, int *err, gchar **err_info)
{
char magic_buf[16];
@@ -241,8 +241,8 @@ mpeg_open(wtap *wth, int *err, gchar **err_info)
if (!wtap_read_bytes(wth->fh, magic_buf, sizeof magic_buf,
err, err_info)) {
if (*err != WTAP_ERR_SHORT_READ)
- return -1;
- return 0;
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
}
for (m=magic; m->match; m++) {
@@ -250,12 +250,12 @@ mpeg_open(wtap *wth, int *err, gchar **err_info)
goto good_magic;
}
- return 0;
+ return WTAP_OPEN_NOT_MINE;
good_magic:
/* This appears to be a file with MPEG data. */
if (file_seek(wth->fh, 0, SEEK_SET, err) == -1)
- return -1;
+ return WTAP_OPEN_ERROR;
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_MPEG;
wth->file_encap = WTAP_ENCAP_MPEG;
@@ -270,5 +270,5 @@ good_magic:
mpeg->now.nsecs = 0;
mpeg->t0 = mpeg->now.secs;
- return 1;
+ return WTAP_OPEN_MINE;
}
diff --git a/wiretap/netmon.c b/wiretap/netmon.c
index 684509aeb6..9c0813f6ea 100644
--- a/wiretap/netmon.c
+++ b/wiretap/netmon.c
@@ -186,7 +186,7 @@ static gboolean netmon_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
const guint8 *pd, int *err);
static gboolean netmon_dump_close(wtap_dumper *wdh, int *err);
-int netmon_open(wtap *wth, int *err, gchar **err_info)
+wtap_open_return_val netmon_open(wtap *wth, int *err, gchar **err_info)
{
char magic[MAGIC_SIZE];
struct netmon_hdr hdr;
@@ -205,18 +205,18 @@ int netmon_open(wtap *wth, int *err, gchar **err_info)
* Monitor file */
if (!wtap_read_bytes(wth->fh, magic, MAGIC_SIZE, err, err_info)) {
if (*err != WTAP_ERR_SHORT_READ)
- return -1;
- return 0;
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
}
if (memcmp(magic, netmon_1_x_magic, MAGIC_SIZE) != 0 &&
memcmp(magic, netmon_2_x_magic, MAGIC_SIZE) != 0) {
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
/* Read the rest of the header. */
if (!wtap_read_bytes(wth->fh, &hdr, sizeof hdr, err, err_info))
- return -1;
+ return WTAP_OPEN_ERROR;
switch (hdr.ver_major) {
@@ -231,7 +231,7 @@ int netmon_open(wtap *wth, int *err, gchar **err_info)
default:
*err = WTAP_ERR_UNSUPPORTED;
*err_info = g_strdup_printf("netmon: major version %u unsupported", hdr.ver_major);
- return -1;
+ return WTAP_OPEN_ERROR;
}
hdr.network = pletoh16(&hdr.network);
@@ -240,7 +240,7 @@ int netmon_open(wtap *wth, int *err, gchar **err_info)
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
*err_info = g_strdup_printf("netmon: network type %u unknown or unsupported",
hdr.network);
- return -1;
+ return WTAP_OPEN_ERROR;
}
/* This is a netmon file */
@@ -321,13 +321,13 @@ int netmon_open(wtap *wth, int *err, gchar **err_info)
*err = WTAP_ERR_BAD_FILE;
*err_info = g_strdup_printf("netmon: frame table length is %u, which is not a multiple of the size of an entry",
frame_table_length);
- return -1;
+ return WTAP_OPEN_ERROR;
}
if (frame_table_size == 0) {
*err = WTAP_ERR_BAD_FILE;
*err_info = g_strdup_printf("netmon: frame table length is %u, which means it's less than one entry in size",
frame_table_length);
- return -1;
+ return WTAP_OPEN_ERROR;
}
/*
* XXX - clamp the size of the frame table, so that we don't
@@ -346,20 +346,20 @@ int netmon_open(wtap *wth, int *err, gchar **err_info)
*err = WTAP_ERR_BAD_FILE;
*err_info = g_strdup_printf("netmon: frame table length is %u, which is larger than we support",
frame_table_length);
- return -1;
+ return WTAP_OPEN_ERROR;
}
if (file_seek(wth->fh, frame_table_offset, SEEK_SET, err) == -1) {
- return -1;
+ return WTAP_OPEN_ERROR;
}
frame_table = (guint32 *)g_try_malloc(frame_table_length);
if (frame_table_length != 0 && frame_table == NULL) {
*err = ENOMEM; /* we assume we're out of memory */
- return -1;
+ return WTAP_OPEN_ERROR;
}
if (!wtap_read_bytes(wth->fh, frame_table, frame_table_length,
err, err_info)) {
g_free(frame_table);
- return -1;
+ return WTAP_OPEN_ERROR;
}
netmon->frame_table_size = frame_table_size;
netmon->frame_table = frame_table;
diff --git a/wiretap/netscaler.c b/wiretap/netscaler.c
index 1c28c5f11b..60d1427c65 100644
--- a/wiretap/netscaler.c
+++ b/wiretap/netscaler.c
@@ -667,7 +667,7 @@ static guint64 ns_hrtime2nsec(guint32 tm)
/*
** Netscaler trace format open routines
*/
-int nstrace_open(wtap *wth, int *err, gchar **err_info)
+wtap_open_return_val nstrace_open(wtap *wth, int *err, gchar **err_info)
{
gchar *nstrace_buf;
gint64 file_size;
@@ -676,7 +676,7 @@ int nstrace_open(wtap *wth, int *err, gchar **err_info)
if ((file_size = wtap_file_size(wth, err)) == -1)
- return 0;
+ return WTAP_OPEN_NOT_MINE;
nstrace_buf = (gchar *)g_malloc(NSPR_PAGESIZE);
page_size = GET_READ_PAGE_SIZE(file_size);
@@ -701,22 +701,21 @@ int nstrace_open(wtap *wth, int *err, gchar **err_info)
default:
/* No known signature found, assume it's not NetScaler */
g_free(nstrace_buf);
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
if ((file_seek(wth->fh, 0, SEEK_SET, err)) == -1)
{
- *err = file_error(wth->fh, err_info);
g_free(nstrace_buf);
- return 0;
+ return WTAP_OPEN_ERROR;
}
if (!wtap_read_bytes(wth->fh, nstrace_buf, page_size, err, err_info))
{
g_free(nstrace_buf);
if (*err != WTAP_ERR_SHORT_READ)
- return -1;
- return 0;
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
}
switch (wth->file_type_subtype)
@@ -759,7 +758,7 @@ int nstrace_open(wtap *wth, int *err, gchar **err_info)
{
g_free(nstrace->pnstrace_buf);
g_free(nstrace);
- return -1;
+ return WTAP_OPEN_ERROR;
}
/* Read the first page of data */
@@ -767,7 +766,7 @@ int nstrace_open(wtap *wth, int *err, gchar **err_info)
{
g_free(nstrace->pnstrace_buf);
g_free(nstrace);
- return -1;
+ return WTAP_OPEN_ERROR;
}
/* reset the buffer offset */
@@ -779,7 +778,7 @@ int nstrace_open(wtap *wth, int *err, gchar **err_info)
wth->phdr.ts.nsecs = 0;
*err = 0;
- return 1;
+ return WTAP_OPEN_MINE;
}
diff --git a/wiretap/netscreen.c b/wiretap/netscreen.c
index 61b32834ee..b34312fd84 100644
--- a/wiretap/netscreen.c
+++ b/wiretap/netscreen.c
@@ -166,18 +166,18 @@ static gboolean netscreen_check_file_type(wtap *wth, int *err, gchar **err_info)
}
-int netscreen_open(wtap *wth, int *err, gchar **err_info)
+wtap_open_return_val netscreen_open(wtap *wth, int *err, gchar **err_info)
{
/* Look for a NetScreen snoop header line */
if (!netscreen_check_file_type(wth, err, err_info)) {
if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
- return -1;
- return 0;
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
}
if (file_seek(wth->fh, 0L, SEEK_SET, err) == -1) /* rewind */
- return -1;
+ return WTAP_OPEN_ERROR;
wth->file_encap = WTAP_ENCAP_UNKNOWN;
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_NETSCREEN;
@@ -186,7 +186,7 @@ int netscreen_open(wtap *wth, int *err, gchar **err_info)
wth->subtype_seek_read = netscreen_seek_read;
wth->file_tsprec = WTAP_TSPREC_DSEC;
- return 1;
+ return WTAP_OPEN_MINE;
}
/* Find the next packet and parse it; called from wtap_read(). */
diff --git a/wiretap/nettl.c b/wiretap/nettl.c
index b45652d4c4..f859c2e265 100644
--- a/wiretap/nettl.c
+++ b/wiretap/nettl.c
@@ -185,7 +185,7 @@ static gboolean nettl_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
static gboolean nettl_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
const guint8 *pd, int *err);
-int nettl_open(wtap *wth, int *err, gchar **err_info)
+wtap_open_return_val nettl_open(wtap *wth, int *err, gchar **err_info)
{
struct nettl_file_hdr file_hdr;
guint16 dummy[2];
@@ -197,19 +197,19 @@ int nettl_open(wtap *wth, int *err, gchar **err_info)
/* Read in the string that should be at the start of a HP file */
if (!wtap_read_bytes(wth->fh, file_hdr.magic, MAGIC_SIZE, err, err_info)) {
if (*err != WTAP_ERR_SHORT_READ)
- return -1;
- return 0;
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
}
if (memcmp(file_hdr.magic, nettl_magic_hpux9, MAGIC_SIZE) &&
memcmp(file_hdr.magic, nettl_magic_hpux10, MAGIC_SIZE)) {
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
/* Read the rest of the file header */
if (!wtap_read_bytes(wth->fh, file_hdr.file_name, FILE_HDR_SIZE - MAGIC_SIZE,
err, err_info))
- return -1;
+ return WTAP_OPEN_ERROR;
/* This is an nettl file */
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_NETTL;
@@ -227,9 +227,9 @@ int nettl_open(wtap *wth, int *err, gchar **err_info)
if (!wtap_read_bytes_or_eof(wth->fh, dummy, 4, err, err_info)) {
if (*err == 0) {
/* EOF, so no records */
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
- return -1;
+ return WTAP_OPEN_ERROR;
}
subsys = g_ntohs(dummy[1]);
@@ -266,11 +266,11 @@ int nettl_open(wtap *wth, int *err, gchar **err_info)
}
if (file_seek(wth->fh, FILE_HDR_SIZE, SEEK_SET, err) == -1) {
- return -1;
+ return WTAP_OPEN_ERROR;
}
wth->file_tsprec = WTAP_TSPREC_USEC;
- return 1;
+ return WTAP_OPEN_MINE;
}
/* Read the next packet */
diff --git a/wiretap/network_instruments.c b/wiretap/network_instruments.c
index 64b96375b6..1e2b6d4386 100644
--- a/wiretap/network_instruments.c
+++ b/wiretap/network_instruments.c
@@ -112,7 +112,7 @@ static gboolean observer_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
static gint observer_to_wtap_encap(int observer_encap);
static gint wtap_to_observer_encap(int wtap_encap);
-int network_instruments_open(wtap *wth, int *err, gchar **err_info)
+wtap_open_return_val network_instruments_open(wtap *wth, int *err, gchar **err_info)
{
int offset;
capture_file_header file_header;
@@ -129,15 +129,15 @@ int network_instruments_open(wtap *wth, int *err, gchar **err_info)
if (!wtap_read_bytes(wth->fh, &file_header, sizeof file_header,
err, err_info)) {
if (*err != WTAP_ERR_SHORT_READ)
- return -1;
- return 0;
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
}
offset += (int)sizeof file_header;
CAPTURE_FILE_HEADER_FROM_LE_IN_PLACE(file_header);
/* check if version info is present */
if (memcmp(file_header.observer_version, network_instruments_magic, true_magic_length)!=0) {
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
/* initialize the private state */
@@ -157,7 +157,7 @@ int network_instruments_open(wtap *wth, int *err, gchar **err_info)
/* read the TLV header */
if (!wtap_read_bytes(wth->fh, &tlvh, sizeof tlvh, err, err_info))
- return -1;
+ return WTAP_OPEN_ERROR;
offset += (int)sizeof tlvh;
TLV_HEADER_FROM_LE_IN_PLACE(tlvh);
@@ -165,7 +165,7 @@ int network_instruments_open(wtap *wth, int *err, gchar **err_info)
*err = WTAP_ERR_BAD_FILE;
*err_info = g_strdup_printf("Observer: bad record (TLV length %u < %lu)",
tlvh.length, (unsigned long)sizeof tlvh);
- return -1;
+ return WTAP_OPEN_ERROR;
}
/* process (or skip over) the current TLV */
@@ -174,7 +174,7 @@ int network_instruments_open(wtap *wth, int *err, gchar **err_info)
if (!wtap_read_bytes(wth->fh, &private_state->time_format,
sizeof private_state->time_format,
err, err_info))
- return -1;
+ return WTAP_OPEN_ERROR;
private_state->time_format = GUINT32_FROM_LE(private_state->time_format);
offset += (int)sizeof private_state->time_format;
break;
@@ -182,7 +182,7 @@ int network_instruments_open(wtap *wth, int *err, gchar **err_info)
seek_increment = tlvh.length - (int)sizeof tlvh;
if (seek_increment > 0) {
if (file_seek(wth->fh, seek_increment, SEEK_CUR, err) == -1)
- return -1;
+ return WTAP_OPEN_ERROR;
}
offset += seek_increment;
}
@@ -193,32 +193,32 @@ int network_instruments_open(wtap *wth, int *err, gchar **err_info)
*err = WTAP_ERR_BAD_FILE;
*err_info = g_strdup_printf("Observer: bad record (offset to first packet %d < %d)",
header_offset, offset);
- return -1;
+ return WTAP_OPEN_ERROR;
}
seek_increment = header_offset - offset;
if (seek_increment > 0) {
if (file_seek(wth->fh, seek_increment, SEEK_CUR, err) == -1)
- return -1;
+ return WTAP_OPEN_ERROR;
}
/* pull off the packet header */
if (!wtap_read_bytes(wth->fh, &packet_header, sizeof packet_header,
err, err_info))
- return -1;
+ return WTAP_OPEN_ERROR;
PACKET_ENTRY_HEADER_FROM_LE_IN_PLACE(packet_header);
/* check the packet's magic number */
if (packet_header.packet_magic != observer_packet_magic) {
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
*err_info = g_strdup_printf("Observer: unsupported packet version %ul", packet_header.packet_magic);
- return -1;
+ return WTAP_OPEN_ERROR;
}
/* check the data link type */
if (observer_to_wtap_encap(packet_header.network_type) == WTAP_ENCAP_UNKNOWN) {
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
*err_info = g_strdup_printf("Observer: network type %u unknown or unsupported", packet_header.network_type);
- return -1;
+ return WTAP_OPEN_ERROR;
}
wth->file_encap = observer_to_wtap_encap(packet_header.network_type);
@@ -235,11 +235,11 @@ int network_instruments_open(wtap *wth, int *err, gchar **err_info)
/* reset the pointer to the first packet */
if (file_seek(wth->fh, header_offset, SEEK_SET, err) == -1)
- return -1;
+ return WTAP_OPEN_ERROR;
init_gmt_to_localtime_offset();
- return 1;
+ return WTAP_OPEN_MINE;
}
/* Reads the next packet. */
diff --git a/wiretap/netxray.c b/wiretap/netxray.c
index d6d37535a9..4061a6ee61 100644
--- a/wiretap/netxray.c
+++ b/wiretap/netxray.c
@@ -419,7 +419,7 @@ static gboolean netxray_dump_2_0(wtap_dumper *wdh,
const guint8 *pd, int *err);
static gboolean netxray_dump_close_2_0(wtap_dumper *wdh, int *err);
-int
+wtap_open_return_val
netxray_open(wtap *wth, int *err, gchar **err_info)
{
char magic[MAGIC_SIZE];
@@ -462,8 +462,8 @@ netxray_open(wtap *wth, int *err, gchar **err_info)
* file */
if (!wtap_read_bytes(wth->fh, magic, MAGIC_SIZE, err, err_info)) {
if (*err != WTAP_ERR_SHORT_READ)
- return -1;
- return 0;
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
}
if (memcmp(magic, netxray_magic, MAGIC_SIZE) == 0) {
@@ -471,12 +471,12 @@ netxray_open(wtap *wth, int *err, gchar **err_info)
} else if (memcmp(magic, old_netxray_magic, MAGIC_SIZE) == 0) {
is_old = TRUE;
} else {
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
/* Read the rest of the header. */
if (!wtap_read_bytes(wth->fh, &hdr, sizeof hdr, err, err_info))
- return -1;
+ return WTAP_OPEN_ERROR;
if (is_old) {
version_major = 0;
@@ -517,7 +517,7 @@ netxray_open(wtap *wth, int *err, gchar **err_info)
} else {
*err = WTAP_ERR_UNSUPPORTED;
*err_info = g_strdup_printf("netxray: version \"%.8s\" unsupported", hdr.version);
- return -1;
+ return WTAP_OPEN_ERROR;
}
}
@@ -546,7 +546,7 @@ netxray_open(wtap *wth, int *err, gchar **err_info)
*err = WTAP_ERR_UNSUPPORTED;
*err_info = g_strdup_printf("netxray: the byte after the network type has the value %u, which I don't understand",
hdr.network_plus);
- return -1;
+ return WTAP_OPEN_ERROR;
}
if (network_type >= NUM_NETXRAY_ENCAPS
@@ -554,7 +554,7 @@ netxray_open(wtap *wth, int *err, gchar **err_info)
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
*err_info = g_strdup_printf("netxray: network type %u (%u) unknown or unsupported",
network_type, hdr.network_plus);
- return -1;
+ return WTAP_OPEN_ERROR;
}
/*
@@ -605,7 +605,7 @@ netxray_open(wtap *wth, int *err, gchar **err_info)
*err_info = g_strdup_printf(
"netxray: Unknown timeunit %u for Ethernet/CAPTYPE_NDIS version %.8s capture",
hdr.timeunit, hdr.version);
- return -1;
+ return WTAP_OPEN_ERROR;
}
/*
XXX: 05/29/07: Use 'realtick' instead of TpS table if timeunit=2;
@@ -629,7 +629,7 @@ netxray_open(wtap *wth, int *err, gchar **err_info)
*err_info = g_strdup_printf(
"netxray: Unknown timeunit %u for Ethernet/ETH_CAPTYPE_GIGPOD version %.8s capture",
hdr.timeunit, hdr.version);
- return -1;
+ return WTAP_OPEN_ERROR;
}
ticks_per_sec = TpS_gigpod[hdr.timeunit];
@@ -649,7 +649,7 @@ netxray_open(wtap *wth, int *err, gchar **err_info)
*err_info = g_strdup_printf(
"netxray: Unknown timeunit %u for Ethernet/ETH_CAPTYPE_OTHERPOD version %.8s capture",
hdr.timeunit, hdr.version);
- return -1;
+ return WTAP_OPEN_ERROR;
}
ticks_per_sec = TpS_otherpod[hdr.timeunit];
@@ -669,7 +669,7 @@ netxray_open(wtap *wth, int *err, gchar **err_info)
*err_info = g_strdup_printf(
"netxray: Unknown timeunit %u for Ethernet/ETH_CAPTYPE_OTHERPOD2 version %.8s capture",
hdr.timeunit, hdr.version);
- return -1;
+ return WTAP_OPEN_ERROR;
}
ticks_per_sec = TpS_otherpod2[hdr.timeunit];
/*
@@ -691,7 +691,7 @@ netxray_open(wtap *wth, int *err, gchar **err_info)
*err_info = g_strdup_printf(
"netxray: Unknown timeunit %u for Ethernet/ETH_CAPTYPE_GIGPOD2 version %.8s capture",
hdr.timeunit, hdr.version);
- return -1;
+ return WTAP_OPEN_ERROR;
}
ticks_per_sec = TpS_gigpod2[hdr.timeunit];
/*
@@ -711,7 +711,7 @@ netxray_open(wtap *wth, int *err, gchar **err_info)
*err_info = g_strdup_printf(
"netxray: Unknown capture type %u for Ethernet version %.8s capture",
hdr.captype, hdr.version);
- return -1;
+ return WTAP_OPEN_ERROR;
}
break;
@@ -722,7 +722,7 @@ netxray_open(wtap *wth, int *err, gchar **err_info)
"netxray: Unknown timeunit %u for %u/%u version %.8s capture",
hdr.timeunit, network_type, hdr.captype,
hdr.version);
- return -1;
+ return WTAP_OPEN_ERROR;
}
ticks_per_sec = TpS[hdr.timeunit];
break;
@@ -816,7 +816,7 @@ netxray_open(wtap *wth, int *err, gchar **err_info)
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
*err_info = g_strdup_printf("netxray: WAN HDLC capture subsubtype 0x%02x unknown or unsupported",
hdr.wan_hdlc_subsub_captype);
- return -1;
+ return WTAP_OPEN_ERROR;
}
break;
@@ -838,7 +838,7 @@ netxray_open(wtap *wth, int *err, gchar **err_info)
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
*err_info = g_strdup_printf("netxray: WAN capture subtype 0x%02x unknown or unsupported",
hdr.captype);
- return -1;
+ return WTAP_OPEN_ERROR;
}
} else
file_encap = WTAP_ENCAP_ETHERNET;
@@ -972,10 +972,10 @@ netxray_open(wtap *wth, int *err, gchar **err_info)
/* Seek to the beginning of the data records. */
if (file_seek(wth->fh, netxray->start_offset, SEEK_SET, err) == -1) {
- return -1;
+ return WTAP_OPEN_ERROR;
}
- return 1;
+ return WTAP_OPEN_MINE;
}
/* Read the next packet */
diff --git a/wiretap/ngsniffer.c b/wiretap/ngsniffer.c
index df4b30cc6e..6c71aad6b2 100644
--- a/wiretap/ngsniffer.c
+++ b/wiretap/ngsniffer.c
@@ -541,7 +541,7 @@ static gboolean ng_file_skip_seq(wtap *wth, gint64 delta, int *err,
static gboolean ng_file_seek_rand(wtap *wth, gint64 offset, int *err,
gchar **err_info);
-int
+wtap_open_return_val
ngsniffer_open(wtap *wth, int *err, gchar **err_info)
{
char magic[sizeof ngsniffer_magic];
@@ -576,12 +576,12 @@ ngsniffer_open(wtap *wth, int *err, gchar **err_info)
/* Read in the string that should be at the start of a Sniffer file */
if (!wtap_read_bytes(wth->fh, magic, sizeof magic, err, err_info)) {
if (*err != WTAP_ERR_SHORT_READ)
- return -1;
- return 0;
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
}
if (memcmp(magic, ngsniffer_magic, sizeof ngsniffer_magic)) {
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
/*
@@ -589,20 +589,20 @@ ngsniffer_open(wtap *wth, int *err, gchar **err_info)
* record.
*/
if (!wtap_read_bytes(wth->fh, record_type, 2, err, err_info))
- return -1;
+ return WTAP_OPEN_ERROR;
if (!wtap_read_bytes(wth->fh, record_length, 4, err, err_info))
- return -1;
+ return WTAP_OPEN_ERROR;
type = pletoh16(record_type);
if (type != REC_VERS) {
*err = WTAP_ERR_BAD_FILE;
*err_info = g_strdup_printf("ngsniffer: Sniffer file doesn't start with a version record");
- return -1;
+ return WTAP_OPEN_ERROR;
}
if (!wtap_read_bytes(wth->fh, &version, sizeof version, err, err_info))
- return -1;
+ return WTAP_OPEN_ERROR;
/* Check the data link type. */
if (version.network >= NUM_NGSNIFF_ENCAPS
@@ -610,14 +610,14 @@ ngsniffer_open(wtap *wth, int *err, gchar **err_info)
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
*err_info = g_strdup_printf("ngsniffer: network type %u unknown or unsupported",
version.network);
- return -1;
+ return WTAP_OPEN_ERROR;
}
/* Check the time unit */
if (version.timeunit >= NUM_NGSNIFF_TIMEUNITS) {
*err = WTAP_ERR_UNSUPPORTED;
*err_info = g_strdup_printf("ngsniffer: Unknown timeunit %u", version.timeunit);
- return -1;
+ return WTAP_OPEN_ERROR;
}
/* compressed or uncompressed Sniffer file? */
@@ -648,7 +648,7 @@ ngsniffer_open(wtap *wth, int *err, gchar **err_info)
maj_vers = pletoh16(&version.maj_vers);
if (process_header_records(wth, err, err_info, maj_vers,
version.network) < 0)
- return -1;
+ return WTAP_OPEN_ERROR;
if ((version.network == NETWORK_SYNCHRO ||
version.network == NETWORK_ASYNC) &&
wth->file_encap == WTAP_ENCAP_PER_PACKET) {
@@ -698,7 +698,7 @@ ngsniffer_open(wtap *wth, int *err, gchar **err_info)
*/
if (wth->random_fh != NULL) {
if (file_seek(wth->random_fh, current_offset, SEEK_SET, err) == -1)
- return -1;
+ return WTAP_OPEN_ERROR;
}
/* This is a ngsniffer file */
@@ -770,7 +770,7 @@ ngsniffer_open(wtap *wth, int *err, gchar **err_info)
wth->file_tsprec = WTAP_TSPREC_NSEC; /* XXX */
- return 1;
+ return WTAP_OPEN_MINE;
}
static int
diff --git a/wiretap/packetlogger.c b/wiretap/packetlogger.c
index c8235fd5f8..e94b9c1c04 100644
--- a/wiretap/packetlogger.c
+++ b/wiretap/packetlogger.c
@@ -55,31 +55,31 @@ static gboolean packetlogger_read_packet(FILE_T fh, struct wtap_pkthdr *phdr,
Buffer *buf, int *err,
gchar **err_info);
-int packetlogger_open(wtap *wth, int *err, gchar **err_info)
+wtap_open_return_val packetlogger_open(wtap *wth, int *err, gchar **err_info)
{
packetlogger_header_t pl_hdr;
guint8 type;
if(!packetlogger_read_header(&pl_hdr, wth->fh, err, err_info)) {
if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
- return -1;
- return 0;
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
}
if (!wtap_read_bytes(wth->fh, &type, 1, err, err_info)) {
if (*err != WTAP_ERR_SHORT_READ)
- return -1;
- return 0;
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
}
/* Verify this file belongs to us */
if (!((8 <= pl_hdr.len) && (pl_hdr.len < 65536) &&
(type < 0x04 || type == 0xFB || type == 0xFC || type == 0xFE || type == 0xFF)))
- return 0;
+ return WTAP_OPEN_NOT_MINE;
/* No file header. Reset the fh to 0 so we can read the first packet */
if (file_seek(wth->fh, 0, SEEK_SET, err) == -1)
- return -1;
+ return WTAP_OPEN_ERROR;
/* Set up the pointers to the handlers for this file type */
wth->subtype_read = packetlogger_read;
@@ -89,7 +89,7 @@ int packetlogger_open(wtap *wth, int *err, gchar **err_info)
wth->file_encap = WTAP_ENCAP_PACKETLOGGER;
wth->file_tsprec = WTAP_TSPREC_USEC;
- return 1; /* Our kind of file */
+ return WTAP_OPEN_MINE; /* Our kind of file */
}
static gboolean
diff --git a/wiretap/pcapng.c b/wiretap/pcapng.c
index eef773ef8d..5b14294cd3 100644
--- a/wiretap/pcapng.c
+++ b/wiretap/pcapng.c
@@ -2176,7 +2176,7 @@ pcapng_process_idb(wtap *wth, pcapng_t *pcapng, wtapng_block_t *wblock)
}
/* classic wtap: open capture file */
-int
+wtap_open_return_val
pcapng_open(wtap *wth, int *err, gchar **err_info)
{
int bytes_read;
@@ -2206,12 +2206,12 @@ pcapng_open(wtap *wth, int *err, gchar **err_info)
pcapng_free_wtapng_block_data(&wblock);
if (bytes_read == -2) {
pcapng_debug0("pcapng_open: doesn't begin with SHB, probably not a pcap-ng file");
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
pcapng_debug0("pcapng_open: couldn't read first SHB");
if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
- return -1;
- return 0;
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
}
/* first block must be a "Section Header Block" */
@@ -2223,7 +2223,7 @@ pcapng_open(wtap *wth, int *err, gchar **err_info)
*/
pcapng_debug1("pcapng_open: first block type %u not SHB", wblock.type);
pcapng_free_wtapng_block_data(&wblock);
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
pn.shb_read = TRUE;
@@ -2262,7 +2262,7 @@ pcapng_open(wtap *wth, int *err, gchar **err_info)
break;
}
pcapng_debug1("pcapng_open: Check for more IDB:s, wtap_read_bytes_or_eof() failed, err = %d.", *err);
- return -1;
+ return WTAP_OPEN_ERROR;
}
/* go back to where we were */
@@ -2288,13 +2288,13 @@ pcapng_open(wtap *wth, int *err, gchar **err_info)
pcapng_free_wtapng_block_data(&wblock);
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
- return -1;
+ return WTAP_OPEN_ERROR;
}
pcapng_process_idb(wth, pcapng, &wblock);
pcapng_debug2("pcapng_open: Read IDB number_of_interfaces %u, wtap_encap %i",
wth->interface_data->len, wth->file_encap);
}
- return 1;
+ return WTAP_OPEN_MINE;
}
diff --git a/wiretap/peekclassic.c b/wiretap/peekclassic.c
index cfd4c91bef..a1c4ade563 100644
--- a/wiretap/peekclassic.c
+++ b/wiretap/peekclassic.c
@@ -151,7 +151,7 @@ static gboolean peekclassic_seek_read_v56(wtap *wth, gint64 seek_off,
static gboolean peekclassic_read_packet_v56(wtap *wth, FILE_T fh,
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
-int peekclassic_open(wtap *wth, int *err, gchar **err_info)
+wtap_open_return_val peekclassic_open(wtap *wth, int *err, gchar **err_info)
{
peekclassic_header_t ep_hdr;
struct timeval reference_time;
@@ -170,8 +170,8 @@ int peekclassic_open(wtap *wth, int *err, gchar **err_info)
if (!wtap_read_bytes(wth->fh, &ep_hdr.master,
(int)sizeof(ep_hdr.master), err, err_info)) {
if (*err != WTAP_ERR_SHORT_READ)
- return -1;
- return 0;
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
}
/*
@@ -200,15 +200,15 @@ int peekclassic_open(wtap *wth, int *err, gchar **err_info)
if (!wtap_read_bytes(wth->fh, &ep_hdr.secondary.v567,
(int)sizeof(ep_hdr.secondary.v567), err, err_info)) {
if (*err != WTAP_ERR_SHORT_READ)
- return -1;
- return 0;
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
}
if ((0 != ep_hdr.secondary.v567.reserved[0]) ||
(0 != ep_hdr.secondary.v567.reserved[1]) ||
(0 != ep_hdr.secondary.v567.reserved[2])) {
/* still unknown */
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
/*
@@ -245,7 +245,7 @@ int peekclassic_open(wtap *wth, int *err, gchar **err_info)
/*
* Assume this isn't a Peek classic file.
*/
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
break;
@@ -265,7 +265,7 @@ int peekclassic_open(wtap *wth, int *err, gchar **err_info)
/*
* Assume this isn't a Peek classic file.
*/
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
break;
@@ -273,7 +273,7 @@ int peekclassic_open(wtap *wth, int *err, gchar **err_info)
/*
* Assume this isn't a Peek classic file.
*/
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
@@ -309,7 +309,7 @@ int peekclassic_open(wtap *wth, int *err, gchar **err_info)
/*
* Assume this isn't a Peek classic file.
*/
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
/*
@@ -350,7 +350,7 @@ int peekclassic_open(wtap *wth, int *err, gchar **err_info)
wth->snapshot_length = 0; /* not available in header */
wth->file_tsprec = WTAP_TSPREC_USEC;
- return 1;
+ return WTAP_OPEN_MINE;
}
static gboolean peekclassic_read_v7(wtap *wth, int *err, gchar **err_info,
diff --git a/wiretap/peektagged.c b/wiretap/peektagged.c
index d436d60871..b6e8c4e076 100644
--- a/wiretap/peektagged.c
+++ b/wiretap/peektagged.c
@@ -212,7 +212,7 @@ static int wtap_file_read_number (wtap *wth, guint32 *num, int *err,
}
-int peektagged_open(wtap *wth, int *err, gchar **err_info)
+wtap_open_return_val peektagged_open(wtap *wth, int *err, gchar **err_info)
{
peektagged_section_header_t ap_hdr;
int ret;
@@ -231,12 +231,12 @@ int peektagged_open(wtap *wth, int *err, gchar **err_info)
if (!wtap_read_bytes(wth->fh, &ap_hdr, (int)sizeof(ap_hdr), err, err_info)) {
if (*err != WTAP_ERR_SHORT_READ)
- return -1;
- return 0;
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
}
if (memcmp (ap_hdr.section_id, "\177ver", sizeof(ap_hdr.section_id)) != 0)
- return 0; /* doesn't begin with a "\177ver" section */
+ return WTAP_OPEN_NOT_MINE; /* doesn't begin with a "\177ver" section */
/*
* XXX - we should get the length of the "\177ver" section, check
@@ -265,7 +265,7 @@ int peektagged_open(wtap *wth, int *err, gchar **err_info)
*err = WTAP_ERR_UNSUPPORTED;
*err_info = g_strdup_printf("peektagged: version %u unsupported",
fileVersion);
- return -1;
+ return WTAP_OPEN_ERROR;
}
/*
@@ -280,58 +280,58 @@ int peektagged_open(wtap *wth, int *err, gchar **err_info)
*/
ret = wtap_file_read_pattern (wth, "<MediaType>", err, err_info);
if (ret == -1)
- return -1;
+ return WTAP_OPEN_ERROR;
if (ret == 0) {
*err = WTAP_ERR_BAD_FILE;
*err_info = g_strdup("peektagged: <MediaType> tag not found");
- return -1;
+ return WTAP_OPEN_ERROR;
}
/* XXX - this appears to be 0 in both the EtherPeek and AiroPeek
files we've seen; should we require it to be 0? */
ret = wtap_file_read_number (wth, &mediaType, err, err_info);
if (ret == -1)
- return -1;
+ return WTAP_OPEN_ERROR;
if (ret == 0) {
*err = WTAP_ERR_BAD_FILE;
*err_info = g_strdup("peektagged: <MediaType> value not found");
- return -1;
+ return WTAP_OPEN_ERROR;
}
ret = wtap_file_read_pattern (wth, "<MediaSubType>", err, err_info);
if (ret == -1)
- return -1;
+ return WTAP_OPEN_ERROR;
if (ret == 0) {
*err = WTAP_ERR_BAD_FILE;
*err_info = g_strdup("peektagged: <MediaSubType> tag not found");
- return -1;
+ return WTAP_OPEN_ERROR;
}
ret = wtap_file_read_number (wth, &mediaSubType, err, err_info);
if (ret == -1)
- return -1;
+ return WTAP_OPEN_ERROR;
if (ret == 0) {
*err = WTAP_ERR_BAD_FILE;
*err_info = g_strdup("peektagged: <MediaSubType> value not found");
- return -1;
+ return WTAP_OPEN_ERROR;
}
if (mediaSubType >= NUM_PEEKTAGGED_ENCAPS
|| peektagged_encap[mediaSubType] == WTAP_ENCAP_UNKNOWN) {
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
*err_info = g_strdup_printf("peektagged: network type %u unknown or unsupported",
mediaSubType);
- return -1;
+ return WTAP_OPEN_ERROR;
}
ret = wtap_file_read_pattern (wth, "pkts", err, err_info);
if (ret == -1)
- return -1;
+ return WTAP_OPEN_ERROR;
if (ret == 0) {
*err = WTAP_ERR_SHORT_READ;
- return -1;
+ return WTAP_OPEN_ERROR;
}
/* skip 8 zero bytes */
if (file_seek (wth->fh, 8L, SEEK_CUR, err) == -1)
- return 0;
+ return WTAP_OPEN_NOT_MINE;
/*
* This is an Peek tagged file.
@@ -361,7 +361,7 @@ int peektagged_open(wtap *wth, int *err, gchar **err_info)
wth->snapshot_length = 0; /* not available in header */
- return 1;
+ return WTAP_OPEN_MINE;
}
typedef struct {
diff --git a/wiretap/pppdump.c b/wiretap/pppdump.c
index d678eee1d0..3e64ab1783 100644
--- a/wiretap/pppdump.c
+++ b/wiretap/pppdump.c
@@ -242,7 +242,7 @@ init_state(pppdump_t *state)
}
-int
+wtap_open_return_val
pppdump_open(wtap *wth, int *err, gchar **err_info)
{
guint8 buffer[6]; /* Looking for: 0x07 t3 t2 t1 t0 ID */
@@ -259,8 +259,8 @@ pppdump_open(wtap *wth, int *err, gchar **err_info)
if (!wtap_read_bytes(wth->fh, buffer, sizeof(buffer),
err, err_info)) {
if (*err != WTAP_ERR_SHORT_READ)
- return -1;
- return 0;
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
}
if (buffer[0] == PPPD_RESET_TIME &&
@@ -273,13 +273,13 @@ pppdump_open(wtap *wth, int *err, gchar **err_info)
goto my_file_type;
}
else {
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
my_file_type:
if (file_seek(wth->fh, 5, SEEK_SET, err) == -1)
- return -1;
+ return WTAP_OPEN_ERROR;
state = (pppdump_t *)g_malloc(sizeof(pppdump_t));
wth->priv = (void *)state;
@@ -309,7 +309,7 @@ pppdump_open(wtap *wth, int *err, gchar **err_info)
state->pids = NULL;
state->pkt_cnt = 0;
- return 1;
+ return WTAP_OPEN_MINE;
}
/* Set part of the struct wtap_pkthdr. */
diff --git a/wiretap/radcom.c b/wiretap/radcom.c
index 52c7cdc05d..c2f20ab30e 100644
--- a/wiretap/radcom.c
+++ b/wiretap/radcom.c
@@ -91,7 +91,7 @@ static gboolean radcom_seek_read(wtap *wth, gint64 seek_off,
static gboolean radcom_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
Buffer *buf, int *err, gchar **err_info);
-int radcom_open(wtap *wth, int *err, gchar **err_info)
+wtap_open_return_val radcom_open(wtap *wth, int *err, gchar **err_info)
{
guint8 r_magic[8], t_magic[11], search_encap[7];
struct frame_date start_date;
@@ -103,8 +103,8 @@ int radcom_open(wtap *wth, int *err, gchar **err_info)
/* Read in the string that should be at the start of a RADCOM file */
if (!wtap_read_bytes(wth->fh, r_magic, 8, err, err_info)) {
if (*err != WTAP_ERR_SHORT_READ)
- return -1;
- return 0;
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
}
/* XXX: bytes 2 and 3 of the "magic" header seem to be different in some
@@ -114,45 +114,46 @@ int radcom_open(wtap *wth, int *err, gchar **err_info)
r_magic[1] = 0xD2;
r_magic[2] = 0x00;
if (memcmp(r_magic, radcom_magic, 8) != 0) {
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
/* Look for the "Active Time" string. The "frame_date" structure should
* be located 32 bytes before the beginning of this string */
if (!wtap_read_bytes(wth->fh, t_magic, 11, err, err_info)) {
if (*err != WTAP_ERR_SHORT_READ)
- return -1;
- return 0;
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
}
while (memcmp(t_magic, active_time_magic, 11) != 0)
{
if (file_seek(wth->fh, -10, SEEK_CUR, err) == -1)
- return -1;
+ return WTAP_OPEN_ERROR;
if (!wtap_read_bytes(wth->fh, t_magic, 11, err, err_info)) {
if (*err != WTAP_ERR_SHORT_READ)
- return -1;
- return 0;
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
}
}
- if (file_seek(wth->fh, -43, SEEK_CUR, err) == -1) return -1;
+ if (file_seek(wth->fh, -43, SEEK_CUR, err) == -1)
+ return WTAP_OPEN_ERROR;
/* Get capture start time */
if (!wtap_read_bytes(wth->fh, &start_date, sizeof(struct frame_date),
err, err_info)) {
if (*err != WTAP_ERR_SHORT_READ)
- return -1;
- return 0;
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
}
if (file_seek(wth->fh, sizeof(struct frame_date), SEEK_CUR, err) == -1)
- return -1;
+ return WTAP_OPEN_ERROR;
for (;;) {
if (!wtap_read_bytes(wth->fh, search_encap, 4,
err, err_info)) {
if (*err != WTAP_ERR_SHORT_READ)
- return -1;
- return 0;
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
}
if (memcmp(encap_magic, search_encap, 4) == 0)
@@ -165,14 +166,14 @@ int radcom_open(wtap *wth, int *err, gchar **err_info)
* try the 4 bytes at that offset.
*/
if (file_seek(wth->fh, -3, SEEK_CUR, err) == -1)
- return -1;
+ return WTAP_OPEN_ERROR;
}
if (file_seek(wth->fh, 12, SEEK_CUR, err) == -1)
- return -1;
+ return WTAP_OPEN_ERROR;
if (!wtap_read_bytes(wth->fh, search_encap, 4, err, err_info)) {
if (*err != WTAP_ERR_SHORT_READ)
- return -1;
- return 0;
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
}
/* This is a radcom file */
@@ -202,35 +203,35 @@ int radcom_open(wtap *wth, int *err, gchar **err_info)
else {
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
*err_info = g_strdup_printf("radcom: network type \"%.4s\" unknown", search_encap);
- return -1;
+ return WTAP_OPEN_ERROR;
}
#if 0
if (!wtap_read_bytes(wth->fh, &next_date, sizeof(struct frame_date),
err, err_info))
- return -1;
+ return WTAP_OPEN_ERROR;
while (memcmp(&start_date, &next_date, 4)) {
if (file_seek(wth->fh, 1-sizeof(struct frame_date), SEEK_CUR, err) == -1)
- return -1;
+ return WTAP_OPEN_ERROR;
if (!wtap_read_bytes(wth->fh, &next_date, sizeof(struct frame_date),
err, err_info))
- return -1;
+ return WTAP_OPEN_ERROR;
}
#endif
if (wth->file_encap == WTAP_ENCAP_ETHERNET) {
if (file_seek(wth->fh, 294, SEEK_CUR, err) == -1)
- return -1;
+ return WTAP_OPEN_ERROR;
} else if (wth->file_encap == WTAP_ENCAP_LAPB) {
if (file_seek(wth->fh, 297, SEEK_CUR, err) == -1)
- return -1;
+ return WTAP_OPEN_ERROR;
} else if (wth->file_encap == WTAP_ENCAP_ATM_RFC1483) {
if (file_seek(wth->fh, 504, SEEK_CUR, err) == -1)
- return -1;
+ return WTAP_OPEN_ERROR;
}
- return 1;
+ return WTAP_OPEN_MINE;
}
/* Read the next packet */
diff --git a/wiretap/snoop.c b/wiretap/snoop.c
index b8c64f9de9..a3de7aa17f 100644
--- a/wiretap/snoop.c
+++ b/wiretap/snoop.c
@@ -177,7 +177,7 @@ static gboolean snoop_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
* 4MB from 16MB Token Ring, and distinguishing both of them from the
* "Shomiti" versions of same.
*/
-int snoop_open(wtap *wth, int *err, gchar **err_info)
+wtap_open_return_val snoop_open(wtap *wth, int *err, gchar **err_info)
{
char magic[sizeof snoop_magic];
struct snoop_hdr hdr;
@@ -255,17 +255,17 @@ int snoop_open(wtap *wth, int *err, gchar **err_info)
/* Read in the string that should be at the start of a "snoop" file */
if (!wtap_read_bytes(wth->fh, magic, sizeof magic, err, err_info)) {
if (*err != WTAP_ERR_SHORT_READ)
- return -1;
- return 0;
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
}
if (memcmp(magic, snoop_magic, sizeof snoop_magic) != 0) {
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
/* Read the rest of the header. */
if (!wtap_read_bytes(wth->fh, &hdr, sizeof hdr, err, err_info))
- return -1;
+ return WTAP_OPEN_ERROR;
/*
* Make sure it's a version we support.
@@ -284,7 +284,7 @@ int snoop_open(wtap *wth, int *err, gchar **err_info)
default:
*err = WTAP_ERR_UNSUPPORTED;
*err_info = g_strdup_printf("snoop: version %u unsupported", hdr.version);
- return -1;
+ return WTAP_OPEN_ERROR;
}
/*
@@ -321,7 +321,7 @@ int snoop_open(wtap *wth, int *err, gchar **err_info)
saved_offset = file_tell(wth->fh);
if (!wtap_read_bytes_or_eof(wth->fh, &rec_hdr, sizeof rec_hdr, err, err_info)) {
if (*err != 0)
- return -1;
+ return WTAP_OPEN_ERROR;
/*
* The file ends after the record header, which means this
@@ -363,7 +363,7 @@ int snoop_open(wtap *wth, int *err, gchar **err_info)
* Seek back to the beginning of the first record.
*/
if (file_seek(wth->fh, saved_offset, SEEK_SET, err) == -1)
- return -1;
+ return WTAP_OPEN_ERROR;
hdr.network = g_ntohl(hdr.network);
if (is_shomiti) {
@@ -372,7 +372,7 @@ int snoop_open(wtap *wth, int *err, gchar **err_info)
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
*err_info = g_strdup_printf("snoop: Shomiti network type %u unknown or unsupported",
hdr.network);
- return -1;
+ return WTAP_OPEN_ERROR;
}
file_encap = shomiti_encap[hdr.network];
@@ -384,7 +384,7 @@ int snoop_open(wtap *wth, int *err, gchar **err_info)
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
*err_info = g_strdup_printf("snoop: private network type %u unknown or unsupported",
hdr.network);
- return -1;
+ return WTAP_OPEN_ERROR;
}
file_encap = snoop_private_encap[hdr.network^SNOOP_PRIVATE_BIT];
@@ -396,7 +396,7 @@ int snoop_open(wtap *wth, int *err, gchar **err_info)
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
*err_info = g_strdup_printf("snoop: network type %u unknown or unsupported",
hdr.network);
- return -1;
+ return WTAP_OPEN_ERROR;
}
file_encap = snoop_encap[hdr.network];
@@ -414,7 +414,7 @@ int snoop_open(wtap *wth, int *err, gchar **err_info)
wth->file_encap = file_encap;
wth->snapshot_length = 0; /* not available in header */
wth->file_tsprec = WTAP_TSPREC_USEC;
- return 1;
+ return WTAP_OPEN_MINE;
}
typedef struct {
diff --git a/wiretap/stanag4607.c b/wiretap/stanag4607.c
index 24b29d7518..a3c0a207aa 100644
--- a/wiretap/stanag4607.c
+++ b/wiretap/stanag4607.c
@@ -158,21 +158,21 @@ static gboolean stanag4607_seek_read(wtap *wth, gint64 seek_off,
return stanag4607_read_file(wth, wth->random_fh, phdr, buf, err, err_info);
}
-int stanag4607_open(wtap *wth, int *err, gchar **err_info)
+wtap_open_return_val stanag4607_open(wtap *wth, int *err, gchar **err_info)
{
guint16 version_id;
stanag4607_t *stanag4607;
if (!wtap_read_bytes(wth->fh, &version_id, sizeof version_id, err, err_info))
- return (*err != WTAP_ERR_SHORT_READ) ? -1 : 0;
+ return (*err != WTAP_ERR_SHORT_READ) ? WTAP_OPEN_ERROR : WTAP_OPEN_NOT_MINE;
if (!is_valid_id(GUINT16_TO_BE(version_id)))
/* Not a stanag4607 file */
- return 0;
+ return WTAP_OPEN_NOT_MINE;
/* seek back to the start of the file */
if (file_seek(wth->fh, 0, SEEK_SET, err) == -1)
- return -1;
+ return WTAP_OPEN_ERROR;
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_STANAG_4607;
wth->file_encap = WTAP_ENCAP_STANAG_4607;
@@ -186,5 +186,5 @@ int stanag4607_open(wtap *wth, int *err, gchar **err_info)
wth->subtype_seek_read = stanag4607_seek_read;
wth->file_tsprec = WTAP_TSPREC_MSEC;
- return 1;
+ return WTAP_OPEN_MINE;
}
diff --git a/wiretap/tnef.c b/wiretap/tnef.c
index 3dcc5e40ca..85115a11b2 100644
--- a/wiretap/tnef.c
+++ b/wiretap/tnef.c
@@ -101,15 +101,15 @@ int tnef_open(wtap *wth, int *err, gchar **err_info)
guint32 magic;
if (!wtap_read_bytes(wth->fh, &magic, sizeof magic, err, err_info))
- return (*err != WTAP_ERR_SHORT_READ) ? -1 : 0;
+ return (*err != WTAP_ERR_SHORT_READ) ? WTAP_OPEN_ERROR : WTAP_OPEN_NOT_MINE;
if (GUINT32_TO_LE(magic) != TNEF_SIGNATURE)
/* Not a tnef file */
- return 0;
+ return WTAP_OPEN_NOT_MINE;
/* seek back to the start of the file */
if (file_seek(wth->fh, 0, SEEK_SET, err) == -1)
- return -1;
+ return WTAP_OPEN_ERROR;
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_TNEF;
wth->file_encap = WTAP_ENCAP_TNEF;
@@ -119,5 +119,5 @@ int tnef_open(wtap *wth, int *err, gchar **err_info)
wth->subtype_seek_read = tnef_seek_read;
wth->file_tsprec = WTAP_TSPREC_SEC;
- return 1;
+ return WTAP_OPEN_MINE;
}
diff --git a/wiretap/toshiba.c b/wiretap/toshiba.c
index 681e094a9c..e8383a9808 100644
--- a/wiretap/toshiba.c
+++ b/wiretap/toshiba.c
@@ -194,13 +194,13 @@ static gboolean toshiba_check_file_type(wtap *wth, int *err, gchar **err_info)
}
-int toshiba_open(wtap *wth, int *err, gchar **err_info)
+wtap_open_return_val toshiba_open(wtap *wth, int *err, gchar **err_info)
{
/* Look for Toshiba header */
if (!toshiba_check_file_type(wth, err, err_info)) {
if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
- return -1;
- return 0;
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
}
wth->file_encap = WTAP_ENCAP_PER_PACKET;
@@ -210,7 +210,7 @@ int toshiba_open(wtap *wth, int *err, gchar **err_info)
wth->subtype_seek_read = toshiba_seek_read;
wth->file_tsprec = WTAP_TSPREC_CSEC;
- return 1;
+ return WTAP_OPEN_MINE;
}
/* Find the next packet and parse it; called from wtap_read(). */
diff --git a/wiretap/visual.c b/wiretap/visual.c
index d781e3651a..c29216d94d 100644
--- a/wiretap/visual.c
+++ b/wiretap/visual.c
@@ -171,7 +171,7 @@ static void visual_dump_free(wtap_dumper *wdh);
/* Open a file for reading */
-int visual_open(wtap *wth, int *err, gchar **err_info)
+wtap_open_return_val visual_open(wtap *wth, int *err, gchar **err_info)
{
char magic[sizeof visual_magic];
struct visual_file_hdr vfile_hdr;
@@ -182,18 +182,18 @@ int visual_open(wtap *wth, int *err, gchar **err_info)
if (!wtap_read_bytes(wth->fh, magic, sizeof magic, err, err_info))
{
if (*err != WTAP_ERR_SHORT_READ)
- return -1;
- return 0;
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
}
if (memcmp(magic, visual_magic, sizeof visual_magic) != 0)
{
- return 0;
+ return WTAP_OPEN_NOT_MINE;
}
/* Read the rest of the file header. */
if (!wtap_read_bytes(wth->fh, &vfile_hdr, sizeof vfile_hdr, err, err_info))
{
- return -1;
+ return WTAP_OPEN_ERROR;
}
/* Verify the file version is known */
@@ -202,7 +202,7 @@ int visual_open(wtap *wth, int *err, gchar **err_info)
{
*err = WTAP_ERR_UNSUPPORTED;
*err_info = g_strdup_printf("visual: file version %u unsupported", vfile_hdr.file_version);
- return -1;
+ return WTAP_OPEN_ERROR;
}
/* Translate the encapsulation type; these values are SNMP ifType
@@ -244,7 +244,7 @@ int visual_open(wtap *wth, int *err, gchar **err_info)
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
*err_info = g_strdup_printf("visual: network type %u unknown or unsupported",
vfile_hdr.media_type);
- return -1;
+ return WTAP_OPEN_ERROR;
}
/* Fill in the wiretap struct with data from the file header */
@@ -264,7 +264,7 @@ int visual_open(wtap *wth, int *err, gchar **err_info)
visual->start_time = ((double) pletoh32(&vfile_hdr.start_time)) * 1000000;
visual->current_pkt = 1;
- return 1;
+ return WTAP_OPEN_MINE;
}
diff --git a/wiretap/vms.c b/wiretap/vms.c
index 28c0e5df4e..6a1c5fb6a2 100644
--- a/wiretap/vms.c
+++ b/wiretap/vms.c
@@ -235,13 +235,13 @@ static gboolean vms_check_file_type(wtap *wth, int *err, gchar **err_info)
}
-int vms_open(wtap *wth, int *err, gchar **err_info)
+wtap_open_return_val vms_open(wtap *wth, int *err, gchar **err_info)
{
/* Look for VMS header */
if (!vms_check_file_type(wth, err, err_info)) {
if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
- return -1;
- return 0;
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
}
wth->file_encap = WTAP_ENCAP_RAW_IP;
@@ -251,7 +251,7 @@ int vms_open(wtap *wth, int *err, gchar **err_info)
wth->subtype_seek_read = vms_seek_read;
wth->file_tsprec = WTAP_TSPREC_CSEC;
- return 1;
+ return WTAP_OPEN_MINE;
}
/* Find the next packet and parse it; called from wtap_read(). */
diff --git a/wiretap/vwr.c b/wiretap/vwr.c
index 43cedd33fe..10c8bf8ffa 100644
--- a/wiretap/vwr.c
+++ b/wiretap/vwr.c
@@ -525,7 +525,7 @@ static float getRate( guint8 plcpType, guint8 mcsIndex, guint16 rflags, g
/* This does very little, except setting the wiretap header for a VWR file type */
/* and setting the timestamp precision to microseconds. */
-int vwr_open(wtap *wth, int *err, gchar **err_info)
+wtap_open_return_val vwr_open(wtap *wth, int *err, gchar **err_info)
{
int fpgaVer;
vwr_t *vwr;
@@ -534,10 +534,10 @@ int vwr_open(wtap *wth, int *err, gchar **err_info)
fpgaVer = vwr_get_fpga_version(wth, err, err_info);
if (fpgaVer == -1) {
- return -1; /* I/O error */
+ return WTAP_OPEN_ERROR; /* I/O error */
}
if (fpgaVer == UNKNOWN_FPGA) {
- return 0; /* not a VWR file */
+ return WTAP_OPEN_NOT_MINE; /* not a VWR file */
}
/* This is a vwr file */
@@ -559,7 +559,7 @@ int vwr_open(wtap *wth, int *err, gchar **err_info)
else if (fpgaVer == vVW510012_E_FPGA || fpgaVer == vVW510024_E_FPGA)
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_VWR_ETH;
- return 1;
+ return WTAP_OPEN_MINE;
}
diff --git a/wiretap/wtap.h b/wiretap/wtap.h
index 245f912766..e46935aa86 100644
--- a/wiretap/wtap.h
+++ b/wiretap/wtap.h
@@ -1255,11 +1255,13 @@ struct file_extension_info {
*
* The open routine should return:
*
- * -1 on an I/O error;
+ * WTAP_OPEN_ERROR on an I/O error;
*
- * 1 if the file it's reading is one of the types it handles;
+ * WTAP_OPEN_MINE if the file it's reading is one of the types
+ * it handles;
*
- * 0 if the file it's reading isn't the type it handles.
+ * WTAP_OPEN_NOT_MINE if the file it's reading isn't one of the
+ * types it handles.
*
* If the routine handles this type of file, it should set the "file_type"
* field in the "struct wtap" to the type of the file.
@@ -1269,9 +1271,17 @@ struct file_extension_info {
* (See https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8518)
*
* However, the caller does have to free the private data pointer when
- * returning 0, since the next file type will be called and will likely
- * just overwrite the pointer.
+ * returning WTAP_OPEN_NOT_MINE, since the next file type will be called
+ * and will likely just overwrite the pointer.
*/
+typedef enum {
+ WTAP_OPEN_NOT_MINE = 0,
+ WTAP_OPEN_MINE = 1,
+ WTAP_OPEN_ERROR = -1
+} wtap_open_return_val;
+
+typedef wtap_open_return_val (*wtap_open_routine_t)(struct wtap*, int *,
+ char **);
/*
* Some file formats have defined magic numbers at fixed offsets from
@@ -1282,11 +1292,8 @@ struct file_extension_info {
* Those file formats do not require a file name extension in order
* to recognize them or to avoid recognizing other file types as that
* type, and have no extensions specified for them.
- */
-typedef int (*wtap_open_routine_t)(struct wtap*, int *, char **);
-
-/*
- * Some file formats don't have defined magic numbers at fixed offsets,
+ *
+ * Other file formats don't have defined magic numbers at fixed offsets,
* so a heuristic is required. If that file format has any file name
* extensions used for it, a list of those extensions should be
* specified, so that, if the name of the file being opened has an