Function anjay_security_config_from_dm
Defined in File core.h
Function Documentation
-
int anjay_security_config_from_dm(anjay_t *anjay, anjay_security_config_t *out_config, const char *uri)
Queries security configuration appropriate for a specified URI.
Given a URI, the Security object is scanned for instances with Server URI resource matching it in the following way:
if there is at least one instance with matching hostname, protocol and port number, and valid secure connection configuration, the first such instance (in the order as returned via anjay_dm_list_instances_t) is used
otherwise, if there is at least one instance with matching hostname and valid secure connection configuration, the first such instance (in the order as returned via anjay_dm_list_instances_t) is used
The returned security information is exactly the same configuration that is used for LwM2M connection with the server chosen with the rules described above.
NOTE: The returned structure will contain pointers to buffers allocated within the
anjayobject. They will only be valid until next call toanjay_security_config_from_dm()or anjay_serve. Note that this is enough for direct use in anjay_fw_update_get_security_config_t implementations. If you need this information for a longer period, you will need to manually create a deep copy.In particular, you may need to implement additional synchronization to achieve thread safety if calling this function from multiple threads. Instead, it is recommended to only call it from callback functions called from within Anjay, or in scheduler jobs.
- Parameters:
anjay – Anjay object whose data model shall be queried.
out_config – Pointer to an anjay_security_config_t structure that will be filled with the appropriate information, if found.
uri – URI for which to find security configuration.
- Returns:
0 for success, or a negative value in case of error, including if no suitable LwM2M Security Object instance could be found.