mesh: Clear addr field if virt sub failed
authorIsak Westin <isak.westin@loytec.com>
Fri, 23 Sep 2022 11:31:48 +0000 (13:31 +0200)
committerAyush Garg <ayush.garg@samsung.com>
Mon, 15 May 2023 09:25:55 +0000 (14:55 +0530)
If processing failed for a Config Model Subscription Virtual Address
Add/Delete/Overwrite message, the address field in the status reply
should be set to zero. See MshPRFv1.0.1 section 4.4.1.2.8.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
mesh/cfgmod-server.c

index c1e1faa..9bc2f1c 100644 (file)
@@ -286,6 +286,10 @@ static uint16_t cfg_virt_sub_add_msg(struct mesh_node *node, const uint8_t *pkt,
                                                label, true, addr, opcode))
                msg[n] = MESH_STATUS_STORAGE_FAIL;
 
+       /* If processing failed, set addr field to zero in reply */
+       if (msg[n] != MESH_STATUS_SUCCESS)
+               addr = UNASSIGNED_ADDRESS;
+
        l_put_le16(ele_addr, msg + n + 1);
        l_put_le16(addr, msg + n + 3);