diff options
Diffstat (limited to 'epan/dissectors/packet-lwm.c')
-rw-r--r-- | epan/dissectors/packet-lwm.c | 106 |
1 files changed, 58 insertions, 48 deletions
diff --git a/epan/dissectors/packet-lwm.c b/epan/dissectors/packet-lwm.c index 0630c90d29..8fa9d7e04c 100644 --- a/epan/dissectors/packet-lwm.c +++ b/epan/dissectors/packet-lwm.c @@ -96,46 +96,46 @@ static int dissect_lwm_cmd_frame_route_req (tvbuff_t *, packet_info *, proto_ static int dissect_lwm_cmd_frame_route_reply (tvbuff_t *, packet_info *, proto_tree *); /* Initialize protocol and registered fields. */ -static int proto_lwm = -1; - -static int hf_lwm_fcf = -1; -static int hf_lwm_fcf_ack_req = -1; -static int hf_lwm_fcf_security = -1; -static int hf_lwm_fcf_linklocal = -1; -static int hf_lwm_fcf_multicast = -1; -static int hf_lwm_fcf_reserved = -1; -static int hf_lwm_seq = -1; -static int hf_lwm_src_addr = -1; -static int hf_lwm_dst_addr = -1; -static int hf_lwm_src_endp = -1; -static int hf_lwm_dst_endp = -1; -static int hf_lwm_multi_nmrad = -1; -static int hf_lwm_multi_mnmrad = -1; -static int hf_lwm_multi_mrad = -1; -static int hf_lwm_multi_mmrad = -1; -static int hf_lwm_mic = -1; -static int hf_lwm_cmd = -1; -static int hf_lwm_cmd_seq = -1; -static int hf_lwm_cmd_cm = -1; -static int hf_lwm_cmd_route_src = -1; -static int hf_lwm_cmd_route_dst = -1; -static int hf_lwm_cmd_route_multi = -1; -static int hf_lwm_cmd_linkquality = -1; -static int hf_lwm_cmd_forwlinkquality = -1; -static int hf_lwm_cmd_revlinkquality = -1; +static int proto_lwm; + +static int hf_lwm_fcf; +static int hf_lwm_fcf_ack_req; +static int hf_lwm_fcf_security; +static int hf_lwm_fcf_linklocal; +static int hf_lwm_fcf_multicast; +static int hf_lwm_fcf_reserved; +static int hf_lwm_seq; +static int hf_lwm_src_addr; +static int hf_lwm_dst_addr; +static int hf_lwm_src_endp; +static int hf_lwm_dst_endp; +static int hf_lwm_multi_nmrad; +static int hf_lwm_multi_mnmrad; +static int hf_lwm_multi_mrad; +static int hf_lwm_multi_mmrad; +static int hf_lwm_mic; +static int hf_lwm_cmd; +static int hf_lwm_cmd_seq; +static int hf_lwm_cmd_cm; +static int hf_lwm_cmd_route_src; +static int hf_lwm_cmd_route_dst; +static int hf_lwm_cmd_route_multi; +static int hf_lwm_cmd_linkquality; +static int hf_lwm_cmd_forwlinkquality; +static int hf_lwm_cmd_revlinkquality; /* Initialize protocol subtrees. */ -static gint ett_lwm = -1; -static gint ett_lwm_fcf = -1; -static gint ett_lwm_cmd_tree = -1; -static gint ett_lwm_multi_tree = -1; - -static expert_field ei_lwm_mal_error = EI_INIT; -static expert_field ei_lwm_n_src_broad = EI_INIT; -static expert_field ei_lwm_mismatch_endp = EI_INIT; -static expert_field ei_lwm_empty_payload = EI_INIT; -static expert_field ei_lwm_no_decryption_key = EI_INIT; -static expert_field ei_lwm_decryption_failed = EI_INIT; +static gint ett_lwm; +static gint ett_lwm_fcf; +static gint ett_lwm_cmd_tree; +static gint ett_lwm_multi_tree; + +static expert_field ei_lwm_mal_error; +static expert_field ei_lwm_n_src_broad; +static expert_field ei_lwm_mismatch_endp; +static expert_field ei_lwm_empty_payload; +static expert_field ei_lwm_no_decryption_key; +static expert_field ei_lwm_decryption_failed; static dissector_handle_t lwm_handle; @@ -461,7 +461,13 @@ static int dissect_lwm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void for (i = 0; i < block; i++) { text_dec[i] ^= vector[i]; + /* + * GCC 12.2.0 gives a false positive Wstringop-overflow warning. + * https://gitlab.com/wireshark/wireshark/-/issues/18383 + */ + DIAG_OFF_STRINGOP_OVERFLOW() vector[i] ^= text_dec[i]; + DIAG_ON_STRINGOP_OVERFLOW() } payload_offset += block; @@ -788,19 +794,19 @@ void proto_register_lwm(void) /*Multicast header*/ { &hf_lwm_multi_nmrad, - { "Non-member Radius", "lwm.multi_nmrad", FT_UINT8, BASE_DEC, NULL, 0x0, + { "Non-member Radius", "lwm.multi_nmrad", FT_UINT16, BASE_DEC, NULL, 0x0, "Specifies remaining radius (number of hops) for Non-members of multicast group.", HFILL }}, { &hf_lwm_multi_mnmrad, - { "Maximum Non-member Radius", "lwm.multi_mnmrad", FT_UINT8, BASE_DEC, NULL, 0x0, + { "Maximum Non-member Radius", "lwm.multi_mnmrad", FT_UINT16, BASE_DEC, NULL, 0x0, "Specifies maximum radius (number of hops) for Non-members of multicast group.", HFILL }}, { &hf_lwm_multi_mrad, - { "Member Radius", "lwm.multi_mrad", FT_UINT8, BASE_DEC, NULL, 0x0, + { "Member Radius", "lwm.multi_mrad", FT_UINT16, BASE_DEC, NULL, 0x0, "Specifies remaining radius (number of hops) for Members of multicast group.", HFILL }}, { &hf_lwm_multi_mmrad, - { "Maximum Member Radius", "lwm.multi_mmrad", FT_UINT8, BASE_DEC, NULL, 0x0, + { "Maximum Member Radius", "lwm.multi_mmrad", FT_UINT16, BASE_DEC, NULL, 0x0, "Specifies maximum radius (number of hops) for Members of multicast group.", HFILL }}, @@ -905,7 +911,8 @@ void proto_register_lwm(void) * proto_reg_handoff_lwm * DESCRIPTION * Registers the lwm dissector with Wireshark. - * Will be called during Wireshark startup. + * Will be called during Wireshark startup, and whenever + * preferences are changed. * PARAMETERS * none * RETURNS @@ -914,9 +921,17 @@ void proto_register_lwm(void) */ void proto_reg_handoff_lwm(void) { + static gboolean initialized = FALSE; GByteArray *bytes; gboolean res; + if (!initialized) { + /* Register our dissector with IEEE 802.15.4 */ + dissector_add_for_decode_as(IEEE802154_PROTOABBREV_WPAN_PANID, lwm_handle); + heur_dissector_add(IEEE802154_PROTOABBREV_WPAN, dissect_lwm_heur, "Lightweight Mesh over IEEE 802.15.4", "lwm_wlan", proto_lwm, HEURISTIC_ENABLE); + + initialized = TRUE; + } /* Convert key to raw bytes */ bytes = g_byte_array_new(); res = hex_str_to_bytes(lwmes_key_str, bytes, FALSE); @@ -926,11 +941,6 @@ void proto_reg_handoff_lwm(void) } g_byte_array_free(bytes, TRUE); - - /* Register our dissector with IEEE 802.15.4 */ - dissector_add_for_decode_as(IEEE802154_PROTOABBREV_WPAN_PANID, lwm_handle); - heur_dissector_add(IEEE802154_PROTOABBREV_WPAN, dissect_lwm_heur, "Lightweight Mesh over IEEE 802.15.4", "lwm_wlan", proto_lwm, HEURISTIC_ENABLE); - } /* proto_reg_handoff_lwm */ /* |