aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathis Marion <mathis.marion@silabs.com>2023-03-08 10:58:46 +0100
committerAlexis La Goutte <alexis.lagoutte@gmail.com>2023-03-09 10:33:48 +0000
commitd574cd2c24a655ac869b90666e96de99c3aba6e1 (patch)
tree4d4e4182ff3f2b0561ebe9b182f77c348e67ee58
parent035547761896cf41870bbbc3885b19e101c3f29f (diff)
Add support for Wi-SUN JM-IE and JM-PFL
-rw-r--r--epan/dissectors/packet-wisun.c130
1 files changed, 130 insertions, 0 deletions
diff --git a/epan/dissectors/packet-wisun.c b/epan/dissectors/packet-wisun.c
index 57ac6fdc75..b73429242b 100644
--- a/epan/dissectors/packet-wisun.c
+++ b/epan/dissectors/packet-wisun.c
@@ -77,6 +77,7 @@ static reassembly_table netricity_reassembly_table;
#define WISUN_PIE_SUBID_LFNVER 0x40
#define WISUN_PIE_SUBID_LGTKHASH 0x41
#define WISUN_PIE_SUBID_LBATS 0x09
+#define WISUN_PIE_SUBID_JM 0x0a
#define WISUN_LGTKHASH_LGTK0_INCLUDED_MASK 0x01
#define WISUN_LGTKHASH_LGTK1_INCLUDED_MASK 0x02
@@ -111,6 +112,10 @@ static reassembly_table netricity_reassembly_table;
#define WISUN_PIE_PHY_OPERATING_MODES_MASK 0x0F
#define WISUN_PIE_PHY_TYPE 0xF0
+#define WISUN_PIE_JM_ID_PLF 1
+#define WISUN_PIE_JM_ID_MASK 0xfc
+#define WISUN_PIE_JM_LEN_MASK 0x03
+
static int proto_wisun = -1;
static int hf_wisun_subid = -1;
static int hf_wisun_unknown_ie = -1;
@@ -248,6 +253,14 @@ static int hf_wisun_lgtkhashie_gtk2 = -1;
static int hf_wisun_lbatsie = -1;
static int hf_wisun_lbatsie_additional_tx = -1;
static int hf_wisun_lbatsie_next_tx_delay = -1;
+static int hf_wisun_jmie = -1;
+static int hf_wisun_jmie_version = -1;
+static int hf_wisun_jmie_metric_hdr = -1;
+static int hf_wisun_jmie_metric_id = -1;
+static int hf_wisun_jmie_metric_len = -1;
+static int hf_wisun_jmie_metric_plf = -1;
+static int hf_wisun_jmie_metric_plf_data = -1;
+static int hf_wisun_jmie_metric_unknown = -1;
static int proto_wisun_sec = -1;
static int hf_wisun_sec_function = -1;
@@ -324,6 +337,10 @@ static gint ett_wisun_lfnverie = -1;
static gint ett_wisun_lgtkhashie = -1;
static gint ett_wisun_lgtkhashie_flags = -1;
static gint ett_wisun_lbatsie = -1;
+static gint ett_wisun_jmie = -1;
+static gint ett_wisun_jmie_metric_hdr = -1;
+static gint ett_wisun_jmie_metric_plf = -1;
+static gint ett_wisun_jmie_metric_unknown = -1;
static gint ett_wisun_sec = -1;
static gint ett_wisun_eapol_relay = -1;
// Netricity
@@ -408,6 +425,7 @@ static const value_string wisun_wsie_names_short[] = {
{ WISUN_PIE_SUBID_LFNVER, "LFN Version IE" },
{ WISUN_PIE_SUBID_LGTKHASH, "LFN GTK Hash IE" },
{ WISUN_PIE_SUBID_LBATS, "LFN Broadcast Additional Transmit Schedule IE" },
+ { WISUN_PIE_SUBID_JM, "Join Metrics IE" },
{ 0, NULL }
};
@@ -526,6 +544,19 @@ static const value_string wisun_window_style[] = {
{ 0, NULL }
};
+static const value_string wisun_metric_id[] = {
+ { WISUN_PIE_JM_ID_PLF, "PAN Load Factor" },
+ { 0, NULL }
+};
+
+static const value_string wisun_metric_len[] = {
+ { 0, "0" },
+ { 1, "1" },
+ { 2, "2" },
+ { 3, "4" },
+ { 0, NULL }
+};
+
static const value_string wisun_sec_functions[] = {
{ 0x01, "SM Error" },
{ 0, NULL }
@@ -612,6 +643,7 @@ static expert_field ei_wisun_wsie_unsupported = EI_INIT;
static expert_field ei_wisun_usie_channel_plan_invalid = EI_INIT;
static expert_field ei_wisun_edfe_start_not_found = EI_INIT;
static expert_field ei_wisun_usie_explicit_reserved_bits_not_zero = EI_INIT;
+static expert_field ei_wisun_jmie_metric_unsupported = EI_INIT;
static guint
wisun_add_wbxml_uint(tvbuff_t *tvb, proto_tree *tree, int hf, guint offset)
@@ -1436,6 +1468,55 @@ dissect_wisun_lbatsie(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, v
}
static int
+dissect_wisun_jmie(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
+{
+ static int * const fields_jmie_metric_hdr[] = {
+ &hf_wisun_jmie_metric_id,
+ &hf_wisun_jmie_metric_len,
+ NULL
+ };
+ guint8 offset = 0;
+ proto_item *item;
+ proto_tree *subtree;
+
+ item = proto_tree_add_item(tree, hf_wisun_jmie, tvb, 0, tvb_reported_length(tvb), ENC_NA);
+ subtree = proto_item_add_subtree(item, ett_wisun_jmie);
+
+ proto_tree_add_bitmask(subtree, tvb, offset, hf_wisun_wsie, ett_wisun_wsie_bitmap, wisun_format_nested_ie_short, ENC_LITTLE_ENDIAN);
+ offset += 2;
+ proto_tree_add_item(subtree, hf_wisun_jmie_version, tvb, offset, 1, ENC_LITTLE_ENDIAN);
+ offset += 1;
+ while (tvb_reported_length_remaining(tvb, offset) > 0) {
+ guint8 metric_hdr = tvb_get_guint8(tvb, offset);
+ guint8 metric_len = metric_hdr & WISUN_PIE_JM_LEN_MASK;
+ proto_tree *metric_subtree;
+
+ if (metric_len == 3)
+ metric_len = 4;
+
+ switch ((metric_hdr & WISUN_PIE_JM_ID_MASK) >> 2) {
+ case WISUN_PIE_JM_ID_PLF:
+ item = proto_tree_add_item(subtree, hf_wisun_jmie_metric_plf, tvb, offset, 1 + metric_len, ENC_NA);
+ metric_subtree = proto_item_add_subtree(item, ett_wisun_jmie_metric_plf);
+ proto_tree_add_bitmask(metric_subtree, tvb, offset, hf_wisun_jmie_metric_hdr, ett_wisun_jmie_metric_hdr, fields_jmie_metric_hdr, ENC_NA);
+ offset += 1;
+ proto_tree_add_item(metric_subtree, hf_wisun_jmie_metric_plf_data, tvb, offset, 1, ENC_LITTLE_ENDIAN);
+ break;
+ default:
+ item = proto_tree_add_item(subtree, hf_wisun_jmie_metric_unknown, tvb, offset, 1 + metric_len, ENC_NA);
+ metric_subtree = proto_item_add_subtree(item, ett_wisun_jmie_metric_unknown);
+ proto_tree_add_bitmask(metric_subtree, tvb, offset, hf_wisun_jmie_metric_hdr, ett_wisun_jmie_metric_hdr, fields_jmie_metric_hdr, ENC_NA);
+ offset += 1;
+ expert_add_info(pinfo, metric_subtree, &ei_wisun_jmie_metric_unsupported);
+ call_data_dissector(tvb_new_subset_length(tvb, offset, metric_len), pinfo, metric_subtree);
+ break;
+ }
+ offset += metric_len;
+ }
+ return offset;
+}
+
+static int
dissect_wisun_pie(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ies_tree, void *data)
{
proto_tree *tree = ieee802154_create_pie_tree(tvb, ies_tree, hf_wisun_pie, ett_wisun_pie);
@@ -1501,6 +1582,9 @@ dissect_wisun_pie(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ies_tree, void
case WISUN_PIE_SUBID_LBATS:
dissect_wisun_lbatsie(wsie_tvb, pinfo, tree, data);
break;
+ case WISUN_PIE_SUBID_JM:
+ dissect_wisun_jmie(wsie_tvb, pinfo, tree, data);
+ break;
default:{
proto_item *item = proto_tree_add_item(tree, hf_wisun_unknown_ie, wsie_tvb, 0, tvb_reported_length(wsie_tvb), ENC_NA);
proto_tree *subtree = proto_item_add_subtree(item, ett_wisun_unknown_ie);
@@ -2340,6 +2424,46 @@ void proto_register_wisun(void)
NULL, HFILL }
},
+ { &hf_wisun_jmie,
+ { "JM-IE", "wisun.jmie", FT_NONE, BASE_NONE, NULL, 0x0,
+ "Join Metrics IE", HFILL }
+ },
+
+ { &hf_wisun_jmie_version,
+ { "Content Version", "wisun.jmie.version", FT_UINT8, BASE_DEC, NULL, 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_jmie_metric_hdr,
+ { "Metric Header", "wisun.jmie.metric.hdr", FT_UINT8, BASE_HEX, NULL, 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_jmie_metric_id,
+ { "Metric ID", "wisun.jmie.metric.id", FT_UINT8, BASE_DEC, VALS(wisun_metric_id), WISUN_PIE_JM_ID_MASK,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_jmie_metric_len,
+ { "Metric Length", "wisun.jmie.metric.len", FT_UINT8, BASE_DEC, VALS(wisun_metric_len), WISUN_PIE_JM_LEN_MASK,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_jmie_metric_plf,
+ { "JM-PLF", "wisun.jmie.metric.plf", FT_NONE, BASE_NONE, NULL, 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_jmie_metric_plf_data,
+ { "PAN Load Factor", "wisun.jmie.metric.plf.data", FT_UINT8, BASE_DEC|BASE_UNIT_STRING, &units_percent, 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_jmie_metric_unknown,
+ { "Unknown Metric", "wisun.jmie.metric.unknown", FT_NONE, BASE_NONE, NULL, 0x0,
+ NULL, HFILL }
+ },
+
/* Wi-SUN FAN Security Extension */
{ &hf_wisun_sec_function,
{ "Function Code", "wisun.sec.function", FT_UINT8, BASE_HEX, VALS(wisun_sec_functions), 0x0,
@@ -2495,6 +2619,10 @@ void proto_register_wisun(void)
&ett_wisun_lgtkhashie,
&ett_wisun_lgtkhashie_flags,
&ett_wisun_lbatsie,
+ &ett_wisun_jmie,
+ &ett_wisun_jmie_metric_hdr,
+ &ett_wisun_jmie_metric_plf,
+ &ett_wisun_jmie_metric_unknown,
&ett_wisun_sec,
&ett_wisun_eapol_relay,
&ett_wisun_netricity_nftie,
@@ -2526,6 +2654,8 @@ void proto_register_wisun(void)
"EDFE Transfer: start frame not found", EXPFILL }},
{ &ei_wisun_usie_explicit_reserved_bits_not_zero, { "wisun.usie.explicit.reserved.invalid", PI_MALFORMED, PI_ERROR,
"Reserved bits not zero", EXPFILL }},
+ { &ei_wisun_jmie_metric_unsupported, { "wisun.jmie.metric.unsupported", PI_PROTOCOL, PI_WARN,
+ "Unsupported Metric ID", EXPFILL }},
};
expert_module_t* expert_wisun;