Have the code that opens "libpcap" files for writing check to make sure
that the Wiretap encapsulation can be written to a "libpcap" file, and
return -1 and supply a new WTAP_ERR_UNSUPPORTED_ENCAP error code if it
can't.
Handle that new error code in "wtap_strerror()".
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@546
f5534014-38df-0310-8fa8-
9805f1628bb7
/* libpcap.c
*
- * $Id: libpcap.c,v 1.12 1999/08/22 02:29:37 guy Exp $
+ * $Id: libpcap.c,v 1.13 1999/08/22 03:50:31 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@verdict.uthscsa.edu>
static const guint32 pcap_magic = PCAP_MAGIC;
struct pcap_hdr file_hdr;
static const int wtap_encap[] = {
- 0, /* WTAP_ENCAP_UNKNOWN -> DLT_NULL */
+ -1, /* WTAP_ENCAP_UNKNOWN -> unsupported */
1, /* WTAP_ENCAP_ETHERNET -> DLT_EN10MB */
6, /* WTAP_ENCAP_TR -> DLT_IEEE802 */
8, /* WTAP_ENCAP_SLIP -> DLT_SLIP */
7, /* WTAP_ENCAP_ARCNET -> DLT_ARCNET */
11, /* WTAP_ENCAP_ATM_RFC1483 -> DLT_ATM_RFC1483 */
19, /* WTAP_ENCAP_LINUX_ATM_CLIP */
+ -1, /* WTAP_ENCAP_LAPB -> unsupported*/
+ -1, /* WTAP_ENCAP_ATM_SNIFFER -> unsupported */
0 /* WTAP_ENCAP_NULL -> DLT_NULL */
};
+ #define NUM_WTAP_ENCAPS (sizeof wtap_encap / sizeof wtap_encap[0])
int nwritten;
/* Per-packet encapsulations aren't supported. */
return 0;
}
+ if (wdh->encap < 0 || wdh->encap >= NUM_WTAP_ENCAPS
+ || wtap_encap[wdh->encap] == -1) {
+ *err = WTAP_ERR_UNSUPPORTED_ENCAP;
+ return 0;
+ }
+
/* This is a libpcap file */
wdh->subtype_write = libpcap_dump;
wdh->subtype_close = libpcap_dump_close;
/* wtap.c
*
- * $Id: wtap.c,v 1.16 1999/08/22 02:52:48 guy Exp $
+ * $Id: wtap.c,v 1.17 1999/08/22 03:50:31 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@verdict.uthscsa.edu>
"File contains record data we don't support",
NULL,
"Files can't be saved in that format",
+ "Files from that network type can't be saved in that format",
"That format doesn't support per-packet encapsulations",
NULL,
NULL,
/* wtap.h
*
- * $Id: wtap.h,v 1.32 1999/08/22 02:52:48 guy Exp $
+ * $Id: wtap.h,v 1.33 1999/08/22 03:50:30 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@verdict.uthscsa.edu>
/* The file couldn't be opened, reason unknown */
#define WTAP_ERR_UNSUPPORTED_FILE_TYPE -5
/* Wiretap can't save files in the specified format */
-#define WTAP_ERR_ENCAP_PER_PACKET_UNSUPPORTED -6
+#define WTAP_ERR_UNSUPPORTED_ENCAP -6
+ /* Wiretap can't save files in the specified format with the
+ specified encapsulation */
+#define WTAP_ERR_ENCAP_PER_PACKET_UNSUPPORTED -7
/* The specified format doesn't support per-packet encapsulations */
-#define WTAP_ERR_CANT_CLOSE -7
+#define WTAP_ERR_CANT_CLOSE -8
/* The file couldn't be closed, reason unknown */
-#define WTAP_ERR_CANT_READ -8
+#define WTAP_ERR_CANT_READ -9
/* An attempt to read failed, reason unknown */
-#define WTAP_ERR_SHORT_READ -9
+#define WTAP_ERR_SHORT_READ -10
/* An attempt to read read less data than it should have */
-#define WTAP_ERR_BAD_RECORD -10
+#define WTAP_ERR_BAD_RECORD -11
/* We read an invalid record */
-#define WTAP_ERR_SHORT_WRITE -11
+#define WTAP_ERR_SHORT_WRITE -12
/* An attempt to write wrote less data than it should have */
/* Pointer versions of ntohs and ntohl. Given a pointer to a member of a