forked from osmocom/wireshark
Making wiretap option blocks more generic.
This was inspired by https://code.wireshark.org/review/9729/, but takes it in a different direction where all options are put into an array, regardless of whether they are "standard" or "custom". It should be easier to add "custom" options in this design. Some, but not all blocks have been converted. Descriptions of some of the block options have been moved from wtap.h to pcapng.h as it seems to be the one that implements the description of the blocks. Also what could be added/refactored is registering block behavior. Change-Id: I3dffa38f0bb088f98749a4f97a3b7655baa4aa6a Reviewed-on: https://code.wireshark.org/review/13667 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>daniel/osmux
parent
37acf433db
commit
08d49ff2e0
19
capinfos.c
19
capinfos.c
|
@ -80,6 +80,8 @@
|
|||
#include <wsutil/privileges.h>
|
||||
#include <wsutil/ws_diag_control.h>
|
||||
#include <wsutil/ws_version_info.h>
|
||||
#include <wiretap/wtap_opttypes.h>
|
||||
#include <wiretap/pcapng.h>
|
||||
|
||||
#ifdef HAVE_PLUGINS
|
||||
#include <wsutil/plugins.h>
|
||||
|
@ -1039,9 +1041,10 @@ process_cap_file(wtap *wth, const char *filename)
|
|||
nstime_t prev_time;
|
||||
gboolean know_order = FALSE;
|
||||
order_t order = IN_ORDER;
|
||||
const wtapng_section_t *shb_inf;
|
||||
wtap_optionblock_t shb_inf;
|
||||
guint i;
|
||||
wtapng_iface_descriptions_t *idb_info;
|
||||
char *shb_str;
|
||||
|
||||
g_assert(wth != NULL);
|
||||
g_assert(filename != NULL);
|
||||
|
@ -1072,7 +1075,7 @@ process_cap_file(wtap *wth, const char *filename)
|
|||
|
||||
/* get IDB info strings */
|
||||
for (i = 0; i < cf_info.num_interfaces; i++) {
|
||||
const wtapng_if_descr_t *if_descr = &g_array_index(idb_info->interface_data, wtapng_if_descr_t, i);
|
||||
const wtap_optionblock_t if_descr = g_array_index(idb_info->interface_data, wtap_optionblock_t, i);
|
||||
gchar *s = wtap_get_debug_if_descr(if_descr, 21, "\n");
|
||||
g_array_append_val(cf_info.idb_info_strings, s);
|
||||
}
|
||||
|
@ -1246,10 +1249,14 @@ process_cap_file(wtap *wth, const char *filename)
|
|||
shb_inf = wtap_file_get_shb(wth);
|
||||
if (shb_inf) {
|
||||
/* opt_comment is always 0-terminated by pcapng_read_section_header_block */
|
||||
cf_info.comment = g_strdup(shb_inf->opt_comment);
|
||||
cf_info.hardware = g_strdup(shb_inf->shb_hardware);
|
||||
cf_info.os = g_strdup(shb_inf->shb_os);
|
||||
cf_info.usr_appl = g_strdup(shb_inf->shb_user_appl);
|
||||
wtap_optionblock_get_option_string(shb_inf, OPT_COMMENT, &shb_str);
|
||||
cf_info.comment = g_strdup(shb_str);
|
||||
wtap_optionblock_get_option_string(shb_inf, OPT_SHB_HARDWARE, &shb_str);
|
||||
cf_info.hardware = g_strdup(shb_str);
|
||||
wtap_optionblock_get_option_string(shb_inf, OPT_SHB_OS, &shb_str);
|
||||
cf_info.os = g_strdup(shb_str);
|
||||
wtap_optionblock_get_option_string(shb_inf, OPT_SHB_USERAPPL, &shb_str);
|
||||
cf_info.usr_appl = g_strdup(shb_str);
|
||||
}
|
||||
|
||||
string_replace_newlines(cf_info.comment);
|
||||
|
|
16
cfile.c
16
cfile.c
|
@ -26,6 +26,7 @@
|
|||
#include <glib.h>
|
||||
|
||||
#include <epan/packet.h>
|
||||
#include <wiretap/pcapng.h>
|
||||
|
||||
#include "cfile.h"
|
||||
|
||||
|
@ -34,20 +35,23 @@ cap_file_get_interface_name(void *data, guint32 interface_id)
|
|||
{
|
||||
capture_file *cf = (capture_file *) data;
|
||||
wtapng_iface_descriptions_t *idb_info;
|
||||
const wtapng_if_descr_t *wtapng_if_descr = NULL;
|
||||
wtap_optionblock_t wtapng_if_descr = NULL;
|
||||
char* interface_name;
|
||||
|
||||
idb_info = wtap_file_get_idb_info(cf->wth);
|
||||
|
||||
if (interface_id < idb_info->interface_data->len)
|
||||
wtapng_if_descr = &g_array_index(idb_info->interface_data, wtapng_if_descr_t, interface_id);
|
||||
wtapng_if_descr = g_array_index(idb_info->interface_data, wtap_optionblock_t, interface_id);
|
||||
|
||||
g_free(idb_info);
|
||||
|
||||
if (wtapng_if_descr) {
|
||||
if (wtapng_if_descr->if_name)
|
||||
return wtapng_if_descr->if_name;
|
||||
else if (wtapng_if_descr->if_description)
|
||||
return wtapng_if_descr->if_description;
|
||||
wtap_optionblock_get_option_string(wtapng_if_descr, OPT_IDB_NAME, &interface_name);
|
||||
if (interface_name)
|
||||
return interface_name;
|
||||
wtap_optionblock_get_option_string(wtapng_if_descr, OPT_IDB_DESCR, &interface_name);
|
||||
if (interface_name)
|
||||
return interface_name;
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
|
|
@ -62,8 +62,6 @@ libwiretap.so.0 libwiretap0 #MINVER#
|
|||
wtap_file_type_subtype_string@Base 1.12.0~rc1
|
||||
wtap_free_extensions_list@Base 1.9.1
|
||||
wtap_free_idb_info@Base 1.99.9
|
||||
wtap_free_nrb@Base 1.99.9
|
||||
wtap_free_shb@Base 1.99.9
|
||||
wtap_fstat@Base 1.9.1
|
||||
wtap_get_all_file_extensions_list@Base 1.12.0~rc1
|
||||
wtap_get_bytes_dumped@Base 1.9.1
|
||||
|
@ -79,6 +77,17 @@ libwiretap.so.0 libwiretap0 #MINVER#
|
|||
wtap_has_open_info@Base 1.12.0~rc1
|
||||
wtap_iscompressed@Base 1.9.1
|
||||
wtap_open_offline@Base 1.9.1
|
||||
wtap_optionblock_create@Base 2.1.0
|
||||
wtap_optionblock_free@Base 2.1.0
|
||||
wtap_optionblock_get_mandatory_data@Base 2.1.0
|
||||
wtap_optionblock_get_option_custom@Base 2.1.0
|
||||
wtap_optionblock_get_option_string@Base 2.1.0
|
||||
wtap_optionblock_get_option_uint8@Base 2.1.0
|
||||
wtap_optionblock_get_option_uint64@Base 2.1.0
|
||||
wtap_optionblock_set_option_custom@Base 2.1.0
|
||||
wtap_optionblock_set_option_string@Base 2.1.0
|
||||
wtap_optionblock_set_option_uint8@Base 2.1.0
|
||||
wtap_optionblock_set_option_uint64@Base 2.1.0
|
||||
wtap_pcap_encap_to_wtap_encap@Base 1.9.1
|
||||
wtap_phdr@Base 1.9.1
|
||||
wtap_phdr_cleanup@Base 1.99.2
|
||||
|
|
26
editcap.c
26
editcap.c
|
@ -89,6 +89,8 @@
|
|||
#include <wsutil/str_util.h>
|
||||
#include <wsutil/ws_diag_control.h>
|
||||
#include <wsutil/ws_version_info.h>
|
||||
#include <wiretap/wtap_opttypes.h>
|
||||
#include <wiretap/pcapng.h>
|
||||
|
||||
#include "ringbuffer.h" /* For RINGBUFFER_MAX_NUM_FILES */
|
||||
|
||||
|
@ -936,9 +938,9 @@ get_editcap_runtime_info(GString *str)
|
|||
|
||||
static wtap_dumper *
|
||||
editcap_dump_open(const char *filename, guint32 snaplen,
|
||||
wtapng_section_t *shb_hdr,
|
||||
wtap_optionblock_t shb_hdr,
|
||||
wtapng_iface_descriptions_t *idb_inf,
|
||||
wtapng_name_res_t *nrb_hdr, int *write_err)
|
||||
wtap_optionblock_t nrb_hdr, int *write_err)
|
||||
{
|
||||
wtap_dumper *pdh;
|
||||
|
||||
|
@ -998,8 +1000,9 @@ main(int argc, char *argv[])
|
|||
const struct wtap_pkthdr *phdr;
|
||||
struct wtap_pkthdr temp_phdr;
|
||||
wtapng_iface_descriptions_t *idb_inf = NULL;
|
||||
wtapng_section_t *shb_hdr = NULL;
|
||||
wtapng_name_res_t *nrb_hdr = NULL;
|
||||
wtap_optionblock_t shb_hdr = NULL;
|
||||
wtap_optionblock_t nrb_hdr = NULL;
|
||||
char *shb_user_appl;
|
||||
|
||||
#ifdef HAVE_PLUGINS
|
||||
char* init_progfile_dir_error;
|
||||
|
@ -1410,8 +1413,11 @@ main(int argc, char *argv[])
|
|||
g_assert(filename);
|
||||
|
||||
/* If we don't have an application name add Editcap */
|
||||
if (shb_hdr->shb_user_appl == NULL) {
|
||||
shb_hdr->shb_user_appl = g_strdup("Editcap " VERSION);
|
||||
wtap_optionblock_get_option_string(shb_hdr, OPT_SHB_USERAPPL, &shb_user_appl);
|
||||
if (shb_user_appl == NULL) {
|
||||
shb_user_appl = g_strdup("Editcap " VERSION);
|
||||
wtap_optionblock_set_option_string(shb_hdr, OPT_SHB_USERAPPL, shb_user_appl);
|
||||
g_free(shb_user_appl);
|
||||
}
|
||||
|
||||
pdh = editcap_dump_open(filename,
|
||||
|
@ -1873,9 +1879,9 @@ main(int argc, char *argv[])
|
|||
wtap_strerror(write_err));
|
||||
goto error_on_exit;
|
||||
}
|
||||
wtap_free_shb(shb_hdr);
|
||||
wtap_optionblock_free(shb_hdr);
|
||||
shb_hdr = NULL;
|
||||
wtap_free_nrb(nrb_hdr);
|
||||
wtap_optionblock_free(nrb_hdr);
|
||||
nrb_hdr = NULL;
|
||||
g_free(filename);
|
||||
|
||||
|
@ -1899,8 +1905,8 @@ main(int argc, char *argv[])
|
|||
return 0;
|
||||
|
||||
error_on_exit:
|
||||
wtap_free_shb(shb_hdr);
|
||||
wtap_free_nrb(nrb_hdr);
|
||||
wtap_optionblock_free(shb_hdr);
|
||||
wtap_optionblock_free(nrb_hdr);
|
||||
g_free(idb_inf);
|
||||
exit(2);
|
||||
}
|
||||
|
|
|
@ -554,6 +554,12 @@ extern int wslua_set__index(lua_State *L);
|
|||
#define WSLUA_ATTRIBUTE_STRING_GETTER(C,member) \
|
||||
WSLUA_ATTRIBUTE_NAMED_STRING_GETTER(C,member,member)
|
||||
|
||||
#define WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_STRING_GETTER(C,name,member,option) \
|
||||
WSLUA_ATTRIBUTE_GET(C,name, { \
|
||||
char* str; \
|
||||
wtap_optionblock_get_option_string(obj->member, option, &str); \
|
||||
lua_pushstring(L,str); /* this pushes nil if obj->member is null */ \
|
||||
})
|
||||
|
||||
#define WSLUA_ATTRIBUTE_SET(C,name,block) \
|
||||
static int C##_set_##name (lua_State* L) { \
|
||||
|
@ -603,6 +609,21 @@ extern int wslua_set__index(lua_State *L);
|
|||
#define WSLUA_ATTRIBUTE_STRING_SETTER(C,field,need_free) \
|
||||
WSLUA_ATTRIBUTE_NAMED_STRING_SETTER(C,field,field,need_free)
|
||||
|
||||
#define WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_STRING_SETTER(C,field,member,option) \
|
||||
static int C##_set_##field (lua_State* L) { \
|
||||
C obj = check##C (L,1); \
|
||||
gchar* s = NULL; \
|
||||
if (lua_isstring(L,-1) || lua_isnil(L,-1)) { \
|
||||
s = g_strdup(lua_tostring(L,-1)); \
|
||||
} else { \
|
||||
return luaL_error(L, "%s's attribute `%s' must be a string or nil", #C , #field ); \
|
||||
} \
|
||||
wtap_optionblock_set_option_string(obj->member, option, s); \
|
||||
return 0; \
|
||||
} \
|
||||
/* silly little trick so we can add a semicolon after this macro */ \
|
||||
typedef void __dummy##C##_set_##field
|
||||
|
||||
#define WSLUA_ERROR(name,error) { luaL_error(L, "%s%s", #name ": " ,error); }
|
||||
#define WSLUA_ARG_ERROR(name,attr,error) { luaL_argerror(L,WSLUA_ARG_ ## name ## _ ## attr, #name ": " error); }
|
||||
#define WSLUA_OPTARG_ERROR(name,attr,error) { luaL_argerror(L,WSLUA_OPTARG_##name##_ ##attr, #name ": " error); }
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "wslua_file_common.h"
|
||||
|
||||
#include <epan/addr_resolv.h>
|
||||
#include <wiretap/pcapng.h>
|
||||
|
||||
|
||||
/* WSLUA_CONTINUE_MODULE File */
|
||||
|
@ -111,23 +112,23 @@ WSLUA_ATTRIBUTE_NAMED_NUMBER_SETTER(CaptureInfo,snapshot_length,wth->snapshot_le
|
|||
|
||||
/* WSLUA_ATTRIBUTE CaptureInfo_comment RW A string comment for the whole capture file,
|
||||
or nil if there is no `comment`. */
|
||||
WSLUA_ATTRIBUTE_NAMED_STRING_GETTER(CaptureInfo,comment,wth->shb_hdr.opt_comment);
|
||||
WSLUA_ATTRIBUTE_NAMED_STRING_SETTER(CaptureInfo,comment,wth->shb_hdr.opt_comment,TRUE);
|
||||
WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_STRING_GETTER(CaptureInfo,comment,wth->shb_hdr,OPT_COMMENT);
|
||||
WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_STRING_SETTER(CaptureInfo,comment,wth->shb_hdr,OPT_COMMENT);
|
||||
|
||||
/* WSLUA_ATTRIBUTE CaptureInfo_hardware RW A string containing the description of
|
||||
the hardware used to create the capture, or nil if there is no `hardware` string. */
|
||||
WSLUA_ATTRIBUTE_NAMED_STRING_GETTER(CaptureInfo,hardware,wth->shb_hdr.shb_hardware);
|
||||
WSLUA_ATTRIBUTE_NAMED_STRING_SETTER(CaptureInfo,hardware,wth->shb_hdr.shb_hardware,TRUE);
|
||||
WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_STRING_GETTER(CaptureInfo,hardware,wth->shb_hdr,OPT_SHB_HARDWARE);
|
||||
WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_STRING_SETTER(CaptureInfo,hardware,wth->shb_hdr,OPT_SHB_HARDWARE);
|
||||
|
||||
/* WSLUA_ATTRIBUTE CaptureInfo_os RW A string containing the name of
|
||||
the operating system used to create the capture, or nil if there is no `os` string. */
|
||||
WSLUA_ATTRIBUTE_NAMED_STRING_GETTER(CaptureInfo,os,wth->shb_hdr.shb_os);
|
||||
WSLUA_ATTRIBUTE_NAMED_STRING_SETTER(CaptureInfo,os,wth->shb_hdr.shb_os,TRUE);
|
||||
WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_STRING_GETTER(CaptureInfo,os,wth->shb_hdr,OPT_SHB_OS);
|
||||
WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_STRING_SETTER(CaptureInfo,os,wth->shb_hdr,OPT_SHB_OS);
|
||||
|
||||
/* WSLUA_ATTRIBUTE CaptureInfo_user_app RW A string containing the name of
|
||||
the application used to create the capture, or nil if there is no `user_app` string. */
|
||||
WSLUA_ATTRIBUTE_NAMED_STRING_GETTER(CaptureInfo,user_app,wth->shb_hdr.shb_user_appl);
|
||||
WSLUA_ATTRIBUTE_NAMED_STRING_SETTER(CaptureInfo,user_app,wth->shb_hdr.shb_user_appl,TRUE);
|
||||
WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_STRING_GETTER(CaptureInfo,user_app,wth->shb_hdr,OPT_SHB_USERAPPL);
|
||||
WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_STRING_SETTER(CaptureInfo,user_app,wth->shb_hdr,OPT_SHB_USERAPPL);
|
||||
|
||||
/* WSLUA_ATTRIBUTE CaptureInfo_hosts WO Sets resolved ip-to-hostname information.
|
||||
|
||||
|
@ -354,19 +355,19 @@ WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(CaptureInfoConst,encap,wdh->encap);
|
|||
|
||||
/* WSLUA_ATTRIBUTE CaptureInfoConst_comment RW A comment for the whole capture file, if the
|
||||
`wtap_presence_flags.COMMENTS` was set in the presence flags; nil if there is no comment. */
|
||||
WSLUA_ATTRIBUTE_NAMED_STRING_GETTER(CaptureInfoConst,comment,wth->shb_hdr.opt_comment);
|
||||
WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_STRING_GETTER(CaptureInfoConst,comment,wth->shb_hdr,OPT_COMMENT);
|
||||
|
||||
/* WSLUA_ATTRIBUTE CaptureInfoConst_hardware RO A string containing the description of
|
||||
the hardware used to create the capture, or nil if there is no hardware string. */
|
||||
WSLUA_ATTRIBUTE_NAMED_STRING_GETTER(CaptureInfoConst,hardware,wth->shb_hdr.shb_hardware);
|
||||
WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_STRING_GETTER(CaptureInfoConst,hardware,wth->shb_hdr,OPT_SHB_HARDWARE);
|
||||
|
||||
/* WSLUA_ATTRIBUTE CaptureInfoConst_os RO A string containing the name of
|
||||
the operating system used to create the capture, or nil if there is no os string. */
|
||||
WSLUA_ATTRIBUTE_NAMED_STRING_GETTER(CaptureInfoConst,os,wth->shb_hdr.shb_os);
|
||||
WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_STRING_GETTER(CaptureInfoConst,os,wth->shb_hdr,OPT_SHB_OS);
|
||||
|
||||
/* WSLUA_ATTRIBUTE CaptureInfoConst_user_app RO A string containing the name of
|
||||
the application used to create the capture, or nil if there is no user_app string. */
|
||||
WSLUA_ATTRIBUTE_NAMED_STRING_GETTER(CaptureInfoConst,user_app,wth->shb_hdr.shb_user_appl);
|
||||
WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_STRING_GETTER(CaptureInfoConst,user_app,wth->shb_hdr,OPT_SHB_USERAPPL);
|
||||
|
||||
/* WSLUA_ATTRIBUTE CaptureInfoConst_hosts RO A ip-to-hostname Lua table of two key-ed names: `ipv4_addresses` and `ipv6_addresses`.
|
||||
The value of each of these names are themselves array tables, of key-ed tables, such that the inner table has a key
|
||||
|
|
8
file.c
8
file.c
|
@ -4475,9 +4475,9 @@ cf_save_records(capture_file *cf, const char *fname, guint save_format,
|
|||
or moving the capture file, we have to do it by writing the packets
|
||||
out in Wiretap. */
|
||||
|
||||
wtapng_section_t *shb_hdr = NULL;
|
||||
wtap_optionblock_t shb_hdr = NULL;
|
||||
wtapng_iface_descriptions_t *idb_inf = NULL;
|
||||
wtapng_name_res_t *nrb_hdr = NULL;
|
||||
wtap_optionblock_t nrb_hdr = NULL;
|
||||
int encap;
|
||||
|
||||
/* XXX: what free's this shb_hdr? */
|
||||
|
@ -4698,9 +4698,9 @@ cf_export_specified_packets(capture_file *cf, const char *fname,
|
|||
int err;
|
||||
wtap_dumper *pdh;
|
||||
save_callback_args_t callback_args;
|
||||
wtapng_section_t *shb_hdr = NULL;
|
||||
wtap_optionblock_t shb_hdr = NULL;
|
||||
wtapng_iface_descriptions_t *idb_inf = NULL;
|
||||
wtapng_name_res_t *nrb_hdr = NULL;
|
||||
wtap_optionblock_t nrb_hdr = NULL;
|
||||
int encap;
|
||||
|
||||
cf_callback_invoke(cf_cb_file_export_specified_packets_started, (gpointer)fname);
|
||||
|
|
17
reordercap.c
17
reordercap.c
|
@ -46,6 +46,7 @@
|
|||
#include <wsutil/file_util.h>
|
||||
#include <wsutil/ws_diag_control.h>
|
||||
#include <wsutil/ws_version_info.h>
|
||||
#include <wiretap/wtap_opttypes.h>
|
||||
|
||||
/* Show command-line usage */
|
||||
static void
|
||||
|
@ -187,9 +188,9 @@ main(int argc, char *argv[])
|
|||
guint wrong_order_count = 0;
|
||||
gboolean write_output_regardless = TRUE;
|
||||
guint i;
|
||||
wtapng_section_t *shb_hdr = NULL;
|
||||
wtap_optionblock_t shb_hdr = NULL;
|
||||
wtapng_iface_descriptions_t *idb_inf = NULL;
|
||||
wtapng_name_res_t *nrb_hdr = NULL;
|
||||
wtap_optionblock_t nrb_hdr = NULL;
|
||||
|
||||
GPtrArray *frames;
|
||||
FrameRecord_t *prevFrame = NULL;
|
||||
|
@ -287,8 +288,8 @@ main(int argc, char *argv[])
|
|||
if (pdh == NULL) {
|
||||
fprintf(stderr, "reordercap: Failed to open output file: (%s) - error %s\n",
|
||||
outfile, wtap_strerror(err));
|
||||
wtap_free_shb(shb_hdr);
|
||||
wtap_free_nrb(nrb_hdr);
|
||||
wtap_optionblock_free(shb_hdr);
|
||||
wtap_optionblock_free(nrb_hdr);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -361,12 +362,12 @@ main(int argc, char *argv[])
|
|||
if (!wtap_dump_close(pdh, &err)) {
|
||||
fprintf(stderr, "reordercap: Error closing %s: %s\n", outfile,
|
||||
wtap_strerror(err));
|
||||
wtap_free_shb(shb_hdr);
|
||||
wtap_free_nrb(nrb_hdr);
|
||||
wtap_optionblock_free(shb_hdr);
|
||||
wtap_optionblock_free(nrb_hdr);
|
||||
exit(1);
|
||||
}
|
||||
wtap_free_shb(shb_hdr);
|
||||
wtap_free_nrb(nrb_hdr);
|
||||
wtap_optionblock_free(shb_hdr);
|
||||
wtap_optionblock_free(nrb_hdr);
|
||||
|
||||
/* Finally, close infile */
|
||||
wtap_fdclose(wth);
|
||||
|
|
47
summary.c
47
summary.c
|
@ -23,6 +23,8 @@
|
|||
#include <config.h>
|
||||
|
||||
#include <wiretap/pcap-encap.h>
|
||||
#include <wiretap/wtap_opttypes.h>
|
||||
#include <wiretap/pcapng.h>
|
||||
|
||||
#include <epan/packet.h>
|
||||
#include "cfile.h"
|
||||
|
@ -105,12 +107,16 @@ summary_fill_in(capture_file *cf, summary_tally *st)
|
|||
{
|
||||
frame_data *first_frame, *cur_frame;
|
||||
guint32 framenum;
|
||||
const wtapng_section_t* shb_inf;
|
||||
wtap_optionblock_t shb_inf;
|
||||
iface_options iface;
|
||||
guint i;
|
||||
wtapng_iface_descriptions_t* idb_info;
|
||||
wtapng_if_descr_t wtapng_if_descr;
|
||||
wtapng_if_stats_t *if_stats;
|
||||
wtap_optionblock_t wtapng_if_descr;
|
||||
wtapng_if_descr_mandatory_t *wtapng_if_descr_mand;
|
||||
wtap_optionblock_t if_stats;
|
||||
guint64 isb_ifdrop;
|
||||
char* if_string;
|
||||
wtapng_if_descr_filter_t* if_filter;
|
||||
|
||||
st->packet_count_ts = 0;
|
||||
st->start_time = 0;
|
||||
|
@ -163,34 +169,39 @@ summary_fill_in(capture_file *cf, summary_tally *st)
|
|||
st->shb_os = NULL;
|
||||
st->shb_user_appl = NULL;
|
||||
}else{
|
||||
st->opt_comment = shb_inf->opt_comment;
|
||||
st->shb_hardware = shb_inf->shb_hardware;
|
||||
st->shb_os = shb_inf->shb_os;
|
||||
st->shb_user_appl = shb_inf->shb_user_appl;
|
||||
wtap_optionblock_get_option_string(shb_inf, OPT_COMMENT, &st->opt_comment);
|
||||
wtap_optionblock_get_option_string(shb_inf, OPT_SHB_HARDWARE, &st->shb_hardware);
|
||||
wtap_optionblock_get_option_string(shb_inf, OPT_SHB_OS, &st->shb_os);
|
||||
wtap_optionblock_get_option_string(shb_inf, OPT_SHB_USERAPPL, (char**)&st->shb_user_appl);
|
||||
}
|
||||
|
||||
st->ifaces = g_array_new(FALSE, FALSE, sizeof(iface_options));
|
||||
idb_info = wtap_file_get_idb_info(cf->wth);
|
||||
for (i = 0; i < idb_info->interface_data->len; i++) {
|
||||
wtapng_if_descr = g_array_index(idb_info->interface_data, wtapng_if_descr_t, i);
|
||||
iface.cfilter = g_strdup(wtapng_if_descr.if_filter_str);
|
||||
iface.name = g_strdup(wtapng_if_descr.if_name);
|
||||
iface.descr = g_strdup(wtapng_if_descr.if_description);
|
||||
wtapng_if_descr = g_array_index(idb_info->interface_data, wtap_optionblock_t, i);
|
||||
wtapng_if_descr_mand = (wtapng_if_descr_mandatory_t*)wtap_optionblock_get_mandatory_data(wtapng_if_descr);
|
||||
wtap_optionblock_get_option_custom(wtapng_if_descr, OPT_IDB_FILTER, (void**)&if_filter);
|
||||
iface.cfilter = g_strdup(if_filter->if_filter_str);
|
||||
wtap_optionblock_get_option_string(wtapng_if_descr, OPT_IDB_NAME, &if_string);
|
||||
iface.name = g_strdup(if_string);
|
||||
wtap_optionblock_get_option_string(wtapng_if_descr, OPT_IDB_DESCR, &if_string);
|
||||
iface.descr = g_strdup(if_string);
|
||||
iface.drops_known = FALSE;
|
||||
iface.drops = 0;
|
||||
iface.snap = wtapng_if_descr.snap_len;
|
||||
iface.snap = wtapng_if_descr_mand->snap_len;
|
||||
iface.has_snap = (iface.snap != 65535);
|
||||
iface.encap_type = wtapng_if_descr.wtap_encap;
|
||||
iface.encap_type = wtapng_if_descr_mand->wtap_encap;
|
||||
iface.isb_comment = NULL;
|
||||
if(wtapng_if_descr.num_stat_entries == 1){
|
||||
if(wtapng_if_descr_mand->num_stat_entries == 1){
|
||||
/* dumpcap only writes one ISB, only handle that for now */
|
||||
if_stats = &g_array_index(wtapng_if_descr.interface_statistics, wtapng_if_stats_t, 0);
|
||||
if (if_stats->isb_ifdrop != G_GUINT64_CONSTANT(0xFFFFFFFFFFFFFFFF)) {
|
||||
if_stats = g_array_index(wtapng_if_descr_mand->interface_statistics, wtap_optionblock_t, 0);
|
||||
wtap_optionblock_get_option_uint64(if_stats, OPT_ISB_IFDROP, &isb_ifdrop);
|
||||
if (isb_ifdrop != G_GUINT64_CONSTANT(0xFFFFFFFFFFFFFFFF)) {
|
||||
iface.drops_known = TRUE;
|
||||
iface.drops = if_stats->isb_ifdrop;
|
||||
iface.drops = isb_ifdrop;
|
||||
}
|
||||
/* XXX: this doesn't get used, and might need to be g_strdup'ed when it does */
|
||||
iface.isb_comment = if_stats->opt_comment;
|
||||
wtap_optionblock_get_option_string(if_stats, OPT_COMMENT, &iface.isb_comment);
|
||||
}
|
||||
g_array_append_val(st->ifaces, iface);
|
||||
}
|
||||
|
|
28
tshark.c
28
tshark.c
|
@ -67,6 +67,8 @@
|
|||
#include <wsutil/report_err.h>
|
||||
#include <wsutil/ws_diag_control.h>
|
||||
#include <wsutil/ws_version_info.h>
|
||||
#include <wiretap/wtap_opttypes.h>
|
||||
#include <wiretap/pcapng.h>
|
||||
|
||||
#include "globals.h"
|
||||
#include <epan/timestamp.h>
|
||||
|
@ -3170,12 +3172,13 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
|
|||
char *save_file_string = NULL;
|
||||
gboolean filtering_tap_listeners;
|
||||
guint tap_flags;
|
||||
wtapng_section_t *shb_hdr = NULL;
|
||||
wtap_optionblock_t shb_hdr = NULL;
|
||||
wtapng_iface_descriptions_t *idb_inf = NULL;
|
||||
wtapng_name_res_t *nrb_hdr = NULL;
|
||||
wtap_optionblock_t nrb_hdr = NULL;
|
||||
struct wtap_pkthdr phdr;
|
||||
Buffer buf;
|
||||
epan_dissect_t *edt = NULL;
|
||||
char *shb_user_appl;
|
||||
|
||||
wtap_phdr_init(&phdr);
|
||||
|
||||
|
@ -3205,9 +3208,12 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
|
|||
nrb_hdr = wtap_file_get_nrb_for_new_file(cf->wth);
|
||||
|
||||
/* If we don't have an application name add Tshark */
|
||||
if (shb_hdr->shb_user_appl == NULL) {
|
||||
/* this is free'd by wtap_free_shb() later */
|
||||
shb_hdr->shb_user_appl = g_strdup_printf("TShark (Wireshark) %s", get_ws_vcs_version_info());
|
||||
wtap_optionblock_get_option_string(shb_hdr, OPT_SHB_USERAPPL, &shb_user_appl);
|
||||
if (shb_user_appl == NULL) {
|
||||
/* this is free'd by wtap_optionblock_free() later */
|
||||
shb_user_appl = g_strdup_printf("TShark (Wireshark) %s", get_ws_vcs_version_info());
|
||||
wtap_optionblock_set_option_string(shb_hdr, OPT_SHB_USERAPPL, shb_user_appl);
|
||||
g_free(shb_user_appl);
|
||||
}
|
||||
|
||||
if (linktype != WTAP_ENCAP_PER_PACKET &&
|
||||
|
@ -3448,8 +3454,8 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
|
|||
break;
|
||||
}
|
||||
wtap_dump_close(pdh, &err);
|
||||
wtap_free_shb(shb_hdr);
|
||||
wtap_free_nrb(nrb_hdr);
|
||||
wtap_optionblock_free(shb_hdr);
|
||||
wtap_optionblock_free(nrb_hdr);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
|
@ -3563,8 +3569,8 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
|
|||
break;
|
||||
}
|
||||
wtap_dump_close(pdh, &err);
|
||||
wtap_free_shb(shb_hdr);
|
||||
wtap_free_nrb(nrb_hdr);
|
||||
wtap_optionblock_free(shb_hdr);
|
||||
wtap_optionblock_free(nrb_hdr);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
|
@ -3680,8 +3686,8 @@ out:
|
|||
cf->wth = NULL;
|
||||
|
||||
g_free(save_file_string);
|
||||
wtap_free_shb(shb_hdr);
|
||||
wtap_free_nrb(nrb_hdr);
|
||||
wtap_optionblock_free(shb_hdr);
|
||||
wtap_optionblock_free(nrb_hdr);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
|
|
@ -48,6 +48,8 @@
|
|||
#include "wsutil/tempfile.h"
|
||||
#include "wsutil/os_version_info.h"
|
||||
#include "wsutil/ws_version_info.h"
|
||||
#include "wiretap/wtap_opttypes.h"
|
||||
#include "wiretap/pcapng.h"
|
||||
|
||||
#define INPUT_FRM_KEY "input_frame"
|
||||
|
||||
|
@ -456,57 +458,49 @@ file_import_open(text_import_info_t *info)
|
|||
int err;
|
||||
|
||||
/* pcapng defs */
|
||||
wtapng_section_t *shb_hdr;
|
||||
wtap_optionblock_t shb_hdr;
|
||||
wtapng_iface_descriptions_t *idb_inf;
|
||||
wtapng_if_descr_t int_data;
|
||||
wtap_optionblock_t int_data;
|
||||
wtapng_if_descr_mandatory_t *int_data_mand;
|
||||
GString *os_info_str;
|
||||
gchar *opt_comment, *wireshark_ver;
|
||||
|
||||
/* Create data for SHB */
|
||||
os_info_str = g_string_new("");
|
||||
get_os_version_info(os_info_str);
|
||||
|
||||
shb_hdr = g_new(wtapng_section_t,1);
|
||||
shb_hdr->section_length = -1;
|
||||
shb_hdr = wtap_optionblock_create(WTAP_OPTION_BLOCK_NG_SECTION);
|
||||
|
||||
/* options */
|
||||
shb_hdr->opt_comment = g_strdup_printf("File created by File->Import of file %s", info->import_text_filename);
|
||||
/*
|
||||
* UTF-8 string containing the description of the hardware used to create
|
||||
* this section.
|
||||
*/
|
||||
shb_hdr->shb_hardware = NULL;
|
||||
opt_comment = g_strdup_printf("File created by File->Import of file %s", info->import_text_filename);
|
||||
wtap_optionblock_set_option_string(shb_hdr, OPT_COMMENT, opt_comment);
|
||||
g_free(opt_comment);
|
||||
|
||||
/*
|
||||
* UTF-8 string containing the name of the operating system used to create
|
||||
* this section.
|
||||
*/
|
||||
shb_hdr->shb_os = g_string_free(os_info_str, FALSE);
|
||||
wtap_optionblock_set_option_string(shb_hdr, OPT_SHB_OS, g_string_free(os_info_str, TRUE));
|
||||
/*
|
||||
* UTF-8 string containing the name of the application used to create
|
||||
* this section.
|
||||
*/
|
||||
shb_hdr->shb_user_appl = g_strdup_printf("Wireshark %s", get_ws_vcs_version_info());
|
||||
|
||||
wireshark_ver = g_strdup_printf("Wireshark %s", get_ws_vcs_version_info());
|
||||
wtap_optionblock_set_option_string(shb_hdr, OPT_SHB_USERAPPL, wireshark_ver);
|
||||
g_free(wireshark_ver);
|
||||
|
||||
/* Create fake IDB info */
|
||||
idb_inf = g_new(wtapng_iface_descriptions_t,1);
|
||||
idb_inf->interface_data = g_array_new(FALSE, FALSE, sizeof(wtapng_if_descr_t));
|
||||
idb_inf->interface_data = g_array_new(FALSE, FALSE, sizeof(wtap_optionblock_t));
|
||||
|
||||
/* create the fake interface data */
|
||||
int_data.wtap_encap = info->encapsulation;
|
||||
int_data.time_units_per_second = 1000000; /* default microsecond resolution */
|
||||
int_data.link_type = wtap_wtap_encap_to_pcap_encap(info->encapsulation);
|
||||
int_data.snap_len = WTAP_MAX_PACKET_SIZE;
|
||||
int_data.if_name = g_strdup("Fake IF File->Import");
|
||||
int_data.opt_comment = NULL;
|
||||
int_data.if_description = NULL;
|
||||
int_data.if_speed = 0;
|
||||
int_data.if_tsresol = 6;
|
||||
int_data.if_filter_str = NULL;
|
||||
int_data.bpf_filter_len = 0;
|
||||
int_data.if_filter_bpf_bytes = NULL;
|
||||
int_data.if_os = NULL;
|
||||
int_data.if_fcslen = -1;
|
||||
int_data.num_stat_entries = 0; /* Number of ISB:s */
|
||||
int_data.interface_statistics = NULL;
|
||||
int_data = wtap_optionblock_create(WTAP_OPTION_BLOCK_IF_DESCR);
|
||||
int_data_mand = (wtapng_if_descr_mandatory_t*)wtap_optionblock_get_mandatory_data(int_data);
|
||||
int_data_mand->wtap_encap = info->encapsulation;
|
||||
int_data_mand->time_units_per_second = 1000000; /* default microsecond resolution */
|
||||
int_data_mand->link_type = wtap_wtap_encap_to_pcap_encap(info->encapsulation);
|
||||
int_data_mand->snap_len = WTAP_MAX_PACKET_SIZE;
|
||||
wtap_optionblock_set_option_string(int_data, OPT_IDB_NAME, "Fake IF File->Import");
|
||||
|
||||
g_array_append_val(idb_inf->interface_data, int_data);
|
||||
|
||||
|
@ -565,7 +559,7 @@ end:
|
|||
g_free(info->date_timestamp_format);
|
||||
g_free(info);
|
||||
g_free(capfile_name);
|
||||
wtap_free_shb(shb_hdr);
|
||||
wtap_optionblock_free(shb_hdr);
|
||||
wtap_free_idb_info(idb_inf);
|
||||
window_destroy(file_import_dlg_w);
|
||||
}
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
#include <epan/tap.h>
|
||||
#include <epan/exported_pdu.h>
|
||||
#include <epan/epan_dissect.h>
|
||||
#include <wiretap/wtap_opttypes.h>
|
||||
#include <wiretap/pcapng.h>
|
||||
|
||||
#include "ui/alert_box.h"
|
||||
#include "ui/simple_dialog.h"
|
||||
|
@ -102,56 +104,51 @@ exp_pdu_file_open(exp_pdu_t *exp_pdu_tap_data)
|
|||
int err;
|
||||
|
||||
/* pcapng defs */
|
||||
wtapng_section_t *shb_hdr;
|
||||
wtap_optionblock_t shb_hdr;
|
||||
wtapng_iface_descriptions_t *idb_inf;
|
||||
wtapng_if_descr_t int_data;
|
||||
wtap_optionblock_t int_data;
|
||||
wtapng_if_descr_mandatory_t *int_data_mand;
|
||||
GString *os_info_str;
|
||||
gchar *opt_comment, *wireshark_ver;
|
||||
|
||||
/* Create data for SHB */
|
||||
os_info_str = g_string_new("");
|
||||
get_os_version_info(os_info_str);
|
||||
|
||||
shb_hdr = g_new0(wtapng_section_t,1);
|
||||
shb_hdr->section_length = -1;
|
||||
shb_hdr = wtap_optionblock_create(WTAP_OPTION_BLOCK_NG_SECTION);
|
||||
|
||||
/* options */
|
||||
shb_hdr->opt_comment = g_strdup_printf("Dump of PDUs from %s", cfile.filename);
|
||||
/*
|
||||
* UTF-8 string containing the description of the hardware used to create
|
||||
* this section.
|
||||
*/
|
||||
shb_hdr->shb_hardware = NULL;
|
||||
opt_comment = g_strdup_printf("Dump of PDUs from %s", cfile.filename);
|
||||
wtap_optionblock_set_option_string(shb_hdr, OPT_COMMENT, opt_comment);
|
||||
g_free(opt_comment);
|
||||
|
||||
/*
|
||||
* UTF-8 string containing the name of the operating system used to create
|
||||
* this section.
|
||||
*/
|
||||
shb_hdr->shb_os = g_string_free(os_info_str, FALSE);
|
||||
wtap_optionblock_set_option_string(shb_hdr, OPT_SHB_OS, g_string_free(os_info_str, TRUE));
|
||||
/*
|
||||
* UTF-8 string containing the name of the application used to create
|
||||
* this section.
|
||||
*/
|
||||
shb_hdr->shb_user_appl = g_strdup_printf("Wireshark %s", get_ws_vcs_version_info());
|
||||
wireshark_ver = g_strdup_printf("Wireshark %s", get_ws_vcs_version_info());
|
||||
wtap_optionblock_set_option_string(shb_hdr, OPT_SHB_USERAPPL, wireshark_ver);
|
||||
g_free(wireshark_ver);
|
||||
|
||||
/* Create fake IDB info */
|
||||
idb_inf = g_new(wtapng_iface_descriptions_t,1);
|
||||
idb_inf->interface_data = g_array_new(FALSE, FALSE, sizeof(wtapng_if_descr_t));
|
||||
idb_inf->interface_data = g_array_new(FALSE, FALSE, sizeof(wtap_optionblock_t));
|
||||
|
||||
/* create the fake interface data */
|
||||
int_data.wtap_encap = WTAP_ENCAP_WIRESHARK_UPPER_PDU;
|
||||
int_data.time_units_per_second = 1000000000; /* default nanosecond resolution */
|
||||
int_data.link_type = wtap_wtap_encap_to_pcap_encap(WTAP_ENCAP_WIRESHARK_UPPER_PDU);
|
||||
int_data.snap_len = WTAP_MAX_PACKET_SIZE;
|
||||
int_data.if_name = g_strdup("Fake IF, PDU->Export");
|
||||
int_data.opt_comment = NULL;
|
||||
int_data.if_description = NULL;
|
||||
int_data.if_speed = 0;
|
||||
int_data.if_tsresol = 9;
|
||||
int_data.if_filter_str = NULL;
|
||||
int_data.bpf_filter_len = 0;
|
||||
int_data.if_filter_bpf_bytes = NULL;
|
||||
int_data.if_os = NULL;
|
||||
int_data.if_fcslen = -1;
|
||||
int_data.num_stat_entries = 0; /* Number of ISB:s */
|
||||
int_data.interface_statistics = NULL;
|
||||
int_data = wtap_optionblock_create(WTAP_OPTION_BLOCK_IF_DESCR);
|
||||
int_data_mand = (wtapng_if_descr_mandatory_t*)wtap_optionblock_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 */
|
||||
int_data_mand->link_type = wtap_wtap_encap_to_pcap_encap(WTAP_ENCAP_WIRESHARK_UPPER_PDU);
|
||||
int_data_mand->snap_len = WTAP_MAX_PACKET_SIZE;
|
||||
|
||||
wtap_optionblock_set_option_string(int_data, OPT_IDB_NAME, "Fake IF, PDU->Export");
|
||||
wtap_optionblock_set_option_uint8(int_data, OPT_IDB_TSRESOL, 9);
|
||||
|
||||
g_array_append_val(idb_inf->interface_data, int_data);
|
||||
|
||||
|
@ -200,7 +197,7 @@ exp_pdu_file_open(exp_pdu_t *exp_pdu_tap_data)
|
|||
|
||||
end:
|
||||
g_free(capfile_name);
|
||||
wtap_free_shb(shb_hdr);
|
||||
wtap_optionblock_free(shb_hdr);
|
||||
wtap_free_idb_info(idb_inf);
|
||||
}
|
||||
|
||||
|
|
|
@ -79,6 +79,7 @@ set(WIRETAP_FILES
|
|||
vms.c
|
||||
vwr.c
|
||||
wtap.c
|
||||
wtap_opttypes.c
|
||||
)
|
||||
|
||||
if (WERROR_COMMON_FLAGS)
|
||||
|
|
|
@ -83,7 +83,8 @@ NONGENERATED_C_FILES = \
|
|||
visual.c \
|
||||
vms.c \
|
||||
vwr.c \
|
||||
wtap.c
|
||||
wtap.c \
|
||||
wtap_opttypes.c
|
||||
|
||||
# Header files that are not generated from other files
|
||||
NONGENERATED_HEADER_FILES = \
|
||||
|
@ -147,6 +148,7 @@ NONGENERATED_HEADER_FILES = \
|
|||
vms.h \
|
||||
vwr.h \
|
||||
wtap.h \
|
||||
wtap_opttypes.h \
|
||||
wtap-int.h
|
||||
|
||||
# Files that generate compileable files
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
#include "wtap-int.h"
|
||||
#include "file_wrappers.h"
|
||||
#include "pcap-encap.h"
|
||||
#include "pcapng.h"
|
||||
#include "erf.h"
|
||||
|
||||
static gboolean erf_read_header(FILE_T fh,
|
||||
|
@ -751,42 +752,47 @@ int erf_dump_open(wtap_dumper *wdh, int *err)
|
|||
|
||||
int erf_populate_interfaces(wtap *wth)
|
||||
{
|
||||
wtapng_if_descr_t int_data;
|
||||
wtap_optionblock_t int_data;
|
||||
wtapng_if_descr_mandatory_t* int_data_mand;
|
||||
int i;
|
||||
char* tmp;
|
||||
|
||||
if (!wth)
|
||||
return -1;
|
||||
|
||||
memset(&int_data, 0, sizeof(int_data)); /* Zero all fields */
|
||||
|
||||
int_data.wtap_encap = WTAP_ENCAP_ERF;
|
||||
/* int_data.time_units_per_second = (1LL<<32); ERF format resolution is 2^-32, capture resolution is unknown */
|
||||
int_data.time_units_per_second = 1000000000; /* XXX Since Wireshark only supports down to nanosecond resolution we have to dilute to this */
|
||||
int_data.link_type = wtap_wtap_encap_to_pcap_encap(WTAP_ENCAP_ERF);
|
||||
int_data.snap_len = 65535; /* ERF max length */
|
||||
int_data.opt_comment = NULL;
|
||||
/* XXX: if_IPv4addr opt 4 Interface network address and netmask.*/
|
||||
/* XXX: if_IPv6addr opt 5 Interface network address and prefix length (stored in the last byte).*/
|
||||
/* XXX: if_MACaddr opt 6 Interface Hardware MAC address (48 bits).*/
|
||||
/* XXX: if_EUIaddr opt 7 Interface Hardware EUI address (64 bits)*/
|
||||
int_data.if_speed = 0; /* Unknown */
|
||||
/* int_data.if_tsresol = 0xa0; ERF format resolution is 2^-32 = 0xa0, capture resolution is unknown */
|
||||
int_data.if_tsresol = 0x09; /* XXX Since Wireshark only supports down to nanosecond resolution we have to dilute to this */
|
||||
/* XXX: if_tzone 10 Time zone for GMT support (TODO: specify better). */
|
||||
int_data.if_filter_str = NULL;
|
||||
int_data.bpf_filter_len = 0;
|
||||
int_data.if_filter_bpf_bytes = NULL;
|
||||
int_data.if_os = NULL;
|
||||
int_data.if_fcslen = 0; /* unknown! */
|
||||
/* XXX if_tsoffset; opt 14 A 64 bits integer value that specifies an offset (in seconds)...*/
|
||||
/* Interface statistics */
|
||||
int_data.num_stat_entries = 0;
|
||||
int_data.interface_statistics = NULL;
|
||||
|
||||
/* Preemptively create interface entries for 4 interfaces, since this is the max number in ERF */
|
||||
for (i=0; i<4; i++) {
|
||||
int_data.if_name = g_strdup_printf("Port %c", 'A'+i);
|
||||
int_data.if_description = g_strdup_printf("ERF Interface Id %d (Port %c)", i, 'A'+i);
|
||||
|
||||
int_data = wtap_optionblock_create(WTAP_OPTION_BLOCK_IF_DESCR);
|
||||
int_data_mand = (wtapng_if_descr_mandatory_t*)wtap_optionblock_get_mandatory_data(int_data);
|
||||
|
||||
int_data_mand->wtap_encap = WTAP_ENCAP_ERF;
|
||||
/* int_data.time_units_per_second = (1LL<<32); ERF format resolution is 2^-32, capture resolution is unknown */
|
||||
int_data_mand->time_units_per_second = 1000000000; /* XXX Since Wireshark only supports down to nanosecond resolution we have to dilute to this */
|
||||
int_data_mand->link_type = wtap_wtap_encap_to_pcap_encap(WTAP_ENCAP_ERF);
|
||||
int_data_mand->snap_len = 65535; /* ERF max length */
|
||||
|
||||
/* XXX: if_IPv4addr opt 4 Interface network address and netmask.*/
|
||||
/* XXX: if_IPv6addr opt 5 Interface network address and prefix length (stored in the last byte).*/
|
||||
/* XXX: if_MACaddr opt 6 Interface Hardware MAC address (48 bits).*/
|
||||
/* XXX: if_EUIaddr opt 7 Interface Hardware EUI address (64 bits)*/
|
||||
wtap_optionblock_set_option_uint64(int_data, OPT_IDB_SPEED, 0); /* Unknown - XXX should be left at default? */
|
||||
/* int_data.if_tsresol = 0xa0; ERF format resolution is 2^-32 = 0xa0, capture resolution is unknown */
|
||||
wtap_optionblock_set_option_uint8(int_data, OPT_IDB_TSRESOL, 0x09); /* XXX Since Wireshark only supports down to nanosecond resolution we have to dilute to this */
|
||||
|
||||
/* XXX: if_tzone 10 Time zone for GMT support (TODO: specify better). */
|
||||
|
||||
/* XXX if_tsoffset; opt 14 A 64 bits integer value that specifies an offset (in seconds)...*/
|
||||
/* Interface statistics */
|
||||
int_data_mand->num_stat_entries = 0;
|
||||
int_data_mand->interface_statistics = NULL;
|
||||
|
||||
tmp = g_strdup_printf("Port %c", 'A'+i);
|
||||
wtap_optionblock_set_option_string(int_data, OPT_IDB_NAME, tmp);
|
||||
g_free(tmp);
|
||||
tmp = g_strdup_printf("ERF Interface Id %d (Port %c)", i, 'A'+i);
|
||||
wtap_optionblock_set_option_string(int_data, OPT_IDB_DESCR, tmp);
|
||||
g_free(tmp);
|
||||
|
||||
g_array_append_val(wth->interface_data, int_data);
|
||||
}
|
||||
|
|
|
@ -818,11 +818,12 @@ wtap_open_offline(const char *filename, unsigned int type, int *err, char **err_
|
|||
wth->file_tsprec = WTAP_TSPREC_USEC;
|
||||
wth->priv = NULL;
|
||||
wth->wslua_data = NULL;
|
||||
wth->shb_hdr = wtap_optionblock_create(WTAP_OPTION_BLOCK_NG_SECTION);
|
||||
|
||||
/* Initialize the array containing a list of interfaces. pcapng_open and
|
||||
* erf_open needs this (and libpcap_open for ERF encapsulation types).
|
||||
* Always initing it here saves checking for a NULL ptr later. */
|
||||
wth->interface_data = g_array_new(FALSE, FALSE, sizeof(wtapng_if_descr_t));
|
||||
wth->interface_data = g_array_new(FALSE, FALSE, sizeof(wtap_optionblock_t));
|
||||
|
||||
if (wth->random_fh) {
|
||||
wth->fast_seek = g_ptr_array_new();
|
||||
|
@ -1083,31 +1084,24 @@ success:
|
|||
if ((wth->file_type_subtype == WTAP_FILE_TYPE_SUBTYPE_PCAP) ||
|
||||
(wth->file_type_subtype == WTAP_FILE_TYPE_SUBTYPE_PCAP_NSEC)) {
|
||||
|
||||
wtapng_if_descr_t descr;
|
||||
wtap_optionblock_t descr = wtap_optionblock_create(WTAP_OPTION_BLOCK_IF_DESCR);
|
||||
wtapng_if_descr_mandatory_t* descr_mand = (wtapng_if_descr_mandatory_t*)wtap_optionblock_get_mandatory_data(descr);
|
||||
|
||||
descr.wtap_encap = wth->file_encap;
|
||||
descr_mand->wtap_encap = wth->file_encap;
|
||||
if (wth->file_type_subtype == WTAP_FILE_TYPE_SUBTYPE_PCAP_NSEC) {
|
||||
descr.time_units_per_second = 1000000000; /* nanosecond resolution */
|
||||
descr.if_tsresol = 9;
|
||||
descr.tsprecision = WTAP_TSPREC_NSEC;
|
||||
descr_mand->time_units_per_second = 1000000000; /* nanosecond resolution */
|
||||
wtap_optionblock_set_option_uint8(descr, OPT_IDB_TSRESOL, 9);
|
||||
descr_mand->tsprecision = WTAP_TSPREC_NSEC;
|
||||
} else {
|
||||
descr.time_units_per_second = 1000000; /* default microsecond resolution */
|
||||
descr.if_tsresol = 6;
|
||||
descr.tsprecision = WTAP_TSPREC_USEC;
|
||||
descr_mand->time_units_per_second = 1000000; /* default microsecond resolution */
|
||||
wtap_optionblock_set_option_uint8(descr, OPT_IDB_TSRESOL, 6);
|
||||
descr_mand->tsprecision = WTAP_TSPREC_USEC;
|
||||
}
|
||||
descr.link_type = wtap_wtap_encap_to_pcap_encap(wth->file_encap);
|
||||
descr.snap_len = wth->snapshot_length;
|
||||
descr.opt_comment = NULL;
|
||||
descr.if_name = NULL;
|
||||
descr.if_description = NULL;
|
||||
descr.if_speed = 0;
|
||||
descr.if_filter_str= NULL;
|
||||
descr.bpf_filter_len= 0;
|
||||
descr.if_filter_bpf_bytes= NULL;
|
||||
descr.if_os = NULL;
|
||||
descr.if_fcslen = -1;
|
||||
descr.num_stat_entries = 0; /* Number of ISB:s */
|
||||
descr.interface_statistics = NULL;
|
||||
descr_mand->link_type = wtap_wtap_encap_to_pcap_encap(wth->file_encap);
|
||||
descr_mand->snap_len = wth->snapshot_length;
|
||||
|
||||
descr_mand->num_stat_entries = 0; /* Number of ISB:s */
|
||||
descr_mand->interface_statistics = NULL;
|
||||
g_array_append_val(wth->interface_data, descr);
|
||||
|
||||
}
|
||||
|
@ -2144,11 +2138,12 @@ static int wtap_dump_file_close(wtap_dumper *wdh);
|
|||
|
||||
static wtap_dumper *
|
||||
wtap_dump_init_dumper(int file_type_subtype, int encap, int snaplen, gboolean compressed,
|
||||
wtapng_section_t *shb_hdr, wtapng_iface_descriptions_t *idb_inf,
|
||||
wtapng_name_res_t *nrb_hdr, int *err)
|
||||
wtap_optionblock_t shb_hdr, wtapng_iface_descriptions_t *idb_inf,
|
||||
wtap_optionblock_t nrb_hdr, int *err)
|
||||
{
|
||||
wtap_dumper *wdh;
|
||||
wtapng_if_descr_t descr, *file_int_data;
|
||||
wtap_optionblock_t descr, file_int_data;
|
||||
wtapng_if_descr_mandatory_t *descr_mand, *file_int_data_mand;
|
||||
|
||||
/* Check whether we can open a capture file with that file type
|
||||
and that encapsulation. */
|
||||
|
@ -2169,37 +2164,31 @@ wtap_dump_init_dumper(int file_type_subtype, int encap, int snaplen, gboolean co
|
|||
guint itf_count;
|
||||
|
||||
/* XXX: what free's this stuff? */
|
||||
wdh->interface_data = g_array_new(FALSE, FALSE, sizeof(wtapng_if_descr_t));
|
||||
wdh->interface_data = g_array_new(FALSE, FALSE, sizeof(wtap_optionblock_t));
|
||||
for (itf_count = 0; itf_count < idb_inf->interface_data->len; itf_count++) {
|
||||
file_int_data = &g_array_index(idb_inf->interface_data, wtapng_if_descr_t, itf_count);
|
||||
if ((encap != WTAP_ENCAP_PER_PACKET) && (encap != file_int_data->wtap_encap)) {
|
||||
/* XXX: this does a shallow copy, not a true clone; e.g., comments are not duped */
|
||||
memcpy(&descr, file_int_data, sizeof(wtapng_if_descr_t));
|
||||
descr.wtap_encap = encap;
|
||||
descr.link_type = wtap_wtap_encap_to_pcap_encap(encap);
|
||||
g_array_append_val(wdh->interface_data, descr);
|
||||
} else {
|
||||
g_array_append_val(wdh->interface_data, *file_int_data);
|
||||
file_int_data = g_array_index(idb_inf->interface_data, wtap_optionblock_t, itf_count);
|
||||
file_int_data_mand = (wtapng_if_descr_mandatory_t*)wtap_optionblock_get_mandatory_data(file_int_data);
|
||||
descr = wtap_optionblock_create(WTAP_OPTION_BLOCK_IF_DESCR);
|
||||
wtap_optionblock_copy_options(descr, file_int_data);
|
||||
if ((encap != WTAP_ENCAP_PER_PACKET) && (encap != file_int_data_mand->wtap_encap)) {
|
||||
descr_mand = (wtapng_if_descr_mandatory_t*)wtap_optionblock_get_mandatory_data(descr);
|
||||
descr_mand->wtap_encap = encap;
|
||||
descr_mand->link_type = wtap_wtap_encap_to_pcap_encap(encap);
|
||||
}
|
||||
g_array_append_val(wdh->interface_data, descr);
|
||||
}
|
||||
} else {
|
||||
descr.wtap_encap = encap;
|
||||
descr.time_units_per_second = 1000000; /* default microsecond resolution */
|
||||
descr.link_type = wtap_wtap_encap_to_pcap_encap(encap);
|
||||
descr.snap_len = snaplen;
|
||||
descr.opt_comment = NULL;
|
||||
descr.if_name = g_strdup("Unknown/not available in original file format(libpcap)");
|
||||
descr.if_description = NULL;
|
||||
descr.if_speed = 0;
|
||||
descr.if_tsresol = 6;
|
||||
descr.if_filter_str= NULL;
|
||||
descr.bpf_filter_len= 0;
|
||||
descr.if_filter_bpf_bytes= NULL;
|
||||
descr.if_os = NULL;
|
||||
descr.if_fcslen = -1;
|
||||
descr.num_stat_entries = 0; /* Number of ISB:s */
|
||||
descr.interface_statistics = NULL;
|
||||
wdh->interface_data = g_array_new(FALSE, FALSE, sizeof(wtapng_if_descr_t));
|
||||
descr = wtap_optionblock_create(WTAP_OPTION_BLOCK_IF_DESCR);
|
||||
descr_mand = (wtapng_if_descr_mandatory_t*)wtap_optionblock_get_mandatory_data(descr);
|
||||
descr_mand->wtap_encap = encap;
|
||||
descr_mand->time_units_per_second = 1000000; /* default microsecond resolution */
|
||||
descr_mand->link_type = wtap_wtap_encap_to_pcap_encap(encap);
|
||||
descr_mand->snap_len = snaplen;
|
||||
wtap_optionblock_set_option_string(descr, OPT_IDB_NAME, "Unknown/not available in original file format(libpcap)");
|
||||
|
||||
descr_mand->num_stat_entries = 0; /* Number of ISB:s */
|
||||
descr_mand->interface_statistics = NULL;
|
||||
wdh->interface_data = g_array_new(FALSE, FALSE, sizeof(wtap_optionblock_t));
|
||||
g_array_append_val(wdh->interface_data, descr);
|
||||
}
|
||||
return wdh;
|
||||
|
@ -2214,8 +2203,8 @@ wtap_dump_open(const char *filename, int file_type_subtype, int encap,
|
|||
|
||||
wtap_dumper *
|
||||
wtap_dump_open_ng(const char *filename, int file_type_subtype, int encap,
|
||||
int snaplen, gboolean compressed, wtapng_section_t *shb_hdr, wtapng_iface_descriptions_t *idb_inf,
|
||||
wtapng_name_res_t *nrb_hdr, int *err)
|
||||
int snaplen, gboolean compressed, wtap_optionblock_t shb_hdr, wtapng_iface_descriptions_t *idb_inf,
|
||||
wtap_optionblock_t nrb_hdr, int *err)
|
||||
{
|
||||
wtap_dumper *wdh;
|
||||
WFILE_T fh;
|
||||
|
@ -2260,9 +2249,9 @@ wtap_dumper *
|
|||
wtap_dump_open_tempfile_ng(char **filenamep, const char *pfx,
|
||||
int file_type_subtype, int encap,
|
||||
int snaplen, gboolean compressed,
|
||||
wtapng_section_t *shb_hdr,
|
||||
wtap_optionblock_t shb_hdr,
|
||||
wtapng_iface_descriptions_t *idb_inf,
|
||||
wtapng_name_res_t *nrb_hdr, int *err)
|
||||
wtap_optionblock_t nrb_hdr, int *err)
|
||||
{
|
||||
int fd;
|
||||
char *tmpname;
|
||||
|
@ -2319,8 +2308,8 @@ wtap_dump_fdopen(int fd, int file_type_subtype, int encap, int snaplen,
|
|||
|
||||
wtap_dumper *
|
||||
wtap_dump_fdopen_ng(int fd, int file_type_subtype, int encap, int snaplen,
|
||||
gboolean compressed, wtapng_section_t *shb_hdr, wtapng_iface_descriptions_t *idb_inf,
|
||||
wtapng_name_res_t *nrb_hdr, int *err)
|
||||
gboolean compressed, wtap_optionblock_t shb_hdr, wtapng_iface_descriptions_t *idb_inf,
|
||||
wtap_optionblock_t nrb_hdr, int *err)
|
||||
{
|
||||
wtap_dumper *wdh;
|
||||
WFILE_T fh;
|
||||
|
@ -2359,9 +2348,9 @@ wtap_dump_open_stdout(int file_type_subtype, int encap, int snaplen,
|
|||
|
||||
wtap_dumper *
|
||||
wtap_dump_open_stdout_ng(int file_type_subtype, int encap, int snaplen,
|
||||
gboolean compressed, wtapng_section_t *shb_hdr,
|
||||
gboolean compressed, wtap_optionblock_t shb_hdr,
|
||||
wtapng_iface_descriptions_t *idb_inf,
|
||||
wtapng_name_res_t *nrb_hdr, int *err)
|
||||
wtap_optionblock_t nrb_hdr, int *err)
|
||||
{
|
||||
wtap_dumper *wdh;
|
||||
WFILE_T fh;
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "wtap-int.h"
|
||||
#include "file_wrappers.h"
|
||||
#include "lanalyzer.h"
|
||||
#include "pcapng.h"
|
||||
|
||||
/* The LANalyzer format is documented (at least in part) in Novell document
|
||||
TID022037, which can be found at, among other places:
|
||||
|
@ -327,7 +328,7 @@ wtap_open_return_val lanalyzer_open(wtap *wth, int *err, gchar **err_info)
|
|||
return WTAP_OPEN_NOT_MINE;
|
||||
}
|
||||
comment[record_length] = '\0';
|
||||
wth->shb_hdr.opt_comment = comment;
|
||||
wtap_optionblock_set_option_string(wth->shb_hdr, OPT_COMMENT, comment);
|
||||
}
|
||||
|
||||
/* If we made it this far, then the file is a LANAlyzer file.
|
||||
|
|
201
wiretap/merge.c
201
wiretap/merge.c
|
@ -35,6 +35,8 @@
|
|||
|
||||
#include <string.h>
|
||||
#include "merge.h"
|
||||
#include "wtap_opttypes.h"
|
||||
#include "pcapng.h"
|
||||
|
||||
#include <wsutil/filesystem.h>
|
||||
#include "wsutil/os_version_info.h"
|
||||
|
@ -358,14 +360,16 @@ merge_append_read_packet(int in_file_count, merge_in_file_t in_files[],
|
|||
|
||||
|
||||
/* creates a section header block for the new output file */
|
||||
static wtapng_section_t*
|
||||
static wtap_optionblock_t
|
||||
create_shb_header(const merge_in_file_t *in_files, const guint in_file_count,
|
||||
const gchar *app_name)
|
||||
{
|
||||
wtapng_section_t *shb_hdr = NULL;
|
||||
wtap_optionblock_t shb_hdr;
|
||||
GString *comment_gstr;
|
||||
GString *os_info_str;
|
||||
guint i;
|
||||
char* shb_comment = NULL;
|
||||
wtapng_mandatory_section_t* shb_data;
|
||||
|
||||
shb_hdr = wtap_file_get_shb_for_new_file(in_files[0].wth);
|
||||
|
||||
|
@ -373,12 +377,12 @@ create_shb_header(const merge_in_file_t *in_files, const guint in_file_count,
|
|||
|
||||
/* TODO: merge comments from all files */
|
||||
|
||||
wtap_optionblock_get_option_string(shb_hdr, OPT_COMMENT, &shb_comment);
|
||||
|
||||
/* very lame way to save comments - does not save them from the other files */
|
||||
if (shb_hdr->opt_comment && strlen(shb_hdr->opt_comment) > 0) {
|
||||
g_string_append_printf(comment_gstr, "%s \n",shb_hdr->opt_comment);
|
||||
if (shb_comment && strlen(shb_comment) > 0) {
|
||||
g_string_append_printf(comment_gstr, "%s \n",shb_comment);
|
||||
}
|
||||
g_free(shb_hdr->opt_comment);
|
||||
shb_hdr->opt_comment = NULL;
|
||||
|
||||
g_string_append_printf(comment_gstr, "File created by merging: \n");
|
||||
|
||||
|
@ -389,65 +393,97 @@ create_shb_header(const merge_in_file_t *in_files, const guint in_file_count,
|
|||
os_info_str = g_string_new("");
|
||||
get_os_version_info(os_info_str);
|
||||
|
||||
shb_hdr->section_length = -1;
|
||||
shb_data = (wtapng_mandatory_section_t*)wtap_optionblock_get_mandatory_data(shb_hdr);
|
||||
shb_data->section_length = -1;
|
||||
/* TODO: handle comments from each file being merged */
|
||||
shb_hdr->opt_comment = g_string_free(comment_gstr, FALSE); /* section comment */
|
||||
shb_hdr->shb_hardware = NULL; /* NULL if not available, UTF-8 string containing the */
|
||||
/* description of the hardware used to create this section. */
|
||||
shb_hdr->shb_os = g_string_free(os_info_str, FALSE); /* UTF-8 string containing the name */
|
||||
/* of the operating system used to create this section. */
|
||||
shb_hdr->shb_user_appl = g_strdup(app_name); /* NULL if not available, UTF-8 string containing the name */
|
||||
/* of the application used to create this section. */
|
||||
wtap_optionblock_set_option_string(shb_hdr, OPT_COMMENT, g_string_free(comment_gstr, TRUE)); /* section comment */
|
||||
wtap_optionblock_set_option_string(shb_hdr, OPT_SHB_HARDWARE, NULL ); /* NULL if not available, UTF-8 string containing the */
|
||||
/* description of the hardware used to create this section. */
|
||||
|
||||
wtap_optionblock_set_option_string(shb_hdr, OPT_SHB_OS, g_string_free(os_info_str, TRUE)); /* UTF-8 string containing the name */
|
||||
/* of the operating system used to create this section. */
|
||||
wtap_optionblock_set_option_string(shb_hdr, OPT_SHB_USERAPPL, (char*)app_name ); /* NULL if not available, UTF-8 string containing the name */
|
||||
/* of the application used to create this section. */
|
||||
|
||||
return shb_hdr;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
is_duplicate_idb(const wtapng_if_descr_t *idb1, const wtapng_if_descr_t *idb2)
|
||||
is_duplicate_idb(const wtap_optionblock_t idb1, const wtap_optionblock_t idb2)
|
||||
{
|
||||
wtapng_if_descr_mandatory_t *idb1_mand, *idb2_mand;
|
||||
guint64 idb1_if_speed, idb2_if_speed;
|
||||
guint8 idb1_if_tsresol, idb2_if_tsresol;
|
||||
guint8 idb1_if_fcslen, idb2_if_fcslen;
|
||||
char *idb1_opt_comment, *idb2_opt_comment, *idb1_if_name, *idb2_if_name,
|
||||
*idb1_if_description, *idb2_if_description, *idb1_if_os, *idb2_if_os;
|
||||
|
||||
g_assert(idb1 && idb2);
|
||||
idb1_mand = (wtapng_if_descr_mandatory_t*)wtap_optionblock_get_mandatory_data(idb1);
|
||||
idb2_mand = (wtapng_if_descr_mandatory_t*)wtap_optionblock_get_mandatory_data(idb2);
|
||||
|
||||
merge_debug("merge::is_duplicate_idb() called");
|
||||
merge_debug("idb1->wtap_encap == idb2->wtap_encap: %s",
|
||||
(idb1->wtap_encap == idb2->wtap_encap) ? "TRUE":"FALSE");
|
||||
merge_debug("idb1->time_units_per_second == idb2->time_units_per_second: %s",
|
||||
(idb1->time_units_per_second == idb2->time_units_per_second) ? "TRUE":"FALSE");
|
||||
merge_debug("idb1->tsprecision == idb2->tsprecision: %s",
|
||||
(idb1->tsprecision == idb2->tsprecision) ? "TRUE":"FALSE");
|
||||
merge_debug("idb1->link_type == idb2->link_type: %s",
|
||||
(idb1->link_type == idb2->link_type) ? "TRUE":"FALSE");
|
||||
merge_debug("idb1->snap_len == idb2->snap_len: %s",
|
||||
(idb1->snap_len == idb2->snap_len) ? "TRUE":"FALSE");
|
||||
merge_debug("idb1->if_speed == idb2->if_speed: %s",
|
||||
(idb1->if_speed == idb2->if_speed) ? "TRUE":"FALSE");
|
||||
merge_debug("idb1->if_tsresol == idb2->if_tsresol: %s",
|
||||
(idb1->if_tsresol == idb2->if_tsresol) ? "TRUE":"FALSE");
|
||||
merge_debug("idb1->if_fcslen == idb2->if_fcslen: %s",
|
||||
(idb1->if_fcslen == idb2->if_fcslen) ? "TRUE":"FALSE");
|
||||
merge_debug("g_strcmp0(idb1->opt_comment, idb2->opt_comment) == 0: %s",
|
||||
(g_strcmp0(idb1->opt_comment, idb2->opt_comment) == 0) ? "TRUE":"FALSE");
|
||||
merge_debug("g_strcmp0(idb1->if_name, idb2->if_name) == 0: %s",
|
||||
(g_strcmp0(idb1->if_name, idb2->if_name) == 0) ? "TRUE":"FALSE");
|
||||
merge_debug("g_strcmp0(idb1->if_description, idb2->if_description) == 0: %s",
|
||||
(g_strcmp0(idb1->if_description, idb2->if_description) == 0) ? "TRUE":"FALSE");
|
||||
merge_debug("g_strcmp0(idb1->if_os, idb2->if_os) == 0: %s",
|
||||
(g_strcmp0(idb1->if_os, idb2->if_os) == 0) ? "TRUE":"FALSE");
|
||||
merge_debug("idb1_mand->wtap_encap == idb2_mand->wtap_encap: %s",
|
||||
(idb1_mand->wtap_encap == idb2_mand->wtap_encap) ? "TRUE":"FALSE");
|
||||
merge_debug("idb1_mand->time_units_per_second == idb2_mand->time_units_per_second: %s",
|
||||
(idb1_mand->time_units_per_second == idb2_mand->time_units_per_second) ? "TRUE":"FALSE");
|
||||
merge_debug("idb1_mand->tsprecision == idb2_mand->tsprecision: %s",
|
||||
(idb1_mand->tsprecision == idb2_mand->tsprecision) ? "TRUE":"FALSE");
|
||||
merge_debug("idb1_mand->link_type == idb2_mand->link_type: %s",
|
||||
(idb1_mand->link_type == idb2_mand->link_type) ? "TRUE":"FALSE");
|
||||
merge_debug("idb1_mand->snap_len == idb2_mand->snap_len: %s",
|
||||
(idb1_mand->snap_len == idb2_mand->snap_len) ? "TRUE":"FALSE");
|
||||
|
||||
wtap_optionblock_get_option_uint64(idb1, OPT_IDB_SPEED, &idb1_if_speed);
|
||||
wtap_optionblock_get_option_uint64(idb2, OPT_IDB_SPEED, &idb2_if_speed);
|
||||
merge_debug("idb1_if_speed == idb2_if_speed: %s",
|
||||
(idb1_if_speed == idb2_if_speed) ? "TRUE":"FALSE");
|
||||
|
||||
wtap_optionblock_get_option_uint8(idb1, OPT_IDB_TSRESOL, &idb1_if_tsresol);
|
||||
wtap_optionblock_get_option_uint8(idb2, OPT_IDB_TSRESOL, &idb2_if_tsresol);
|
||||
merge_debug("idb1_if_tsresol == idb2_if_tsresol: %s",
|
||||
(idb1_if_tsresol == idb2_if_tsresol) ? "TRUE":"FALSE");
|
||||
|
||||
wtap_optionblock_get_option_uint8(idb1, OPT_IDB_FCSLEN, &idb1_if_fcslen);
|
||||
wtap_optionblock_get_option_uint8(idb2, OPT_IDB_FCSLEN, &idb2_if_fcslen);
|
||||
merge_debug("idb1_if_fcslen == idb2_if_fcslen: %s",
|
||||
(idb1_if_fcslen == idb2_if_fcslen) ? "TRUE":"FALSE");
|
||||
|
||||
wtap_optionblock_get_option_string(idb1, OPT_COMMENT, &idb1_opt_comment);
|
||||
wtap_optionblock_get_option_string(idb2, OPT_COMMENT, &idb2_opt_comment);
|
||||
merge_debug("g_strcmp0(idb1_opt_comment, idb2_opt_comment) == 0: %s",
|
||||
(g_strcmp0(idb1_opt_comment, idb2_opt_comment) == 0) ? "TRUE":"FALSE");
|
||||
|
||||
wtap_optionblock_get_option_string(idb1, OPT_IDB_NAME, &idb1_if_name);
|
||||
wtap_optionblock_get_option_string(idb2, OPT_IDB_NAME, &idb2_if_name);
|
||||
merge_debug("g_strcmp0(idb1_if_name, idb2_if_name) == 0: %s",
|
||||
(g_strcmp0(idb1_if_name, idb2_if_name) == 0) ? "TRUE":"FALSE");
|
||||
|
||||
wtap_optionblock_get_option_string(idb1, OPT_IDB_DESCR, &idb1_if_description);
|
||||
wtap_optionblock_get_option_string(idb2, OPT_IDB_DESCR, &idb2_if_description);
|
||||
merge_debug("g_strcmp0(idb1_if_description, idb2_if_description) == 0: %s",
|
||||
(g_strcmp0(idb1_if_description, idb2_if_description) == 0) ? "TRUE":"FALSE");
|
||||
|
||||
wtap_optionblock_get_option_string(idb1, OPT_IDB_OS, &idb1_if_os);
|
||||
wtap_optionblock_get_option_string(idb2, OPT_IDB_OS, &idb2_if_os);
|
||||
merge_debug("g_strcmp0(idb1_if_os, idb2_if_os) == 0: %s",
|
||||
(g_strcmp0(idb1_if_os, idb2_if_os) == 0) ? "TRUE":"FALSE");
|
||||
merge_debug("merge::is_duplicate_idb() returning");
|
||||
|
||||
/* does not compare filters nor interface statistics */
|
||||
return (idb1->wtap_encap == idb2->wtap_encap &&
|
||||
idb1->time_units_per_second == idb2->time_units_per_second &&
|
||||
idb1->tsprecision == idb2->tsprecision &&
|
||||
idb1->link_type == idb2->link_type &&
|
||||
return (idb1_mand->wtap_encap == idb2_mand->wtap_encap &&
|
||||
idb1_mand->time_units_per_second == idb2_mand->time_units_per_second &&
|
||||
idb1_mand->tsprecision == idb2_mand->tsprecision &&
|
||||
idb1_mand->link_type == idb2_mand->link_type &&
|
||||
/* XXX: should snaplen not be compared? */
|
||||
idb1->snap_len == idb2->snap_len &&
|
||||
idb1->if_speed == idb2->if_speed &&
|
||||
idb1->if_tsresol == idb2->if_tsresol &&
|
||||
idb1->if_fcslen == idb2->if_fcslen &&
|
||||
g_strcmp0(idb1->opt_comment, idb2->opt_comment) == 0 &&
|
||||
g_strcmp0(idb1->if_name, idb2->if_name) == 0 &&
|
||||
g_strcmp0(idb1->if_description, idb2->if_description) == 0 &&
|
||||
g_strcmp0(idb1->if_os, idb2->if_os) == 0);
|
||||
idb1_mand->snap_len == idb2_mand->snap_len &&
|
||||
idb1_if_speed == idb2_if_speed &&
|
||||
idb1_if_tsresol == idb2_if_tsresol &&
|
||||
idb1_if_fcslen == idb2_if_fcsl |