UATs could be put into "categories". The categories were defined only

implicitly by the #define name and string they were defined to; not all
UATs neatly fit into any of the categories, so some of them were put
into categories that weren't obviously correct for them, and one - the
display filter macro UAT - wasn't put into any category at all (which
caused crashes when editing them, as the GUI code that handled UAT
changes from a dialog assumed the category field was non-null).

The category was, in practice, used only to decide, in the
aforementioned GUI code, whether the packet summary pane needed to be
updated or not.  It also offered no option of "don't update the packet
summary pane *and* don't redissect anything", which is what would be
appropriate for the display filter macro UAT.

Replace the category with a set of fields indicating what the UAT
affects; we currently offer "dissection", which applies to most UATs
(any UAT in libwireshark presumably affects dissection at a minimum) and
"the set of named fields that exist".  Changing any UAT that affects
dissection requires a redissection; changing any UAT that affects the
set of named fields that exist requires a redissection *and* rebuilding
the packet summary pane.

Perhaps we also need "filtering", so that if you change a display filter
macro, we re-filter, in case the display is currently filtered with a
display filter that uses a macro that changed.

svn path=/trunk/; revision=43603
This commit is contained in:
Guy Harris 2012-07-08 01:00:46 +00:00
parent 1b1fbd24e7
commit 659cf0527a
36 changed files with 140 additions and 109 deletions

View File

@ -1314,7 +1314,7 @@ void proto_register_c1222(void) {
TRUE, /* from_profile */
(void*)&c1222_uat_data, /* data_ptr */
&num_c1222_uat_data, /* numitems_ptr */
UAT_CAT_CRYPTO, /* category */
UAT_AFFECTS_DISSECTION, /* affects dissection of packets, but not set of named fields */
NULL, /* help */
NULL, /* copy callback */
c1222_uat_data_update_cb, /* update callback */

View File

@ -173,7 +173,7 @@ void proto_register_ess(void) {
TRUE,
(void*) &ess_category_attributes,
&num_ess_category_attributes,
UAT_CAT_PORTS,
UAT_AFFECTS_DISSECTION, /* affects dissection of packets, but not set of named fields */
"ChEssCategoryAttributes",
ess_copy_cb,
NULL,

View File

@ -2283,7 +2283,9 @@ void proto_register_ldap(void) {
TRUE,
(void*) &attribute_types,
&num_attribute_types,
UAT_CAT_FIELDS,
/* specifies named fields, so affects dissection
and the set of named fields */
UAT_AFFECTS_DISSECTION|UAT_AFFECTS_FIELDS,
NULL,
attribute_types_copy_cb,
attribute_types_update_cb,

View File

@ -417,7 +417,7 @@ void proto_register_pres(void) {
TRUE,
(void*) &pres_users,
&num_pres_users,
UAT_CAT_PORTS,
UAT_AFFECTS_DISSECTION, /* affects dissection of packets, but not set of named fields */
"ChPresContextList",
pres_copy_cb,
NULL,

View File

@ -2236,7 +2236,7 @@ void proto_register_snmp(void) {
TRUE,
(void*)&ueas,
&num_ueas,
UAT_CAT_CRYPTO,
UAT_AFFECTS_DISSECTION, /* affects dissection of packets, but not set of named fields */
"ChSNMPUsersSection",
snmp_users_copy_cb,
snmp_users_update_cb,
@ -2257,7 +2257,7 @@ void proto_register_snmp(void) {
TRUE,
(void*) &specific_traps,
&num_specific_traps,
UAT_CAT_GENERAL,
UAT_AFFECTS_DISSECTION, /* affects dissection of packets, but not set of named fields */
"ChSNMPEnterpriseSpecificTrapTypes",
snmp_specific_trap_copy_cb,
NULL,

View File

@ -615,7 +615,7 @@ void dfilter_macro_init(void) {
TRUE,
(void*) &macros,
&num_macros,
NULL,
0, /* doesn't affect anything that requires a GUI update */
"ChDisplayFilterMacrosSection",
macro_copy,
macro_update,

View File

@ -4937,7 +4937,7 @@ proto_register_ber(void)
FALSE,
(void*) &oid_users,
&num_oid_users,
UAT_CAT_GENERAL,
UAT_AFFECTS_DISSECTION, /* affects dissection of packets, but not set of named fields */
"ChObjectIdentifiers",
oid_copy_cb,
NULL,

View File

@ -6440,7 +6440,7 @@ proto_register_bootp(void)
TRUE, /* from_profile */
(void*) &uat_bootp_records, /* data_ptr */
&num_bootp_records_uat, /* numitems_ptr */
UAT_CAT_GENERAL, /* category */
UAT_AFFECTS_DISSECTION, /* affects dissection of packets, but not set of named fields */
NULL, /* help */
uat_bootp_record_copy_cb, /* copy callback */
uat_bootp_record_update_cb, /* update callback */

View File

@ -1887,7 +1887,7 @@ void proto_register_c1222(void) {
TRUE, /* from_profile */
(void*)&c1222_uat_data, /* data_ptr */
&num_c1222_uat_data, /* numitems_ptr */
UAT_CAT_CRYPTO, /* category */
UAT_AFFECTS_DISSECTION, /* affects dissection of packets, but not set of named fields */
NULL, /* help */
NULL, /* copy callback */
c1222_uat_data_update_cb, /* update callback */

View File

@ -4975,7 +4975,7 @@ void proto_register_dmp (void)
TRUE,
(void*) &dmp_security_classes,
&num_dmp_security_classes,
UAT_CAT_FFMT,
UAT_AFFECTS_DISSECTION, /* affects dissection of packets, but not set of named fields */
"ChDMPSecurityClassifications",
dmp_class_copy_cb,
NULL,

View File

@ -2695,7 +2695,7 @@ proto_register_dtls(void)
TRUE, /* from_profile */
(void*) &dtlskeylist_uats, /* data_ptr */
&ndtlsdecrypt, /* numitems_ptr */
UAT_CAT_FFMT, /* category */
UAT_AFFECTS_DISSECTION, /* affects dissection of packets, but not set of named fields */
"ChK12ProtocolsSection", /* TODO, need revision - help */
dtlsdecrypt_copy_cb,
NULL, /* dtlsdecrypt_update_cb? */

View File

@ -1482,7 +1482,7 @@ void proto_register_ess(void) {
TRUE,
(void*) &ess_category_attributes,
&num_ess_category_attributes,
UAT_CAT_PORTS,
UAT_AFFECTS_DISSECTION, /* affects dissection of packets, but not set of named fields */
"ChEssCategoryAttributes",
ess_copy_cb,
NULL,

View File

@ -2783,7 +2783,9 @@ proto_register_http(void)
TRUE,
(void*) &header_fields,
&num_header_fields,
UAT_CAT_FIELDS,
/* specifies named fields, so affects dissection
and the set of named fields */
UAT_AFFECTS_DISSECTION|UAT_AFFECTS_FIELDS,
NULL,
header_fields_copy_cb,
header_fields_update_cb,

View File

@ -16574,7 +16574,7 @@ proto_register_ieee80211 (void)
TRUE, /* from_profile */
(void*) &uat_wep_key_records, /* data_ptr */
&num_wepkeys_uat, /* numitems_ptr */
UAT_CAT_CRYPTO, /* category */
UAT_AFFECTS_DISSECTION, /* affects dissection of packets, but not set of named fields */
NULL, /* help */
uat_wep_key_record_copy_cb, /* copy callback */
uat_wep_key_record_update_cb, /* update callback */

View File

@ -2726,7 +2726,7 @@ void proto_register_ieee802154(void)
TRUE, /* from_profile */
(void*) &static_addrs, /* data_ptr */
&num_static_addrs, /* numitems_ptr */
UAT_CAT_GENERAL, /* category */
UAT_AFFECTS_DISSECTION, /* affects dissection of packets, but not set of named fields */
NULL, /* help */
NULL, /* copy callback */
addr_uat_update_cb, /* update callback */

View File

@ -1216,7 +1216,9 @@ proto_register_imf(void)
TRUE,
(void*) &header_fields,
&num_header_fields,
UAT_CAT_FIELDS,
/* specifies named fields, so affects dissection
and the set of named fields */
UAT_AFFECTS_DISSECTION|UAT_AFFECTS_FIELDS,
NULL,
header_fields_copy_cb,
header_fields_update_cb,

View File

@ -2112,25 +2112,25 @@ proto_register_ipsec(void)
"Attempt to Check ESP Authentication based on the SAD described hereafter.",
&g_esp_enable_authentication_check);
esp_uat = uat_new("ESP SAs",
sizeof(uat_esp_sa_record_t), /* record size */
"esp_sa", /* filename */
TRUE, /* from_profile */
(void*) &uat_esp_sa_records, /* data_ptr */
&num_sa_uat, /* numitems_ptr */
UAT_CAT_CRYPTO, /* category */
NULL, /* help */
esp_uat = uat_new("ESP SAs",
sizeof(uat_esp_sa_record_t), /* record size */
"esp_sa", /* filename */
TRUE, /* from_profile */
(void*) &uat_esp_sa_records, /* data_ptr */
&num_sa_uat, /* numitems_ptr */
UAT_AFFECTS_DISSECTION, /* affects dissection of packets, but not set of named fields */
NULL, /* help */
uat_esp_sa_record_copy_cb, /* copy callback */
NULL, /* update callback */
NULL, /* update callback */
uat_esp_sa_record_free_cb, /* free callback */
NULL, /* post update callback */
esp_uat_flds); /* UAT field definitions */
NULL, /* post update callback */
esp_uat_flds); /* UAT field definitions */
prefs_register_uat_preference(esp_module,
"sa_table",
"ESP SAs",
"Preconfigured ESP Security Associations",
esp_uat);
prefs_register_uat_preference(esp_module,
"sa_table",
"ESP SAs",
"Preconfigured ESP Security Associations",
esp_uat);
#endif

View File

@ -6104,7 +6104,7 @@ proto_register_isakmp(void)
TRUE,
(void*)&ikev1_uat_data,
&num_ikev1_uat_data,
UAT_CAT_CRYPTO,
UAT_AFFECTS_DISSECTION, /* affects dissection of packets, but not set of named fields */
"ChIKEv1DecryptionSection",
NULL,
ikev1_uat_data_update_cb,
@ -6124,7 +6124,7 @@ proto_register_isakmp(void)
TRUE,
(void*)&ikev2_uat_data,
&num_ikev2_uat_data,
UAT_CAT_CRYPTO,
UAT_AFFECTS_DISSECTION, /* affects dissection of packets, but not set of named fields */
"ChIKEv2DecryptionSection",
NULL,
ikev2_uat_data_update_cb,

View File

@ -455,9 +455,9 @@ proto_register_k12(void)
sizeof(k12_handles_t),
"k12_protos", /* filename */
TRUE, /* from_profile */
(void*) &k12_handles, /* data_ptr */
(void*) &k12_handles, /* data_ptr */
&nk12_handles, /* numitems_ptr */
UAT_CAT_FFMT, /* category */
UAT_AFFECTS_DISSECTION, /* affects dissection of packets, but not set of named fields */
"ChK12ProtocolsSection", /* help */
k12_copy_cb,
k12_update_cb,

View File

@ -5889,7 +5889,9 @@ void proto_register_ldap(void) {
TRUE,
(void*) &attribute_types,
&num_attribute_types,
UAT_CAT_FIELDS,
/* specifies named fields, so affects dissection
and the set of named fields */
UAT_AFFECTS_DISSECTION|UAT_AFFECTS_FIELDS,
NULL,
attribute_types_copy_cb,
attribute_types_update_cb,
@ -6004,7 +6006,7 @@ proto_reg_handoff_ldap(void)
/*--- End of included file: packet-ldap-dis-tab.c ---*/
#line 2385 "../../asn1/ldap/packet-ldap-template.c"
#line 2387 "../../asn1/ldap/packet-ldap-template.c"
}

View File

@ -5692,7 +5692,7 @@ void proto_register_mac_lte(void)
TRUE,
(void*) &lcid_drb_mappings,
&num_lcid_drb_mappings,
UAT_CAT_FFMT,
UAT_AFFECTS_DISSECTION, /* affects dissection of packets, but not set of named fields */
"", /* TODO: is this ref to help manual? */
lcid_drb_mapping_copy_cb,
NULL,

View File

@ -1928,7 +1928,7 @@ void proto_register_pres(void) {
TRUE,
(void*) &pres_users,
&num_pres_users,
UAT_CAT_PORTS,
UAT_AFFECTS_DISSECTION, /* affects dissection of packets, but not set of named fields */
"ChPresContextList",
pres_copy_cb,
NULL,

View File

@ -5886,11 +5886,11 @@ proto_register_reload(void)
reloadkindids_uat =
uat_new("Kind-ID Table",
sizeof(kind_t),
"reload_kindids", /* filename */
"reload_kindids", /* filename */
TRUE, /* from_profile */
(void*) &kindidlist_uats, /* data_ptr */
&nreloadkinds, /* numitems_ptr */
UAT_CAT_GENERAL, /* category */
&nreloadkinds, /* numitems_ptr */
UAT_AFFECTS_DISSECTION, /* affects dissection of packets, but not set of named fields */
NULL, /* Help section (currently a wiki page) */
uat_kindid_copy_cb,
NULL,

View File

@ -4002,9 +4002,10 @@ proto_register_sccp(void)
uat_t *users_uat = uat_new("SCCP Users Table", sizeof(sccp_user_t),
"sccp_users", TRUE, (void*) &sccp_users,
&num_sccp_users, UAT_CAT_PORTS, "ChSccpUsers",
sccp_users_copy_cb, sccp_users_update_cb,
sccp_users_free_cb, NULL, users_flds );
&num_sccp_users, UAT_AFFECTS_DISSECTION,
"ChSccpUsers", sccp_users_copy_cb,
sccp_users_update_cb, sccp_users_free_cb,
NULL, users_flds );
/* Register the protocol name and description */
proto_sccp = proto_register_protocol("Signalling Connection Control Part",

View File

@ -3749,7 +3749,7 @@ void proto_register_snmp(void) {
TRUE,
(void*)&ueas,
&num_ueas,
UAT_CAT_CRYPTO,
UAT_AFFECTS_DISSECTION, /* affects dissection of packets, but not set of named fields */
"ChSNMPUsersSection",
snmp_users_copy_cb,
snmp_users_update_cb,
@ -3770,7 +3770,7 @@ void proto_register_snmp(void) {
TRUE,
(void*) &specific_traps,
&num_specific_traps,
UAT_CAT_GENERAL,
UAT_AFFECTS_DISSECTION, /* affects dissection of packets, but not set of named fields */
"ChSNMPEnterpriseSpecificTrapTypes",
snmp_specific_trap_copy_cb,
NULL,

View File

@ -5683,7 +5683,7 @@ proto_register_ssl(void)
TRUE, /* from_profile */
(void*) &sslkeylist_uats, /* data_ptr */
&nssldecrypt, /* numitems_ptr */
UAT_CAT_FFMT, /* category */
UAT_AFFECTS_DISSECTION, /* affects dissection of packets, but not set of named fields */
NULL, /* Help section (currently a wiki page) */
ssldecrypt_copy_cb,
ssldecrypt_update_cb,

View File

@ -223,12 +223,12 @@ void proto_register_user_encap(void)
TRUE,
(void*) &encaps,
&num_encaps,
UAT_CAT_FFMT,
UAT_AFFECTS_DISSECTION, /* affects dissection of packets, but not set of named fields */
"ChUserDLTsSection",
user_copy_cb,
NULL,
user_free_cb,
NULL,
NULL,
user_flds );
prefs_register_uat_preference(module,

View File

@ -616,7 +616,7 @@ proto_register_vcdu(void)
TRUE,
(void*)&uat_bitchannels,
&num_channels_uat,
UAT_CAT_GENERAL,
UAT_AFFECTS_DISSECTION, /* affects dissection of packets, but not set of named fields */
NULL,
NULL,
vcdu_uat_data_update_cb,

View File

@ -274,7 +274,7 @@ void zbee_security_register(module_t *zbee_prefs, int proto)
TRUE,
(void*) &uat_key_records,
&num_uat_key_records,
UAT_CAT_FFMT,
UAT_AFFECTS_DISSECTION, /* affects dissection of packets, but not set of named fields */
NULL, /* TODO: ptr to help manual? */
uat_key_record_copy_cb,
uat_key_record_update_cb,

View File

@ -154,12 +154,14 @@ geoip_db_pref_init(module_t *nameres)
FALSE,
(void*)&geoip_db_paths,
&num_geoip_db_paths,
UAT_CAT_GENERAL,
/* affects dissection of packets (as the GeoIP database is
used when dissecting), but not set of named fields */
UAT_AFFECTS_DISSECTION,
"ChGeoIPDbPaths",
geoip_db_path_copy_cb,
NULL,
geoip_db_path_free_cb,
NULL,
NULL,
geoip_db_paths_fields);
prefs_register_uat_preference(nameres,

View File

@ -740,47 +740,61 @@ void oid_pref_init(module_t *nameres)
"Some errors can be ignored. If unsure, set to false.",
&suppress_smi_errors);
smi_paths_uat = uat_new("SMI Paths",
sizeof(smi_module_t),
"smi_paths",
FALSE,
(void*)&smi_paths,
&num_smi_paths,
UAT_CAT_GENERAL,
"ChSNMPSMIPaths",
smi_mod_copy_cb,
NULL,
smi_mod_free_cb,
restart_needed_warning,
smi_paths_fields);
smi_paths_uat = uat_new("SMI Paths",
sizeof(smi_module_t),
"smi_paths",
FALSE,
(void*)&smi_paths,
&num_smi_paths,
/* affects dissection of packets (as the MIBs and PIBs affect the
interpretation of e.g. SNMP variable bindings), but not set of
named fields
prefs_register_uat_preference(nameres,
"smi_paths",
"SMI (MIB and PIB) paths",
"Search paths for SMI (MIB and PIB) modules. You must\n"
"restart Wireshark for these changes to take effect.",
smi_paths_uat);
XXX - if named fields are generated from the MIBs and PIBs
for particular variable bindings, this *does* affect the set
of named fields! */
UAT_AFFECTS_DISSECTION,
"ChSNMPSMIPaths",
smi_mod_copy_cb,
NULL,
smi_mod_free_cb,
restart_needed_warning,
smi_paths_fields);
smi_modules_uat = uat_new("SMI Modules",
sizeof(smi_module_t),
"smi_modules",
FALSE,
(void*)&smi_modules,
&num_smi_modules,
UAT_CAT_GENERAL,
"ChSNMPSMIModules",
smi_mod_copy_cb,
NULL,
smi_mod_free_cb,
restart_needed_warning,
smi_fields);
prefs_register_uat_preference(nameres,
"smi_paths",
"SMI (MIB and PIB) paths",
"Search paths for SMI (MIB and PIB) modules. You must\n"
"restart Wireshark for these changes to take effect.",
smi_paths_uat);
prefs_register_uat_preference(nameres,
"smi_modules",
"SMI (MIB and PIB) modules",
"List of enabled SMI (MIB and PIB) modules. You must\n"
"restart Wireshark for these changes to take effect.",
smi_modules_uat);
smi_modules_uat = uat_new("SMI Modules",
sizeof(smi_module_t),
"smi_modules",
FALSE,
(void*)&smi_modules,
&num_smi_modules,
/* affects dissection of packets (as the MIBs and PIBs affect the
interpretation of e.g. SNMP variable bindings), but not set of
named fields
XXX - if named fields are generated from the MIBs and PIBs
for particular variable bindings, would this affect the set
of named fields? */
UAT_AFFECTS_DISSECTION,
"ChSNMPSMIModules",
smi_mod_copy_cb,
NULL,
smi_mod_free_cb,
restart_needed_warning,
smi_fields);
prefs_register_uat_preference(nameres,
"smi_modules",
"SMI (MIB and PIB) modules",
"List of enabled SMI (MIB and PIB) modules. You must\n"
"restart Wireshark for these changes to take effect.",
smi_modules_uat);
#else
prefs_register_static_text_preference(nameres, "load_smi_modules_static",

View File

@ -51,7 +51,7 @@ struct _uat_t {
const char* filename;
gboolean from_profile;
const char* help;
const char* category;
guint flags;
void** user_ptr;
guint* nrows_p;
uat_copy_cb_t copy_cb;

View File

@ -62,7 +62,7 @@ uat_t* uat_new(const char* name,
gboolean from_profile,
void** data_ptr,
guint* numitems_ptr,
const char* category,
guint flags,
const char* help,
uat_copy_cb_t copy_cb,
uat_update_cb_t update_cb,
@ -101,7 +101,7 @@ uat_t* uat_new(const char* name,
uat->rep = NULL;
uat->free_rep = NULL;
uat->help = help;
uat->category = category;
uat->flags = flags;
for (i=0;flds_array[i].title;i++) {
fld_data_t* f = g_malloc(sizeof(fld_data_t));

View File

@ -221,12 +221,13 @@ typedef struct _uat_field_t {
#define FLDFILL NULL
#define UAT_END_FIELDS {NULL,NULL,PT_TXTMOD_NONE,{0,0,0},{0,0,0},0,0,FLDFILL}
#define UAT_CAT_GENERAL "General"
#define UAT_CAT_PORTS "Port Assignments"
#define UAT_CAT_CRYPTO "Decryption"
#define UAT_CAT_FFMT "File Formats"
#define UAT_CAT_FIELDS "Header Fields"
/*
* Flags to indicate what the settings in this UAT affect.
* This is used when UATs are changed interactively, to indicate what needs
* to be redone when the UAT is changed.
*/
#define UAT_AFFECTS_DISSECTION 0x00000001 /* affects packet dissection */
#define UAT_AFFECTS_FIELDS 0x00000002 /* affects what named fields exist */
/** Create a new uat
*
@ -236,7 +237,7 @@ typedef struct _uat_field_t {
* @param from_profile TRUE if profile directory to be used
* @param data_ptr A pointer to a null terminated array of pointers to the data
* @param num_items_ptr
* @param category
* @param flags flags indicating what this UAT affects
* @param help A pointer to help text
* @param copy_cb A function that copies the data in the struct
* @param update_cb Will be called when a record is updated
@ -252,7 +253,7 @@ uat_t* uat_new(const char* name,
gboolean from_profile,
void** data_ptr,
guint* num_items_ptr,
const char* category,
guint flags,
const char* help,
uat_copy_cb_t copy_cb,
uat_update_cb_t update_cb,

View File

@ -221,7 +221,7 @@ void register_pinfo_stat_trees(void) {
TRUE, /* from_profile */
(void*) &uat_plen_records, /* data_ptr */
&num_plen_uat, /* numitems_ptr */
UAT_CAT_GENERAL, /* category */
0, /* not a dissector, so affects neither dissection nor fields */
NULL, /* help */
uat_plen_record_copy_cb, /* copy callback */
NULL, /* update callback */

View File

@ -716,11 +716,16 @@ static void uat_down_cb(GtkButton *button _U_, gpointer u) {
}
static void uat_apply_changes(uat_t *uat) {
if(uat->category && strcmp(uat->category, UAT_CAT_FIELDS) == 0) {
if(uat->flags & UAT_AFFECTS_FIELDS) {
/* Recreate list with new fields and redissect packets */
new_packet_list_recreate ();
} else if(cfile.state != FILE_CLOSED) {
redissect_packets ();
} else {
if(uat->flags & UAT_AFFECTS_DISSECTION) {
/* Just redissect packets if we have any */
if(cfile.state != FILE_CLOSED) {
redissect_packets ();
}
}
}
}