/* * Returns true if all of the input files have duplicate IDBs to the other files. */ static gboolean all_idbs_are_duplicates(const merge_in_file_t *in_files, const guint in_file_count) { wtapng_iface_descriptions_t *first_idb_list = NULL; wtapng_iface_descriptions_t *other_idb_list = NULL; guint first_idb_list_size, other_idb_list_size; wtap_block_t first_file_idb, other_file_idb; guint i, j; g_assert(in_files != NULL); /* get the first file's info */ first_idb_list = wtap_file_get_idb_info(in_files[0].wth); g_assert(first_idb_list->interface_data); first_idb_list_size = first_idb_list->interface_data->len; /* now compare the other input files with that */ for (i = 1; i < in_file_count; i++) { other_idb_list = wtap_file_get_idb_info(in_files[i].wth); g_assert(other_idb_list->interface_data); other_idb_list_size = other_idb_list->interface_data->len; if (other_idb_list_size != first_idb_list_size) { merge_debug("merge::all_idbs_are_duplicates: sizes of IDB lists don't match: first=%u, other=%u", first_idb_list_size, other_idb_list_size); g_free(other_idb_list); g_free(first_idb_list); return FALSE; } for (j = 0; j < other_idb_list_size; j++) { first_file_idb = g_array_index(first_idb_list->interface_data, wtap_block_t, j); other_file_idb = g_array_index(other_idb_list->interface_data, wtap_block_t, j); if (!is_duplicate_idb(first_file_idb, other_file_idb)) { merge_debug("merge::all_idbs_are_duplicates: IDBs at index %d do not match, returning FALSE", j); g_free(other_idb_list); g_free(first_idb_list); return FALSE; } } g_free(other_idb_list); } merge_debug("merge::all_idbs_are_duplicates: returning TRUE"); g_free(first_idb_list); return TRUE; }
void merge_sort_debug(data array[], int len, STAT *stat) { if (len > 1) { int middle = len/2; // split the array merge_sort_debug(array, middle, stat); // order from 0 to middle-1 merge_sort_debug(array+middle, len-middle, stat); // order from middle to len-1 stat->recc += 2; merge_debug(array, middle, len, stat); // merge the two arrays } }
static gboolean map_phdr_interface_id(struct wtap_pkthdr *phdr, const merge_in_file_t *in_file) { guint current_interface_id = 0; g_assert(phdr != NULL); g_assert(in_file != NULL); g_assert(in_file->idb_index_map != NULL); if (phdr->presence_flags & WTAP_HAS_INTERFACE_ID) { current_interface_id = phdr->interface_id; } if (current_interface_id >= in_file->idb_index_map->len) { /* this shouldn't happen, but in a malformed input file it could */ merge_debug("merge::map_phdr_interface_id: current_interface_id >= in_file->idb_index_map->len (ERROR?)"); return FALSE; } phdr->interface_id = g_array_index(in_file->idb_index_map, guint, current_interface_id); phdr->presence_flags |= WTAP_HAS_INTERFACE_ID; return TRUE; }
/* * Merges the files based on given input, and invokes callback during * execution. Returns MERGE_OK on success, or a MERGE_ERR_XXX on failure; note * that the passed-in 'err' variable will be more specific to what failed, and * err_info will have pretty output. */ merge_result merge_files(int out_fd, const gchar* out_filename, const int file_type, const char *const *in_filenames, const guint in_file_count, const gboolean do_append, const idb_merge_mode mode, guint snaplen, const gchar *app_name, merge_progress_callback_t* cb, int *err, gchar **err_info, guint *err_fileno) { merge_in_file_t *in_files = NULL, *in_file = NULL; int frame_type = WTAP_ENCAP_PER_PACKET; merge_result status = MERGE_OK; wtap_dumper *pdh; struct wtap_pkthdr *phdr, snap_phdr; int count = 0; gboolean stop_flag = FALSE; GArray *shb_hdrs = NULL; wtapng_iface_descriptions_t *idb_inf = NULL; g_assert(out_fd > 0); g_assert(in_file_count > 0); g_assert(in_filenames != NULL); g_assert(err != NULL); g_assert(err_info != NULL); g_assert(err_fileno != NULL); /* if a callback was given, it has to have a callback function ptr */ g_assert((cb != NULL) ? (cb->callback_func != NULL) : TRUE); merge_debug("merge_files: begin"); /* open the input files */ if (!merge_open_in_files(in_file_count, in_filenames, &in_files, err, err_info, err_fileno)) { merge_debug("merge_files: merge_open_in_files() failed with err=%d", *err); return MERGE_ERR_CANT_OPEN_INFILE; } if (cb) cb->callback_func(MERGE_EVENT_INPUT_FILES_OPENED, 0, in_files, in_file_count, cb->data); if (snaplen == 0) { /* Snapshot length not specified - default to the maximum. */ snaplen = WTAP_MAX_PACKET_SIZE; } /* * This doesn't tell us that much. It tells us what to set the outfile's * encap type to, but that's all - for example, it does *not* tells us * whether the input files had the same number of IDBs, for the same exact * interfaces, and only one IDB each, so it doesn't actually tell us * whether we can merge IDBs into one or not. */ frame_type = merge_select_frame_type(in_file_count, in_files); merge_debug("merge_files: got frame_type=%d", frame_type); if (cb) cb->callback_func(MERGE_EVENT_FRAME_TYPE_SELECTED, frame_type, in_files, in_file_count, cb->data); /* prepare the outfile */ if (file_type == WTAP_FILE_TYPE_SUBTYPE_PCAPNG) { shb_hdrs = create_shb_header(in_files, in_file_count, app_name); merge_debug("merge_files: SHB created"); idb_inf = generate_merged_idb(in_files, in_file_count, mode); merge_debug("merge_files: IDB merge operation complete, got %u IDBs", idb_inf ? idb_inf->interface_data->len : 0); pdh = wtap_dump_fdopen_ng(out_fd, file_type, frame_type, snaplen, FALSE /* compressed */, shb_hdrs, idb_inf, NULL, err); } else { pdh = wtap_dump_fdopen(out_fd, file_type, frame_type, snaplen, FALSE /* compressed */, err); } if (pdh == NULL) { merge_close_in_files(in_file_count, in_files); g_free(in_files); wtap_block_array_free(shb_hdrs); wtap_free_idb_info(idb_inf); return MERGE_ERR_CANT_OPEN_OUTFILE; } if (cb) cb->callback_func(MERGE_EVENT_READY_TO_MERGE, 0, in_files, in_file_count, cb->data); for (;;) { *err = 0; if (do_append) { in_file = merge_append_read_packet(in_file_count, in_files, err, err_info); } else { in_file = merge_read_packet(in_file_count, in_files, err, err_info); } if (in_file == NULL) { /* EOF */ break; } if (*err != 0) { /* I/O error reading from in_file */ status = MERGE_ERR_CANT_READ_INFILE; break; } count++; if (cb) stop_flag = cb->callback_func(MERGE_EVENT_PACKET_WAS_READ, count, in_files, in_file_count, cb->data); if (stop_flag) { /* The user decided to abort the merge. */ status = MERGE_USER_ABORTED; break; } phdr = wtap_phdr(in_file->wth); if (snaplen != 0 && phdr->caplen > snaplen) { /* * The dumper will only write up to caplen bytes out, so we only * need to change that value, instead of cloning the whole packet * with fewer bytes. * * XXX: but do we need to change the IDBs' snap_len? */ snap_phdr = *phdr; snap_phdr.caplen = snaplen; phdr = &snap_phdr; } if (file_type == WTAP_FILE_TYPE_SUBTYPE_PCAPNG) { /* * XXX - We should do this only for record types * that pertain to a particular interface; for * now, we hardcode that, but we need to figure * out a more general way to handle this. */ if (phdr->rec_type == REC_TYPE_PACKET) { if (!map_phdr_interface_id(phdr, in_file)) { status = MERGE_ERR_BAD_PHDR_INTERFACE_ID; break; } } } if (!wtap_dump(pdh, phdr, wtap_buf_ptr(in_file->wth), err, err_info)) { status = MERGE_ERR_CANT_WRITE_OUTFILE; break; } } if (cb) cb->callback_func(MERGE_EVENT_DONE, count, in_files, in_file_count, cb->data); merge_close_in_files(in_file_count, in_files); if (status == MERGE_OK || status == MERGE_USER_ABORTED) { if (!wtap_dump_close(pdh, err)) status = MERGE_ERR_CANT_CLOSE_OUTFILE; } else { /* * We already got some error; no need to report another error on * close. * * Don't overwrite the earlier error. */ int close_err = 0; (void)wtap_dump_close(pdh, &close_err); } if (status != MERGE_OK) { GString *err_message = NULL; gchar *display_basename = NULL; switch(status) { case MERGE_ERR_CANT_READ_INFILE: *err_info = get_read_error_string(in_files, in_file_count, err, err_info); break; case MERGE_ERR_CANT_WRITE_OUTFILE: /* fall through */ case MERGE_ERR_CANT_CLOSE_OUTFILE: *err_info = get_write_error_string(in_file, file_type, out_filename, err, err_info); break; case MERGE_ERR_BAD_PHDR_INTERFACE_ID: display_basename = g_filename_display_basename(in_file ? in_file->filename : "UNKNOWN"); if (*err_info != NULL) g_free(*err_info); err_message = g_string_new(""); g_string_printf(err_message, "Record %u of \"%s\" has an interface ID which does not match any IDB in its file.", in_file ? in_file->packet_num : 0, display_basename); g_free(display_basename); *err_info = g_string_free(err_message, FALSE); break; case MERGE_USER_ABORTED: /* not really an error */ default: break; } } g_free(in_files); wtap_block_array_free(shb_hdrs); wtap_free_idb_info(idb_inf); return status; }
/* * Create clone IDBs for the merge file, based on the input files and mode. */ static wtapng_iface_descriptions_t * generate_merged_idb(merge_in_file_t *in_files, const guint in_file_count, const idb_merge_mode mode) { wtapng_iface_descriptions_t *merged_idb_list = NULL; wtapng_iface_descriptions_t *input_file_idb_list = NULL; wtap_block_t input_file_idb; guint itf_count, merged_index; guint i; /* create new IDB info */ merged_idb_list = g_new(wtapng_iface_descriptions_t,1); merged_idb_list->interface_data = g_array_new(FALSE, FALSE, sizeof(wtap_block_t)); if (mode == IDB_MERGE_MODE_ALL_SAME && all_idbs_are_duplicates(in_files, in_file_count)) { guint num_idbs; merge_debug("merge::generate_merged_idb: mode ALL set and all IDBs are duplicates"); /* they're all the same, so just get the first file's IDBs */ input_file_idb_list = wtap_file_get_idb_info(in_files[0].wth); /* this is really one more than number of IDBs, but that's good for the for-loops */ num_idbs = input_file_idb_list->interface_data->len; /* put them in the merged file */ for (itf_count = 0; itf_count < num_idbs; itf_count++) { input_file_idb = g_array_index(input_file_idb_list->interface_data, wtap_block_t, itf_count); merged_index = add_idb_to_merged_file(merged_idb_list, input_file_idb); add_idb_index_map(&in_files[0], itf_count, merged_index); } /* and set all the other file index maps the same way */ for (i = 1; i < in_file_count; i++) { for (itf_count = 0; itf_count < num_idbs; itf_count++) { add_idb_index_map(&in_files[i], itf_count, itf_count); } } g_free(input_file_idb_list); } else { for (i = 0; i < in_file_count; i++) { input_file_idb_list = wtap_file_get_idb_info(in_files[i].wth); for (itf_count = 0; itf_count < input_file_idb_list->interface_data->len; itf_count++) { input_file_idb = g_array_index(input_file_idb_list->interface_data, wtap_block_t, itf_count); if (mode == IDB_MERGE_MODE_ANY_SAME && find_duplicate_idb(input_file_idb, merged_idb_list, &merged_index)) { merge_debug("merge::generate_merged_idb: mode ANY set and found a duplicate"); /* * It's the same as a previous IDB, so we're going to "merge" * them into one by adding a map from its old IDB index to the new * one. This will be used later to change the phdr interface_id. */ add_idb_index_map(&in_files[i], itf_count, merged_index); } else { merge_debug("merge::generate_merged_idb: mode NONE set or did not find a duplicate"); /* * This IDB does not match a previous (or we want to save all IDBs), * so add the IDB to the merge file, and add a map of the indeces. */ merged_index = add_idb_to_merged_file(merged_idb_list, input_file_idb); add_idb_index_map(&in_files[i], itf_count, merged_index); } } g_free(input_file_idb_list); } } return merged_idb_list; }
static gboolean is_duplicate_idb(const wtap_block_t idb1, const wtap_block_t idb2) { wtapng_if_descr_mandatory_t *idb1_mand, *idb2_mand; gboolean have_idb1_value, have_idb2_value; 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_block_get_mandatory_data(idb1); idb2_mand = (wtapng_if_descr_mandatory_t*)wtap_block_get_mandatory_data(idb2); merge_debug("merge::is_duplicate_idb() called"); merge_debug("idb1_mand->wtap_encap == idb2_mand->wtap_encap: %s", (idb1_mand->wtap_encap == idb2_mand->wtap_encap) ? "TRUE":"FALSE"); if (idb1_mand->wtap_encap != idb2_mand->wtap_encap) { /* Clearly not the same interface. */ merge_debug("merge::is_duplicate_idb() returning FALSE"); return FALSE; } merge_debug("idb1_mand->link_type == idb2_mand->link_type: %s", (idb1_mand->link_type == idb2_mand->link_type) ? "TRUE":"FALSE"); if (idb1_mand->link_type != idb2_mand->link_type) { /* Clearly not the same interface. */ merge_debug("merge::is_duplicate_idb() returning FALSE"); return 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"); if (idb1_mand->time_units_per_second != idb2_mand->time_units_per_second) { /* * Probably not the same interface, and we can't combine them * in any case. */ merge_debug("merge::is_duplicate_idb() returning FALSE"); return FALSE; } merge_debug("idb1_mand->tsprecision == idb2_mand->tsprecision: %s", (idb1_mand->tsprecision == idb2_mand->tsprecision) ? "TRUE":"FALSE"); if (idb1_mand->tsprecision != idb2_mand->tsprecision) { /* * Probably not the same interface, and we can't combine them * in any case. */ merge_debug("merge::is_duplicate_idb() returning FALSE"); return FALSE; } /* XXX: should snaplen not be compared? */ merge_debug("idb1_mand->snap_len == idb2_mand->snap_len: %s", (idb1_mand->snap_len == idb2_mand->snap_len) ? "TRUE":"FALSE"); if (idb1_mand->snap_len != idb2_mand->snap_len) { merge_debug("merge::is_duplicate_idb() returning FALSE"); return FALSE; } /* XXX - what do to if we have only one value? */ have_idb1_value = (wtap_block_get_uint64_option_value(idb1, OPT_IDB_SPEED, &idb1_if_speed) == WTAP_OPTTYPE_SUCCESS); have_idb2_value = (wtap_block_get_uint64_option_value(idb2, OPT_IDB_SPEED, &idb2_if_speed) == WTAP_OPTTYPE_SUCCESS); if (have_idb1_value && have_idb2_value) { merge_debug("idb1_if_speed == idb2_if_speed: %s", (idb1_if_speed == idb2_if_speed) ? "TRUE":"FALSE"); if (idb1_if_speed != idb2_if_speed) { merge_debug("merge::is_duplicate_idb() returning FALSE"); return FALSE; } } /* XXX - what do to if we have only one value? */ have_idb1_value = (wtap_block_get_uint8_option_value(idb1, OPT_IDB_TSRESOL, &idb1_if_tsresol) == WTAP_OPTTYPE_SUCCESS); have_idb2_value = (wtap_block_get_uint8_option_value(idb2, OPT_IDB_TSRESOL, &idb2_if_tsresol) == WTAP_OPTTYPE_SUCCESS); if (have_idb1_value && have_idb2_value) { merge_debug("idb1_if_tsresol == idb2_if_tsresol: %s", (idb1_if_tsresol == idb2_if_tsresol) ? "TRUE":"FALSE"); if (idb1_if_tsresol != idb2_if_tsresol) { merge_debug("merge::is_duplicate_idb() returning FALSE"); return FALSE; } } /* XXX - what do to if we have only one value? */ have_idb1_value = (wtap_block_get_uint8_option_value(idb1, OPT_IDB_FCSLEN, &idb1_if_fcslen) == WTAP_OPTTYPE_SUCCESS); have_idb2_value = (wtap_block_get_uint8_option_value(idb2, OPT_IDB_FCSLEN, &idb2_if_fcslen) == WTAP_OPTTYPE_SUCCESS); if (have_idb1_value && have_idb2_value) { merge_debug("idb1_if_fcslen == idb2_if_fcslen: %s", (idb1_if_fcslen == idb2_if_fcslen) ? "TRUE":"FALSE"); if (idb1_if_fcslen == idb2_if_fcslen) { merge_debug("merge::is_duplicate_idb() returning FALSE"); return FALSE; } } /* * XXX - handle multiple comments? * XXX - if the comments are different, just combine them if we * decide the two interfaces are really the same? As comments * can be arbitrary strings added by people, the fact that they're * different doesn't necessarily mean the interfaces are different. */ have_idb1_value = (wtap_block_get_nth_string_option_value(idb1, OPT_COMMENT, 0, &idb1_opt_comment) == WTAP_OPTTYPE_SUCCESS); have_idb2_value = (wtap_block_get_nth_string_option_value(idb2, OPT_COMMENT, 0, &idb2_opt_comment) == WTAP_OPTTYPE_SUCCESS); if (have_idb1_value && have_idb2_value) { merge_debug("g_strcmp0(idb1_opt_comment, idb2_opt_comment) == 0: %s", (g_strcmp0(idb1_opt_comment, idb2_opt_comment) == 0) ? "TRUE":"FALSE"); if (g_strcmp0(idb1_opt_comment, idb2_opt_comment) != 0) { merge_debug("merge::is_duplicate_idb() returning FALSE"); return FALSE; } } /* XXX - what do to if we have only one value? */ have_idb1_value = (wtap_block_get_string_option_value(idb1, OPT_IDB_NAME, &idb1_if_name) == WTAP_OPTTYPE_SUCCESS); have_idb2_value = (wtap_block_get_string_option_value(idb2, OPT_IDB_NAME, &idb2_if_name) == WTAP_OPTTYPE_SUCCESS); if (have_idb1_value && have_idb2_value) { merge_debug("g_strcmp0(idb1_if_name, idb2_if_name) == 0: %s", (g_strcmp0(idb1_if_name, idb2_if_name) == 0) ? "TRUE":"FALSE"); if (g_strcmp0(idb1_if_name, idb2_if_name) != 0) { merge_debug("merge::is_duplicate_idb() returning FALSE"); return FALSE; } } /* XXX - what do to if we have only one value? */ have_idb1_value = (wtap_block_get_string_option_value(idb1, OPT_IDB_DESCR, &idb1_if_description) == WTAP_OPTTYPE_SUCCESS); have_idb2_value = (wtap_block_get_string_option_value(idb2, OPT_IDB_DESCR, &idb2_if_description) == WTAP_OPTTYPE_SUCCESS); if (have_idb1_value && have_idb2_value) { merge_debug("g_strcmp0(idb1_if_description, idb2_if_description) == 0: %s", (g_strcmp0(idb1_if_description, idb2_if_description) == 0) ? "TRUE":"FALSE"); if (g_strcmp0(idb1_if_description, idb2_if_description) != 0) { merge_debug("merge::is_duplicate_idb() returning FALSE"); return FALSE; } } /* XXX - what do to if we have only one value? */ have_idb1_value = (wtap_block_get_string_option_value(idb1, OPT_IDB_OS, &idb1_if_os) == WTAP_OPTTYPE_SUCCESS); have_idb2_value = (wtap_block_get_string_option_value(idb2, OPT_IDB_OS, &idb2_if_os) == WTAP_OPTTYPE_SUCCESS); if (have_idb1_value && have_idb2_value) { merge_debug("g_strcmp0(idb1_if_os, idb2_if_os) == 0: %s", (g_strcmp0(idb1_if_os, idb2_if_os) == 0) ? "TRUE":"FALSE"); if (g_strcmp0(idb1_if_os, idb2_if_os) != 0) { merge_debug("merge::is_duplicate_idb() returning FALSE"); return FALSE; } } /* does not compare filters nor interface statistics */ merge_debug("merge::is_duplicate_idb() returning TRUE"); return TRUE; }
/* * Merges the files to an output file whose name is supplied as an argument, * based on given input, and invokes callback during execution. Returns * MERGE_OK on success, or a MERGE_ERR_XXX on failure. */ merge_result merge_files(const gchar* out_filename, const int file_type, const char *const *in_filenames, const guint in_file_count, const gboolean do_append, const idb_merge_mode mode, guint snaplen, const gchar *app_name, merge_progress_callback_t* cb, int *err, gchar **err_info, guint *err_fileno, guint32 *err_framenum) { merge_in_file_t *in_files = NULL; int frame_type = WTAP_ENCAP_PER_PACKET; merge_result status = MERGE_OK; wtap_dumper *pdh; GArray *shb_hdrs = NULL; wtapng_iface_descriptions_t *idb_inf = NULL; g_assert(out_filename != NULL); g_assert(in_file_count > 0); g_assert(in_filenames != NULL); g_assert(err != NULL); g_assert(err_info != NULL); g_assert(err_fileno != NULL); g_assert(err_framenum != NULL); /* if a callback was given, it has to have a callback function ptr */ g_assert((cb != NULL) ? (cb->callback_func != NULL) : TRUE); merge_debug("merge_files: begin"); /* open the input files */ if (!merge_open_in_files(in_file_count, in_filenames, &in_files, cb, err, err_info, err_fileno)) { merge_debug("merge_files: merge_open_in_files() failed with err=%d", *err); *err_framenum = 0; return MERGE_ERR_CANT_OPEN_INFILE; } if (snaplen == 0) { /* Snapshot length not specified - default to the maximum. */ snaplen = WTAP_MAX_PACKET_SIZE_STANDARD; } /* * This doesn't tell us that much. It tells us what to set the outfile's * encap type to, but that's all - for example, it does *not* tells us * whether the input files had the same number of IDBs, for the same exact * interfaces, and only one IDB each, so it doesn't actually tell us * whether we can merge IDBs into one or not. */ frame_type = merge_select_frame_type(in_file_count, in_files); merge_debug("merge_files: got frame_type=%d", frame_type); if (cb) cb->callback_func(MERGE_EVENT_FRAME_TYPE_SELECTED, frame_type, in_files, in_file_count, cb->data); /* prepare the outfile */ if (file_type == WTAP_FILE_TYPE_SUBTYPE_PCAPNG) { shb_hdrs = create_shb_header(in_files, in_file_count, app_name); merge_debug("merge_files: SHB created"); idb_inf = generate_merged_idb(in_files, in_file_count, mode); merge_debug("merge_files: IDB merge operation complete, got %u IDBs", idb_inf ? idb_inf->interface_data->len : 0); pdh = wtap_dump_open_ng(out_filename, file_type, frame_type, snaplen, FALSE /* compressed */, shb_hdrs, idb_inf, NULL, err); } else { pdh = wtap_dump_open(out_filename, file_type, frame_type, snaplen, FALSE /* compressed */, err); } if (pdh == NULL) { merge_close_in_files(in_file_count, in_files); g_free(in_files); wtap_block_array_free(shb_hdrs); wtap_free_idb_info(idb_inf); *err_framenum = 0; return MERGE_ERR_CANT_OPEN_OUTFILE; } if (cb) cb->callback_func(MERGE_EVENT_READY_TO_MERGE, 0, in_files, in_file_count, cb->data); status = merge_process_packets(pdh, file_type, in_files, in_file_count, do_append, snaplen, cb, err, err_info, err_fileno, err_framenum); g_free(in_files); wtap_block_array_free(shb_hdrs); wtap_free_idb_info(idb_inf); return status; }
static gboolean 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_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_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_mand->snap_len == idb2_mand->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); }
static gboolean is_duplicate_idb(const wtapng_if_descr_t *idb1, const wtapng_if_descr_t *idb2) { g_assert(idb1 && 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("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 && /* 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); }