net: lwm2m: Fix Security and Server object instance matching
A proper way to match a Security object instance with a Server object instance is via Short Server ID resource. Both coupled object instances should carry the same value of this resource in order to me considered matched. This was not implemented in the LwM2M library and it was incorrectly assumed that the Security object instance index corresponds to the Server object instance index. While such apporach works is simple scenario, it might yield incorrect results when bootstrap is used. Fix this, by verifyng the Short Server ID resource in the Secuirty instance used, and finding a matching Server instance. The server object instance is stored for future use in the engine. Additionally, remove an extra Server object instance that was created when the bootstrap procedure was used. Since the boostrap Security object instance does not have the corresponding Server object, it's enough to have a single Server instance. Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit is contained in:
parent
74fa8cef21
commit
b9caaf217e
6 changed files with 112 additions and 69 deletions
|
@ -424,8 +424,8 @@ static int engine_add_observer(struct lwm2m_message *msg,
|
|||
}
|
||||
|
||||
/* defaults from server object */
|
||||
attrs.pmin = lwm2m_server_get_pmin(msg->ctx->sec_obj_inst);
|
||||
attrs.pmax = lwm2m_server_get_pmax(msg->ctx->sec_obj_inst);
|
||||
attrs.pmin = lwm2m_server_get_pmin(msg->ctx->srv_obj_inst);
|
||||
attrs.pmax = lwm2m_server_get_pmax(msg->ctx->srv_obj_inst);
|
||||
|
||||
/* TODO: observe dup checking */
|
||||
|
||||
|
@ -2761,8 +2761,8 @@ static int lwm2m_write_attr_handler(struct lwm2m_engine_obj *obj,
|
|||
}
|
||||
|
||||
/* defaults from server object */
|
||||
nattrs.pmin = lwm2m_server_get_pmin(msg->ctx->sec_obj_inst);
|
||||
nattrs.pmax = lwm2m_server_get_pmax(msg->ctx->sec_obj_inst);
|
||||
nattrs.pmin = lwm2m_server_get_pmin(msg->ctx->srv_obj_inst);
|
||||
nattrs.pmax = lwm2m_server_get_pmax(msg->ctx->srv_obj_inst);
|
||||
|
||||
ret = update_attrs(obj, &nattrs);
|
||||
if (ret < 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue