void proto_reg_handoff_gsm_ipa(void) { static gboolean ipa_initialized = FALSE; static range_t *ipa_tcp_ports, *ipa_udp_ports; if (!ipa_initialized) { sub_handles[SUB_RSL] = find_dissector("gsm_abis_rsl"); sub_handles[SUB_OML] = find_dissector("gsm_abis_oml"); sub_handles[SUB_SCCP] = find_dissector("sccp"); sub_handles[SUB_MGCP] = find_dissector("mgcp"); sub_handles[SUB_DATA] = find_dissector("data"); ipa_handle = create_dissector_handle(dissect_ipa, proto_ipa); ipa_initialized = TRUE; } else { range_foreach(ipa_tcp_ports, ipa_tcp_delete_callback); g_free(ipa_tcp_ports); range_foreach(ipa_udp_ports, ipa_udp_delete_callback); g_free(ipa_udp_ports); } ipa_tcp_ports = range_copy(global_ipa_tcp_ports); ipa_udp_ports = range_copy(global_ipa_udp_ports); range_foreach(ipa_tcp_ports, ipa_tcp_add_callback); range_foreach(ipa_udp_ports, ipa_udp_add_callback); }
static void nasdaq_soup_prefs(void) { range_foreach(nasdaq_soup_tcp_range, range_delete_nasdaq_soup_tcp_callback); g_free(nasdaq_soup_tcp_range); nasdaq_soup_tcp_range = range_copy(global_nasdaq_soup_tcp_range); range_foreach(nasdaq_soup_tcp_range, range_add_nasdaq_soup_tcp_callback); }
void proto_reg_handoff_inap(void) { static gboolean inap_prefs_initialized = FALSE; static range_t *ssn_range; if (!inap_prefs_initialized) { inap_prefs_initialized = TRUE; inap_handle = find_dissector("inap"); data_handle = find_dissector("data"); oid_add_from_string("Core-INAP-CS1-Codes","0.4.0.1.1.0.3.0"); oid_add_from_string("iso(1) identified-organization(3) icd-ecma(12) member-company(2) 1107 oen(3) inap(3) extensions(2)","1.3.12.2.1107.3.3.2"); oid_add_from_string("alcatel(1006)","1.3.12.2.1006.64"); oid_add_from_string("Siemens (1107)","1.3.12.2.1107"); oid_add_from_string("iso(1) member-body(2) gb(826) national(0) ericsson(1249) inDomain(51) inNetwork(1) inNetworkcapabilitySet1plus(1) ","1.2.826.0.1249.51.1.1"); } else { range_foreach(ssn_range, range_delete_callback); g_free(ssn_range); } ssn_range = range_copy(global_ssn_range); range_foreach(ssn_range, range_add_callback); }
/* Register the protocol with Wireshark */ static void nasdaq_soup_prefs(void) { dissector_delete_uint_range("tcp.port", nasdaq_soup_tcp_range, nasdaq_soup_handle); g_free(nasdaq_soup_tcp_range); nasdaq_soup_tcp_range = range_copy(global_nasdaq_soup_tcp_range); dissector_add_uint_range("tcp.port", nasdaq_soup_tcp_range, nasdaq_soup_handle); }
static void gopher_prefs_apply(void) { range_foreach(gopher_tcp_range, range_delete_gopher_tcp_callback); g_free(gopher_tcp_range); gopher_tcp_range = range_copy(global_gopher_tcp_range); range_foreach(gopher_tcp_range, range_add_gopher_tcp_callback); }
static void *uat_plen_record_copy_cb(void *n, const void *o, size_t siz _U_) { const uat_plen_record_t *r = (const uat_plen_record_t *)o; uat_plen_record_t *rn = (uat_plen_record_t *)n; if (r->packet_range) rn->packet_range = range_copy(r->packet_range); return n; }
static void init_tcap(void) { if (ssn_range) { range_foreach(ssn_range, range_delete_callback); g_free(ssn_range); } ssn_range = range_copy(global_ssn_range); range_foreach(ssn_range, range_add_callback); tcapsrt_init_routine(); }
static int dom_filter_ranges( dom *d, range_array *ranges ) { // first range must be root range *root = range_array_get(ranges,0); if ( root != NULL ) { if ( !queue_push(d->q,root) ) return 0; else { d->ranges = range_array_create(); if ( d->ranges != NULL ) { int i,num_ranges = range_array_size( ranges ); for ( i=1;i<num_ranges;i++ ) { range *r = range_array_get( ranges, i ); char *r_name = range_name( r ); hashset *pruned = matrix_get_lookup(d->pm); if ( hashset_contains(pruned,r_name) ) { css_rule *rule = hashmap_get( d->css_rules,r_name ); char *html_name = css_rule_get_element(rule); if ( range_html_name(r) != NULL|| range_set_html_name(r,html_name) ) { // this should duplicate the range range *r_dup = range_copy( r ); if ( r_dup == NULL || !dom_store_range(d,r_dup) ) { warning("dom: failed to push onto queue\n"); return 0; } } else { warning("dom: couldn't set html name for %s\n", r_name); return 0; } } } } return 1; } } else return 0; }
guint pref_stash(pref_t *pref, gpointer unused _U_) { switch (pref->type) { case PREF_DECODE_AS_UINT: pref->stashed_val.uint = *pref->varp.uint; break; case PREF_UINT: pref->stashed_val.uint = *pref->varp.uint; break; case PREF_BOOL: pref->stashed_val.boolval = *pref->varp.boolp; break; case PREF_ENUM: pref->stashed_val.enumval = *pref->varp.enump; break; case PREF_STRING: case PREF_FILENAME: case PREF_DIRNAME: g_free(pref->stashed_val.string); pref->stashed_val.string = g_strdup(*pref->varp.string); break; case PREF_DECODE_AS_RANGE: case PREF_RANGE: g_free(pref->stashed_val.range); pref->stashed_val.range = range_copy(*pref->varp.range); break; case PREF_COLOR: pref->stashed_val.color = *pref->varp.colorp; break; case PREF_STATIC_TEXT: case PREF_UAT: case PREF_CUSTOM: break; case PREF_OBSOLETE: g_assert_not_reached(); break; } return 0; }
void reset_stashed_pref(pref_t *pref) { switch (pref->type) { case PREF_DECODE_AS_UINT: pref->stashed_val.uint = pref->default_val.uint; break; case PREF_UINT: pref->stashed_val.uint = pref->default_val.uint; break; case PREF_BOOL: pref->stashed_val.boolval = pref->default_val.boolval; break; case PREF_ENUM: pref->stashed_val.enumval = pref->default_val.enumval; break; case PREF_STRING: case PREF_FILENAME: case PREF_DIRNAME: g_free(pref->stashed_val.string); pref->stashed_val.string = g_strdup(pref->default_val.string); break; case PREF_DECODE_AS_RANGE: case PREF_RANGE: g_free(pref->stashed_val.range); pref->stashed_val.range = range_copy(pref->default_val.range); break; case PREF_COLOR: memcpy(&pref->stashed_val.color, &pref->default_val.color, sizeof(color_t)); break; case PREF_STATIC_TEXT: case PREF_UAT: case PREF_CUSTOM: break; case PREF_OBSOLETE: g_assert_not_reached(); break; } }
/*--- proto_reg_handoff_pcap ---------------------------------------*/ void proto_reg_handoff_pcap(void) { static gboolean prefs_initialized = FALSE; static range_t *ssn_range; if (! prefs_initialized) { pcap_handle = find_dissector("pcap"); sccp_ssn_table = find_dissector_table("sccp.ssn"); prefs_initialized = TRUE; #include "packet-pcap-dis-tab.c" } else { dissector_delete_uint_range("sccp.ssn", ssn_range, pcap_handle); g_free(ssn_range); } ssn_range = range_copy(global_ssn_range); dissector_add_uint_range("sccp.ssn", ssn_range, pcap_handle); }
void proto_reg_handoff_kt(void) { static gboolean Initialized = FALSE; static range_t *kt_tcp_port_range; if (!Initialized) { kt_handle = find_dissector("kt"); Initialized = TRUE; } else { dissector_delete_uint_range("tcp.port", kt_tcp_port_range, kt_handle); g_free(kt_tcp_port_range); } kt_tcp_port_range = range_copy(global_kt_tcp_port_range); dissector_add_uint_range("tcp.port", kt_tcp_port_range, kt_handle); }
void proto_reg_handoff_nsip(void) { static gboolean nsip_prefs_initialized = FALSE; static range_t *nsip_udp_port_range; if (!nsip_prefs_initialized) { nsip_handle = find_dissector("gprs_ns"); bssgp_handle = find_dissector("bssgp"); nsip_prefs_initialized = TRUE; } else { dissector_delete_uint_range("udp.port", nsip_udp_port_range, nsip_handle); g_free(nsip_udp_port_range); } nsip_udp_port_range = range_copy(global_nsip_udp_port_range); dissector_add_uint_range("udp.port", nsip_udp_port_range, nsip_handle); }
void proto_reg_handoff_nsip(void) { static gboolean nsip_prefs_initialized = FALSE; static range_t *nsip_udp_port_range; if (!nsip_prefs_initialized) { nsip_handle = find_dissector("gprs_ns"); bssgp_handle = find_dissector("bssgp"); nsip_prefs_initialized = TRUE; } else { range_foreach(nsip_udp_port_range, range_delete_callback); g_free(nsip_udp_port_range); } nsip_udp_port_range = range_copy(global_nsip_udp_port_range); range_foreach(nsip_udp_port_range, range_add_callback); }
void PreferenceEditorFrame::on_okButton_clicked() { bool apply = false; switch(pref_->type) { case PREF_UINT: if (pref_->stashed_val.uint != new_uint_) { pref_->stashed_val.uint = new_uint_; apply = true; } break; case PREF_STRING: if (new_str_.compare(pref_->stashed_val.string) != 0) { g_free(pref_->stashed_val.string); pref_->stashed_val.string = qstring_strdup(new_str_); apply = true; } break; case PREF_RANGE: if (!ranges_are_equal(pref_->stashed_val.range, new_range_)) { g_free(pref_->stashed_val.range); pref_->stashed_val.range = range_copy(new_range_); apply = true; } break; default: break; } if (apply && module_) { pref_unstash(pref_, &module_->prefs_changed); prefs_apply(module_); if (!prefs.gui_use_pref_save) { prefs_main_write(); } } on_cancelButton_clicked(); // Emit signals once UI is hidden if (apply) { wsApp->emitAppSignal(WiresharkApplication::PacketDissectionChanged); wsApp->emitAppSignal(WiresharkApplication::PreferencesChanged); } }
void proto_reg_handoff_inap(void) { static gboolean inap_prefs_initialized = FALSE; static range_t *ssn_range; if (!inap_prefs_initialized) { inap_prefs_initialized = TRUE; inap_handle = find_dissector("inap"); oid_add_from_string("Core-INAP-CS1-Codes","0.4.0.1.1.0.3.0"); } else { range_foreach(ssn_range, range_delete_callback); g_free(ssn_range); } ssn_range = range_copy(global_ssn_range); range_foreach(ssn_range, range_add_callback); }
void PreferenceEditorFrame::editPreference(preference *pref, pref_module *module) { pref_ = pref; module_ = module; if (!pref || !module) { hide(); return; } ui->modulePreferencesToolButton->setText(tr("Open %1 preferences").arg(module_->title)); pref_stash(pref_, NULL); ui->preferenceTitleLabel->setText(pref->title); // Convert the pref description from plain text to rich text. QString description; #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) description = Qt::escape(pref->description); #else description = QString(pref->description).toHtmlEscaped(); #endif description.replace('\n', "<br>"); QString tooltip = QString("<span>%1</span>").arg(description); ui->preferenceTitleLabel->setToolTip(tooltip); ui->preferenceLineEdit->setToolTip(tooltip); ui->preferenceLineEdit->clear(); ui->preferenceLineEdit->setSyntaxState(SyntaxLineEdit::Empty); disconnect(ui->preferenceLineEdit); bool show = false; switch (pref_->type) { case PREF_UINT: new_uint_ = pref->stashed_val.uint; connect(ui->preferenceLineEdit, SIGNAL(textEdited(QString)), this, SLOT(uintLineEditTextEdited(QString))); show = true; break; case PREF_STRING: new_str_ = pref->stashed_val.string; connect(ui->preferenceLineEdit, SIGNAL(textEdited(QString)), this, SLOT(stringLineEditTextEdited(QString))); show = true; break; case PREF_RANGE: g_free(new_range_); new_range_ = range_copy(pref->stashed_val.range); connect(ui->preferenceLineEdit, SIGNAL(textEdited(QString)), this, SLOT(rangeLineEditTextEdited(QString))); show = true; break; default: break; } if (show) { ui->preferenceLineEdit->setText(gchar_free_to_qstring(prefs_pref_to_str(pref_, pref_stashed)).remove(QRegExp("\n\t"))); animatedShow(); } }
guint pref_unstash(pref_t *pref, gpointer changed_p) { gboolean *pref_changed_p = (gboolean *)changed_p; /* Revert the preference to its saved value. */ switch (pref->type) { case PREF_UINT: if (*pref->varp.uint != pref->stashed_val.uint) { *pref_changed_p = TRUE; *pref->varp.uint = pref->stashed_val.uint; } break; case PREF_BOOL: if (*pref->varp.boolp != pref->stashed_val.boolval) { *pref_changed_p = TRUE; *pref->varp.boolp = pref->stashed_val.boolval; } break; case PREF_ENUM: if (*pref->varp.enump != pref->stashed_val.enumval) { *pref_changed_p = TRUE; *pref->varp.enump = pref->stashed_val.enumval; } break; case PREF_STRING: case PREF_FILENAME: case PREF_DIRNAME: if (strcmp(*pref->varp.string, pref->stashed_val.string) != 0) { *pref_changed_p = TRUE; g_free((void *)*pref->varp.string); *pref->varp.string = g_strdup(pref->stashed_val.string); } break; case PREF_RANGE: if (!ranges_are_equal(*pref->varp.range, pref->stashed_val.range)) { *pref_changed_p = TRUE; g_free(*pref->varp.range); *pref->varp.range = range_copy(pref->stashed_val.range); } break; case PREF_COLOR: *pref->varp.colorp = pref->stashed_val.color; break; case PREF_STATIC_TEXT: case PREF_UAT: case PREF_CUSTOM: break; case PREF_OBSOLETE: g_assert_not_reached(); break; } return 0; }
guint pref_unstash(pref_t *pref, gpointer unstash_data_p) { pref_unstash_data_t *unstash_data = (pref_unstash_data_t *)unstash_data_p; dissector_table_t sub_dissectors = NULL; dissector_handle_t handle = NULL; /* Revert the preference to its saved value. */ switch (pref->type) { case PREF_DECODE_AS_UINT: if (*pref->varp.uint != pref->stashed_val.uint) { unstash_data->module->prefs_changed = TRUE; if (unstash_data->handle_decode_as) { if (*pref->varp.uint != pref->default_val.uint) { dissector_reset_uint(pref->name, *pref->varp.uint); } } *pref->varp.uint = pref->stashed_val.uint; if (unstash_data->handle_decode_as) { sub_dissectors = find_dissector_table(pref->name); if (sub_dissectors != NULL) { handle = dissector_table_get_dissector_handle(sub_dissectors, (gchar*)unstash_data->module->title); if (handle != NULL) { dissector_change_uint(pref->name, *pref->varp.uint, handle); } } } } break; case PREF_UINT: if (*pref->varp.uint != pref->stashed_val.uint) { unstash_data->module->prefs_changed = TRUE; *pref->varp.uint = pref->stashed_val.uint; } break; case PREF_BOOL: if (*pref->varp.boolp != pref->stashed_val.boolval) { unstash_data->module->prefs_changed = TRUE; *pref->varp.boolp = pref->stashed_val.boolval; } break; case PREF_ENUM: if (*pref->varp.enump != pref->stashed_val.enumval) { unstash_data->module->prefs_changed = TRUE; *pref->varp.enump = pref->stashed_val.enumval; } break; case PREF_STRING: case PREF_FILENAME: case PREF_DIRNAME: if (strcmp(*pref->varp.string, pref->stashed_val.string) != 0) { unstash_data->module->prefs_changed = TRUE; g_free(*pref->varp.string); *pref->varp.string = g_strdup(pref->stashed_val.string); } break; case PREF_DECODE_AS_RANGE: if (!ranges_are_equal(*pref->varp.range, pref->stashed_val.range)) { guint32 i, j; unstash_data->module->prefs_changed = TRUE; if (unstash_data->handle_decode_as) { sub_dissectors = find_dissector_table(pref->name); if (sub_dissectors != NULL) { handle = dissector_table_get_dissector_handle(sub_dissectors, (gchar*)unstash_data->module->title); if (handle != NULL) { /* Delete all of the old values from the dissector table */ for (i = 0; i < (*pref->varp.range)->nranges; i++) { for (j = (*pref->varp.range)->ranges[i].low; j < (*pref->varp.range)->ranges[i].high; j++) { dissector_delete_uint(pref->name, j, handle); decode_build_reset_list(pref->name, dissector_table_get_type(sub_dissectors), GUINT_TO_POINTER(j), NULL, NULL); } dissector_delete_uint(pref->name, (*pref->varp.range)->ranges[i].high, handle); decode_build_reset_list(pref->name, dissector_table_get_type(sub_dissectors), GUINT_TO_POINTER((*pref->varp.range)->ranges[i].high), NULL, NULL); } } } } g_free(*pref->varp.range); *pref->varp.range = range_copy(pref->stashed_val.range); if (unstash_data->handle_decode_as) { if ((sub_dissectors != NULL) && (handle != NULL)) { /* Add new values to the dissector table */ for (i = 0; i < (*pref->varp.range)->nranges; i++) { for (j = (*pref->varp.range)->ranges[i].low; j < (*pref->varp.range)->ranges[i].high; j++) { dissector_change_uint(pref->name, j, handle); decode_build_reset_list(pref->name, dissector_table_get_type(sub_dissectors), GUINT_TO_POINTER(j), NULL, NULL); } dissector_change_uint(pref->name, (*pref->varp.range)->ranges[i].high, handle); decode_build_reset_list(pref->name, dissector_table_get_type(sub_dissectors), GUINT_TO_POINTER((*pref->varp.range)->ranges[i].high), NULL, NULL); } } } } break; case PREF_RANGE: if (!ranges_are_equal(*pref->varp.range, pref->stashed_val.range)) { unstash_data->module->prefs_changed = TRUE; g_free(*pref->varp.range); *pref->varp.range = range_copy(pref->stashed_val.range); } break; case PREF_COLOR: *pref->varp.colorp = pref->stashed_val.color; break; case PREF_STATIC_TEXT: case PREF_UAT: case PREF_CUSTOM: break; case PREF_OBSOLETE: g_assert_not_reached(); break; } return 0; }