ZigBee: implement dissector for Parent_Annce_rsp; minor fixes
authordsrsupport <eugene.exarevsky@dsr-company.com>
Thu, 21 Jul 2016 14:35:24 +0000 (17:35 +0300)
committerMichael Mann <mmann78@netscape.net>
Sat, 23 Jul 2016 04:29:59 +0000 (04:29 +0000)
Implement dissector for User Descriptor Response.
Fix Number OfChild foield or Parent_Annce.
Fix name of User Descriptor Response cluster.

Change-Id: Ia48277a76bc7742021a407a45ca18e2c51a35046
Reviewed-on: https://code.wireshark.org/review/16570
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Michael Mann <mmann78@netscape.net>
epan/dissectors/packet-zbee-zdp-discovery.c
epan/dissectors/packet-zbee-zdp.c
epan/dissectors/packet-zbee-zdp.h

index 9f6d6c3a888677810bf59e8b0ff304ede56ba160..6c1f5c882f89738280db73ad9453097bc978783f 100644 (file)
@@ -320,7 +320,7 @@ dissect_zbee_zdp_parent_annce(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre
     guint   i;
     guint64 ext_addr;
 
-    n_children  = zbee_parse_uint(tree, hf_zbee_zdp_device, tvb, &offset, (int)1, NULL);
+    n_children  = zbee_parse_uint(tree, hf_zbee_zdp_number_of_children, tvb, &offset, (int)1, NULL);
     zbee_append_info(tree, pinfo, ", # children %d :", n_children);
     for (i = 0 ; i < n_children ; ++i)
     {
@@ -335,6 +335,40 @@ dissect_zbee_zdp_parent_annce(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre
     zdp_dump_excess(tvb, offset, pinfo, tree);
 } /* dissect_zbee_zdp_parent_annce */
 
+
+/**
+ *ZigBee Device Profile dissector for the parent announce rsp
+ *
+ *@param tvb pointer to buffer containing raw packet.
+ *@param pinfo pointer to packet information fields
+ *@param tree pointer to data tree Wireshark uses to display packet.
+*/
+void
+dissect_zbee_zdp_rsp_parent_annce(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+{
+    guint   offset = 0;
+    guint   n_children;
+    guint   i;
+    guint64 ext_addr;
+    guint8  status;
+
+    status = zdp_parse_status(tree, tvb, &offset);
+    n_children  = zbee_parse_uint(tree, hf_zbee_zdp_number_of_children, tvb, &offset, (int)1, NULL);
+    zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
+    zbee_append_info(tree, pinfo, ", # children %d :", n_children);
+    for (i = 0 ; i < n_children ; ++i)
+    {
+        ext_addr = zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, (int)sizeof(guint64), NULL);
+        if (i == 0)
+        {
+            zbee_append_info(tree, pinfo, n_children == 1 ? " %s" : " %s ...", eui64_to_display(wmem_packet_scope(), ext_addr));
+        }
+    }
+
+    /* Dump any leftover bytes. */
+    zdp_dump_excess(tvb, offset, pinfo, tree);
+} /* dissect_zbee_zdp_rsp_parent_annce */
+
 /**
  *ZigBee Device Profile dissector for the end set user
  *
index e36be76c0e7569b5c70ef39890ab032a1ae493c9..9c8582b4e4cbffb5a5b1db9c9b7c4ece5507b41c 100644 (file)
@@ -194,6 +194,7 @@ static int hf_zbee_zdp_scan_channel = -1;
        int hf_zbee_zdp_ieee_join_list_start = -1;
        int hf_zbee_zdp_ieee_join_list_count = -1;
        int hf_zbee_zdp_ieee_join_list_ieee = -1;
+       int hf_zbee_zdp_number_of_children = -1;
 
 /* Routing Table */
        int hf_zbee_zdp_rtg = -1;
@@ -202,6 +203,7 @@ static int hf_zbee_zdp_scan_channel = -1;
        int hf_zbee_zdp_rtg_next_hop = -1;
        int hf_zbee_zdp_rtg_status = -1;
 
+
 /* Subtree indicies. */
 static gint ett_zbee_zdp = -1;
        gint ett_zbee_zdp_endpoint = -1;
@@ -295,7 +297,7 @@ const value_string zbee_zdp_cluster_names[] = {
     { ZBEE_ZDP_RSP_ACTIVE_EP,                     "Active Endpoint Response" },
     { ZBEE_ZDP_RSP_MATCH_DESC,                    "Match Descriptor Response" },
     { ZBEE_ZDP_RSP_COMPLEX_DESC,                  "Complex Descriptor Response" },
-    { ZBEE_ZDP_RSP_USER_DESC,                     "User Descriptor Request" },
+    { ZBEE_ZDP_RSP_USER_DESC,                     "User Descriptor Response" },
     { ZBEE_ZDP_RSP_DISCOVERY_CACHE,               "Discovery Cache Response" },
     { ZBEE_ZDP_RSP_CONF_USER_DESC,                "Set User Descriptor Confirm" },
     { ZBEE_ZDP_RSP_SYSTEM_SERVER_DISC,            "Server Discovery Response" },
@@ -308,6 +310,7 @@ const value_string zbee_zdp_cluster_names[] = {
     { ZBEE_ZDP_RSP_FIND_NODE_CACHE,               "Find Node Cache Response" },
     { ZBEE_ZDP_RSP_EXT_SIMPLE_DESC,               "Extended Simple Descriptor Response" },
     { ZBEE_ZDP_RSP_EXT_ACTIVE_EP,                 "Extended Active Endpoint Response" },
+    { ZBEE_ZDP_RSP_PARENT_ANNCE,                  "Parent Announce Response" },
     { ZBEE_ZDP_RSP_END_DEVICE_BIND,               "End Device Bind Response" },
     { ZBEE_ZDP_RSP_BIND,                          "Bind Response" },
     { ZBEE_ZDP_RSP_UNBIND,                        "Unbind Response" },
@@ -1228,6 +1231,9 @@ dissect_zbee_zdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data
         case ZBEE_ZDP_RSP_EXT_ACTIVE_EP:
             dissect_zbee_zdp_rsp_ext_active_ep(zdp_tvb, pinfo, zdp_tree);
             break;
+        case ZBEE_ZDP_RSP_PARENT_ANNCE:
+            dissect_zbee_zdp_rsp_parent_annce(zdp_tvb, pinfo, zdp_tree);
+            break;
         case ZBEE_ZDP_RSP_END_DEVICE_BIND:
             dissect_zbee_zdp_rsp_end_device_bind(zdp_tvb, pinfo, zdp_tree);
             break;
@@ -1821,6 +1827,9 @@ void proto_register_zbee_zdp(void)
         { "IEEE",                "zbee_zdp.ieee_joining_list.ieee", FT_EUI64, BASE_NONE, NULL, 0x0,
             NULL, HFILL }},
 
+        { &hf_zbee_zdp_number_of_children,
+          { "NumberOfChildren",    "zbee_zdp.n_children", FT_UINT8, BASE_DEC, NULL, 0x0,
+            NULL, HFILL }},
     };
 
     /*  APS subtrees */
index b58099090908e5f828bcfb61940a6a874c405ed6..9f9807839166c3dd961bd5c945d06849ea755589 100644 (file)
@@ -96,6 +96,7 @@
 #define ZBEE_ZDP_RSP_FIND_NODE_CACHE              0x801c  /* ZigBee 2006 & later. */
 #define ZBEE_ZDP_RSP_EXT_SIMPLE_DESC              0x801d  /* ZigBee 2007 & later. */
 #define ZBEE_ZDP_RSP_EXT_ACTIVE_EP                0x801e  /* ZigBee 2007 & later. */
+#define ZBEE_ZDP_RSP_PARENT_ANNCE                 0x801f  /* r21 */
 #define ZBEE_ZDP_RSP_END_DEVICE_BIND              0x8020
 #define ZBEE_ZDP_RSP_BIND                         0x8021
 #define ZBEE_ZDP_RSP_UNBIND                       0x8022
@@ -292,6 +293,7 @@ extern int hf_zbee_zdp_ieee_join_list_total;
 extern int hf_zbee_zdp_ieee_join_list_start;
 extern int hf_zbee_zdp_ieee_join_list_count;
 extern int hf_zbee_zdp_ieee_join_list_ieee;
+extern int hf_zbee_zdp_number_of_children;
 
 /* Routing Table */
 extern int hf_zbee_zdp_rtg;
@@ -358,6 +360,7 @@ extern void dissect_zbee_zdp_req_user_desc              (tvbuff_t *tvb, packet_i
 extern void dissect_zbee_zdp_req_discovery_cache        (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
 extern void dissect_zbee_zdp_device_annce               (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
 extern void dissect_zbee_zdp_parent_annce               (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
+extern void dissect_zbee_zdp_rsp_parent_annce           (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
 extern void dissect_zbee_zdp_req_set_user_desc          (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint8 version);
 extern void dissect_zbee_zdp_req_system_server_disc     (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
 extern void dissect_zbee_zdp_req_store_discovery        (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);