void ResponseTimeDelayDialog::fillTree() { rtd_data_t rtd_data; memset (&rtd_data, 0, sizeof(rtd_data)); rtd_table_dissector_init(rtd_, &rtd_data.stat_table, NULL, NULL); rtd_data.user_data = this; GString *error_string = register_tap_listener(get_rtd_tap_listener_name(rtd_), &rtd_data, displayFilter(), 0, tapReset, get_rtd_packet_func(rtd_), tapDraw); if (error_string) { QMessageBox::critical(this, tr("Failed to attach to tap \"%1\"").arg(get_rtd_tap_listener_name(rtd_)), error_string->str); g_string_free(error_string, TRUE); free_rtd_table(&rtd_data.stat_table, NULL, NULL); reject(); } statsTreeWidget()->setSortingEnabled(false); cf_retap_packets(cap_file_.capFile()); tapDraw(&rtd_data); statsTreeWidget()->sortItems(col_type_, Qt::AscendingOrder); statsTreeWidget()->setSortingEnabled(true); remove_tap_listener(&rtd_data); free_rtd_table(&rtd_data.stat_table, NULL, NULL); }
void LBMStreamDialog::fillTree(void) { gchar * error_string; if (m_capture_file == NULL) { return; } m_dialog_info->setDialog(this); error_string = register_tap_listener("lbm_stream", (void *)m_dialog_info, m_ui->displayFilterLineEdit->text().toUtf8().constData(), TL_REQUIRES_COLUMNS, resetTap, tapPacket, drawTreeItems); if (error_string) { QMessageBox::critical(this, tr("LBM Stream failed to attach to tap"), error_string); wmem_free(NULL, error_string); reject(); } cf_retap_packets(m_capture_file); drawTreeItems(&m_dialog_info); remove_tap_listener((void *)m_dialog_info); }
void StatsTreeDialog::fillTree() { GString *error_string; if (!st_cfg_ || file_closed_) return; gchar* display_name_temp = stats_tree_get_displayname(st_cfg_->name); QString display_name(display_name_temp); g_free(display_name_temp); // The GTK+ UI appends "Stats Tree" to the window title. If we do the same // here we should expand the name completely, e.g. to "Statistics Tree". setWindowSubtitle(display_name); st_cfg_->pr = &cfg_pr_; cfg_pr_.st_dlg = this; if (st_) { stats_tree_free(st_); } st_ = stats_tree_new(st_cfg_, NULL, ui->displayFilterLineEdit->text().toUtf8().constData()); // Add number of columns for this stats_tree QStringList headerLabels; for (int count = 0; count<st_->num_columns; count++) { headerLabels.push_back(stats_tree_get_column_name(count)); } ui->statsTreeWidget->setColumnCount(headerLabels.count()); ui->statsTreeWidget->setHeaderLabels(headerLabels); resize(st_->num_columns*80+80, height()); for (int count = 0; count<st_->num_columns; count++) { headerLabels.push_back(stats_tree_get_column_name(count)); } ui->statsTreeWidget->setSortingEnabled(false); error_string = register_tap_listener(st_cfg_->tapname, st_, st_->filter, st_cfg_->flags, resetTap, stats_tree_packet, drawTreeItems); if (error_string) { QMessageBox::critical(this, tr("%1 failed to attach to tap").arg(display_name), error_string->str); g_string_free(error_string, TRUE); reject(); } cf_retap_packets(cap_file_.capFile()); drawTreeItems(st_); ui->statsTreeWidget->setSortingEnabled(true); remove_tap_listener(st_); st_cfg_->pr = NULL; }
static void exp_pdu_file_open(exp_pdu_t *exp_pdu_tap_data) { int import_file_fd; char *tmpname, *capfile_name, *comment; int err; /* Choose a random name for the temporary import buffer */ import_file_fd = create_tempfile(&tmpname, "Wireshark_PDU_", NULL); capfile_name = g_strdup(tmpname); comment = g_strdup_printf("Dump of PDUs from %s", cfile.filename); err = exp_pdu_open(exp_pdu_tap_data, import_file_fd, comment); if (err != 0) { g_free(comment); cfile_dump_open_failure_alert_box(capfile_name ? capfile_name : "temporary file", err, WTAP_FILE_TYPE_SUBTYPE_PCAPNG); goto end; } /* Run the tap */ cf_retap_packets(&cfile); err = exp_pdu_close(exp_pdu_tap_data); if (err!= 0) { cfile_close_failure_alert_box(capfile_name, err); } /* XXX: should this use the open_routine type in the cfile instead of WTAP_TYPE_AUTO? */ if (cf_open(&cfile, capfile_name, WTAP_TYPE_AUTO, TRUE /* temporary file */, &err) != CF_OK) { /* cf_open() has put up a dialog box for the error */ goto end; } switch (cf_read(&cfile, FALSE)) { case CF_READ_OK: case CF_READ_ERROR: /* Just because we got an error, that doesn't mean we were unable to read any of the file; we handle what we could get from the file. */ break; case CF_READ_ABORTED: /* The user bailed out of re-reading the capture file; the capture file has been closed - just free the capture file name string and return (without changing the last containing directory). */ break; } end: g_free(capfile_name); }
/* save rtp dump of stream_fwd */ gboolean rtpstream_save(rtpstream_tapinfo_t *tapinfo, capture_file *cap_file, rtp_stream_info_t* stream, const gchar *filename) { gboolean was_registered; if (!tapinfo) { return FALSE; } was_registered = tapinfo->is_registered; /* open file for saving */ tapinfo->save_file = ws_fopen(filename, "wb"); if (tapinfo->save_file==NULL) { open_failure_alert_box(filename, errno, TRUE); return FALSE; } rtp_write_header(stream, tapinfo->save_file); if (ferror(tapinfo->save_file)) { write_failure_alert_box(filename, errno); fclose(tapinfo->save_file); return FALSE; } if (!tapinfo->is_registered) register_tap_listener_rtp_stream(tapinfo); tapinfo->mode = TAP_SAVE; tapinfo->filter_stream_fwd = stream; cf_retap_packets(cap_file); tapinfo->mode = TAP_ANALYSE; if (!was_registered) remove_tap_listener_rtp_stream(tapinfo); if (ferror(tapinfo->save_file)) { write_failure_alert_box(filename, errno); fclose(tapinfo->save_file); return FALSE; } if (fclose(tapinfo->save_file) == EOF) { write_failure_alert_box(filename, errno); return FALSE; } return TRUE; }
/* scan for RTP streams */ void rtpstream_scan(rtpstream_tapinfo_t *tapinfo, capture_file *cap_file) { gboolean was_registered; if (!tapinfo || !cap_file) { return; } was_registered = tapinfo->is_registered; if (!tapinfo->is_registered) register_tap_listener_rtp_stream(tapinfo); tapinfo->mode = TAP_ANALYSE; cf_retap_packets(cap_file); if (!was_registered) remove_tap_listener_rtp_stream(tapinfo); }
static void lbm_uimflow_get_analysis(capture_file * cfile, seq_analysis_info_t * seq_info) { GList * list = NULL; gchar time_str[COL_MAX_LEN]; register_tap_listener("lbm_uim", (void *)seq_info, NULL, TL_REQUIRES_COLUMNS, NULL, lbm_uimflow_tap_packet, NULL); cf_retap_packets(cfile); remove_tap_listener((void *)seq_info); /* Fill in the timestamps. */ list = g_queue_peek_nth_link(seq_info->items, 0); while (list != NULL) { seq_analysis_item_t * seq_item = (seq_analysis_item_t *)list->data; set_fd_time(cfile->epan, frame_data_sequence_find(cfile->frames, seq_item->frame_number), time_str); seq_item->time_str = g_strdup(time_str); list = g_list_next(list); } }
/* scan for RTP streams */ void rtpstream_scan(rtpstream_tapinfo_t *tapinfo, capture_file *cap_file, const char *fstring) { gboolean was_registered; if (!tapinfo || !cap_file) { return; } was_registered = tapinfo->is_registered; if (!tapinfo->is_registered) register_tap_listener_rtp_stream(tapinfo, fstring); /* RTP_STREAM_DEBUG("scanning %s, filter: %s", cap_file->filename, fstring); */ tapinfo->mode = TAP_ANALYSE; cf_retap_packets(cap_file); if (!was_registered) remove_tap_listener_rtp_stream(tapinfo); }
sctp_assoc_info_t* SCTPAssocAnalyseDialog::findAssocForPacket(capture_file* cf) { frame_data *fdata; GList *list, *framelist; sctp_assoc_info_t *assoc; bool frame_found = false; fdata = cf->current_frame; if (sctp_stat_get_info()->is_registered == FALSE) { register_tap_listener_sctp_stat(); /* (redissect all packets) */ cf_retap_packets(cf); } list = g_list_first(sctp_stat_get_info()->assoc_info_list); while (list) { assoc = (sctp_assoc_info_t*)(list->data); framelist = g_list_first(assoc->frame_numbers); while (framelist) { guint32 *fn; fn = (guint32 *)framelist->data; if (*fn == fdata->num) { frame_found = TRUE; break; } framelist = g_list_next(framelist); } if (frame_found) { return assoc; } else { list = g_list_next(list); } } if (!frame_found) { QMessageBox msgBox; msgBox.setText(tr("No Association found for this packet.")); msgBox.exec(); } return NULL; }
SCTPAssocAnalyseDialog::SCTPAssocAnalyseDialog(QWidget *parent, sctp_assoc_info_t *assoc, capture_file *cf, SCTPAllAssocsDialog* caller) : QDialog(parent), ui(new Ui::SCTPAssocAnalyseDialog), selected_assoc(assoc), cap_file_(cf), caller_(caller) { ui->setupUi(this); ui->SCTPAssocAnalyseTab->setCurrentWidget(ui->Statistics); if (!selected_assoc) { if (sctp_stat_get_info()->is_registered == FALSE) { register_tap_listener_sctp_stat(); } /* (redissect all packets) */ cf_retap_packets(cap_file_); selected_assoc = findAssocForPacket(cap_file_); } this->setWindowTitle(QString(tr("SCTP Analyse Association: %1 Port1 %2 Port2 %3")).arg(cf_get_display_name(cap_file_)).arg(selected_assoc->port1).arg(selected_assoc->port2)); fillTabs(); }
/* mark packets in stream_fwd or stream_rev */ void rtpstream_mark(rtpstream_tapinfo_t *tapinfo, capture_file *cap_file, rtp_stream_info_t* stream_fwd, rtp_stream_info_t* stream_rev) { gboolean was_registered; if (!tapinfo) { return; } was_registered = tapinfo->is_registered; if (!tapinfo->is_registered) register_tap_listener_rtp_stream(tapinfo); tapinfo->mode = TAP_MARK; tapinfo->filter_stream_fwd = stream_fwd; tapinfo->filter_stream_rev = stream_rev; cf_retap_packets(cap_file); tapinfo->mode = TAP_ANALYSE; if (!was_registered) remove_tap_listener_rtp_stream(tapinfo); }
void SCTPAllAssocsDialog::fillTable() { QString output; GList *list; sctp_assoc_info_t* assinfo; int numAssocs; ui->assocList->setColumnHidden(0, true); ui->assocList->setColumnWidth(1, 85); ui->assocList->setColumnWidth(2, 85); ui->assocList->setColumnWidth(3, 150); ui->assocList->setColumnWidth(4, 150); sctp_assocs = (sctp_allassocs_info_t*)sctp_stat_get_info(); if (sctp_stat_get_info()->is_registered == FALSE) { register_tap_listener_sctp_stat(); /* (redissect all packets) */ cf_retap_packets(cap_file_); } numAssocs = 0; ui->assocList->setRowCount(g_list_length(sctp_assocs->assoc_info_list)); list = g_list_first(sctp_assocs->assoc_info_list); while (list) { assinfo = (sctp_assoc_info_t*)(list->data); ui->assocList->setItem(numAssocs, 0, new QTableWidgetItem(QString("%1").arg(assinfo->assoc_id))); ui->assocList->setItem(numAssocs, 1, new QTableWidgetItem(QString("%1").arg(assinfo->port1))); ui->assocList->setItem(numAssocs, 2, new QTableWidgetItem(QString("%1").arg(assinfo->port2))); ui->assocList->setItem(numAssocs, 3, new QTableWidgetItem(QString("%1").arg(assinfo->n_packets))); ui->assocList->setItem(numAssocs, 4, new QTableWidgetItem(QString("%1").arg(assinfo->n_data_chunks))); ui->assocList->setItem(numAssocs, 5, new QTableWidgetItem(QString("%1").arg(assinfo->n_data_bytes))); list = g_list_next(list); numAssocs++; } ui->analyseButton->setEnabled(false); ui->setFilterButton->setEnabled(false); connect(ui->assocList, SIGNAL(itemSelectionChanged()), this, SLOT(getSelectedItem())); }
static void exp_pdu_file_open(exp_pdu_t *exp_pdu_tap_data) { int import_file_fd; char *tmpname, *capfile_name; int err; /* pcapng defs */ wtapng_section_t *shb_hdr; wtapng_iface_descriptions_t *idb_inf; wtapng_if_descr_t int_data; GString *os_info_str; char *appname; /* Choose a random name for the temporary import buffer */ import_file_fd = create_tempfile(&tmpname, "Wireshark_PDU_"); capfile_name = g_strdup(tmpname); /* Create data for SHB */ os_info_str = g_string_new(""); get_os_version_info(os_info_str); appname = g_strdup_printf("Wireshark %s", get_ws_vcs_version_info()); shb_hdr = g_new(wtapng_section_t,1); shb_hdr->section_length = -1; /* options */ shb_hdr->opt_comment = g_strdup_printf("Dump of PDUs from %s", cfile.filename); shb_hdr->shb_hardware = NULL; /* UTF-8 string containing the * description of the hardware used to create this section. */ shb_hdr->shb_os = os_info_str->str; /* UTF-8 string containing the name * of the operating system used to create this section. */ g_string_free(os_info_str, FALSE); /* The actual string is not freed */ shb_hdr->shb_user_appl = appname; /* UTF-8 string containing the name * of the application used to create this section. */ /* 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)); /* create the fake interface data */ int_data.wtap_encap = WTAP_ENCAP_WIRESHARK_UPPER_PDU; int_data.time_units_per_second = 1000000; /* default microsecond 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 = 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; g_array_append_val(idb_inf->interface_data, int_data); exp_pdu_tap_data->wdh = wtap_dump_fdopen_ng(import_file_fd, WTAP_FILE_TYPE_SUBTYPE_PCAPNG, WTAP_ENCAP_WIRESHARK_UPPER_PDU, WTAP_MAX_PACKET_SIZE, FALSE, shb_hdr, idb_inf, &err); if (exp_pdu_tap_data->wdh == NULL) { open_failure_alert_box(capfile_name, err, TRUE); goto end; } /* Run the tap */ cf_retap_packets(&cfile); if (!wtap_dump_close(exp_pdu_tap_data->wdh, &err)) { write_failure_alert_box(capfile_name, err); } remove_tap_listener(exp_pdu_tap_data); /* XXX: should this use the open_routine type in the cfile instead of WTAP_TYPE_AUTO? */ if (cf_open(&cfile, capfile_name, WTAP_TYPE_AUTO, TRUE /* temporary file */, &err) != CF_OK) { open_failure_alert_box(capfile_name, err, FALSE); goto end; } switch (cf_read(&cfile, FALSE)) { case CF_READ_OK: case CF_READ_ERROR: /* Just because we got an error, that doesn't mean we were unable to read any of the file; we handle what we could get from the file. */ break; case CF_READ_ABORTED: /* The user bailed out of re-reading the capture file; the capture file has been closed - just free the capture file name string and return (without changing the last containing directory). */ break; } end: g_free(capfile_name); g_free(shb_hdr); g_free(appname); }
static void exp_pdu_file_open(exp_pdu_t *exp_pdu_tap_data) { char *tmpname, *capfile_name; int err; /* pcapng defs */ wtap_optionblock_t shb_hdr; wtapng_iface_descriptions_t *idb_inf; 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 = wtap_optionblock_create(WTAP_OPTION_BLOCK_NG_SECTION); /* options */ 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. */ 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. */ 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(wtap_optionblock_t)); /* create the fake interface data */ 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); /* Use a random name for the temporary import buffer */ exp_pdu_tap_data->wdh = wtap_dump_open_tempfile_ng(&tmpname, "Wireshark_PDU_", WTAP_FILE_TYPE_SUBTYPE_PCAPNG, WTAP_ENCAP_WIRESHARK_UPPER_PDU, WTAP_MAX_PACKET_SIZE, FALSE, shb_hdr, idb_inf, NULL, &err); capfile_name = g_strdup(tmpname); if (exp_pdu_tap_data->wdh == NULL) { open_failure_alert_box(capfile_name ? capfile_name : "temporary file", err, TRUE); goto end; } /* Run the tap */ cf_retap_packets(&cfile); if (!wtap_dump_close(exp_pdu_tap_data->wdh, &err)) { write_failure_alert_box(capfile_name, err); } remove_tap_listener(exp_pdu_tap_data); /* XXX: should this use the open_routine type in the cfile instead of WTAP_TYPE_AUTO? */ if (cf_open(&cfile, capfile_name, WTAP_TYPE_AUTO, TRUE /* temporary file */, &err) != CF_OK) { open_failure_alert_box(capfile_name, err, FALSE); goto end; } switch (cf_read(&cfile, FALSE)) { case CF_READ_OK: case CF_READ_ERROR: /* Just because we got an error, that doesn't mean we were unable to read any of the file; we handle what we could get from the file. */ break; case CF_READ_ABORTED: /* The user bailed out of re-reading the capture file; the capture file has been closed - just free the capture file name string and return (without changing the last containing directory). */ break; } end: g_free(capfile_name); wtap_optionblock_free(shb_hdr); wtap_free_idb_info(idb_inf); }
void CaptureFile::retapPackets() { if (cap_file_) { cf_retap_packets(cap_file_); } }
void StatsTreeDialog::fillTree() { GString *error_string; if (!st_cfg_) return; gchar* display_name_temp = stats_tree_get_displayname(st_cfg_->name); QString display_name(display_name_temp); g_free(display_name_temp); setWindowTitle(display_name + tr(" Stats Tree")); if (!cap_file_) return; if (st_cfg_->in_use) { QMessageBox::warning(this, tr("%1 already open").arg(display_name), tr("Each type of tree can only be generated one at at time.")); reject(); } st_cfg_->in_use = TRUE; st_cfg_->pr = &cfg_pr_; cfg_pr_.st_dlg = this; if (st_) { stats_tree_free(st_); } st_ = stats_tree_new(st_cfg_, NULL, ui->displayFilterLineEdit->text().toUtf8().constData()); // Add number of columns for this stats_tree QStringList headerLabels; for (int count = 0; count<st_->num_columns; count++) { headerLabels.push_back(stats_tree_get_column_name(count)); } ui->statsTreeWidget->setColumnCount(headerLabels.count()); ui->statsTreeWidget->setHeaderLabels(headerLabels); resize(st_->num_columns*80+80, height()); for (int count = 0; count<st_->num_columns; count++) { headerLabels.push_back(stats_tree_get_column_name(count)); } ui->statsTreeWidget->setSortingEnabled(false); error_string = register_tap_listener(st_cfg_->tapname, st_, st_->filter, st_cfg_->flags, resetTap, stats_tree_packet, drawTreeItems); if (error_string) { QMessageBox::critical(this, tr("%1 failed to attach to tap").arg(display_name), error_string->str); g_string_free(error_string, TRUE); reject(); } cf_retap_packets(cap_file_); drawTreeItems(st_); ui->statsTreeWidget->setSortingEnabled(true); remove_tap_listener(st_); st_cfg_->in_use = FALSE; st_cfg_->pr = NULL; }