From c1d447fc88cb64a6f8db11eff87f910a15b963bd Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Mon, 4 Jan 2016 13:29:45 -0800 Subject: Remove unneeded "#if 0"ed out code. If we ever need to look at the value of any field in the packet, we should do it the way we do in the RTP analysis code, rather than walking the entire protocol tree. Get rid of an unnecessary extra level of indirection for the filter string. Change-Id: Ie95c0171da79e7f24019a3f67396f6a533959881 Reviewed-on: https://code.wireshark.org/review/13046 Reviewed-by: Guy Harris --- ui/gtk/iax2_analysis.c | 90 +++------------------------------------ ui/qt/iax2_analysis_dialog.cpp | 95 +++++------------------------------------- 2 files changed, 16 insertions(+), 169 deletions(-) diff --git a/ui/gtk/iax2_analysis.c b/ui/gtk/iax2_analysis.c index c783112910..b1ffd3c00f 100644 --- a/ui/gtk/iax2_analysis.c +++ b/ui/gtk/iax2_analysis.c @@ -3398,81 +3398,6 @@ create_iax2_dialog(user_data_t* user_data) gtk_widget_grab_focus(list_fwd); } -#if 0 -/****************************************************************************/ -static gboolean -process_node(proto_node *ptree_node, header_field_info *hfinformation, - const gchar* proto_field, guint32* p_result) -{ - field_info *finfo; - proto_node *proto_sibling_node; - header_field_info *hfssrc; - ipv4_addr *ipv4; - - finfo = PNODE_FINFO(ptree_node); - - if (hfinformation == (finfo->hfinfo)) { - hfssrc = proto_registrar_get_byname(proto_field); - if (hfssrc == NULL) { - simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, - "Bad field name."); - return FALSE; - } - for (ptree_node = ptree_node->first_child; - ptree_node != NULL; - ptree_node = ptree_node->next) { - finfo = PNODE_FINFO(ptree_node); - if (hfssrc == finfo->hfinfo) { - if (hfinformation->type == FT_IPv4) { - ipv4 = fvalue_get(&finfo->value); - *p_result = ipv4_get_net_order_addr(ipv4); - } - else { - *p_result = fvalue_get_uinteger(&finfo->value); - } - return TRUE; - } - } - if (!ptree_node) - return FALSE; - } - - proto_sibling_node = ptree_node->next; - - if (proto_sibling_node) { - return process_node(proto_sibling_node, hfinformation, proto_field, p_result); - } - else - return FALSE; -} - -/****************************************************************************/ -static gboolean -get_int_value_from_proto_tree(proto_tree *protocol_tree, - const gchar* proto_name, - const gchar* proto_field, - guint32* p_result) -{ - proto_node *ptree_node; - header_field_info *hfinformation; - - hfinformation = proto_registrar_get_byname(proto_name); - if (hfinformation == NULL) { - simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, - "Bad proto."); - return FALSE; - } - - ptree_node = ((proto_node *)protocol_tree)->first_child; - if (!ptree_node) { - simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, - "No info."); - return FALSE; - } - return process_node(ptree_node, hfinformation, proto_field, p_result); -} -#endif - /****************************************************************************/ static void iax2_analysis( @@ -3600,7 +3525,12 @@ void iax2_analysis_cb(GtkAction *action _U_, gpointer user_data _U_) guint16 port_dst_rev; /* unsigned int ptype; */ - const gchar *filter_text = "iax2 && (ip || ipv6)"; +#if 0 + /* Only accept Voice or MiniPacket packets */ + const gchar filter_text[] = "iax2.call && (ip || ipv6)"; +#else + const gchar filter_text[] = "iax2 && (ip || ipv6)"; +#endif dfilter_t *sfcode; gchar *err_msg; capture_file *cf; @@ -3640,14 +3570,6 @@ void iax2_analysis_cb(GtkAction *action _U_, gpointer user_data _U_) "Please select an IAX2 packet."); return; } -#if 0 - /* check if it is Voice or MiniPacket */ - if (!get_int_value_from_proto_tree(edt->tree, "iax2", "iax2.call", &ptype)) { - simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, - "Please select a Voice packet."); - return; - } -#endif /* ok, it is a IAX2 frame, so let's get the ip and port values */ copy_address(&(ip_src_fwd), &(edt.pi.src)); diff --git a/ui/qt/iax2_analysis_dialog.cpp b/ui/qt/iax2_analysis_dialog.cpp index c37b48bee7..b8cb240a1f 100644 --- a/ui/qt/iax2_analysis_dialog.cpp +++ b/ui/qt/iax2_analysis_dialog.cpp @@ -297,14 +297,21 @@ Iax2AnalysisDialog::Iax2AnalysisDialog(QWidget &parent, CaptureFile &cf) : save_menu->addAction(ui->actionSaveGraph); ui->buttonBox->button(QDialogButtonBox::Save)->setMenu(save_menu); - const gchar *filter_text = "iax2 && (ip || ipv6)"; +#if 0 + /* Only accept Voice or MiniPacket packets */ + const gchar filter_text[] = "iax2.call && (ip || ipv6)"; +#else + const gchar filter_text[] = "iax2 && (ip || ipv6)"; +#endif dfilter_t *sfcode; gchar *err_msg; + /* Try to compile the filter. */ if (!dfilter_compile(filter_text, &sfcode, &err_msg)) { - QMessageBox::warning(this, tr("No IAX2 packets found"), QString("%1").arg(err_msg)); + err_str_ = QString(err_msg); g_free(err_msg); - close(); + updateWidgets(); + return; } if (!cap_file_.capFile() || !cap_file_.capFile()->current_frame) close(); @@ -343,17 +350,6 @@ Iax2AnalysisDialog::Iax2AnalysisDialog(QWidget &parent, CaptureFile &cf) : port_src_rev_ = edt.pi.destport; port_dst_rev_ = edt.pi.srcport; -#if 0 - /* check if it is Voice or MiniPacket */ - bool ok; - getIntFromProtoTree(edt.tree, "iax2", "iax2.call", &ok); - if (!ok) { - err_str_ = tr("Please select an IAX2 packet."); - updateWidgets(); - return; - } -#endif - #ifdef IAX2_RTP_STREAM_CHECK rtpstream_tapinfot tapinfo; @@ -1207,77 +1203,6 @@ void Iax2AnalysisDialog::saveCsv(Iax2AnalysisDialog::StreamDirection direction) } } -#if 0 -// Adapted from iax2_analysis.c:process_node -guint32 Iax2AnalysisDialog::processNode(proto_node *ptree_node, header_field_info *hfinformation, const gchar *proto_field, bool *ok) -{ - field_info *finfo; - proto_node *proto_sibling_node; - header_field_info *hfssrc; - ipv4_addr *ipv4; - - finfo = PNODE_FINFO(ptree_node); - - /* Caller passed top of the protocol tree. Expected child node */ - g_assert(finfo); - - if (hfinformation == (finfo->hfinfo)) { - hfssrc = proto_registrar_get_byname(proto_field); - if (hfssrc == NULL) { - return 0; - } - for (ptree_node = ptree_node->first_child; - ptree_node != NULL; - ptree_node = ptree_node->next) { - finfo = PNODE_FINFO(ptree_node); - if (hfssrc == finfo->hfinfo) { - guint32 result; - if (hfinformation->type == FT_IPv4) { - ipv4 = (ipv4_addr *)fvalue_get(&finfo->value); - result = ipv4_get_net_order_addr(ipv4); - } else { - result = fvalue_get_uinteger(&finfo->value); - } - if (ok) *ok = true; - return result; - } - } - if (!ptree_node) { - return 0; - } - } - - proto_sibling_node = ptree_node->next; - - if (proto_sibling_node) { - return processNode(proto_sibling_node, hfinformation, proto_field, ok); - } else { - return 0; - } -} - -// Adapted from iax2_analysis.c:get_int_value_from_proto_tree -guint32 Iax2AnalysisDialog::getIntFromProtoTree(proto_tree *protocol_tree, const gchar *proto_name, const gchar *proto_field, bool *ok) -{ - proto_node *ptree_node; - header_field_info *hfinformation; - - if (ok) *ok = false; - - hfinformation = proto_registrar_get_byname(proto_name); - if (hfinformation == NULL) { - return 0; - } - - ptree_node = ((proto_node *)protocol_tree)->first_child; - if (!ptree_node) { - return 0; - } - - return processNode(ptree_node, hfinformation, proto_field, ok); -} -#endif - bool Iax2AnalysisDialog::eventFilter(QObject *, QEvent *event) { if (event->type() != QEvent::KeyPress) return false; -- cgit v1.2.3