diff --git a/mesh/model.c b/mesh/model.c
index 90bb62d..f29ad9a 100644
--- a/mesh/model.c
+++ b/mesh/model.c
model = l_queue_find(models, match_model_id, L_UINT_TO_PTR(id));
- if (status)
- *status = (model) ? MESH_STATUS_SUCCESS :
- MESH_STATUS_INVALID_MODEL;
+ *status = (model) ? MESH_STATUS_SUCCESS : MESH_STATUS_INVALID_MODEL;
return model;
}
*dst = l_get_le16(mod_addr);
}
- if (b_virt) {
- if (!mesh_crypto_virtual_addr(mod_addr, &grp))
- return MESH_STATUS_STORAGE_FAIL;
- }
+ if (b_virt && !mesh_crypto_virtual_addr(mod_addr, &grp))
+ return MESH_STATUS_STORAGE_FAIL;
/* If old publication was Virtual, remove it */
if (mod->pub && mod->pub->addr >= VIRTUAL_BASE) {
}
mod->pub = l_new(struct mesh_model_pub, 1);
+
if (b_virt) {
virt = l_queue_find(mesh_virtuals, find_virt_by_addr, mod_addr);
if (!virt) {
} else {
grp = virt->ota;
}
+
virt->ref_cnt++;
l_queue_push_head(mod->virtuals, virt);
mod->pub->addr = virt->id;
mod->pub = NULL;
/* Remove publication if Pub Addr is 0x0000 */
} else {
+
if (!mod->pub)
mod->pub = l_new(struct mesh_model_pub, 1);
- if (!mod->pub)
- return MESH_STATUS_STORAGE_FAIL;
mod->pub->credential = cred_flag;
mod->pub->idx = idx;
virt->id = virt_id_next++;
virt->ota = grp;
memcpy(virt->addr, group, sizeof(virt->addr));
+
if (!l_queue_push_head(mesh_virtuals, virt))
return MESH_STATUS_STORAGE_FAIL;
} else {
grp = virt->ota;
}
+
virt->ref_cnt++;
l_queue_push_head(mod->virtuals, virt);
} else {
void *user_data)
{
struct mesh_model *mod;
+ int status;
/* Internal models are always SIG models */
mod_id = VENDOR_ID_MASK | mod_id;
- mod = get_model(node, ele_idx, mod_id, NULL);
+ mod = get_model(node, ele_idx, mod_id, &status);
if (!mod)
return false;
buf += 3;
n += 3;
}
+
i++;
}
struct mesh_net *net = node_get_net(node);
entry = l_queue_get_entries(subs);
+
for (; entry; entry = entry->next)
mesh_net_dst_unreg(net,
(uint16_t) L_PTR_TO_UINT(entry->data));
return fail;
entry = l_queue_get_entries(mod->subs);
+
for (; entry; entry = entry->next)
mesh_net_dst_unreg(net, (uint16_t) L_PTR_TO_UINT(entry->data));
}
virt = l_new(struct mesh_virtual, 1);
- if (!virt)
- return;
if (!mesh_crypto_virtual_addr(v, &virt->ota)) {
l_free(virt);