aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorOwen Kirby <osk@exegin.com>2017-11-09 18:33:51 -0800
committerAnders Broman <a.broman58@gmail.com>2017-11-11 19:11:44 +0000
commit3f11c2f7c53ff07aa2d402eda013259706f257f8 (patch)
tree9d76e1360ed34cbc4a47449f30ff266c32e630d6 /epan
parent499ae4ab573fbfefdb1c200e3177e18844e545b5 (diff)
Wi-SUN Protocol dissection and IEEE 802.15.4 IE cleanup.
This patch adds dissection for the Wi-SUN Field Area Network standard. Wi-SUN packets are encoded as a collection of IEEE 802.15.4 information elements. This required a bit of refactoring in how the IE dissector table is handled so that external protocols could supply their own dissectors. While I was working with the IEs, I also added support for the TSCH Timeslot and Global Time IEs from the IEEE 802.15.4 standard in addition to some general cleanup. Change-Id: I2858e4ab577756568e33b86adfe282967899abd5 Reviewed-on: https://code.wireshark.org/review/24331 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/CMakeLists.txt1
-rw-r--r--epan/dissectors/Makefile.am1
-rw-r--r--epan/dissectors/packet-ieee802154.c952
-rw-r--r--epan/dissectors/packet-ieee802154.h14
-rw-r--r--epan/dissectors/packet-wisun.c1102
-rw-r--r--epan/oui.h1
6 files changed, 1592 insertions, 479 deletions
diff --git a/epan/dissectors/CMakeLists.txt b/epan/dissectors/CMakeLists.txt
index f60aa016b1..5046ec4d3f 100644
--- a/epan/dissectors/CMakeLists.txt
+++ b/epan/dissectors/CMakeLists.txt
@@ -1748,6 +1748,7 @@ set(DISSECTOR_SRC
packet-wifi-p2p.c
packet-windows-common.c
packet-winsrepl.c
+ packet-wisun.c
packet-wlccp.c
packet-wol.c
packet-wow.c
diff --git a/epan/dissectors/Makefile.am b/epan/dissectors/Makefile.am
index 0a70cf4dd9..3eff21d3f2 100644
--- a/epan/dissectors/Makefile.am
+++ b/epan/dissectors/Makefile.am
@@ -1402,6 +1402,7 @@ DISSECTOR_SRC = \
packet-wifi-p2p.c \
packet-windows-common.c \
packet-winsrepl.c \
+ packet-wisun.c \
packet-wlccp.c \
packet-wol.c \
packet-wow.c \
diff --git a/epan/dissectors/packet-ieee802154.c b/epan/dissectors/packet-ieee802154.c
index ef218ef6c2..6f896b1a2d 100644
--- a/epan/dissectors/packet-ieee802154.c
+++ b/epan/dissectors/packet-ieee802154.c
@@ -72,6 +72,7 @@
#include <epan/show_exception.h>
#include <epan/proto_data.h>
#include <epan/etypes.h>
+#include <epan/oui.h>
#include <wsutil/pint.h>
/* Use libgcrypt for cipher libraries. */
@@ -273,13 +274,13 @@ static tvbuff_t *dissect_zboss_specific (tvbuff_t *, packet_info *, proto_tre
static void dissect_ieee802154_common (tvbuff_t *, packet_info *, proto_tree *, guint);
/* Information Elements */
-static int dissect_ieee802154_header_ie(tvbuff_t *, packet_info *, proto_tree *, guint, ieee802154_packet *);
-static int dissect_ieee802154_payload_ie(tvbuff_t *, packet_info *, proto_tree *, guint, ieee802154_packet *);
-static void dissect_802154_enhanced_beacon_filter(tvbuff_t *tvb, proto_tree *subtree, guint16 psie_remaining, gint *offset);
-static void dissect_802154_tsch_time_sync(tvbuff_t *, proto_tree *, int *, guint);
-static void dissect_802154_tsch_timeslot(tvbuff_t *, proto_tree *, guint, guint16, gint*);
-static void dissect_802154_tsch_slotframe_link(tvbuff_t *, proto_tree *, guint16, guint16, guint *);
-static void dissect_802154_channel_hopping(tvbuff_t *, proto_tree *, guint16, guint *);
+static int dissect_ieee802154_header_ie (tvbuff_t *, packet_info *, proto_tree *, guint, ieee802154_packet *);
+static int dissect_ieee802154_payload_ie (tvbuff_t *, packet_info *, proto_tree *, guint, ieee802154_packet *);
+static int dissect_802154_eb_filter (tvbuff_t *, packet_info *, proto_tree *, void *);
+static int dissect_802154_tsch_time_sync (tvbuff_t *, packet_info *, proto_tree *, void *);
+static int dissect_802154_tsch_timeslot (tvbuff_t *, packet_info *, proto_tree *, void *);
+static int dissect_802154_tsch_slotframe_link (tvbuff_t *, packet_info *, proto_tree *, void *);
+static int dissect_802154_channel_hopping (tvbuff_t *, packet_info *, proto_tree *, void *);
/* Sub-dissector helpers. */
static void dissect_ieee802154_fcf (tvbuff_t *, packet_info *, proto_tree *, ieee802154_packet *, guint *);
static void dissect_ieee802154_command (tvbuff_t *, packet_info *, proto_tree *, ieee802154_packet *);
@@ -331,6 +332,8 @@ static int hf_ieee802154_hie_csl = -1;
static int hf_ieee802154_hie_csl_phase = -1;
static int hf_ieee802154_hie_csl_period = -1;
static int hf_ieee802154_hie_csl_rendezvous_time = -1;
+static int hf_ieee802154_hie_global_time = -1;
+static int hf_ieee802154_hie_global_time_value = -1;
static int hf_ieee802154_payload_ies = -1;
static int hf_ieee802154_payload_ie_tlv = -1;
static int hf_ieee802154_payload_ie_type = -1;
@@ -339,18 +342,15 @@ static int hf_ieee802154_payload_ie_length = -1;
static int hf_ieee802154_pie_unsupported = -1;
static int hf_ieee802154_pie_termination = -1;
static int hf_ieee802154_pie_vendor = -1;
+static int hf_ieee802154_pie_vendor_oui = -1;
static int hf_ieee802154_pie_ietf = -1;
static int hf_ieee802154_mlme = -1;
-static int hf_ieee802154_payload_ie_vendor_oui = -1;
-static int hf_ieee802154_timeslot_ie = -1;
-static int hf_ieee802154_enhanced_beacon_filter_ie = -1;
static int hf_ieee802154_mlme_ie_data = -1;
-static int hf_ieee802154_psie_short = -1;
-static int hf_ieee802154_psie_type_short = -1;
+static int hf_ieee802154_mlme_ie_unsupported = -1;
+static int hf_ieee802154_psie = -1;
+static int hf_ieee802154_psie_type = -1;
static int hf_ieee802154_psie_id_short = -1;
static int hf_ieee802154_psie_length_short = -1;
-static int hf_ieee802154_psie_long = -1;
-static int hf_ieee802154_psie_type_long = -1;
static int hf_ieee802154_psie_id_long = -1;
static int hf_ieee802154_psie_length_long = -1;
@@ -367,8 +367,27 @@ static int hf_ieee802154_tsch_slotf_link_nb_links = -1;
static int hf_ieee802154_tsch_slotf_link_timeslot = -1;
static int hf_ieee802154_tsch_slotf_link_channel_offset = -1;
static int hf_ieee802154_tsch_slotf_link_options = -1;
+static int hf_ieee802154_tsch_slotf_link_options_tx = -1;
+static int hf_ieee802154_tsch_slotf_link_options_rx = -1;
+static int hf_ieee802154_tsch_slotf_link_options_shared = -1;
+static int hf_ieee802154_tsch_slotf_link_options_timkeeping = -1;
+static int hf_ieee802154_tsch_slotf_link_options_priority = -1;
static int hf_ieee802154_tsch_channel_hopping = -1;
static int hf_ieee802154_tsch_hopping_sequence_id = -1;
+static int hf_ieee802154_tsch_timeslot = -1;
+static int hf_ieee802154_tsch_timeslot_id = -1;
+static int hf_ieee802154_tsch_timeslot_cca_offset = -1;
+static int hf_ieee802154_tsch_timeslot_cca = -1;
+static int hf_ieee802154_tsch_timeslot_tx_offset = -1;
+static int hf_ieee802154_tsch_timeslot_rx_offset = -1;
+static int hf_ieee802154_tsch_timeslot_rx_ack_delay = -1;
+static int hf_ieee802154_tsch_timeslot_tx_ack_delay = -1;
+static int hf_ieee802154_tsch_timeslot_rx_wait = -1;
+static int hf_ieee802154_tsch_timeslot_ack_wait = -1;
+static int hf_ieee802154_tsch_timeslot_turnaround = -1;
+static int hf_ieee802154_tsch_timeslot_max_ack = -1;
+static int hf_ieee802154_tsch_timeslot_max_tx = -1;
+static int hf_ieee802154_tsch_timeslot_length = -1;
static int hf_ieee802154_psie_eb_filter = -1;
static int hf_ieee802154_psie_eb_filter_pjoin = -1;
@@ -417,6 +436,7 @@ static int hf_ieee802159_mpx_multiplex_id = -1;
static int hf_ieee802159_mpx_kmp_id = -1;
static int hf_ieee802159_mpx_kmp_vendor_oui = -1;
static int hf_ieee802159_mpx_fragment = -1;
+static int hf_ieee802159_mpx_wisun_subid = -1;
static int proto_zboss = -1;
static int hf_zboss_direction = -1;
@@ -512,6 +532,7 @@ static gint ett_ieee802154_hie_unsupported = -1;
static gint ett_ieee802154_hie_time_correction = -1;
static gint ett_ieee802154_hie_ht = -1;
static gint ett_ieee802154_hie_csl = -1;
+static gint ett_ieee802154_hie_global_time = -1;
static gint ett_ieee802154_payload_ie = -1;
static gint ett_ieee802154_payload_ie_tlv = -1;
static gint ett_ieee802154_pie_termination = -1;
@@ -521,16 +542,17 @@ static gint ett_ieee802154_pie_unsupported = -1;
static gint ett_ieee802154_mlme = -1;
static gint ett_ieee802154_mlme_payload = -1;
static gint ett_ieee802154_mlme_payload_data = -1;
+static gint ett_ieee802154_mlme_unsupported = -1;
+static gint ett_ieee802154_tsch_slotframe = -1;
+static gint ett_ieee802154_tsch_slotframe_list = -1;
+static gint ett_ieee802154_tsch_slotframe_link = -1;
+static gint ett_ieee802154_tsch_slotframe_link_options = -1;
static gint ett_ieee802154_tsch_timeslot = -1;
static gint ett_ieee802154_tsch_synch = -1;
static gint ett_ieee802154_channel_hopping = -1;
-static gint ett_ieee802154_psie_short = -1;
-static gint ett_ieee802154_psie_short_bitmap= -1;
-static gint ett_ieee802154_psie_long = -1;
-static gint ett_ieee802154_psie_long_bitmap = -1;
-static gint ett_ieee802154_psie_enh_beacon_flt = -1;
-static gint ett_ieee802154_psie_enh_beacon_flt_bitmap = -1;
-static gint ett_ieee802154_psie_slotframe_link_slotframes = -1;
+static gint ett_ieee802154_psie = -1;
+static gint ett_ieee802154_eb_filter = -1;
+static gint ett_ieee802154_eb_filter_bitmap = -1;
static gint ett_ieee802154_zigbee = -1;
static gint ett_ieee802154_zboss = -1;
static gint ett_ieee802154_p_ie_6top = -1;
@@ -576,16 +598,19 @@ static heur_dissector_list_t ieee802154_heur_subdissector_list;
/* For the IEs */
static dissector_table_t header_ie_dissector_table;
static dissector_table_t payload_ie_dissector_table;
+static dissector_table_t mlme_ie_dissector_table;
-static dissector_handle_t zigbee_beacon_handle;
static dissector_handle_t zigbee_ie_handle;
static dissector_handle_t zigbee_nwk_handle;
static dissector_handle_t ieee802154_handle;
static dissector_handle_t ieee802154_nonask_phy_handle;
static dissector_handle_t ieee802154_nofcs_handle;
-static dissector_table_t ethertype_table; // for the MPX-IE
-static dissector_handle_t eapol_handle; // for the MPX-IE
+/* Handles for MPX-IE the Multiplex ID */
+static dissector_table_t ethertype_table;
+static dissector_handle_t eapol_handle;
+static dissector_handle_t lowpan_handle;
+static dissector_handle_t wisun_sec_handle;
/* Versions */
static const value_string ieee802154_frame_versions[] = {
@@ -715,6 +740,7 @@ static const value_string ieee802154_header_ie_names[] = {
{ IEEE802154_HEADER_IE_RCC_CAP, "RCC Capabilities IE" },
{ IEEE802154_HEADER_IE_RCCN, "RCCN Descriptor IE" },
{ IEEE802154_HEADER_IE_GLOBAL_TIME, "Global Time IE" },
+ { IEEE802154_HEADER_IE_WISUN, "Wi-SUN IE" },
{ IEEE802154_HEADER_IE_DA_IE, "DA IE" },
{ IEEE802154_HEADER_IE_HT1, "Header Termination 1 IE" },
{ IEEE802154_HEADER_IE_HT2, "Header Termination 2 IE" },
@@ -731,16 +757,12 @@ static const value_string ieee802154_payload_ie_names[] = {
{ IEEE802154_PAYLOAD_IE_MLME, "MLME IE" },
{ IEEE802154_PAYLOAD_IE_VENDOR, "Vendor Specific IE" },
{ IEEE802154_PAYLOAD_IE_MPX, "MPX IE" },
+ { IEEE802154_PAYLOAD_IE_WISUN, "Wi-SUN IE" },
{ IEEE802154_PAYLOAD_IE_IETF, "IETF IE" },
{ IEEE802154_PAYLOAD_IE_TERMINATION, "Payload Termination IE" },
{ 0, NULL }
};
-static const value_string ieee802154_vendor_oui_names[] = {
- { IEEE802154_VENDOR_OUI_ZIGBEE, "ZigBee" },
- { 0, NULL }
-};
-
static const value_string ieee802154_psie_names[] = {
{ IEEE802154_MLME_SUBIE_CHANNEL_HOPPING, "Channel Hopping IE" },
{ IEEE802154_MLME_SUBIE_TSCH_SYNCH, "TSCH Synchronization IE" },
@@ -865,6 +887,7 @@ static const value_string mpx_transfer_type_vals[] = {
static const value_string mpx_multiplex_id_vals[] = {
{ IEEE802159_MPX_MULTIPLEX_ID_KMP, "KMP" },
+ { IEEE802159_MPX_MULTIPLEX_ID_WISUN, "Wi-SUN" },
{ 0, NULL }
};
@@ -881,11 +904,11 @@ static const value_string mpx_kmp_id_vals[] = {
{ 0, NULL }
};
-static const int * header_short_format_nested_ie[] = {
- &hf_ieee802154_psie_type_short,
- &hf_ieee802154_psie_id_short,
- &hf_ieee802154_psie_length_short,
- NULL
+static const value_string mpx_wisun_subid_vals[] = {
+ { IEEE802159_MPX_WISUN_SUBID_MHDS, "WM-MHDS" },
+ { IEEE802159_MPX_WISUN_SUBID_6LOWPAN, "WM-6LO" },
+ { IEEE802159_MPX_WISUN_SUBID_SECURITY, "WM-SEC" },
+ { 0, NULL }
};
/* Preferences for 2003 security */
@@ -907,7 +930,6 @@ static gboolean ieee802154_extend_auth = TRUE;
#define IEEE802154_CRC_XOROUT 0xFFFF
#define ieee802154_crc_tvb(tvb, offset) (crc16_ccitt_tvb_seed(tvb, offset, IEEE802154_CRC_SEED) ^ IEEE802154_CRC_XOROUT)
-
static int ieee802_15_4_short_address_to_str(const address* addr, gchar *buf, int buf_len)
{
guint16 ieee_802_15_4_short_addr = pletoh16(addr->data);
@@ -2060,15 +2082,14 @@ dissect_ieee802154_fcs:
* @param tree the tree to append this item to
* @param hf field index
* @param ett tree index
- * @param id the IE ID used to append the IE name to the parent item of tree
- * @param new_item if != NULL, pointer to store the item created for this Payload IE
* @returns the tree created for the Payload IE
*/
-static proto_tree*
-create_payload_ie_tree(tvbuff_t *tvb, proto_tree *tree, int hf, gint ett, guint16 id, proto_item** new_item)
+proto_tree*
+ieee802154_create_pie_tree(tvbuff_t *tvb, proto_tree *tree, int hf, gint ett)
{
proto_item *subitem;
proto_tree *subtree;
+ header_field_info *hfinfo;
static const int * tlv_fields[] = {
&hf_ieee802154_payload_ie_type,
&hf_ieee802154_payload_ie_id,
@@ -2078,153 +2099,189 @@ create_payload_ie_tree(tvbuff_t *tvb, proto_tree *tree, int hf, gint ett, guint1
subitem = proto_tree_add_item(tree, hf, tvb, 0, tvb_reported_length(tvb), ENC_NA);
subtree = proto_item_add_subtree(subitem, ett);
-
proto_tree_add_bitmask_with_flags(subtree, tvb, 0, hf_ieee802154_payload_ie_tlv, ett_ieee802154_payload_ie_tlv,
tlv_fields, ENC_LITTLE_ENDIAN, BMT_NO_FLAGS);
- const char *name = try_val_to_str(id, ieee802154_payload_ie_names);
- if (name) {
- proto_item_append_text(proto_tree_get_parent(tree), ", %s", name);
- } else {
- proto_item_append_text(proto_tree_get_parent(tree), ", Unknown IE 0x%02x", id);
- proto_item_append_text(subitem, ": 0x%02x", id);
- }
-
- if (new_item) {
- *new_item = subitem;
+ hfinfo = proto_registrar_get_nth(hf);
+ if (hfinfo && hfinfo->name) {
+ proto_item_append_text(proto_tree_get_parent(tree), ", %s", hfinfo->name);
}
return subtree;
}
/**
- * Subdissector for the MLME Channel Hopping Payload IE
+ * Create a tree for a Payload Sub-IE incl. the TLV header and append the IE name to the parent item
*
- * Reference: IEEE 802.15.4-2015 - 7.4.4.31 Channel hopping IE
- *
- * @param tvb pointer to buffer containing raw packet.
- * @param tree pointer to data tree wireshark uses to display packet.
- * @param psie_remaining size of the Information Element.
- * @param offset offset into the tvbuff to begin dissection.
+ * @param tvb the tv buffer
+ * @param tree the tree to append this item to
+ * @param hf field index
+ * @param ett tree index
+ * @returns the tree created for the Payload IE
*/
-static void
-dissect_802154_channel_hopping(tvbuff_t *tvb, proto_tree *tree, guint16 psie_remaining, guint *offset)
+proto_tree*
+ieee802154_create_psie_tree(tvbuff_t *tvb, proto_tree *tree, int hf, gint ett)
{
- proto_item *tsch_channel_hopping_data_item = NULL;
- proto_tree *tsch_channel_hopping_data_tree = NULL;
- static const int * fields_long[] = {
- &hf_ieee802154_psie_type_long,
+ proto_item *subitem;
+ proto_tree *subtree;
+ header_field_info *hfinfo;
+
+ subitem = proto_tree_add_item(tree, hf, tvb, 0, tvb_reported_length(tvb), ENC_NA);
+ subtree = proto_item_add_subtree(subitem, ett);
+ if (tvb_get_letohs(tvb, 0) & IEEE802154_PSIE_TYPE_MASK) {
+ static const int * fields_long[] = {
+ &hf_ieee802154_psie_type,
&hf_ieee802154_psie_id_long,
&hf_ieee802154_psie_length_long,
NULL
- };
-
- tsch_channel_hopping_data_item = proto_tree_add_item(tree, hf_ieee802154_tsch_channel_hopping, tvb, (*offset), 2 + psie_remaining, ENC_NA);
- tsch_channel_hopping_data_tree = proto_item_add_subtree(tsch_channel_hopping_data_item, ett_ieee802154_mlme_payload);
- proto_tree_add_bitmask(tsch_channel_hopping_data_tree, tvb, *offset, hf_ieee802154_psie_long, ett_ieee802154_psie_long_bitmap, fields_long, ENC_LITTLE_ENDIAN);
- *offset += 2;
-
- proto_tree_add_item(tsch_channel_hopping_data_tree, hf_ieee802154_tsch_hopping_sequence_id, tvb, (*offset), 1, ENC_LITTLE_ENDIAN);
+ };
+ proto_tree_add_bitmask(subtree, tvb, 0, hf_ieee802154_psie, ett_ieee802154_psie, fields_long, ENC_LITTLE_ENDIAN);
+ }
+ else {
+ static const int * fields_short[] = {
+ &hf_ieee802154_psie_type,
+ &hf_ieee802154_psie_id_short,
+ &hf_ieee802154_psie_length_short,
+ NULL
+ };
+ proto_tree_add_bitmask(subtree, tvb, 0, hf_ieee802154_psie, ett_ieee802154_psie, fields_short, ENC_LITTLE_ENDIAN);
+ }
- if (psie_remaining > 1) {
- proto_tree_add_item(tsch_channel_hopping_data_tree, hf_ieee802154_mlme_ie_data, tvb, *offset, psie_remaining, ENC_NA);
+ hfinfo = proto_registrar_get_nth(hf);
+ if (hfinfo && hfinfo->name) {
+ proto_item_append_text(proto_tree_get_parent(tree), ", %s", hfinfo->name);
}
- *offset += psie_remaining;
-} /* dissect_802154_channel_hopping */
+ return subtree;
+}
/**
- * Subdissector for the Payload Information Element MLME TSCH Synchronization
- *
- * @param tvb pointer to buffer containing raw packet.
- * @param tree pointer to data tree wireshark uses to display packet.
- * @param offset offset into the tvbuff to begin dissection.
+ * Subdissector for the MLME Channel Hopping Payload IE
*/
-static void
-dissect_802154_tsch_time_sync(tvbuff_t *tvb, proto_tree *tree, int *offset, guint psie_remaining)
+static int
+dissect_802154_channel_hopping(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
{
- proto_item *tsch_sync_data_item = NULL;
- proto_tree *tsch_sync_data_tree = NULL;
+ proto_tree *subtree = ieee802154_create_psie_tree(tvb, tree, hf_ieee802154_tsch_channel_hopping, ett_ieee802154_mlme_payload);
- tsch_sync_data_item = proto_tree_add_item(tree, hf_ieee802154_tsch_sync, tvb, *offset, 2 + psie_remaining, ENC_NA);
- tsch_sync_data_tree = proto_item_add_subtree(tsch_sync_data_item, ett_ieee802154_tsch_synch);
+ proto_tree_add_item(subtree, hf_ieee802154_tsch_hopping_sequence_id, tvb, 2, 1, ENC_LITTLE_ENDIAN);
- proto_tree_add_bitmask(tsch_sync_data_tree, tvb, *offset, hf_ieee802154_psie_short, ett_ieee802154_psie_short_bitmap, header_short_format_nested_ie, ENC_LITTLE_ENDIAN);
- *offset += 2;
+ if (tvb_reported_length_remaining(tvb, 3) > 1) {
+ /* TODO: There's still a huge amount of optional stuff that could follow */
+ proto_tree_add_item(subtree, hf_ieee802154_mlme_ie_data, tvb, 3, tvb_reported_length_remaining(tvb, 3), ENC_NA);
+ }
+ return tvb_reported_length(tvb);
+} /* dissect_802154_channel_hopping */
- proto_tree_add_item(tsch_sync_data_tree, hf_ieee802154_tsch_asn, tvb, (*offset), 5, ENC_LITTLE_ENDIAN);
- *offset += 5;
+/**
+ * Subdissector for the Nested MLME IE for TSCH Synchronization
+ */
+static int
+dissect_802154_tsch_time_sync(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
+{
+ proto_tree *subtree = ieee802154_create_psie_tree(tvb, tree, hf_ieee802154_tsch_sync, ett_ieee802154_tsch_synch);
- proto_tree_add_item(tsch_sync_data_tree, hf_ieee802154_tsch_join_metric, tvb, (*offset), 1, ENC_LITTLE_ENDIAN);
- *offset += 1;
+ proto_tree_add_item(subtree, hf_ieee802154_tsch_asn, tvb, 2, 5, ENC_LITTLE_ENDIAN);
+ proto_tree_add_item(subtree, hf_ieee802154_tsch_join_metric, tvb, 7, 1, ENC_LITTLE_ENDIAN);
+ return 8;
}/* dissect_802154_tsch_time_sync*/
/**
- * Subdissector for the Payload Information Element MLME TSCH Slotframe and Link
- *
- * @param tvb pointer to buffer containing raw packet.
- * @param tree pointer to data tree wireshark uses to display packet.
- * @param psie_remaining size of the Information Element.
- * @param offset offset into the tvbuff to begin dissection.
+ * Subdissector for the Nested MLME IE for TSCH Slotframe and Link
*/
-static void
-dissect_802154_tsch_slotframe_link(tvbuff_t *tvb, proto_tree *tree, guint16 psie_remaining, guint16 psie_id,
- guint *offset)
+static int
+dissect_802154_tsch_slotframe_link(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
{
- guint8 nb_slotframes;
- guint8 nb_slotframes_aux;
- guint8 nb_links;
- guint8 nb_links_aux;
- guint8 slotframe_index;
+ guint8 nb_slotframes;
+ guint8 slotframe_index;
+ proto_tree *subtree;
+ guint offset = 0;
- proto_item *tsch_slotframe_item;
- proto_tree *tsch_slotframe_tree;
+ subtree = ieee802154_create_psie_tree(tvb, tree, hf_ieee802154_tsch_slotframe, ett_ieee802154_tsch_slotframe);
+ offset += 2;
- proto_item *tsch_slotframe_list_item;
- proto_tree *tsch_slotframe_list_tree;
+ nb_slotframes = tvb_get_guint8(tvb, offset);
+ proto_tree_add_item(subtree, hf_ieee802154_tsch_slotf_link_nb_slotf, tvb, offset, 1, ENC_LITTLE_ENDIAN);
+ offset += 1;
+ for (slotframe_index = 1; slotframe_index <= nb_slotframes; slotframe_index++) {
+ /* Create a tree for the slotframe. */
+ guint8 nb_links = tvb_get_guint8(tvb, offset + 3);
+ proto_item *sf_item = proto_tree_add_none_format(subtree, hf_ieee802154_tsch_slotframe_list, tvb, offset, 4 + (5 * nb_links), "Slotframes [%u]", slotframe_index);
+ proto_tree *sf_tree = proto_item_add_subtree(sf_item, ett_ieee802154_tsch_slotframe_list);
+ proto_tree_add_item(sf_tree, hf_ieee802154_tsch_slotf_link_slotf_handle, tvb, offset, 1, ENC_LITTLE_ENDIAN);
+ proto_tree_add_item(sf_tree, hf_ieee802154_tsch_slotf_size, tvb, offset + 1, 2, ENC_LITTLE_ENDIAN);
+ proto_tree_add_item(sf_tree, hf_ieee802154_tsch_slotf_link_nb_links, tvb, offset + 3, 1, ENC_LITTLE_ENDIAN);
+
+ /* Create a tree for each link in the slotframe. */
+ offset += 4;
+ while (nb_links > 0) {
+ static const int * fields_options[] = {
+ &hf_ieee802154_tsch_slotf_link_options_tx,
+ &hf_ieee802154_tsch_slotf_link_options_rx,
+ &hf_ieee802154_tsch_slotf_link_options_shared,
+ &hf_ieee802154_tsch_slotf_link_options_timkeeping,
+ &hf_ieee802154_tsch_slotf_link_options_priority,
+ NULL
+ };
+
+ proto_item *link_item = proto_tree_add_item(sf_tree, hf_ieee802154_tsch_link_info, tvb, offset, 5, ENC_NA);
+ proto_tree *link_tree = proto_item_add_subtree(link_item, ett_ieee802154_tsch_slotframe_link);
+ proto_tree_add_item(link_tree, hf_ieee802154_tsch_slotf_link_timeslot, tvb, offset, 2, ENC_LITTLE_ENDIAN);
+ proto_tree_add_item(link_tree, hf_ieee802154_tsch_slotf_link_channel_offset, tvb, offset + 2, 2, ENC_LITTLE_ENDIAN);
+ proto_tree_add_bitmask(link_tree, tvb, offset + 4, hf_ieee802154_tsch_slotf_link_options, ett_ieee802154_tsch_slotframe_link_options, fields_options, ENC_LITTLE_ENDIAN);
+ nb_links -= 1;
+ offset += 5;
+ }
+ }
- proto_item *tsch_slotframe_data_item;
- proto_tree *tsch_slotframe_data_tree;
+ return offset;
+}/* dissect_802154_tsch_slotframe_link */
+/**
+ * Subdissector for the Nested MLME IE for TSCH Timeslot Description
+ */
+static int
+dissect_802154_tsch_timeslot(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
+{
+ proto_tree *subtree = ieee802154_create_psie_tree(tvb, tree, hf_ieee802154_tsch_timeslot, ett_ieee802154_tsch_timeslot);
+ guint offset = 2;
- tsch_slotframe_item = proto_tree_add_item(tree, hf_ieee802154_tsch_slotframe, tvb, *offset, 2+ psie_remaining, ENC_NA);
- tsch_slotframe_tree = proto_item_add_subtree(tsch_slotframe_item, ett_ieee802154_psie_slotframe_link_slotframes);
- proto_tree_add_bitmask(tsch_slotframe_tree, tvb, *offset, hf_ieee802154_psie_short, ett_ieee802154_psie_short_bitmap, header_short_format_nested_ie, ENC_LITTLE_ENDIAN);
- proto_item_set_text(tsch_slotframe_tree, "%s", val_to_str_const(psie_id, ieee802154_psie_names, "Unknown IE"));
+ proto_tree_add_item(subtree, hf_ieee802154_tsch_timeslot_id, tvb, 2, 1, ENC_LITTLE_ENDIAN);
+ offset++;
+
+ if (tvb_reported_length(tvb) > offset) {
+ const int timeslot_fields[] = {
+ hf_ieee802154_tsch_timeslot_cca_offset,
+ hf_ieee802154_tsch_timeslot_cca,
+ hf_ieee802154_tsch_timeslot_tx_offset,
+ hf_ieee802154_tsch_timeslot_rx_offset,
+ hf_ieee802154_tsch_timeslot_rx_ack_delay,
+ hf_ieee802154_tsch_timeslot_tx_ack_delay,
+ hf_ieee802154_tsch_timeslot_rx_wait,
+ hf_ieee802154_tsch_timeslot_ack_wait,
+ hf_ieee802154_tsch_timeslot_turnaround,
+ hf_ieee802154_tsch_timeslot_max_ack,
+ };
+ unsigned int i;
+ for (i = 0; i < sizeof(timeslot_fields)/sizeof(timeslot_fields[1]); i++) {
+ proto_tree_add_item(subtree, timeslot_fields[i], tvb, offset, 2, ENC_LITTLE_ENDIAN);
+ offset += 2;
+ }
- *offset += 2;
- nb_slotframes = tvb_get_guint8(tvb, *offset);
- nb_slotframes_aux = nb_slotframes;
-
- proto_tree_add_item(tsch_slotframe_tree, hf_ieee802154_tsch_slotf_link_nb_slotf, tvb, (*offset), 1, ENC_LITTLE_ENDIAN);
- *offset += 1;
-
- slotframe_index = 1;
- while (nb_slotframes_aux > 0) {
- nb_links = tvb_get_guint8(tvb, *offset + 3);
- nb_links_aux = nb_links;
-
- tsch_slotframe_list_item = proto_tree_add_none_format(tsch_slotframe_tree, hf_ieee802154_tsch_slotframe_list, tvb, *offset, 4 + 5 * nb_links_aux, "Slotframes [%u]", slotframe_index);
- tsch_slotframe_list_tree = proto_item_add_subtree(tsch_slotframe_list_item, ett_ieee802154_psie_slotframe_link_slotframes);
-
- slotframe_index += 1;
-
- proto_tree_add_item(tsch_slotframe_list_tree, hf_ieee802154_tsch_slotf_link_slotf_handle, tvb, (*offset), 1, ENC_LITTLE_ENDIAN);
- proto_tree_add_item(tsch_slotframe_list_tree, hf_ieee802154_tsch_slotf_size, tvb, (*offset) + 1, 2, ENC_LITTLE_ENDIAN);
- proto_tree_add_item(tsch_slotframe_list_tree, hf_ieee802154_tsch_slotf_link_nb_links, tvb, (*offset) + 3, 1, ENC_LITTLE_ENDIAN);
-
- nb_slotframes_aux -= 1;
- *offset += 4;
- while (nb_links_aux > 0) {
- tsch_slotframe_data_item = proto_tree_add_item(tsch_slotframe_list_tree, hf_ieee802154_tsch_link_info, tvb, *offset, 5, ENC_NA);
- tsch_slotframe_data_tree = proto_item_add_subtree(tsch_slotframe_data_item, ett_ieee802154_mlme_payload_data);
- proto_tree_add_item(tsch_slotframe_data_tree, hf_ieee802154_tsch_slotf_link_timeslot, tvb, (*offset), 2, ENC_LITTLE_ENDIAN);
- proto_tree_add_item(tsch_slotframe_data_tree, hf_ieee802154_tsch_slotf_link_channel_offset, tvb, (*offset) + 2, 2, ENC_LITTLE_ENDIAN);
- proto_tree_add_item(tsch_slotframe_data_tree, hf_ieee802154_tsch_slotf_link_options, tvb, (*offset) + 4, 1, ENC_LITTLE_ENDIAN);
- nb_links_aux -= 1;
- *offset += 5;
+ /* The last two fields are may have different encodings depending on the length of the IE. */
+ if (tvb_reported_length_remaining(tvb, offset) > 4) {
+ proto_tree_add_item(subtree, hf_ieee802154_tsch_timeslot_max_tx, tvb, offset, 3, ENC_LITTLE_ENDIAN);
+ offset += 3;
+ proto_tree_add_item(subtree, hf_ieee802154_tsch_timeslot_length, tvb, offset, 3, ENC_LITTLE_ENDIAN);
+ offset += 3;
+ }
+ else {
+ proto_tree_add_item(subtree, hf_ieee802154_tsch_timeslot_max_tx, tvb, offset, 2, ENC_LITTLE_ENDIAN);
+ offset += 2;
+ proto_tree_add_item(subtree, hf_ieee802154_tsch_timeslot_length, tvb, offset, 2, ENC_LITTLE_ENDIAN);
+ offset += 2;
}
}
-}/* dissect_802154_tsch_slotframe_link */
+ return offset;
+} /* dissect_802154_tsch_timeslot */
/**
* Subdissector for the 6TOP Protocol contained within the Payload Information Elements.
@@ -2234,8 +2291,7 @@ dissect_ietf_ie(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *ies_tree, voi
{
const guint8 supported_6p_version = 0x00;
- proto_tree *p_inf_elem_tree = create_payload_ie_tree(tvb, ies_tree, hf_ieee802154_pie_ietf, ett_ieee802154_pie_ietf,
- IEEE802154_PAYLOAD_IE_IETF, NULL);
+ proto_tree *p_inf_elem_tree = ieee802154_create_pie_tree(tvb, ies_tree, hf_ieee802154_pie_ietf, ett_ieee802154_pie_ietf);
guint offset = 2;
guint pie_length = tvb_reported_length(tvb) - 2;
guint8 subie;
@@ -2581,15 +2637,14 @@ dissect_ieee802154_pendaddr(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *t
* @param tree the tree to append this item to
* @param hf field index
* @param ett tree index
- * @param id the IE ID used to append the IE name to the parent item of tree
- * @param new_item if != NULL, pointer to store the item created for this Header IE
* @returns the tree created for the Header IE
*/
-static proto_tree*
-create_header_ie_tree(tvbuff_t *tvb, proto_tree *tree, int hf, gint ett, guint16 id, proto_item** new_item)
+proto_tree*
+ieee802154_create_hie_tree(tvbuff_t *tvb, proto_tree *tree, int hf, gint ett)
{
proto_item *subitem;
proto_tree *subtree;
+ header_field_info *hfinfo;
static const int * tlv_fields[] = {
&hf_ieee802154_header_ie_type,
&hf_ieee802154_header_ie_id,
@@ -2599,20 +2654,12 @@ create_header_ie_tree(tvbuff_t *tvb, proto_tree *tree, int hf, gint ett, guint16
subitem = proto_tree_add_item(tree, hf, tvb, 0, tvb_reported_length(tvb), ENC_NA);
subtree = proto_item_add_subtree(subitem, ett);
-
proto_tree_add_bitmask_with_flags(subtree, tvb, 0, hf_ieee802154_header_ie_tlv, ett_ieee802154_header_ie_tlv,
tlv_fields, ENC_LITTLE_ENDIAN, BMT_NO_FLAGS);
- const char *name = try_val_to_str(id, ieee802154_header_ie_names);
- if (name) {
- proto_item_append_text(proto_tree_get_parent(tree), ", %s", name);
- } else {
- proto_item_append_text(proto_tree_get_parent(tree), ", Unknown IE 0x%02x", id);
- proto_item_append_text(subitem, ": 0x%02x", id);
- }
-
- if (new_item) {
- *new_item = subitem;
+ hfinfo = proto_registrar_get_nth(hf);
+ if (hfinfo && hfinfo->name) {
+ proto_item_append_text(proto_tree_get_parent(tree), ", %s", hfinfo->name);
}
return subtree;
}
@@ -2628,7 +2675,7 @@ create_header_ie_tree(tvbuff_t *tvb, proto_tree *tree, int hf, gint ett, guint16
static int
dissect_hie_csl(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
{
- proto_tree *subtree = create_header_ie_tree(tvb, tree, hf_ieee802154_hie_csl, ett_ieee802154_hie_csl, IEEE802154_HEADER_IE_CSL, NULL);
+ proto_tree *subtree = ieee802154_create_hie_tree(tvb, tree, hf_ieee802154_hie_csl, ett_ieee802154_hie_csl);
proto_tree_add_item(subtree, hf_ieee802154_hie_csl_phase, tvb, 2, 2, ENC_LITTLE_ENDIAN);
proto_tree_add_item(subtree, hf_ieee802154_hie_csl_period, tvb, 4, 2, ENC_LITTLE_ENDIAN);
if (tvb_reported_length(tvb) >= 8) {
@@ -2653,14 +2700,13 @@ dissect_hie_time_correction(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *i
&hf_ieee802154_nack,
NULL
};
- proto_item *subitem;
- proto_tree *tree = create_header_ie_tree(tvb, ies_tree, hf_ieee802154_hie_time_correction, ett_ieee802154_hie_time_correction,
- IEEE802154_HEADER_IE_TIME_CORR, &subitem);
+ proto_tree *tree = ieee802154_create_hie_tree(tvb, ies_tree, hf_ieee802154_hie_time_correction, ett_ieee802154_hie_time_correction);
guint16 time_sync_value = tvb_get_letohs(tvb, 2);
proto_tree_add_bitmask_with_flags(tree, tvb, 2, hf_ieee802154_hie_time_correction_time_sync_info, ett_ieee802154_header_ie,
fields, ENC_LITTLE_ENDIAN, BMT_NO_FLAGS);
+
if (time_sync_value & ~(0x8fff)) {
- expert_add_info(pinfo, subitem, &ei_ieee802154_time_correction_error);
+ expert_add_info(pinfo, proto_tree_get_parent(tree), &ei_ieee802154_time_correction_error);
}
if (time_sync_value & 0x8000) {
proto_item_append_text(proto_tree_get_parent(ies_tree), ": NACK");
@@ -2668,6 +2714,17 @@ dissect_hie_time_correction(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *i
return 2 + 2;
}
+static int
+dissect_hie_global_time(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
+{
+ nstime_t ts;
+ proto_tree *subtree = ieee802154_create_hie_tree(tvb, tree, hf_ieee802154_hie_global_time, ett_ieee802154_hie_global_time);
+ ts.secs = tvb_get_letohl(tvb, 2);
+ ts.nsecs = 0;
+ proto_tree_add_time(subtree, hf_ieee802154_hie_global_time_value, tvb, 2, 4, &ts);
+ return 2 + 4;
+}
+
/**
* Subdissector for Header IEs (Information Elements)
*
@@ -2698,19 +2755,18 @@ dissect_ieee802154_header_ie(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree
tvbuff_t *ie_tvb = tvb_new_subset_length(tvb, offset, 2 + length);
if (id == IEEE802154_HEADER_IE_HT1 || id == IEEE802154_HEADER_IE_HT2) {
- create_header_ie_tree(ie_tvb, ies_tree, id == IEEE802154_HEADER_IE_HT1 ? hf_ieee802154_hie_ht1 : hf_ieee802154_hie_ht2,
- ett_ieee802154_hie_ht, id, NULL);
+ int hf_term_ie = (id == IEEE802154_HEADER_IE_HT1) ? hf_ieee802154_hie_ht1 : hf_ieee802154_hie_ht2;
+ ieee802154_create_hie_tree(ie_tvb, ies_tree, hf_term_ie, ett_ieee802154_hie_ht);
consumed = 2;
} else {
TRY {
consumed = dissector_try_uint_new(header_ie_dissector_table, id, ie_tvb, pinfo, ies_tree, FALSE, packet);
if (consumed == 0) {
- proto_item *subitem;
- proto_tree *subtree = create_header_ie_tree(ie_tvb, ies_tree, hf_ieee802154_hie_unsupported,
- ett_ieee802154_hie_unsupported, id, &subitem);
+ proto_tree *subtree = ieee802154_create_hie_tree(ie_tvb, ies_tree, hf_ieee802154_hie_unsupported,
+ ett_ieee802154_hie_unsupported);
proto_tree_add_item(subtree, hf_ieee802154_ie_unknown_content, ie_tvb, 2, length, ENC_NA);
consumed = 2 + length;
- expert_add_info(pinfo, subitem, &ei_ieee802154_ie_unsupported_id);
+ expert_add_info(pinfo, proto_tree_get_parent(subtree), &ei_ieee802154_ie_unsupported_id);
}
}
CATCH_ALL {
@@ -2728,7 +2784,7 @@ dissect_ieee802154_header_ie(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree
offset += 2 + length;
if (id == IEEE802154_HEADER_IE_HT1 || id == IEEE802154_HEADER_IE_HT2) {
- packet->payload_ie_present = id == IEEE802154_HEADER_IE_HT1;
+ packet->payload_ie_present = (id == IEEE802154_HEADER_IE_HT1);
break;
}
} while ((tvb_reported_length_remaining(tvb, offset) > IEEE802154_MIC_LENGTH(packet->security_level) + IEEE802154_FCS_LEN + 1));
@@ -2737,205 +2793,13 @@ dissect_ieee802154_header_ie(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree
return offset - orig_offset;
}
-/**
- * Subdissector for MAC Layer Management Entitiy (MLME) Payload Sub IEs
- *
- * Reference: IEEE 802.15.4-2015: 7.4.3.2 MLME IE
- *
- * @param tvb pointer to buffer containing raw packet.
- * @param pinfo pointer to packet information fields (unused).
- * @param tree pointer to command subtree.
- * @param offset offset into the tvbuff to begin dissection.
- */
static int
-dissect_ieee802154_payload_mlme_sub_ie(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
-{
- guint16 psie_ie;
- guint16 psie_id;
- guint psie_remaining = 0;
- int orig_offset = offset;
-
- psie_ie = tvb_get_letohs(tvb, offset);
- if (psie_ie & IEEE802154_PSIE_TYPE_MASK) {
- /* long format: Table 7-17-Sub-ID allocation for long format */
- psie_id = (guint16) ((psie_ie & IEEE802154_PSIE_ID_MASK_LONG) >> 11);
- psie_remaining = (guint) (psie_ie & IEEE802154_PSIE_LENGTH_MASK_LONG);
- }
- else {
- /* short format: Table 7-16-Sub-ID allocation for short format */
- psie_id = (guint16) ((psie_ie & IEEE802154_PSIE_ID_MASK_SHORT) >> 8);
- psie_remaining = (guint) (psie_ie & IEEE802154_PSIE_LENGTH_MASK_SHORT);
- }
-
- switch (psie_id) {
-
- case IEEE802154_MLME_SUBIE_TSCH_SYNCH:
- // 7.4.4.2 TSCH Synchronization IE
- dissect_802154_tsch_time_sync(tvb, tree, &offset, psie_remaining);
- break;
-
- case IEEE802154_MLME_SUBIE_TSCH_SLOTFR_LINK:
- // 7.4.4.3 TSCH Slotframe and Link IE
- dissect_802154_tsch_slotframe_link(tvb, tree, psie_remaining, psie_id, &offset);
- break;
-
- case IEEE802154_MLME_SUBIE_TSCH_TIMESLOT:
- // 7.4.4.4 TSCH Timeslot IE
- dissect_802154_tsch_timeslot(tvb, tree, psie_remaining, psie_id, &offset);
- break;
-
- case IEEE802154_MLME_SUBIE_ENHANCED_BEACON_FILTER:
- // 7.4.4.6 Enhanced Beacon Filter IE
- dissect_802154_enhanced_beacon_filter(tvb, tree, psie_remaining, &offset);
- break;
-
- case IEEE802154_MLME_SUBIE_CHANNEL_HOPPING:
- // 7.4.4.31 Channel hopping IE
- dissect_802154_channel_hopping(tvb, tree, psie_remaining, &offset);
- break;
-
- case IEEE802154_MLME_SUBIE_HOPPING_TIMING:
- // 7.4.4.5 Hopping timing IE
- // TODO
-
- case IEEE802154_MLME_SUBIE_MAC_METRICS:
- // 7.4.4.7 MAC Metrics IE
- // TODO
-
- case IEEE802154_MLME_SUBIE_ALL_MAC_METRICS:
- // 7.4.4.8 All MAC Metrics IE
- // TODO
-
- case IEEE802154_MLME_SUBIE_COEXISTENCE_SPEC:
- // 7.4.4.9 Coexistence Specification IE
- // TODO
-
- case IEEE802154_MLME_SUBIE_SUN_DEVICE_CAPABILITIES:
- // 7.4.4.10 SUN Device Capabilities IE
- // TODO
-
- case IEEE802154_MLME_SUBIE_SUN_FSK_GEN_PHY:
- // 7.4.4.11 SUN FSK Generic PHY IE
- // TODO
-
- case IEEE802154_MLME_SUBIE_MODE_SWITCH_PARAMETER:
- // 7.4.4.12 Mode Switch Parameter IE
- // TODO
-
- case IEEE802154_MLME_SUBIE_PHY_PARAMETER_CHANGE:
- // 7.4.4.13 PHY Parameter Change IE
- // TODO
-
- case IEEE802154_MLME_SUBIE_O_QPSK_PHY_MODE:
- // 7.4.4.14 O-QPSK PHY Mode IE
- // TODO
-
- case IEEE802154_MLME_SUBIE_PCA_ALLOCATION:
- // 7.4.4.15 PCA Allocation IE
- // TODO
-
- case IEEE802154_MLME_SUBIE_DSSS_OPER_MODE:
- // 7.4.4.16 LECIM DSSS Operating Mode IE
- // TODO
-
- case IEEE802154_MLME_SUBIE_FSK_OPER_MODE:
- // 7.4.4.17 LECIM FSK Operating Mode IE
- // TODO
-
- case IEEE802154_MLME_SUBIE_TVWS_PHY_OPE_MODE:
- // 7.4.4.18 TVWS PHY Operating Mode Description IE
- // TODO
-
- case IEEE802154_MLME_SUBIE_TVWS_DEVICE_CAPAB:
- // 7.4.4.19 TVWS Device Capabilities IE
- // TODO
-
- case IEEE802154_MLME_SUBIE_TVWS_DEVICE_CATEG:
- // 7.4.4.20 TVWS Device Category IE
- // TODO
-
- case IEEE802154_MLME_SUBIE_TVWS_DEVICE_IDENTIF:
- // 7.4.4.21 TVWS Device Identification IE
- // TODO
-
- case IEEE802154_MLME_SUBIE_TVWS_DEVICE_LOCATION:
- // 7.4.4.22 TVWS Device Location IE
- // TODO
-
- case IEEE802154_MLME_SUBIE_TVWS_CH_INFOR_QUERY:
- // 7.4.4.23 TVWS Channel Information Query IE
- // TODO
-
- case IEEE802154_MLME_SUBIE_TVWS_CH_INFOR_SOURCE:
- // 7.4.4.24 TVWS Channel Information Source IE
- // TODO
-
- case IEEE802154_MLME_SUBIE_CTM:
- // 7.4.4.25 CTM IE
- // TODO
-
- case IEEE802154_MLME_SUBIE_TIMESTAMP:
- // 7.4.4.26 Timestamp IE
- // TODO
-
- case IEEE802154_MLME_SUBIE_TIMESTAMP_DIFF:
- // 7.4.4.27 Timestamp Difference IE
- // TODO
-
- case IEEE802154_MLME_SUBIE_TMCP_SPECIFICATION:
- // 7.4.4.28 TMCTP Specification IE
- // TODO
-
- case IEEE802154_MLME_SUBIE_RCC_PHY_OPER_MODE:
- // 7.4.4.29 RCC PHY Operating Mode IE
- // TODO
-
- default:
- offset += 2;
- if (psie_remaining) {
- proto_tree_add_item(tree, hf_ieee802154_mlme_ie_data, tvb, offset, psie_remaining, ENC_NA);
- expert_add_info(pinfo, tree, &ei_ieee802154_ie_unsupported_id);
- offset += psie_remaining;
- }
- break;
- }
-
- return (offset - orig_offset);
-}
-
-/**
- * Subdissector for MAC Layer Management Entitiy (MLME) Payload Sub IEs
- *
- * Reference: IEEE 802.15.4-2015 - 7.4.4.4 TSCH Timeslot IE
- */
-static void
-dissect_802154_tsch_timeslot(tvbuff_t *tvb, proto_tree *tree, guint psie_remaining, guint16 psie_id, int *offset)
-{
- proto_tree * timeslot_tree;
- proto_item * timeslot_item;
-
- timeslot_item = proto_tree_add_item(tree, hf_ieee802154_timeslot_ie, tvb, *offset, 2 + psie_remaining, ENC_NA);
- timeslot_tree = proto_item_add_subtree(timeslot_item, ett_ieee802154_tsch_timeslot);
- proto_tree_add_bitmask(timeslot_tree, tvb, *offset, hf_ieee802154_payload_ie_tlv, ett_ieee802154_psie_short_bitmap,
- header_short_format_nested_ie, ENC_LITTLE_ENDIAN);
-
- proto_item_set_text(timeslot_tree, "%s", val_to_str_const(psie_id, ieee802154_psie_names, "Unknown IE"));
- *offset += 2;
-
- if (psie_remaining) {
- proto_tree_add_item(timeslot_tree, hf_ieee802154_mlme_ie_data, tvb, *offset, psie_remaining, ENC_NA);
- *offset += psie_remaining;
- }
-}
-
-static void
-dissect_802154_enhanced_beacon_filter(tvbuff_t *tvb, proto_tree *tree, guint16 psie_remaining, gint *offset)
+dissect_802154_eb_filter(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
{
guint8 filter;
guint8 attr_len;
- guint32 attr_bitmap = 0;
- proto_item *item;
proto_tree *subtree;
+ guint offset = 0;
static const int * fields_eb_filter[] = {
&hf_ieee802154_psie_eb_filter_pjoin,
@@ -2946,47 +2810,75 @@ dissect_802154_enhanced_beacon_filter(tvbuff_t *tvb, proto_tree *tree, guint16 p
NULL
};
- item = proto_tree_add_item(tree, hf_ieee802154_enhanced_beacon_filter_ie, tvb, *offset, 2 + psie_remaining, ENC_NA);
- subtree = proto_item_add_subtree(item, ett_ieee802154_tsch_synch);
-
- proto_tree_add_bitmask(subtree, tvb, *offset, hf_ieee802154_psie_short, ett_ieee802154_psie_short_bitmap, header_short_format_nested_ie, ENC_LITTLE_ENDIAN);
- *offset += 2;
+ subtree = ieee802154_create_psie_tree(tvb, tree, hf_ieee802154_psie_eb_filter, ett_ieee802154_eb_filter);
+ offset += 2;
- filter = tvb_get_guint8(tvb, *offset);
- proto_tree_add_bitmask(subtree, tvb, (const guint) *offset, hf_ieee802154_psie_eb_filter,
- ett_ieee802154_psie_enh_beacon_flt_bitmap, fields_eb_filter,
- ENC_NA);
- *offset += 1;
+ filter = tvb_get_guint8(tvb, offset);
+ proto_tree_add_bitmask(subtree, tvb, offset, hf_ieee802154_psie_eb_filter,
+ ett_ieee802154_eb_filter_bitmap, fields_eb_filter, ENC_NA);
+ offset++;
if (filter & IEEE802154_MLME_PSIE_EB_FLT_LQI) {
- proto_tree_add_item(subtree, hf_ieee802154_psie_eb_filter_lqi_min, tvb, *offset, 1, ENC_NA);
- *offset += 1;
+ proto_tree_add_item(subtree, hf_ieee802154_psie_eb_filter_lqi_min, tvb, offset, 1, ENC_NA);
+ offset++;
}
if (filter & IEEE802154_MLME_PSIE_EB_FLT_PERCENT) {
- proto_tree_add_item(subtree, hf_ieee802154_psie_eb_filter_percent_prob, tvb, *offset, 1, ENC_NA);
- *offset += 1;
+ proto_tree_add_item(subtree, hf_ieee802154_psie_eb_filter_percent_prob, tvb, offset, 1, ENC_NA);
+ offset++;
}
attr_len = (guint8) ((filter & IEEE802154_MLME_PSIE_EB_FLT_ATTR_LEN) >> 3);
if (attr_len) {
/* just display in hex until we know how to decode */
- proto_tree_add_item(subtree, hf_ieee802154_psie_eb_filter_attr_id_bitmap, tvb, *offset, attr_len, attr_bitmap);
- *offset += attr_len;
+ proto_tree_add_item(subtree, hf_ieee802154_psie_eb_filter_attr_id_bitmap, tvb, offset, attr_len, ENC_LITTLE_ENDIAN);
+ offset += attr_len;
}
+
+ return offset;
}
/**
* Subdissector for MLME IEs
*/
static int
-dissect_pie_mlme(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *ies_tree, void *data _U_)
+dissect_pie_mlme(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ies_tree, void *data)
{
- proto_tree *tree = create_payload_ie_tree(tvb, ies_tree, hf_ieee802154_mlme, ett_ieee802154_mlme,
- IEEE802154_PAYLOAD_IE_MLME, NULL);
+ proto_tree *tree = ieee802154_create_pie_tree(tvb, ies_tree, hf_ieee802154_mlme, ett_ieee802154_mlme);
guint offset = 2;
+
while (tvb_reported_length_remaining(tvb, offset) > 1) {
- offset += dissect_ieee802154_payload_mlme_sub_ie(tvb, pinfo, tree, offset);
+ guint16 psie_ie = tvb_get_letohs(tvb, offset);
+ volatile guint16 psie_id;
+ tvbuff_t * psie_tvb;
+
+ if (psie_ie & IEEE802154_PSIE_TYPE_MASK) {
+ /* long format: Table 7-17-Sub-ID allocation for long format */
+ psie_id = (guint16) ((psie_ie & IEEE802154_PSIE_ID_MASK_LONG) >> 11);
+ psie_tvb = tvb_new_subset_length(tvb, offset, (psie_ie & IEEE802154_PSIE_LENGTH_MASK_LONG) + 2);
+ }
+ else {
+ /* short format: Table 7-16-Sub-ID allocation for short format */
+ psie_id = (guint16) ((psie_ie & IEEE802154_PSIE_ID_MASK_SHORT) >> 8);
+ psie_tvb = tvb_new_subset_length(tvb, offset, (psie_ie & IEEE802154_PSIE_LENGTH_MASK_SHORT) + 2);
+ }
+ offset += tvb_reported_length(psie_tvb);
+
+ /* Pass the tvb off to a subdissector. */
+ TRY {
+ guint consumed = dissector_try_uint_new(mlme_ie_dissector_table, psie_id, psie_tvb, pinfo, tree, FALSE, data);
+ if (consumed == 0) {
+ proto_tree *subtree = ieee802154_create_psie_tree(psie_tvb, tree, hf_ieee802154_mlme_ie_unsupported, ett_ieee802154_mlme_unsupported);
+ if (tvb_reported_length(psie_tvb) > 2) {
+ proto_tree_add_item(subtree, hf_ieee802154_mlme_ie_data, psie_tvb, 2, -1, ENC_NA);
+ }
+ expert_add_info(pinfo, subtree, &ei_ieee802154_ie_unsupported_id);
+ }
+ }
+ CATCH_ALL {
+ show_exception(tvb, pinfo, ies_tree, EXCEPT_CODE, GET_MESSAGE);
+ }
+ ENDTRY;
}
return offset;
}
@@ -3008,7 +2900,7 @@ dissect_mpx_ie(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *ies_tree, void
NULL
};
- proto_tree *tree = create_payload_ie_tree(tvb, ies_tree, hf_ieee802159_mpx, ett_ieee802159_mpx, IEEE802154_PAYLOAD_IE_MPX, NULL);
+ proto_tree *tree = ieee802154_create_pie_tree(tvb, ies_tree, hf_ieee802159_mpx, ett_ieee802159_mpx);
guint offset = 2;
guint8 transaction_control = tvb_get_guint8(tvb, offset);
guint8 transfer_type = (guint8) (transaction_control & IEEE802159_MPX_TRANSFER_TYPE_MASK);
@@ -3028,8 +2920,9 @@ dissect_mpx_ie(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *ies_tree, void
switch (transfer_type) { // cf. IEEE 802.15.9 Table 18 - Summary of different MPX IE formats
case IEEE802159_MPX_FULL_FRAME:
- proto_tree_add_item(tree, hf_ieee802159_mpx_multiplex_id, tvb, offset, 2, ENC_LITTLE_ENDIAN);
multiplex_id = tvb_get_letohs(tvb, offset);
+ proto_tree_add_uint_format_value(tree, hf_ieee802159_mpx_multiplex_id, tvb, offset, 2, multiplex_id, "%s (0x%04x)",
+ val_to_str_const(multiplex_id, (multiplex_id > 1500) ? etype_vals : mpx_multiplex_id_vals, "Unknown"), multiplex_id);
offset += 2;
break;
case IEEE802159_MPX_FULL_FRAME_NO_MUXID:
@@ -3095,12 +2988,34 @@ dissect_mpx_ie(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *ies_tree, void
expert_add_info(pinfo, proto_tree_get_parent(tree), &ei_ieee802159_mpx_unknown_kmp);
}
}
+ else if (multiplex_id == IEEE802159_MPX_MULTIPLEX_ID_WISUN) {
+ guint8 subid = tvb_get_guint8(tvb, offset);
+ proto_tree_add_item(tree, hf_ieee802159_mpx_wisun_subid, tvb, offset, 1, ENC_LITTLE_ENDIAN);
+ offset += 1;
+ switch (subid) {
+ case IEEE802159_MPX_WISUN_SUBID_6LOWPAN:
+ dissector = lowpan_handle;
+ break;
+
+ case IEEE802159_MPX_WISUN_SUBID_SECURITY:
+ dissector = wisun_sec_handle;
+ break;
+
+ case IEEE802159_MPX_WISUN_SUBID_MHDS:
+ expert_add_info(pinfo, proto_tree_get_parent(tree), &ei_ieee802159_mpx_unsupported_kmp);
+ break;
+
+ default:
+ expert_add_info(pinfo, proto_tree_get_parent(tree), &ei_ieee802159_mpx_unknown_kmp);
+ break;
+ }
+ }
+ else if (multiplex_id > 1500) {
+ dissector = dissector_get_uint_handle(ethertype_table, (guint)multiplex_id);
+ }
if (transfer_type == IEEE802159_MPX_FULL_FRAME || transfer_type == IEEE802159_MPX_FULL_FRAME_NO_MUXID) {
tvbuff_t * payload = tvb_new_subset_remaining(tvb, offset);
- if (multiplex_id > 1500) {
- dissector = dissector_get_uint_handle(ethertype_table, (guint)multiplex_id);
- }
if (dissector) {
call_dissector(dissector, payload, pinfo, proto_tree_get_root(tree)); // exceptions are caught in our caller
} else {
@@ -3120,8 +3035,7 @@ dissect_mpx_ie(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *ies_tree, void
static int
dissect_pie_vendor(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *ies_tree, void *data _U_)
{
- proto_tree *tree = create_payload_ie_tree(tvb, ies_tree, hf_ieee802154_pie_vendor, ett_ieee802154_pie_vendor,
- IEEE802154_PAYLOAD_IE_VENDOR, NULL);
+ proto_tree *tree = ieee802154_create_pie_tree(tvb, ies_tree, hf_ieee802154_pie_vendor, ett_ieee802154_pie_vendor);
guint offset = 2;
guint pie_length = tvb_reported_length(tvb) - 2;
@@ -3129,17 +3043,13 @@ dissect_pie_vendor(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *ies_tree,
guint32 vendor_oui;
vendor_oui = tvb_get_letoh24(tvb, offset);
- proto_item_append_text(tree, ", Vendor OUI: %06X (%s)", vendor_oui,
- val_to_str_const(vendor_oui, ieee802154_vendor_oui_names, "unknown"));
- proto_tree_add_uint_format_value(tree, hf_ieee802154_payload_ie_vendor_oui, tvb, offset, 3,
- vendor_oui, "%06X (%s)", vendor_oui, val_to_str_const(vendor_oui, ieee802154_vendor_oui_names, "unknown"));
+ proto_tree_add_item(tree, hf_ieee802154_pie_vendor_oui, tvb, offset, 3, ENC_LITTLE_ENDIAN);
offset += 3; /* adjust for vendor OUI */
pie_length -= 3;
next_tvb = tvb_new_subset_length(tvb, offset, pie_length);
switch (vendor_oui) {
-
- case IEEE802154_VENDOR_OUI_ZIGBEE:
+ case OUI_ZIGBEE:
call_dissector_with_data(zigbee_ie_handle, next_tvb, pinfo, tree, &pie_length);
break;
@@ -3176,18 +3086,17 @@ dissect_ieee802154_payload_ie(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree
tvbuff_t *ie_tvb = tvb_new_subset_length(tvb, offset, 2 + length);
if (id == IEEE802154_PAYLOAD_IE_TERMINATION) {
- create_payload_ie_tree(ie_tvb, ies_tree, hf_ieee802154_pie_termination, ett_ieee802154_pie_termination, id, NULL);
+ ieee802154_create_pie_tree(ie_tvb, ies_tree, hf_ieee802154_pie_termination, ett_ieee802154_pie_termination);
consumed = 2;
} else {
TRY {
consumed = dissector_try_uint_new(payload_ie_dissector_table, id, ie_tvb, pinfo, ies_tree, FALSE, packet);
if (consumed == 0) {
- proto_item *subitem;
- proto_tree *subtree = create_payload_ie_tree(ie_tvb, ies_tree, hf_ieee802154_pie_unsupported,
- ett_ieee802154_pie_unsupported, id, &subitem);
+ proto_tree *subtree = ieee802154_create_pie_tree(ie_tvb, ies_tree, hf_ieee802154_pie_unsupported,
+ ett_ieee802154_pie_unsupported);
proto_tree_add_item(subtree, hf_ieee802154_ie_unknown_content, ie_tvb, 2, length, ENC_NA);
consumed = 2 + length;
- expert_add_info(pinfo, subitem, &ei_ieee802154_ie_unsupported_id);
+ expert_add_info(pinfo, proto_tree_get_parent(subtree), &ei_ieee802154_ie_unsupported_id);
}
}
CATCH_ALL {
@@ -4382,6 +4291,15 @@ void proto_register_ieee802154(void)
{ "Rendezvous Time", "wpan.header_ie.csl.rendezvous_time", FT_INT16, BASE_DEC, NULL, 0x0,
"CSL Rendezvous Time in units of 10 symbols", HFILL }},
+ /* Global Time IE */
+ { &hf_ieee802154_hie_global_time,
+ { "Global Time IE", "wpan.header_ie.global_time", FT_NONE, BASE_NONE, NULL, 0x0,
+ NULL, HFILL }},
+
+ { &hf_ieee802154_hie_global_time_value,
+ { "Global Time", "wpan.header_ie.global_time.value", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_UTC, NULL, 0x0,
+ NULL, HFILL }},
+
/* Payload IEs */
{ &hf_ieee802154_payload_ies,
@@ -4417,53 +4335,78 @@ void proto_register_ieee802154(void)
{ "Vendor Specific IE", "wpan.payload_ie.vendor", FT_NONE, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
+ { &hf_ieee802154_pie_vendor_oui,
+ { "Vendor OUI", "wpan.payload_ie.vendor.oui", FT_UINT24, BASE_OUI, NULL, 0x0,
+ NULL, HFILL }},
+
{ &hf_ieee802154_mlme,
{ "MLME IE", "wpan.mlme", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
- { &hf_ieee802154_timeslot_ie,
- { "Timeslot IE", "wpan.timeslot", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
-
- { &hf_ieee802154_enhanced_beacon_filter_ie,
- { "Enhanced Beacon Filter IE", "wpan.enhanced_beacon_filter", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
+ { &hf_ieee802154_psie_type,
+ { "Type", "wpan.mlme.ie.type", FT_UINT16, BASE_DEC, VALS(ieee802154_psie_types),
+ IEEE802154_PSIE_TYPE_MASK, NULL, HFILL }},
- { &hf_ieee802154_psie_short,
- { "Payload Sub IE (short)", "wpan.payload_sub_ie.short", FT_UINT16, BASE_HEX, NULL,
+ { &hf_ieee802154_psie,
+ { "MLME Sub IE", "wpan.mlme.ie", FT_UINT16, BASE_HEX, NULL,
0x0, NULL, HFILL }},
- { &hf_ieee802154_psie_type_short,
- { "Type", "wpan.payload_sub_ie.type_short", FT_UINT16, BASE_DEC, VALS(ieee802154_psie_types),
- IEEE802154_PSIE_TYPE_MASK, NULL, HFILL }},
-
{ &hf_ieee802154_psie_id_short,
- { "Sub Id (Short)", "wpan.payload_sub_ie.id_short", FT_UINT16, BASE_HEX, VALS(ieee802154_psie_names),
+ { "Sub ID", "wpan.mlme.ie.id", FT_UINT16, BASE_HEX, VALS(ieee802154_psie_names),
IEEE802154_PSIE_ID_MASK_SHORT, NULL, HFILL }},
{ &hf_ieee802154_psie_length_short,
- { "Length", "wpan.payload_sub_ie.length_short", FT_UINT16, BASE_DEC, NULL,
+ { "Length", "wpan.mlme.ie.length", FT_UINT16, BASE_DEC, NULL,
IEEE802154_PSIE_LENGTH_MASK_SHORT, NULL, HFILL }},
- { &hf_ieee802154_psie_long,
- { "Payload Sub IE (long)", "wpan.payload_sub_ie.long", FT_UINT16, BASE_HEX, NULL,
- 0x0, NULL, HFILL }},
-
- { &hf_ieee802154_psie_type_long,
- { "Type", "wpan.payload_sub_ie.type_long", FT_UINT16, BASE_DEC, VALS(ieee802154_psie_types),
- IEEE802154_PSIE_TYPE_MASK, NULL, HFILL }},
-
{ &hf_ieee802154_psie_id_long,
- { "Sub Id (Long)", "wpan.payload_sub_ie.id_long", FT_UINT16, BASE_HEX, VALS(ieee802154_psie_names),
+ { "Sub ID", "wpan.mlme.ie.id", FT_UINT16, BASE_HEX, VALS(ieee802154_psie_names),
IEEE802154_PSIE_ID_MASK_LONG, NULL, HFILL }},
{ &hf_ieee802154_psie_length_long,
- { "Length", "wpan.payload_sub_ie.length_long", FT_UINT16, BASE_DEC, NULL,
+ { "Length", "wpan.mlme.ie.length", FT_UINT16, BASE_DEC, NULL,
IEEE802154_PSIE_LENGTH_MASK_LONG, NULL, HFILL }},
+ { &hf_ieee802154_mlme_ie_unsupported,
+ { "Unsupported Sub IE", "wpan.mlme.unsupported", FT_NONE, BASE_NONE, NULL,
+ 0, NULL, HFILL }},
+
+ { &hf_ieee802154_mlme_ie_data,
+ { "Data", "wpan.mlme.data", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
+
{ &hf_ieee802154_psie_eb_filter,
- { "Enhanced Beacon Filter", "wpan.payload_sub_ie.eb_filter", FT_UINT8, BASE_HEX, NULL,
+ { "Enhanced Beacon Filter", "wpan.eb_filter", FT_UINT8, BASE_HEX, NULL,
0, NULL, HFILL }},
+ { &hf_ieee802154_psie_eb_filter_pjoin,
+ { "Permit Join Filter", "wpan.eb_filter.pjoin", FT_BOOLEAN, 8, TFS(&tfs_enabled_disabled),
+ IEEE802154_MLME_PSIE_EB_FLT_PJOIN, NULL, HFILL }},
+
+ { &hf_ieee802154_psie_eb_filter_lqi,
+ { "LQI Filter", "wpan.eb_filter.lqi", FT_BOOLEAN, 8, TFS(&tfs_enabled_disabled),
+ IEEE802154_MLME_PSIE_EB_FLT_LQI, NULL, HFILL }},
+
+ { &hf_ieee802154_psie_eb_filter_lqi_min,
+ { "Minimum LQI", "wpan.eb_filter.lqi_minimum", FT_UINT8, BASE_DEC, NULL,
+ 0x0, NULL, HFILL }},
+
+ { &hf_ieee802154_psie_eb_filter_percent,
+ { "Probability to Respond", "wpan.eb_filter.contains_prob", FT_BOOLEAN, 8, TFS(&tfs_enabled_disabled),
+ IEEE802154_MLME_PSIE_EB_FLT_PERCENT, NULL, HFILL }},
+
+ { &hf_ieee802154_psie_eb_filter_percent_prob,
+ { "Response Probability Percentage", "wpan.eb_filter.prob", FT_UINT8, BASE_DEC, NULL,
+ 0x0, NULL, HFILL }},
+
+ { &hf_ieee802154_psie_eb_filter_attr_id,
+ { "Requested Attribute Length", "wpan.eb_filter.attr_id", FT_UINT8, BASE_DEC, NULL,
+ IEEE802154_MLME_PSIE_EB_FLT_ATTR_LEN, NULL, HFILL }},
+
+ { &hf_ieee802154_psie_eb_filter_attr_id_bitmap,
+ { "Attribute ID Bitmap", "wpan.eb_filter.attr_id_bits", FT_UINT24, BASE_HEX, NULL,
+ 0x0, NULL, HFILL }},
+
{ &hf_ieee802154_tsch_sync,
- { "Time Synchronization IE", "wpan.tsch.time_sync", FT_NONE, BASE_NONE, NULL, 0x0,
+ { "TSCH Synchronization IE", "wpan.tsch.time_sync", FT_NONE, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ieee802154_tsch_asn,
@@ -4474,6 +4417,62 @@ void proto_register_ieee802154(void)
{ "Join Metric", "wpan.tsch.join_metric", FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
+ { &hf_ieee802154_tsch_timeslot,
+ { "TSCH Timeslot IE", "wpan.tsch.timeslot", FT_NONE, BASE_NONE, NULL, 0x0,
+ NULL, HFILL }},
+
+ { &hf_ieee802154_tsch_timeslot_id,
+ { "Timeslot ID", "wpan.tsch.timeslot.id", FT_UINT8, BASE_HEX, NULL, 0x0,
+ "Identifier of the Timeslot Template", HFILL }},
+
+ { &hf_ieee802154_tsch_timeslot_cca_offset,
+ { "CCA Offset", "wpan.tsch.timeslot.cca_offset", FT_UINT16, BASE_DEC, NULL, 0x0,
+ "Time between the beginning of the timeslot and the start of CCA", HFILL }},
+
+ { &hf_ieee802154_tsch_timeslot_cca,
+ { "CCA", "wpan.tsch.timeslot.cca", FT_UINT16, BASE_DEC, NULL, 0x0,
+ "Duration of CCA", HFILL }},
+
+ { &hf_ieee802154_tsch_timeslot_tx_offset,
+ { "TX Offset", "wpan.tsch.timeslot.tx_offset", FT_UINT16, BASE_DEC, NULL, 0x0,
+ "Time between the beginning of the timeslot and the start of frame transmission", HFILL }},
+
+ { &hf_ieee802154_tsch_timeslot_rx_offset,
+ { "RX Offset", "wpan.tsch.timeslot.rx_offset", FT_UINT16, BASE_DEC, NULL, 0x0,
+ "Time between the beginning of the timeslot to when the receiver shall be listening", HFILL }},
+
+ { &hf_ieee802154_tsch_timeslot_rx_ack_delay,
+ { "RX Ack Delay", "wpan.tsch.timeslot.rx_ack_delay", FT_UINT16, BASE_DEC, NULL, 0x0,
+ "Time between the end of frame to when the transmitter shall listen for acknowledgment", HFILL }},
+
+ { &hf_ieee802154_tsch_timeslot_tx_ack_delay,
+ { "TX Ack Delay", "wpan.tsch.timeslot.tx_ack_delay", FT_UINT16, BASE_DEC, NULL, 0x0,
+ "Time between the end of frame to start of acknowledgment", HFILL }},
+
+ { &hf_ieee802154_tsch_timeslot_rx_wait,
+ { "RX Wait", "wpan.tsch.timeslot.rx_wait", FT_UINT16, BASE_DEC, NULL, 0x0,
+ "Time to wait for the start of frame", HFILL }},
+
+ { &hf_ieee802154_tsch_timeslot_ack_wait,
+ { "RX Wait", "wpan.tsch.timeslot.rx_wait", FT_UINT16, BASE_DEC, NULL, 0x0,
+ "Minimum time to wait for the start of an acknowledgment", HFILL }},
+
+ { &hf_ieee802154_tsch_timeslot_turnaround,
+ { "RX Wait", "wpan.tsch.timeslot.turnaround", FT_UINT16, BASE_DEC, NULL, 0x0,
+ "Transmit to receive turnaround time", HFILL }},
+
+ { &hf_ieee802154_tsch_timeslot_max_ack,
+ { "Max Ack", "wpan.tsch.timeslot.max_ack", FT_UINT16, BASE_DEC, NULL, 0x0,
+ "Transmission time to send an acknowledgment", HFILL }},
+
+ { &hf_ieee802154_tsch_timeslot_max_tx,
+ { "Max TX", "wpan.tsch.timeslot.max_tx", FT_UINT24, BASE_DEC, NULL, 0x0,
+ "Transmission time to send the maximum length frame", HFILL }},
+
+ { &hf_ieee802154_tsch_timeslot_length,
+ { "Timeslot Length", "wpan.tsch.timeslot.length", FT_UINT24, BASE_DEC, NULL, 0x0,
+ "Total length of the timeslot, including any unsused time after frame transmission", HFILL }},
+
{ &hf_ieee802154_tsch_channel_hopping,
{ "Channel Hopping IE", "wpan.channel_hopping", FT_NONE, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
@@ -4512,47 +4511,32 @@ void proto_register_ieee802154(void)
NULL, HFILL }},
{ &hf_ieee802154_tsch_slotf_link_options,
- { "Link Options", "wpan.tsch.link_options", FT_UINT8, BASE_DEC, NULL, 0x0,
+ { "Link Options", "wpan.tsch.link_options", FT_UINT8, BASE_HEX, NULL, 0x0,
NULL, HFILL }},
- { &hf_ieee802154_tsch_hopping_sequence_id,
- { "Hopping Sequence ID", "wpan.tsch.hopping_sequence_id", FT_UINT8, BASE_HEX, NULL, 0x0,
+ { &hf_ieee802154_tsch_slotf_link_options_tx,
+ { "TX Link", "wpan.tsch.link_options.tx", FT_BOOLEAN, 8, NULL, (1 << 0),
NULL, HFILL }},
- { &hf_ieee802154_psie_eb_filter_pjoin,
- { "Permit Join Filter", "wpan.payload_sub_ie.eb_filter.pjoin", FT_BOOLEAN, 8, TFS(&tfs_enabled_disabled),
- IEEE802154_MLME_PSIE_EB_FLT_PJOIN, NULL, HFILL }},
-
- { &hf_ieee802154_psie_eb_filter_lqi,
- { "LQI Filter", "wpan.payload_sub_ie.eb_filter.lqi", FT_BOOLEAN, 8, TFS(&tfs_enabled_disabled),
- IEEE802154_MLME_PSIE_EB_FLT_LQI, NULL, HFILL }},
-
- { &hf_ieee802154_psie_eb_filter_lqi_min,
- { "Minimum LQI", "wpan.payload_sub_ie.eb_filter.lqi_minimum", FT_UINT8, BASE_DEC, NULL,
- 0x0, NULL, HFILL }},
-
- { &hf_ieee802154_psie_eb_filter_percent,
- { "Probability to Respond", "wpan.payload_sub_ie.eb_filter.contains_prob", FT_BOOLEAN, 8, TFS(&tfs_enabled_disabled),
- IEEE802154_MLME_PSIE_EB_FLT_PERCENT, NULL, HFILL }},
-
- { &hf_ieee802154_psie_eb_filter_percent_prob,
- { "Response Probability Percentage", "wpan.payload_sub_ie.eb_filter.prob", FT_UINT8, BASE_DEC, NULL,
- 0x0, NULL, HFILL }},
+ { &hf_ieee802154_tsch_slotf_link_options_rx,
+ { "RX Link", "wpan.tsch.link_options.rx", FT_BOOLEAN, 8, NULL, (1 << 1),
+ NULL, HFILL }},
- { &hf_ieee802154_psie_eb_filter_attr_id,
- { "Requested Attribute Length", "wpan.payload_sub_ie.eb_filter.attr_id", FT_UINT8, BASE_DEC, NULL,
- IEEE802154_MLME_PSIE_EB_FLT_ATTR_LEN, NULL, HFILL }},
+ { &hf_ieee802154_tsch_slotf_link_options_shared,
+ { "Shared Link", "wpan.tsch.link_options.shared", FT_BOOLEAN, 8, NULL, (1 << 2),
+ NULL, HFILL }},
- { &hf_ieee802154_psie_eb_filter_attr_id_bitmap,
- { "Attribute ID Bitmap", "wpan.payload_sub_ie.eb_filter.attr_id_bits", FT_UINT24, BASE_HEX, NULL,
- 0x0, NULL, HFILL }},
+ { &hf_ieee802154_tsch_slotf_link_options_timkeeping,
+ { "Timekeeping", "wpan.tsch.link_options.timekeeping", FT_BOOLEAN, 8, NULL, (1 << 3),
+ NULL, HFILL }},
- { &hf_ieee802154_payload_ie_vendor_oui,
- { "Vendor OUI", "wpan.payload_ie.vendor_oui", FT_UINT24, BASE_HEX, NULL,
- 0x0, NULL, HFILL }},
+ { &hf_ieee802154_tsch_slotf_link_options_priority,
+ { "Priority", "wpan.tsch.link_options.priority", FT_BOOLEAN, 8, NULL, (1 << 4),
+ NULL, HFILL }},
- { &hf_ieee802154_mlme_ie_data,
- { "Data", "wpan.mlme_sub_ie.data", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
+ { &hf_ieee802154_tsch_hopping_sequence_id,
+ { "Hopping Sequence ID", "wpan.tsch.hopping_sequence_id", FT_UINT8, BASE_HEX, NULL, 0x0,
+ NULL, HFILL }},
/* IETF IE */
{ &hf_ieee802154_pie_ietf,
@@ -4699,7 +4683,7 @@ void proto_register_ieee802154(void)
},
{ &hf_ieee802159_mpx_multiplex_id,
- { "Multiplex ID", "wpan.mpx.multiplex_id", FT_UINT16, BASE_HEX, VALS(etype_vals), 0x0,
+ { "Multiplex ID", "wpan.mpx.multiplex_id", FT_UINT16, BASE_HEX, NULL, 0x0,
NULL, HFILL }
},
@@ -4718,6 +4702,10 @@ void proto_register_ieee802154(void)
NULL, HFILL }
},
+ { &hf_ieee802159_mpx_wisun_subid,
+ { "Wi-SUN Multiplex Sub ID", "wpan.mpx.wisun", FT_UINT8, BASE_HEX, VALS(mpx_wisun_subid_vals), 0x0,
+ NULL, HFILL }
+ },
/* Command Frame Specific Fields */
@@ -4957,6 +4945,7 @@ void proto_register_ieee802154(void)
&ett_ieee802154_hie_time_correction,
&ett_ieee802154_hie_ht,
&ett_ieee802154_hie_csl,
+ &ett_ieee802154_hie_global_time,
&ett_ieee802154_payload_ie,
&ett_ieee802154_payload_ie_tlv,
&ett_ieee802154_pie_termination,
@@ -4965,19 +4954,20 @@ void proto_register_ieee802154(void)
&ett_ieee802159_mpx_transaction_control,
&ett_ieee802154_pie_ietf,
&ett_ieee802154_pie_unsupported,
+ &ett_ieee802154_tsch_slotframe,
+ &ett_ieee802154_tsch_slotframe_list,
+ &ett_ieee802154_tsch_slotframe_link,
+ &ett_ieee802154_tsch_slotframe_link_options,
&ett_ieee802154_tsch_timeslot,
&ett_ieee802154_tsch_synch,
&ett_ieee802154_channel_hopping,
&ett_ieee802154_mlme,
&ett_ieee802154_mlme_payload,
&ett_ieee802154_mlme_payload_data,
- &ett_ieee802154_psie_short,
- &ett_ieee802154_psie_short_bitmap,
- &ett_ieee802154_psie_long,
- &ett_ieee802154_psie_long_bitmap,
- &ett_ieee802154_psie_enh_beacon_flt,
- &ett_ieee802154_psie_enh_beacon_flt_bitmap,
- &ett_ieee802154_psie_slotframe_link_slotframes,
+ &ett_ieee802154_mlme_unsupported,
+ &ett_ieee802154_psie,
+ &ett_ieee802154_eb_filter,
+ &ett_ieee802154_eb_filter_bitmap,
&ett_ieee802154_zigbee,
&ett_ieee802154_zboss,
&ett_ieee802154_p_ie_6top,
@@ -5168,6 +5158,7 @@ void proto_register_ieee802154(void)
/* Register dissector tables for IEs */
header_ie_dissector_table = register_dissector_table(IEEE802154_HEADER_IE_DTABLE, "IEEE 802.15.4 Header IEs", proto_ieee802154, FT_UINT8, BASE_HEX);
payload_ie_dissector_table = register_dissector_table(IEEE802154_PAYLOAD_IE_DTABLE, "IEEE 802.15.4 Payload IEs", proto_ieee802154, FT_UINT8, BASE_HEX);
+ mlme_ie_dissector_table = register_dissector_table(IEEE802154_MLME_IE_DTABLE, "IEEE 802.15.4 Nested IEs", proto_ieee802154, FT_UINT8, BASE_HEX);
/* Register dissectors with Wireshark. */
ieee802154_handle = register_dissector(IEEE802154_PROTOABBREV_WPAN, dissect_ieee802154, proto_ieee802154);
@@ -5195,7 +5186,6 @@ void proto_reg_handoff_ieee802154(void)
if (!prefs_initialized) {
/* Get the dissector handles. */
- zigbee_beacon_handle = find_dissector_add_dependency("zbee_beacon", proto_ieee802154);
zigbee_ie_handle = find_dissector_add_dependency("zbee_ie", proto_ieee802154);
zigbee_nwk_handle = find_dissector("zbee_nwk");
@@ -5217,14 +5207,24 @@ void proto_reg_handoff_ieee802154(void)
/* Register internal IE handlers */
dissector_add_uint(IEEE802154_HEADER_IE_DTABLE, IEEE802154_HEADER_IE_TIME_CORR, create_dissector_handle(dissect_hie_time_correction, -1));
dissector_add_uint(IEEE802154_HEADER_IE_DTABLE, IEEE802154_HEADER_IE_CSL, create_dissector_handle(dissect_hie_csl, -1));
+ dissector_add_uint(IEEE802154_HEADER_IE_DTABLE, IEEE802154_HEADER_IE_GLOBAL_TIME, create_dissector_handle(dissect_hie_global_time, -1));
+
dissector_add_uint(IEEE802154_PAYLOAD_IE_DTABLE, IEEE802154_PAYLOAD_IE_MLME, create_dissector_handle(dissect_pie_mlme, -1));
dissector_add_uint(IEEE802154_PAYLOAD_IE_DTABLE, IEEE802154_PAYLOAD_IE_VENDOR, create_dissector_handle(dissect_pie_vendor, -1));
dissector_add_uint(IEEE802154_PAYLOAD_IE_DTABLE, IEEE802154_PAYLOAD_IE_MPX, create_dissector_handle(dissect_mpx_ie, -1));
dissector_add_uint(IEEE802154_PAYLOAD_IE_DTABLE, IEEE802154_PAYLOAD_IE_IETF, create_dissector_handle(dissect_ietf_ie, -1));
+ dissector_add_uint(IEEE802154_MLME_IE_DTABLE, IEEE802154_MLME_SUBIE_CHANNEL_HOPPING, create_dissector_handle(dissect_802154_channel_hopping, -1));
+ dissector_add_uint(IEEE802154_MLME_IE_DTABLE, IEEE802154_MLME_SUBIE_TSCH_SYNCH, create_dissector_handle(dissect_802154_tsch_time_sync, -1));
+ dissector_add_uint(IEEE802154_MLME_IE_DTABLE, IEEE802154_MLME_SUBIE_TSCH_SLOTFR_LINK, create_dissector_handle(dissect_802154_tsch_slotframe_link, -1));
+ dissector_add_uint(IEEE802154_MLME_IE_DTABLE, IEEE802154_MLME_SUBIE_TSCH_TIMESLOT, create_dissector_handle(dissect_802154_tsch_timeslot, -1));
+ dissector_add_uint(IEEE802154_MLME_IE_DTABLE, IEEE802154_MLME_SUBIE_ENHANCED_BEACON_FILTER, create_dissector_handle(dissect_802154_eb_filter, -1));
+
/* For the MPX-IE */
ethertype_table = find_dissector_table("ethertype");
eapol_handle = find_dissector("eapol");
+ lowpan_handle = find_dissector("6lowpan");
+ wisun_sec_handle = find_dissector("wisun.sec");
} /* proto_reg_handoff_ieee802154 */
/*
diff --git a/epan/dissectors/packet-ieee802154.h b/epan/dissectors/packet-ieee802154.h
index e305051c42..c7b5e665ed 100644
--- a/epan/dissectors/packet-ieee802154.h
+++ b/epan/dissectors/packet-ieee802154.h
@@ -34,6 +34,7 @@
/* Dissector tables for the Header IEs and Payload IEs */
#define IEEE802154_HEADER_IE_DTABLE "wpan.header_ie"
#define IEEE802154_PAYLOAD_IE_DTABLE "wpan.payload_ie"
+#define IEEE802154_MLME_IE_DTABLE "wpan.mlme_ie"
/* Packet Overhead from MAC header + footer (excluding addressing) */
#define IEEE802154_MAX_FRAME_LEN 127
@@ -177,7 +178,6 @@
#define IEEE802154_MLME_PSIE_EB_FLT_ATTR_LEN 0x18
/* Vendor OUIs */
-#define IEEE802154_VENDOR_OUI_ZIGBEE 0x4A191B
/* Bit-masks for CC24xx style FCS */
#define IEEE802154_CC24xx_CORRELATION 0x7F00
@@ -248,7 +248,7 @@ typedef enum {
#define IEEE802154_HEADER_IE_RCC_CAP 0x27
#define IEEE802154_HEADER_IE_RCCN 0x28
#define IEEE802154_HEADER_IE_GLOBAL_TIME 0x29
-/* Assigned to External Organization: 0x2a */
+#define IEEE802154_HEADER_IE_WISUN 0x2a
#define IEEE802154_HEADER_IE_DA_IE 0x2b
/* Reserved 0x2c-0x7d */
#define IEEE802154_HEADER_IE_HT1 0x7e
@@ -260,7 +260,7 @@ typedef enum {
#define IEEE802154_PAYLOAD_IE_MLME 0x1 /* Media Access Control (MAC) subLayer Management Entity */
#define IEEE802154_PAYLOAD_IE_VENDOR 0x2 /* Vendor Specific */
#define IEEE802154_PAYLOAD_IE_MPX 0x3 /* MPX IE (802.15.9) */
-/* Reserved 0x4 */
+#define IEEE802154_PAYLOAD_IE_WISUN 0x4 /* Wi-SUN IE */
#define IEEE802154_PAYLOAD_IE_IETF 0x5 /* IETF IE, RFC 8137 */
/* Reserved 0x6-0xe */
#define IEEE802154_PAYLOAD_IE_TERMINATION 0xf
@@ -362,6 +362,7 @@ typedef enum {
#define IEEE802159_MPX_ABORT 6
/* IEEE 802.15.9 Table 20 */
#define IEEE802159_MPX_MULTIPLEX_ID_KMP 1
+#define IEEE802159_MPX_MULTIPLEX_ID_WISUN 2
/* IEEE 802.15.9 Table 21 */
#define IEEE802159_MPX_KMP_ID_IEEE8021X 1
#define IEEE802159_MPX_KMP_ID_HIP 2
@@ -372,6 +373,10 @@ typedef enum {
#define IEEE802159_MPX_KMP_ID_IEEE80211_GKH 7
#define IEEE802159_MPX_KMP_ID_ETSI_TS_102_887_2 8
#define IEEE802159_MPX_KMP_ID_VENDOR_SPECIFIC 255
+/* Wi-SUN MPX Sub-ID values. */
+#define IEEE802159_MPX_WISUN_SUBID_MHDS 0
+#define IEEE802159_MPX_WISUN_SUBID_6LOWPAN 1
+#define IEEE802159_MPX_WISUN_SUBID_SECURITY 2
/* Structure containing information regarding all necessary packet fields. */
typedef struct {
@@ -480,6 +485,9 @@ void ccm_init_block(gchar *block, gboolean adata, gint M, guint64 addr, guint32
gboolean ccm_ctr_encrypt(const gchar *key, const gchar *iv, gchar *mic, gchar *data, gint length);
gboolean ccm_cbc_mac(const gchar *key, const gchar *iv, const gchar *a, gint a_len, const gchar *m, gint m_len, gchar *mic);
+proto_tree *ieee802154_create_hie_tree(tvbuff_t *tvb, proto_tree *tree, int hf, gint ett);
+proto_tree *ieee802154_create_pie_tree(tvbuff_t *tvb, proto_tree *tree, int hf, gint ett);
+
typedef struct {
unsigned char* rx_mic;
guint* rx_mic_length;
diff --git a/epan/dissectors/packet-wisun.c b/epan/dissectors/packet-wisun.c
new file mode 100644
index 0000000000..e917be0972
--- /dev/null
+++ b/epan/dissectors/packet-wisun.c
@@ -0,0 +1,1102 @@
+/* packet-ieee802154.c
+ *
+ * Wi-SUN IE Dissectors for Wireshark
+ * By Owen Kirby <osk@exegin.com>
+ * Copyright 2007 Exegin Technologies Limited
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *------------------------------------------------------------
+ */
+#include "config.h"
+#include <epan/packet.h>
+#include <epan/decode_as.h>
+#include <epan/exceptions.h>
+#include <epan/expert.h>
+#include <epan/addr_resolv.h>
+#include <epan/address_types.h>
+#include <epan/prefs.h>
+#include <epan/strutil.h>
+#include <epan/to_str.h>
+#include <epan/show_exception.h>
+#include <epan/proto_data.h>
+#include <epan/etypes.h>
+#include <epan/oui.h>
+#include <wsutil/pint.h>
+
+#include "packet-ieee802154.h"
+
+/* Wi-SUN Header IE Sub-ID Values. */
+#define WISUN_SUBID_UTT 1
+#define WISUN_SUBID_BT 2
+#define WISUN_SUBID_FC 3
+#define WISUN_SUBID_RSL 4
+#define WISUN_SUBID_MHDS 5
+#define WISUN_SUBID_VH 6
+
+/* Wi-SUN Payload/Nested ID values. */
+#define WISUN_PIE_SUBID_US 1
+#define WISUN_PIE_SUBID_BS 2
+#define WISUN_PIE_SUBID_VP 3
+#define WISUN_PIE_SUBID_PAN 4
+#define WISUN_PIE_SUBID_NETNAME 5
+#define WISUN_PIE_SUBID_PENVER 6
+#define WISUN_PIE_SUBID_GTKHASH 7
+
+#define WISUN_CHANNEL_PLAN 0x07
+#define WISUN_CHANNEL_FUNCTION 0x38
+#define WISUN_CHANNEL_EXCLUDE 0xc0
+
+#define WISUN_CHANNEL_PLAN_REGULATORY 0
+#define WISUN_CHANNEL_PLAN_SPACING 1
+#define WISUN_CHANNEL_FUNCTION_FIXED 0
+#define WISUN_CHANNEL_FUNCTION_TR51CF 1
+#define WISUN_CHANNEL_FUNCTION_DH1CF 2
+#define WISUN_CHANNEL_FUNCTION_VENDOR 3
+#define WISUN_CHANNEL_EXCLUDE_NONE 0
+#define WISUN_CHANNEL_EXCLUDE_RANGE 1
+#define WISUN_CHANNEL_EXCLUDE_MASK 2
+
+static int proto_wisun = -1;
+static int hf_wisun_subid = -1;
+static int hf_wisun_unknown_ie = -1;
+static int hf_wisun_uttie = -1;
+static int hf_wisun_uttie_type = -1;
+static int hf_wisun_uttie_ufsi = -1;
+static int hf_wisun_btie = -1;
+static int hf_wisun_btie_slot = -1;
+static int hf_wisun_btie_bfio = -1;
+static int hf_wisun_fcie = -1;
+static int hf_wisun_fcie_tx = -1;
+static int hf_wisun_fcie_rx = -1;
+static int hf_wisun_rslie = -1;
+static int hf_wisun_rslie_rsl = -1;
+static int hf_wisun_vhie = -1;
+static int hf_wisun_vhie_vid = -1;
+static int hf_wisun_pie = -1;
+static int hf_wisun_wsie = -1;
+static int hf_wisun_wsie_type = -1;
+static int hf_wisun_wsie_id = -1;
+static int hf_wisun_wsie_length = -1;
+static int hf_wisun_usie = -1;
+static int hf_wisun_usie_dwell_interval = -1;
+static int hf_wisun_usie_clock_drift = -1;
+static int hf_wisun_usie_timing_accuracy = -1;
+static int hf_wisun_usie_channel_control = -1;
+static int hf_wisun_usie_channel_plan = -1;
+static int hf_wisun_usie_channel_function = -1;
+static int hf_wisun_usie_channel_exclude = -1;
+static int hf_wisun_usie_regulatory_domain = -1;
+static int hf_wisun_usie_operating_class = -1;
+static int hf_wisun_usie_channel_frequency = -1;
+static int hf_wisun_usie_channel_spacing = -1;
+static int hf_wisun_usie_number_channels = -1;
+static int hf_wisun_usie_fixed_channel = -1;
+static int hf_wisun_usie_hop_count = -1;
+static int hf_wisun_usie_hop_list = -1;
+static int hf_wisun_usie_number_ranges = -1;
+static int hf_wisun_usie_exclude_range = -1;
+static int hf_wisun_usie_exclude_mask = -1;
+static int hf_wisun_bsie = -1;
+static int hf_wisun_bsie_bcast_interval = -1;
+static int hf_wisun_bsie_bcast_schedule_id = -1;
+static int hf_wisun_vpie = -1;
+static int hf_wisun_vpie_vid = -1;
+static int hf_wisun_panie = -1;
+static int hf_wisun_panie_size = -1;
+static int hf_wisun_panie_cost = -1;
+static int hf_wisun_panie_flags = -1;
+static int hf_wisun_panie_flag_parent_bsie = -1;
+static int hf_wisun_panie_flag_routing_method = -1;
+static int hf_wisun_panie_flag_eapol_ready = -1;
+static int hf_wisun_panie_flag_version = -1;
+static int hf_wisun_netnameie = -1;
+static int hf_wisun_netnameie_name = -1;
+static int hf_wisun_panverie = -1;
+static int hf_wisun_panverie_version = -1;
+static int hf_wisun_gtkhashie = -1;
+static int hf_wisun_gtkhashie_gtk0 = -1;
+static int hf_wisun_gtkhashie_gtk1 = -1;
+static int hf_wisun_gtkhashie_gtk2 = -1;
+static int hf_wisun_gtkhashie_gtk3 = -1;
+
+static int proto_wisun_sec = -1;
+static int hf_wisun_sec_function = -1;
+static int hf_wisun_sec_error_type = -1;
+static int hf_wisun_sec_error_nonce = -1;
+
+static gint ett_wisun_unknown_ie = -1;
+static gint ett_wisun_uttie = -1;
+static gint ett_wisun_btie = -1;
+static gint ett_wisun_fcie = -1;
+static gint ett_wisun_rslie = -1;
+static gint ett_wisun_vhie = -1;
+static gint ett_wisun_pie = -1;
+static gint ett_wisun_wsie_bitmap = -1;
+static gint ett_wisun_usie = -1;
+static gint ett_wisun_bsie = -1;
+static gint ett_wisun_vpie = -1;
+static gint ett_wisun_usie_channel_control;
+static gint ett_wisun_panie = -1;
+static gint ett_wisun_panie_flags = -1;
+static gint ett_wisun_netnameie = -1;
+static gint ett_wisun_panverie = -1;
+static gint ett_wisun_gtkhashie = -1;
+static gint ett_wisun_sec = -1;
+
+static const value_string wisun_wsie_types[] = {
+ { 0, "Short" },
+ { 1, "Long" },
+ { 0, NULL }
+};
+
+static const value_string wisun_subid_vals[] = {
+ { WISUN_SUBID_UTT, "Unicast Timing IE" },
+ { WISUN_SUBID_BT, "Broadcast Timing IE" },
+ { WISUN_SUBID_FC, "Flow Control IE" },
+ { WISUN_SUBID_RSL, "Received Signal Level IE" },
+ { WISUN_SUBID_MHDS, "Multi-Hop Delivery Service IE" },
+ { WISUN_SUBID_VH, "Vendor Header IE" },
+ { 0, NULL }
+};
+
+static const value_string wisun_wsie_names[] = {
+ { WISUN_PIE_SUBID_US, "Unicast Schedule IE" },
+ { WISUN_PIE_SUBID_BS, "Broadcast Schedule IE" },
+ { WISUN_PIE_SUBID_VP, "Vendor Payload IE" },
+ { WISUN_PIE_SUBID_PAN, "PAN Information IE" },
+ { WISUN_PIE_SUBID_NETNAME, "Network Name IE" },
+ { WISUN_PIE_SUBID_PENVER, "PAN Version IE" },
+ { WISUN_PIE_SUBID_GTKHASH, "GTK Hash IE" },
+ { 0, NULL }
+};
+
+static const value_string wisun_frame_type_vals[] = {
+ { 0, "PAN Advertisement" },
+ { 1, "PAN Advertisement Solicit" },
+ { 2, "PAN Configuration" },
+ { 3, "PAN Configuration Solicit" },
+ { 4, "Data" },
+ { 5, "Acknowledgment" },
+ { 6, "EAPOL" },
+ { 0, NULL }
+};
+
+static const value_string wisun_channel_plan_names[] = {
+ { WISUN_CHANNEL_PLAN_REGULATORY, "Regulatory Domain and Operating Class" },
+ { WISUN_CHANNEL_PLAN_SPACING, "Channel Spacing and Number" },
+ { 0, NULL }
+};
+
+static const value_string wisun_channel_function_names[] = {
+ { WISUN_CHANNEL_FUNCTION_FIXED, "Fixed Channel" },
+ { WISUN_CHANNEL_FUNCTION_TR51CF, "TR51 Channel Function" },
+ { WISUN_CHANNEL_FUNCTION_DH1CF, "Direct Hash Channel Function" },
+ { WISUN_CHANNEL_FUNCTION_VENDOR, "Vendor Defined Channel Function" },
+ { 0, NULL }
+};
+
+static const value_string wisun_channel_exclude_names[] = {
+ { WISUN_CHANNEL_EXCLUDE_NONE, "None" },
+ { WISUN_CHANNEL_EXCLUDE_RANGE, "Ranges" },
+ { WISUN_CHANNEL_EXCLUDE_MASK, "Bitmask" },
+ { 0, NULL }
+};
+
+static const value_string wisun_channel_spacing_names[] = {
+ { 0, "200 kHz" },
+ { 1, "400 kHz" },
+ { 2, "600 kHz" },
+ { 0, NULL }
+};
+
+static const value_string wisun_routing_methods[] = {
+ { 0, "RPL" },
+ { 1, "MHDS" },
+ { 0, NULL }
+};
+
+static const value_string wisun_sec_functions[] = {
+ { 0x01, "SM Error" },
+ { 0, NULL }
+};
+
+static const value_string wisun_sec_sm_errors[] = {
+ { 0x01, "No Session" },
+ { 0x02, "Unavailable Key" },
+ { 0x03, "Unsupported Security" },
+ { 0x04, "Invalid Parameter" },
+ { 0x06, "Unsupported Security" },
+ { 0, NULL }
+};
+
+static const int * wisun_format_nested_ie[] = {
+ &hf_wisun_wsie_type,
+ &hf_wisun_wsie_id,
+ &hf_wisun_wsie_length,
+ NULL
+};
+
+static expert_field ei_wisun_subid_unsupported = EI_INIT;
+static expert_field ei_wisun_wsie_short_format = EI_INIT;
+static expert_field ei_wisun_wsie_unsupported = EI_INIT;
+static expert_field ei_wisun_usie_channel_plan_invalid = EI_INIT;
+
+static int
+wisun_add_wbxml_uint(tvbuff_t *tvb, proto_tree *tree, int hf, guint offset)
+{
+ guint val = 0;
+ guint len = 0;
+ guint8 b;
+ do {
+ b = tvb_get_guint8(tvb, offset + len++);
+ val = (val << 7) | (b & 0x7f);
+ } while (b & 0x80);
+ proto_tree_add_uint(tree, hf, tvb, offset, len, val);
+ return len;
+}
+
+/*-----------------------------------------------
+ * Wi-SUN Header IE Dissection
+ *---------------------------------------------*/
+static proto_tree *
+wisun_create_hie_tree(tvbuff_t *tvb, proto_tree *tree, int hf, gint ett)
+{
+ proto_tree *subtree = ieee802154_create_hie_tree(tvb, tree, hf, ett);
+ proto_tree_add_item(subtree, hf_wisun_subid, tvb, 2, 1, ENC_LITTLE_ENDIAN);
+ return subtree;
+}
+
+static int
+dissect_wisun_uttie(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset)
+{
+ guint8 frame_type = tvb_get_guint8(tvb, offset);
+ col_set_str(pinfo->cinfo, COL_PROTOCOL, "Wi-SUN");
+ col_set_str(pinfo->cinfo, COL_INFO, val_to_str_const(frame_type, wisun_frame_type_vals, "Unknown Wi-SUN Frame"));
+ proto_tree_add_item(tree, hf_wisun_uttie_type, tvb, offset, 1, ENC_LITTLE_ENDIAN);
+ proto_tree_add_item(tree, hf_wisun_uttie_ufsi, tvb, offset+1, 3, ENC_LITTLE_ENDIAN);
+ return 4;
+}
+
+static int
+dissect_wisun_btie(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, guint offset)
+{
+ proto_tree_add_item(tree, hf_wisun_btie_slot, tvb, offset, 2, ENC_LITTLE_ENDIAN);
+ proto_tree_add_item(tree, hf_wisun_btie_bfio, tvb, offset+2, 4, ENC_LITTLE_ENDIAN);
+ return 6;
+}
+
+static int
+dissect_wisun_fcie(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, guint offset)
+{
+ nstime_t ts;
+ ts.secs = 0;
+ ts.nsecs = tvb_get_guint8(tvb, offset) * 1000000UL;
+ proto_tree_add_time(tree, hf_wisun_fcie_tx, tvb, offset, 1, &ts);
+ ts.nsecs = tvb_get_guint8(tvb, offset+1) * 1000000UL;
+ proto_tree_add_time(tree, hf_wisun_fcie_rx, tvb, offset + 1, 1, &ts);
+ return 2;
+}
+
+static int
+dissect_wisun_rslie(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, guint offset)
+{
+ proto_tree_add_item(tree, hf_wisun_rslie_rsl, tvb, offset, 1, ENC_LITTLE_ENDIAN);
+ return 1;
+}
+
+static int
+dissect_wisun_vhie(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset)
+{
+ guint vidlen = wisun_add_wbxml_uint(tvb, tree, hf_wisun_vhie_vid, offset);
+ call_data_dissector(tvb_new_subset_remaining(tvb, offset + vidlen), pinfo, tree);
+ return tvb_reported_length(tvb);
+}
+
+static int
+dissect_wisun_hie(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
+{
+ guint offset;
+ proto_tree *subtree;
+ guint8 subid = tvb_get_guint8(tvb, 2);
+
+ offset = 3;
+ switch (subid) {
+ case WISUN_SUBID_UTT:
+ subtree = wisun_create_hie_tree(tvb, tree, hf_wisun_uttie, ett_wisun_uttie);
+ offset += dissect_wisun_uttie(tvb, pinfo, subtree, offset);
+ break;
+
+ case WISUN_SUBID_BT:
+ subtree = wisun_create_hie_tree(tvb, tree, hf_wisun_btie, ett_wisun_btie);
+ offset += dissect_wisun_btie(tvb, pinfo, subtree, offset);
+ break;
+
+ case WISUN_SUBID_FC:
+ subtree = wisun_create_hie_tree(tvb, tree, hf_wisun_fcie, ett_wisun_fcie);
+ offset += dissect_wisun_fcie(tvb, pinfo, subtree, offset);
+ break;
+
+ case WISUN_SUBID_RSL:
+ subtree = wisun_create_hie_tree(tvb, tree, hf_wisun_rslie, ett_wisun_rslie);
+ offset += dissect_wisun_rslie(tvb, pinfo, subtree, offset);
+ break;
+
+ case WISUN_SUBID_VH:
+ subtree = wisun_create_hie_tree(tvb, tree, hf_wisun_vhie, ett_wisun_vhie);
+ offset += dissect_wisun_vhie(tvb, pinfo, subtree, offset);
+ break;
+
+ default:
+ subtree = wisun_create_hie_tree(tvb, tree, hf_wisun_unknown_ie, ett_wisun_unknown_ie);
+ expert_add_info(pinfo, subtree, &ei_wisun_subid_unsupported);
+ call_data_dissector(tvb_new_subset_remaining(tvb, offset), pinfo, subtree);
+ offset = tvb_reported_length(tvb);
+ break;
+ }
+ return offset;
+}
+
+/*-----------------------------------------------
+ * Wi-SUN Payload IE Dissection
+ *---------------------------------------------*/
+static int
+dissect_wisun_channel_info(tvbuff_t *tvb, packet_info *pinfo, guint offset, proto_tree *tree, guint8 control)
+{
+ guint count;
+
+ switch ((control & WISUN_CHANNEL_PLAN) >> 0) {
+ case WISUN_CHANNEL_PLAN_REGULATORY:
+ proto_tree_add_item(tree, hf_wisun_usie_regulatory_domain, tvb, offset, 1, ENC_LITTLE_ENDIAN);
+ offset++;
+ proto_tree_add_item(tree, hf_wisun_usie_operating_class, tvb, offset, 1, ENC_LITTLE_ENDIAN);
+ offset++;
+ break;
+
+ case WISUN_CHANNEL_PLAN_SPACING:
+ proto_tree_add_item(tree, hf_wisun_usie_channel_frequency, tvb, offset, 3, ENC_LITTLE_ENDIAN);
+ offset += 3;
+ proto_tree_add_item(tree, hf_wisun_usie_channel_spacing, tvb, offset, 1, ENC_LITTLE_ENDIAN);
+ offset++;
+ proto_tree_add_item(tree, hf_wisun_usie_number_channels, tvb, offset, 2, ENC_LITTLE_ENDIAN);
+ offset += 2;
+ break;
+
+ default:
+ expert_add_info(pinfo, tree, &ei_wisun_usie_channel_plan_invalid);
+ return tvb_reported_length(tvb);
+ }
+
+ switch ((control & WISUN_CHANNEL_FUNCTION) >> 3) {
+ case WISUN_CHANNEL_FUNCTION_FIXED:
+ proto_tree_add_item(tree, hf_wisun_usie_fixed_channel, tvb, offset, 2, ENC_LITTLE_ENDIAN);
+ offset += 2;
+ break;
+
+ case WISUN_CHANNEL_FUNCTION_VENDOR:
+ count = tvb_get_guint8(tvb, offset);
+ proto_tree_add_item(tree, hf_wisun_usie_hop_count, tvb, offset, 1, ENC_LITTLE_ENDIAN);
+ offset++;
+ while (count--) {
+ proto_tree_add_item(tree, hf_wisun_usie_hop_list, tvb, offset, 1, ENC_LITTLE_ENDIAN);
+ offset++;
+ }
+ break;
+
+ default:
+ /* Hopping list is implied by the hashing function. */
+ break;
+ }
+
+ switch ((control & WISUN_CHANNEL_EXCLUDE) >> 6) {
+ case WISUN_CHANNEL_EXCLUDE_RANGE:
+ count = tvb_get_guint8(tvb, offset);
+ proto_tree_add_item(tree, hf_wisun_usie_number_ranges, tvb, offset, 1, ENC_LITTLE_ENDIAN);
+ offset++;
+ while (count) {
+ guint16 ex_start = tvb_get_letohs(tvb, offset);
+ guint16 ex_end = tvb_get_letohs(tvb, offset+2);
+ proto_tree_add_uint_format_value(tree, hf_wisun_usie_exclude_range, tvb, offset, 4, ex_start, "[%u, %u]", ex_start, ex_end);
+ offset += 4;
+ count--;
+ }
+ break;
+
+ case WISUN_CHANNEL_EXCLUDE_MASK:
+ count = tvb_reported_length_remaining(tvb, offset);
+ proto_tree_add_item(tree, hf_wisun_usie_exclude_mask, tvb, offset, count, ENC_NA);
+ offset += count;
+ break;
+
+ default:
+ /* Assume there is nothing to exclude. */
+ break;
+ }
+ return offset;
+}
+
+static int
+dissect_wisun_usie(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
+{
+ proto_item *item;
+ proto_tree *subtree;
+ guint offset = 0;
+ guint8 channel_control;
+ static const int * fields_usie_channel[] = {
+ &hf_wisun_usie_channel_plan,
+ &hf_wisun_usie_channel_function,
+ &hf_wisun_usie_channel_exclude,
+ NULL
+ };
+
+ item = proto_tree_add_item(tree, hf_wisun_usie, tvb, 0, tvb_reported_length_remaining(tvb, 0), ENC_NA);
+ subtree = proto_item_add_subtree(item, ett_wisun_usie);
+
+ /* Fixed stuff */
+ proto_tree_add_bitmask(subtree, tvb, offset, hf_wisun_wsie, ett_wisun_wsie_bitmap, wisun_format_nested_ie, ENC_LITTLE_ENDIAN);
+ offset += 2;
+ proto_tree_add_item(subtree, hf_wisun_usie_dwell_interval, tvb, offset, 1, ENC_LITTLE_ENDIAN);
+ offset++;
+ proto_tree_add_item(subtree, hf_wisun_usie_clock_drift, tvb, offset, 1, ENC_LITTLE_ENDIAN);
+ offset++;
+ proto_tree_add_item(subtree, hf_wisun_usie_timing_accuracy, tvb, offset, 1, ENC_LITTLE_ENDIAN);
+ offset++;
+ channel_control = tvb_get_guint8(tvb, offset);
+ proto_tree_add_bitmask_with_flags(subtree, tvb, offset, hf_wisun_usie_channel_control, ett_wisun_usie_channel_control,
+ fields_usie_channel, ENC_LITTLE_ENDIAN, BMT_NO_FLAGS);
+ offset++;
+
+ /* Variable stuff */
+ return offset + dissect_wisun_channel_info(tvb, pinfo, offset, subtree, channel_control);
+}
+
+static int
+dissect_wisun_bsie(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
+{
+ proto_item *item;
+ proto_tree *subtree;
+ guint offset = 0;
+ guint8 channel_control;
+ static const int * fields_usie_channel[] = {
+ &hf_wisun_usie_channel_plan,
+ &hf_wisun_usie_channel_function,
+ &hf_wisun_usie_channel_exclude,
+ NULL
+ };
+
+ item = proto_tree_add_item(tree, hf_wisun_bsie, tvb, 0, tvb_reported_length(tvb), ENC_NA);
+ subtree = proto_item_add_subtree(item, ett_wisun_bsie);
+
+ /* Fixed stuff */
+ proto_tree_add_bitmask(subtree, tvb, offset, hf_wisun_wsie, ett_wisun_wsie_bitmap, wisun_format_nested_ie, ENC_LITTLE_ENDIAN);
+ offset += 2;
+ proto_tree_add_item(subtree, hf_wisun_bsie_bcast_interval, tvb, offset, 4, ENC_LITTLE_ENDIAN);
+ offset += 4;
+ proto_tree_add_item(subtree, hf_wisun_bsie_bcast_schedule_id, tvb, offset, 2, ENC_LITTLE_ENDIAN);
+ offset += 2;
+ proto_tree_add_item(subtree, hf_wisun_usie_dwell_interval, tvb, offset, 1, ENC_LITTLE_ENDIAN);
+ offset++;
+ proto_tree_add_item(subtree, hf_wisun_usie_clock_drift, tvb, offset, 1, ENC_LITTLE_ENDIAN);
+ offset++;
+ proto_tree_add_item(subtree, hf_wisun_usie_timing_accuracy, tvb, offset, 1, ENC_LITTLE_ENDIAN);
+ offset++;
+ channel_control = tvb_get_guint8(tvb, offset);
+ proto_tree_add_bitmask_with_flags(subtree, tvb, offset, hf_wisun_usie_channel_control, ett_wisun_usie_channel_control,
+ fields_usie_channel, ENC_LITTLE_ENDIAN, BMT_NO_FLAGS);
+ offset++;
+
+ /* Variable stuff */
+ return offset + dissect_wisun_channel_info(tvb, pinfo, offset, subtree, channel_control);
+}
+
+static int
+dissect_wisun_vpie(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
+{
+ proto_item *item;
+ proto_tree *subtree;
+ guint vidlen;
+
+ item = proto_tree_add_item(tree, hf_wisun_vpie, tvb, 0, tvb_reported_length(tvb), ENC_NA);
+ subtree = proto_item_add_subtree(item, ett_wisun_vpie);
+
+ vidlen = wisun_add_wbxml_uint(tvb, subtree, hf_wisun_vpie_vid, 2);
+ call_data_dissector(tvb_new_subset_remaining(tvb, 2 + vidlen), pinfo, subtree);
+ return tvb_reported_length(tvb);
+}
+
+static int
+dissect_wisun_panie(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
+{
+ proto_item *item;
+ proto_tree *subtree;
+ guint offset = 0;
+ static const int * fields_panie_flags[] = {
+ &hf_wisun_panie_flag_parent_bsie,
+ &hf_wisun_panie_flag_routing_method,
+ &hf_wisun_panie_flag_eapol_ready,
+ &hf_wisun_panie_flag_version,
+ NULL
+ };
+
+ item = proto_tree_add_item(tree, hf_wisun_panie, tvb, 0, tvb_reported_length(tvb), ENC_NA);
+ subtree = proto_item_add_subtree(item, ett_wisun_panie);
+
+ proto_tree_add_bitmask(subtree, tvb, offset, hf_wisun_wsie, ett_wisun_wsie_bitmap, wisun_format_nested_ie, ENC_LITTLE_ENDIAN);
+ offset += 2;
+ proto_tree_add_item(subtree, hf_wisun_panie_size, tvb, offset, 2, ENC_LITTLE_ENDIAN);
+ offset += 2;
+ proto_tree_add_item(subtree, hf_wisun_panie_cost, tvb, offset, 1, ENC_LITTLE_ENDIAN);
+ offset++;
+ proto_tree_add_bitmask_with_flags(subtree, tvb, offset, hf_wisun_panie_flags, ett_wisun_panie_flags,
+ fields_panie_flags, ENC_LITTLE_ENDIAN, BMT_NO_FLAGS);
+ offset++;
+ return offset;
+}
+
+static int
+dissect_wisun_netnameie(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
+{
+ proto_item *item;
+ proto_tree *subtree;
+
+ item = proto_tree_add_item(tree, hf_wisun_netnameie, tvb, 0, tvb_reported_length(tvb), ENC_NA);
+ subtree = proto_item_add_subtree(item, ett_wisun_netnameie);
+
+ proto_tree_add_bitmask(subtree, tvb, 0, hf_wisun_wsie, ett_wisun_wsie_bitmap, wisun_format_nested_ie, ENC_LITTLE_ENDIAN);
+ proto_tree_add_item(subtree, hf_wisun_netnameie_name, tvb, 2, tvb_reported_length_remaining(tvb, 2), ENC_ASCII|ENC_NA);
+ return tvb_reported_length(tvb);
+}
+
+static int
+dissect_wisun_panverie(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
+{
+ proto_item *item;
+ proto_tree *subtree;
+
+ item = proto_tree_add_item(tree, hf_wisun_panverie, tvb, 0, tvb_reported_length(tvb), ENC_NA);
+ subtree = proto_item_add_subtree(item, ett_wisun_panverie);
+
+ proto_tree_add_bitmask(subtree, tvb, 0, hf_wisun_wsie, ett_wisun_wsie_bitmap, wisun_format_nested_ie, ENC_LITTLE_ENDIAN);
+ proto_tree_add_item(subtree, hf_wisun_panverie_version, tvb, 2, 2, ENC_LITTLE_ENDIAN);
+ return tvb_reported_length(tvb);
+}
+
+static int
+dissect_wisun_gtkhashie(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
+{
+ proto_item *item;
+ proto_tree *subtree;
+
+ item = proto_tree_add_item(tree, hf_wisun_gtkhashie, tvb, 0, tvb_reported_length(tvb), ENC_NA);
+ subtree = proto_item_add_subtree(item, ett_wisun_gtkhashie);
+
+ proto_tree_add_bitmask(subtree, tvb, 0, hf_wisun_wsie, ett_wisun_wsie_bitmap, wisun_format_nested_ie, ENC_LITTLE_ENDIAN);
+ proto_tree_add_item(subtree, hf_wisun_gtkhashie_gtk0, tvb, 2, 8, ENC_LITTLE_ENDIAN);
+ proto_tree_add_item(subtree, hf_wisun_gtkhashie_gtk1, tvb, 10, 8, ENC_LITTLE_ENDIAN);
+ proto_tree_add_item(subtree, hf_wisun_gtkhashie_gtk2, tvb, 18, 8, ENC_LITTLE_ENDIAN);
+ proto_tree_add_item(subtree, hf_wisun_gtkhashie_gtk3, tvb, 26, 8, ENC_LITTLE_ENDIAN);
+ return 34;
+}
+
+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);
+ guint offset = 2;
+ while (tvb_reported_length_remaining(tvb, offset) > 1) {
+ /* Wi-SUN Payload IE contains nested IE's using the same format as IEEE802.15.4 */
+ guint16 wsie_ie = tvb_get_letohs(tvb, offset);
+ guint16 wsie_len;
+ tvbuff_t * wsie_tvb;
+
+ /* No Wi-SUN Sub-IEs are currently defined for the short format. */
+ if (!(wsie_ie & IEEE802154_PSIE_TYPE_MASK)) {
+ wsie_len = (wsie_ie & IEEE802154_PSIE_LENGTH_MASK_SHORT) + 2;
+ call_data_dissector(tvb_new_subset_remaining(tvb, offset), pinfo, tree);
+ expert_add_info(pinfo, tree, &ei_wisun_wsie_short_format);
+ offset += wsie_len + 2;
+ continue;
+ }
+
+ wsie_len = (wsie_ie & IEEE802154_PSIE_LENGTH_MASK_LONG);
+ wsie_tvb = tvb_new_subset_length(tvb, offset, wsie_len + 2);
+ switch ((wsie_ie & IEEE802154_PSIE_ID_MASK_LONG) >> 11) {
+ case WISUN_PIE_SUBID_US:
+ dissect_wisun_usie(wsie_tvb, pinfo, tree, data);
+ break;
+ case WISUN_PIE_SUBID_BS:
+ dissect_wisun_bsie(wsie_tvb, pinfo, tree, data);
+ break;
+ case WISUN_PIE_SUBID_VP:
+ dissect_wisun_vpie(wsie_tvb, pinfo, tree, data);
+ break;
+ case WISUN_PIE_SUBID_PAN:
+ dissect_wisun_panie(wsie_tvb, pinfo, tree, data);
+ break;
+ case WISUN_PIE_SUBID_NETNAME:
+ dissect_wisun_netnameie(wsie_tvb, pinfo, tree, data);
+ break;
+ case WISUN_PIE_SUBID_PENVER:
+ dissect_wisun_panverie(wsie_tvb, pinfo, tree, data);
+ break;
+ case WISUN_PIE_SUBID_GTKHASH:
+ dissect_wisun_gtkhashie(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);
+ proto_tree_add_bitmask(subtree, wsie_tvb, 0, hf_wisun_wsie, ett_wisun_wsie_bitmap, wisun_format_nested_ie, ENC_LITTLE_ENDIAN);
+ expert_add_info(pinfo, subtree, &ei_wisun_wsie_unsupported);
+ call_data_dissector(tvb_new_subset_remaining(wsie_tvb, 2), pinfo, subtree);
+ break;
+ }
+ }
+ offset += (wsie_ie & IEEE802154_PSIE_LENGTH_MASK_LONG) + 2;
+ }
+ return offset;
+}
+
+/*-----------------------------------------------
+ * Wi-SUN FAN Security Extensions Dissection
+ *---------------------------------------------*/
+static int
+dissect_wisun_sec(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
+{
+ proto_item *ws_root;
+ proto_tree *ws_tree;
+ guint8 function = tvb_get_guint8(tvb, 0);
+ const char *function_name = val_to_str_const(function, wisun_sec_functions, "Unknown Function");
+
+ /* Create the protocol tree. */
+ ws_root = proto_tree_add_protocol_format(tree, proto_wisun_sec, tvb, 0, -1, "Wi-SUN %s", function_name);
+ ws_tree = proto_item_add_subtree(ws_root, ett_wisun_sec);
+
+ /* Add the protocol name. */
+ col_set_str(pinfo->cinfo, COL_PROTOCOL, "Wi-SUN");
+ col_set_str(pinfo->cinfo, COL_INFO, function_name);
+
+ /* Decode based on the function code. */
+ proto_tree_add_item(ws_tree, hf_wisun_sec_function, tvb, 0, 1, ENC_LITTLE_ENDIAN);
+ switch (function) {
+ case 0x01:{
+ const char *err_name = val_to_str_const(tvb_get_guint8(tvb, 1), wisun_sec_sm_errors, "Unknown Error");
+ col_append_fstr(pinfo->cinfo, COL_INFO, ": %s", err_name);
+ proto_item_append_text(ws_root, ": %s", err_name);
+
+ proto_tree_add_item(ws_tree, hf_wisun_sec_error_type, tvb, 1, 1, ENC_LITTLE_ENDIAN);
+ proto_tree_add_item(ws_tree, hf_wisun_sec_error_nonce, tvb, 2, tvb_reported_length_remaining(tvb, 2), ENC_NA);
+ return tvb_reported_length(tvb);
+ }
+
+ default:
+ call_data_dissector(tvb_new_subset_remaining(tvb, 2), pinfo, ws_tree);
+ return tvb_reported_length(tvb);
+ }
+}
+
+/*-----------------------------------------------
+ * Wi-SUN Protocol Registration
+ *---------------------------------------------*/
+void proto_register_wisun(void)
+{
+ static hf_register_info hf[] = {
+ /* Wi-SUN Header IEs */
+ { &hf_wisun_subid,
+ { "Header Sub ID", "wisun.subid", FT_UINT8, BASE_DEC, VALS(wisun_subid_vals), 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_unknown_ie,
+ { "Unknown IE", "wisun.unknown", FT_NONE, BASE_NONE, NULL, 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_uttie,
+ { "Unicast Timing IE", "wisun.uttie", FT_NONE, BASE_NONE, NULL, 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_uttie_type,
+ { "Frame Type", "wisun.uttie.type", FT_UINT8, BASE_DEC, VALS(wisun_frame_type_vals), 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_uttie_ufsi,
+ { "Unicast Fractional Sequence Interval", "wisun.uttie.ufsi", FT_UINT24, BASE_DEC, NULL, 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_btie,
+ { "Broadcast Timing IE", "wisun.btie", FT_NONE, BASE_NONE, NULL, 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_btie_slot,
+ { "Broadcast Slot Number", "wisun.btie.slot", FT_UINT24, BASE_DEC, NULL, 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_btie_bfio,
+ { "Broadcast Fractional Interval Offset", "wisun.btie.bfio", FT_UINT32, BASE_DEC, NULL, 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_fcie,
+ { "Flow Control IE", "wisun.fcie", FT_NONE, BASE_NONE, NULL, 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_fcie_tx,
+ { "Transmit Flow Control", "wisun.fcie.tx", FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_fcie_rx,
+ { "Receive Flow Control", "wisun.fcie.rx", FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_rslie,
+ { "Received Signal Level IE", "wisun.rslie", FT_NONE, BASE_NONE, NULL, 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_rslie_rsl,
+ { "Received Signal Level", "wisun.rslie.rsl", FT_UINT8, BASE_DEC, NULL, 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_vhie,
+ { "Vendor Header IE", "wisun.vhie", FT_NONE, BASE_NONE, NULL, 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_vhie_vid,
+ { "Vendor ID", "wisun.vhie.vid", FT_UINT32, BASE_DEC, NULL, 0x0,
+ NULL, HFILL }
+ },
+
+ /* Wi-SUN Payload IE */
+ { &hf_wisun_pie,
+ { "Wi-SUN Payload IE", "wisun.pie", FT_NONE, BASE_NONE, NULL, 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_wsie,
+ { "Wi-SUN Sub IE", "wisun.wsie", FT_UINT16, BASE_HEX, NULL, 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_wsie_type,
+ { "Type", "wisun.wsie.type", FT_UINT16, BASE_DEC, VALS(wisun_wsie_types), IEEE802154_PSIE_TYPE_MASK,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_wsie_id,
+ { "Sub ID", "wisun.wsie.id", FT_UINT16, BASE_DEC, VALS(wisun_wsie_names), IEEE802154_PSIE_ID_MASK_LONG,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_wsie_length,
+ { "Length", "wisun.wsie.length", FT_UINT16, BASE_DEC, NULL, IEEE802154_PSIE_LENGTH_MASK_LONG,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_usie,
+ { "Unicast Schedule IE", "wisun.usie", FT_NONE, BASE_NONE, NULL, 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_usie_dwell_interval,
+ { "Dwell Interval", "wisun.usie.dwell", FT_UINT8, BASE_DEC, NULL, 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_usie_clock_drift,
+ { "Clock Drift", "wisun.usie.drift", FT_UINT8, BASE_DEC, NULL, 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_usie_timing_accuracy,
+ { "Timing Accuracy", "wisun.usie.accuracy", FT_UINT8, BASE_DEC, NULL, 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_usie_channel_control,
+ { "Channel Control", "wisun.usie.channel", FT_UINT8, BASE_HEX, NULL, 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_usie_channel_plan,
+ { "Channel Plan", "wisun.usie.channel.plan", FT_UINT8, BASE_DEC, VALS(wisun_channel_plan_names), WISUN_CHANNEL_PLAN,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_usie_channel_function,
+ { "Channel Function", "wisun.usie.channel.function", FT_UINT8, BASE_DEC, VALS(wisun_channel_function_names), WISUN_CHANNEL_FUNCTION,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_usie_channel_exclude,
+ { "Excluded Channels", "wisun.usie.channel.exclude", FT_UINT8, BASE_DEC, VALS(wisun_channel_exclude_names), WISUN_CHANNEL_EXCLUDE,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_usie_regulatory_domain,
+ { "Regulatory Domain", "wisun.usie.domain", FT_UINT8, BASE_DEC, NULL, 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_usie_operating_class,
+ { "Operating Class", "wisun.usie.class", FT_UINT8, BASE_DEC, NULL, 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_usie_channel_frequency,
+ { "CH0 Frequency", "wisun.usie.channel_frequency", FT_UINT24, BASE_DEC, NULL, 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_usie_channel_spacing,
+ { "Channel Spacing", "wisun.usie.channel_spacing", FT_UINT8, BASE_DEC, VALS(wisun_channel_spacing_names), 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_usie_number_channels,
+ { "Number of Channels", "wisun.usie.num_channels", FT_UINT16, BASE_DEC, NULL, 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_usie_fixed_channel,
+ { "Fixed Channel", "wisun.usie.fixed_channel", FT_UINT16, BASE_DEC, NULL, 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_usie_hop_count,
+ { "Chanel Hop Count", "wisun.usie.hop_count", FT_UINT8, BASE_DEC, NULL, 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_usie_hop_list,
+ { "Channel Hop List", "wisun.usie.hop_list", FT_UINT8, BASE_DEC, NULL, 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_usie_number_ranges,
+ { "Number of Excluded Ranges", "wisun.usie.num_ranges", FT_UINT8, BASE_DEC, NULL, 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_usie_exclude_range,
+ { "Excluded Channel Range", "wisun.usie.exclude.range", FT_UINT16, BASE_DEC, NULL, 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_usie_exclude_mask,
+ { "Excluded Channel Mask", "wisun.usie.exclude.mask", FT_BYTES, BASE_NONE, NULL, 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_bsie,
+ { "Broadcast Schedule IE", "wisun.bsie", FT_NONE, BASE_NONE, NULL, 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_bsie_bcast_interval,
+ { "Broadcast Interval", "wisun.bsie.interval", FT_UINT32, BASE_DEC, NULL, 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_bsie_bcast_schedule_id,
+ { "Broadcast Schedule ID", "wisun.bsie.schedule", FT_UINT16, BASE_DEC, NULL, 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_vpie,
+ { "Vendor Payload IE", "wisun.vpie", FT_NONE, BASE_NONE, NULL, 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_vpie_vid,
+ { "Vendor ID", "wisun.vpie.vid", FT_UINT32, BASE_DEC, NULL, 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_panie,
+ { "PAN Information IE", "wisun.panie", FT_NONE, BASE_NONE, NULL, 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_panie_size,
+ { "PAN Size", "wisun.panie.size", FT_UINT16, BASE_DEC, NULL, 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_panie_cost,
+ { "Routing Cost", "wisun.panie.cost", FT_UINT8, BASE_DEC, NULL, 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_panie_flags,
+ { "PAN Flags", "wisun.panie.flags", FT_UINT8, BASE_HEX, NULL, 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_panie_flag_parent_bsie,
+ { "Use Parent BS-IE", "wisun.panie.flags.parent_bsie", FT_BOOLEAN, 8, NULL, 0x01,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_panie_flag_routing_method,
+ { "Routing Method", "wisun.panie.flags.routing_method", FT_UINT8, BASE_HEX, VALS(wisun_routing_methods), 0x02,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_panie_flag_eapol_ready,
+ { "EAPOL Ready", "wisun.panie.flags.eapol", FT_BOOLEAN, 8, NULL, 0x04,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_panie_flag_version,
+ { "FAN TPS Version", "wisun.panie.flags.version", FT_UINT8, BASE_DEC, NULL, 0xe0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_netnameie,
+ { "Network Name IE", "wisun.netnameie", FT_NONE, BASE_NONE, NULL, 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_netnameie_name,
+ { "Network Name", "wisun.netnameie.name", FT_STRING, STR_ASCII, NULL, 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_panverie,
+ { "PAN Version IE", "wisun.panverie", FT_NONE, BASE_NONE, NULL, 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_panverie_version,
+ { "PAN Version", "wisun.panverie.version", FT_UINT16, BASE_DEC, NULL, 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_gtkhashie,
+ { "GTK Hash IE", "wisun.gtkhashie", FT_NONE, BASE_NONE, NULL, 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_gtkhashie_gtk0,
+ { "GTK0 Hash", "wisun.gtkhashie.gtk0", FT_UINT64, BASE_HEX, NULL, 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_gtkhashie_gtk1,
+ { "GTK1 Hash", "wisun.gtkhashie.gtk1", FT_UINT64, BASE_HEX, NULL, 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_gtkhashie_gtk2,
+ { "GTK2 Hash", "wisun.gtkhashie.gtk2", FT_UINT64, BASE_HEX, NULL, 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_gtkhashie_gtk3,
+ { "GTK3 Hash", "wisun.gtkhashie.gtk3", FT_UINT64, BASE_HEX, 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,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_sec_error_type,
+ { "Error Type", "wisun.sec.error", FT_UINT8, BASE_HEX, VALS(wisun_sec_sm_errors), 0x0,
+ NULL, HFILL }
+ },
+
+ { &hf_wisun_sec_error_nonce,
+ { "Initiator Nonce", "wisun.sec.nonce", FT_BYTES, BASE_NONE, NULL, 0x0,
+ NULL, HFILL }
+ },
+ };
+
+ /* Subtrees */
+ static gint *ett[] = {
+ &ett_wisun_unknown_ie,
+ &ett_wisun_uttie,
+ &ett_wisun_btie,
+ &ett_wisun_fcie,
+ &ett_wisun_rslie,
+ &ett_wisun_vhie,
+ &ett_wisun_pie,
+ &ett_wisun_wsie_bitmap,
+ &ett_wisun_usie,
+ &ett_wisun_bsie,
+ &ett_wisun_vpie,
+ &ett_wisun_panie,
+ &ett_wisun_panie_flags,
+ &ett_wisun_netnameie,
+ &ett_wisun_panverie,
+ &ett_wisun_gtkhashie,
+ &ett_wisun_sec
+ };
+
+ static ei_register_info ei[] = {
+ { &ei_wisun_subid_unsupported, { "wisun.subid.unsupported", PI_PROTOCOL, PI_WARN,
+ "Unsuppoted Header Sub ID", EXPFILL }},
+ { &ei_wisun_wsie_short_format, { "wisun.wsie.short_format", PI_PROTOCOL, PI_WARN,
+ "Wi-SUN Sub-IE are not valid for the short format", EXPFILL }},
+ { &ei_wisun_usie_channel_plan_invalid, { "wisun.usie.channel.plan.invalid", PI_PROTOCOL, PI_WARN,
+ "Invalid Channel Plan", EXPFILL }},
+ { &ei_wisun_wsie_unsupported, { "wisun.wsie.unsupported", PI_PROTOCOL, PI_WARN,
+ "Unsupported Sub-IE ID", EXPFILL }},
+ };
+
+ expert_module_t* expert_wisun;
+
+ proto_wisun = proto_register_protocol("Wi-SUN Field Area Network", "Wi-SUN", "wisun");
+ proto_wisun_sec = proto_register_protocol("Wi-SUN FAN Security Extension", "Wi-SUN WM-SEC", "wisun.sec");
+
+ proto_register_field_array(proto_wisun, hf, array_length(hf));
+ proto_register_subtree_array(ett, array_length(ett));
+
+ expert_wisun = expert_register_protocol(proto_wisun);
+ expert_register_field_array(expert_wisun, ei, array_length(ei));
+
+ register_dissector("wisun.sec", dissect_wisun_sec, proto_wisun_sec);
+}
+
+void proto_reg_handoff_wisun(void)
+{
+ dissector_add_uint(IEEE802154_HEADER_IE_DTABLE, IEEE802154_HEADER_IE_WISUN, create_dissector_handle(dissect_wisun_hie, proto_wisun));
+ dissector_add_uint(IEEE802154_PAYLOAD_IE_DTABLE, IEEE802154_PAYLOAD_IE_WISUN, create_dissector_handle(dissect_wisun_pie, proto_wisun));
+}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */
diff --git a/epan/oui.h b/epan/oui.h
index 1c25f416a4..7272d04a06 100644
--- a/epan/oui.h
+++ b/epan/oui.h
@@ -87,6 +87,7 @@
#define OUI_APPLE_ATALK 0x080007 /* Appletalk */
#define OUI_HP 0x080009 /* Hewlett-Packard */
#define OUI_HYTEC_GER 0x30B216 /* Hytec Geraetebau GmbH */
+#define OUI_ZIGBEE 0x4A191B /* ZigBee Alliance */
#define OUI_WFA 0x506F9A /* Wi-Fi Alliance */
#define OUI_3GPP2 0xCF0002 /* 3GPP2 */