aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorErik de Jong <erikdejong@gmail.com>2018-01-08 21:09:51 +0100
committerAnders Broman <a.broman58@gmail.com>2018-01-09 06:39:02 +0000
commit0a8d6cf97e0dccc02cb36f2636feb053725118da (patch)
tree3587fb1019b8245a4991f6d9b9d707e1cdd5f5ad /epan
parent958374f352c0d1c238355a6434e0222e754f43f1 (diff)
LoRaTap/LoRaWAN: Add decode as and fix field types
Allow LoRaTap syncword field to be used for "decode as". Fix field types for LoRaWAN EUI fields to display as EUI-64 little endian. Change-Id: I584f338031a4bc87e127d35a7bf8751a60e93d55 Reviewed-on: https://code.wireshark.org/review/25199 Reviewed-by: Michael Mann <mmann78@netscape.net> Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan')
-rw-r--r--epan/dissectors/packet-loratap.c22
-rw-r--r--epan/dissectors/packet-lorawan.c8
2 files changed, 25 insertions, 5 deletions
diff --git a/epan/dissectors/packet-loratap.c b/epan/dissectors/packet-loratap.c
index 782c63bdc2..2d41567b49 100644
--- a/epan/dissectors/packet-loratap.c
+++ b/epan/dissectors/packet-loratap.c
@@ -26,6 +26,8 @@
#include <wiretap/wtap.h>
#include <epan/packet.h>
#include <epan/capture_dissectors.h>
+#include <epan/decode_as.h>
+#include <epan/proto_data.h>
void proto_reg_handoff_loratap(void);
void proto_register_loratap(void);
@@ -78,6 +80,18 @@ snr_base_custom(gchar *buffer, guint32 value) {
g_snprintf(buffer, ITEM_LABEL_LENGTH, "%d dB", value);
}
+static void
+loratap_prompt(packet_info *pinfo, gchar* result)
+{
+ g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "LoRaTap syncword 0x%02x as", GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, proto_loratap, 0)));
+}
+
+static gpointer
+loratap_value(packet_info *pinfo)
+{
+ return p_get_proto_data(pinfo->pool, pinfo, proto_loratap, 0);
+}
+
static int
dissect_loratap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree _U_, void *data _U_)
{
@@ -119,7 +133,7 @@ dissect_loratap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree _U_, void *d
current_offset++;
proto_tree_add_item_ret_uint(loratap_tree, hf_loratap_header_syncword_type, tvb, current_offset, 1, ENC_NA, &syncword);
current_offset++;
-
+ p_add_proto_data(pinfo->pool, pinfo, proto_loratap, 0, GUINT_TO_POINTER((guint)syncword));
next_tvb = tvb_new_subset_length_caplen(tvb, current_offset, tvb_captured_length_remaining(tvb, current_offset), tvb_reported_length_remaining(tvb, current_offset));
if (!dissector_try_uint_new(loratap_dissector_table, syncword, next_tvb, pinfo, tree, TRUE, NULL)) {
@@ -219,6 +233,11 @@ proto_register_loratap(void)
},
};
+ /* Register for decode as */
+ static build_valid_func loratap_da_build_value[1] = {loratap_value};
+ static decode_as_value_t loratap_da_values = {loratap_prompt, 1, loratap_da_build_value};
+ static decode_as_t loratap_da = {"loratap", "LoRa Syncword", "loratap.syncword", 1, 0, &loratap_da_values, NULL, NULL, decode_as_default_populate_list, decode_as_default_reset, decode_as_default_change, NULL};
+
/* Setup protocol subtree array */
static gint *ett[] = {
&ett_loratap
@@ -234,6 +253,7 @@ proto_register_loratap(void)
proto_register_field_array(proto_loratap, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
loratap_dissector_table = register_dissector_table("loratap.syncword", "LoRa Syncword", proto_loratap, FT_UINT8, BASE_HEX);
+ register_decode_as(&loratap_da);
}
/*
diff --git a/epan/dissectors/packet-lorawan.c b/epan/dissectors/packet-lorawan.c
index 29d500d830..b93c410e1b 100644
--- a/epan/dissectors/packet-lorawan.c
+++ b/epan/dissectors/packet-lorawan.c
@@ -694,9 +694,9 @@ dissect_lorawan(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree _U_, void *d
if (mac_mtype == LORAWAN_MAC_MTYPE_JOINREQUEST) {
tf = proto_tree_add_item(lorawan_tree, hf_lorawan_join_request_type, tvb, current_offset, 18, ENC_NA);
field_tree = proto_item_add_subtree(tf, ett_lorawan_join_request);
- proto_tree_add_item(field_tree, hf_lorawan_join_request_appeui_type, tvb, current_offset, 8, ENC_NA);
+ proto_tree_add_item(field_tree, hf_lorawan_join_request_appeui_type, tvb, current_offset, 8, ENC_LITTLE_ENDIAN);
current_offset += 8;
- proto_tree_add_item(field_tree, hf_lorawan_join_request_deveui_type, tvb, current_offset, 8, ENC_NA);
+ proto_tree_add_item(field_tree, hf_lorawan_join_request_deveui_type, tvb, current_offset, 8, ENC_LITTLE_ENDIAN);
current_offset += 8;
proto_tree_add_item(field_tree, hf_lorawan_join_request_devnonce_type, tvb, current_offset, 2, ENC_NA);
current_offset += 2;
@@ -1184,13 +1184,13 @@ proto_register_lorawan(void)
},
{ &hf_lorawan_join_request_appeui_type,
{ "AppEUI", "lorawan.join_request.appeui",
- FT_BYTES, BASE_NONE,
+ FT_EUI64, BASE_NONE,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_lorawan_join_request_deveui_type,
{ "DevEUI", "lorawan.join_request.deveui",
- FT_BYTES, BASE_NONE,
+ FT_EUI64, BASE_NONE,
NULL, 0x0,
NULL, HFILL }
},