forked from osmocom/wireshark
Add the ability to dynamically add a new protocol to export PDU dialog box
Change-Id: I83012cc963d514982e40010e837e11a6fcf1bc3e Reviewed-on: https://code.wireshark.org/review/2423 Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
parent
5a6366c9b5
commit
bcff3c57cc
|
@ -6144,6 +6144,8 @@ proto_register_dvbci(void)
|
|||
/* the dissector for decrypted CI+ SAC messages which we can export */
|
||||
new_register_dissector(EXPORTED_SAC_MSG_PROTO,
|
||||
dissect_dvbci_exported_sac_msg, proto_dvbci);
|
||||
|
||||
exported_pdu_tap = register_export_pdu_tap("DVB-CI");
|
||||
}
|
||||
|
||||
|
||||
|
@ -6162,8 +6164,6 @@ proto_reg_handoff_dvbci(void)
|
|||
tcp_dissector_table = find_dissector_table("tcp.port");
|
||||
udp_dissector_table = find_dissector_table("udp.port");
|
||||
|
||||
exported_pdu_tap = find_tap_id(EXPORT_PDU_TAP_NAME_DVB_CI);
|
||||
|
||||
if (dvbci_sek_bin) {
|
||||
g_free(dvbci_sek_bin);
|
||||
dvbci_sek_bin = NULL;
|
||||
|
|
|
@ -345,10 +345,8 @@ proto_register_exported_pdu(void)
|
|||
* The tap is registered here but it is to be used by dissectors that
|
||||
* want to export their PDUs, see packet-sip.c
|
||||
*/
|
||||
register_tap(EXPORT_PDU_TAP_NAME_LAYER_3);
|
||||
register_tap(EXPORT_PDU_TAP_NAME_LAYER_7);
|
||||
register_tap(EXPORT_PDU_TAP_NAME_DVB_CI);
|
||||
register_tap(EXPORT_PDU_TAP_NAME_LOGCAT);
|
||||
register_export_pdu_tap(EXPORT_PDU_TAP_NAME_LAYER_3);
|
||||
register_export_pdu_tap(EXPORT_PDU_TAP_NAME_LAYER_7);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -277,6 +277,8 @@ proto_register_logcat(void)
|
|||
|
||||
expert_module = expert_register_protocol(proto_logcat);
|
||||
expert_register_field_array(expert_module, ei, array_length(ei));
|
||||
|
||||
exported_pdu_tap = register_export_pdu_tap("Logcat");
|
||||
}
|
||||
|
||||
|
||||
|
@ -286,8 +288,6 @@ proto_reg_handoff_logcat(void)
|
|||
dissector_add_uint("wtap_encap", WTAP_ENCAP_LOGCAT, logcat_handle);
|
||||
|
||||
dissector_add_handle("tcp.port", logcat_handle);
|
||||
|
||||
exported_pdu_tap = find_tap_id(EXPORT_PDU_TAP_NAME_LOGCAT);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -27,9 +27,12 @@
|
|||
|
||||
#include <epan/packet.h>
|
||||
#include <epan/exported_pdu.h>
|
||||
#include <epan/tap.h>
|
||||
#include <epan/dissectors/packet-mtp3.h>
|
||||
#include <epan/dissectors/packet-dvbci.h>
|
||||
|
||||
GSList *export_pdu_tap_name_list = NULL;
|
||||
|
||||
/**
|
||||
* Allocates and fills the exp_pdu_data_t struct according to the wanted_exp_tags
|
||||
* bit field of wanted_exp_tags_len bytes length
|
||||
|
@ -332,3 +335,24 @@ load_export_pdu_tags(packet_info *pinfo, const char* proto_name, int wtap_encap
|
|||
|
||||
return exp_pdu_data;
|
||||
}
|
||||
|
||||
gint
|
||||
register_export_pdu_tap(const char *name)
|
||||
{
|
||||
gchar *tap_name = g_strdup(name);
|
||||
export_pdu_tap_name_list = g_slist_prepend(export_pdu_tap_name_list, tap_name);
|
||||
return register_tap(tap_name);
|
||||
}
|
||||
|
||||
static
|
||||
gint sort_pdu_tap_name_list(gconstpointer a, gconstpointer b)
|
||||
{
|
||||
return g_strcmp0((const char *)a, (const char*)b);
|
||||
}
|
||||
|
||||
GSList *
|
||||
get_export_pdu_tap_list(void)
|
||||
{
|
||||
export_pdu_tap_name_list = g_slist_sort(export_pdu_tap_name_list, sort_pdu_tap_name_list);
|
||||
return export_pdu_tap_name_list;
|
||||
}
|
||||
|
|
|
@ -27,20 +27,26 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include "ws_symbol_export.h"
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*
|
||||
* Define different common tap names to extract PDUs at different layers,
|
||||
* otherwise one packet may be exported several times at different layers
|
||||
* if all taps are run.
|
||||
* NOTE if a new tap is added here it needs to be added to export_pdu_dlg.c
|
||||
* and packet-exported_pdu.c
|
||||
* TODO: Use an enum_val_t instead?
|
||||
*/
|
||||
#define EXPORT_PDU_TAP_NAME_LAYER_3 "OSI layer 3"
|
||||
#define EXPORT_PDU_TAP_NAME_LAYER_7 "OSI layer 7"
|
||||
#define EXPORT_PDU_TAP_NAME_DVB_CI "DVB-CI"
|
||||
#define EXPORT_PDU_TAP_NAME_LOGCAT "Logcat"
|
||||
|
||||
/* To add dynamically an export name, call the following function
|
||||
It returns the registered tap */
|
||||
WS_DLL_PUBLIC gint register_export_pdu_tap(const char *name);
|
||||
WS_DLL_PUBLIC GSList *get_export_pdu_tap_list(void);
|
||||
|
||||
/**
|
||||
* This struct is used as the data part of tap_queue_packet() and contains a
|
||||
|
@ -151,5 +157,8 @@ typedef struct _exp_pdu_data_t {
|
|||
WS_DLL_PUBLIC exp_pdu_data_t *load_export_pdu_tags(packet_info *pinfo, const char* proto_name,
|
||||
int wtap_encap, guint8 *wanted_exp_tags, guint16 wanted_exp_tags_len);
|
||||
|
||||
#endif /* EXPORTED_PDU_H */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* EXPORTED_PDU_H */
|
||||
|
|
|
@ -86,6 +86,7 @@ export_pdu_show_cb(GtkWidget *w _U_, gpointer d _U_)
|
|||
exp_pdu_dlg_t *exp_pdu_dlg_data;
|
||||
const char *filter = NULL;
|
||||
guint row;
|
||||
GSList *tap_name_list;
|
||||
|
||||
static construct_args_t args = {
|
||||
"Wireshark: Export PDUs Filter",
|
||||
|
@ -146,10 +147,9 @@ export_pdu_show_cb(GtkWidget *w _U_, gpointer d _U_)
|
|||
/* Select which tap to run */
|
||||
/* Combo box */
|
||||
exp_pdu_dlg_data->tap_name_widget = gtk_combo_box_text_new();
|
||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(exp_pdu_dlg_data->tap_name_widget), EXPORT_PDU_TAP_NAME_LAYER_7);
|
||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(exp_pdu_dlg_data->tap_name_widget), EXPORT_PDU_TAP_NAME_LAYER_3);
|
||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(exp_pdu_dlg_data->tap_name_widget), EXPORT_PDU_TAP_NAME_DVB_CI);
|
||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(exp_pdu_dlg_data->tap_name_widget), EXPORT_PDU_TAP_NAME_LOGCAT);
|
||||
for (tap_name_list = get_export_pdu_tap_list(); tap_name_list; tap_name_list = g_slist_next(tap_name_list)) {
|
||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(exp_pdu_dlg_data->tap_name_widget), (const char*)(tap_name_list->data));
|
||||
}
|
||||
gtk_combo_box_set_active(GTK_COMBO_BOX(exp_pdu_dlg_data->tap_name_widget), 0);
|
||||
|
||||
ws_gtk_grid_attach_defaults(GTK_GRID(grid), exp_pdu_dlg_data->tap_name_widget, 0, row, 1, 1);
|
||||
|
|
|
@ -36,12 +36,13 @@ ExportPDUDialog::ExportPDUDialog(QWidget *parent) :
|
|||
QDialog(parent),
|
||||
ui(new Ui::ExportPDUDialog)
|
||||
{
|
||||
GSList *tap_name_list;
|
||||
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->comboBox->addItem(EXPORT_PDU_TAP_NAME_LAYER_7);
|
||||
ui->comboBox->addItem(EXPORT_PDU_TAP_NAME_LAYER_3);
|
||||
ui->comboBox->addItem(EXPORT_PDU_TAP_NAME_DVB_CI);
|
||||
ui->comboBox->addItem(EXPORT_PDU_TAP_NAME_LOGCAT);
|
||||
for (tap_name_list = get_export_pdu_tap_list(); tap_name_list; tap_name_list = g_slist_next(tap_name_list)) {
|
||||
ui->comboBox->addItem((const char*)(tap_name_list->data));
|
||||
}
|
||||
}
|
||||
void ExportPDUDialog::on_buttonBox_accepted()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue