#include "capsa.h"
#include "pcap-encap.h"
#include "nettrace_3gpp_32_423.h"
+#include "mplog.h"
/*
* Add an extension, and all compressed versions thereof, to a GSList
{ "Tektronix K12xx 32-bit .rf5 format", "rf5" },
{ "Savvius *Peek", "pkt;tpc;apc;wpz" },
{ "Catapult DCT2000 trace (.out format)", "out" },
+ { "Micropross mplog", "mplog" },
{ "MPEG files", "mpg;mp3" },
{ "TamoSoft CommView", "ncf" },
{ "Symbian OS btsnoop", "log" },
* type to interpret it as, if the file name has no extension, the
* extension isn't sufficient to determine the appropriate file type,
* or the extension is wrong.
+ *
+ * NOTE: when adding file formats to this list you may also want to add them
+ * to the following files so that the various desktop environments will
+ * know that Wireshark can open the file:
+ * 1) wireshark-mime-package.xml (for freedesktop.org environments)
+ * 2) packaging/macosx/Info.plist.in (for OS X)
+ * 3) packaging/nsis/AdditionalTasksPage.ini, packaging/nsis/common.nsh,
+ * and packaging/wix/ComponentGroups.wxi (for Windows)
+ *
+ * If your file format has an expected extension (e.g., ".pcap") then you
+ * should probably also add it to file_type_extensions_base[] (in this file).
*/
static struct open_info open_info_base[] = {
{ "Wireshark/tcpdump/... - pcap", OPEN_INFO_MAGIC, libpcap_open, "pcap", NULL, NULL },
/* Gammu DCT3 trace must come before MIME files as it's XML based*/
{ "Gammu DCT3 trace", OPEN_INFO_MAGIC, dct3trace_open, NULL, NULL, NULL },
{ "MIME Files Format", OPEN_INFO_MAGIC, mime_file_open, NULL, NULL, NULL },
+ { "Micropross mplog", OPEN_INFO_MAGIC, mplog_open, "mplog", NULL, NULL },
{ "Novell LANalyzer", OPEN_INFO_HEURISTIC, lanalyzer_open, "tr1", NULL, NULL },
/*
* PacketLogger must come before MPEG, because its files
/* this is only used to build the dynamic array on load, do NOT use this
* for anything else, because the size of the actual array will change if
- * Lua scripts register a new file reader.
+ * Lua scripts register a new file reader.
*/
#define N_OPEN_INFO_ROUTINES ((sizeof open_info_base / sizeof open_info_base[0]))
unsigned int i;
gboolean use_stdin = FALSE;
gchar *extension;
+ wtap_optionblock_t shb;
*err = 0;
*err_info = NULL;
wth->file_tsprec = WTAP_TSPREC_USEC;
wth->priv = NULL;
wth->wslua_data = NULL;
- wth->shb_hdr = wtap_optionblock_create(WTAP_OPTION_BLOCK_NG_SECTION);
+ wth->shb_hdrs = g_array_new(FALSE, FALSE, sizeof(wtap_optionblock_t));
+ shb = wtap_optionblock_create(WTAP_OPTION_BLOCK_NG_SECTION);
+ if (shb)
+ g_array_append_val(wth->shb_hdrs, shb);
/* Initialize the array containing a list of interfaces. pcapng_open and
* erf_open needs this (and libpcap_open for ERF encapsulation types).
{ "3GPP TS 32.423 Trace", "3gpp32423", NULL, NULL,
FALSE, FALSE, 0,
NULL, NULL, NULL },
+
+ /* WTAP_FILE_TYPE_MPLOG */
+ { "Micropross mplog file", "mplog", "mplog", NULL,
+ FALSE, FALSE, 0,
+ NULL, NULL, NULL }
};
/*
return TRUE;
}
-#ifdef HAVE_LIBZ
+#ifdef HAVE_ZLIB
gboolean
wtap_dump_can_compress(int file_type_subtype)
{
static wtap_dumper *
wtap_dump_init_dumper(int file_type_subtype, int encap, int snaplen, gboolean compressed,
- wtap_optionblock_t shb_hdr, wtapng_iface_descriptions_t *idb_inf,
- wtap_optionblock_t nrb_hdr, int *err)
+ GArray* shb_hdrs, wtapng_iface_descriptions_t *idb_inf,
+ GArray* nrb_hdrs, int *err)
{
wtap_dumper *wdh;
wtap_optionblock_t descr, file_int_data;
return NULL; /* couldn't allocate it */
/* Set Section Header Block data */
- wdh->shb_hdr = shb_hdr;
+ wdh->shb_hdrs = shb_hdrs;
/* Set Name Resolution Block data */
- wdh->nrb_hdr = nrb_hdr;
+ wdh->nrb_hdrs = nrb_hdrs;
/* Set Interface Description Block data */
if ((idb_inf != NULL) && (idb_inf->interface_data->len > 0)) {
guint itf_count;
descr_mand->time_units_per_second = 1000000; /* default microsecond resolution */
descr_mand->link_type = wtap_wtap_encap_to_pcap_encap(encap);
descr_mand->snap_len = snaplen;
- wtap_optionblock_set_option_string(descr, OPT_IDB_NAME, "Unknown/not available in original file format(libpcap)");
+ wtap_optionblock_set_option_string(descr, OPT_IDB_NAME, "Unknown/not available in original file format(libpcap)",
+ strlen("Unknown/not available in original file format(libpcap)"));
descr_mand->num_stat_entries = 0; /* Number of ISB:s */
descr_mand->interface_statistics = NULL;
wtap_dumper *
wtap_dump_open_ng(const char *filename, int file_type_subtype, int encap,
- int snaplen, gboolean compressed, wtap_optionblock_t shb_hdr, wtapng_iface_descriptions_t *idb_inf,
- wtap_optionblock_t nrb_hdr, int *err)
+ int snaplen, gboolean compressed, GArray* shb_hdrs, wtapng_iface_descriptions_t *idb_inf,
+ GArray* nrb_hdrs, int *err)
{
wtap_dumper *wdh;
WFILE_T fh;
/* Allocate and initialize a data structure for the output stream. */
wdh = wtap_dump_init_dumper(file_type_subtype, encap, snaplen, compressed,
- shb_hdr, idb_inf, nrb_hdr, err);
+ shb_hdrs, idb_inf, nrb_hdrs, err);
if (wdh == NULL)
return NULL;
wtap_dump_open_tempfile_ng(char **filenamep, const char *pfx,
int file_type_subtype, int encap,
int snaplen, gboolean compressed,
- wtap_optionblock_t shb_hdr,
+ GArray* shb_hdrs,
wtapng_iface_descriptions_t *idb_inf,
- wtap_optionblock_t nrb_hdr, int *err)
+ GArray* nrb_hdrs, int *err)
{
int fd;
char *tmpname;
/* Allocate and initialize a data structure for the output stream. */
wdh = wtap_dump_init_dumper(file_type_subtype, encap, snaplen, compressed,
- shb_hdr, idb_inf, nrb_hdr, err);
+ shb_hdrs, idb_inf, nrb_hdrs, err);
if (wdh == NULL)
return NULL;
/* Choose a random name for the file */
- fd = create_tempfile(&tmpname, pfx);
+ fd = create_tempfile(&tmpname, pfx, ".pcapng");
if (fd == -1) {
*err = errno;
g_free(wdh);
fh = wtap_dump_file_fdopen(wdh, fd);
if (fh == NULL) {
*err = errno;
- close(fd);
+ ws_close(fd);
g_free(wdh);
return NULL; /* can't create file */
}
wtap_dumper *
wtap_dump_fdopen_ng(int fd, int file_type_subtype, int encap, int snaplen,
- gboolean compressed, wtap_optionblock_t shb_hdr, wtapng_iface_descriptions_t *idb_inf,
- wtap_optionblock_t nrb_hdr, int *err)
+ gboolean compressed, GArray* shb_hdrs, wtapng_iface_descriptions_t *idb_inf,
+ GArray* nrb_hdrs, int *err)
{
wtap_dumper *wdh;
WFILE_T fh;
/* Allocate and initialize a data structure for the output stream. */
wdh = wtap_dump_init_dumper(file_type_subtype, encap, snaplen, compressed,
- shb_hdr, idb_inf, nrb_hdr, err);
+ shb_hdrs, idb_inf, nrb_hdrs, err);
if (wdh == NULL)
return NULL;
wtap_dumper *
wtap_dump_open_stdout_ng(int file_type_subtype, int encap, int snaplen,
- gboolean compressed, wtap_optionblock_t shb_hdr,
+ gboolean compressed, GArray* shb_hdrs,
wtapng_iface_descriptions_t *idb_inf,
- wtap_optionblock_t nrb_hdr, int *err)
+ GArray* nrb_hdrs, int *err)
{
wtap_dumper *wdh;
WFILE_T fh;
/* Allocate and initialize a data structure for the output stream. */
wdh = wtap_dump_init_dumper(file_type_subtype, encap, snaplen, compressed,
- shb_hdr, idb_inf, nrb_hdr, err);
+ shb_hdrs, idb_inf, nrb_hdrs, err);
if (wdh == NULL)
return NULL;
if(compressed) {
cant_seek = TRUE;
} else {
- fd = fileno((FILE *)wdh->fh);
+ fd = ws_fileno((FILE *)wdh->fh);
if (ws_lseek64(fd, 1, SEEK_CUR) == (off_t) -1)
cant_seek = TRUE;
else {
void
wtap_dump_flush(wtap_dumper *wdh)
{
-#ifdef HAVE_LIBZ
+#ifdef HAVE_ZLIB
if(wdh->compressed) {
gzwfile_flush((GZWFILE_T)wdh->fh);
} else
}
/* internally open a file for writing (compressed or not) */
-#ifdef HAVE_LIBZ
+#ifdef HAVE_ZLIB
static WFILE_T
wtap_dump_file_open(wtap_dumper *wdh, const char *filename)
{
#endif
/* internally open a file for writing (compressed or not) */
-#ifdef HAVE_LIBZ
+#ifdef HAVE_ZLIB
static WFILE_T
wtap_dump_file_fdopen(wtap_dumper *wdh, int fd)
{
{
size_t nwritten;
-#ifdef HAVE_LIBZ
+#ifdef HAVE_ZLIB
if (wdh->compressed) {
nwritten = gzwfile_write((GZWFILE_T)wdh->fh, buf, (unsigned int) bufsize);
/*
static int
wtap_dump_file_close(wtap_dumper *wdh)
{
-#ifdef HAVE_LIBZ
+#ifdef HAVE_ZLIB
if(wdh->compressed) {
/*
* Tell gzwfile_close() whether to close the descriptor
gint64
wtap_dump_file_seek(wtap_dumper *wdh, gint64 offset, int whence, int *err)
{
-#ifdef HAVE_LIBZ
+#ifdef HAVE_ZLIB
if(wdh->compressed) {
*err = WTAP_ERR_CANT_SEEK_COMPRESSED;
return -1;
wtap_dump_file_tell(wtap_dumper *wdh, int *err)
{
gint64 rval;
-#ifdef HAVE_LIBZ
+#ifdef HAVE_ZLIB
if(wdh->compressed) {
*err = WTAP_ERR_CANT_SEEK_COMPRESSED;
return -1;