From a025147c990591dd43222a26f6dc45fcd7aaca25 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Fri, 26 Apr 2019 23:06:47 +0200 Subject: [PATCH] mesh: respond with Invalid NetKey on AppKey Add that already exists but with different NetKey --- test/mesh/mesh.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/mesh/mesh.c b/test/mesh/mesh.c index fc5064ce9..ce11b7fea 100644 --- a/test/mesh/mesh.c +++ b/test/mesh/mesh.c @@ -1573,7 +1573,10 @@ static void config_appkey_add_handler(mesh_model_t *mesh_model, mesh_pdu_t * pdu mesh_transport_key_t * transport_key = mesh_transport_key_get(appkey_index); if (transport_key){ uint8_t status; - if (memcmp(transport_key->key, appkey, 16) == 0){ + if (transport_key->netkey_index != netkey_index){ + // already stored but with different netkey + status = MESH_FOUNDATION_STATUS_INVALID_NETKEY_INDEX; + } else if (memcmp(transport_key->key, appkey, 16) == 0 && transport_key->netkey_index == netkey_index){ // key identical status = MESH_FOUNDATION_STATUS_SUCCESS; } else {