aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-solaredge.c
diff options
context:
space:
mode:
Diffstat (limited to 'epan/dissectors/packet-solaredge.c')
-rw-r--r--epan/dissectors/packet-solaredge.c118
1 files changed, 59 insertions, 59 deletions
diff --git a/epan/dissectors/packet-solaredge.c b/epan/dissectors/packet-solaredge.c
index 852677dc38..69394f151f 100644
--- a/epan/dissectors/packet-solaredge.c
+++ b/epan/dissectors/packet-solaredge.c
@@ -17,7 +17,6 @@
#include <epan/prefs.h>
#include <epan/strutil.h>
#include <range.h>
-#include <wiretap/wtap.h>
#include <wsutil/crc16-plain.h>
#include <wsutil/pint.h>
#include <wsutil/wsgcrypt.h>
@@ -478,70 +477,72 @@ typedef struct solaredge_conversion_data {
void proto_reg_handoff_solaredge(void);
void proto_register_solaredge(void);
+static dissector_handle_t solaredge_handle;
+
static gboolean global_show_unknown_fields = TRUE;
-static expert_field ei_solaredge_invalid_length = EI_INIT;
-static expert_field ei_solaredge_invalid_crc = EI_INIT;
+static expert_field ei_solaredge_invalid_length;
+static expert_field ei_solaredge_invalid_crc;
-static int proto_solaredge = -1;
+static int proto_solaredge;
-static int hf_solaredge_length_type = -1;
-static int hf_solaredge_length_inverse_type = -1;
-static int hf_solaredge_sequence_number_type = -1;
-static int hf_solaredge_source_address_type = -1;
-static int hf_solaredge_destination_address_type = -1;
-static int hf_solaredge_command_type = -1;
-static int hf_solaredge_crc_type = -1;
-static int hf_solaredge_crc_status_type = -1;
+static int hf_solaredge_length_type;
+static int hf_solaredge_length_inverse_type;
+static int hf_solaredge_sequence_number_type;
+static int hf_solaredge_source_address_type;
+static int hf_solaredge_destination_address_type;
+static int hf_solaredge_command_type;
+static int hf_solaredge_crc_type;
+static int hf_solaredge_crc_status_type;
-static int hf_solaredge_payload_type = -1;
+static int hf_solaredge_payload_type;
-static int hf_solaredge_session_key_type = -1;
+static int hf_solaredge_session_key_type;
-static int hf_solaredge_post_type = -1;
-static int hf_solaredge_post_device_type = -1;
-static int hf_solaredge_post_device_type_type = -1;
-static int hf_solaredge_post_device_id_type = -1;
-static int hf_solaredge_post_length_type = -1;
+static int hf_solaredge_post_type;
+static int hf_solaredge_post_device_type;
+static int hf_solaredge_post_device_type_type;
+static int hf_solaredge_post_device_id_type;
+static int hf_solaredge_post_length_type;
-static int hf_solaredge_post_padding_uint32_type = -1;
-static int hf_solaredge_post_padding_float_type = -1;
+static int hf_solaredge_post_padding_uint32_type;
+static int hf_solaredge_post_padding_float_type;
-static int hf_solaredge_post_singlephase_inverter_timestamp_type = -1;
-static int hf_solaredge_post_singlephase_inverter_uptime_type = -1;
-static int hf_solaredge_post_singlephase_inverter_interval_type = -1;
-static int hf_solaredge_post_singlephase_inverter_temperature_type = -1;
-static int hf_solaredge_post_singlephase_inverter_energy_day_type = -1;
-static int hf_solaredge_post_singlephase_inverter_energy_interval_type = -1;
-static int hf_solaredge_post_singlephase_inverter_ac_voltage_type = -1;
-static int hf_solaredge_post_singlephase_inverter_ac_current_type = -1;
-static int hf_solaredge_post_singlephase_inverter_ac_frequency_type = -1;
-static int hf_solaredge_post_singlephase_inverter_dc_voltage_type = -1;
-static int hf_solaredge_post_singlephase_inverter_energy_total_type = -1;
-static int hf_solaredge_post_singlephase_inverter_power_max_type = -1;
-static int hf_solaredge_post_singlephase_inverter_ac_power_type = -1;
+static int hf_solaredge_post_singlephase_inverter_timestamp_type;
+static int hf_solaredge_post_singlephase_inverter_uptime_type;
+static int hf_solaredge_post_singlephase_inverter_interval_type;
+static int hf_solaredge_post_singlephase_inverter_temperature_type;
+static int hf_solaredge_post_singlephase_inverter_energy_day_type;
+static int hf_solaredge_post_singlephase_inverter_energy_interval_type;
+static int hf_solaredge_post_singlephase_inverter_ac_voltage_type;
+static int hf_solaredge_post_singlephase_inverter_ac_current_type;
+static int hf_solaredge_post_singlephase_inverter_ac_frequency_type;
+static int hf_solaredge_post_singlephase_inverter_dc_voltage_type;
+static int hf_solaredge_post_singlephase_inverter_energy_total_type;
+static int hf_solaredge_post_singlephase_inverter_power_max_type;
+static int hf_solaredge_post_singlephase_inverter_ac_power_type;
-static int hf_solaredge_post_optimizer_inverter_type = -1;
-static int hf_solaredge_post_optimizer_uptime_type = -1;
-static int hf_solaredge_post_optimizer_dc_current_panel_type = -1;
-static int hf_solaredge_post_optimizer_timestamp_type = -1;
-static int hf_solaredge_post_optimizer_uptime_short_type = -1;
-static int hf_solaredge_post_optimizer_dc_voltage_panel_type = -1;
-static int hf_solaredge_post_optimizer_dc_voltage_optimzer_type = -1;
-static int hf_solaredge_post_optimizer_dc_current_optimzer_type = -1;
-static int hf_solaredge_post_optimizer_energy_day_type = -1;
-static int hf_solaredge_post_optimizer_temperature_type = -1;
+static int hf_solaredge_post_optimizer_inverter_type;
+static int hf_solaredge_post_optimizer_uptime_type;
+static int hf_solaredge_post_optimizer_dc_current_panel_type;
+static int hf_solaredge_post_optimizer_timestamp_type;
+static int hf_solaredge_post_optimizer_uptime_short_type;
+static int hf_solaredge_post_optimizer_dc_voltage_panel_type;
+static int hf_solaredge_post_optimizer_dc_voltage_optimzer_type;
+static int hf_solaredge_post_optimizer_dc_current_optimzer_type;
+static int hf_solaredge_post_optimizer_energy_day_type;
+static int hf_solaredge_post_optimizer_temperature_type;
-static int hf_solaredge_post_event_timestamp_type = -1;
-static int hf_solaredge_post_event_type_type = -1;
-static int hf_solaredge_post_event_event_start_timestamp_type = -1;
-static int hf_solaredge_post_event_event_timezone_offset_type = -1;
-static int hf_solaredge_post_event_event_end_timestamp_type = -1;
+static int hf_solaredge_post_event_timestamp_type;
+static int hf_solaredge_post_event_type_type;
+static int hf_solaredge_post_event_event_start_timestamp_type;
+static int hf_solaredge_post_event_event_timezone_offset_type;
+static int hf_solaredge_post_event_event_end_timestamp_type;
-static gint ett_solaredge_packet = -1;
-static gint ett_solaredge_packet_decrypted = -1;
-static gint ett_solaredge_packet_post = -1;
-static gint ett_solaredge_packet_post_device = -1;
+static gint ett_solaredge_packet;
+static gint ett_solaredge_packet_decrypted;
+static gint ett_solaredge_packet_post;
+static gint ett_solaredge_packet_post_device;
static const value_string solaredge_packet_commandtypes[] = {
{ SOLAREDGE_COMMAND_PARAMS_RESET, "PARAMS_RESET" },
@@ -1273,11 +1274,11 @@ dissect_solaredge_recursive(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree
header.command_type = tvb_get_guint16(tvb, current_offset, ENC_LITTLE_ENDIAN);
proto_tree_add_item(solaredge_header_tree, hf_solaredge_command_type, tvb, current_offset, 2, ENC_LITTLE_ENDIAN);
current_offset += 2;
- col_append_str(pinfo->cinfo, COL_INFO, val_to_str(header.command_type, solaredge_packet_commandtypes,"Unknown command"));
+ col_append_str(pinfo->cinfo, COL_INFO, val_to_str_const(header.command_type, solaredge_packet_commandtypes, "Unknown command"));
switch (header.command_type) {
case SOLAREDGE_COMMAND_MISC_ENCRYPTED:
- proto_tree_add_item(solaredge_header_tree, hf_solaredge_payload_type, tvb, current_offset, header.length, BASE_NONE);
+ proto_tree_add_item(solaredge_header_tree, hf_solaredge_payload_type, tvb, current_offset, header.length, ENC_NA);
conv_data = (t_solaredge_conversion_data *)conversation_get_proto_data(conv, proto_solaredge);
if ((conv_data != NULL) && (conv_data->session_key_found == TRUE)) {
guint8 *decrypted_buffer = (guint8*)wmem_alloc(pinfo->pool, header.length);
@@ -1296,7 +1297,7 @@ dissect_solaredge_recursive(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree
dissect_solaredge_devicedata(tvb, pinfo, solaredge_payload_tree, current_offset, header.length);
break;
case SOLAREDGE_COMMAND_SERVER_SET_KEY:
- proto_tree_add_item(solaredge_header_tree, hf_solaredge_session_key_type, tvb, current_offset, header.length, BASE_NONE);
+ proto_tree_add_item(solaredge_header_tree, hf_solaredge_session_key_type, tvb, current_offset, header.length, ENC_NA);
if (!gcry_cipher_open(&cipher_hd_system, GCRY_CIPHER_AES128, GCRY_CIPHER_MODE_ECB, 0)) {
/* Load the system key to generate session key */
system_key = g_byte_array_new();
@@ -1358,8 +1359,6 @@ dissect_solaredge(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree _U_, void
void
proto_reg_handoff_solaredge(void)
{
- static dissector_handle_t solaredge_handle;
- solaredge_handle = create_dissector_handle(dissect_solaredge, proto_solaredge);
dissector_add_for_decode_as("tcp.port", solaredge_handle);
}
@@ -1659,8 +1658,9 @@ proto_register_solaredge(void)
"SolarEdge",
"solaredge"
);
+ solaredge_handle = register_dissector("solaredge", dissect_solaredge, proto_solaredge);
- module_t * module_solaredge = prefs_register_protocol(proto_solaredge, proto_reg_handoff_solaredge);
+ module_t * module_solaredge = prefs_register_protocol(proto_solaredge, NULL);
prefs_register_bool_preference(module_solaredge, "unknown", "Show unknown fields", "Show unidentified fields (\"padding\") in packet dissections", &global_show_unknown_fields);
prefs_register_string_preference(module_solaredge, "system_encryption_key", "System encryption key", "Inverter system encryption key", &global_system_encryption_key);