aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--debian/libwiretap0.symbols5
-rw-r--r--editcap.c20
-rw-r--r--epan/wslua/wslua_file_handler.c272
-rw-r--r--extcap/etl.c4
-rw-r--r--file.c2
-rw-r--r--tshark.c9
-rw-r--r--ui/qt/capture_file_dialog.cpp21
-rw-r--r--ui/tap_export_pdu.c2
-rw-r--r--wiretap/5views.c9
-rw-r--r--wiretap/aethra.c9
-rw-r--r--wiretap/ascendtext.c9
-rw-r--r--wiretap/ber.c11
-rw-r--r--wiretap/btsnoop.c9
-rw-r--r--wiretap/busmaster.c9
-rw-r--r--wiretap/camins.c9
-rw-r--r--wiretap/candump.c9
-rw-r--r--wiretap/capsa.c18
-rw-r--r--wiretap/catapult_dct2000.c9
-rw-r--r--wiretap/commview.c9
-rw-r--r--wiretap/cosine.c9
-rw-r--r--wiretap/csids.c9
-rw-r--r--wiretap/daintree-sna.c9
-rw-r--r--wiretap/dbs-etherwatch.c9
-rw-r--r--wiretap/dct3trace.c9
-rw-r--r--wiretap/dpa400.c9
-rw-r--r--wiretap/erf.c52
-rw-r--r--wiretap/eyesdn.c11
-rw-r--r--wiretap/file_access.c289
-rw-r--r--wiretap/hcidump.c10
-rw-r--r--wiretap/i4btrace.c9
-rw-r--r--wiretap/ipfix.c9
-rw-r--r--wiretap/iptrace.c76
-rw-r--r--wiretap/iseries.c18
-rw-r--r--wiretap/json.c11
-rw-r--r--wiretap/k12.c9
-rw-r--r--wiretap/k12text.l9
-rw-r--r--wiretap/lanalyzer.c9
-rw-r--r--wiretap/log3gpp.c9
-rw-r--r--wiretap/logcat.c9
-rw-r--r--wiretap/logcat_text.c63
-rw-r--r--wiretap/merge.c22
-rw-r--r--wiretap/mime_file.c24
-rw-r--r--wiretap/mp2t.c9
-rw-r--r--wiretap/mp4.c11
-rw-r--r--wiretap/mpeg.c11
-rw-r--r--wiretap/mplog.c9
-rw-r--r--wiretap/netmon.c18
-rw-r--r--wiretap/netscaler.c36
-rw-r--r--wiretap/netscreen.c9
-rw-r--r--wiretap/nettl.c9
-rw-r--r--wiretap/nettrace_3gpp_32_423.c9
-rw-r--r--wiretap/network_instruments.c9
-rw-r--r--wiretap/netxray.c36
-rw-r--r--wiretap/ngsniffer.c18
-rw-r--r--wiretap/packetlogger.c9
-rw-r--r--wiretap/pcapng.c6
-rw-r--r--wiretap/peekclassic.c18
-rw-r--r--wiretap/peektagged.c9
-rw-r--r--wiretap/pppdump.c9
-rw-r--r--wiretap/radcom.c9
-rw-r--r--wiretap/rfc7468.c15
-rw-r--r--wiretap/ruby_marshal.c9
-rw-r--r--wiretap/snoop.c18
-rw-r--r--wiretap/stanag4607.c9
-rw-r--r--wiretap/systemd_journal.c9
-rw-r--r--wiretap/tnef.c11
-rw-r--r--wiretap/toshiba.c9
-rw-r--r--wiretap/visual.c9
-rw-r--r--wiretap/vms.c9
-rw-r--r--wiretap/vwr.c18
-rw-r--r--wiretap/wtap.c2
-rw-r--r--wiretap/wtap.h97
-rw-r--r--wiretap/wtap_opttypes.c2
-rw-r--r--wiretap/wtap_opttypes.h30
-rw-r--r--ws_diag_control.h21
75 files changed, 1424 insertions, 226 deletions
diff --git a/debian/libwiretap0.symbols b/debian/libwiretap0.symbols
index 24f083c0e5..ef49398093 100644
--- a/debian/libwiretap0.symbols
+++ b/debian/libwiretap0.symbols
@@ -78,7 +78,6 @@ libwiretap.so.0 libwiretap0 #MINVER#
wtap_dump_file_write@Base 1.12.0~rc1
wtap_dump_flush@Base 1.9.1
wtap_dump_get_needs_reload@Base 2.5.0
- wtap_dump_has_name_resolution@Base 1.9.1
wtap_dump_open@Base 1.9.1
wtap_dump_open_stdout@Base 2.0.0
wtap_dump_open_tempfile@Base 2.0.0
@@ -87,7 +86,6 @@ libwiretap.so.0 libwiretap0 #MINVER#
wtap_dump_params_init@Base 2.9.0
wtap_dump_params_init_no_idbs@Base 3.3.2
wtap_dump_set_addrinfo_list@Base 1.9.1
- wtap_dump_supports_comment_types@Base 1.9.1
wtap_encap_description@Base 2.9.1
wtap_encap_name@Base 2.9.1
wtap_encap_requires_phdr@Base 1.9.1
@@ -105,6 +103,8 @@ libwiretap.so.0 libwiretap0 #MINVER#
wtap_file_type_subtype@Base 1.12.0~rc1
wtap_file_type_subtype_description@Base 3.5.0
wtap_file_type_subtype_name@Base 3.5.0
+ wtap_file_type_subtype_supports_block@Base 3.5.0
+ wtap_file_type_subtype_supports_option@Base 3.5.0
wtap_free_extensions_list@Base 1.9.1
wtap_free_idb_info@Base 1.99.9
wtap_fstat@Base 1.9.1
@@ -153,6 +153,5 @@ libwiretap.so.0 libwiretap0 #MINVER#
wtap_snapshot_length@Base 1.9.1
wtap_strerror@Base 1.9.1
wtap_tsprec_string@Base 1.99.9
- wtap_uses_interface_ids@Base 3.3.2
wtap_write_shb_comment@Base 1.9.1
wtap_wtap_encap_to_pcap_encap@Base 1.9.1
diff --git a/editcap.c b/editcap.c
index 86712f5073..8e7dc1c77a 100644
--- a/editcap.c
+++ b/editcap.c
@@ -1009,10 +1009,14 @@ editcap_dump_open(const char *filename, const wtap_dump_params *params,
return NULL;
/*
- * If the output file requires interface IDs, add all the IDBs we've
- * seen so far.
+ * If the output file supporst identifying the interfaces on which
+ * packets arrive, add all the IDBs we've seen so far.
+ *
+ * That mean that the abstract interface provided by libwiretap
+ * involves WTAP_BLOCK_IF_ID_AND_INFO blocks.
*/
- if (wtap_uses_interface_ids(wtap_dump_file_type_subtype(pdh))) {
+ if (wtap_file_type_subtype_supports_block(wtap_dump_file_type_subtype(pdh),
+ WTAP_BLOCK_IF_ID_AND_INFO) != BLOCK_NOT_SUPPORTED) {
for (guint i = 0; i < idbs_seen->len; i++) {
wtap_block_t if_data = g_array_index(idbs_seen, wtap_block_t, i);
@@ -1041,10 +1045,14 @@ process_new_idbs(wtap *wth, wtap_dumper *pdh, GArray *idbs_seen,
while ((if_data = wtap_get_next_interface_description(wth)) != NULL) {
/*
- * Only add IDBs if the output file requires interface IDs;
- * otherwise, it doesn't support writing IDBs.
+ * Only add interface blocks if the output file supports (meaning
+ * *requires*) them.
+ *
+ * That mean that the abstract interface provided by libwiretap
+ * involves WTAP_BLOCK_IF_ID_AND_INFO blocks.
*/
- if (wtap_uses_interface_ids(wtap_dump_file_type_subtype(pdh))) {
+ if (wtap_file_type_subtype_supports_block(wtap_dump_file_type_subtype(pdh),
+ WTAP_BLOCK_IF_ID_AND_INFO) != BLOCK_NOT_SUPPORTED) {
wtap_block_t if_data_copy;
/*
diff --git a/epan/wslua/wslua_file_handler.c b/epan/wslua/wslua_file_handler.c
index 49602878a8..75c2111f73 100644
--- a/epan/wslua/wslua_file_handler.c
+++ b/epan/wslua/wslua_file_handler.c
@@ -606,6 +606,31 @@ wslua_filehandler_dump_finish(wtap_dumper *wdh, int *err, gchar **err_info)
return (retval == 1);
}
+/*
+ * Prototype table of option support.
+ * We start out saying we don't support comments, and we don't mention
+ * other options.
+ */
+static const struct supported_option_type option_type_proto[] = {
+ { OPT_COMMENT, OPTION_NOT_SUPPORTED }
+};
+
+/*
+ * Prototype table of block type support.
+ * We start out saying we only support packets.
+ */
+static const struct supported_block_type block_type_proto[] = {
+ { WTAP_BLOCK_SECTION, BLOCK_NOT_SUPPORTED, 0, NULL },
+ { WTAP_BLOCK_IF_ID_AND_INFO, BLOCK_NOT_SUPPORTED, 0, NULL },
+ { WTAP_BLOCK_NAME_RESOLUTION, BLOCK_NOT_SUPPORTED, 0, NULL },
+ { WTAP_BLOCK_IF_STATISTICS, BLOCK_NOT_SUPPORTED, 0, NULL },
+ { WTAP_BLOCK_DECRYPTION_SECRETS, BLOCK_NOT_SUPPORTED, 0, NULL },
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, 0, NULL },
+ { WTAP_BLOCK_FT_SPECIFIC_REPORT, BLOCK_NOT_SUPPORTED, 0, NULL },
+ { WTAP_BLOCK_FT_SPECIFIC_EVENT, BLOCK_NOT_SUPPORTED, 0, NULL }
+};
+
+#define NUM_LISTED_BLOCK_TYPES (sizeof block_type_proto / sizeof block_type_proto[0])
WSLUA_CONSTRUCTOR FileHandler_new(lua_State* L) {
/* Creates a new FileHandler */
@@ -619,6 +644,7 @@ WSLUA_CONSTRUCTOR FileHandler_new(lua_State* L) {
const gchar* internal_description = luaL_checkstring(L,WSLUA_ARG_FileHandler_new_INTERNAL_DESCRIPTION);
const gchar* type = luaL_checkstring(L,WSLUA_ARG_FileHandler_new_TYPE);
FileHandler fh = (FileHandler) g_malloc0(sizeof(struct _wslua_filehandler));
+ struct supported_block_type *supported_blocks;
fh->is_reader = (strchr(type,'r') != NULL) ? TRUE : FALSE;
fh->is_writer = (strchr(type,'w') != NULL) ? TRUE : FALSE;
@@ -640,7 +666,27 @@ WSLUA_CONSTRUCTOR FileHandler_new(lua_State* L) {
fh->finfo.default_file_extension = NULL;
fh->finfo.additional_file_extensions = NULL;
fh->finfo.writing_must_seek = FALSE;
- fh->finfo.has_name_resolution = FALSE;
+ supported_blocks = (struct supported_block_type *)g_memdup(&block_type_proto, sizeof block_type_proto);
+ /*
+ * Add a list of options to the seciton block, interface block, and
+ * packet block, so the file handler can indicate comment support.
+ */
+ for (size_t i = 0; i < NUM_LISTED_BLOCK_TYPES; i++) {
+ switch (supported_blocks[i].type) {
+
+ case WTAP_BLOCK_SECTION:
+ case WTAP_BLOCK_IF_ID_AND_INFO:
+ case WTAP_BLOCK_PACKET:
+ supported_blocks[i].num_supported_options = OPTION_TYPES_SUPPORTED(option_type_proto);
+ supported_blocks[i].supported_options = (struct supported_option_type *)g_memdup(&option_type_proto, sizeof option_type_proto);
+ break;
+
+ default:
+ break;
+ }
+ }
+ fh->finfo.num_supported_blocks = NUM_LISTED_BLOCK_TYPES;
+ fh->finfo.supported_blocks = supported_blocks;
fh->finfo.can_write_encap = NULL;
fh->finfo.dump_open = NULL;
/* this will be set to a new file_type when registered */
@@ -975,13 +1021,229 @@ WSLUA_ATTRIBUTE_NAMED_BOOLEAN_SETTER(FileHandler,writing_must_seek,finfo.writing
/* WSLUA_ATTRIBUTE FileHandler_writes_name_resolution RW true if the file format supports name resolution
records, else false. */
-WSLUA_ATTRIBUTE_NAMED_BOOLEAN_GETTER(FileHandler,writes_name_resolution,finfo.has_name_resolution);
-WSLUA_ATTRIBUTE_NAMED_BOOLEAN_SETTER(FileHandler,writes_name_resolution,finfo.has_name_resolution);
+static inline struct supported_block_type *
+safe_cast_away_block_type_const(const struct supported_block_type *arg)
+{
+ /*
+ * Cast away constness without a warning; we know we can do this
+ * because, for Lua file handlers, the table of supported block
+ * types is in allocated memory, so that we *can* modify it.
+ *
+ * The pointer in the file_type_subtype_info structure is a
+ * pointer to const because compiled file handlers will
+ * normally set it to point to a static const structure.
+ */
+DIAG_OFF_CAST_AWAY_CONST
+ return (struct supported_block_type *)arg;
+DIAG_ON_CAST_AWAY_CONST
+}
+
+WSLUA_ATTRIBUTE_GET(FileHandler,writes_name_resolution,{ \
+ gboolean supports_name_resolution = FALSE; \
+ for (size_t i = 0; i < obj->finfo.num_supported_blocks; i++) { \
+ /* \
+ * If WTAP_BLOCK_NAME_RESOLUTION is supported, name \
+ * resolution is supported. \
+ */ \
+ if (obj->finfo.supported_blocks[i].type == WTAP_BLOCK_NAME_RESOLUTION) { \
+ supports_name_resolution = (obj->finfo.supported_blocks[i].support != BLOCK_NOT_SUPPORTED); \
+ break; \
+ } \
+ } \
+ lua_pushboolean(L, supports_name_resolution); \
+});
+WSLUA_ATTRIBUTE_SET(FileHandler,writes_name_resolution, { \
+ gboolean supports_name_resolution; \
+ if (!lua_isboolean(L,-1) ) \
+ return luaL_error(L, "FileHandler's attribute`writes_name_resolution' must be a boolean"); \
+ supports_name_resolution = lua_toboolean(L,-1); \
+ /* \
+ * Update support for WTAP_BLOCK_NAME_RESOLUTION; the entry for \
+ * it should be there. \
+ */ \
+ for (size_t i = 0; i < obj->finfo.num_supported_blocks; i++) { \
+ if (obj->finfo.supported_blocks[i].type == WTAP_BLOCK_NAME_RESOLUTION) { \
+ struct supported_block_type *supported_blocks;
+ supported_blocks = safe_cast_away_block_type_const(obj->finfo.supported_blocks); \
+
+ supported_blocks[i].support = supports_name_resolution ? ONE_BLOCK_SUPPORTED : BLOCK_NOT_SUPPORTED; \
+ break; \
+ } \
+ } \
+});
/* WSLUA_ATTRIBUTE FileHandler_supported_comment_types RW set to the bit-wise OR'ed number representing
the type of comments the file writer supports writing, based on the numbers in the `wtap_comments` table. */
-WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(FileHandler,supported_comment_types,finfo.supported_comment_types);
-WSLUA_ATTRIBUTE_NAMED_NUMBER_SETTER(FileHandler,supported_comment_types,finfo.supported_comment_types,guint32);
+static inline struct supported_option_type *
+safe_cast_away_option_type_const(const struct supported_option_type *arg)
+{
+ /*
+ * Cast away constness without a warning; we know we can do this
+ * because, for Lua file handlers, the table of supported option
+ * types is in allocated memory, so that we *can* modify it.
+ *
+ * The pointer in the file_type_subtype_info structure is a
+ * pointer to const because compiled file handlers will
+ * normally set it to point to a static const structure.
+ */
+DIAG_OFF_CAST_AWAY_CONST
+ return (struct supported_option_type *)arg;
+DIAG_ON_CAST_AWAY_CONST
+}
+
+WSLUA_ATTRIBUTE_GET(FileHandler,supported_comment_types,{ \
+ guint supported_comment_types = 0; \
+ for (size_t i = 0; i < obj->finfo.num_supported_blocks; i++) { \
+ size_t num_supported_options; \
+ const struct supported_option_type *supported_options;
+\
+ /* \
+ * Is this block type supported? \
+ */ \
+ if (obj->finfo.supported_blocks[i].support == BLOCK_NOT_SUPPORTED) { \
+ /* \
+ * No - skip it. \
+ */ \
+ continue; \
+ } \
+\
+ /* \
+ * Yes - what type of block is it? \
+ */ \
+ switch (obj->finfo.supported_blocks[i].type) { \
+\
+ case WTAP_BLOCK_SECTION: \
+ /* \
+ * Section block - does this block type support comments? \
+ */ \
+ num_supported_options = obj->finfo.supported_blocks[i].num_supported_options; \
+ supported_options = obj->finfo.supported_blocks[i].supported_options; \
+ for (size_t j = 0; j < num_supported_options; i++) { \
+ if (supported_options[i].opt == OPT_COMMENT) { \
+ if (supported_options[i].support != OPTION_NOT_SUPPORTED) \
+ supported_comment_types |= WTAP_COMMENT_PER_SECTION; \
+ break; \
+ } \
+ } \
+ break; \
+\
+ case WTAP_BLOCK_IF_ID_AND_INFO: \
+ /* \
+ * Interface block - does this block type support comments? \
+ */ \
+ num_supported_options = obj->finfo.supported_blocks[i].num_supported_options; \
+ supported_options = obj->finfo.supported_blocks[i].supported_options; \
+ for (size_t j = 0; j < num_supported_options; i++) { \
+ if (supported_options[i].opt == OPT_COMMENT) { \
+ if (supported_options[i].support != OPTION_NOT_SUPPORTED) \
+ supported_comment_types |= WTAP_COMMENT_PER_INTERFACE; \
+ break; \
+ } \
+ } \
+ break; \
+\
+ case WTAP_BLOCK_PACKET: \
+ /* \
+ * Packet block - does this block type support comments? \
+ */ \
+ num_supported_options = obj->finfo.supported_blocks[i].num_supported_options; \
+ supported_options = obj->finfo.supported_blocks[i].supported_options; \
+ for (size_t j = 0; j < num_supported_options; i++) { \
+ if (supported_options[i].opt == OPT_COMMENT) { \
+ if (supported_options[i].support != OPTION_NOT_SUPPORTED) \
+ supported_comment_types |= WTAP_COMMENT_PER_PACKET; \
+ break; \
+ } \
+ } \
+ break; \
+\
+ default: \
+ break;\
+ } \
+ } \
+ lua_pushnumber(L, (lua_Number)supported_comment_types); \
+});
+WSLUA_ATTRIBUTE_SET(FileHandler,supported_comment_types, { \
+ guint supported_comment_types; \
+ size_t num_supported_options; \
+ struct supported_option_type *supported_options; \
+ if (!lua_isnumber(L,-1) ) \
+ return luaL_error(L, "FileHandler's attribute`supported_comment_types' must be a number"); \
+ supported_comment_types = wslua_toguint(L,-1); \
+ /* \
+ * Update support for comments in the relevant block types; the entries \
+ * for comments in those types should be there. \
+ */ \
+ for (size_t i = 0; i < obj->finfo.num_supported_blocks; i++) { \
+\
+ /* \
+ * Is this block type supported? \
+ */ \
+ if (obj->finfo.supported_blocks[i].support == BLOCK_NOT_SUPPORTED) { \
+ /* \
+ * No - skip it. \
+ */ \
+ continue; \
+ } \
+\
+ /* \
+ * Yes - what type of block is it? \
+ */ \
+ switch (obj->finfo.supported_blocks[i].type) { \
+\
+ case WTAP_BLOCK_SECTION: \
+ /* \
+ * Section block - update the comment support. \
+ */ \
+ num_supported_options = obj->finfo.supported_blocks[i].num_supported_options; \
+ supported_options = safe_cast_away_option_type_const(obj->finfo.supported_blocks[i].supported_options); \
+ for (size_t j = 0; j < num_supported_options; i++) { \
+ if (supported_options[i].opt == OPT_COMMENT) { \
+ supported_options[i].support = \
+ (supported_comment_types &= WTAP_COMMENT_PER_SECTION) ? \
+ ONE_OPTION_SUPPORTED : OPTION_NOT_SUPPORTED ; \
+ break; \
+ } \
+ } \
+ break; \
+\
+ case WTAP_BLOCK_IF_ID_AND_INFO: \
+ /* \
+ * Interface block - does this block type support comments? \
+ */ \
+ num_supported_options = obj->finfo.supported_blocks[i].num_supported_options; \
+ supported_options = safe_cast_away_option_type_const(obj->finfo.supported_blocks[i].supported_options); \
+ for (size_t j = 0; j < num_supported_options; i++) { \
+ if (supported_options[i].opt == OPT_COMMENT) { \
+ supported_options[i].support = \
+ (supported_comment_types &= WTAP_COMMENT_PER_INTERFACE) ? \
+ ONE_OPTION_SUPPORTED : OPTION_NOT_SUPPORTED ; \
+ break; \
+ } \
+ } \
+ break; \
+\
+ case WTAP_BLOCK_PACKET: \
+ /* \
+ * Packet block - does this block type support comments? \
+ */ \
+ num_supported_options = obj->finfo.supported_blocks[i].num_supported_options; \
+ supported_options = safe_cast_away_option_type_const(obj->finfo.supported_blocks[i].supported_options); \
+ for (size_t j = 0; j < num_supported_options; i++) { \
+ if (supported_options[i].opt == OPT_COMMENT) { \
+ supported_options[i].support = \
+ (supported_comment_types &= WTAP_COMMENT_PER_PACKET) ? \
+ ONE_OPTION_SUPPORTED : OPTION_NOT_SUPPORTED ; \
+ break; \
+ } \
+ } \
+ break; \
+\
+ default: \
+ break;\
+ } \
+ } \
+});
/* This table is ultimately registered as a sub-table of the class' metatable,
* and if __index/__newindex is invoked then it calls the appropriate function
diff --git a/extcap/etl.c b/extcap/etl.c
index 1ebca96a3b..a1725f3b96 100644
--- a/extcap/etl.c
+++ b/extcap/etl.c
@@ -174,10 +174,10 @@ wtap_dumper* etw_dump_open(const char* pcapng_filename, int* err, gchar** err_in
shb_hdr = wtap_block_create(WTAP_BLOCK_SECTION);
g_array_append_val(shb_hdrs, shb_hdr);
- /* In the future, may create multiple WTAP_BLOCK_IF_DESCRIPTION separately for IP packet */
+ /* In the future, may create multiple WTAP_BLOCK_IF_ID_AND_INFO separately for IP packet */
idb_info = g_new(wtapng_iface_descriptions_t, 1);
idb_datas = g_array_new(FALSE, FALSE, sizeof(wtap_block_t));
- idb_data = wtap_block_create(WTAP_BLOCK_IF_DESCRIPTION);
+ idb_data = wtap_block_create(WTAP_BLOCK_IF_ID_AND_INFO);
descr_mand = (wtapng_if_descr_mandatory_t*)wtap_block_get_mandatory_data(idb_data);
descr_mand->tsprecision = WTAP_TSPREC_USEC;
descr_mand->wtap_encap = WTAP_ENCAP_ETW;
diff --git a/file.c b/file.c
index 7bdd6e8fdd..1e0b28e661 100644
--- a/file.c
+++ b/file.c
@@ -4467,7 +4467,7 @@ cf_save_records(capture_file *cf, const char *fname, guint save_format,
if (save_format == cf->cd_t && compression_type == cf->compression_type
&& !discard_comments && !cf->unsaved_changes
- && (wtap_addrinfo_list_empty(addr_lists) || !wtap_dump_has_name_resolution(save_format))) {
+ && (wtap_addrinfo_list_empty(addr_lists) || wtap_file_type_subtype_supports_block(save_format, WTAP_BLOCK_NAME_RESOLUTION) == BLOCK_NOT_SUPPORTED)) {
/* We're saving in the format it's already in, and we're not discarding
comments, and there are no changes we have in memory that aren't saved
to the file, and we have no name resolution information to write or
diff --git a/tshark.c b/tshark.c
index f8c9646a3e..d71ced4c57 100644
--- a/tshark.c
+++ b/tshark.c
@@ -3287,11 +3287,14 @@ process_new_idbs(wtap *wth, wtap_dumper *pdh, int *err, gchar **err_info)
while ((if_data = wtap_get_next_interface_description(wth)) != NULL) {
/*
- * Only add IDBs if we're writing to a file and the output file
- * requires interface IDs; otherwise, it doesn't support writing IDBs.
+ * Only add interface blocks if the output file supports (meaning
+ * *requires*) them.
+ *
+ * That mean that the abstract interface provided by libwiretap
+ * involves WTAP_BLOCK_IF_ID_AND_INFO blocks.
*/
if (pdh != NULL) {
- if (wtap_uses_interface_ids(wtap_dump_file_type_subtype(pdh))) {
+ if (wtap_file_type_subtype_supports_block(wtap_dump_file_type_subtype(pdh), WTAP_BLOCK_IF_ID_AND_INFO) != BLOCK_NOT_SUPPORTED) {
if (!wtap_dump_add_idb(pdh, if_data, err, err_info))
return FALSE;
}
diff --git a/ui/qt/capture_file_dialog.cpp b/ui/qt/capture_file_dialog.cpp
index afea3b8d71..a5834cb2ca 100644
--- a/ui/qt/capture_file_dialog.cpp
+++ b/ui/qt/capture_file_dialog.cpp
@@ -106,12 +106,31 @@ CaptureFileDialog::CaptureFileDialog(QWidget *parent, capture_file *cf, QString
check_savability_t CaptureFileDialog::checkSaveAsWithComments(QWidget *parent, capture_file *cf, int file_type) {
guint32 comment_types;
+ bool all_comment_types_supported = true;
/* What types of comments do we have? */
comment_types = cf_comment_types(cf);
/* Does the file's format support all the comments we have? */
- if (wtap_dump_supports_comment_types(file_type, comment_types)) {
+ if (comment_types & WTAP_COMMENT_PER_SECTION) {
+ if (wtap_file_type_subtype_supports_option(file_type,
+ WTAP_BLOCK_SECTION,
+ OPT_COMMENT) == OPTION_NOT_SUPPORTED)
+ all_comment_types_supported = false;
+ }
+ if (comment_types & WTAP_COMMENT_PER_INTERFACE) {
+ if (wtap_file_type_subtype_supports_option(file_type,
+ WTAP_BLOCK_IF_ID_AND_INFO,
+ OPT_COMMENT) == OPTION_NOT_SUPPORTED)
+ all_comment_types_supported = false;
+ }
+ if (comment_types & WTAP_COMMENT_PER_PACKET) {
+ if (wtap_file_type_subtype_supports_option(file_type,
+ WTAP_BLOCK_PACKET,
+ OPT_COMMENT) == OPTION_NOT_SUPPORTED)
+ all_comment_types_supported = false;
+ }
+ if (all_comment_types_supported) {
/* Yes. Let the save happen; we can save all the comments, so
there's no need to delete them. */
return SAVE;
diff --git a/ui/tap_export_pdu.c b/ui/tap_export_pdu.c
index ea96342fc9..22915b8a1b 100644
--- a/ui/tap_export_pdu.c
+++ b/ui/tap_export_pdu.c
@@ -126,7 +126,7 @@ exp_pdu_open(exp_pdu_t *exp_pdu_tap_data, int fd, const char *comment, int *err,
exp_pdu_tap_data->idb_inf->interface_data = g_array_new(FALSE, FALSE, sizeof(wtap_block_t));
/* create the fake interface data */
- int_data = wtap_block_create(WTAP_BLOCK_IF_DESCRIPTION);
+ int_data = wtap_block_create(WTAP_BLOCK_IF_ID_AND_INFO);
int_data_mand = (wtapng_if_descr_mandatory_t*)wtap_block_get_mandatory_data(int_data);
int_data_mand->wtap_encap = WTAP_ENCAP_WIRESHARK_UPPER_PDU;
int_data_mand->time_units_per_second = 1000000000; /* default nanosecond resolution */
diff --git a/wiretap/5views.c b/wiretap/5views.c
index 8c74b61e96..f297f26d71 100644
--- a/wiretap/5views.c
+++ b/wiretap/5views.c
@@ -453,9 +453,16 @@ static gboolean _5views_dump_finish(wtap_dumper *wdh, int *err, gchar **err_info
return TRUE;
}
+static const struct supported_block_type _5views_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info _5views_info = {
"InfoVista 5View capture", "5views", "5vw", NULL,
- TRUE, FALSE, 0,
+ TRUE, BLOCKS_SUPPORTED(_5views_blocks_supported),
_5views_dump_can_write_encap, _5views_dump_open, NULL
};
diff --git a/wiretap/aethra.c b/wiretap/aethra.c
index 00c13e9c75..b6447affd9 100644
--- a/wiretap/aethra.c
+++ b/wiretap/aethra.c
@@ -341,9 +341,16 @@ aethra_read_rec_header(wtap *wth, FILE_T fh, struct aethrarec_hdr *hdr,
return TRUE;
}
+static const struct supported_block_type aethra_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info aethra_info = {
"Aethra .aps file", "aethra", "aps", NULL,
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(aethra_blocks_supported),
NULL, NULL, NULL
};
diff --git a/wiretap/ascendtext.c b/wiretap/ascendtext.c
index 233503b322..a44b09c189 100644
--- a/wiretap/ascendtext.c
+++ b/wiretap/ascendtext.c
@@ -457,9 +457,16 @@ static gboolean ascend_seek_read(wtap *wth, gint64 seek_off,
return TRUE;
}
+static const struct supported_block_type ascend_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info ascend_info = {
"Lucent/Ascend access server trace", "ascend", "txt", NULL,
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(ascend_blocks_supported),
NULL, NULL, NULL
};
diff --git a/wiretap/ber.c b/wiretap/ber.c
index 789f93993c..c71ed65ca2 100644
--- a/wiretap/ber.c
+++ b/wiretap/ber.c
@@ -129,9 +129,18 @@ wtap_open_return_val ber_open(wtap *wth, int *err, gchar **err_info)
return WTAP_OPEN_MINE;
}
+static const struct supported_block_type ber_blocks_supported[] = {
+ /*
+ * These are file formats that we dissect, so we provide only one
+ * "packet" with the file's contents, and don't support any
+ * options.
+ */
+ { WTAP_BLOCK_PACKET, ONE_BLOCK_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info ber_info = {
"ASN.1 Basic Encoding Rules", "ber", NULL, NULL,
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(ber_blocks_supported),
NULL, NULL, NULL
};
diff --git a/wiretap/btsnoop.c b/wiretap/btsnoop.c
index 6448437fd0..83e7807ce4 100644
--- a/wiretap/btsnoop.c
+++ b/wiretap/btsnoop.c
@@ -426,9 +426,16 @@ static gboolean btsnoop_dump_open(wtap_dumper *wdh, int *err, gchar **err_info _
return TRUE;
}
+static const struct supported_block_type btsnoop_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info btsnoop_info = {
"Symbian OS btsnoop", "btsnoop", "log", NULL,
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(btsnoop_blocks_supported),
btsnoop_dump_can_write_encap, btsnoop_dump_open, NULL
};
diff --git a/wiretap/busmaster.c b/wiretap/busmaster.c
index e57e13acc3..5b0fe68100 100644
--- a/wiretap/busmaster.c
+++ b/wiretap/busmaster.c
@@ -442,9 +442,16 @@ busmaster_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec,
return busmaster_gen_packet(rec, buf, priv_entry, &state.msg, err, err_info);
}
+static const struct supported_block_type busmaster_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info busmaster_info = {
"BUSMASTER log file", "busmaster", "log", NULL,
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(busmaster_blocks_supported),
NULL, NULL, NULL
};
diff --git a/wiretap/camins.c b/wiretap/camins.c
index eecaa79d5f..680a26c722 100644
--- a/wiretap/camins.c
+++ b/wiretap/camins.c
@@ -452,9 +452,16 @@ wtap_open_return_val camins_open(wtap *wth, int *err, gchar **err_info _U_)
return WTAP_OPEN_MINE;
}
+static const struct supported_block_type camins_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info camins_info = {
"CAM Inspector file", "camins", "camins", NULL,
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(camins_blocks_supported),
NULL, NULL, NULL
};
diff --git a/wiretap/candump.c b/wiretap/candump.c
index dd85992e96..daccaa6c25 100644
--- a/wiretap/candump.c
+++ b/wiretap/candump.c
@@ -229,9 +229,16 @@ candump_seek_read(wtap *wth , gint64 seek_off, wtap_rec *rec,
return TRUE;
}
+static const struct supported_block_type candump_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info candump_info = {
"Linux candump file", "candump", NULL, NULL,
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(candump_blocks_supported),
NULL, NULL, NULL
};
diff --git a/wiretap/capsa.c b/wiretap/capsa.c
index 2b2b403773..904208c721 100644
--- a/wiretap/capsa.c
+++ b/wiretap/capsa.c
@@ -434,15 +434,29 @@ capsa_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec,
return rec_size - (header_size + packet_size);
}
+static const struct supported_block_type capsa_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info capsa_info = {
"Colasoft Capsa format", "capsa", "cscpkt", NULL,
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(capsa_blocks_supported),
NULL, NULL, NULL
};
+static const struct supported_block_type packet_builder_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info packet_builder_info = {
"Colasoft Packet Builder format", "colasoft-pb", "cscpkt", NULL,
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(packet_builder_blocks_supported),
NULL, NULL, NULL
};
diff --git a/wiretap/catapult_dct2000.c b/wiretap/catapult_dct2000.c
index 7a506b56b3..962cc953e3 100644
--- a/wiretap/catapult_dct2000.c
+++ b/wiretap/catapult_dct2000.c
@@ -1651,9 +1651,16 @@ free_line_prefix_info(gpointer key, gpointer value,
return TRUE;
}
+static const struct supported_block_type dct2000_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info dct2000_info = {
"Catapult DCT2000 trace (.out format)", "dct2000", "out", NULL,
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(dct2000_blocks_supported),
catapult_dct2000_dump_can_write_encap, catapult_dct2000_dump_open, NULL
};
diff --git a/wiretap/commview.c b/wiretap/commview.c
index 1be532604f..d6118f6240 100644
--- a/wiretap/commview.c
+++ b/wiretap/commview.c
@@ -600,9 +600,16 @@ static gboolean commview_dump(wtap_dumper *wdh,
return TRUE;
}
+static const struct supported_block_type commview_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info commview_info = {
"TamoSoft CommView", "commview", "ncf", NULL,
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(commview_blocks_supported),
commview_dump_can_write_encap, commview_dump_open, NULL
};
diff --git a/wiretap/cosine.c b/wiretap/cosine.c
index 1ca9b16d69..76c1082110 100644
--- a/wiretap/cosine.c
+++ b/wiretap/cosine.c
@@ -488,9 +488,16 @@ parse_single_hex_dump_line(char* rec, guint8 *buf, guint byte_offset)
return num_items_scanned;
}
+static const struct supported_block_type cosine_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info cosine_info = {
"CoSine IPSX L2 capture", "cosine", "txt", NULL,
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(cosine_blocks_supported),
NULL, NULL, NULL
};
diff --git a/wiretap/csids.c b/wiretap/csids.c
index d144524851..bbf8b0311e 100644
--- a/wiretap/csids.c
+++ b/wiretap/csids.c
@@ -209,9 +209,16 @@ csids_read_packet(FILE_T fh, csids_t *csids, wtap_rec *rec,
return TRUE;
}
+static const struct supported_block_type csids_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info csids_info = {
"CSIDS IPLog", "csids", NULL, NULL,
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(csids_blocks_supported),
NULL, NULL, NULL
};
diff --git a/wiretap/daintree-sna.c b/wiretap/daintree-sna.c
index 97a6479117..70392e0f5f 100644
--- a/wiretap/daintree-sna.c
+++ b/wiretap/daintree-sna.c
@@ -254,9 +254,16 @@ daintree_sna_read_packet(FILE_T fh, wtap_rec *rec, Buffer *buf,
return TRUE;
}
+static const struct supported_block_type daintree_sna_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info daintree_sna_info = {
"Daintree SNA", "dsna", "dcf", NULL,
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(daintree_sna_blocks_supported),
NULL, NULL, NULL
};
diff --git a/wiretap/dbs-etherwatch.c b/wiretap/dbs-etherwatch.c
index d2adcfdf84..c213241d41 100644
--- a/wiretap/dbs-etherwatch.c
+++ b/wiretap/dbs-etherwatch.c
@@ -630,9 +630,16 @@ parse_hex_dump(char* dump, guint8 *buf, char separator, char end) {
return count;
}
+static const struct supported_block_type dbs_etherwatch_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info dbs_etherwatch_info = {
"DBS Etherwatch (VMS)", "etherwatch", "txt", NULL,
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(dbs_etherwatch_blocks_supported),
NULL, NULL, NULL
};
diff --git a/wiretap/dct3trace.c b/wiretap/dct3trace.c
index 89b8988571..6e6a7e0035 100644
--- a/wiretap/dct3trace.c
+++ b/wiretap/dct3trace.c
@@ -402,9 +402,16 @@ static gboolean dct3trace_seek_read(wtap *wth, gint64 seek_off,
return dct3trace_get_packet(wth->random_fh, rec, buf, err, err_info);
}
+static const struct supported_block_type dct3trace_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info dct3trace_info = {
"Gammu DCT3 trace", "dct3trace", "xml", NULL,
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(dct3trace_blocks_supported),
NULL, NULL, NULL
};
diff --git a/wiretap/dpa400.c b/wiretap/dpa400.c
index aa4ee490f1..be6d065f1c 100644
--- a/wiretap/dpa400.c
+++ b/wiretap/dpa400.c
@@ -246,9 +246,16 @@ wtap_open_return_val dpa400_open(wtap *wth, int *err, gchar **err_info)
return WTAP_OPEN_MINE;
}
+static const struct supported_block_type dpa400_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info dpa400_info = {
"Unigraf DPA-400 capture", "dpa400", "bin", NULL,
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(dpa400_blocks_supported),
NULL, NULL, NULL
};
diff --git a/wiretap/erf.c b/wiretap/erf.c
index 6ecf2db74f..721b180137 100644
--- a/wiretap/erf.c
+++ b/wiretap/erf.c
@@ -2455,7 +2455,7 @@ static int erf_populate_interface(erf_t *erf_priv, wtap *wth, union wtap_pseudo_
return if_map->interfaces[if_num].if_index;
}
- int_data = wtap_block_create(WTAP_BLOCK_IF_DESCRIPTION);
+ int_data = wtap_block_create(WTAP_BLOCK_IF_ID_AND_INFO);
int_data_mand = (wtapng_if_descr_mandatory_t*)wtap_block_get_mandatory_data(int_data);
int_data_mand->wtap_encap = WTAP_ENCAP_ERF;
@@ -3395,9 +3395,57 @@ static void erf_close(wtap *wth)
wth->priv = NULL;
}
+static const struct supported_option_type section_block_options_supported[] = {
+ { OPT_COMMENT, ONE_OPTION_SUPPORTED }, /* XXX - multiple? */
+ { OPT_SHB_USERAPPL, ONE_OPTION_SUPPORTED }
+};
+
+static const struct supported_option_type interface_block_options_supported[] = {
+ { OPT_COMMENT, ONE_OPTION_SUPPORTED }, /* XXX - multiple? */
+ { OPT_IDB_NAME, ONE_OPTION_SUPPORTED },
+ { OPT_IDB_DESCR, ONE_OPTION_SUPPORTED },
+ { OPT_IDB_OS, ONE_OPTION_SUPPORTED },
+ { OPT_IDB_TSOFFSET, ONE_OPTION_SUPPORTED },
+ { OPT_IDB_SPEED, ONE_OPTION_SUPPORTED },
+ { OPT_IDB_IP4ADDR, ONE_OPTION_SUPPORTED }, /* XXX - multiple? */
+ { OPT_IDB_IP6ADDR, ONE_OPTION_SUPPORTED }, /* XXX - multiple? */
+ { OPT_IDB_FILTER, ONE_OPTION_SUPPORTED },
+ { OPT_IDB_FCSLEN, ONE_OPTION_SUPPORTED }
+};
+
+static const struct supported_option_type packet_block_options_supported[] = {
+ { OPT_COMMENT, ONE_OPTION_SUPPORTED } /* XXX - multiple? */
+};
+
+static const struct supported_block_type erf_blocks_supported[] = {
+ /*
+ * Per-file comments and application supported; section blocks
+ * are used for that.
+ * ERF files have only one section. (XXX - true?)
+ */
+ { WTAP_BLOCK_SECTION, ONE_BLOCK_SUPPORTED, OPTION_TYPES_SUPPORTED(section_block_options_supported) },
+
+ /*
+ * ERF supports multiple interfaces, with information, and
+ * supports associating packets with interfaces. Interface
+ * description blocks are used for that.
+ */
+ { WTAP_BLOCK_IF_ID_AND_INFO, MULTIPLE_BLOCKS_SUPPORTED, OPTION_TYPES_SUPPORTED(interface_block_options_supported) },
+
+ /*
+ * Name resolution is supported, but we don't support comments.
+ */
+ { WTAP_BLOCK_NAME_RESOLUTION, ONE_BLOCK_SUPPORTED, NO_OPTIONS_SUPPORTED },
+
+ /*
+ * ERF is a capture format, so it obviously supports packets.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, OPTION_TYPES_SUPPORTED(packet_block_options_supported) }
+};
+
static const struct file_type_subtype_info erf_info = {
"Endace ERF capture", "erf", "erf", NULL,
- FALSE, TRUE, WTAP_COMMENT_PER_SECTION|WTAP_COMMENT_PER_INTERFACE|WTAP_COMMENT_PER_PACKET,
+ FALSE, BLOCKS_SUPPORTED(erf_blocks_supported),
erf_dump_can_write_encap, erf_dump_open, NULL
};
diff --git a/wiretap/eyesdn.c b/wiretap/eyesdn.c
index 622085ac09..32b0317fa1 100644
--- a/wiretap/eyesdn.c
+++ b/wiretap/eyesdn.c
@@ -476,10 +476,17 @@ static gboolean eyesdn_dump(wtap_dumper *wdh,
return TRUE;
}
+static const struct supported_block_type eyesdn_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info eyesdn_info = {
"EyeSDN USB S0/E1 ISDN trace format", "eyesdn", "trc", NULL,
- FALSE, FALSE, 0,
- eyesdn_dump_can_write_encap, eyesdn_dump_open, NULL
+ FALSE, BLOCKS_SUPPORTED(eyesdn_blocks_supported),
+ eyesdn_dump_can_write_encap, eyesdn_dump_open, NULL
};
void register_eyesdn(void)
diff --git a/wiretap/file_access.c b/wiretap/file_access.c
index db93a129a5..f8e0d7a41d 100644
--- a/wiretap/file_access.c
+++ b/wiretap/file_access.c
@@ -1214,6 +1214,114 @@ wtap_fdreopen(wtap *wth, const char *filename, int *err)
return TRUE;
}
+static const struct supported_block_type pcap_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
+/*
+ * pcapng supports several block types, and supports more than one
+ * of them.
+ *
+ * It also supports comments for many block types, as well as other
+ * option types.
+ */
+
+/* Options for section blocks. */
+static const struct supported_option_type section_block_options_supported[] = {
+ { OPT_COMMENT, MULTIPLE_OPTIONS_SUPPORTED },
+ { OPT_SHB_HARDWARE, ONE_OPTION_SUPPORTED },
+ { OPT_SHB_USERAPPL, ONE_OPTION_SUPPORTED }
+};
+
+/* Options for interface blocks. */
+static const struct supported_option_type interface_block_options_supported[] = {
+ { OPT_COMMENT, MULTIPLE_OPTIONS_SUPPORTED },
+ { OPT_IDB_NAME, ONE_OPTION_SUPPORTED },
+ { OPT_IDB_DESCR, ONE_OPTION_SUPPORTED },
+ { OPT_IDB_IP4ADDR, MULTIPLE_OPTIONS_SUPPORTED },
+ { OPT_IDB_IP6ADDR, MULTIPLE_OPTIONS_SUPPORTED },
+ { OPT_IDB_MACADDR, ONE_OPTION_SUPPORTED },
+ { OPT_IDB_EUIADDR, ONE_OPTION_SUPPORTED },
+ { OPT_IDB_SPEED, ONE_OPTION_SUPPORTED },
+ { OPT_IDB_TSRESOL, ONE_OPTION_SUPPORTED },
+ { OPT_IDB_TZONE, ONE_OPTION_SUPPORTED },
+ { OPT_IDB_FILTER, ONE_OPTION_SUPPORTED },
+ { OPT_IDB_OS, ONE_OPTION_SUPPORTED },
+ { OPT_IDB_FCSLEN, ONE_OPTION_SUPPORTED },
+ { OPT_IDB_TSOFFSET, ONE_OPTION_SUPPORTED },
+ { OPT_IDB_HARDWARE, ONE_OPTION_SUPPORTED }
+};
+
+/* Options for name resolution blocks. */
+static const struct supported_option_type name_resolution_block_options_supported[] = {
+ { OPT_COMMENT, MULTIPLE_OPTIONS_SUPPORTED },
+ { OPT_NS_DNSNAME, ONE_OPTION_SUPPORTED },
+ { OPT_NS_DNSIP4ADDR, ONE_OPTION_SUPPORTED },
+ { OPT_NS_DNSIP6ADDR, ONE_OPTION_SUPPORTED }
+};
+
+/* Options for interface statistics blocks. */
+static const struct supported_option_type interface_statistics_block_options_supported[] = {
+ { OPT_COMMENT, MULTIPLE_OPTIONS_SUPPORTED },
+ { OPT_ISB_STARTTIME, ONE_OPTION_SUPPORTED },
+ { OPT_ISB_ENDTIME, ONE_OPTION_SUPPORTED },
+ { OPT_ISB_IFRECV, ONE_OPTION_SUPPORTED },
+ { OPT_ISB_IFDROP, ONE_OPTION_SUPPORTED },
+ { OPT_ISB_FILTERACCEPT, ONE_OPTION_SUPPORTED },
+ { OPT_ISB_OSDROP, ONE_OPTION_SUPPORTED },
+ { OPT_ISB_USRDELIV, ONE_OPTION_SUPPORTED }
+};
+
+/* Options for decryption secrets blocks. */
+static const struct supported_option_type decryption_secrets_block_options_supported[] = {
+ { OPT_COMMENT, MULTIPLE_OPTIONS_SUPPORTED }
+};
+
+/* Options for packet blocks. */
+static const struct supported_option_type packet_block_options_supported[] = {
+ /* XXX - pending use of wtap_block_t's for packets */
+ { OPT_COMMENT, MULTIPLE_OPTIONS_SUPPORTED }
+};
+
+/* Options for file-type-sepcific reports. */
+static const struct supported_option_type ft_specific_report_block_options_supported[] = {
+ { OPT_COMMENT, MULTIPLE_OPTIONS_SUPPORTED }
+};
+
+/* Options for file-type-sepcific event. */
+static const struct supported_option_type ft_specific_event_block_options_supported[] = {
+ { OPT_COMMENT, MULTIPLE_OPTIONS_SUPPORTED }
+};
+
+static const struct supported_block_type pcapng_blocks_supported[] = {
+ /* Multiple sections. */
+ { WTAP_BLOCK_SECTION, MULTIPLE_BLOCKS_SUPPORTED, OPTION_TYPES_SUPPORTED(section_block_options_supported) },
+
+ /* Multiple interfaces. */
+ { WTAP_BLOCK_IF_ID_AND_INFO, MULTIPLE_BLOCKS_SUPPORTED, OPTION_TYPES_SUPPORTED(interface_block_options_supported) },
+
+ /* Multiple blocks of name resolution information */
+ { WTAP_BLOCK_NAME_RESOLUTION, MULTIPLE_BLOCKS_SUPPORTED, OPTION_TYPES_SUPPORTED(name_resolution_block_options_supported) },
+
+ /* Multiple blocks of interface statistics. */
+ { WTAP_BLOCK_IF_STATISTICS, MULTIPLE_BLOCKS_SUPPORTED, OPTION_TYPES_SUPPORTED(interface_statistics_block_options_supported) },
+
+ /* Multiple blocks of decryption secrets. */
+ { WTAP_BLOCK_DECRYPTION_SECRETS, MULTIPLE_BLOCKS_SUPPORTED, OPTION_TYPES_SUPPORTED(decryption_secrets_block_options_supported) },
+
+ /* And, obviously, multiple packets. */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, OPTION_TYPES_SUPPORTED(packet_block_options_supported) },
+
+ /* Multiple file-type specific reports (including local ones). */
+ { WTAP_BLOCK_FT_SPECIFIC_REPORT, MULTIPLE_BLOCKS_SUPPORTED, OPTION_TYPES_SUPPORTED(ft_specific_report_block_options_supported) },
+
+ /* Multiple file-type specific events (including local ones). */
+ { WTAP_BLOCK_FT_SPECIFIC_EVENT, MULTIPLE_BLOCKS_SUPPORTED, OPTION_TYPES_SUPPORTED(ft_specific_event_block_options_supported) }
+};
+
/* Table of the file types and subtypes for which we have built-in support.
Entries must be sorted by WTAP_FILE_TYPE_SUBTYPE_xxx values in ascending
order.
@@ -1228,59 +1336,49 @@ wtap_fdreopen(wtap *wth, const char *filename, int *err)
static const struct file_type_subtype_info file_type_subtype_table_base[] = {
/* WTAP_FILE_TYPE_SUBTYPE_UNKNOWN (only used internally for initialization) */
{ NULL, NULL, NULL, NULL,
- FALSE, FALSE, 0,
+ FALSE, NO_OPTIONS_SUPPORTED,
NULL, NULL, NULL },
/* WTAP_FILE_TYPE_SUBTYPE_PCAP */
/* Gianluca Varenni suggests that we add "deprecated" to the description. */
{ "Wireshark/tcpdump/... - pcap", "pcap", "pcap", "cap;dmp",
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(pcap_blocks_supported),
libpcap_dump_can_write_encap, libpcap_dump_open, NULL },
/* WTAP_FILE_TYPE_SUBTYPE_PCAPNG */
{ "Wireshark/... - pcapng", "pcapng", "pcapng", "ntar",
- FALSE, TRUE, WTAP_COMMENT_PER_SECTION|WTAP_COMMENT_PER_INTERFACE|WTAP_COMMENT_PER_PACKET,
+ FALSE, BLOCKS_SUPPORTED(pcapng_blocks_supported),
pcapng_dump_can_write_encap, pcapng_dump_open, NULL },
/* WTAP_FILE_TYPE_SUBTYPE_PCAP_NSEC */
{ "Wireshark/tcpdump/... - nanosecond pcap", "nsecpcap", "pcap", "cap;dmp",
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(pcap_blocks_supported),
libpcap_dump_can_write_encap, libpcap_dump_open, NULL },
/* WTAP_FILE_TYPE_SUBTYPE_PCAP_AIX */
{ "AIX tcpdump - pcap", "aixpcap", "pcap", "cap;dmp",
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(pcap_blocks_supported),
NULL, NULL, NULL },
/* WTAP_FILE_TYPE_SUBTYPE_PCAP_SS991029 */
{ "Modified tcpdump - pcap", "modpcap", "pcap", "cap;dmp",
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(pcap_blocks_supported),
libpcap_dump_can_write_encap, libpcap_dump_open, NULL },
/* WTAP_FILE_TYPE_SUBTYPE_PCAP_NOKIA */
{ "Nokia tcpdump - pcap", "nokiapcap", "pcap", "cap;dmp",
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(pcap_blocks_supported),
libpcap_dump_can_write_encap, libpcap_dump_open, NULL },
/* WTAP_FILE_TYPE_SUBTYPE_PCAP_SS990417 */
{ "RedHat 6.1 tcpdump - pcap", "rh6_1pcap", "pcap", "cap;dmp",
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(pcap_blocks_supported),
libpcap_dump_can_write_encap, libpcap_dump_open, NULL },
/* WTAP_FILE_TYPE_SUBTYPE_PCAP_SS990915 */
{ "SuSE 6.3 tcpdump - pcap", "suse6_3pcap", "pcap", "cap;dmp",
- FALSE, FALSE, 0,
- libpcap_dump_can_write_encap, libpcap_dump_open, NULL },
-
- /* WTAP_FILE_TYPE_SUBTYPE_IPTRACE_1_0 */
- { "AIX iptrace 1.0", "iptrace_1", NULL, NULL,
- FALSE, FALSE, 0,
- NULL, NULL, NULL },
-
- /* WTAP_FILE_TYPE_SUBTYPE_IPTRACE_2_0 */
- { "AIX iptrace 2.0", "iptrace_2", NULL, NULL,
- FALSE, FALSE, 0,
- NULL, NULL, NULL }
+ FALSE, BLOCKS_SUPPORTED(pcap_blocks_supported),
+ libpcap_dump_can_write_encap, libpcap_dump_open, NULL }
};
#define N_DUMP_OPEN_TABLE_BASE_ENTRIES (sizeof(file_type_subtype_table_base) / sizeof(struct file_type_subtype_info))
@@ -1438,8 +1536,8 @@ wtap_deregister_file_type_subtype(const int subtype)
finfo->default_file_extension = NULL;
finfo->additional_file_extensions = NULL;
finfo->writing_must_seek = FALSE;
- finfo->has_name_resolution = FALSE;
- finfo->supported_comment_types = 0;
+ finfo->num_supported_blocks = 0;
+ finfo->supported_blocks = NULL;
finfo->can_write_encap = NULL;
finfo->dump_open = NULL;
finfo->wslua_info = NULL;
@@ -1515,9 +1613,26 @@ wtap_dump_can_write_format(int ft, const GArray *file_encaps,
* Yes. Can we write out all the required comments in this
* format?
*/
- if (!wtap_dump_supports_comment_types(ft, required_comment_types)) {
- /* No. */
- return FALSE;
+ if (required_comment_types & WTAP_COMMENT_PER_SECTION) {
+ if (wtap_file_type_subtype_supports_option(ft,
+ WTAP_BLOCK_SECTION, OPT_COMMENT) == OPTION_NOT_SUPPORTED) {
+ /* Not section comments. */
+ return FALSE;
+ }
+ }
+ if (required_comment_types & WTAP_COMMENT_PER_INTERFACE) {
+ if (wtap_file_type_subtype_supports_option(ft,
+ WTAP_BLOCK_IF_ID_AND_INFO, OPT_COMMENT) == OPTION_NOT_SUPPORTED) {
+ /* Not interface comments. */
+ return FALSE;
+ }
+ }
+ if (required_comment_types & WTAP_COMMENT_PER_PACKET) {
+ if (wtap_file_type_subtype_supports_option(ft,
+ WTAP_BLOCK_PACKET, OPT_COMMENT) == OPTION_NOT_SUPPORTED) {
+ /* Not packet comments. */
+ return FALSE;
+ }
}
/*
@@ -1764,24 +1879,6 @@ wtap_get_writable_file_types_subtypes(ft_sort_order sort_order)
return writable_file_types_subtypes;
}
-/**
- * Return TRUE if files of this file type/subtype use interface IDs
- * to associate records with an interface.
- */
-gboolean
-wtap_uses_interface_ids(int file_type)
-{
- /*
- * XXX - for now, pcapng and iptrace are the only such file types.
- * We don't write iptrace files, so this doesn't currently
- * matter, but we provide this API to make it clearer what's
- * being checked.
- */
- return file_type == WTAP_FILE_TYPE_SUBTYPE_PCAPNG ||
- file_type == WTAP_FILE_TYPE_SUBTYPE_IPTRACE_1_0 ||
- file_type == WTAP_FILE_TYPE_SUBTYPE_IPTRACE_2_0;
-}
-
/* String describing the file type/subtype. */
const char *
wtap_file_type_subtype_description(int file_type_subtype)
@@ -1847,6 +1944,77 @@ wtap_name_to_file_type_subtype(const char *name)
return -1; /* no such file type, or we can't write it */
}
+block_support_t
+wtap_file_type_subtype_supports_block(int filetype, wtap_block_type_t type)
+{
+ size_t num_supported_blocks;
+ const struct supported_block_type *supported_blocks;
+
+ num_supported_blocks = file_type_subtype_table[filetype].num_supported_blocks;
+ supported_blocks = file_type_subtype_table[filetype].supported_blocks;
+
+ for (size_t i = 0; i < num_supported_blocks; i++) {
+ if (supported_blocks[i].type == type)
+ return supported_blocks[i].support;
+ }
+
+ /*
+ * Not found, which means not supported.
+ */
+ return BLOCK_NOT_SUPPORTED;
+}
+
+option_support_t
+wtap_file_type_subtype_supports_option(int filetype, wtap_block_type_t type,
+ guint option)
+{
+ size_t num_supported_blocks;
+ const struct supported_block_type *supported_blocks;
+
+ num_supported_blocks = file_type_subtype_table[filetype].num_supported_blocks;
+ supported_blocks = file_type_subtype_table[filetype].supported_blocks;
+
+ for (size_t i = 0; i < num_supported_blocks; i++) {
+ if (supported_blocks[i].type == type) {
+ /*
+ * OK, that block is known.
+ * Is it supported?
+ */
+ if (supported_blocks[i].support == BLOCK_NOT_SUPPORTED) {
+ /*
+ * No, so clearly the option isn't
+ * supported in that block.
+ */
+ return OPTION_NOT_SUPPORTED;
+ }
+
+ /*
+ * Yes, so check the options.
+ */
+ size_t num_supported_options;
+ const struct supported_option_type *supported_options;
+
+ num_supported_options = supported_blocks[i].num_supported_options;
+ supported_options = supported_blocks[i].supported_options;
+ for (size_t j = 0; j < num_supported_options; i++) {
+ if (supported_options[i].opt == option)
+ return supported_options[i].support;
+ }
+
+ /*
+ * Not found, which means not supported.
+ */
+ return OPTION_NOT_SUPPORTED;
+ }
+ }
+
+ /*
+ * The block type wasn't found, which means it's not supported,
+ * which means the option isn't supported in that block.
+ */
+ return OPTION_NOT_SUPPORTED;
+}
+
static GSList *
add_extensions_for_file_type_subtype(int file_type_subtype, GSList *extensions,
GSList *compression_type_extensions)
@@ -2037,33 +2205,6 @@ wtap_dump_can_compress(int file_type_subtype _U_)
}
#endif
-gboolean
-wtap_dump_has_name_resolution(int file_type_subtype)
-{
- if (file_type_subtype < 0 ||
- file_type_subtype >= (int)file_type_subtype_table_arr->len ||
- file_type_subtype_table[file_type_subtype].has_name_resolution == FALSE)
- return FALSE;
-
- return TRUE;
-}
-
-gboolean
-wtap_dump_supports_comment_types(int file_type_subtype, guint32 comment_types)
-{
- guint32 supported_comment_types;
-
- if (file_type_subtype < 0 ||
- file_type_subtype >= (int)file_type_subtype_table_arr->len)
- return FALSE;
-
- supported_comment_types = file_type_subtype_table[file_type_subtype].supported_comment_types;
-
- if ((comment_types & supported_comment_types) == comment_types)
- return TRUE;
- return FALSE;
-}
-
static gboolean wtap_dump_open_check(int file_type_subtype, int encap, gboolean compressed, int *err);
static wtap_dumper* wtap_dump_alloc_wdh(int file_type_subtype, int encap, int snaplen,
wtap_compression_type compression_type,
@@ -2124,7 +2265,7 @@ wtap_dump_init_dumper(int file_type_subtype, wtap_compression_type compression_t
int snaplen;
// XXX IDBs should be optional.
- descr = wtap_block_create(WTAP_BLOCK_IF_DESCRIPTION);
+ descr = wtap_block_create(WTAP_BLOCK_IF_ID_AND_INFO);
descr_mand = (wtapng_if_descr_mandatory_t*)wtap_block_get_mandatory_data(descr);
descr_mand->wtap_encap = params->encap;
descr_mand->tsprecision = params->tsprec;
@@ -2574,7 +2715,7 @@ wtap_dump_set_addrinfo_list(wtap_dumper *wdh, addrinfo_lists_t *addrinfo_lists)
{
if (!wdh || wdh->file_type_subtype < 0 ||
wdh->file_type_subtype >= (int)file_type_subtype_table_arr->len ||
- file_type_subtype_table[wdh->file_type_subtype].has_name_resolution == FALSE)
+ wtap_file_type_subtype_supports_block(wdh->file_type_subtype, WTAP_BLOCK_NAME_RESOLUTION) == BLOCK_NOT_SUPPORTED)
return FALSE;
wdh->addrinfo_lists = addrinfo_lists;
return TRUE;
@@ -2821,10 +2962,6 @@ wtap_register_backwards_compatibility_lua_name(const char *name, int ft)
WTAP_FILE_TYPE_SUBTYPE_PCAP_SS990417);
wtap_register_backwards_compatibility_lua_name("PCAP_SS990915",
WTAP_FILE_TYPE_SUBTYPE_PCAP_SS990915);
- wtap_register_backwards_compatibility_lua_name("IPTRACE_1_0",
- WTAP_FILE_TYPE_SUBTYPE_IPTRACE_1_0);
- wtap_register_backwards_compatibility_lua_name("IPTRACE_2_0",
- WTAP_FILE_TYPE_SUBTYPE_IPTRACE_2_0);
}
entry.name = name;
entry.ft = ft;
diff --git a/wiretap/hcidump.c b/wiretap/hcidump.c
index 902f8df5cf..2423630096 100644
--- a/wiretap/hcidump.c
+++ b/wiretap/hcidump.c
@@ -121,11 +121,17 @@ wtap_open_return_val hcidump_open(wtap *wth, int *err, gchar **err_info)
return WTAP_OPEN_MINE;
}
+static const struct supported_block_type hcidummp_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info hcidump_info = {
"Bluetooth HCI dump", "hcidump", NULL, NULL,
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(hcidummp_blocks_supported),
NULL, NULL, NULL
-
};
void register_hcidump(void)
diff --git a/wiretap/i4btrace.c b/wiretap/i4btrace.c
index 439e8e1a20..5489822c47 100644
--- a/wiretap/i4btrace.c
+++ b/wiretap/i4btrace.c
@@ -297,9 +297,16 @@ i4b_read_rec(wtap *wth, FILE_T fh, wtap_rec *rec, Buffer *buf,
return wtap_read_packet_bytes(fh, buf, length, err, err_info);
}
+static const struct supported_block_type i4btrace_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info i4btrace_info = {
"I4B ISDN trace", "i4btrace", NULL, NULL,
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(i4btrace_blocks_supported),
NULL, NULL, NULL
};
diff --git a/wiretap/ipfix.c b/wiretap/ipfix.c
index 120f752179..a71a4a6cad 100644
--- a/wiretap/ipfix.c
+++ b/wiretap/ipfix.c
@@ -328,9 +328,16 @@ ipfix_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec,
return TRUE;
}
+static const struct supported_block_type ipfix_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info ipfix_info = {
"IPFIX File Format", "ipfix", "pfx", "ipfix",
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(ipfix_blocks_supported),
NULL, NULL, NULL
};
diff --git a/wiretap/iptrace.c b/wiretap/iptrace.c
index 1b471bc9bc..d506999298 100644
--- a/wiretap/iptrace.c
+++ b/wiretap/iptrace.c
@@ -61,6 +61,11 @@ typedef struct {
guint8 if_type;
} if_info;
+static int iptrace_1_0_file_type_subtype = -1;
+static int iptrace_2_0_file_type_subtype = -1;
+
+void register_iptrace(void);
+
static gboolean destroy_if_info(gpointer key, gpointer value _U_,
gpointer user_data _U_)
{
@@ -102,13 +107,13 @@ wtap_open_return_val iptrace_open(wtap *wth, int *err, gchar **err_info)
version_string[VERSION_STRING_SIZE] = '\0';
if (strcmp(version_string, "iptrace 1.0") == 0) {
- wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_IPTRACE_1_0;
+ wth->file_type_subtype = iptrace_1_0_file_type_subtype;
wth->subtype_read = iptrace_read_1_0;
wth->subtype_seek_read = iptrace_seek_read_1_0;
wth->file_tsprec = WTAP_TSPREC_SEC;
}
else if (strcmp(version_string, "iptrace 2.0") == 0) {
- wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_IPTRACE_2_0;
+ wth->file_type_subtype = iptrace_2_0_file_type_subtype;
wth->subtype_read = iptrace_read_2_0;
wth->subtype_seek_read = iptrace_seek_read_2_0;
wth->file_tsprec = WTAP_TSPREC_NSEC;
@@ -329,7 +334,7 @@ iptrace_read_rec_1_0(wtap *wth, FILE_T fh, wtap_rec *rec, Buffer *buf,
/*
* Now make a new IDB and add it.
*/
- int_data = wtap_block_create(WTAP_BLOCK_IF_DESCRIPTION);
+ int_data = wtap_block_create(WTAP_BLOCK_IF_ID_AND_INFO);
int_data_mand = (wtapng_if_descr_mandatory_t *)wtap_block_get_mandatory_data(int_data);
int_data_mand->wtap_encap = rec->rec_header.packet_header.pkt_encap;
@@ -600,7 +605,7 @@ iptrace_read_rec_2_0(wtap *wth, FILE_T fh, wtap_rec *rec, Buffer *buf,
/*
* Now make a new IDB and add it.
*/
- int_data = wtap_block_create(WTAP_BLOCK_IF_DESCRIPTION);
+ int_data = wtap_block_create(WTAP_BLOCK_IF_ID_AND_INFO);
int_data_mand = (wtapng_if_descr_mandatory_t *)wtap_block_get_mandatory_data(int_data);
int_data_mand->wtap_encap = rec->rec_header.packet_header.pkt_encap;
@@ -826,6 +831,69 @@ wtap_encap_ift(unsigned int ift)
}
}
+/* Options for interface blocks. */
+static const struct supported_option_type interface_block_options_supported[] = {
+ /* No comments, just an interface name. */
+ { OPT_IDB_NAME, ONE_OPTION_SUPPORTED }
+};
+
+static const struct supported_block_type iptrace_1_0_blocks_supported[] = {
+ /*
+ * iptrace supports multiple interfaces, with descriptions, and
+ * supports associating packets with interfaces. Interface
+ * description blocks are used for that.
+ */
+ { WTAP_BLOCK_IF_ID_AND_INFO, MULTIPLE_BLOCKS_SUPPORTED, OPTION_TYPES_SUPPORTED(interface_block_options_supported) },
+
+ /*
+ * iptrace is a capture format, so it obviously supports packets.
+ * It supports no packet options, however.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
+static const struct file_type_subtype_info iptrace_1_0_info = {
+ "AIX iptrace 1.0", "iptrace_1", NULL, NULL,
+ FALSE, BLOCKS_SUPPORTED(iptrace_1_0_blocks_supported),
+ NULL, NULL, NULL
+};
+
+static const struct supported_block_type iptrace_2_0_blocks_supported[] = {
+ /*
+ * iptrace supports multiple interfaces, with descriptions, and
+ * supports associating packets with interfaces. Interface
+ * description blocks are used for that.
+ */
+ { WTAP_BLOCK_IF_ID_AND_INFO, MULTIPLE_BLOCKS_SUPPORTED, OPTION_TYPES_SUPPORTED(interface_block_options_supported) },
+
+ /*
+ * iptrace is a capture format, so it obviously supports packets.
+ * It supports no packet options, however.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
+static const struct file_type_subtype_info iptrace_2_0_info = {
+ "AIX iptrace 2.0", "iptrace_2", NULL, NULL,
+ FALSE, BLOCKS_SUPPORTED(iptrace_2_0_blocks_supported),
+ NULL, NULL, NULL
+};
+
+void register_iptrace(void)
+{
+ iptrace_1_0_file_type_subtype = wtap_register_file_type_subtypes(&iptrace_1_0_info);
+ iptrace_2_0_file_type_subtype = wtap_register_file_type_subtypes(&iptrace_2_0_info);
+
+ /*
+ * Register names for backwards compatibility with the
+ * wtap_filetypes table in Lua.
+ */
+ wtap_register_backwards_compatibility_lua_name("IPTRACE_1_0",
+ iptrace_1_0_file_type_subtype);
+ wtap_register_backwards_compatibility_lua_name("IPTRACE_2_0",
+ iptrace_2_0_file_type_subtype);
+}
+
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
diff --git a/wiretap/iseries.c b/wiretap/iseries.c
index d9fce389e8..cde980a12d 100644
--- a/wiretap/iseries.c
+++ b/wiretap/iseries.c
@@ -1052,15 +1052,29 @@ iseries_parse_hex_string (const char * ascii, guint8 * buf, size_t len)
return TRUE;
}
+static const struct supported_block_type iseries_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info iseries_info = {
"IBM iSeries comm. trace (ASCII)", "iseries_ascii", "txt", NULL,
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(iseries_blocks_supported),
NULL, NULL, NULL
};
+static const struct supported_block_type iseries_unicode_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info iseries_unicode_info = {
"IBM iSeries comm. trace (Unicode)", "iseries_unicode", "txt", NULL,
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(iseries_unicode_blocks_supported),
NULL, NULL, NULL
};
diff --git a/wiretap/json.c b/wiretap/json.c
index 064cca584b..b350dfeb42 100644
--- a/wiretap/json.c
+++ b/wiretap/json.c
@@ -67,9 +67,18 @@ wtap_open_return_val json_open(wtap *wth, int *err, gchar **err_info)
return WTAP_OPEN_MINE;
}
+static const struct supported_block_type json_blocks_supported[] = {
+ /*
+ * This is a file format that we dissect, so we provide only one
+ * "packet" with the file's contents, and don't support any
+ * options.
+ */
+ { WTAP_BLOCK_PACKET, ONE_BLOCK_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info json_info = {
"JavaScript Object Notation", "json", "json", NULL,
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(json_blocks_supported),
NULL, NULL, NULL
};
diff --git a/wiretap/k12.c b/wiretap/k12.c
index 2a76990fcd..7521903424 100644
--- a/wiretap/k12.c
+++ b/wiretap/k12.c
@@ -1393,9 +1393,16 @@ static gboolean k12_dump_open(wtap_dumper *wdh, int *err, gchar **err_info _U_)
return TRUE;
}
+static const struct supported_block_type k12_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info k12_info = {
"Tektronix K12xx 32-bit .rf5 format", "rf5", "rf5", NULL,
- TRUE, FALSE, 0,
+ TRUE, BLOCKS_SUPPORTED(k12_blocks_supported),
k12_dump_can_write_encap, k12_dump_open, NULL
};
diff --git a/wiretap/k12text.l b/wiretap/k12text.l
index 32aef08205..2c04b53abe 100644
--- a/wiretap/k12text.l
+++ b/wiretap/k12text.l
@@ -576,9 +576,16 @@ k12text_dump_can_write_encap(int encap)
}
}
+static const struct supported_block_type k12text_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info k12text_info = {
"K12 text file", "k12text", "txt", NULL,
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(k12text_blocks_supported),
k12text_dump_can_write_encap, k12text_dump_open, NULL
};
diff --git a/wiretap/lanalyzer.c b/wiretap/lanalyzer.c
index 85ae5538bc..a12fe158d7 100644
--- a/wiretap/lanalyzer.c
+++ b/wiretap/lanalyzer.c
@@ -964,9 +964,16 @@ static gboolean lanalyzer_dump_finish(wtap_dumper *wdh, int *err,
return *err ? FALSE : TRUE;
}
+static const struct supported_block_type lanalyzer_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info lanalyzer_info = {
"Novell LANalyzer","lanalyzer", "tr1", NULL,
- TRUE, FALSE, 0,
+ TRUE, BLOCKS_SUPPORTED(lanalyzer_blocks_supported),
lanalyzer_dump_can_write_encap, lanalyzer_dump_open, NULL
};
diff --git a/wiretap/log3gpp.c b/wiretap/log3gpp.c
index ba48a966a2..d4f089ed37 100644
--- a/wiretap/log3gpp.c
+++ b/wiretap/log3gpp.c
@@ -886,9 +886,16 @@ gboolean get_file_time_stamp(gchar* linebuff, time_t *secs, guint32 *usecs)
return TRUE;
}
+static const struct supported_block_type log3gpp_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info log3gpp_info = {
"3GPP Log", "3gpp_log", "*.log", NULL,
- TRUE, FALSE, 0,
+ TRUE, BLOCKS_SUPPORTED(log3gpp_blocks_supported),
NULL, NULL, NULL
};
diff --git a/wiretap/logcat.c b/wiretap/logcat.c
index 5181b9124a..795e3ef617 100644
--- a/wiretap/logcat.c
+++ b/wiretap/logcat.c
@@ -364,9 +364,16 @@ static gboolean logcat_binary_dump_open(wtap_dumper *wdh, int *err _U_,
return TRUE;
}
+static const struct supported_block_type logcat_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info logcat_info = {
"Android Logcat Binary format", "logcat", "logcat", NULL,
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(logcat_blocks_supported),
logcat_dump_can_write_encap, logcat_binary_dump_open, NULL
};
diff --git a/wiretap/logcat_text.c b/wiretap/logcat_text.c
index b49eed49f8..13416ac436 100644
--- a/wiretap/logcat_text.c
+++ b/wiretap/logcat_text.c
@@ -628,45 +628,94 @@ static gboolean logcat_text_long_dump_open(wtap_dumper *wdh, int *err _U_, gchar
return logcat_text_dump_open(wdh, WTAP_ENCAP_LOGCAT_LONG);
}
+static const struct supported_block_type logcat_text_brief_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info logcat_text_brief_info = {
"Android Logcat Brief text format", "logcat-brief", NULL, NULL,
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(logcat_text_brief_blocks_supported),
logcat_text_brief_dump_can_write_encap, logcat_text_brief_dump_open, NULL
};
+static const struct supported_block_type logcat_text_process_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info logcat_text_process_info = {
"Android Logcat Process text format", "logcat-process", NULL, NULL,
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(logcat_text_process_blocks_supported),
logcat_text_process_dump_can_write_encap, logcat_text_process_dump_open, NULL
};
+static const struct supported_block_type logcat_text_tag_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info logcat_text_tag_info = {
"Android Logcat Tag text format", "logcat-tag", NULL, NULL,
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(logcat_text_tag_blocks_supported),
logcat_text_tag_dump_can_write_encap, logcat_text_tag_dump_open, NULL
};
+static const struct supported_block_type logcat_text_thread_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info logcat_text_thread_info = {
"Android Logcat Thread text format", "logcat-thread", NULL, NULL,
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(logcat_text_thread_blocks_supported),
logcat_text_thread_dump_can_write_encap, logcat_text_thread_dump_open, NULL
};
+static const struct supported_block_type logcat_text_time_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info logcat_text_time_info = {
"Android Logcat Time text format", "logcat-time", NULL, NULL,
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(logcat_text_time_blocks_supported),
logcat_text_time_dump_can_write_encap, logcat_text_time_dump_open, NULL
};
+static const struct supported_block_type logcat_text_threadtime_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info logcat_text_threadtime_info = {
"Android Logcat Threadtime text format", "logcat-threadtime", NULL, NULL,
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(logcat_text_threadtime_blocks_supported),
logcat_text_threadtime_dump_can_write_encap, logcat_text_threadtime_dump_open, NULL
};
+static const struct supported_block_type logcat_text_long_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info logcat_text_long_info = {
"Android Logcat Long text format", "logcat-long", NULL, NULL,
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(logcat_text_long_blocks_supported),
logcat_text_long_dump_can_write_encap, logcat_text_long_dump_open, NULL
};
diff --git a/wiretap/merge.c b/wiretap/merge.c
index 2c18d27aec..8f156f2dab 100644
--- a/wiretap/merge.c
+++ b/wiretap/merge.c
@@ -713,7 +713,7 @@ static guint
add_idb_to_merged_file(wtapng_iface_descriptions_t *merged_idb_list,
const wtap_block_t input_file_idb)
{
- wtap_block_t idb = wtap_block_create(WTAP_BLOCK_IF_DESCRIPTION);
+ wtap_block_t idb = wtap_block_create(WTAP_BLOCK_IF_ID_AND_INFO);
wtapng_if_descr_mandatory_t* idb_mand;
g_assert(merged_idb_list != NULL);
@@ -908,7 +908,15 @@ merge_process_packets(wtap_dumper *pdh, const int file_type,
break;
}
- if (wtap_uses_interface_ids(file_type)) {
+ /*
+ * Does this file type support identifying the interfaces on
+ * which packets arrive?
+ *
+ * That mean that the abstract interface provided by libwiretap
+ * involves WTAP_BLOCK_IF_ID_AND_INFO blocks.
+ */
+ if (wtap_file_type_subtype_supports_block(file_type,
+ WTAP_BLOCK_IF_ID_AND_INFO) != BLOCK_NOT_SUPPORTED) {
/*
* XXX - We should do this only for record types
* that pertain to a particular interface; for
@@ -1038,7 +1046,15 @@ merge_files_common(const gchar* out_filename, /* normal output mode */
wtap_dump_params params = WTAP_DUMP_PARAMS_INIT;
params.encap = frame_type;
params.snaplen = snaplen;
- if (wtap_uses_interface_ids(file_type)) {
+ /*
+ * Does this file type support identifying the interfaces on
+ * which packets arrive?
+ *
+ * That mean that the abstract interface provided by libwiretap
+ * involves WTAP_BLOCK_IF_ID_AND_INFO blocks.
+ */
+ if (wtap_file_type_subtype_supports_block(file_type,
+ WTAP_BLOCK_IF_ID_AND_INFO) != BLOCK_NOT_SUPPORTED) {
shb_hdrs = create_shb_header(in_files, in_file_count, app_name);
merge_debug("merge_files: SHB created");
diff --git a/wiretap/mime_file.c b/wiretap/mime_file.c
index 2fb4295533..074b30d835 100644
--- a/wiretap/mime_file.c
+++ b/wiretap/mime_file.c
@@ -149,10 +149,19 @@ mime_file_open(wtap *wth, int *err, gchar **err_info)
return WTAP_OPEN_MINE;
}
+static const struct supported_block_type mime_blocks_supported[] = {
+ /*
+ * This is a file format that we dissect, so we provide
+ * only one "packet" with the file's contents, and don't
+ * support any options.
+ */
+ { WTAP_BLOCK_PACKET, ONE_BLOCK_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info mime_info = {
"MIME File Format", "mime", NULL, NULL,
- FALSE, FALSE, 0,
- NULL, NULL, NULL
+ FALSE, BLOCKS_SUPPORTED(mime_blocks_supported),
+ NULL, NULL, NULL
};
/*
@@ -160,9 +169,18 @@ static const struct file_type_subtype_info mime_info = {
* look for the file type "JPEG_JFIF"; it may be removed once
* we get rid of wtap_filetypes.
*/
+static const struct supported_block_type jpeg_jfif_blocks_supported[] = {
+ /*
+ * This is a file format that we dissect, so we provide
+ * only one "packet" with the file's contents, and don't
+ * support any options.
+ */
+ { WTAP_BLOCK_PACKET, ONE_BLOCK_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info jpeg_jfif_info = {
"JPEG/JFIF", "jpeg", "jpg", "jpeg;jfif",
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(jpeg_jfif_blocks_supported),
NULL, NULL, NULL
};
diff --git a/wiretap/mp2t.c b/wiretap/mp2t.c
index c05bb684c8..50cc93819d 100644
--- a/wiretap/mp2t.c
+++ b/wiretap/mp2t.c
@@ -395,9 +395,16 @@ found:
return WTAP_OPEN_MINE;
}
+static const struct supported_block_type mp2t_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info mp2t_info = {
"MPEG2 transport stream", "mp2t", "mp2t", "ts;mpg",
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(mp2t_blocks_supported),
NULL, NULL, NULL
};
diff --git a/wiretap/mp4.c b/wiretap/mp4.c
index 3f7e1efb51..3b8e7aa263 100644
--- a/wiretap/mp4.c
+++ b/wiretap/mp4.c
@@ -52,9 +52,18 @@ mp4_open(wtap *wth, int *err, gchar **err_info)
return WTAP_OPEN_MINE;
}
+static const struct supported_block_type mp4_blocks_supported[] = {
+ /*
+ * This is a file format that we dissect, so we provide
+ * only one "packet" with the file's contents, and don't
+ * support any options.
+ */
+ { WTAP_BLOCK_PACKET, ONE_BLOCK_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info mp4_info = {
"MP4 media", "mp4", "mp4", NULL,
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(mp4_blocks_supported),
NULL, NULL, NULL
};
diff --git a/wiretap/mpeg.c b/wiretap/mpeg.c
index f5ce370a22..a5f4e6b46b 100644
--- a/wiretap/mpeg.c
+++ b/wiretap/mpeg.c
@@ -265,9 +265,18 @@ good_magic:
return WTAP_OPEN_MINE;
}
+static const struct supported_block_type mpeg_blocks_supported[] = {
+ /*
+ * This is a file format that we dissect, so we provide
+ * only one "packet" with the file's contents, and don't
+ * support any options.
+ */
+ { WTAP_BLOCK_PACKET, ONE_BLOCK_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info mpeg_info = {
"MPEG", "mpeg", "mpeg", "mpg;mp3",
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(mpeg_blocks_supported),
NULL, NULL, NULL
};
diff --git a/wiretap/mplog.c b/wiretap/mplog.c
index 0c31c964bd..63b10cae9f 100644
--- a/wiretap/mplog.c
+++ b/wiretap/mplog.c
@@ -254,9 +254,16 @@ wtap_open_return_val mplog_open(wtap *wth, int *err, gchar **err_info)
return WTAP_OPEN_MINE;
}
+static const struct supported_block_type mplog_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info mplog_info = {
"Micropross mplog", "mplog", "mplog", NULL,
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(mplog_blocks_supported),
NULL, NULL, NULL
};
diff --git a/wiretap/netmon.c b/wiretap/netmon.c
index 0b7c9d5bfd..9e2023e09b 100644
--- a/wiretap/netmon.c
+++ b/wiretap/netmon.c
@@ -1979,15 +1979,29 @@ static gboolean netmon_dump_finish(wtap_dumper *wdh, int *err,
return TRUE;
}
+static const struct supported_block_type netmon_1_x_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info netmon_1_x_info = {
"Microsoft NetMon 1.x", "netmon1", "cap", NULL,
- TRUE, FALSE, 0,
+ TRUE, BLOCKS_SUPPORTED(netmon_1_x_blocks_supported),
netmon_dump_can_write_encap_1_x, netmon_dump_open_1_x, NULL
};
+static const struct supported_block_type netmon_2_x_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info netmon_2_x_info = {
"Microsoft NetMon 2.x", "netmon2", "cap", NULL,
- TRUE, FALSE, 0,
+ TRUE, BLOCKS_SUPPORTED(netmon_2_x_blocks_supported),
netmon_dump_can_write_encap_2_x, netmon_dump_open_2_x, NULL
};
diff --git a/wiretap/netscaler.c b/wiretap/netscaler.c
index 1b313d219a..af3a6b2f68 100644
--- a/wiretap/netscaler.c
+++ b/wiretap/netscaler.c
@@ -2415,27 +2415,55 @@ static gboolean nstrace_dump(wtap_dumper *wdh, const wtap_rec *rec,
return TRUE;
}
+static const struct supported_block_type nstrace_1_0_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info nstrace_1_0_info = {
"NetScaler Trace (Version 1.0)", "nstrace10", NULL, NULL,
- TRUE, FALSE, 0,
+ TRUE, BLOCKS_SUPPORTED(nstrace_1_0_blocks_supported),
nstrace_10_dump_can_write_encap, nstrace_10_dump_open, NULL
};
+static const struct supported_block_type nstrace_2_0_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info nstrace_2_0_info = {
"NetScaler Trace (Version 2.0)", "nstrace20", "cap", NULL,
- TRUE, FALSE, 0,
+ TRUE, BLOCKS_SUPPORTED(nstrace_2_0_blocks_supported),
nstrace_20_dump_can_write_encap, nstrace_20_dump_open, NULL
};
+static const struct supported_block_type nstrace_3_0_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info nstrace_3_0_info = {
"NetScaler Trace (Version 3.0)", "nstrace30", "cap", NULL,
- TRUE, FALSE, 0,
+ TRUE, BLOCKS_SUPPORTED(nstrace_3_0_blocks_supported),
nstrace_30_dump_can_write_encap, nstrace_30_dump_open, NULL
};
+static const struct supported_block_type nstrace_3_5_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info nstrace_3_5_info = {
"NetScaler Trace (Version 3.5)", "nstrace35", "cap", NULL,
- TRUE, FALSE, 0,
+ TRUE, BLOCKS_SUPPORTED(nstrace_3_5_blocks_supported),
nstrace_35_dump_can_write_encap, nstrace_35_dump_open, NULL
};
diff --git a/wiretap/netscreen.c b/wiretap/netscreen.c
index 597267164a..26fff07994 100644
--- a/wiretap/netscreen.c
+++ b/wiretap/netscreen.c
@@ -450,9 +450,16 @@ parse_single_hex_dump_line(char* rec, guint8 *buf, guint byte_offset)
return num_items_scanned;
}
+static const struct supported_block_type netscreen_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info netscreen_info = {
"NetScreen snoop text file", "netscreen", "txt", NULL,
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(netscreen_blocks_supported),
NULL, NULL, NULL
};
diff --git a/wiretap/nettl.c b/wiretap/nettl.c
index c9e8f6c1ed..b831fe12bd 100644
--- a/wiretap/nettl.c
+++ b/wiretap/nettl.c
@@ -797,9 +797,16 @@ static gboolean nettl_dump(wtap_dumper *wdh,
return TRUE;
}
+static const struct supported_block_type nettl_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info nettl_info = {
"HP-UX nettl trace", "nettl", "trc0", "trc1",
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(nettl_blocks_supported),
nettl_dump_can_write_encap, nettl_dump_open, NULL
};
diff --git a/wiretap/nettrace_3gpp_32_423.c b/wiretap/nettrace_3gpp_32_423.c
index 2bba6b77da..338c3ff2c7 100644
--- a/wiretap/nettrace_3gpp_32_423.c
+++ b/wiretap/nettrace_3gpp_32_423.c
@@ -831,9 +831,16 @@ nettrace_3gpp_32_423_file_open(wtap *wth, int *err, gchar **err_info)
return WTAP_OPEN_MINE;
}
+static const struct supported_block_type nettrace_3gpp_32_423_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info nettrace_3gpp_32_423_info = {
"3GPP TS 32.423 Trace", "3gpp32423", NULL, NULL,
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(nettrace_3gpp_32_423_blocks_supported),
NULL, NULL, NULL
};
diff --git a/wiretap/network_instruments.c b/wiretap/network_instruments.c
index 41947c2b9b..5755e5a339 100644
--- a/wiretap/network_instruments.c
+++ b/wiretap/network_instruments.c
@@ -880,9 +880,16 @@ static gint wtap_to_observer_encap(int wtap_encap)
return OBSERVER_UNDEFINED;
}
+static const struct supported_block_type network_instruments_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info network_instruments_info = {
"Network Instruments Observer", "niobserver", "bfr", NULL,
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(network_instruments_blocks_supported),
network_instruments_dump_can_write_encap, network_instruments_dump_open, NULL
};
diff --git a/wiretap/netxray.c b/wiretap/netxray.c
index ff3b094379..488e83a89c 100644
--- a/wiretap/netxray.c
+++ b/wiretap/netxray.c
@@ -2095,27 +2095,55 @@ netxray_dump_finish_2_0(wtap_dumper *wdh, int *err, gchar **err_info _U_)
return TRUE;
}
+static const struct supported_block_type netxray_old_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info netxray_old_info = {
"Cinco Networks NetXRay 1.x", "netxray1", "cap", NULL,
- TRUE, FALSE, 0,
+ TRUE, BLOCKS_SUPPORTED(netxray_old_blocks_supported),
NULL, NULL, NULL
};
+static const struct supported_block_type netxray_1_0_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info netxray_1_0_info = {
"Cinco Networks NetXRay 2.0 or later", "netxray2", "cap", NULL,
- TRUE, FALSE, 0,
+ TRUE, BLOCKS_SUPPORTED(netxray_1_0_blocks_supported),
NULL, NULL, NULL
};
+static const struct supported_block_type netxray_1_1_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info netxray_1_1_info = {
"NetXray, Sniffer (Windows) 1.1", "ngwsniffer_1_1", "cap", NULL,
- TRUE, FALSE, 0,
+ TRUE, BLOCKS_SUPPORTED(netxray_1_1_blocks_supported),
netxray_dump_can_write_encap_1_1, netxray_dump_open_1_1, NULL
};
+static const struct supported_block_type netxray_2_00x_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info netxray_2_00x_info = {
"Sniffer (Windows) 2.00x", "ngwsniffer_2_0", "cap", "caz",
- TRUE, FALSE, 0,
+ TRUE, BLOCKS_SUPPORTED(netxray_2_00x_blocks_supported),
netxray_dump_can_write_encap_2_0, netxray_dump_open_2_0, NULL
};
diff --git a/wiretap/ngsniffer.c b/wiretap/ngsniffer.c
index ae1602089f..21fdeaa768 100644
--- a/wiretap/ngsniffer.c
+++ b/wiretap/ngsniffer.c
@@ -2842,15 +2842,29 @@ ng_file_seek_rand(wtap *wth, gint64 offset, int *err, gchar **err_info)
return TRUE;
}
+static const struct supported_block_type ngsniffer_uncompressed_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info ngsniffer_uncompressed_info = {
"Sniffer (DOS)", "ngsniffer", "cap", "enc;trc;fdc;syc",
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(ngsniffer_uncompressed_blocks_supported),
ngsniffer_dump_can_write_encap, ngsniffer_dump_open, NULL
};
+static const struct supported_block_type ngsniffer_compressed_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info ngsniffer_compressed_info = {
"Sniffer (DOS), compressed", "ngsniffer_comp", "cap", "enc;trc;fdc;syc",
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(ngsniffer_compressed_blocks_supported),
NULL, NULL, NULL
};
diff --git a/wiretap/packetlogger.c b/wiretap/packetlogger.c
index d9cad3d252..5330f0361c 100644
--- a/wiretap/packetlogger.c
+++ b/wiretap/packetlogger.c
@@ -377,9 +377,16 @@ packetlogger_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec, Buffer *buf,
return wtap_read_packet_bytes(fh, buf, rec->rec_header.packet_header.caplen, err, err_info);
}
+static const struct supported_block_type packetlogger_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info packetlogger_info = {
"macOS PacketLogger", "pklg", "pklg", NULL,
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(packetlogger_blocks_supported),
NULL, NULL, NULL
};
diff --git a/wiretap/pcapng.c b/wiretap/pcapng.c
index 0ff98643cb..f036c54f51 100644
--- a/wiretap/pcapng.c
+++ b/wiretap/pcapng.c
@@ -891,7 +891,7 @@ pcapng_read_if_descr_block(wtap *wth, FILE_T fh, pcapng_block_header_t *bh,
}
/* mandatory values */
- wblock->block = wtap_block_create(WTAP_BLOCK_IF_DESCRIPTION);
+ wblock->block = wtap_block_create(WTAP_BLOCK_IF_ID_AND_INFO);
if_descr_mand = (wtapng_if_descr_mandatory_t*)wtap_block_get_mandatory_data(wblock->block);
if (section_info->byte_swapped) {
link_type = GUINT16_SWAP_LE_BE(idb.linktype);
@@ -2712,7 +2712,7 @@ static void
pcapng_process_idb(wtap *wth, section_info_t *section_info,
wtapng_block_t *wblock)
{
- wtap_block_t int_data = wtap_block_create(WTAP_BLOCK_IF_DESCRIPTION);
+ wtap_block_t int_data = wtap_block_create(WTAP_BLOCK_IF_ID_AND_INFO);
interface_info_t iface_info;
wtapng_if_descr_mandatory_t *if_descr_mand = (wtapng_if_descr_mandatory_t*)wtap_block_get_mandatory_data(int_data),
*wblock_if_descr_mand = (wtapng_if_descr_mandatory_t*)wtap_block_get_mandatory_data(wblock->block);
@@ -4768,7 +4768,7 @@ static gboolean pcapng_add_idb(wtap_dumper *wdh, wtap_block_t idb,
/*
* Add a copy of this IDB to our array of IDBs.
*/
- idb_copy = wtap_block_create(WTAP_BLOCK_IF_DESCRIPTION);
+ idb_copy = wtap_block_create(WTAP_BLOCK_IF_ID_AND_INFO);
wtap_block_copy(idb_copy, idb);
g_array_append_val(wdh->interface_data, idb_copy);
diff --git a/wiretap/peekclassic.c b/wiretap/peekclassic.c
index c164264612..095d73f809 100644
--- a/wiretap/peekclassic.c
+++ b/wiretap/peekclassic.c
@@ -662,15 +662,29 @@ static gboolean peekclassic_read_packet_v56(wtap *wth, FILE_T fh,
return wtap_read_packet_bytes(fh, buf, sliceLength, err, err_info);
}
+static const struct supported_block_type peekclassic_v56_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info peekclassic_v56_info = {
"Savvius classic (V5 and V6)", "peekclassic56", "pkt", "tpc;apc;wpz",
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(peekclassic_v56_blocks_supported),
NULL, NULL, NULL
};
+static const struct supported_block_type peekclassic_v7_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info peekclassic_v7_info = {
"Savvius classic (V7)", "peekclassic7", "pkt", "tpc;apc;wpz",
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(peekclassic_v7_blocks_supported),
NULL, NULL, NULL
};
diff --git a/wiretap/peektagged.c b/wiretap/peektagged.c
index 99de82ddd0..267126454f 100644
--- a/wiretap/peektagged.c
+++ b/wiretap/peektagged.c
@@ -885,9 +885,16 @@ peektagged_seek_read(wtap *wth, gint64 seek_off,
return TRUE;
}
+static const struct supported_block_type peektagged_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info peektagged_info = {
"Savvius tagged", "peektagged", "pkt", "tpc;apc;wpz",
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(peektagged_blocks_supported),
NULL, NULL, NULL
};
diff --git a/wiretap/pppdump.c b/wiretap/pppdump.c
index aaf7f7e4be..b484df9c10 100644
--- a/wiretap/pppdump.c
+++ b/wiretap/pppdump.c
@@ -796,9 +796,16 @@ pppdump_close(wtap *wth)
}
}
+static const struct supported_block_type pppdump_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info pppdump_info = {
"pppd log (pppdump format)", "pppd", NULL, NULL,
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(pppdump_blocks_supported),
NULL, NULL, NULL
};
diff --git a/wiretap/radcom.c b/wiretap/radcom.c
index 8ad81e66e6..cecc45e6ac 100644
--- a/wiretap/radcom.c
+++ b/wiretap/radcom.c
@@ -372,9 +372,16 @@ radcom_read_rec(wtap *wth, FILE_T fh, wtap_rec *rec, Buffer *buf,
return TRUE;
}
+static const struct supported_block_type radcom_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info radcom_info = {
"RADCOM WAN/LAN analyzer", "radcom", NULL, NULL,
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(radcom_blocks_supported),
NULL, NULL, NULL
};
diff --git a/wiretap/rfc7468.c b/wiretap/rfc7468.c
index 5435587889..17fd35789b 100644
--- a/wiretap/rfc7468.c
+++ b/wiretap/rfc7468.c
@@ -99,10 +99,19 @@ wtap_open_return_val rfc7468_open(wtap *wth, int *err, gchar **err_info)
return WTAP_OPEN_MINE;
}
+static const struct supported_block_type rfc7468_blocks_supported[] = {
+ /*
+ * This is a file format that we dissect, so we provide only one
+ * "packet" with the file's contents, and don't support any
+ * options.
+ */
+ { WTAP_BLOCK_PACKET, ONE_BLOCK_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info rfc7468_info = {
- "RFC 7468 files", "rfc7468", NULL, NULL,
- FALSE, FALSE, 0,
- NULL, NULL, NULL
+ "RFC 7468 files", "rfc7468", NULL, NULL,
+ FALSE, BLOCKS_SUPPORTED(rfc7468_blocks_supported),
+ NULL, NULL, NULL
};
void register_rfc7468(void)
diff --git a/wiretap/ruby_marshal.c b/wiretap/ruby_marshal.c
index a57eb2b2d0..66042c97ea 100644
--- a/wiretap/ruby_marshal.c
+++ b/wiretap/ruby_marshal.c
@@ -84,9 +84,16 @@ wtap_open_return_val ruby_marshal_open(wtap *wth, int *err, gchar **err_info)
return WTAP_OPEN_MINE;
}
+static const struct supported_block_type ruby_marshal_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info ruby_marshal_info = {
"Ruby marshal files", "ruby_marshal", NULL, NULL,
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(ruby_marshal_blocks_supported),
NULL, NULL, NULL
};
diff --git a/wiretap/snoop.c b/wiretap/snoop.c
index 6fa7ac9cd7..30cf84648d 100644
--- a/wiretap/snoop.c
+++ b/wiretap/snoop.c
@@ -917,15 +917,29 @@ static gboolean snoop_dump(wtap_dumper *wdh,
return TRUE;
}
+static const struct supported_block_type snoop_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info snoop_info = {
"Sun snoop", "snoop", "snoop", "cap",
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(snoop_blocks_supported),
snoop_dump_can_write_encap, snoop_dump_open, NULL
};
+static const struct supported_block_type shomiti_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info shomiti_info = {
"Shomiti/Finisar Surveyor", "shomiti", "cap", NULL,
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(shomiti_blocks_supported),
NULL, NULL, NULL
};
diff --git a/wiretap/stanag4607.c b/wiretap/stanag4607.c
index f1662680ce..66a29efcf5 100644
--- a/wiretap/stanag4607.c
+++ b/wiretap/stanag4607.c
@@ -208,9 +208,16 @@ wtap_open_return_val stanag4607_open(wtap *wth, int *err, gchar **err_info)
return WTAP_OPEN_MINE;
}
+static const struct supported_block_type stanag4607_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info stanag4607_info = {
"STANAG 4607 Format", "stanag4607", NULL, NULL,
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(stanag4607_blocks_supported),
NULL, NULL, NULL
};
diff --git a/wiretap/systemd_journal.c b/wiretap/systemd_journal.c
index 621241e8f8..d829ab7105 100644
--- a/wiretap/systemd_journal.c
+++ b/wiretap/systemd_journal.c
@@ -236,9 +236,16 @@ systemd_journal_read_export_entry(FILE_T fh, wtap_rec *rec, Buffer *buf, int *er
return TRUE;
}
+static const struct supported_block_type systemd_journal_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info systemd_journal_info = {
"systemd journal export", "systemd_journal", NULL, NULL,
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(systemd_journal_blocks_supported),
NULL, NULL, NULL
};
diff --git a/wiretap/tnef.c b/wiretap/tnef.c
index 593fe09ced..f81b3ddac2 100644
--- a/wiretap/tnef.c
+++ b/wiretap/tnef.c
@@ -44,9 +44,18 @@ wtap_open_return_val tnef_open(wtap *wth, int *err, gchar **err_info)
return WTAP_OPEN_MINE;
}
+static const struct supported_block_type tnef_blocks_supported[] = {
+ /*
+ * This is a file format that we dissect, so we provide only one
+ * "packet" with the file's contents, and don't support any
+ * options.
+ */
+ { WTAP_BLOCK_PACKET, ONE_BLOCK_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info tnef_info = {
"Transport-Neutral Encapsulation Format", "tnef", NULL, NULL,
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(tnef_blocks_supported),
NULL, NULL, NULL
};
diff --git a/wiretap/toshiba.c b/wiretap/toshiba.c
index 844457286c..7781dadc6a 100644
--- a/wiretap/toshiba.c
+++ b/wiretap/toshiba.c
@@ -429,9 +429,16 @@ parse_single_hex_dump_line(char* rec, guint8 *buf, guint byte_offset) {
return TRUE;
}
+static const struct supported_block_type toshiba_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info toshiba_info = {
"Toshiba Compact ISDN Router snoop", "toshiba", "txt", NULL,
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(toshiba_blocks_supported),
NULL, NULL, NULL
};
diff --git a/wiretap/visual.c b/wiretap/visual.c
index 9dfaab7bed..ed9db91e77 100644
--- a/wiretap/visual.c
+++ b/wiretap/visual.c
@@ -861,9 +861,16 @@ static void visual_dump_free(wtap_dumper *wdh)
}
}
+static const struct supported_block_type visual_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info visual_info = {
"Visual Networks traffic capture", "visual", NULL, NULL,
- TRUE, FALSE, 0,
+ TRUE, BLOCKS_SUPPORTED(visual_blocks_supported),
visual_dump_can_write_encap, visual_dump_open, NULL
};
diff --git a/wiretap/vms.c b/wiretap/vms.c
index b1b157f539..5951520de9 100644
--- a/wiretap/vms.c
+++ b/wiretap/vms.c
@@ -528,9 +528,16 @@ parse_single_hex_dump_line(char* rec, guint8 *buf, long byte_offset,
return TRUE;
}
+static const struct supported_block_type vms_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info vms_info = {
"TCPIPtrace (VMS)", "tcpiptrace", "txt", NULL,
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(vms_blocks_supported),
NULL, NULL, NULL
};
diff --git a/wiretap/vwr.c b/wiretap/vwr.c
index 9744a8c5eb..953fac9a6a 100644
--- a/wiretap/vwr.c
+++ b/wiretap/vwr.c
@@ -3370,15 +3370,29 @@ vwr_process_rec_data(FILE_T fh, int rec_size,
return ret;
}
+static const struct supported_block_type vwr_80211_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info vwr_80211_info = {
"Ixia IxVeriWave .vwr Raw 802.11 Capture", "vwr80211", "vwr", NULL,
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(vwr_80211_blocks_supported),
NULL, NULL, NULL
};
+static const struct supported_block_type vwr_eth_blocks_supported[] = {
+ /*
+ * We support packet blocks, with no comments or other options.
+ */
+ { WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
+};
+
static const struct file_type_subtype_info vwr_eth_info = {
"Ixia IxVeriWave .vwr Raw Ethernet Capture", "vwreth", "vwr", NULL,
- FALSE, FALSE, 0,
+ FALSE, BLOCKS_SUPPORTED(vwr_eth_blocks_supported),
NULL, NULL, NULL
};
diff --git a/wiretap/wtap.c b/wiretap/wtap.c
index 26dab87158..ec7b0e34ef 100644
--- a/wiretap/wtap.c
+++ b/wiretap/wtap.c
@@ -215,7 +215,7 @@ wtap_add_generated_idb(wtap *wth)
g_assert(wth->file_tsprec != WTAP_TSPREC_UNKNOWN &&
wth->file_tsprec != WTAP_TSPREC_PER_PACKET);
- idb = wtap_block_create(WTAP_BLOCK_IF_DESCRIPTION);
+ idb = wtap_block_create(WTAP_BLOCK_IF_ID_AND_INFO);
if_descr_mand = (wtapng_if_descr_mandatory_t*)wtap_block_get_mandatory_data(idb);
if_descr_mand->wtap_encap = wth->file_encap;
diff --git a/wiretap/wtap.h b/wiretap/wtap.h
index 6d345d2cbc..b64607a3d0 100644
--- a/wiretap/wtap.h
+++ b/wiretap/wtap.h
@@ -309,9 +309,6 @@ extern "C" {
#define WTAP_FILE_TYPE_SUBTYPE_PCAP_NOKIA 6
#define WTAP_FILE_TYPE_SUBTYPE_PCAP_SS990417 7
#define WTAP_FILE_TYPE_SUBTYPE_PCAP_SS990915 8
-#define WTAP_FILE_TYPE_SUBTYPE_IPTRACE_1_0 9
-#define WTAP_FILE_TYPE_SUBTYPE_IPTRACE_2_0 10
-#define WTAP_FILE_TYPE_SUBTYPE_BER 11
/* timestamp precision (currently only these values are supported) */
#define WTAP_TSPREC_UNKNOWN -2
@@ -1584,6 +1581,54 @@ WS_DLL_PUBLIC struct open_info *open_routines;
#define WTAP_COMMENT_PER_INTERFACE 0x00000002 /* per-interface */
#define WTAP_COMMENT_PER_PACKET 0x00000004 /* per-packet */
+/*
+ * For a given option type in a certain block type, does a file format
+ * not support it, support only one such option, or support multiple
+ * such options?
+ */
+typedef enum {
+ OPTION_NOT_SUPPORTED,
+ ONE_OPTION_SUPPORTED,
+ MULTIPLE_OPTIONS_SUPPORTED
+} option_support_t;
+
+/*
+ * Entry in a table of supported option types.
+ */
+struct supported_option_type {
+ guint opt;
+ option_support_t support; /* OPTION_NOT_SUPPORTED allowed, equivalent to absence */
+};
+
+#define OPTION_TYPES_SUPPORTED(option_type_array) \
+ sizeof option_type_array / sizeof option_type_array[0], option_type_array
+
+#define NO_OPTIONS_SUPPORTED \
+ 0, NULL
+
+/*
+ * For a given block type, does a file format not support it, support
+ * only one such block, or support multiple such blocks?
+ */
+typedef enum {
+ BLOCK_NOT_SUPPORTED,
+ ONE_BLOCK_SUPPORTED,
+ MULTIPLE_BLOCKS_SUPPORTED
+} block_support_t;
+
+/*
+ * Entry in a table of supported block types.
+ */
+struct supported_block_type {
+ wtap_block_type_t type;
+ block_support_t support; /* BLOCK_NOT_SUPPORTED allowed, equivalent to absence */
+ size_t num_supported_options;
+ const struct supported_option_type *supported_options;
+};
+
+#define BLOCKS_SUPPORTED(block_type_array) \
+ sizeof block_type_array / sizeof block_type_array[0], block_type_array
+
struct file_type_subtype_info {
/*
* The file type description.
@@ -1615,12 +1660,11 @@ struct file_type_subtype_info {
/* when writing this file format, is seeking required? */
gboolean writing_must_seek;
- /* does this type support name resolution records? */
- /* should be FALSE is this file type doesn't support name resolution records */
- gboolean has_name_resolution;
+ /* Number of block types supported. */
+ size_t num_supported_blocks;
- /* what types of comment does this file support? */
- guint32 supported_comment_types;
+ /* Table of block types supported. */
+ const struct supported_block_type *supported_blocks;
/* can this type write this encapsulation format? */
/* should be NULL is this file type doesn't have write support */
@@ -1957,20 +2001,6 @@ WS_DLL_PUBLIC
gboolean wtap_dump_can_compress(int filetype);
/**
- * Return TRUE if this capture file format supports storing name
- * resolution information in it, FALSE if not.
- */
-WS_DLL_PUBLIC
-gboolean wtap_dump_has_name_resolution(int filetype);
-
-/**
- * Return TRUE if this capture file format supports all the comment
- * types specified, FALSE if not.
- */
-WS_DLL_PUBLIC
-gboolean wtap_dump_supports_comment_types(int filetype, guint32 comment_types);
-
-/**
* Initialize the per-file information based on an existing file. Its
* contents must be freed according to the requirements of wtap_dump_params.
* If wth does not remain valid for the duration of the session, dsbs_growing
@@ -2160,13 +2190,6 @@ GArray *wtap_get_savable_file_types_subtypes_for_file(int file_type,
WS_DLL_PUBLIC
GArray *wtap_get_writable_file_types_subtypes(ft_sort_order sort_order);
-/**
- * Return TRUE if files of this file type/subtype use interface IDs
- * to associate records with an interface.
- */
-WS_DLL_PUBLIC
-gboolean wtap_uses_interface_ids(int file_type);
-
/*** various file type/subtype functions ***/
WS_DLL_PUBLIC
const char *wtap_file_type_subtype_description(int file_type_subtype);
@@ -2175,6 +2198,22 @@ const char *wtap_file_type_subtype_name(int file_type_subtype);
WS_DLL_PUBLIC
int wtap_name_to_file_type_subtype(const char *name);
+/**
+ * Return an indication of whether this capture file format supports
+ * the block in question.
+ */
+WS_DLL_PUBLIC
+block_support_t wtap_file_type_subtype_supports_block(int filetype,
+ wtap_block_type_t type);
+
+/**
+ * Return an indication of whether this capture file format supports
+ * the option in queston for the block in question.
+ */
+WS_DLL_PUBLIC
+option_support_t wtap_file_type_subtype_supports_option(int filetype,
+ wtap_block_type_t type, guint opttype);
+
/*** various file extension functions ***/
WS_DLL_PUBLIC
GSList *wtap_get_all_capture_file_extensions_list(void);
diff --git a/wiretap/wtap_opttypes.c b/wiretap/wtap_opttypes.c
index 981533578c..e6d250e1f1 100644
--- a/wiretap/wtap_opttypes.c
+++ b/wiretap/wtap_opttypes.c
@@ -1052,7 +1052,7 @@ void wtap_opttypes_initialize(void)
};
static wtap_blocktype_t idb_block = {
- WTAP_BLOCK_IF_DESCRIPTION, /* block_type */
+ WTAP_BLOCK_IF_ID_AND_INFO, /* block_type */
"IDB", /* name */
"Interface Description Block", /* description */
idb_create, /* create */
diff --git a/wiretap/wtap_opttypes.h b/wiretap/wtap_opttypes.h
index ff428109e7..9ad9314efb 100644
--- a/wiretap/wtap_opttypes.h
+++ b/wiretap/wtap_opttypes.h
@@ -129,13 +129,37 @@ typedef struct wtap_block *wtap_block_t;
* for them, they're identifiers used internally, and more than one
* pcapng block type may use a given block type.
*
+ * Note that, in a given file format, this information won't necessarily
+ * appear in the form of blocks in the file, even though they're presented
+ * to the caller of libwiretap as blocks when reading and and are presented
+ * by the caller of libwiretap as blocks when writing. See, for example,
+ * the iptrace file format, in which the interface name is given as part
+ * of the packet record header; we synthesize those blocks when reading
+ * (we don't currently support writing that format, but if we did, we'd
+ * get the interface name from the block and put it in the packet record
+ * header).
+ *
+ * WTAP_BLOCK_IF_ID_AND_INFO is a block that not only gives
+ * descriptive information about an interface but *also* assigns an
+ * ID to the interface, so that every packet has either an explicit
+ * or implicit interface ID indicating on which the packet arrived.
+ *
+ * It does *not* refer to information about interfaces that does not
+ * allow identification of the interface on which a packet arrives
+ * (I'm looking at *you*, Microsoft Network Monitor...). Do *not*
+ * indicate support for that block if your capture format merely
+ * gives a list of interface information without having every packet
+ * explicitly or implicitly (as in, for example, the pcapng Simple
+ * Packet Block) indicate on which of those interfaces the packet
+ * arrived.
+ *
* WTAP_BLOCK_PACKET (which corresponds to the Enhanced Packet Block,
* the Simple Packet Block, and the deprecated Packet Block) is not
* currently used; it's reserved for future use.
*/
typedef enum {
WTAP_BLOCK_SECTION = 0,
- WTAP_BLOCK_IF_DESCRIPTION,
+ WTAP_BLOCK_IF_ID_AND_INFO,
WTAP_BLOCK_NAME_RESOLUTION,
WTAP_BLOCK_IF_STATISTICS,
WTAP_BLOCK_DECRYPTION_SECRETS,
@@ -159,7 +183,7 @@ typedef struct wtapng_section_mandatory_s {
*/
} wtapng_mandatory_section_t;
-/** struct holding the information to build an WTAP_BLOCK_IF_DESCRIPTION.
+/** struct holding the information to build an WTAP_BLOCK_IF_ID_AND_INFO.
* the interface_data array holds an array of wtap_block_t
* representing interfacs, one per interface.
*/
@@ -168,7 +192,7 @@ typedef struct wtapng_iface_descriptions_s {
} wtapng_iface_descriptions_t;
/**
- * Holds the required data from a WTAP_BLOCK_IF_DESCRIPTION.
+ * Holds the required data from a WTAP_BLOCK_IF_ID_AND_INFO.
*/
typedef struct wtapng_if_descr_mandatory_s {
int wtap_encap; /**< link_type translated to wtap_encap */
diff --git a/ws_diag_control.h b/ws_diag_control.h
index 6f6aebad61..d168e8c7ee 100644
--- a/ws_diag_control.h
+++ b/ws_diag_control.h
@@ -187,6 +187,27 @@ extern "C" {
#endif
/*
+ * Suppress warnings about casting away constness.
+ * Do this only if you know that the pointer is to something that can
+ * be written and, in this context, should be writable.
+ */
+#if defined(__GNUC__) || defined(__clang__)
+ /*
+ * GCC or a compiler that claims to be GCC-compatible.
+ * We throw in Clang just in case clang-cl doesn't define
+ * __GNUC__; if it does, __GNUC__ should suffice.
+ */
+ #define DIAG_OFF_CAST_AWAY_CONST DIAG_OFF(cast-qual)
+ #define DIAG_ON_CAST_AWAY_CONST DIAG_OFF(cast-qual)
+#elif defined(_MSC_VER)
+ #define DIAG_OFF_CAST_AWAY_CONST
+ #define DIAG_ON_CAST_AWAY_CONST
+#else
+ #define DIAG_OFF_CAST_AWAY_CONST
+ #define DIAG_ON_CAST_AWAY_CONST
+#endif
+
+/*
* For dealing with APIs which are only deprecated in macOS (like the
* OpenSSL and MIT/Heimdal Kerberos APIs).
*