summaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-lorawan.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-19 04:14:26 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-19 04:14:26 +0000
commitc4e8a3222648fcf22ca207f1815ebbf7cd144eeb (patch)
tree93d5c6aa93d9987680dd1adad5685e2ad698f223 /epan/dissectors/packet-lorawan.c
parentAdding upstream version 4.2.6. (diff)
downloadwireshark-upstream.tar.xz
wireshark-upstream.zip
Adding upstream version 4.4.0.upstream/4.4.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'epan/dissectors/packet-lorawan.c')
-rw-r--r--epan/dissectors/packet-lorawan.c487
1 files changed, 246 insertions, 241 deletions
diff --git a/epan/dissectors/packet-lorawan.c b/epan/dissectors/packet-lorawan.c
index dd0d0d7b..ee06de5f 100644
--- a/epan/dissectors/packet-lorawan.c
+++ b/epan/dissectors/packet-lorawan.c
@@ -19,6 +19,9 @@
#include <epan/uat.h>
#include <epan/strutil.h>
#include <epan/crc16-tvb.h> /* For CRC verification */
+#include <epan/unit_strings.h>
+
+#include <wsutil/array.h>
#include <wsutil/wsgcrypt.h>
void proto_reg_handoff_lorawan(void);
@@ -26,107 +29,107 @@ void proto_register_lorawan(void);
static dissector_handle_t lorawan_handle;
-static int proto_lorawan = -1;
-static int hf_lorawan_msgtype_type = -1;
-static int hf_lorawan_mac_header_type = -1;
-static int hf_lorawan_mac_header_ftype_type = -1;
-static int hf_lorawan_mac_header_rfu_type = -1;
-static int hf_lorawan_mac_header_major_type = -1;
-static int hf_lorawan_mac_commands_type = -1;
-static int hf_lorawan_mac_command_uplink_type = -1;
-static int hf_lorawan_mac_command_downlink_type = -1;
-static int hf_lorawan_mac_command_down_link_check_ans_type = -1;
-static int hf_lorawan_mac_command_down_link_check_ans_margin_type = -1;
-static int hf_lorawan_mac_command_down_link_check_ans_gwcnt_type = -1;
-static int hf_lorawan_mac_command_down_link_adr_req_datarate_type = -1;
-static int hf_lorawan_mac_command_down_link_adr_req_txpower_type = -1;
-static int hf_lorawan_mac_command_down_link_adr_req_channel_type = -1;
-static int hf_lorawan_mac_command_down_link_adr_req_channel1_type = -1;
-static int hf_lorawan_mac_command_down_link_adr_req_channel2_type = -1;
-static int hf_lorawan_mac_command_down_link_adr_req_channel3_type = -1;
-static int hf_lorawan_mac_command_down_link_adr_req_channel4_type = -1;
-static int hf_lorawan_mac_command_down_link_adr_req_channel5_type = -1;
-static int hf_lorawan_mac_command_down_link_adr_req_channel6_type = -1;
-static int hf_lorawan_mac_command_down_link_adr_req_channel7_type = -1;
-static int hf_lorawan_mac_command_down_link_adr_req_channel8_type = -1;
-static int hf_lorawan_mac_command_down_link_adr_req_channel9_type = -1;
-static int hf_lorawan_mac_command_down_link_adr_req_channel10_type = -1;
-static int hf_lorawan_mac_command_down_link_adr_req_channel11_type = -1;
-static int hf_lorawan_mac_command_down_link_adr_req_channel12_type = -1;
-static int hf_lorawan_mac_command_down_link_adr_req_channel13_type = -1;
-static int hf_lorawan_mac_command_down_link_adr_req_channel14_type = -1;
-static int hf_lorawan_mac_command_down_link_adr_req_channel15_type = -1;
-static int hf_lorawan_mac_command_down_link_adr_req_channel16_type = -1;
-static int hf_lorawan_mac_command_down_link_adr_req_channel_mask_control_type = -1;
-static int hf_lorawan_mac_command_down_link_adr_req_repetitions_type = -1;
-static int hf_lorawan_mac_command_up_link_adr_ans_txpower_type = -1;
-static int hf_lorawan_mac_command_up_link_adr_ans_datarate_type = -1;
-static int hf_lorawan_mac_command_up_link_adr_ans_channel_mask_type = -1;
-static int hf_lorawan_mac_command_down_dutycycle_type = -1;
-static int hf_lorawan_mac_command_down_rx_setup_req_rx1droffset_type = -1;
-static int hf_lorawan_mac_command_down_rx_setup_req_rx2datarate_type = -1;
-static int hf_lorawan_mac_command_down_rx_setup_req_frequency_type = -1;
-static int hf_lorawan_mac_command_up_rx_setup_ans_type = -1;
-static int hf_lorawan_mac_command_up_rx_setup_ans_rx1droffset_type = -1;
-static int hf_lorawan_mac_command_up_rx_setup_ans_rx2datarate_type = -1;
-static int hf_lorawan_mac_command_up_rx_setup_ans_frequency_type = -1;
-static int hf_lorawan_mac_command_up_device_status_ans_battery_type = -1;
-static int hf_lorawan_mac_command_up_device_status_ans_margin_type = -1;
-static int hf_lorawan_mac_command_down_new_channel_req_index_type = -1;
-static int hf_lorawan_mac_command_down_new_channel_req_frequency_type = -1;
-static int hf_lorawan_mac_command_down_new_channel_req_drrange_max_type = -1;
-static int hf_lorawan_mac_command_down_new_channel_req_drrange_min_type = -1;
-static int hf_lorawan_mac_command_up_new_channel_ans_type = -1;
-static int hf_lorawan_mac_command_up_new_channel_ans_datarate_type = -1;
-static int hf_lorawan_mac_command_up_new_channel_ans_frequency_type = -1;
-static int hf_lorawan_mac_command_down_rx_timing_req_delay_type = -1;
-static int hf_lorawan_mac_command_up_di_channel_ans_type = -1;
-static int hf_lorawan_mac_command_up_ping_slot_info_req_type = -1;
-static int hf_lorawan_mac_command_up_ping_slot_channel_ans_type = -1;
-static int hf_lorawan_mac_command_up_beacon_freq_ans_type = -1;
-static int hf_lorawan_mac_command_down_tx_param_setup_req_type = -1;
-static int hf_lorawan_mac_command_down_di_channel_req_type = -1;
-static int hf_lorawan_mac_command_down_device_time_ans_type = -1;
-static int hf_lorawan_mac_command_down_ping_slot_channel_req_type = -1;
-static int hf_lorawan_mac_command_down_beacon_freq_req_type = -1;
-static int hf_lorawan_join_request_type = -1;
-static int hf_lorawan_join_request_joineui_type = -1;
-static int hf_lorawan_join_request_deveui_type = -1;
-static int hf_lorawan_join_request_devnonce_type = -1;
-static int hf_lorawan_join_accept_type = -1;
-static int hf_lorawan_join_accept_joinnonce_type = -1;
-static int hf_lorawan_join_accept_netid_type = -1;
-static int hf_lorawan_join_accept_devaddr_type = -1;
-static int hf_lorawan_join_accept_dlsettings_type = -1;
-static int hf_lorawan_join_accept_dlsettings_rx1droffset_type = -1;
-static int hf_lorawan_join_accept_dlsettings_rx2dr_type = -1;
-static int hf_lorawan_join_accept_rxdelay_type = -1;
-static int hf_lorawan_join_accept_cflist_type = -1;
-static int hf_lorawan_frame_header_type = -1;
-static int hf_lorawan_frame_header_address_type = -1;
-static int hf_lorawan_frame_header_frame_control_adr_type = -1;
-static int hf_lorawan_frame_header_frame_control_adrackreq_type = -1;
-static int hf_lorawan_frame_header_frame_control_ack_type = -1;
-static int hf_lorawan_frame_header_frame_control_fpending_type = -1;
-static int hf_lorawan_frame_header_frame_control_foptslen_type = -1;
-static int hf_lorawan_frame_header_frame_control_type = -1;
-static int hf_lorawan_frame_header_frame_counter_type = -1;
-static int hf_lorawan_frame_fport_type = -1;
-static int hf_lorawan_frame_payload_type = -1;
-static int hf_lorawan_frame_payload_decrypted_type = -1;
-static int hf_lorawan_mic_type = -1;
-static int hf_lorawan_mic_status_type = -1;
-static int hf_lorawan_beacon_rfu1_type = -1;
-static int hf_lorawan_beacon_time_type = -1;
-static int hf_lorawan_beacon_crc1_type = -1;
-static int hf_lorawan_beacon_crc1_status_type = -1;
-static int hf_lorawan_beacon_gwspecific_type = -1;
-static int hf_lorawan_beacon_gwspecific_infodesc_type = -1;
-static int hf_lorawan_beacon_gwspecific_lat_type = -1;
-static int hf_lorawan_beacon_gwspecific_lng_type = -1;
-static int hf_lorawan_beacon_rfu2_type = -1;
-static int hf_lorawan_beacon_crc2_type = -1;
-static int hf_lorawan_beacon_crc2_status_type = -1;
+static int proto_lorawan;
+static int hf_lorawan_msgtype_type;
+static int hf_lorawan_mac_header_type;
+static int hf_lorawan_mac_header_ftype_type;
+static int hf_lorawan_mac_header_rfu_type;
+static int hf_lorawan_mac_header_major_type;
+static int hf_lorawan_mac_commands_type;
+static int hf_lorawan_mac_command_uplink_type;
+static int hf_lorawan_mac_command_downlink_type;
+static int hf_lorawan_mac_command_down_link_check_ans_type;
+static int hf_lorawan_mac_command_down_link_check_ans_margin_type;
+static int hf_lorawan_mac_command_down_link_check_ans_gwcnt_type;
+static int hf_lorawan_mac_command_down_link_adr_req_datarate_type;
+static int hf_lorawan_mac_command_down_link_adr_req_txpower_type;
+static int hf_lorawan_mac_command_down_link_adr_req_channel_type;
+static int hf_lorawan_mac_command_down_link_adr_req_channel1_type;
+static int hf_lorawan_mac_command_down_link_adr_req_channel2_type;
+static int hf_lorawan_mac_command_down_link_adr_req_channel3_type;
+static int hf_lorawan_mac_command_down_link_adr_req_channel4_type;
+static int hf_lorawan_mac_command_down_link_adr_req_channel5_type;
+static int hf_lorawan_mac_command_down_link_adr_req_channel6_type;
+static int hf_lorawan_mac_command_down_link_adr_req_channel7_type;
+static int hf_lorawan_mac_command_down_link_adr_req_channel8_type;
+static int hf_lorawan_mac_command_down_link_adr_req_channel9_type;
+static int hf_lorawan_mac_command_down_link_adr_req_channel10_type;
+static int hf_lorawan_mac_command_down_link_adr_req_channel11_type;
+static int hf_lorawan_mac_command_down_link_adr_req_channel12_type;
+static int hf_lorawan_mac_command_down_link_adr_req_channel13_type;
+static int hf_lorawan_mac_command_down_link_adr_req_channel14_type;
+static int hf_lorawan_mac_command_down_link_adr_req_channel15_type;
+static int hf_lorawan_mac_command_down_link_adr_req_channel16_type;
+static int hf_lorawan_mac_command_down_link_adr_req_channel_mask_control_type;
+static int hf_lorawan_mac_command_down_link_adr_req_repetitions_type;
+static int hf_lorawan_mac_command_up_link_adr_ans_txpower_type;
+static int hf_lorawan_mac_command_up_link_adr_ans_datarate_type;
+static int hf_lorawan_mac_command_up_link_adr_ans_channel_mask_type;
+static int hf_lorawan_mac_command_down_dutycycle_type;
+static int hf_lorawan_mac_command_down_rx_setup_req_rx1droffset_type;
+static int hf_lorawan_mac_command_down_rx_setup_req_rx2datarate_type;
+static int hf_lorawan_mac_command_down_rx_setup_req_frequency_type;
+static int hf_lorawan_mac_command_up_rx_setup_ans_type;
+static int hf_lorawan_mac_command_up_rx_setup_ans_rx1droffset_type;
+static int hf_lorawan_mac_command_up_rx_setup_ans_rx2datarate_type;
+static int hf_lorawan_mac_command_up_rx_setup_ans_frequency_type;
+static int hf_lorawan_mac_command_up_device_status_ans_battery_type;
+static int hf_lorawan_mac_command_up_device_status_ans_margin_type;
+static int hf_lorawan_mac_command_down_new_channel_req_index_type;
+static int hf_lorawan_mac_command_down_new_channel_req_frequency_type;
+static int hf_lorawan_mac_command_down_new_channel_req_drrange_max_type;
+static int hf_lorawan_mac_command_down_new_channel_req_drrange_min_type;
+static int hf_lorawan_mac_command_up_new_channel_ans_type;
+static int hf_lorawan_mac_command_up_new_channel_ans_datarate_type;
+static int hf_lorawan_mac_command_up_new_channel_ans_frequency_type;
+static int hf_lorawan_mac_command_down_rx_timing_req_delay_type;
+static int hf_lorawan_mac_command_up_di_channel_ans_type;
+static int hf_lorawan_mac_command_up_ping_slot_info_req_type;
+static int hf_lorawan_mac_command_up_ping_slot_channel_ans_type;
+static int hf_lorawan_mac_command_up_beacon_freq_ans_type;
+static int hf_lorawan_mac_command_down_tx_param_setup_req_type;
+static int hf_lorawan_mac_command_down_di_channel_req_type;
+static int hf_lorawan_mac_command_down_device_time_ans_type;
+static int hf_lorawan_mac_command_down_ping_slot_channel_req_type;
+static int hf_lorawan_mac_command_down_beacon_freq_req_type;
+static int hf_lorawan_join_request_type;
+static int hf_lorawan_join_request_joineui_type;
+static int hf_lorawan_join_request_deveui_type;
+static int hf_lorawan_join_request_devnonce_type;
+static int hf_lorawan_join_accept_type;
+static int hf_lorawan_join_accept_joinnonce_type;
+static int hf_lorawan_join_accept_netid_type;
+static int hf_lorawan_join_accept_devaddr_type;
+static int hf_lorawan_join_accept_dlsettings_type;
+static int hf_lorawan_join_accept_dlsettings_rx1droffset_type;
+static int hf_lorawan_join_accept_dlsettings_rx2dr_type;
+static int hf_lorawan_join_accept_rxdelay_type;
+static int hf_lorawan_join_accept_cflist_type;
+static int hf_lorawan_frame_header_type;
+static int hf_lorawan_frame_header_address_type;
+static int hf_lorawan_frame_header_frame_control_adr_type;
+static int hf_lorawan_frame_header_frame_control_adrackreq_type;
+static int hf_lorawan_frame_header_frame_control_ack_type;
+static int hf_lorawan_frame_header_frame_control_fpending_type;
+static int hf_lorawan_frame_header_frame_control_foptslen_type;
+static int hf_lorawan_frame_header_frame_control_type;
+static int hf_lorawan_frame_header_frame_counter_type;
+static int hf_lorawan_frame_fport_type;
+static int hf_lorawan_frame_payload_type;
+static int hf_lorawan_frame_payload_decrypted_type;
+static int hf_lorawan_mic_type;
+static int hf_lorawan_mic_status_type;
+static int hf_lorawan_beacon_rfu1_type;
+static int hf_lorawan_beacon_time_type;
+static int hf_lorawan_beacon_crc1_type;
+static int hf_lorawan_beacon_crc1_status_type;
+static int hf_lorawan_beacon_gwspecific_type;
+static int hf_lorawan_beacon_gwspecific_infodesc_type;
+static int hf_lorawan_beacon_gwspecific_lat_type;
+static int hf_lorawan_beacon_gwspecific_lng_type;
+static int hf_lorawan_beacon_rfu2_type;
+static int hf_lorawan_beacon_crc2_type;
+static int hf_lorawan_beacon_crc2_status_type;
static int * const hfx_lorawan_mac_command_link_check_ans[] = {
&hf_lorawan_mac_command_up_link_adr_ans_txpower_type,
@@ -180,22 +183,22 @@ static int * const hfx_lorawan_join_accept_dlsettings[] = {
NULL
};
-static gint ett_lorawan = -1;
-static gint ett_lorawan_mac_header = -1;
-static gint ett_lorawan_mac_commands = -1;
-static gint ett_lorawan_mac_command = -1;
-static gint ett_lorawan_mac_command_link_check_ans = -1;
-static gint ett_lorawan_mac_command_link_adr_req_channel = -1;
-static gint ett_lorawan_mac_command_rx_setup_ans = -1;
-static gint ett_lorawan_mac_command_new_channel_ans = -1;
-static gint ett_lorawan_join_request = -1;
-static gint ett_lorawan_join_accept = -1;
-static gint ett_lorawan_join_accept_dlsettings = -1;
-static gint ett_lorawan_frame_header = -1;
-static gint ett_lorawan_frame_header_control = -1;
-static gint ett_lorawan_frame_payload_decrypted = -1;
-static gint ett_lorawan_beacon = -1;
-static gint ett_lorawan_beacon_gwspecific = -1;
+static int ett_lorawan;
+static int ett_lorawan_mac_header;
+static int ett_lorawan_mac_commands;
+static int ett_lorawan_mac_command;
+static int ett_lorawan_mac_command_link_check_ans;
+static int ett_lorawan_mac_command_link_adr_req_channel;
+static int ett_lorawan_mac_command_rx_setup_ans;
+static int ett_lorawan_mac_command_new_channel_ans;
+static int ett_lorawan_join_request;
+static int ett_lorawan_join_accept;
+static int ett_lorawan_join_accept_dlsettings;
+static int ett_lorawan_frame_header;
+static int ett_lorawan_frame_header_control;
+static int ett_lorawan_frame_payload_decrypted;
+static int ett_lorawan_beacon;
+static int ett_lorawan_beacon_gwspecific;
#define LORAWAN_MAC_FTYPE_MASK 0xE0
#define LORAWAN_MAC_FTYPE(ftype) (((ftype) & LORAWAN_MAC_FTYPE_MASK) >> 5)
@@ -290,11 +293,11 @@ static gint ett_lorawan_beacon_gwspecific = -1;
#define LORAWAN_AES_BLOCK_LENGTH 16
#define LORAWAN_AES_PADDEDSIZE(length) (LORAWAN_AES_BLOCK_LENGTH * ((length + LORAWAN_AES_BLOCK_LENGTH - 1) / LORAWAN_AES_BLOCK_LENGTH))
-static expert_field ei_lorawan_missing_keys = EI_INIT;
-static expert_field ei_lorawan_decrypting_error = EI_INIT;
-static expert_field ei_lorawan_mic = EI_INIT;
-static expert_field ei_lorawan_length_error = EI_INIT;
-static expert_field ei_lorawan_mhdr_error = EI_INIT;
+static expert_field ei_lorawan_missing_keys;
+static expert_field ei_lorawan_decrypting_error;
+static expert_field ei_lorawan_mic;
+static expert_field ei_lorawan_length_error;
+static expert_field ei_lorawan_mhdr_error;
static const value_string lorawan_ftypenames[] = {
{ LORAWAN_MAC_FTYPE_JOINREQUEST, "Join Request" },
@@ -305,6 +308,8 @@ static const value_string lorawan_ftypenames[] = {
{ LORAWAN_MAC_FTYPE_CONFIRMEDDATADOWN, "Confirmed Data Down" },
{ LORAWAN_MAC_FTYPE_RFU, "RFU" },
{ LORAWAN_MAC_FTYPE_PROPRIETARY, "Proprietary" },
+ // TODO: having this here makes no sense.
+ // It's value doesn't fit into 3 bits, and is only ever looked up with a hardcoded key...
{ LORAWAN_MAC_BEACON, "Class-B Beacon" },
{ 0, NULL }
};
@@ -352,31 +357,31 @@ static const value_string lorawan_mac_downlink_commandnames[] = {
typedef struct _root_keys_t {
- gchar *deveui_string;
- gchar *appkey_string;
+ char *deveui_string;
+ char *appkey_string;
GByteArray *deveui;
GByteArray *appkey;
} root_key_t;
typedef struct _session_keys_t {
- gchar *dev_addr_string;
- gchar *nwkskey_string;
- gchar *appskey_string;
- guint32 dev_addr;
+ char *dev_addr_string;
+ char *nwkskey_string;
+ char *appskey_string;
+ uint32_t dev_addr;
GByteArray *nwkskey;
GByteArray *appskey;
} session_key_t;
-static root_key_t *root_keys = NULL;
-static session_key_t *session_keys = NULL;
-static guint root_num_keys = 0;
-static guint session_num_keys = 0;
+static root_key_t *root_keys;
+static session_key_t *session_keys;
+static unsigned root_num_keys;
+static unsigned session_num_keys;
static void
byte_array_reverse(GByteArray *arr)
{
- for (guint i = 0; i < arr->len / 2; i++) {
- gint8 b = arr->data[i];
+ for (unsigned i = 0; i < arr->len / 2; i++) {
+ int8_t b = arr->data[i];
arr->data[i] = arr->data[(arr->len - 1) - i];
arr->data[(arr->len - 1) - i] = b;
}
@@ -389,39 +394,39 @@ root_keys_update_cb(void *r, char **err)
if (rec->deveui_string == NULL) {
*err = g_strdup("End-device identifier can't be empty");
- return FALSE;
+ return false;
}
if (!rec->deveui) {
rec->deveui = g_byte_array_new();
}
- if (!hex_str_to_bytes(rec->deveui_string, rec->deveui, FALSE)) {
+ if (!hex_str_to_bytes(rec->deveui_string, rec->deveui, false)) {
*err = g_strdup("End-device identifier must be hexadecimal");
- return FALSE;
+ return false;
}
if (rec->deveui->len != 8) {
*err = g_strdup("End-device identifier must be 8 bytes hexadecimal");
- return FALSE;
+ return false;
}
byte_array_reverse(rec->deveui);
if (rec->appkey_string == NULL) {
*err = g_strdup("Application key can't be empty");
- return FALSE;
+ return false;
}
if (!rec->appkey) {
rec->appkey = g_byte_array_new();
}
- if (!hex_str_to_bytes(rec->appkey_string, rec->appkey, FALSE)) {
+ if (!hex_str_to_bytes(rec->appkey_string, rec->appkey, false)) {
*err = g_strdup("Application key must be hexadecimal");
- return FALSE;
+ return false;
}
if (rec->appkey->len != 16) {
*err = g_strdup("Application key must be 16 bytes hexadecimal");
- return FALSE;
+ return false;
}
*err = NULL;
- return TRUE;
+ return true;
}
static void *
@@ -433,7 +438,7 @@ root_keys_copy_cb(void *n, const void *o, size_t siz _U_)
if (old_rec->deveui_string) {
new_rec->deveui_string = g_strdup(old_rec->deveui_string);
new_rec->deveui = g_byte_array_new();
- hex_str_to_bytes(new_rec->deveui_string, new_rec->deveui, FALSE);
+ hex_str_to_bytes(new_rec->deveui_string, new_rec->deveui, false);
byte_array_reverse(new_rec->deveui);
} else {
new_rec->deveui_string = NULL;
@@ -443,7 +448,7 @@ root_keys_copy_cb(void *n, const void *o, size_t siz _U_)
if (old_rec->appkey_string) {
new_rec->appkey_string = g_strdup(old_rec->appkey_string);
new_rec->appkey = g_byte_array_new();
- hex_str_to_bytes(new_rec->appkey_string, new_rec->appkey, FALSE);
+ hex_str_to_bytes(new_rec->appkey_string, new_rec->appkey, false);
}
else {
new_rec->appkey_string = NULL;
@@ -459,9 +464,9 @@ root_keys_free_cb(void *r)
root_key_t *rec = (root_key_t*)r;
g_free(rec->deveui_string);
- g_byte_array_free(rec->deveui, TRUE);
+ g_byte_array_free(rec->deveui, true);
g_free(rec->appkey_string);
- g_byte_array_free(rec->appkey, TRUE);
+ g_byte_array_free(rec->appkey, true);
}
static bool
@@ -471,57 +476,57 @@ session_keys_update_cb(void *r, char **err)
if (rec->dev_addr_string == NULL) {
*err = g_strdup("Device address can't be empty");
- return FALSE;
+ return false;
}
GByteArray *addr = g_byte_array_new();
- if (!hex_str_to_bytes(rec->dev_addr_string, addr, FALSE)) {
- g_byte_array_free(addr, TRUE);
+ if (!hex_str_to_bytes(rec->dev_addr_string, addr, false)) {
+ g_byte_array_free(addr, true);
*err = g_strdup("Device address must be hexadecimal");
- return FALSE;
+ return false;
}
if (addr->len != 4) {
- g_byte_array_free(addr, TRUE);
+ g_byte_array_free(addr, true);
*err = g_strdup("Device address must be 4 bytes hexadecimal");
- return FALSE;
+ return false;
}
byte_array_reverse(addr);
memcpy(&rec->dev_addr, addr->data, sizeof(rec->dev_addr));
- g_byte_array_free(addr, TRUE);
+ g_byte_array_free(addr, true);
if (rec->nwkskey_string == NULL) {
*err = g_strdup("Network session key can't be empty");
- return FALSE;
+ return false;
}
if (!rec->nwkskey) {
rec->nwkskey = g_byte_array_new();
}
- if (!hex_str_to_bytes(rec->nwkskey_string, rec->nwkskey, FALSE)) {
+ if (!hex_str_to_bytes(rec->nwkskey_string, rec->nwkskey, false)) {
*err = g_strdup("Network session key must be hexadecimal");
- return FALSE;
+ return false;
}
if (rec->nwkskey->len != 16) {
*err = g_strdup("Network session key must be 16 bytes hexadecimal");
- return FALSE;
+ return false;
}
if (rec->appskey_string == NULL) {
*err = g_strdup("Application session key can't be empty");
- return FALSE;
+ return false;
}
if (!rec->appskey) {
rec->appskey = g_byte_array_new();
}
- if (!hex_str_to_bytes(rec->appskey_string, rec->appskey, FALSE)) {
+ if (!hex_str_to_bytes(rec->appskey_string, rec->appskey, false)) {
*err = g_strdup("Application session key must be hexadecimal");
- return FALSE;
+ return false;
}
if (rec->appskey->len != 16) {
*err = g_strdup("Application session key must be 16 bytes hexadecimal");
- return FALSE;
+ return false;
}
*err = NULL;
- return TRUE;
+ return true;
}
static void *
@@ -533,7 +538,7 @@ session_keys_copy_cb(void *n, const void *o, size_t siz _U_)
if (old_rec->dev_addr_string) {
new_rec->dev_addr_string = g_strdup(old_rec->dev_addr_string);
GByteArray *addr = g_byte_array_new();
- if (hex_str_to_bytes(new_rec->dev_addr_string, addr, FALSE)) {
+ if (hex_str_to_bytes(new_rec->dev_addr_string, addr, false)) {
if (addr->len == 4) {
byte_array_reverse(addr);
memcpy(&new_rec->dev_addr, addr->data, sizeof(new_rec->dev_addr));
@@ -541,7 +546,7 @@ session_keys_copy_cb(void *n, const void *o, size_t siz _U_)
new_rec->dev_addr = 0;
}
}
- g_byte_array_free(addr, TRUE);
+ g_byte_array_free(addr, true);
} else {
new_rec->dev_addr_string = NULL;
new_rec->dev_addr = 0;
@@ -550,7 +555,7 @@ session_keys_copy_cb(void *n, const void *o, size_t siz _U_)
if (old_rec->nwkskey_string) {
new_rec->nwkskey_string = g_strdup(old_rec->nwkskey_string);
new_rec->nwkskey = g_byte_array_new();
- hex_str_to_bytes(new_rec->nwkskey_string, new_rec->nwkskey, FALSE);
+ hex_str_to_bytes(new_rec->nwkskey_string, new_rec->nwkskey, false);
} else {
new_rec->nwkskey_string = NULL;
new_rec->nwkskey = NULL;
@@ -559,7 +564,7 @@ session_keys_copy_cb(void *n, const void *o, size_t siz _U_)
if (old_rec->appskey_string) {
new_rec->appskey_string = g_strdup(old_rec->appskey_string);
new_rec->appskey = g_byte_array_new();
- hex_str_to_bytes(new_rec->appskey_string, new_rec->appskey, FALSE);
+ hex_str_to_bytes(new_rec->appskey_string, new_rec->appskey, false);
} else {
new_rec->appskey_string = NULL;
new_rec->appskey = NULL;
@@ -575,9 +580,9 @@ session_keys_free_cb(void *r)
g_free(rec->dev_addr_string);
g_free(rec->nwkskey_string);
- g_byte_array_free(rec->nwkskey, TRUE);
+ g_byte_array_free(rec->nwkskey, true);
g_free(rec->appskey_string);
- g_byte_array_free(rec->appskey, TRUE);
+ g_byte_array_free(rec->appskey, true);
}
UAT_CSTRING_CB_DEF(root_keys, deveui_string, root_key_t)
@@ -587,9 +592,9 @@ UAT_CSTRING_CB_DEF(session_keys, nwkskey_string, session_key_t)
UAT_CSTRING_CB_DEF(session_keys, appskey_string, session_key_t)
static session_key_t *
-get_session_key(guint32 dev_addr)
+get_session_key(uint32_t dev_addr)
{
- guint i;
+ unsigned i;
for (i = 0; i < session_num_keys; i++) {
if (session_keys[i].dev_addr == dev_addr) {
return &session_keys[i];
@@ -599,9 +604,9 @@ get_session_key(guint32 dev_addr)
}
static root_key_t *
-get_root_key(const guint8 *deveui)
+get_root_key(const uint8_t *deveui)
{
- guint i;
+ unsigned i;
for (i = 0; i < root_num_keys; i++) {
if (root_keys[i].deveui != NULL && memcmp(root_keys[i].deveui->data, deveui, 8) == 0) {
return &root_keys[i];
@@ -610,15 +615,15 @@ get_root_key(const guint8 *deveui)
return NULL;
}
-static guint32
-calculate_mic(const guint8 *in, guint8 length, const guint8 *key)
+static uint32_t
+calculate_mic(const uint8_t *in, uint8_t length, const uint8_t *key)
{
/*
* cmac = aes128_cmac(key, in)
* MIC = cmac[0..3]
*/
gcry_mac_hd_t mac_hd;
- guint32 mac;
+ uint32_t mac;
size_t read_digest_length = 4;
if (gcry_mac_open(&mac_hd, GCRY_MAC_CMAC_AES, 0, NULL)) {
@@ -644,10 +649,10 @@ calculate_mic(const guint8 *in, guint8 length, const guint8 *key)
}
static nstime_t
-gps_to_utctime(const guint32 gpstime)
+gps_to_utctime(const uint32_t gpstime)
{
nstime_t utctime;
- utctime.secs = (guint64)gpstime;
+ utctime.secs = (uint64_t)gpstime;
utctime.secs += 315964800; /* difference between Unix epoch and GPS epoch */
utctime.secs -= 18; /* leap seconds valid after 2017-01-01 */
utctime.nsecs = 0;
@@ -655,82 +660,82 @@ gps_to_utctime(const guint32 gpstime)
}
static void
-cf_coords_lat_custom(gchar *buffer, guint32 value)
+cf_coords_lat_custom(char *buffer, uint32_t value)
{
- gint32 coord_int = (value < 0x00800000) ? ((gint32)value) : ((gint32)value - 0x01000000);
- gdouble coord_double = coord_int * 90. / 0x00800000;
+ int32_t coord_int = (value < 0x00800000) ? ((int32_t)value) : ((int32_t)value - 0x01000000);
+ double coord_double = coord_int * 90. / 0x00800000;
snprintf(buffer, ITEM_LABEL_LENGTH, "%.5f%c", fabs(coord_double), (coord_double >= 0) ? 'N' : 'S');
}
static void
-cf_coords_lng_custom(gchar *buffer, guint32 value)
+cf_coords_lng_custom(char *buffer, uint32_t value)
{
- gint32 coord_int = (value < 0x00800000) ? ((gint32)value) : ((gint32)value - 0x01000000);
- gdouble coord_double = coord_int * 180. / 0x00800000;
+ int32_t coord_int = (value < 0x00800000) ? ((int32_t)value) : ((int32_t)value - 0x01000000);
+ double coord_double = coord_int * 180. / 0x00800000;
snprintf(buffer, ITEM_LABEL_LENGTH, "%.5f%c", fabs(coord_double), (coord_double >= 0) ? 'E' : 'W');
}
-static gboolean
-aes128_lorawan_encrypt(const guint8 *key, const guint8 *data_in, guint8 *data_out, gint length)
+static bool
+aes128_lorawan_encrypt(const uint8_t *key, const uint8_t *data_in, uint8_t *data_out, int length)
{
gcry_cipher_hd_t cipher;
if (gcry_cipher_open(&cipher, GCRY_CIPHER_AES128, GCRY_CIPHER_MODE_ECB, 0)) {
- return FALSE;
+ return false;
}
if (gcry_cipher_setkey(cipher, key, LORAWAN_AES_BLOCK_LENGTH)) {
gcry_cipher_close(cipher);
- return FALSE;
+ return false;
}
if (gcry_cipher_encrypt(cipher, data_out, length, data_in, length)) {
gcry_cipher_close(cipher);
- return FALSE;
+ return false;
}
gcry_cipher_close(cipher);
- return TRUE;
+ return true;
}
/* length should be a multiple of 16, in should be padded to get to a multiple of 16 */
-static gboolean
-decrypt_lorawan_frame_payload(const guint8 *in, gint length, guint8 *out, const guint8 * key, guint8 dir, guint32 dev_addr, guint32 fcnt)
+static bool
+decrypt_lorawan_frame_payload(const uint8_t *in, int length, uint8_t *out, const uint8_t * key, uint8_t dir, uint32_t dev_addr, uint32_t fcnt)
{
gcry_cipher_hd_t cipher;
- guint8 iv[LORAWAN_AES_BLOCK_LENGTH] = {0x01, 0x00, 0x00, 0x00, 0x00, dir, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
+ uint8_t iv[LORAWAN_AES_BLOCK_LENGTH] = {0x01, 0x00, 0x00, 0x00, 0x00, dir, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
memcpy(iv + 6, &dev_addr, 4);
memcpy(iv + 10, &fcnt, 4);
if (gcry_cipher_open(&cipher, GCRY_CIPHER_AES128, GCRY_CIPHER_MODE_CTR, 0)) {
- return FALSE;
+ return false;
}
if (gcry_cipher_setkey(cipher, key, LORAWAN_AES_BLOCK_LENGTH)) {
gcry_cipher_close(cipher);
- return FALSE;
+ return false;
}
if (gcry_cipher_setctr(cipher, iv, 16)) {
gcry_cipher_close(cipher);
- return FALSE;
+ return false;
}
if (gcry_cipher_encrypt(cipher, out, length, in, length)) {
gcry_cipher_close(cipher);
- return FALSE;
+ return false;
}
gcry_cipher_close(cipher);
- return TRUE;
+ return true;
}
static int
-dissect_lorawan_mac_commands(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree _U_, gboolean uplink)
+dissect_lorawan_mac_commands(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree _U_, bool uplink)
{
proto_item *ti, *tf;
proto_tree *mac_command_tree, *field_tree;
- guint8 command;
- gint32 current_offset = 0;
+ uint8_t command;
+ int32_t current_offset = 0;
ti = proto_tree_add_item(tree, hf_lorawan_mac_commands_type, tvb, 0, -1, ENC_NA);
mac_command_tree = proto_item_add_subtree(ti, ett_lorawan_mac_commands);
do {
- command = tvb_get_guint8(tvb, current_offset);
+ command = tvb_get_uint8(tvb, current_offset);
if (uplink) {
tf = proto_tree_add_item(mac_command_tree, hf_lorawan_mac_command_uplink_type, tvb, current_offset, 1, ENC_NA);
current_offset++;
@@ -896,9 +901,9 @@ dissect_lorawan_beacon(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree _
{
proto_item *ti;
proto_tree *gwspecific_tree;
- gint32 current_offset = 0;
- guint length = tvb_reported_length(tvb);
- guint16 calc_crc1, calc_crc2;
+ int32_t current_offset = 0;
+ unsigned length = tvb_reported_length(tvb);
+ uint16_t calc_crc1, calc_crc2;
nstime_t utctime;
proto_tree_add_string(tree, hf_lorawan_msgtype_type, tvb, current_offset, 0, val_to_str_const(LORAWAN_MAC_BEACON, lorawan_ftypenames, "RFU"));
@@ -914,7 +919,7 @@ dissect_lorawan_beacon(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree _
proto_tree_add_item(tree, hf_lorawan_beacon_rfu1_type, tvb, current_offset, 3, ENC_NA);
current_offset += 3;
}
- utctime = gps_to_utctime(tvb_get_guint32(tvb, current_offset, ENC_LITTLE_ENDIAN));
+ utctime = gps_to_utctime(tvb_get_uint32(tvb, current_offset, ENC_LITTLE_ENDIAN));
proto_tree_add_time(tree, hf_lorawan_beacon_time_type, tvb, current_offset, 4, &utctime);
current_offset += 4;
proto_tree_add_checksum(tree, tvb, current_offset, hf_lorawan_beacon_crc1_type, hf_lorawan_beacon_crc1_status_type, NULL, pinfo, calc_crc1, ENC_LITTLE_ENDIAN, PROTO_CHECKSUM_VERIFY);
@@ -943,7 +948,7 @@ dissect_lorawan_join_request(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *
{
proto_item *tf;
proto_tree *field_tree;
- gint32 current_offset = 1;
+ int32_t current_offset = 1;
tf = proto_tree_add_item(tree, hf_lorawan_join_request_type, tvb, current_offset, 18, ENC_NA);
field_tree = proto_item_add_subtree(tf, ett_lorawan_join_request);
@@ -976,10 +981,10 @@ dissect_lorawan_join_accept(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *t
{
proto_item *tf;
proto_tree *field_tree;
- gint32 current_offset = 1;
+ int32_t current_offset = 1;
root_key_t *root_key = NULL;
- gint length = tvb_captured_length_remaining(tvb, current_offset);
+ int length = tvb_captured_length_remaining(tvb, current_offset);
tf = proto_tree_add_item(tree, hf_lorawan_join_accept_type, tvb, current_offset, 12, ENC_NA);
field_tree = proto_item_add_subtree(tf, ett_lorawan_join_accept);
@@ -991,12 +996,12 @@ dissect_lorawan_join_accept(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *t
}
/* Iterate through all available root keys for Join-Accept */
- guint8 *decrypted_buffer = (guint8 *)wmem_alloc0(pinfo->pool, length);
- guint8 *mic_buffer = (guint8 *)wmem_alloc0(pinfo->pool, length - 4 + 1);
- guint32 mic_check;
- for (guint key_idx = 0; key_idx < root_num_keys; key_idx++) {
+ uint8_t *decrypted_buffer = (uint8_t *)wmem_alloc0(pinfo->pool, length);
+ uint8_t *mic_buffer = (uint8_t *)wmem_alloc0(pinfo->pool, length - 4 + 1);
+ uint32_t mic_check;
+ for (unsigned key_idx = 0; key_idx < root_num_keys; key_idx++) {
if (aes128_lorawan_encrypt(root_keys[key_idx].appkey->data, tvb_get_ptr(tvb, current_offset, length), decrypted_buffer, length)) {
- mic_buffer[0] = tvb_get_guint8(tvb, current_offset - 1); // unencrypted MHDR
+ mic_buffer[0] = tvb_get_uint8(tvb, current_offset - 1); // unencrypted MHDR
memcpy(&mic_buffer[1], decrypted_buffer, length - 4); // decrypted Join-Accept
memcpy(&mic_check, &decrypted_buffer[length - 4], 4); // decrypted MIC
@@ -1039,24 +1044,24 @@ dissect_lorawan_join_accept(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *t
}
static int
-dissect_lorawan_data(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree _U_, gboolean uplink)
+dissect_lorawan_data(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree _U_, bool uplink)
{
proto_item *ti = NULL, *tf;
proto_tree *field_tree;
- gint32 current_offset = 1;
- guint8 fopts_length = (tvb_get_guint8(tvb, current_offset + 4) & LORAWAN_FRAME_FOPTSLEN_MASK);
- guint8 fport = 0;
+ int32_t current_offset = 1;
+ uint8_t fopts_length = (tvb_get_uint8(tvb, current_offset + 4) & LORAWAN_FRAME_FOPTSLEN_MASK);
+ uint8_t fport = 0;
/* Frame header */
tf = proto_tree_add_item(tree, hf_lorawan_frame_header_type, tvb, current_offset, 7 + fopts_length, ENC_NA);
field_tree = proto_item_add_subtree(tf, ett_lorawan_frame_header);
proto_tree_add_item(field_tree, hf_lorawan_frame_header_address_type, tvb, current_offset, 4, ENC_LITTLE_ENDIAN);
- guint32 dev_address = tvb_get_guint32(tvb, current_offset, ENC_LITTLE_ENDIAN);
+ uint32_t dev_address = tvb_get_uint32(tvb, current_offset, ENC_LITTLE_ENDIAN);
current_offset += 4;
proto_tree_add_bitmask(field_tree, tvb, current_offset, hf_lorawan_frame_header_frame_control_type, ett_lorawan_frame_header_control, hfx_lorawan_frame_header_frame_control, ENC_NA);
current_offset++;
proto_tree_add_item(field_tree, hf_lorawan_frame_header_frame_counter_type, tvb, current_offset, 2, ENC_LITTLE_ENDIAN);
- guint32 fcnt = tvb_get_guint16(tvb, current_offset, ENC_LITTLE_ENDIAN);
+ uint32_t fcnt = tvb_get_uint16(tvb, current_offset, ENC_LITTLE_ENDIAN);
current_offset += 2;
/*
@@ -1073,7 +1078,7 @@ dissect_lorawan_data(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree _U_
if (tvb_captured_length_remaining(tvb, current_offset) > 4) {
/* FPort present */
proto_tree_add_item(tree, hf_lorawan_frame_fport_type, tvb, current_offset, 1, ENC_NA);
- fport = tvb_get_guint8(tvb, current_offset);
+ fport = tvb_get_uint8(tvb, current_offset);
current_offset++;
}
@@ -1081,16 +1086,16 @@ dissect_lorawan_data(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree _U_
/* TODO?: error, not allowed */
}
- guint8 frmpayload_length = tvb_captured_length_remaining(tvb, current_offset) - 4;
+ uint8_t frmpayload_length = tvb_captured_length_remaining(tvb, current_offset) - 4;
if (frmpayload_length > 0) {
ti = proto_tree_add_item(tree, hf_lorawan_frame_payload_type, tvb, current_offset, frmpayload_length, ENC_NA);
}
session_key_t *session_key = get_session_key(dev_address);
if (session_key && frmpayload_length > 0) {
- guint8 padded_length = LORAWAN_AES_PADDEDSIZE(frmpayload_length);
- guint8 *decrypted_buffer = (guint8 *)wmem_alloc0(pinfo->pool, padded_length);
- guint8 *encrypted_buffer = (guint8 *)wmem_alloc0(pinfo->pool, padded_length);
+ uint8_t padded_length = LORAWAN_AES_PADDEDSIZE(frmpayload_length);
+ uint8_t *decrypted_buffer = (uint8_t *)wmem_alloc0(pinfo->pool, padded_length);
+ uint8_t *encrypted_buffer = (uint8_t *)wmem_alloc0(pinfo->pool, padded_length);
tvb_memcpy(tvb, encrypted_buffer, current_offset, frmpayload_length);
if (decrypt_lorawan_frame_payload(encrypted_buffer, padded_length, decrypted_buffer, (fport == 0) ? session_key->nwkskey->data : session_key->appskey->data, !uplink, dev_address, fcnt)) {
tvbuff_t *next_tvb = tvb_new_child_real_data(tvb, decrypted_buffer, frmpayload_length, frmpayload_length);
@@ -1121,8 +1126,8 @@ dissect_lorawan_data(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree _U_
* B0 = 0x49 | 0x00 | 0x00 | 0x00 | 0x00 | dir | devAddr | fcntup/fcntdown | len(msg)
*/
if (session_key) {
- gint frame_length = current_offset;
- guint8 *msg = (guint8 *)wmem_alloc0(pinfo->pool, frame_length + 16);
+ int frame_length = current_offset;
+ uint8_t *msg = (uint8_t *)wmem_alloc0(pinfo->pool, frame_length + 16);
msg[0] = 0x49;
msg[5] = uplink ? 0 : 1;
memcpy(msg + 6, &dev_address, 4);
@@ -1144,7 +1149,7 @@ dissect_lorawan(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree _U_, void *d
{
proto_item *ti, *tf;
proto_tree *lorawan_tree, *field_tree;
- gint32 current_offset = 0;
+ int32_t current_offset = 0;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "LoRaWAN");
col_clear(pinfo->cinfo,COL_INFO);
@@ -1154,22 +1159,22 @@ dissect_lorawan(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree _U_, void *d
/* Detect and dissect Class-B beacon frames
* common mark: beacon is 17B or 19B long and begins with 2 bytes of zeroed RFU
*/
- guint16 classb_rfu = tvb_get_guint16(tvb, current_offset, ENC_LITTLE_ENDIAN);
- guint classb_length = tvb_reported_length(tvb);
+ uint16_t classb_rfu = tvb_get_uint16(tvb, current_offset, ENC_LITTLE_ENDIAN);
+ unsigned classb_length = tvb_reported_length(tvb);
if (classb_rfu == 0x0000 && (classb_length == 17 || classb_length == 19)) {
return dissect_lorawan_beacon(tvb, pinfo, lorawan_tree);
}
/* MAC header */
- guint8 mac_ftype = LORAWAN_MAC_FTYPE(tvb_get_guint8(tvb, current_offset));
+ uint8_t mac_ftype = LORAWAN_MAC_FTYPE(tvb_get_uint8(tvb, current_offset));
proto_tree_add_string(lorawan_tree, hf_lorawan_msgtype_type, tvb, current_offset, 0, val_to_str_const(mac_ftype, lorawan_ftypenames, "RFU"));
tf = proto_tree_add_item(lorawan_tree, hf_lorawan_mac_header_type, tvb, current_offset, 1, ENC_NA);
proto_item_append_text(tf, " (Message Type: %s, Major Version: %s)",
val_to_str_const(mac_ftype, lorawan_ftypenames, "RFU"),
- val_to_str_const(LORAWAN_MAC_MAJOR(tvb_get_guint8(tvb, current_offset)), lorawan_majornames, "RFU"));
+ val_to_str_const(LORAWAN_MAC_MAJOR(tvb_get_uint8(tvb, current_offset)), lorawan_majornames, "RFU"));
/* Validate MHDR fields for LoRaWAN packet, do not dissect malformed packets */
- if ((tvb_get_guint8(tvb, current_offset) & (LORAWAN_MAC_MAJOR_MASK | LORAWAN_MAC_RFU_MASK)) != LORAWAN_MAC_MAJOR_R1) {
+ if ((tvb_get_uint8(tvb, current_offset) & (LORAWAN_MAC_MAJOR_MASK | LORAWAN_MAC_RFU_MASK)) != LORAWAN_MAC_MAJOR_R1) {
expert_add_info(pinfo, lorawan_tree, &ei_lorawan_mhdr_error);
mac_ftype = LORAWAN_MAC_FTYPE_RFU;
}
@@ -1262,7 +1267,7 @@ proto_register_lorawan(void)
{ &hf_lorawan_mac_command_down_link_check_ans_margin_type,
{ "Demodulation Margin", "lorawan.link_check_answer.margin",
FT_UINT8, BASE_DEC|BASE_UNIT_STRING,
- &units_decibels, 0x0,
+ UNS(&units_decibels), 0x0,
NULL, HFILL }
},
{ &hf_lorawan_mac_command_down_link_check_ans_gwcnt_type,
@@ -1436,7 +1441,7 @@ proto_register_lorawan(void)
{ &hf_lorawan_mac_command_down_rx_setup_req_frequency_type,
{ "Frequency", "lorawan.rx_setup_request.frequency",
FT_UINT24, BASE_DEC|BASE_UNIT_STRING,
- &units_hz, 0x0,
+ UNS(&units_hz), 0x0,
NULL, HFILL }
},
{ &hf_lorawan_mac_command_up_rx_setup_ans_type,
@@ -1484,7 +1489,7 @@ proto_register_lorawan(void)
{ &hf_lorawan_mac_command_down_new_channel_req_frequency_type,
{ "Frequency", "lorawan.new_channel_request.frequency",
FT_UINT24, BASE_DEC|BASE_UNIT_STRING,
- &units_hz, 0x0,
+ UNS(&units_hz), 0x0,
NULL, HFILL }
},
{ &hf_lorawan_mac_command_down_new_channel_req_drrange_max_type,
@@ -1520,7 +1525,7 @@ proto_register_lorawan(void)
{ &hf_lorawan_mac_command_down_rx_timing_req_delay_type,
{ "Delay", "lorawan.rx_timing_request.delay",
FT_UINT8, BASE_DEC|BASE_UNIT_STRING,
- &units_seconds, LORAWAN_MAC_COMMAND_DOWN_RX_TIMING_REQ_DELAY_MASK,
+ UNS(&units_seconds), LORAWAN_MAC_COMMAND_DOWN_RX_TIMING_REQ_DELAY_MASK,
NULL, HFILL }
},
{ &hf_lorawan_mac_command_up_di_channel_ans_type,
@@ -1646,7 +1651,7 @@ proto_register_lorawan(void)
{ &hf_lorawan_join_accept_rxdelay_type,
{ "Delay between TX and RX", "lorawan.join_accept.rxdelay",
FT_UINT8, BASE_DEC|BASE_UNIT_STRING,
- &units_seconds, 0x0,
+ UNS(&units_seconds), 0x0,
"[RXDelay] Delay between TX and RX", HFILL }
},
{ &hf_lorawan_join_accept_cflist_type,
@@ -1808,7 +1813,7 @@ proto_register_lorawan(void)
};
/* Setup protocol subtree array */
- static gint *ett[] = {
+ static int *ett[] = {
&ett_lorawan,
&ett_lorawan_mac_header,
&ett_lorawan_mac_commands,
@@ -1866,7 +1871,7 @@ proto_register_lorawan(void)
uat_t *root_keys_uat = uat_new("LoRaWAN Root Keys",
sizeof(root_key_t),
"root_keys_lorawan",
- TRUE,
+ true,
&root_keys,
&root_num_keys,
UAT_AFFECTS_DISSECTION | UAT_AFFECTS_FIELDS,
@@ -1881,7 +1886,7 @@ proto_register_lorawan(void)
uat_t *session_keys_uat = uat_new("LoRaWAN Session Keys",
sizeof(session_key_t),
"session_keys_lorawan",
- TRUE,
+ true,
&session_keys,
&session_num_keys,
UAT_AFFECTS_DISSECTION | UAT_AFFECTS_FIELDS,