diff options
author | Roland Knall <roland.knall@br-automation.com> | 2017-04-27 17:23:03 +0200 |
---|---|---|
committer | Roland Knall <rknall@gmail.com> | 2017-04-28 16:19:51 +0000 |
commit | b3a339b86f813fb9268039c643e11e6d92273ee7 (patch) | |
tree | b903274125b9f62b601da06e431d6ac692ba7093 /epan | |
parent | 1c9588ddc33b40c28787ab5aaad885d76dbe37e7 (diff) |
openSAFETY: Set filter list for nodes
To enhance the possibility for dissections, add a list
of nodes, you explicitly want to see and print an info
text in the node list for all nodes filtered
Change-Id: I08e8a7ddcfd7b78fee24431ffdae75124a8ecddd
Reviewed-on: https://code.wireshark.org/review/21383
Reviewed-by: Roland Knall <rknall@gmail.com>
Diffstat (limited to 'epan')
-rw-r--r-- | epan/dissectors/packet-opensafety.c | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/epan/dissectors/packet-opensafety.c b/epan/dissectors/packet-opensafety.c index 0fb098da71..ffa20bf289 100644 --- a/epan/dissectors/packet-opensafety.c +++ b/epan/dissectors/packet-opensafety.c @@ -274,6 +274,10 @@ static gboolean global_enable_mbtcp = TRUE; static gboolean global_opensafety_debug_verbose = FALSE; +static const char * global_filter_nodes = ""; +static gboolean global_show_only_node_in_filter = TRUE; +static wmem_list_t * global_filter_list = NULL; + static gboolean heuristic_siii_dissection_enabled = TRUE; static heur_dissector_list_t heur_opensafety_spdo_subdissector_list; @@ -297,6 +301,17 @@ setup_dissector(void) { heur_dtbl_entry_t * heur_entry = NULL; + /* create list if it does not exist, but clean existing elements anyway, + * as options might have changed */ + global_filter_list = wmem_list_new(wmem_file_scope()); + + gchar ** vector = wmem_strsplit(wmem_file_scope(), global_filter_nodes, ",", -1); + for (; NULL != *vector; vector++ ) + { + if ( *vector && g_ascii_strtoll(*vector, NULL, 10) > 0 ) + wmem_list_append(global_filter_list, GINT_TO_POINTER(g_ascii_strtoll(*vector, NULL, 10))); + } + heur_entry = find_heur_dissector_by_unique_short_name("opensafety_sercosiii"); if ( heur_entry != NULL ) heuristic_siii_dissection_enabled = heur_entry->enabled; @@ -306,6 +321,12 @@ static void cleanup_dissector(void) { local_scm_udid = NULL; + + if ( global_filter_list ) + { + wmem_destroy_list(global_filter_list); + global_filter_list = NULL; + } } void proto_register_opensafety(void); @@ -2161,6 +2182,23 @@ opensafety_package_dissector(const gchar *protocolName, const gchar *sub_diss_ha } } + /* Filter node list */ + gint addr = OSS_FRAME_ADDR_T(message_tvb, byte_offset + frameStart1); + if ( global_filter_list && wmem_list_count ( global_filter_list ) > 0 ) + { + gboolean found_in_list = wmem_list_find(global_filter_list, GINT_TO_POINTER( addr )) ? TRUE : FALSE; + + if ( ( ! global_show_only_node_in_filter && found_in_list ) || + ( global_show_only_node_in_filter && ! found_in_list ) ) + { + opensafety_item = proto_tree_add_item(tree, proto_opensafety, message_tvb, frameOffset, frameLength, ENC_NA); + proto_item_append_text(opensafety_item, ", Filtered Node: 0x%03X (%d)", addr, addr); + frameOffset += 2; + found--; + continue; + } + } + /* From here on, the package should be correct. Even if it is not correct, it will be dissected * anyway and marked as malformed. Therefore it can be assumed, that a gap will end here. */ @@ -2431,7 +2469,6 @@ apply_prefs ( void ) /* Preference names to specific to use "auto" preference */ dissector_add_uint("udp.port", opensafety_udp_port_number, opensafety_udpdata_handle); dissector_add_uint("udp.port", opensafety_udp_siii_port_number, opensafety_udpdata_handle); - } void @@ -2811,6 +2848,15 @@ proto_register_opensafety(void) "Automatically assign a detected SCM UDID (by reading SNMT->SNTM_assign_UDID_SCM) and set it for the file", &global_scm_udid_autoset); + prefs_register_string_preference(opensafety_module, "filter_nodes", + "Filter openSAFETY Nodes", + "A comma-separated list of nodes to be filtered during dissection", + &global_filter_nodes); + prefs_register_bool_preference(opensafety_module, "filter_show_nodes_in_filterlist", + "Show nodes in filter, hide otherwise", + "If set to true, only nodes in the list will be shown, otherwise they will be hidden", + &global_show_only_node_in_filter); + prefs_register_uint_preference(opensafety_module, "network_udp_port", "Port used for Generic UDP", "Port used by any UDP demo implementation to transport data", 10, |