ServiceResponseTimeDialog::ServiceResponseTimeDialog(QWidget &parent, CaptureFile &cf, register_srt *srt, const QString filter, int help_topic) : TapParameterDialog(parent, cf, help_topic), srt_(srt) { QString subtitle = QString("%1 Service Response Time Statistics") .arg(proto_get_protocol_short_name(find_protocol_by_id(get_srt_proto_id(srt)))); setWindowSubtitle(subtitle); // Add number of columns for this stats_tree QStringList header_labels; for (int col = 0; col < NUM_SRT_COLUMNS; col++) { header_labels.push_back(service_response_time_get_column_name(col)); } statsTreeWidget()->setColumnCount(header_labels.count()); statsTreeWidget()->setHeaderLabels(header_labels); for (int col = 0; col < statsTreeWidget()->columnCount(); col++) { if (col == SRT_COLUMN_PROCEDURE) continue; statsTreeWidget()->headerItem()->setTextAlignment(col, Qt::AlignRight); } addFilterActions(); if (!filter.isEmpty()) { setDisplayFilter(filter); } connect(statsTreeWidget(), SIGNAL(itemChanged(QTreeWidgetItem*,int)), this, SLOT(statsTreeWidgetItemChanged())); }
/* This function is only called from the IGMP dissector */ int dissect_dvmrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset) { proto_tree *tree; proto_item *item; if (!proto_is_protocol_enabled(find_protocol_by_id(proto_dvmrp))) { /* we are not enabled, skip entire packet to be nice to the igmp layer. (so clicking on IGMP will display the data) */ return offset+tvb_length_remaining(tvb, offset); } item = proto_tree_add_item(parent_tree, proto_dvmrp, tvb, offset, -1, ENC_NA); tree = proto_item_add_subtree(item, ett_dvmrp); col_set_str(pinfo->cinfo, COL_PROTOCOL, "DVMRP"); col_clear(pinfo->cinfo, COL_INFO); if ((tvb_length_remaining(tvb, offset)>=8) && (((tvb_get_guint8(tvb, 6)==0xff) && (tvb_get_guint8(tvb, 7)==0x03)) || !strict_v3)) { offset = dissect_dvmrp_v3(tvb, pinfo, tree, offset); } else { offset = dissect_dvmrp_v1(tvb, pinfo, tree, offset); } proto_item_set_len(item, offset); return offset; }
void register_follow_stream(const int proto_id, const char* tap_listener, follow_conv_filter_func conv_filter, follow_index_filter_func index_filter, follow_address_filter_func address_filter, follow_port_to_display_func port_to_display, tap_packet_cb tap_handler) { register_follow_t *follower; DISSECTOR_ASSERT(tap_listener); DISSECTOR_ASSERT(conv_filter); DISSECTOR_ASSERT(index_filter); DISSECTOR_ASSERT(address_filter); DISSECTOR_ASSERT(port_to_display); DISSECTOR_ASSERT(tap_handler); follower = wmem_new(wmem_epan_scope(), register_follow_t); follower->proto_id = proto_id; follower->tap_listen_str = tap_listener; follower->conv_filter = conv_filter; follower->index_filter = index_filter; follower->address_filter = address_filter; follower->port_to_display = port_to_display; follower->tap_handler = tap_handler; if (registered_followers == NULL) registered_followers = wmem_tree_new(wmem_epan_scope()); wmem_tree_insert_string(registered_followers, proto_get_protocol_short_name(find_protocol_by_id(proto_id)), follower, 0); }
void register_service_response_tables(gpointer data, gpointer) { register_srt_t *srt = (register_srt_t*)data; const char* short_name = proto_get_protocol_short_name(find_protocol_by_id(get_srt_proto_id(srt))); const char *cfg_abbr = srt_table_get_tap_string(srt); tpdCreator tpd_creator = ServiceResponseTimeDialog::createSrtDialog; /* XXX - These dissectors haven't been converted over to due to an "interactive input dialog" for their tap data. Let those specific dialogs register for themselves */ if (strcmp(short_name, "DCERPC") == 0) { short_name = "DCE-RPC"; tpd_creator = RpcServiceResponseTimeDialog::createDceRpcSrtDialog; } else if (strcmp(short_name, "RPC") == 0) { short_name = "ONC-RPC"; tpd_creator = RpcServiceResponseTimeDialog::createOncRpcSrtDialog; } cfg_str_to_srt_[cfg_abbr] = srt; TapParameterDialog::registerDialog( short_name, cfg_abbr, REGISTER_STAT_GROUP_RESPONSE_TIME, srt_init, tpd_creator); }
ServiceResponseTimeDialog::ServiceResponseTimeDialog(QWidget &parent, CaptureFile &cf, register_srt *srt, const QString filter, int help_topic) : TapParameterDialog(parent, cf, help_topic), srt_(srt) { QString subtitle = QString("%1 Service Response Time Statistics") .arg(proto_get_protocol_short_name(find_protocol_by_id(get_srt_proto_id(srt)))); setWindowSubtitle(subtitle); // Add number of columns for this stats_tree QStringList header_labels; for (int col = 0; col < NUM_SRT_COLUMNS; col++) { header_labels.push_back(service_response_time_get_column_name(col)); } statsTreeWidget()->setColumnCount(header_labels.count()); statsTreeWidget()->setHeaderLabels(header_labels); for (int col = 0; col < statsTreeWidget()->columnCount(); col++) { if (col == SRT_COLUMN_PROCEDURE) continue; statsTreeWidget()->headerItem()->setTextAlignment(col, Qt::AlignRight); } QMenu *submenu; QAction *insert_action = ctx_menu_.actions().first(); FilterAction::Action cur_action = FilterAction::ActionApply; submenu = ctx_menu_.addMenu(FilterAction::actionName(cur_action)); foreach (FilterAction::ActionType at, FilterAction::actionTypes()) { FilterAction *fa = new FilterAction(submenu, cur_action, at); submenu->addAction(fa); connect(fa, SIGNAL(triggered()), this, SLOT(filterActionTriggered())); filter_actions_ << fa; }
ResponseTimeDelayDialog::ResponseTimeDelayDialog(QWidget &parent, CaptureFile &cf, register_rtd *rtd, const QString filter, int help_topic) : TapParameterDialog(parent, cf, help_topic), rtd_(rtd) { QString subtitle = tr("%1 Response Time Delay Statistics") .arg(proto_get_protocol_short_name(find_protocol_by_id(get_rtd_proto_id(rtd)))); setWindowSubtitle(subtitle); loadGeometry(0, 0, "ResponseTimeDelayDialog"); QStringList header_names = QStringList() << tr("Type") << tr("Messages") << tr("Min SRT") << tr("Max SRT") << tr("Avg SRT") << tr("Min in Frame") << tr("Max in Frame") << tr("Open Requests") << tr("Discarded Responses") << tr("Repeated Requests") << tr("Repeated Responses"); statsTreeWidget()->setHeaderLabels(header_names); for (int col = 0; col < statsTreeWidget()->columnCount(); col++) { if (col == col_type_) continue; statsTreeWidget()->headerItem()->setTextAlignment(col, Qt::AlignRight); } if (!filter.isEmpty()) { setDisplayFilter(filter); } }
static gint insert_sorted_by_table_name(gconstpointer aparam, gconstpointer bparam) { const register_ct_t *a = (register_ct_t *)aparam; const register_ct_t *b = (register_ct_t *)bparam; return g_ascii_strcasecmp(proto_get_protocol_short_name(find_protocol_by_id(a->proto_id)), proto_get_protocol_short_name(find_protocol_by_id(b->proto_id))); }
static gboolean proto_hier_tree_iter_next(GtkTreeModel *tree_model, GtkTreeIter *iter) { ProtoHierTreeModel *model; g_return_val_if_fail(PROTOHIER_IS_TREE(tree_model), FALSE); model = (ProtoHierTreeModel *) tree_model; g_return_val_if_fail(iter->stamp == model->stamp, FALSE); /* protocol */ if (iter->user_data2 == NULL) { void *cookie = iter->user_data; int proto_id; proto_id = proto_get_next_protocol(&cookie); /* get next enabled protocol */ while (proto_id != -1) { protocol_t *p = find_protocol_by_id(proto_id); if (proto_is_protocol_enabled(p)) break; proto_id = proto_get_next_protocol(&cookie); } if (proto_id == -1) return FALSE; iter->user_data = cookie; iter->user_data3 = proto_registrar_get_nth(proto_id); return TRUE; } /* field */ { void *cookie2 = iter->user_data2; header_field_info *hfinfo; hfinfo = proto_get_next_protocol_field(&cookie2); /* get next field */ while (hfinfo) { if (hfinfo->same_name_prev_id == -1) break; hfinfo = proto_get_next_protocol_field(&cookie2); } /* not found? */ if (!hfinfo) return FALSE; iter->user_data2 = cookie2; iter->user_data3 = hfinfo; return TRUE; } }
static capture_dissector_handle_t new_capture_dissector_handle(capture_dissector_t dissector, int proto, const char *name) { struct capture_dissector_handle* handle; handle = wmem_new(wmem_epan_scope(), struct capture_dissector_handle); handle->name = name; handle->dissector = dissector; handle->protocol = find_protocol_by_id(proto); return handle; }
// ui/gtk/filter_autocomplete.c:build_autocompletion_list void FieldFilterEdit::buildCompletionList(const QString &field_word) { // Push a hint about the current field. if (syntaxState() == Valid) { emit popFilterSyntaxStatus(); header_field_info *hfinfo = proto_registrar_get_byname(field_word.toUtf8().constData()); if (hfinfo) { QString cursor_field_msg = QString("%1: %2") .arg(hfinfo->name) .arg(ftype_pretty_name(hfinfo->type)); emit pushFilterSyntaxStatus(cursor_field_msg); } } if (field_word.length() < 1) { completion_model_->setStringList(QStringList()); return; } void *proto_cookie; QStringList field_list; int field_dots = field_word.count('.'); // Some protocol names (_ws.expert) contain periods. for (int proto_id = proto_get_first_protocol(&proto_cookie); proto_id != -1; proto_id = proto_get_next_protocol(&proto_cookie)) { protocol_t *protocol = find_protocol_by_id(proto_id); if (!proto_is_protocol_enabled(protocol)) continue; // Don't complete the current word. const QString pfname = proto_get_protocol_filter_name(proto_id); if (field_word.compare(pfname)) field_list << pfname; // Add fields only if we're past the protocol name and only for the // current protocol. if (field_dots > pfname.count('.')) { void *field_cookie; const QByteArray fw_ba = field_word.toUtf8(); // or toLatin1 or toStdString? const char *fw_utf8 = fw_ba.constData(); gsize fw_len = (gsize) strlen(fw_utf8); for (header_field_info *hfinfo = proto_get_first_protocol_field(proto_id, &field_cookie); hfinfo; hfinfo = proto_get_next_protocol_field(proto_id, &field_cookie)) { if (hfinfo->same_name_prev_id != -1) continue; // Ignore duplicate names. if (!g_ascii_strncasecmp(fw_utf8, hfinfo->abbrev, fw_len)) { if ((gsize) strlen(hfinfo->abbrev) != fw_len) field_list << hfinfo->abbrev; } } } } field_list.sort(); completion_model_->setStringList(field_list); completer()->setCompletionPrefix(field_word); }
expert_module_t *expert_register_protocol(int id) { expert_module_t *module; protocol_t *protocol; protocol = find_protocol_by_id(id); module = wmem_new(wmem_epan_scope(), expert_module_t); module->proto_id = id; module->proto_name = proto_get_protocol_short_name(protocol); return module; }
static char * hfinfo_to_name(const header_field_info *hfinfo) { if (hfinfo->parent == -1) { protocol_t *protocol = find_protocol_by_id(hfinfo->id); return g_strdup_printf("%s - %s", proto_get_protocol_short_name(protocol), proto_get_protocol_long_name(protocol)); } if (hfinfo->blurb != NULL && hfinfo->blurb[0] != '\0') return g_strdup_printf("%s - %s (%s)", hfinfo->abbrev, hfinfo->name, hfinfo->blurb); else return g_strdup_printf("%s - %s", hfinfo->abbrev, hfinfo->name); }
/* This function is only called from the IGMP dissector */ int dissect_msnip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset) { proto_tree *tree; proto_item *item; guint8 type; if (!proto_is_protocol_enabled(find_protocol_by_id(proto_msnip))) { /* we are not enabled, skip entire packet to be nice to the igmp layer. (so clicking on IGMP will display the data) */ return offset+tvb_length_remaining(tvb, offset); } item = proto_tree_add_item(parent_tree, proto_msnip, tvb, offset, -1, FALSE); tree = proto_item_add_subtree(item, ett_msnip); col_set_str(pinfo->cinfo, COL_PROTOCOL, "MSNIP"); col_clear(pinfo->cinfo, COL_INFO); type = tvb_get_guint8(tvb, offset); if (check_col(pinfo->cinfo, COL_INFO)) { col_add_str(pinfo->cinfo, COL_INFO, val_to_str(type, msnip_types, "Unknown Type:0x%02x")); } /* type of command */ proto_tree_add_uint(tree, hf_type, tvb, offset, 1, type); offset += 1; switch (type) { case MSNIP_GM: offset = dissect_msnip_gm(tvb, pinfo, tree, offset); break; case MSNIP_IS: offset = dissect_msnip_is(tvb, pinfo, tree, offset); break; case MSNIP_RMR: offset = dissect_msnip_rmr(tvb, pinfo, tree, offset); break; } if (item) { proto_item_set_len(item, offset); } return offset; }
static GtkTreePath * proto_hier_tree_get_path(GtkTreeModel *tree_model, GtkTreeIter *iter) { ProtoHierTreeModel *model; GtkTreePath *path; int pos; int p_id; void *cookie; g_return_val_if_fail(PROTOHIER_IS_TREE(tree_model), NULL); model = (ProtoHierTreeModel *) tree_model; g_return_val_if_fail(iter != NULL, NULL); g_return_val_if_fail(iter->stamp == model->stamp, FALSE); p_id = proto_get_data_protocol(iter->user_data); path = gtk_tree_path_new(); /* protocol */ { int id; /* XXX, assuming that protocols can't be disabled! */ pos = 0; for (id = proto_get_first_protocol(&cookie); id != p_id && id != -1; id = proto_get_next_protocol(&cookie)) { protocol_t *p = find_protocol_by_id(id); if (!proto_is_protocol_enabled(p)) continue; pos++; } gtk_tree_path_append_index(path, pos); } /* field */ if (iter->user_data2 != NULL) { header_field_info *hfinfo; pos = 0; for (hfinfo = proto_get_first_protocol_field(p_id, &cookie); hfinfo && hfinfo != iter->user_data3; hfinfo = proto_get_next_protocol_field(&cookie)) { if (hfinfo->same_name_prev_id != -1) continue; pos++; } gtk_tree_path_append_index(path, pos); } return path; }
void register_response_time_delay_tables(gpointer data, gpointer) { register_rtd_t *rtd = (register_rtd_t*)data; const char* short_name = proto_get_protocol_short_name(find_protocol_by_id(get_rtd_proto_id(rtd))); const char *cfg_abbr = rtd_table_get_tap_string(rtd); cfg_str_to_rtd_[cfg_abbr] = rtd; TapParameterDialog::registerDialog( short_name, cfg_abbr, REGISTER_STAT_GROUP_RESPONSE_TIME, rtd_init, ResponseTimeDelayDialog::createRtdDialog); }
// Nearly identical to SupportedProtocolsDialog::fillTree. void DisplayFilterExpressionDialog::fillTree() { void *proto_cookie; QList <QTreeWidgetItem *> proto_list; for (int proto_id = proto_get_first_protocol(&proto_cookie); proto_id != -1; proto_id = proto_get_next_protocol(&proto_cookie)) { protocol_t *protocol = find_protocol_by_id(proto_id); if (!proto_is_protocol_enabled(protocol)) continue; QTreeWidgetItem *proto_ti = new QTreeWidgetItem(proto_type_); QString label = QString("%1 " UTF8_MIDDLE_DOT " %3") .arg(proto_get_protocol_short_name(protocol)) .arg(proto_get_protocol_long_name(protocol)); proto_ti->setText(0, label); proto_ti->setData(0, Qt::UserRole, QVariant::fromValue(proto_id)); proto_list << proto_ti; } wsApp->processEvents(QEventLoop::ExcludeUserInputEvents | QEventLoop::ExcludeSocketNotifiers, 1); ui->fieldTreeWidget->invisibleRootItem()->addChildren(proto_list); ui->fieldTreeWidget->sortByColumn(0, Qt::AscendingOrder); int field_count = 0; foreach (QTreeWidgetItem *proto_ti, proto_list) { void *field_cookie; int proto_id = proto_ti->data(0, Qt::UserRole).toInt(); QList <QTreeWidgetItem *> field_list; for (header_field_info *hfinfo = proto_get_first_protocol_field(proto_id, &field_cookie); hfinfo != NULL; hfinfo = proto_get_next_protocol_field(proto_id, &field_cookie)) { if (hfinfo->same_name_prev_id != -1) continue; // Ignore duplicate names. QTreeWidgetItem *field_ti = new QTreeWidgetItem(field_type_); QString label = QString("%1 " UTF8_MIDDLE_DOT " %3").arg(hfinfo->abbrev).arg(hfinfo->name); field_ti->setText(0, label); field_ti->setData(0, Qt::UserRole, VariantPointer<header_field_info>::asQVariant(hfinfo)); field_list << field_ti; field_count++; if (field_count % 10000 == 0) { wsApp->processEvents(QEventLoop::ExcludeUserInputEvents | QEventLoop::ExcludeSocketNotifiers, 1); } } std::sort(field_list.begin(), field_list.end()); proto_ti->addChildren(field_list); }
void ProtocolPreferencesMenu::setModule(const char *module_name) { QAction *action; int proto_id = -1; if (module_name) { proto_id = proto_get_id_by_filter_name(module_name); } clear(); module_name_.clear(); module_ = NULL; protocol_ = find_protocol_by_id(proto_id); const QString long_name = proto_get_protocol_long_name(protocol_); const QString short_name = proto_get_protocol_short_name(protocol_); if (!module_name || proto_id < 0 || !protocol_) { action = addAction(tr("No protocol preferences available")); action->setDisabled(true); return; } QAction *disable_action = new QAction(tr("Disable %1" UTF8_HORIZONTAL_ELLIPSIS).arg(short_name), this); connect(disable_action, SIGNAL(triggered(bool)), this, SLOT(disableProtocolTriggered())); module_ = prefs_find_module(module_name); if (!module_ || !prefs_is_registered_protocol(module_name)) { action = addAction(tr("%1 has no preferences").arg(long_name)); action->setDisabled(true); addSeparator(); addAction(disable_action); return; } module_name_ = module_name; action = addAction(tr("Open %1 preferences" UTF8_HORIZONTAL_ELLIPSIS).arg(long_name)); action->setData(QString(module_name)); connect(action, SIGNAL(triggered(bool)), this, SLOT(modulePreferencesTriggered())); addSeparator(); prefs_pref_foreach(module_, add_prefs_menu_item, this); if (!actions().last()->isSeparator()) { addSeparator(); } addAction(disable_action); }
void gssapi_init_oid(const char *oid, int proto, int ett, dissector_handle_t handle, dissector_handle_t wrap_handle, const gchar *comment) { char *key = g_strdup(oid); gssapi_oid_value *value = (gssapi_oid_value *)g_malloc(sizeof(*value)); value->proto = find_protocol_by_id(proto); value->ett = ett; value->handle = handle; value->wrap_handle = wrap_handle; value->comment = comment; g_hash_table_insert(gssapi_oids, key, value); register_ber_oid_dissector_handle(key, handle, proto, comment); }
gboolean register_response_time_delay_tables(const void *, void *value, void*) { register_rtd_t *rtd = (register_rtd_t*)value; const char* short_name = proto_get_protocol_short_name(find_protocol_by_id(get_rtd_proto_id(rtd))); char *cfg_abbr = rtd_table_get_tap_string(rtd); cfg_str_to_rtd_[cfg_abbr] = rtd; TapParameterDialog::registerDialog( short_name, cfg_abbr, REGISTER_STAT_GROUP_RESPONSE_TIME, rtd_init, ResponseTimeDelayDialog::createRtdDialog); g_free(cfg_abbr); return FALSE; }
void proto_disable_proto_by_name(const char *name) { protocol_t *protocol; int proto_id; proto_id = proto_get_id_by_filter_name(name); if (proto_id >= 0 ) { protocol = find_protocol_by_id(proto_id); if (proto_is_protocol_enabled(protocol) == TRUE) { if (proto_can_toggle_protocol(proto_id) == TRUE) { proto_set_decoding(proto_id, FALSE); } } } }
/* This function is only called from the IGMP dissector */ int dissect_mrdisc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset) { proto_tree *tree; proto_item *item; guint8 type; if (!proto_is_protocol_enabled(find_protocol_by_id(proto_mrdisc))) { /* we are not enabled, skip entire packet to be nice to the igmp layer. (so clicking on IGMP will display the data) */ return offset+tvb_length_remaining(tvb, offset); } item = proto_tree_add_item(parent_tree, proto_mrdisc, tvb, offset, 0, ENC_NA); tree = proto_item_add_subtree(item, ett_mrdisc); col_set_str(pinfo->cinfo, COL_PROTOCOL, "MRDISC"); col_clear(pinfo->cinfo, COL_INFO); type = tvb_get_guint8(tvb, offset); if (check_col(pinfo->cinfo, COL_INFO)) { col_add_str(pinfo->cinfo, COL_INFO, val_to_str(type, mrdisc_types, "Unknown Type:0x%02x")); } /* type of command */ proto_tree_add_uint(tree, hf_type, tvb, offset, 1, type); offset += 1; switch (type) { case MRDISC_MRA: offset = dissect_mrdisc_mra(tvb, pinfo, tree, offset); break; case MRDISC_MRS: case MRDISC_MRT: /* MRS and MRT packets looks the same */ offset = dissect_mrdisc_mrst(tvb, pinfo, tree, offset); break; } return offset; }
static gint proto_hier_tree_iter_n_children(GtkTreeModel *tree_model, GtkTreeIter *iter) { ProtoHierTreeModel *model; gint count = 0; int p_id; void *cookie; g_return_val_if_fail(PROTOHIER_IS_TREE(tree_model), 0); model = (ProtoHierTreeModel *) tree_model; g_return_val_if_fail(iter == NULL || iter->user_data != NULL, 0); if (iter) { header_field_info *hfinfo; g_return_val_if_fail(iter->stamp == model->stamp, 0); /* field has no child */ if (iter->user_data2 != NULL) return 0; p_id = proto_get_data_protocol(iter->user_data); /* count not-duplicated fields */ for (hfinfo = proto_get_first_protocol_field(p_id, &cookie); hfinfo; hfinfo = proto_get_next_protocol_field(&cookie)) { if (hfinfo->same_name_prev_id != -1) continue; count++; } } else { /* count enabled protocols */ for (p_id = proto_get_first_protocol(&cookie); p_id != -1; p_id = proto_get_next_protocol(&cookie)) { protocol_t *p = find_protocol_by_id(p_id); if (!proto_is_protocol_enabled(p)) continue; count++; } } return count; }
static void decode_proto_add_to_list (const gchar *table_name, gpointer value, gpointer user_data) { struct decode_as_default_populate* populate = (struct decode_as_default_populate*)user_data; const gchar *proto_name; gint i; dissector_handle_t handle; handle = (dissector_handle_t)value; proto_name = dissector_handle_get_short_name(handle); i = dissector_handle_get_protocol_index(handle); if (i >= 0 && !proto_is_protocol_enabled(find_protocol_by_id(i))) return; populate->add_to_list(table_name, proto_name, value, populate->ui_element); }
EnabledProtocolsDialog::EnabledProtocolsDialog(QWidget *parent) : GeometryStateDialog(parent), ui(new Ui::EnabledProtocolsDialog) { ui->setupUi(this); loadGeometry(); setWindowTitle(wsApp->windowTitleString(tr("Enabled Protocols"))); void *cookie; protocol_t *protocol; //Remove "original" item ui->protocol_tree_->takeTopLevelItem(0); // Iterate over all the protocols for (gint i = proto_get_first_protocol(&cookie); i != -1; i = proto_get_next_protocol(&cookie)) { if (proto_can_toggle_protocol(i)) { protocol = find_protocol_by_id(i); ProtocolTreeWidgetItem* protocol_row = new ProtocolTreeWidgetItem(ui->protocol_tree_->invisibleRootItem(), protocol); proto_heuristic_dissector_foreach(protocol, addHeuristicItem, protocol_row); } } ui->protocol_tree_->expandAll(); //make sortable ui->protocol_tree_->setSortingEnabled(true); ui->protocol_tree_->sortByColumn(PROTOCOL_COLUMN, Qt::AscendingOrder); // Some protocols have excessively long names. Instead of calling // resizeColumnToContents, pick a reasonable-ish em width and apply it. int one_em = ui->protocol_tree_->fontMetrics().height(); ui->protocol_tree_->setColumnWidth(PROTOCOL_COLUMN, one_em * 18); //"Remove" Save button if (!prefs.gui_use_pref_save) ui->buttonBox->button(QDialogButtonBox::Save)->setHidden(true); }
void SupportedProtocolsDialog::fillTree() { void *proto_cookie; QList <QTreeWidgetItem *> proto_list; for (int proto_id = proto_get_first_protocol(&proto_cookie); proto_id != -1; proto_id = proto_get_next_protocol(&proto_cookie)) { protocol_t *protocol = find_protocol_by_id(proto_id); QTreeWidgetItem *proto_ti = new QTreeWidgetItem(); proto_ti->setText(name_col_, proto_get_protocol_short_name(protocol)); proto_ti->setText(filter_col_, proto_get_protocol_filter_name(proto_id)); // type_col_ empty proto_ti->setText(descr_col_, proto_get_protocol_long_name(protocol)); proto_ti->setData(name_col_, Qt::UserRole, proto_id); proto_list << proto_ti; } updateStatistics(); ui->protoTreeWidget->invisibleRootItem()->addChildren(proto_list); ui->protoTreeWidget->sortByColumn(name_col_, Qt::AscendingOrder); foreach (QTreeWidgetItem *proto_ti, proto_list) { void *field_cookie; int proto_id = proto_ti->data(name_col_, Qt::UserRole).toInt(); QList <QTreeWidgetItem *> field_list; for (header_field_info *hfinfo = proto_get_first_protocol_field(proto_id, &field_cookie); hfinfo != NULL; hfinfo = proto_get_next_protocol_field(proto_id, &field_cookie)) { if (hfinfo->same_name_prev_id != -1) continue; QTreeWidgetItem *field_ti = new QTreeWidgetItem(); field_ti->setText(name_col_, hfinfo->name); field_ti->setText(filter_col_, hfinfo->abbrev); field_ti->setText(type_col_, ftype_pretty_name(hfinfo->type)); field_ti->setText(descr_col_, hfinfo->blurb); field_list << field_ti; field_count_++; if (field_count_ % 1000 == 0) updateStatistics(); } std::sort(field_list.begin(), field_list.end()); proto_ti->addChildren(field_list); }
void init_iousers(struct register_ct *ct, const char *filter) { io_users_t *iu; GString *error_string; iu = g_new0(io_users_t, 1); iu->type = proto_get_protocol_short_name(find_protocol_by_id(get_conversation_proto_id(ct))); iu->filter = g_strdup(filter); iu->hash.user_data = iu; error_string = register_tap_listener(proto_get_protocol_filter_name(get_conversation_proto_id(ct)), &iu->hash, filter, 0, NULL, get_conversation_packet_func(ct), iousers_draw); if (error_string) { g_free(iu); fprintf(stderr, "tshark: Couldn't register conversations tap: %s\n", error_string->str); g_string_free(error_string, TRUE); exit(1); } }
ResponseTimeDelayDialog::ResponseTimeDelayDialog(QWidget &parent, CaptureFile &cf, register_rtd *rtd, const QString filter, int help_topic) : TapParameterDialog(parent, cf, help_topic), rtd_(rtd) { QString subtitle = QString("%1 Response Time Delay Statistics") .arg(proto_get_protocol_short_name(find_protocol_by_id(get_rtd_proto_id(rtd)))); setWindowSubtitle(subtitle); statsTreeWidget()->setHeaderLabels(header_names_); for (int col = 0; col < statsTreeWidget()->columnCount(); col++) { if (col == col_type_) continue; statsTreeWidget()->headerItem()->setTextAlignment(col, Qt::AlignRight); } setDisplayFilter(filter); if (!filter.isEmpty()) { setDisplayFilter(filter); } }
static void init_srt_tables(register_srt_t* srt, const char *filter) { srt_t *ui; GString *error_string; ui = g_new0(srt_t, 1); ui->type = proto_get_protocol_short_name(find_protocol_by_id(get_srt_proto_id(srt))); ui->filter = g_strdup(filter); ui->data.srt_array = global_srt_array; ui->data.user_data = ui; error_string = register_tap_listener(get_srt_tap_listener_name(srt), &ui->data, filter, 0, NULL, get_srt_packet_func(srt), srt_draw, NULL); if (error_string) { free_srt_table(srt, global_srt_array); g_free(ui); cmdarg_err("Couldn't register srt tap: %s", error_string->str); g_string_free(error_string, TRUE); exit(1); } }
/* This function is only called from the IGMP dissector */ int dissect_rgmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset) { proto_tree *tree; proto_item *item; guint8 type; if (!proto_is_protocol_enabled(find_protocol_by_id(proto_rgmp))) { /* we are not enabled, skip entire packet to be nice to the igmp layer. (so clicking on IGMP will display the data) */ return offset + tvb_length_remaining(tvb, offset); } item = proto_tree_add_item(parent_tree, proto_rgmp, tvb, offset, -1, ENC_NA); tree = proto_item_add_subtree(item, ett_rgmp); col_set_str(pinfo->cinfo, COL_PROTOCOL, "RGMP"); col_clear(pinfo->cinfo, COL_INFO); type = tvb_get_guint8(tvb, offset); if (check_col(pinfo->cinfo, COL_INFO)) { col_add_str(pinfo->cinfo, COL_INFO, val_to_str(type, rgmp_types, "Unknown Type: 0x%02x")); } proto_tree_add_uint(tree, hf_type, tvb, offset, 1, type); offset += 1; /* reserved */ offset += 1; igmp_checksum(tree, tvb, hf_checksum, hf_checksum_bad, pinfo, 0); offset += 2; proto_tree_add_item(tree, hf_maddr, tvb, offset, 4, ENC_BIG_ENDIAN); offset += 4; return offset; }
static void init_rtd_tables(register_rtd_t* rtd, const char *filter) { GString *error_string; rtd_t* ui; ui = g_new0(rtd_t, 1); ui->type = proto_get_protocol_short_name(find_protocol_by_id(get_rtd_proto_id(rtd))); ui->filter = g_strdup(filter); ui->vs_type = get_rtd_value_string(rtd); ui->rtd.user_data = ui; rtd_table_dissector_init(rtd, &ui->rtd.stat_table, NULL, NULL); error_string = register_tap_listener(get_rtd_tap_listener_name(rtd), &ui->rtd, filter, 0, NULL, get_rtd_packet_func(rtd), rtd_draw); if (error_string) { free_rtd_table(&ui->rtd.stat_table, NULL, NULL); fprintf(stderr, "tshark: Couldn't register srt tap: %s\n", error_string->str); g_string_free(error_string, TRUE); exit(1); } }