* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifdef HAVE_CONFIG_H
#include "config.h"
-#endif
#include <string.h>
#include <errno.h>
}
int
-wtap_file_type(wtap *wth)
+wtap_file_type_subtype(wtap *wth)
{
- return wth->file_type;
+ return wth->file_type_subtype;
}
gboolean
{ "Per-Packet Information header", "ppi" },
/* WTAP_ENCAP_ERF */
- { "Endace Record File", "erf" },
+ { "Extensible Record Format", "erf" },
/* WTAP_ENCAP_BLUETOOTH_H4_WITH_PHDR */
{ "Bluetooth H4 with linux header", "bluetooth-h4-linux" },
/* WTAP_ENCAP_IEEE_802_11_AIROPEEK */
{ "IEEE 802.11 plus AiroPeek radio header", "ieee-802-11-airopeek" },
+
+ /* WTAP_ENCAP_SDH */
+ { "SDH", "sdh" },
+
+ /* WTAP_ENCAP_DBUS */
+ { "D-Bus", "dbus" },
+
+ /* WTAP_ENCAP_AX25_KISS */
+ { "AX.25 with KISS header", "ax25-kiss" },
+
+ /* WTAP_ENCAP_AX25 */
+ { "Amateur Radio AX.25", "ax25" },
+
+ /* WTAP_ENCAP_SCTP */
+ { "SCTP", "sctp" },
+
+ /* WTAP_ENCAP_INFINIBAND */
+ { "InfiniBand", "infiniband" },
+
+ /* WTAP_ENCAP_JUNIPER_SVCS */
+ { "Juniper Services", "juniper-svcs" },
+
+ /* WTAP_ENCAP_USBPCAP */
+ { "USB packets with USBPcap header", "usb-usbpcap" },
+
+ /* WTAP_ENCAP_RTAC_SERIAL */
+ { "RTAC serial-line", "rtac-serial" },
+
+ /* WTAP_ENCAP_BLUETOOTH_LE_LL */
+ { "Bluetooth Low Energy Link Layer", "bluetooth-le-ll" },
+
+ /* WTAP_ENCAP_WIRESHARK_UPPER_PDU */
+ { "Wireshark Upper PDU export", "wireshark-upper-pdu" },
};
+WS_DLL_LOCAL
gint wtap_num_encap_types = sizeof(encap_table_base) / sizeof(struct encap_type_info);
static GArray* encap_table_arr = NULL;
-static const struct encap_type_info* encap_table = NULL;
+
+#define encap_table_entry(encap) \
+ g_array_index(encap_table_arr, struct encap_type_info, encap)
static void wtap_init_encap_types(void) {
encap_table_arr = g_array_new(FALSE,TRUE,sizeof(struct encap_type_info));
g_array_append_vals(encap_table_arr,encap_table_base,wtap_num_encap_types);
-
- encap_table = (void*)encap_table_arr->data;
}
int wtap_get_num_encap_types(void) {
}
-int wtap_register_encap_type(char* name, char* short_name) {
+int wtap_register_encap_type(const char* name, const char* short_name) {
struct encap_type_info e;
wtap_init_encap_types();
g_array_append_val(encap_table_arr,e);
- encap_table = (void*)encap_table_arr->data;
-
return wtap_num_encap_types++;
}
else if (encap == WTAP_ENCAP_PER_PACKET)
return "Per packet";
else
- return encap_table[encap].name;
+ return encap_table_entry(encap).name;
}
/* Name to use in, say, a command-line flag specifying the type. */
else if (encap == WTAP_ENCAP_PER_PACKET)
return "per-packet";
else
- return encap_table[encap].short_name;
+ return encap_table_entry(encap).short_name;
}
/* Translate a short name to a capture file type. */
int encap;
for (encap = 0; encap < WTAP_NUM_ENCAP_TYPES; encap++) {
- if (encap_table[encap].short_name != NULL &&
- strcmp(short_name, encap_table[encap].short_name) == 0)
+ if (encap_table_entry(encap).short_name != NULL &&
+ strcmp(short_name, encap_table_entry(encap).short_name) == 0)
return encap;
}
return -1; /* no such encapsulation type */
"The standard input cannot be opened for random access",
"That file format doesn't support compression",
NULL,
+ NULL,
"Uncompression error",
"Internal error"
};
return TRUE; /* success */
}
+/*
+ * Read packet data into a Buffer, growing the buffer as necessary.
+ *
+ * This returns an error on a short read, even if the short read hit
+ * the EOF immediately. (The assumption is that each packet has a
+ * header followed by raw packet data, and that we've already read the
+ * header, so if we get an EOF trying to read the packet data, the file
+ * has been cut short, even if the read didn't read any data at all.)
+ */
+gboolean
+wtap_read_packet_bytes(FILE_T fh, Buffer *buf, guint length, int *err,
+ gchar **err_info)
+{
+ int bytes_read;
+
+ buffer_assure_space(buf, length);
+ errno = WTAP_ERR_CANT_READ;
+ bytes_read = file_read(buffer_start_ptr(buf), length, fh);
+
+ if (bytes_read < 0 || (guint)bytes_read != length) {
+ *err = file_error(fh, err_info);
+ if (*err == 0)
+ *err = WTAP_ERR_SHORT_READ;
+ return FALSE;
+ }
+ return TRUE;
+}
+
/*
* Return an approximation of the amount of data we've read sequentially
* from the file so far. (gint64, in case that's 64 bits.)
return &wth->phdr;
}
-union wtap_pseudo_header *
-wtap_pseudoheader(wtap *wth)
-{
- return &wth->pseudo_header;
-}
-
guint8 *
wtap_buf_ptr(wtap *wth)
{
gboolean
wtap_seek_read(wtap *wth, gint64 seek_off,
- union wtap_pseudo_header *pseudo_header, guint8 *pd, int len,
+ struct wtap_pkthdr *phdr, Buffer *buf, int len,
int *err, gchar **err_info)
{
- return wth->subtype_seek_read(wth, seek_off, pseudo_header, pd, len,
+ return wth->subtype_seek_read(wth, seek_off, phdr, buf, len,
err, err_info);
}