Add an API to determine whether a file type uses interface IDs.

Currently, the only file types that use them are pcapng and IBM's
iptrace; we don't support writing the latter, so this is mainly of
interest for pcapng.

This makes it a bit more obvious what some "is this pcapng?" tests are
really trying to determine, and allows them to automatically support any
new file types that use them.

(With regard to interface descriptions, tere are three types of file:

1) files that contain no interface information;

2) files that contain "just FYI" interface information but that don't
tie packets or other records to particular interfaces;

3) files that contain interface information and tie all packets (and
possibly other records) to an interface.

This tests for files of type 3.)
This commit is contained in:
Guy Harris 2020-10-19 23:25:11 -07:00
parent 89e96c1e77
commit a11b9fb7a0
4 changed files with 27 additions and 1 deletions

View File

@ -144,5 +144,6 @@ 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

View File

@ -1996,6 +1996,24 @@ wtap_get_savable_file_types_subtypes(int file_type_subtype,
return savable_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;
}
/* Name that should be somewhat descriptive. */
const char *
wtap_file_type_subtype_string(int file_type_subtype)

View File

@ -908,7 +908,7 @@ merge_process_packets(wtap_dumper *pdh, const int file_type,
break;
}
if (file_type == WTAP_FILE_TYPE_SUBTYPE_PCAPNG) {
if (wtap_uses_interface_ids(file_type)) {
/*
* XXX - We should do this only for record types
* that pertain to a particular interface; for

View File

@ -2220,6 +2220,13 @@ WS_DLL_PUBLIC
GArray *wtap_get_savable_file_types_subtypes(int file_type,
const GArray *file_encaps, guint32 required_comment_types);
/**
* 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 string converter functions ***/
WS_DLL_PUBLIC
const char *wtap_file_type_subtype_string(int file_type_subtype);