Updated Wi-SUN dissector to latest specification.
authorEd Beroset <beroset@ieee.org>
Wed, 21 Feb 2018 02:51:26 +0000 (21:51 -0500)
committerStig Bjørlykke <stig@bjorlykke.org>
Wed, 21 Feb 2018 08:14:33 +0000 (08:14 +0000)
Change-Id: Iaa3dc73fecf0a5e323fe6306b049514bfd09399d
Reviewed-on: https://code.wireshark.org/review/25956
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
epan/dissectors/packet-ieee802154.c
epan/dissectors/packet-wisun.c

index f447f3fc56e6029d1263ca08205f9c21ffaa84be..efb33b20119f3c27650aa7d12b5700bb3503e505 100644 (file)
@@ -571,6 +571,7 @@ static expert_field ei_ieee802154_ie_unknown_extra_content = EI_INIT;
 static expert_field ei_ieee802159_mpx_invalid_transfer_type = EI_INIT;
 static expert_field ei_ieee802159_mpx_unsupported_kmp = EI_INIT;
 static expert_field ei_ieee802159_mpx_unknown_kmp = EI_INIT;
+static expert_field ei_ieee802154_missing_payload_ie = EI_INIT;
 
 static int ieee802_15_4_short_address_type = -1;
 /*
@@ -1908,7 +1909,11 @@ dissect_ieee802154_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, g
 
     /* Presence of Payload IEs is defined by the termination of the Header IEs */
     if (packet->payload_ie_present) {
-        offset += dissect_ieee802154_payload_ie(payload_tvb, pinfo, ieee802154_tree, offset, packet);
+        if (tvb_reported_length_remaining(payload_tvb, offset) > 2) {
+            offset += dissect_ieee802154_payload_ie(payload_tvb, pinfo, ieee802154_tree, offset, packet);
+        } else {
+            expert_add_info(pinfo, proto_root, &ei_ieee802154_missing_payload_ie);
+        }
     }
 
     if ((packet->version == IEEE802154_VERSION_2015) && (packet->frame_type == IEEE802154_FCF_CMD)) {
@@ -5015,6 +5020,8 @@ void proto_register_ieee802154(void)
                 "Unsupported KMP ID", EXPFILL }},
         { &ei_ieee802159_mpx_unknown_kmp, { "wpan.payload_ie.mpx.invalid_transfer_type", PI_PROTOCOL, PI_WARN,
                 "Unknown KMP ID (cf. IEEE 802.15.9 Table 21)", EXPFILL }},
+        { &ei_ieee802154_missing_payload_ie, { "wpan.payload_ie.missing",  PI_MALFORMED, PI_WARN,
+                "Payload IE indicated by Header Termination, but no Payload IE present", EXPFILL }},
     };
 
     /* Preferences. */
index 863fb5b7c0052e91f1d5bebac590d3ba15fb7689..33acc7b51c221c97661d5522fd1cbd98c7011d18 100644 (file)
@@ -49,6 +49,7 @@ static wmem_map_t* edfe_byaddr;
 #define WISUN_SUBID_RSL     4
 #define WISUN_SUBID_MHDS    5
 #define WISUN_SUBID_VH      6
+#define WISUN_SUBID_EA      9
 
 /* Wi-SUN Payload/Nested ID values. */
 #define WISUN_PIE_SUBID_US      1
@@ -89,11 +90,15 @@ 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_eaie = -1;
+static int hf_wisun_eaie_eui = -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_wsie_id_short = -1;
+static int hf_wisun_wsie_length_short = -1;
 static int hf_wisun_usie = -1;
 static int hf_wisun_usie_dwell_interval = -1;
 static int hf_wisun_usie_clock_drift = -1;
@@ -147,6 +152,7 @@ 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_eaie = -1;
 static gint ett_wisun_pie = -1;
 static gint ett_wisun_wsie_bitmap = -1;
 static gint ett_wisun_usie = -1;
@@ -173,6 +179,7 @@ static const value_string wisun_subid_vals[] = {
     { WISUN_SUBID_RSL,      "Received Signal Level IE" },
     { WISUN_SUBID_MHDS,     "Multi-Hop Delivery Service IE" },
     { WISUN_SUBID_VH,       "Vendor Header IE" },
+    { WISUN_SUBID_EA,       "EAPOL Authenticator EUI-64 IE" },
     { 0, NULL }
 };
 
@@ -253,6 +260,13 @@ static const int * wisun_format_nested_ie[] = {
     NULL
 };
 
+static const int * wisun_format_nested_ie_short[] = {
+    &hf_wisun_wsie_type,
+    &hf_wisun_wsie_id_short,
+    &hf_wisun_wsie_length_short,
+    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;
@@ -299,8 +313,9 @@ 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;
+    /* as of FAN TPS 1v14, this is 3 bytes instead of 4 */
+    proto_tree_add_item(tree, hf_wisun_btie_bfio, tvb, offset+2, 3, ENC_LITTLE_ENDIAN);
+    return 5;
 }
 
 static void
@@ -386,6 +401,13 @@ dissect_wisun_vhie(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint of
     return tvb_reported_length(tvb);
 }
 
+static int
+dissect_wisun_eaie(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, guint offset)
+{
+    proto_tree_add_item(tree, hf_wisun_eaie_eui, tvb, offset, 8, ENC_BIG_ENDIAN);
+    return 8;
+}
+
 static int
 dissect_wisun_hie(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
 {
@@ -421,6 +443,11 @@ dissect_wisun_hie(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat
             offset += dissect_wisun_vhie(tvb, pinfo, subtree, offset);
             break;
 
+        case WISUN_SUBID_EA:
+            subtree = wisun_create_hie_tree(tvb, tree, hf_wisun_eaie, ett_wisun_eaie);
+            offset += dissect_wisun_eaie(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);
@@ -615,7 +642,7 @@ dissect_wisun_panie(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, voi
     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);
+    proto_tree_add_bitmask(subtree, tvb, offset, hf_wisun_wsie, ett_wisun_wsie_bitmap, wisun_format_nested_ie_short, ENC_LITTLE_ENDIAN);
     offset += 2;
     proto_tree_add_item(subtree, hf_wisun_panie_size, tvb, offset, 2, ENC_LITTLE_ENDIAN);
     offset += 2;
@@ -636,7 +663,7 @@ dissect_wisun_netnameie(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
     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_bitmask(subtree, tvb, 0, hf_wisun_wsie, ett_wisun_wsie_bitmap, wisun_format_nested_ie_short, 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);
 }
@@ -650,7 +677,7 @@ dissect_wisun_panverie(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
     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_bitmask(subtree, tvb, 0, hf_wisun_wsie, ett_wisun_wsie_bitmap, wisun_format_nested_ie_short, ENC_LITTLE_ENDIAN);
     proto_tree_add_item(subtree, hf_wisun_panverie_version, tvb, 2, 2, ENC_LITTLE_ENDIAN);
     return tvb_reported_length(tvb);
 }
@@ -664,11 +691,11 @@ dissect_wisun_gtkhashie(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
     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);
+    proto_tree_add_bitmask(subtree, tvb, 0, hf_wisun_wsie, ett_wisun_wsie_bitmap, wisun_format_nested_ie_short, ENC_LITTLE_ENDIAN);
+    proto_tree_add_item(subtree, hf_wisun_gtkhashie_gtk0, tvb, 2, 8, ENC_NA);
+    proto_tree_add_item(subtree, hf_wisun_gtkhashie_gtk1, tvb, 10, 8, ENC_NA);
+    proto_tree_add_item(subtree, hf_wisun_gtkhashie_gtk2, tvb, 18, 8, ENC_NA);
+    proto_tree_add_item(subtree, hf_wisun_gtkhashie_gtk3, tvb, 26, 8, ENC_NA);
     return 34;
 }
 
@@ -683,50 +710,59 @@ dissect_wisun_pie(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ies_tree, void
         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;
+        if (wsie_ie & IEEE802154_PSIE_TYPE_MASK) {
+            /* long format: Table 7-17-Sub-ID allocation for long format */
+            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;
+
+                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;
+                }
+            }
+        } else {
+            /* short format: Table 7-16-Sub-ID allocation for short format */
+            wsie_len = (wsie_ie & IEEE802154_PSIE_LENGTH_MASK_SHORT);
+            wsie_tvb = tvb_new_subset_length(tvb, offset, wsie_len + 2);
+            switch ((wsie_ie & IEEE802154_PSIE_ID_MASK_SHORT) >> 8) {
+                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;
+        offset += tvb_reported_length(wsie_tvb);
     }
     return offset;
 }
@@ -851,6 +887,16 @@ void proto_register_wisun(void)
             NULL, HFILL }
         },
 
+        { &hf_wisun_eaie,
+          { "EAPOL Authenticator IE", "wisun.eaie", FT_NONE, BASE_NONE, NULL, 0x0,
+            NULL, HFILL }
+        },
+
+        { &hf_wisun_eaie_eui,
+          { "Vendor ID", "wisun.eaie.eui", FT_EUI64, BASE_NONE, NULL, 0x0,
+            NULL, HFILL }
+        },
+
         /* Wi-SUN Payload IE */
         { &hf_wisun_pie,
           { "Wi-SUN Payload IE", "wisun.pie", FT_NONE, BASE_NONE, NULL, 0x0,
@@ -877,6 +923,16 @@ void proto_register_wisun(void)
             NULL, HFILL }
         },
 
+        { &hf_wisun_wsie_id_short,
+          { "Sub ID", "wisun.wsie.id", FT_UINT16, BASE_DEC, VALS(wisun_wsie_names), IEEE802154_PSIE_ID_MASK_SHORT,
+            NULL, HFILL }
+        },
+
+        { &hf_wisun_wsie_length_short,
+          { "Length", "wisun.wsie.length", FT_UINT16, BASE_DEC, NULL, IEEE802154_PSIE_LENGTH_MASK_SHORT,
+            NULL, HFILL }
+        },
+
         { &hf_wisun_usie,
           { "Unicast Schedule IE", "wisun.usie", FT_NONE, BASE_NONE, NULL, 0x0,
             NULL, HFILL }
@@ -1063,22 +1119,22 @@ void proto_register_wisun(void)
         },
 
         { &hf_wisun_gtkhashie_gtk0,
-          { "GTK0 Hash", "wisun.gtkhashie.gtk0", FT_UINT64, BASE_HEX, NULL, 0x0,
+          { "GTK0 Hash", "wisun.gtkhashie.gtk0", FT_BYTES, BASE_NONE, NULL, 0x0,
             NULL, HFILL }
         },
 
         { &hf_wisun_gtkhashie_gtk1,
-          { "GTK1 Hash", "wisun.gtkhashie.gtk1", FT_UINT64, BASE_HEX, NULL, 0x0,
+          { "GTK1 Hash", "wisun.gtkhashie.gtk1", FT_BYTES, BASE_NONE, NULL, 0x0,
             NULL, HFILL }
         },
 
         { &hf_wisun_gtkhashie_gtk2,
-          { "GTK2 Hash", "wisun.gtkhashie.gtk2", FT_UINT64, BASE_HEX, NULL, 0x0,
+          { "GTK2 Hash", "wisun.gtkhashie.gtk2", FT_BYTES, BASE_NONE, NULL, 0x0,
             NULL, HFILL }
         },
 
         { &hf_wisun_gtkhashie_gtk3,
-          { "GTK3 Hash", "wisun.gtkhashie.gtk3", FT_UINT64, BASE_HEX, NULL, 0x0,
+          { "GTK3 Hash", "wisun.gtkhashie.gtk3", FT_BYTES, BASE_NONE, NULL, 0x0,
             NULL, HFILL }
         },
 
@@ -1107,6 +1163,7 @@ void proto_register_wisun(void)
         &ett_wisun_fcie,
         &ett_wisun_rslie,
         &ett_wisun_vhie,
+        &ett_wisun_eaie,
         &ett_wisun_pie,
         &ett_wisun_wsie_bitmap,
         &ett_wisun_usie,