diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-09-19 04:14:53 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-09-19 04:14:53 +0000 |
commit | a86c5f7cae7ec9a3398300555a0b644689d946a1 (patch) | |
tree | 39fe4b107c71174fd1e8a8ceb9a4d2aa14116248 /epan/dissectors/packet-someip-sd.c | |
parent | Releasing progress-linux version 4.2.6-1~progress7.99u1. (diff) | |
download | wireshark-a86c5f7cae7ec9a3398300555a0b644689d946a1.tar.xz wireshark-a86c5f7cae7ec9a3398300555a0b644689d946a1.zip |
Merging upstream version 4.4.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'epan/dissectors/packet-someip-sd.c')
-rw-r--r-- | epan/dissectors/packet-someip-sd.c | 641 |
1 files changed, 368 insertions, 273 deletions
diff --git a/epan/dissectors/packet-someip-sd.c b/epan/dissectors/packet-someip-sd.c index 85144d59..1a348d38 100644 --- a/epan/dissectors/packet-someip-sd.c +++ b/epan/dissectors/packet-someip-sd.c @@ -1,7 +1,7 @@ /* packet-someip-sd.c * SOME/IP-SD dissector. * By Dr. Lars Voelker <lars.voelker@technica-engineering.de> / <lars.voelker@bmw.de> - * Copyright 2012-2022 Dr. Lars Voelker + * Copyright 2012-2024 Dr. Lars Voelker * Copyright 2020 Ayoub Kaanich * Copyright 2019 Ana Pantar * Copyright 2019 Guenter Ebermann @@ -87,96 +87,96 @@ #define SD_MAX_NUM_OPTIONS 271 /* ID wireshark identifies the dissector by */ -static int proto_someip_sd = -1; +static int proto_someip_sd; /* header field */ -static int hf_someip_sd_flags = -1; -static int hf_someip_sd_rebootflag = -1; -static int hf_someip_sd_unicastflag = -1; -static int hf_someip_sd_explicitiniteventflag = -1; -static int hf_someip_sd_reserved = -1; - -static int hf_someip_sd_length_entriesarray = -1; -static int hf_someip_sd_entries = -1; - -static int hf_someip_sd_entry = -1; -static int hf_someip_sd_entry_type = -1; -static int hf_someip_sd_entry_type_offerservice = -1; -static int hf_someip_sd_entry_type_stopofferservice = -1; -static int hf_someip_sd_entry_type_findservice = -1; -static int hf_someip_sd_entry_type_subscribeeventgroup = -1; -static int hf_someip_sd_entry_type_stopsubscribeeventgroup = -1; -static int hf_someip_sd_entry_type_subscribeeventgroupack = -1; -static int hf_someip_sd_entry_type_subscribeeventgroupnack = -1; -static int hf_someip_sd_entry_index1 = -1; -static int hf_someip_sd_entry_index2 = -1; -static int hf_someip_sd_entry_numopt1 = -1; -static int hf_someip_sd_entry_numopt2 = -1; -static int hf_someip_sd_entry_opts_referenced = -1; -static int hf_someip_sd_entry_serviceid = -1; -static int hf_someip_sd_entry_servicename = -1; -static int hf_someip_sd_entry_instanceid = -1; -static int hf_someip_sd_entry_majorver = -1; -static int hf_someip_sd_entry_ttl = -1; -static int hf_someip_sd_entry_minorver = -1; -static int hf_someip_sd_entry_eventgroupid = -1; -static int hf_someip_sd_entry_eventgroupname = -1; -static int hf_someip_sd_entry_reserved = -1; -static int hf_someip_sd_entry_counter = -1; -static int hf_someip_sd_entry_intial_event_flag = -1; -static int hf_someip_sd_entry_reserved2 = -1; - -static int hf_someip_sd_length_optionsarray = -1; -static int hf_someip_sd_options = -1; - -static int hf_someip_sd_option_type = -1; -static int hf_someip_sd_option_length = -1; -static int hf_someip_sd_option_reserved = -1; -static int hf_someip_sd_option_ipv4 = -1; -static int hf_someip_sd_option_ipv6 = -1; -static int hf_someip_sd_option_port = -1; -static int hf_someip_sd_option_proto = -1; -static int hf_someip_sd_option_reserved2 = -1; -static int hf_someip_sd_option_data = -1; -static int hf_someip_sd_option_config_string = -1; -static int hf_someip_sd_option_config_string_element = -1; -static int hf_someip_sd_option_lb_priority = -1; -static int hf_someip_sd_option_lb_weight = -1; +static int hf_someip_sd_flags; +static int hf_someip_sd_rebootflag; +static int hf_someip_sd_unicastflag; +static int hf_someip_sd_explicitiniteventflag; +static int hf_someip_sd_reserved; + +static int hf_someip_sd_length_entriesarray; +static int hf_someip_sd_entries; + +static int hf_someip_sd_entry; +static int hf_someip_sd_entry_type; +static int hf_someip_sd_entry_type_offerservice; +static int hf_someip_sd_entry_type_stopofferservice; +static int hf_someip_sd_entry_type_findservice; +static int hf_someip_sd_entry_type_subscribeeventgroup; +static int hf_someip_sd_entry_type_stopsubscribeeventgroup; +static int hf_someip_sd_entry_type_subscribeeventgroupack; +static int hf_someip_sd_entry_type_subscribeeventgroupnack; +static int hf_someip_sd_entry_index1; +static int hf_someip_sd_entry_index2; +static int hf_someip_sd_entry_numopt1; +static int hf_someip_sd_entry_numopt2; +static int hf_someip_sd_entry_opts_referenced; +static int hf_someip_sd_entry_serviceid; +static int hf_someip_sd_entry_servicename; +static int hf_someip_sd_entry_instanceid; +static int hf_someip_sd_entry_majorver; +static int hf_someip_sd_entry_ttl; +static int hf_someip_sd_entry_minorver; +static int hf_someip_sd_entry_eventgroupid; +static int hf_someip_sd_entry_eventgroupname; +static int hf_someip_sd_entry_reserved; +static int hf_someip_sd_entry_counter; +static int hf_someip_sd_entry_intial_event_flag; +static int hf_someip_sd_entry_reserved2; + +static int hf_someip_sd_length_optionsarray; +static int hf_someip_sd_options; + +static int hf_someip_sd_option_type; +static int hf_someip_sd_option_length; +static int hf_someip_sd_option_reserved; +static int hf_someip_sd_option_ipv4; +static int hf_someip_sd_option_ipv6; +static int hf_someip_sd_option_port; +static int hf_someip_sd_option_proto; +static int hf_someip_sd_option_reserved2; +static int hf_someip_sd_option_data; +static int hf_someip_sd_option_config_string; +static int hf_someip_sd_option_config_string_element; +static int hf_someip_sd_option_lb_priority; +static int hf_someip_sd_option_lb_weight; /* protocol tree items */ -static gint ett_someip_sd = -1; -static gint ett_someip_sd_flags = -1; -static gint ett_someip_sd_entries = -1; -static gint ett_someip_sd_entry = -1; -static gint ett_someip_sd_options = -1; -static gint ett_someip_sd_option = -1; -static gint ett_someip_sd_config_string = -1; +static int ett_someip_sd; +static int ett_someip_sd_flags; +static int ett_someip_sd_entries; +static int ett_someip_sd_entry; +static int ett_someip_sd_options; +static int ett_someip_sd_option; +static int ett_someip_sd_config_string; /*** Taps ***/ static int tap_someip_sd_entries = -1; typedef struct _someip_sd_entries_tap { - guint8 entry_type; - guint16 service_id; - guint8 major_version; - guint32 minor_version; - guint16 instance_id; - guint16 eventgroup_id; - guint32 ttl; + uint8_t entry_type; + uint16_t service_id; + uint8_t major_version; + uint32_t minor_version; + uint16_t instance_id; + uint16_t eventgroup_id; + uint32_t ttl; } someip_sd_entries_tap_t; /*** Stats ***/ -static const gchar *st_str_ip_src = "Source Addresses"; -static const gchar *st_str_ip_dst = "Destination Addresses"; +static const char *st_str_ip_src = "Source Addresses"; +static const char *st_str_ip_dst = "Destination Addresses"; static int st_node_ip_src = -1; static int st_node_ip_dst = -1; /*** Preferences ***/ -static range_t *someip_ignore_ports_udp = NULL; -static range_t *someip_ignore_ports_tcp = NULL; +static range_t *someip_ignore_ports_udp; +static range_t *someip_ignore_ports_tcp; /* SOME/IP-SD Entry Names for TTL>0 */ static const value_string sd_entry_type_positive[] = { @@ -195,6 +195,31 @@ static const value_string sd_entry_type_negative[] = { {0, NULL} }; +static const value_string sd_serviceid_vs[] = { + {0xFFFF, "ANY"}, + {0, NULL} +}; + +static const value_string sd_instanceid_vs[] = { + {0xFFFF, "ANY"}, + {0, NULL} +}; + +static const value_string sd_majorversion_vs[] = { + {0xFF, "ANY"}, + {0, NULL} +}; + +static const value_string sd_minorversion_vs[] = { + {0xFFFFFFFF, "ANY"}, + {0, NULL} +}; + +static const value_string sd_eventgroupid_vs[] = { + {0xFFFF, "ANY"}, + {0, NULL} +}; + /* SOME/IP-SD Option Names */ static const value_string sd_option_type[] = { {SD_OPTION_UNKNOWN, "Unknown"}, @@ -232,16 +257,18 @@ static const true_false_string sd_eiec_flag = { }; /*** expert info items ***/ -static expert_field ef_someipsd_message_truncated = EI_INIT; -static expert_field ef_someipsd_entry_array_malformed = EI_INIT; -static expert_field ef_someipsd_entry_array_empty = EI_INIT; -static expert_field ef_someipsd_entry_unknown = EI_INIT; -static expert_field ef_someipsd_option_array_truncated = EI_INIT; -static expert_field ef_someipsd_option_array_bytes_left = EI_INIT; -static expert_field ef_someipsd_option_unknown = EI_INIT; -static expert_field ef_someipsd_option_wrong_length = EI_INIT; -static expert_field ef_someipsd_L4_protocol_unsupported = EI_INIT; -static expert_field ef_someipsd_config_string_malformed = EI_INIT; +static expert_field ei_someipsd_message_truncated; +static expert_field ei_someipsd_entry_array_malformed; +static expert_field ei_someipsd_entry_array_empty; +static expert_field ei_someipsd_entry_unknown; +static expert_field ei_someipsd_offer_without_endpoint; +static expert_field ei_someipsd_entry_stopsubsub; +static expert_field ei_someipsd_option_array_truncated; +static expert_field ei_someipsd_option_array_bytes_left; +static expert_field ei_someipsd_option_unknown; +static expert_field ei_someipsd_option_wrong_length; +static expert_field ei_someipsd_L4_protocol_unsupported; +static expert_field ei_someipsd_config_string_malformed; /*** prototypes ***/ void proto_register_someip_sd(void); @@ -254,12 +281,12 @@ static dissector_handle_t someip_sd_handle; *************************************/ static void -someip_sd_register_ports(guint32 opt_index, guint32 opt_num, guint32 option_count, guint32 option_ports[]) { - guint i; +someip_sd_register_ports(uint32_t opt_index, uint32_t opt_num, uint32_t option_count, uint32_t option_ports[]) { + unsigned i; for (i = opt_index; i < opt_index + opt_num && i < option_count; i++) { - guint32 l4port = 0x0000ffff & option_ports[i]; - guint32 l4proto = (0xff000000 & option_ports[i]) >> 24; + uint32_t l4port = 0x0000ffff & option_ports[i]; + uint32_t l4proto = (0xff000000 & option_ports[i]) >> 24; if (l4proto == SD_OPTION_L4PROTO_UDP && !value_is_in_range(someip_ignore_ports_udp, l4port)) { register_someip_port_udp(l4port); @@ -274,9 +301,9 @@ someip_sd_register_ports(guint32 opt_index, guint32 opt_num, guint32 option_coun } static void -dissect_someip_sd_pdu_option_configuration(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 offset, guint32 length, int optionnum) { - guint32 offset_orig = offset; - const guint8 *config_string; +dissect_someip_sd_pdu_option_configuration(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, uint32_t offset, uint32_t length, int optionnum) { + uint32_t offset_orig = offset; + const uint8_t *config_string; proto_item *ti; proto_tree *subtree; @@ -292,12 +319,12 @@ dissect_someip_sd_pdu_option_configuration(tvbuff_t *tvb, packet_info *pinfo, pr proto_tree_add_item(tree, hf_someip_sd_option_reserved, tvb, offset, 1, ENC_NA); offset += 1; - gint config_string_length = length - offset + offset_orig; + int config_string_length = length - offset + offset_orig; ti = proto_tree_add_item_ret_string(tree, hf_someip_sd_option_config_string, tvb, offset, config_string_length, ENC_ASCII | ENC_NA, pinfo->pool, &config_string); subtree = proto_item_add_subtree(ti, ett_someip_sd_config_string); - guint8 pos = 0; - guint8 element_length; + uint8_t pos = 0; + uint8_t element_length; while (config_string != NULL && config_string_length - pos > 0) { element_length = config_string[pos]; pos++; @@ -307,7 +334,7 @@ dissect_someip_sd_pdu_option_configuration(tvbuff_t *tvb, packet_info *pinfo, pr } if (element_length > config_string_length - pos) { - expert_add_info(pinfo, ti, &ef_someipsd_config_string_malformed); + expert_add_info(pinfo, ti, &ei_someipsd_config_string_malformed); break; } @@ -317,7 +344,7 @@ dissect_someip_sd_pdu_option_configuration(tvbuff_t *tvb, packet_info *pinfo, pr } static void -dissect_someip_sd_pdu_option_loadbalancing(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, guint32 offset, guint32 length, int optionnum) { +dissect_someip_sd_pdu_option_loadbalancing(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, uint32_t offset, uint32_t length, int optionnum) { tree = proto_tree_add_subtree_format(tree, tvb, offset, length, ett_someip_sd_option, NULL, "%d: Load Balancing Option", optionnum); /* Add common fields */ @@ -337,23 +364,23 @@ dissect_someip_sd_pdu_option_loadbalancing(tvbuff_t *tvb, packet_info *pinfo _U_ } static void -dissect_someip_sd_pdu_option_ipv4(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 offset, guint32 length, int optionnum, guint32 option_ports[]) { - guint8 type = 255; - const gchar *description = NULL; - guint32 l4port = 0; - guint32 l4proto = 0; - const gchar *l4protoname = NULL; - const gchar *ipstring = NULL; +dissect_someip_sd_pdu_option_ipv4(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, uint32_t offset, uint32_t length, int optionnum, uint32_t option_ports[]) { + uint8_t type = 255; + const char *description = NULL; + uint32_t l4port = 0; + uint32_t l4proto = 0; + const char *l4protoname = NULL; + const char *ipstring = NULL; proto_item *ti = NULL; proto_item *ti_top = NULL; - type = tvb_get_guint8(tvb, offset + 2); + type = tvb_get_uint8(tvb, offset + 2); description = val_to_str(type, sd_option_type, "(Unknown Option: %d)"); tree = proto_tree_add_subtree_format(tree, tvb, offset, length, ett_someip_sd_option, &ti_top, "%d: %s Option", optionnum, description); if (length != SD_OPTION_IPV4_LENGTH) { - expert_add_info(pinfo, ti_top, &ef_someipsd_option_wrong_length); + expert_add_info(pinfo, ti_top, &ei_someipsd_option_wrong_length); return; } @@ -379,7 +406,7 @@ dissect_someip_sd_pdu_option_ipv4(tvbuff_t *tvb, packet_info *pinfo, proto_tree proto_item_append_text(ti, " (%s)", l4protoname); if (type != SD_OPTION_IPV4_ENDPOINT && l4proto == SD_OPTION_L4PROTO_TCP) { - expert_add_info(pinfo, ti_top, &ef_someipsd_L4_protocol_unsupported); + expert_add_info(pinfo, ti_top, &ei_someipsd_L4_protocol_unsupported); } offset += 1; @@ -387,27 +414,27 @@ dissect_someip_sd_pdu_option_ipv4(tvbuff_t *tvb, packet_info *pinfo, proto_tree proto_item_append_text(ti_top, " (%s:%d (%s))", ipstring, l4port, l4protoname); - option_ports[optionnum] = ((guint32)l4proto << 24) + l4port; + option_ports[optionnum] = ((uint32_t)l4proto << 24) + l4port; } static void -dissect_someip_sd_pdu_option_ipv6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 offset, guint32 length, int optionnum, guint32 option_ports[]) { - guint8 type = 255; - const gchar *description = NULL; - guint32 l4port = 0; - guint32 l4proto = 0; - const gchar *l4protoname = NULL; - const gchar *ipstring = NULL; +dissect_someip_sd_pdu_option_ipv6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, uint32_t offset, uint32_t length, int optionnum, uint32_t option_ports[]) { + uint8_t type = 255; + const char *description = NULL; + uint32_t l4port = 0; + uint32_t l4proto = 0; + const char *l4protoname = NULL; + const char *ipstring = NULL; proto_item *ti = NULL; proto_item *ti_top = NULL; - type = tvb_get_guint8(tvb, offset + 2); + type = tvb_get_uint8(tvb, offset + 2); description = val_to_str(type, sd_option_type, "(Unknown Option: %d)"); tree = proto_tree_add_subtree_format(tree, tvb, offset, length, ett_someip_sd_option, &ti_top, "%d: %s Option", optionnum, description); if (length != SD_OPTION_IPV6_LENGTH) { - expert_add_info(pinfo, ti_top, &ef_someipsd_option_wrong_length); + expert_add_info(pinfo, ti_top, &ei_someipsd_option_wrong_length); return; } @@ -432,7 +459,7 @@ dissect_someip_sd_pdu_option_ipv6(tvbuff_t *tvb, packet_info *pinfo, proto_tree proto_item_append_text(ti, " (%s)", l4protoname); if (type != SD_OPTION_IPV6_ENDPOINT && l4proto == SD_OPTION_L4PROTO_TCP) { - expert_add_info(pinfo, ti_top, &ef_someipsd_L4_protocol_unsupported); + expert_add_info(pinfo, ti_top, &ei_someipsd_L4_protocol_unsupported); } offset += 1; @@ -440,18 +467,18 @@ dissect_someip_sd_pdu_option_ipv6(tvbuff_t *tvb, packet_info *pinfo, proto_tree proto_item_append_text(ti_top, " (%s:%d (%s))", ipstring, l4port, l4protoname); - option_ports[optionnum] = ((guint32)l4proto << 24) + l4port; + option_ports[optionnum] = ((uint32_t)l4proto << 24) + l4port; } static void -dissect_someip_sd_pdu_option_unknown(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 offset, guint32 length, int optionnum) { - guint32 len = 0; +dissect_someip_sd_pdu_option_unknown(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, uint32_t offset, uint32_t length, int optionnum) { + uint32_t len = 0; proto_item *ti; tree = proto_tree_add_subtree_format(tree, tvb, offset, length, ett_someip_sd_option, &ti, "%d: %s Option", optionnum, - val_to_str_const(tvb_get_guint8(tvb, offset + 2), sd_option_type, "Unknown")); + val_to_str_const(tvb_get_uint8(tvb, offset + 2), sd_option_type, "Unknown")); - expert_add_info(pinfo, ti, &ef_someipsd_option_unknown); + expert_add_info(pinfo, ti, &ei_someipsd_option_unknown); proto_tree_add_item_ret_uint(tree, hf_someip_sd_option_length, tvb, offset, 2, ENC_BIG_ENDIAN, &len); offset += 2; @@ -470,16 +497,16 @@ dissect_someip_sd_pdu_option_unknown(tvbuff_t *tvb, packet_info *pinfo, proto_tr } static int -dissect_someip_sd_pdu_options(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *ti, guint32 offset_orig, guint32 length, guint32 option_ports[], guint *option_count) { - guint16 real_length = 0; - guint8 option_type = 0; +dissect_someip_sd_pdu_options(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *ti, uint32_t offset_orig, uint32_t length, uint32_t option_ports[], unsigned *option_count) { + uint16_t real_length = 0; + uint8_t option_type = 0; int optionnum = 0; tvbuff_t *subtvb = NULL; - guint32 offset = offset_orig; + uint32_t offset = offset_orig; if (!tvb_bytes_exist(tvb, offset, SD_OPTION_MINLENGTH) || !tvb_bytes_exist(tvb, offset, length)) { - expert_add_info(pinfo, ti, &ef_someipsd_option_array_truncated); + expert_add_info(pinfo, ti, &ei_someipsd_option_array_truncated); return offset; } @@ -488,14 +515,14 @@ dissect_someip_sd_pdu_options(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre option_ports[optionnum] = 0; real_length = tvb_get_ntohs(tvb, offset) + 3; - option_type = tvb_get_guint8(tvb, offset + 2); + option_type = tvb_get_uint8(tvb, offset + 2); - if (!tvb_bytes_exist(tvb, offset, (gint)real_length) || offset - offset_orig + real_length > length) { - expert_add_info(pinfo, ti, &ef_someipsd_option_array_truncated); + if (!tvb_bytes_exist(tvb, offset, (int)real_length) || offset - offset_orig + real_length > length) { + expert_add_info(pinfo, ti, &ei_someipsd_option_array_truncated); return offset; } - subtvb = tvb_new_subset_length(tvb, offset, (gint)real_length); + subtvb = tvb_new_subset_length(tvb, offset, (int)real_length); switch (option_type) { case SD_OPTION_CONFIGURATION: @@ -530,58 +557,101 @@ dissect_someip_sd_pdu_options(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre } static void -dissect_someip_sd_pdu_entry(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 offset_orig, guint32 length, guint32 *entry_flags, guint32 *stop_entry_flags, guint32 option_ports[], guint option_count) { - guint8 type = 255; - guint32 serviceid = 0; - guint32 instanceid = 0; - guint32 eventgroupid = 0; - guint32 majorver = 0; - guint32 minorver = 0; - guint32 ttl = 0; - guint32 opt_index1; - guint32 opt_index2; - guint32 opt_num1; - guint32 opt_num2; - - guint64 uniqueid = 0; - guint8 category = SD_ENTRY_UNKNOWN; - - const gchar *description = NULL; - static gchar buf_opt_ref[32]; +someip_sd_pdu_entry_append_text(proto_item *ti_entry, uint8_t category, uint16_t serviceid, uint16_t instanceid, uint8_t majorver, uint32_t minorver, uint16_t eventgroupid, char *buf_opt_ref) { + if (category != SD_ENTRY_SERVICE && category != SD_ENTRY_EVENTGROUP) { + return; + } + + if (serviceid == 0xffff) { + proto_item_append_text(ti_entry, " (Service ID ANY"); + } else { + proto_item_append_text(ti_entry, " (Service ID 0x%04x", serviceid); + } + + if (instanceid == 0xffff) { + proto_item_append_text(ti_entry, ", Instance ID ANY"); + } else { + proto_item_append_text(ti_entry, ", Instance ID 0x%04x", instanceid); + } + + if (majorver == 0xff) { + proto_item_append_text(ti_entry, ", Version ANY"); + } else { + proto_item_append_text(ti_entry, ", Version %u", majorver); + } + + switch (category) { + case SD_ENTRY_SERVICE: + if (minorver == 0xffffffff) { + proto_item_append_text(ti_entry, ".ANY"); + } else { + proto_item_append_text(ti_entry, ".%u", minorver); + } + break; + + case SD_ENTRY_EVENTGROUP: + if (eventgroupid == 0xffff) { + proto_item_append_text(ti_entry, ", Eventgroup ID ANY"); + } else { + proto_item_append_text(ti_entry, ", Eventgroup ID 0x%04x", eventgroupid); + } + break; + } + + proto_item_append_text(ti_entry, ", Options: %s)", buf_opt_ref); +} + +static void +dissect_someip_sd_pdu_entry(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, uint32_t offset_orig, uint32_t length, uint8_t *type, uint32_t *ttl, uint64_t *uniqueid, uint32_t option_ports[], unsigned option_count, proto_item **ti_entry) { + uint32_t serviceid = 0; + uint32_t instanceid = 0; + uint32_t eventgroupid = 0; + uint32_t majorver = 0; + uint32_t minorver = 0; + uint32_t opt_index1; + uint32_t opt_index2; + uint32_t opt_num1; + uint32_t opt_num2; + + uint8_t category = SD_ENTRY_UNKNOWN; + + const char *description = NULL; + static char buf_opt_ref[32]; proto_item *ti; - proto_item *ti_top; - guint32 offset = offset_orig; + uint32_t offset = offset_orig; + + *uniqueid = 0; + *type = 255; + *ttl = 0; if (length < SD_ENTRY_LENGTH || !tvb_bytes_exist(tvb, offset, length)) { return; } /* lets look ahead and find out the type and ttl */ - type = tvb_get_guint8(tvb, offset); - ttl = tvb_get_ntoh24(tvb, offset + 9); + *type = tvb_get_uint8(tvb, offset); + *ttl = tvb_get_ntoh24(tvb, offset + 9); - if (type < 4) { + if (*type < 4) { category = SD_ENTRY_SERVICE; - } else if (type >= 4 && type < 8) { + } else if (*type >= 4 && *type < 8) { category = SD_ENTRY_EVENTGROUP; } else { - ti_top = proto_tree_add_none_format(tree, hf_someip_sd_entry, tvb, offset, SD_ENTRY_LENGTH, "Unknown Entry (Type: %d)", type); - expert_add_info(pinfo, ti_top, &ef_someipsd_entry_unknown); + *ti_entry = proto_tree_add_none_format(tree, hf_someip_sd_entry, tvb, offset, SD_ENTRY_LENGTH, "Unknown Entry (Type: %d)", *type); + expert_add_info(pinfo, *ti_entry, &ei_someipsd_entry_unknown); return; } - if (ttl == 0) { - description = val_to_str(type, sd_entry_type_negative, "(Unknown Entry: %d)"); - } else { - description = val_to_str(type, sd_entry_type_positive, "(Unknown Entry: %d)"); - } + description = val_to_str_const(*type, + (*ttl == 0) ? sd_entry_type_negative : sd_entry_type_positive, + "Unknown"); - ti_top = proto_tree_add_none_format(tree, hf_someip_sd_entry, tvb, offset, SD_ENTRY_LENGTH, "%s Entry", description); - tree = proto_item_add_subtree(ti_top, ett_someip_sd_entry); + *ti_entry = proto_tree_add_none_format(tree, hf_someip_sd_entry, tvb, offset, SD_ENTRY_LENGTH, "%s Entry", description); + tree = proto_item_add_subtree(*ti_entry, ett_someip_sd_entry); - proto_tree_add_uint_format_value(tree, hf_someip_sd_entry_type, tvb, offset, 1, type, "0x%02x (%s)", type, description); + proto_tree_add_uint_format_value(tree, hf_someip_sd_entry_type, tvb, offset, 1, *type, "0x%02x (%s)", *type, description); offset += 1; proto_tree_add_item_ret_uint(tree, hf_someip_sd_entry_index1, tvb, offset, 1, ENC_BIG_ENDIAN, &opt_index1); @@ -607,7 +677,7 @@ dissect_someip_sd_pdu_entry(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item_set_generated(ti); ti = proto_tree_add_item_ret_uint(tree, hf_someip_sd_entry_serviceid, tvb, offset, 2, ENC_BIG_ENDIAN, &serviceid); - description = someip_lookup_service_name((guint16)serviceid); + description = someip_lookup_service_name((uint16_t)serviceid); if (description != NULL) { proto_item_append_text(ti, " (%s)", description); ti = proto_tree_add_string(tree, hf_someip_sd_entry_servicename, tvb, offset, 2, description); @@ -628,7 +698,7 @@ dissect_someip_sd_pdu_entry(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, /* Add specific fields - i.e. the last line */ if (category == SD_ENTRY_SERVICE) { proto_tree_add_item_ret_uint(tree, hf_someip_sd_entry_minorver, tvb, offset, 4, ENC_BIG_ENDIAN, &minorver); - proto_item_append_text(ti_top, " (Service ID 0x%04x, Instance ID 0x%04x, Version %u.%u, Options: %s)", serviceid, instanceid, majorver, minorver, buf_opt_ref); + someip_sd_pdu_entry_append_text(*ti_entry, category, serviceid, instanceid, majorver, minorver, 0, buf_opt_ref); } else if (category == SD_ENTRY_EVENTGROUP) { proto_tree_add_item(tree, hf_someip_sd_entry_reserved, tvb, offset, 1, ENC_NA); offset += 1; @@ -639,7 +709,7 @@ dissect_someip_sd_pdu_entry(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, offset += 1; ti = proto_tree_add_item_ret_uint(tree, hf_someip_sd_entry_eventgroupid, tvb, offset, 2, ENC_BIG_ENDIAN, &eventgroupid); - description = someip_lookup_eventgroup_name((guint16)serviceid, (guint16)eventgroupid); + description = someip_lookup_eventgroup_name((uint16_t)serviceid, (uint16_t)eventgroupid); if (description != NULL) { proto_item_append_text(ti, " (%s)", description); ti = proto_tree_add_string(tree, hf_someip_sd_entry_eventgroupname, tvb, offset, 2, description); @@ -647,53 +717,49 @@ dissect_someip_sd_pdu_entry(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item_set_hidden(ti); } - proto_item_append_text(ti_top, " (Service ID 0x%04x, Instance ID 0x%04x, Eventgroup ID 0x%04x, Version %u, Options: %s)", serviceid, instanceid, eventgroupid, majorver, buf_opt_ref); - } - - /* mark for attaching to info column */ - if (type < 32) { - if (ttl == 0) { - *stop_entry_flags = *stop_entry_flags | (1 << type); - } else { - *entry_flags = *entry_flags | (1 << type); - } + someip_sd_pdu_entry_append_text(*ti_entry, category, serviceid, instanceid, majorver, 0, eventgroupid, buf_opt_ref); } /* lets add some combined filtering term */ - uniqueid = (((guint64)serviceid) << 32) | (guint64)instanceid << 16 | (guint64)eventgroupid; + *uniqueid = (((uint64_t)serviceid) << 32) | (uint64_t)instanceid << 16 | (uint64_t)eventgroupid; ti = NULL; - if (ttl > 0) { - switch (type) { + if (*ttl > 0) { + switch (*type) { case SD_ENTRY_FIND_SERVICE: - ti = proto_tree_add_uint64_format_value(tree, hf_someip_sd_entry_type_findservice, tvb, offset_orig, SD_ENTRY_LENGTH, uniqueid, "on 0x%012" PRIx64, uniqueid); + ti = proto_tree_add_uint64_format_value(tree, hf_someip_sd_entry_type_findservice, tvb, offset_orig, SD_ENTRY_LENGTH, *uniqueid, "on 0x%012" PRIx64, *uniqueid); break; case SD_ENTRY_OFFER_SERVICE: - ti = proto_tree_add_uint64_format_value(tree, hf_someip_sd_entry_type_offerservice, tvb, offset_orig, SD_ENTRY_LENGTH, uniqueid, "on 0x%012" PRIx64, uniqueid); + ti = proto_tree_add_uint64_format_value(tree, hf_someip_sd_entry_type_offerservice, tvb, offset_orig, SD_ENTRY_LENGTH, *uniqueid, "on 0x%012" PRIx64, *uniqueid); break; case SD_ENTRY_SUBSCRIBE_EVENTGROUP: - ti = proto_tree_add_uint64_format_value(tree, hf_someip_sd_entry_type_subscribeeventgroup, tvb, offset_orig, SD_ENTRY_LENGTH, uniqueid, "on 0x%012" PRIx64, uniqueid); + ti = proto_tree_add_uint64_format_value(tree, hf_someip_sd_entry_type_subscribeeventgroup, tvb, offset_orig, SD_ENTRY_LENGTH, *uniqueid, "on 0x%012" PRIx64, *uniqueid); break; case SD_ENTRY_SUBSCRIBE_EVENTGROUP_ACK: - ti = proto_tree_add_uint64_format_value(tree, hf_someip_sd_entry_type_subscribeeventgroupack, tvb, offset_orig, SD_ENTRY_LENGTH, uniqueid, "on 0x%012" PRIx64, uniqueid); + ti = proto_tree_add_uint64_format_value(tree, hf_someip_sd_entry_type_subscribeeventgroupack, tvb, offset_orig, SD_ENTRY_LENGTH, *uniqueid, "on 0x%012" PRIx64, *uniqueid); break; } } else { - switch (type) { + switch (*type) { case SD_ENTRY_STOP_OFFER_SERVICE: - ti = proto_tree_add_uint64_format_value(tree, hf_someip_sd_entry_type_stopofferservice, tvb, offset_orig, SD_ENTRY_LENGTH, uniqueid, "on 0x%012" PRIx64, uniqueid); + ti = proto_tree_add_uint64_format_value(tree, hf_someip_sd_entry_type_stopofferservice, tvb, offset_orig, SD_ENTRY_LENGTH, *uniqueid, "on 0x%012" PRIx64, *uniqueid); break; case SD_ENTRY_STOP_SUBSCRIBE_EVENTGROUP: - ti = proto_tree_add_uint64_format_value(tree, hf_someip_sd_entry_type_stopsubscribeeventgroup, tvb, offset_orig, SD_ENTRY_LENGTH, uniqueid, "on 0x%012" PRIx64, uniqueid); + ti = proto_tree_add_uint64_format_value(tree, hf_someip_sd_entry_type_stopsubscribeeventgroup, tvb, offset_orig, SD_ENTRY_LENGTH, *uniqueid, "on 0x%012" PRIx64, *uniqueid); break; case SD_ENTRY_SUBSCRIBE_EVENTGROUP_NACK: - ti = proto_tree_add_uint64_format_value(tree, hf_someip_sd_entry_type_subscribeeventgroupnack, tvb, offset_orig, SD_ENTRY_LENGTH, uniqueid, "on 0x%012" PRIx64, uniqueid); + ti = proto_tree_add_uint64_format_value(tree, hf_someip_sd_entry_type_subscribeeventgroupnack, tvb, offset_orig, SD_ENTRY_LENGTH, *uniqueid, "on 0x%012" PRIx64, *uniqueid); break; } } proto_item_set_hidden(ti); + /* check for Offer Entry without referenced Endpoints */ + if (opt_num1 == 0 && opt_num2 == 0 && *type == SD_ENTRY_OFFER_SERVICE && *ttl > 0) { + expert_add_info(pinfo, *ti_entry, &ei_someipsd_offer_without_endpoint); + } + /* register ports but we skip 0xfffe because of other-serv */ if (serviceid != SOMEIP_SD_SERVICE_ID_OTHER_SERVICE && !PINFO_FD_VISITED(pinfo)) { someip_sd_register_ports(opt_index1, opt_num1, option_count, option_ports); @@ -703,27 +769,54 @@ dissect_someip_sd_pdu_entry(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, /* TAP */ if (have_tap_listener(tap_someip_sd_entries)) { someip_sd_entries_tap_t *data = wmem_alloc(pinfo->pool, sizeof(someip_sd_entries_tap_t)); - data->entry_type = type; - data->service_id = (guint16)serviceid; - data->major_version = (guint8)majorver; + data->entry_type = *type; + data->service_id = (uint16_t)serviceid; + data->major_version = (uint8_t)majorver; data->minor_version = minorver; - data->instance_id = (guint16)instanceid; - data->eventgroup_id = (guint16)eventgroupid; - data->ttl = ttl; + data->instance_id = (uint16_t)instanceid; + data->eventgroup_id = (uint16_t)eventgroupid; + data->ttl = *ttl; tap_queue_packet(tap_someip_sd_entries, pinfo, data); } } static int -dissect_someip_sd_pdu_entries(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *ti, guint32 offset, guint32 length, guint32 option_ports[], guint option_count) { - guint32 entry_flags = 0; - guint32 stop_entry_flags = 0; +dissect_someip_sd_pdu_entries(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *ti, uint32_t offset, uint32_t length, uint32_t option_ports[], unsigned option_count) { + proto_item *ti_entry; + + uint8_t type; + uint32_t ttl; + uint32_t entry_flags = 0; + uint32_t stop_entry_flags = 0; + + uint64_t uniqueid; + uint64_t last_uniqueid = 0xffffffffffffffff; + while (length >= SD_ENTRY_LENGTH) { - dissect_someip_sd_pdu_entry(tvb, pinfo, tree, offset, SD_ENTRY_LENGTH, &entry_flags, &stop_entry_flags, option_ports, option_count); + dissect_someip_sd_pdu_entry(tvb, pinfo, tree, offset, SD_ENTRY_LENGTH, &type, &ttl, &uniqueid, option_ports, option_count, &ti_entry); offset += SD_ENTRY_LENGTH; length -= SD_ENTRY_LENGTH; + + /* mark for attaching to info column */ + if (type < 32) { + if (ttl == 0) { + stop_entry_flags = stop_entry_flags | (1 << type); + } else { + entry_flags = entry_flags | (1 << type); + } + } + + if (type == SD_ENTRY_SUBSCRIBE_EVENTGROUP && ttl == 0) { + last_uniqueid = uniqueid; + } else { + if ( (type == SD_ENTRY_SUBSCRIBE_EVENTGROUP && ttl > 0) && last_uniqueid == uniqueid ) { + expert_add_info(pinfo, ti_entry, &ei_someipsd_entry_stopsubsub); + } + + last_uniqueid = 0xffffffffffffffff; + } } /* Add entry flags */ @@ -760,7 +853,7 @@ dissect_someip_sd_pdu_entries(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre } if (length != 0) { - expert_add_info(pinfo, ti, &ef_someipsd_entry_array_malformed); + expert_add_info(pinfo, ti, &ei_someipsd_entry_array_malformed); } return length; @@ -768,21 +861,21 @@ dissect_someip_sd_pdu_entries(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre static int dissect_someip_sd_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) { - guint32 offset = 0; - guint32 length_entriesarray = 0; - guint32 length_optionsarray = 0; + uint32_t offset = 0; + uint32_t length_entriesarray = 0; + uint32_t length_optionsarray = 0; proto_item *ti = NULL; proto_item *ti_sd_entries = NULL; proto_tree *someip_sd_entries_tree = NULL; proto_tree *someip_sd_options_tree = NULL; - gboolean stop_parsing_after_entries = FALSE; - guint32 offset_entriesarray; + bool stop_parsing_after_entries = false; + uint32_t offset_entriesarray; /* format for option_ports entries: 1 byte proto | 1 byte reserved | 2 byte port number*/ - static guint32 option_ports[SD_MAX_NUM_OPTIONS]; - guint option_count = 0; + static uint32_t option_ports[SD_MAX_NUM_OPTIONS]; + unsigned option_count = 0; static int * const someipsd_flags[] = { &hf_someip_sd_rebootflag, @@ -798,7 +891,7 @@ dissect_someip_sd_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void tree = proto_item_add_subtree(ti, ett_someip_sd); if (!tvb_bytes_exist(tvb, offset, SOMEIP_SD_MIN_LENGTH)) { - expert_add_info(pinfo, ti, &ef_someipsd_message_truncated); + expert_add_info(pinfo, ti, &ei_someipsd_message_truncated); return tvb_reported_length(tvb); } @@ -815,15 +908,15 @@ dissect_someip_sd_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void offset += 4; if (!tvb_bytes_exist(tvb, offset, length_entriesarray)) { - expert_add_info(pinfo, ti , &ef_someipsd_message_truncated); + expert_add_info(pinfo, ti , &ei_someipsd_message_truncated); return tvb_reported_length(tvb); } if (!tvb_bytes_exist(tvb, offset, length_entriesarray)) { /* truncated SD message - need to shorten buffer */ length_entriesarray = tvb_captured_length_remaining(tvb, offset); - expert_add_info(pinfo, ti, &ef_someipsd_message_truncated); - stop_parsing_after_entries = TRUE; + expert_add_info(pinfo, ti, &ei_someipsd_message_truncated); + stop_parsing_after_entries = true; } /* preparing entries array but not parsing it yet */ @@ -849,7 +942,7 @@ dissect_someip_sd_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void /* check, if enough bytes are left for optionsarray */ if (!tvb_bytes_exist(tvb, offset, length_optionsarray)) { length_optionsarray = tvb_captured_length_remaining(tvb, offset); - expert_add_info(pinfo, ti, &ef_someipsd_message_truncated); + expert_add_info(pinfo, ti, &ei_someipsd_message_truncated); proto_item_append_text(ti, " (truncated!)"); } @@ -861,7 +954,7 @@ dissect_someip_sd_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void dissect_someip_sd_pdu_options(tvb, pinfo, someip_sd_options_tree, ti, offset, length_optionsarray, option_ports, &option_count); offset += length_optionsarray; } else { - expert_add_info(pinfo, ti, &ef_someipsd_message_truncated); + expert_add_info(pinfo, ti, &ei_someipsd_message_truncated); } } } @@ -870,7 +963,7 @@ dissect_someip_sd_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void if (length_entriesarray >= SD_ENTRY_LENGTH) { offset += dissect_someip_sd_pdu_entries(tvb, pinfo, someip_sd_entries_tree, ti_sd_entries, offset_entriesarray, length_entriesarray, option_ports, option_count); } else { - expert_add_info(pinfo, ti_sd_entries, &ef_someipsd_entry_array_empty); + expert_add_info(pinfo, ti_sd_entries, &ei_someipsd_entry_array_empty); } return offset; } @@ -881,13 +974,13 @@ dissect_someip_sd_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void static void someipsd_entries_stats_tree_init(stats_tree *st) { - st_node_ip_src = stats_tree_create_node(st, st_str_ip_src, 0, STAT_DT_INT, TRUE); - stat_node_set_flags(st, st_str_ip_src, 0, FALSE, ST_FLG_SORT_TOP); - st_node_ip_dst = stats_tree_create_node(st, st_str_ip_dst, 0, STAT_DT_INT, TRUE); + st_node_ip_src = stats_tree_create_node(st, st_str_ip_src, 0, STAT_DT_INT, true); + stat_node_set_flags(st, st_str_ip_src, 0, false, ST_FLG_SORT_TOP); + st_node_ip_dst = stats_tree_create_node(st, st_str_ip_dst, 0, STAT_DT_INT, true); } static void -stat_number_to_string_with_any(guint32 value, guint max, gchar *format_string, gchar *ret, size_t size_limit) { +stat_number_to_string_with_any(uint32_t value, unsigned max, char *format_string, char *ret, size_t size_limit) { if (value == max) { snprintf(ret, size_limit, "%s", "MAX"); } else { @@ -896,13 +989,13 @@ stat_number_to_string_with_any(guint32 value, guint max, gchar *format_string, g } static void -stat_create_entry_summary_string(const someip_sd_entries_tap_t *data, gchar *ret, size_t size_limit) { - gchar service_str[128]; - gchar instance_str[128]; - gchar majorver_str[128]; - gchar minorver_str[128]; - gchar eventgrp_str[128]; - gchar tmp[128]; +stat_create_entry_summary_string(const someip_sd_entries_tap_t *data, char *ret, size_t size_limit) { + char service_str[128]; + char instance_str[128]; + char majorver_str[128]; + char minorver_str[128]; + char eventgrp_str[128]; + char tmp[128]; char *service_name = someip_lookup_service_name(data->service_id); char *eventgrp_name = someip_lookup_eventgroup_name(data->service_id, data->eventgroup_id); @@ -941,72 +1034,72 @@ static tap_packet_status someipsd_entries_stats_tree_packet(stats_tree *st, packet_info *pinfo, epan_dissect_t *edt _U_, const void *p, tap_flags_t flags _U_) { DISSECTOR_ASSERT(p); const someip_sd_entries_tap_t *data = (const someip_sd_entries_tap_t *)p; - static gchar tmp_addr_str[256]; + static char tmp_addr_str[256]; snprintf(tmp_addr_str, sizeof(tmp_addr_str) - 1, "%s (%s)", address_to_str(pinfo->pool, &pinfo->net_src), address_to_name(&pinfo->net_src)); - tick_stat_node(st, st_str_ip_src, 0, FALSE); - int src_id = tick_stat_node(st, tmp_addr_str, st_node_ip_src, TRUE); + tick_stat_node(st, st_str_ip_src, 0, false); + int src_id = tick_stat_node(st, tmp_addr_str, st_node_ip_src, true); snprintf(tmp_addr_str, sizeof(tmp_addr_str) - 1, "%s (%s)", address_to_str(pinfo->pool, &pinfo->net_dst), address_to_name(&pinfo->net_dst)); - tick_stat_node(st, st_str_ip_dst, 0, FALSE); - int dst_id = tick_stat_node(st, tmp_addr_str, st_node_ip_dst, TRUE); + tick_stat_node(st, st_str_ip_dst, 0, false); + int dst_id = tick_stat_node(st, tmp_addr_str, st_node_ip_dst, true); int tmp_id; - static gchar tmp_str[128]; + static char tmp_str[128]; if (data->ttl == 0) { switch (data->entry_type) { case SD_ENTRY_STOP_OFFER_SERVICE: stat_create_entry_summary_string(data, tmp_str, sizeof(tmp_str) - 1); - tmp_id = tick_stat_node(st, "Stop Offer Service", src_id, TRUE); - tick_stat_node(st, tmp_str, tmp_id, FALSE); - tmp_id = tick_stat_node(st, "Stop Offer Service", dst_id, TRUE); - tick_stat_node(st, tmp_str, tmp_id, FALSE); + tmp_id = tick_stat_node(st, "Stop Offer Service", src_id, true); + tick_stat_node(st, tmp_str, tmp_id, false); + tmp_id = tick_stat_node(st, "Stop Offer Service", dst_id, true); + tick_stat_node(st, tmp_str, tmp_id, false); break; case SD_ENTRY_STOP_SUBSCRIBE_EVENTGROUP: stat_create_entry_summary_string(data, tmp_str, sizeof(tmp_str) - 1); - tmp_id = tick_stat_node(st, "Stop Subscribe Eventgroup", src_id, TRUE); - tick_stat_node(st, tmp_str, tmp_id, FALSE); - tmp_id = tick_stat_node(st, "Stop Subscribe Eventgroup", dst_id, TRUE); - tick_stat_node(st, tmp_str, tmp_id, FALSE); + tmp_id = tick_stat_node(st, "Stop Subscribe Eventgroup", src_id, true); + tick_stat_node(st, tmp_str, tmp_id, false); + tmp_id = tick_stat_node(st, "Stop Subscribe Eventgroup", dst_id, true); + tick_stat_node(st, tmp_str, tmp_id, false); break; case SD_ENTRY_SUBSCRIBE_EVENTGROUP_NACK: stat_create_entry_summary_string(data, tmp_str, sizeof(tmp_str) - 1); - tmp_id = tick_stat_node(st, "Subscribe Eventgroup Nack", src_id, TRUE); - tick_stat_node(st, tmp_str, tmp_id, FALSE); - tmp_id = tick_stat_node(st, "Subscribe Eventgroup Nack", dst_id, TRUE); - tick_stat_node(st, tmp_str, tmp_id, FALSE); + tmp_id = tick_stat_node(st, "Subscribe Eventgroup Nack", src_id, true); + tick_stat_node(st, tmp_str, tmp_id, false); + tmp_id = tick_stat_node(st, "Subscribe Eventgroup Nack", dst_id, true); + tick_stat_node(st, tmp_str, tmp_id, false); break; } } else { switch (data->entry_type) { case SD_ENTRY_FIND_SERVICE: stat_create_entry_summary_string(data, tmp_str, sizeof(tmp_str) - 1); - tmp_id = tick_stat_node(st, "Find Service", src_id, TRUE); - tick_stat_node(st, tmp_str, tmp_id, FALSE); - tmp_id = tick_stat_node(st, "Find Service", dst_id, TRUE); - tick_stat_node(st, tmp_str, tmp_id, FALSE); + tmp_id = tick_stat_node(st, "Find Service", src_id, true); + tick_stat_node(st, tmp_str, tmp_id, false); + tmp_id = tick_stat_node(st, "Find Service", dst_id, true); + tick_stat_node(st, tmp_str, tmp_id, false); break; case SD_ENTRY_OFFER_SERVICE: stat_create_entry_summary_string(data, tmp_str, sizeof(tmp_str) - 1); - tmp_id = tick_stat_node(st, "Offer Service", src_id, TRUE); - tick_stat_node(st, tmp_str, tmp_id, FALSE); - tmp_id = tick_stat_node(st, "Offer Service", dst_id, TRUE); - tick_stat_node(st, tmp_str, tmp_id, FALSE); + tmp_id = tick_stat_node(st, "Offer Service", src_id, true); + tick_stat_node(st, tmp_str, tmp_id, false); + tmp_id = tick_stat_node(st, "Offer Service", dst_id, true); + tick_stat_node(st, tmp_str, tmp_id, false); break; case SD_ENTRY_SUBSCRIBE_EVENTGROUP: stat_create_entry_summary_string(data, tmp_str, sizeof(tmp_str) - 1); - tmp_id = tick_stat_node(st, "Subscribe Eventgroup", src_id, TRUE); - tick_stat_node(st, tmp_str, tmp_id, FALSE); - tmp_id = tick_stat_node(st, "Subscribe Eventgroup", dst_id, TRUE); - tick_stat_node(st, tmp_str, tmp_id, FALSE); + tmp_id = tick_stat_node(st, "Subscribe Eventgroup", src_id, true); + tick_stat_node(st, tmp_str, tmp_id, false); + tmp_id = tick_stat_node(st, "Subscribe Eventgroup", dst_id, true); + tick_stat_node(st, tmp_str, tmp_id, false); break; case SD_ENTRY_SUBSCRIBE_EVENTGROUP_ACK: stat_create_entry_summary_string(data, tmp_str, sizeof(tmp_str) - 1); - tmp_id = tick_stat_node(st, "Subscribe Eventgroup Ack", src_id, TRUE); - tick_stat_node(st, tmp_str, tmp_id, FALSE); - tmp_id = tick_stat_node(st, "Subscribe Eventgroup Ack", dst_id, TRUE); - tick_stat_node(st, tmp_str, tmp_id, FALSE); + tmp_id = tick_stat_node(st, "Subscribe Eventgroup Ack", src_id, true); + tick_stat_node(st, tmp_str, tmp_id, false); + tmp_id = tick_stat_node(st, "Subscribe Eventgroup Ack", dst_id, true); + tick_stat_node(st, tmp_str, tmp_id, false); break; } } @@ -1068,25 +1161,25 @@ proto_register_someip_sd(void) { { &hf_someip_sd_entry_serviceid, { "Service ID", "someipsd.entry.serviceid", - FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }}, + FT_UINT16, BASE_HEX | BASE_SPECIAL_VALS, VALS(sd_serviceid_vs), 0x0, NULL, HFILL }}, { &hf_someip_sd_entry_servicename, { "Service Name", "someipsd.entry.servicename", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }}, { &hf_someip_sd_entry_instanceid, { "Instance ID", "someipsd.entry.instanceid", - FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }}, + FT_UINT16, BASE_HEX | BASE_SPECIAL_VALS, VALS(sd_instanceid_vs), 0x0, NULL, HFILL }}, { &hf_someip_sd_entry_majorver, { "Major Version", "someipsd.entry.majorver", - FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }}, + FT_UINT8, BASE_DEC | BASE_SPECIAL_VALS, VALS(sd_majorversion_vs), 0x0, NULL, HFILL }}, { &hf_someip_sd_entry_ttl, { "TTL", "someipsd.entry.ttl", FT_UINT24, BASE_DEC, NULL, 0x0, NULL, HFILL }}, { &hf_someip_sd_entry_minorver, { "Minor Version", "someipsd.entry.minorver", - FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }}, + FT_UINT32, BASE_DEC | BASE_SPECIAL_VALS, VALS(sd_minorversion_vs), 0x0, NULL, HFILL }}, { &hf_someip_sd_entry_eventgroupid, { "Eventgroup ID", "someipsd.entry.eventgroupid", - FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }}, + FT_UINT16, BASE_HEX | BASE_SPECIAL_VALS, VALS(sd_eventgroupid_vs), 0x0, NULL, HFILL }}, { &hf_someip_sd_entry_eventgroupname, { "Eventgroup Name", "someipsd.entry.eventgroupname", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }}, @@ -1174,7 +1267,7 @@ proto_register_someip_sd(void) { FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL }}, }; - static gint *ett_sd[] = { + static int *ett_sd[] = { &ett_someip_sd, &ett_someip_sd_flags, &ett_someip_sd_entries, @@ -1185,16 +1278,18 @@ proto_register_someip_sd(void) { }; static ei_register_info ei_sd[] = { - { &ef_someipsd_message_truncated,{ "someipsd.message_truncated", PI_MALFORMED, PI_ERROR, "SOME/IP-SD Truncated message!", EXPFILL } }, - { &ef_someipsd_entry_array_malformed,{ "someipsd.entry_array_malformed", PI_MALFORMED, PI_ERROR, "SOME/IP-SD Entry Array length not multiple of 16 bytes!", EXPFILL } }, - { &ef_someipsd_entry_array_empty,{ "someipsd.entry_array_empty", PI_MALFORMED, PI_ERROR, "SOME/IP-SD Empty Entry Array!", EXPFILL } }, - { &ef_someipsd_entry_unknown,{ "someipsd.entry_unknown", PI_MALFORMED, PI_WARN, "SOME/IP-SD Unknown Entry!", EXPFILL } }, - { &ef_someipsd_option_array_truncated,{ "someipsd.option_array_truncated", PI_MALFORMED, PI_ERROR, "SOME/IP-SD Option Array truncated!", EXPFILL } }, - { &ef_someipsd_option_array_bytes_left,{ "someipsd.option_array_bytes_left", PI_MALFORMED, PI_WARN, "SOME/IP-SD Option Array bytes left after parsing options!", EXPFILL } }, - { &ef_someipsd_option_unknown,{ "someipsd.option_unknown", PI_MALFORMED, PI_WARN, "SOME/IP-SD Unknown Option!", EXPFILL } }, - { &ef_someipsd_option_wrong_length,{ "someipsd.option_wrong_length", PI_MALFORMED, PI_ERROR, "SOME/IP-SD Option length is incorrect!", EXPFILL } }, - { &ef_someipsd_L4_protocol_unsupported,{ "someipsd.L4_protocol_unsupported", PI_MALFORMED, PI_ERROR, "SOME/IP-SD Unsupported Layer 4 Protocol!", EXPFILL } }, - { &ef_someipsd_config_string_malformed,{ "someipsd.config_string_malformed", PI_MALFORMED, PI_ERROR, "SOME/IP-SD Configuration String malformed!", EXPFILL } }, + { &ei_someipsd_message_truncated,{ "someipsd.message_truncated", PI_MALFORMED, PI_ERROR, "SOME/IP-SD Truncated message!", EXPFILL } }, + { &ei_someipsd_entry_array_malformed,{ "someipsd.entry_array_malformed", PI_MALFORMED, PI_ERROR, "SOME/IP-SD Entry Array length not multiple of 16 bytes!", EXPFILL } }, + { &ei_someipsd_entry_array_empty,{ "someipsd.entry_array_empty", PI_MALFORMED, PI_ERROR, "SOME/IP-SD Empty Entry Array!", EXPFILL } }, + { &ei_someipsd_entry_unknown,{ "someipsd.entry_unknown", PI_MALFORMED, PI_WARN, "SOME/IP-SD Unknown Entry!", EXPFILL } }, + { &ei_someipsd_offer_without_endpoint,{ "someipsd.offer_no_endpoints", PI_MALFORMED, PI_ERROR, "SOME/IP-SD Offer Service references no endpoints!", EXPFILL } }, + { &ei_someipsd_entry_stopsubsub,{ "someipsd.stopsub_sub", PI_PROTOCOL, PI_WARN, "SOME/IP-SD Subscribe after Stop Subscribe!", EXPFILL } }, + { &ei_someipsd_option_array_truncated,{ "someipsd.option_array_truncated", PI_MALFORMED, PI_ERROR, "SOME/IP-SD Option Array truncated!", EXPFILL } }, + { &ei_someipsd_option_array_bytes_left,{ "someipsd.option_array_bytes_left", PI_MALFORMED, PI_WARN, "SOME/IP-SD Option Array bytes left after parsing options!", EXPFILL } }, + { &ei_someipsd_option_unknown,{ "someipsd.option_unknown", PI_MALFORMED, PI_WARN, "SOME/IP-SD Unknown Option!", EXPFILL } }, + { &ei_someipsd_option_wrong_length,{ "someipsd.option_wrong_length", PI_MALFORMED, PI_ERROR, "SOME/IP-SD Option length is incorrect!", EXPFILL } }, + { &ei_someipsd_L4_protocol_unsupported,{ "someipsd.L4_protocol_unsupported", PI_MALFORMED, PI_ERROR, "SOME/IP-SD Unsupported Layer 4 Protocol!", EXPFILL } }, + { &ei_someipsd_config_string_malformed,{ "someipsd.config_string_malformed", PI_MALFORMED, PI_ERROR, "SOME/IP-SD Configuration String malformed!", EXPFILL } }, }; /* Register Protocol, Fields, ETTs, Expert Info, Taps, Dissector */ |