mesh: Clean up handling of config node identity message
authorInga Stotland <inga.stotland@intel.com>
Fri, 7 Aug 2020 01:38:27 +0000 (18:38 -0700)
committerAbhay Agarwal <ay.agarwal@samsung.com>
Mon, 28 Dec 2020 06:20:04 +0000 (11:50 +0530)
This modification allows using a single point for sending out
the composed status messages by the Config Server.

Change-Id: I8e60fab5765702d588714462afc993cebe11483c
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
mesh/cfgmod-server.c

index c206862..6988124 100644 (file)
@@ -776,11 +776,7 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx,
                break;
 
        case OP_NODE_IDENTITY_SET:
-               if (size != 3 || pkt[2] > 0x01)
-                       return true;
-
-               n_idx = l_get_le16(pkt);
-               if (n_idx > 0xfff)
+               if (size != 3)
                        return true;
 
                /* Currently setting node identity not supported */
@@ -788,18 +784,15 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx,
                /* Fall Through */
 
        case OP_NODE_IDENTITY_GET:
-               if (size < 2)
+               if (opcode == OP_NODE_IDENTITY_GET && size != 2)
                        return true;
 
                n_idx = l_get_le16(pkt);
-               if (n_idx > 0xfff)
+               if (n_idx > NET_IDX_MAX)
                        return true;
 
                n = mesh_model_opcode_set(OP_NODE_IDENTITY_STATUS, msg);
-
-               status = mesh_net_get_identity_mode(net, n_idx, &state);
-
-               msg[n++] = status;
+               msg[n++] = mesh_net_get_identity_mode(net, n_idx, &state);
 
                l_put_le16(n_idx, msg + n);
                n += 2;