diff --git a/debian/libwireshark0.symbols b/debian/libwireshark0.symbols index 77d6f731ca..555ac965af 100644 --- a/debian/libwireshark0.symbols +++ b/debian/libwireshark0.symbols @@ -1620,6 +1620,7 @@ libwireshark.so.0 libwireshark0 #MINVER# tfs_low_normal@Base 2.5.1 tfs_more_nomore@Base 1.9.1 tfs_needed_not_needed@Base 2.9.1 + tfs_no_extension_extension@Base 3.3.0 tfs_no_yes@Base 1.9.1 tfs_not_allowed_allowed@Base 1.9.1 tfs_not_supported_supported@Base 2.9.1 @@ -1654,6 +1655,7 @@ libwireshark.so.0 libwireshark0 #MINVER# tfs_up_down@Base 2.5.0 tfs_uplink_downlink@Base 2.5.0 tfs_used_notused@Base 1.9.1 + tfs_user_provider@Base 3.3.0 tfs_valid_invalid@Base 1.9.1 tfs_valid_not_valid@Base 1.12.0~rc1 tfs_yes_no@Base 1.9.1 diff --git a/epan/dissectors/asn1/camel/packet-camel-template.c b/epan/dissectors/asn1/camel/packet-camel-template.c index 3df099cd5b..473073ed7d 100644 --- a/epan/dissectors/asn1/camel/packet-camel-template.c +++ b/epan/dissectors/asn1/camel/packet-camel-template.c @@ -195,12 +195,6 @@ const value_string camelSRTtype_naming[]= { { 0,NULL} }; -#if 0 -static const true_false_string camel_extension_value = { - "No Extension", - "Extension" -}; -#endif #define EUROPEAN_DATE 1 #define AMERICAN_DATE 2 #define CAMEL_DATE_AND_TIME_LEN 20 /* 2*5 + 4 + 5 + 1 (HH:MM:SS;mm/dd/yyyy) */ diff --git a/epan/dissectors/asn1/gsm_map/packet-gsm_map-template.c b/epan/dissectors/asn1/gsm_map/packet-gsm_map-template.c index fbbe88aca0..c3c1214d7f 100644 --- a/epan/dissectors/asn1/gsm_map/packet-gsm_map-template.c +++ b/epan/dissectors/asn1/gsm_map/packet-gsm_map-template.c @@ -1062,10 +1062,7 @@ static const value_string gsm_map_err_code_string_vals[] = { }; #endif -static const true_false_string gsm_map_extension_value = { - "No Extension", - "Extension" -}; + static const value_string gsm_map_nature_of_number_values[] = { { 0x00, "unknown" }, { 0x01, "International Number" }, @@ -3004,7 +3001,7 @@ void proto_register_gsm_map(void) { NULL, HFILL }}, { &hf_gsm_map_extension, { "Extension", "gsm_map.extension", - FT_BOOLEAN, 8, TFS(&gsm_map_extension_value), 0x80, + FT_BOOLEAN, 8, TFS(&tfs_no_extension_extension), 0x80, NULL, HFILL }}, { &hf_gsm_map_nature_of_number, { "Nature of number", "gsm_map.nature_of_number", diff --git a/epan/dissectors/packet-bssap.c b/epan/dissectors/packet-bssap.c index 4ada237f05..a68c9d815d 100644 --- a/epan/dissectors/packet-bssap.c +++ b/epan/dissectors/packet-bssap.c @@ -1303,11 +1303,6 @@ dissect_bssap_service_area_id(tvbuff_t *tvb, proto_tree *tree, int offset) /* 18.4.22 SGSN number */ -static const true_false_string bssap_extension_value = { - "No Extension", - "Extension" -}; - static int dissect_bssap_sgsn_number(tvbuff_t *tvb, proto_tree *tree, int offset) { @@ -2160,7 +2155,7 @@ proto_register_bssap(void) { &hf_bssap_extension, { "Extension", "bssap.extension", - FT_BOOLEAN, 8, TFS(&bssap_extension_value), 0x80, + FT_BOOLEAN, 8, TFS(&tfs_no_extension_extension), 0x80, NULL, HFILL }}, { &hf_bssap_type_of_number, diff --git a/epan/dissectors/packet-camel.c b/epan/dissectors/packet-camel.c index ff4c08f793..b63fedd69b 100644 --- a/epan/dissectors/packet-camel.c +++ b/epan/dissectors/packet-camel.c @@ -895,12 +895,6 @@ const value_string camelSRTtype_naming[]= { { 0,NULL} }; -#if 0 -static const true_false_string camel_extension_value = { - "No Extension", - "Extension" -}; -#endif #define EUROPEAN_DATE 1 #define AMERICAN_DATE 2 #define CAMEL_DATE_AND_TIME_LEN 20 /* 2*5 + 4 + 5 + 1 (HH:MM:SS;mm/dd/yyyy) */ @@ -1190,7 +1184,7 @@ static const value_string camel_ectTreatmentIndicator_values[] = { #define noInvokeId NULL /*--- End of included file: packet-camel-val.h ---*/ -#line 309 "./asn1/camel/packet-camel-template.c" +#line 303 "./asn1/camel/packet-camel-template.c" /*--- Included file: packet-camel-table.c ---*/ @@ -1280,7 +1274,7 @@ static const value_string camel_err_code_string_vals[] = { /*--- End of included file: packet-camel-table.c ---*/ -#line 311 "./asn1/camel/packet-camel-template.c" +#line 305 "./asn1/camel/packet-camel-template.c" /* * DEBUG fonctions @@ -7233,7 +7227,7 @@ static int dissect_CAP_U_ABORT_REASON_PDU(tvbuff_t *tvb _U_, packet_info *pinfo /*--- End of included file: packet-camel-fn.c ---*/ -#line 412 "./asn1/camel/packet-camel-template.c" +#line 406 "./asn1/camel/packet-camel-template.c" /*--- Included file: packet-camel-table2.c ---*/ @@ -7440,7 +7434,7 @@ static int dissect_returnErrorData(proto_tree *tree, tvbuff_t *tvb, int offset,a /*--- End of included file: packet-camel-table2.c ---*/ -#line 414 "./asn1/camel/packet-camel-template.c" +#line 408 "./asn1/camel/packet-camel-template.c" /* * Functions needed for Hash-Table @@ -8313,7 +8307,7 @@ void proto_reg_handoff_camel(void) { /*--- End of included file: packet-camel-dis-tab.c ---*/ -#line 1279 "./asn1/camel/packet-camel-template.c" +#line 1273 "./asn1/camel/packet-camel-template.c" } else { range_foreach(ssn_range, range_delete_callback, NULL); wmem_free(wmem_epan_scope(), ssn_range); @@ -10435,7 +10429,7 @@ void proto_register_camel(void) { "InvokeId_present", HFILL }}, /*--- End of included file: packet-camel-hfarr.c ---*/ -#line 1452 "./asn1/camel/packet-camel-template.c" +#line 1446 "./asn1/camel/packet-camel-template.c" }; /* List of subtrees */ @@ -10663,7 +10657,7 @@ void proto_register_camel(void) { &ett_camel_InvokeId, /*--- End of included file: packet-camel-ettarr.c ---*/ -#line 1479 "./asn1/camel/packet-camel-template.c" +#line 1473 "./asn1/camel/packet-camel-template.c" }; static ei_register_info ei[] = { diff --git a/epan/dissectors/packet-gsm_map.c b/epan/dissectors/packet-gsm_map.c index d4215d6b64..a08b0ec8e6 100644 --- a/epan/dissectors/packet-gsm_map.c +++ b/epan/dissectors/packet-gsm_map.c @@ -22415,10 +22415,7 @@ static const value_string gsm_map_err_code_string_vals[] = { }; #endif -static const true_false_string gsm_map_extension_value = { - "No Extension", - "Extension" -}; + static const value_string gsm_map_nature_of_number_values[] = { { 0x00, "unknown" }, { 0x01, "International Number" }, @@ -24357,7 +24354,7 @@ void proto_register_gsm_map(void) { NULL, HFILL }}, { &hf_gsm_map_extension, { "Extension", "gsm_map.extension", - FT_BOOLEAN, 8, TFS(&gsm_map_extension_value), 0x80, + FT_BOOLEAN, 8, TFS(&tfs_no_extension_extension), 0x80, NULL, HFILL }}, { &hf_gsm_map_nature_of_number, { "Nature of number", "gsm_map.nature_of_number", @@ -32003,7 +32000,7 @@ void proto_register_gsm_map(void) { NULL, HFILL }}, /*--- End of included file: packet-gsm_map-hfarr.c ---*/ -#line 3324 "./asn1/gsm_map/packet-gsm_map-template.c" +#line 3321 "./asn1/gsm_map/packet-gsm_map-template.c" }; /* List of subtrees */ @@ -32758,7 +32755,7 @@ void proto_register_gsm_map(void) { &ett_NokiaMAP_Extensions_AllowedServiceData, /*--- End of included file: packet-gsm_map-ettarr.c ---*/ -#line 3363 "./asn1/gsm_map/packet-gsm_map-template.c" +#line 3360 "./asn1/gsm_map/packet-gsm_map-template.c" }; static ei_register_info ei[] = { @@ -32902,7 +32899,7 @@ void proto_register_gsm_map(void) { /*--- End of included file: packet-gsm_map-dis-tab.c ---*/ -#line 3423 "./asn1/gsm_map/packet-gsm_map-template.c" +#line 3420 "./asn1/gsm_map/packet-gsm_map-template.c" oid_add_from_string("ericsson-gsm-Map-Ext","1.2.826.0.1249.58.1.0" ); oid_add_from_string("accessTypeNotAllowed-id","1.3.12.2.1107.3.66.1.2"); /*oid_add_from_string("map-ac networkLocUp(1) version3(3)","0.4.0.0.1.0.1.3" ); diff --git a/epan/dissectors/packet-q2931.c b/epan/dissectors/packet-q2931.c index c9fa28d442..59120a5ab5 100644 --- a/epan/dissectors/packet-q2931.c +++ b/epan/dissectors/packet-q2931.c @@ -1124,7 +1124,6 @@ static const value_string q2931_rejection_reason_vals[] = { { 0x00, NULL } }; -static const true_false_string tfs_user_provider = { "User", "Provider" }; static const true_false_string tfs_abnormal_normal = { "Abnormal", "Normal" }; static void diff --git a/epan/dissectors/packet-q931.c b/epan/dissectors/packet-q931.c index 6c74b04972..da41b68d46 100644 --- a/epan/dissectors/packet-q931.c +++ b/epan/dissectors/packet-q931.c @@ -1276,7 +1276,6 @@ static const gchar *get_message_name(guint8 prot_discr, guint8 message_type) { return val_to_str_ext(message_type, &q931_message_type_vals_ext, "Unknown (0x%02X)"); } -static const true_false_string tfs_user_provider = { "User", "Provider" }; static const true_false_string tfs_abnormal_normal = { "Abnormal", "Normal" }; static void diff --git a/epan/dissectors/packet-q933.c b/epan/dissectors/packet-q933.c index b7a4858e2c..321c35fcd8 100644 --- a/epan/dissectors/packet-q933.c +++ b/epan/dissectors/packet-q933.c @@ -900,7 +900,6 @@ static const value_string q933_rejection_reason_vals[] = { { 0x00, NULL } }; -static const true_false_string tfs_user_provider = { "User", "Provider" }; static void dissect_q933_cause_ie(tvbuff_t *tvb, int offset, int len, diff --git a/epan/tfs.c b/epan/tfs.c index cd560660cf..7b7a263ceb 100644 --- a/epan/tfs.c +++ b/epan/tfs.c @@ -105,6 +105,8 @@ const true_false_string tfs_changed_not_changed = { "Changed", "Not Changed" }; const true_false_string tfs_needed_not_needed = { "Needed", "Not Needed" }; const true_false_string tfs_selected_not_selected = { "Selected", "Not Selected" }; const true_false_string tfs_add_drop = { "Add", "Drop" }; +const true_false_string tfs_no_extension_extension = { "No Extension", "Extension" }; +const true_false_string tfs_user_provider = { "User", "Provider" }; /* * Editor modelines - https://www.wireshark.org/tools/modelines.html diff --git a/epan/tfs.h b/epan/tfs.h index ccd41b609c..810549420a 100644 --- a/epan/tfs.h +++ b/epan/tfs.h @@ -124,6 +124,8 @@ WS_DLL_PUBLIC const true_false_string tfs_changed_not_changed; WS_DLL_PUBLIC const true_false_string tfs_needed_not_needed; WS_DLL_PUBLIC const true_false_string tfs_selected_not_selected; WS_DLL_PUBLIC const true_false_string tfs_add_drop; +WS_DLL_PUBLIC const true_false_string tfs_no_extension_extension; +WS_DLL_PUBLIC const true_false_string tfs_user_provider; #ifdef __cplusplus } diff --git a/tools/check_tfs.py b/tools/check_tfs.py index 63f885b0c4..a9b9097abe 100755 --- a/tools/check_tfs.py +++ b/tools/check_tfs.py @@ -29,6 +29,19 @@ def signal_handler(sig, frame): signal.signal(signal.SIGINT, signal_handler) + +# Keep track of custom entries that might appear in multiple dissectors, +# so we can consider adding them to tfs.c +custom_tfs_entries = {} +def AddCustomEntry(val1, val2, file): + global custom_tfs_entries + if (val1, val2) in custom_tfs_entries: + custom_tfs_entries[(val1, val2)].append(file) + else: + custom_tfs_entries[(val1, val2)] = [file] + + + class TFS: def __init__(self, file, name, val1, val2): self.file = file @@ -43,7 +56,7 @@ class TFS: print('N.B.: file=' + self.file + ' ' + self.name + ' - true val begins or ends with space \"' + self.val2 + '\"') def __str__(self): - return '{' + self.val1 + ',' + self.val2 + '}' + return '{' + '"' + self.val1 + '", "' + self.val2 + '"}' def removeComments(code_string): @@ -53,7 +66,7 @@ def removeComments(code_string): # Look for hf items in a dissector file. -def find_items(filename): +def findItems(filename): items = {} with open(filename, 'r') as f: @@ -94,18 +107,24 @@ def findDissectorFilesInFolder(folder): issues_found = 0 # Check the given dissector file. -def checkFile(filename, tfs_items): +def checkFile(filename, tfs_items, look_for_common=False): global issues_found # Find items. - items = find_items(filename) + items = findItems(filename) # See if any of these items already existed in tfs.c for i in items: for t in tfs_items: + found = False if tfs_items[t].val1 == items[i].val1 and tfs_items[t].val2 == items[i].val2: print(filename, i, "- could have used", t, 'from tfs.c instead: ', tfs_items[t]) issues_found += 1 + found = True + break + if not found: + if look_for_common: + AddCustomEntry(items[i].val1, items[i].val2, filename) ################################################################# @@ -120,6 +139,9 @@ parser.add_argument('--commits', action='store', help='last N commits to check') parser.add_argument('--open', action='store_true', help='check open files') +parser.add_argument('--common', action='store_true', + help='check for potential new entries for tfs.c') + args = parser.parse_args() @@ -174,13 +196,22 @@ else: # Get standard/ shared ones. -tfs_entries = find_items(os.path.join('epan', 'tfs.c')) +tfs_entries = findItems(os.path.join('epan', 'tfs.c')) # Now check the files to see if they could have used shared ones instead. for f in files: if should_exit: exit(1) - checkFile(f, tfs_entries) + checkFile(f, tfs_entries, look_for_common=args.common) + # Show summary. print(issues_found, 'issues found') + +if args.common: + # Looking for items that could potentially be moved to tfs.c + for c in custom_tfs_entries: + # Only want to see items that have 3 or more occurrences. + # Even then, probably only want to consider ones that sound generic. + if len(custom_tfs_entries[c]) > 2: + print(c, 'appears', len(custom_tfs_entries[c]), 'times, in: ', custom_tfs_entries[c])