anjay
Loading...
Searching...
No Matches
dm.h
Go to the documentation of this file.
1/*
2 * Copyright 2017-2024 AVSystem <avsystem@avsystem.com>
3 * AVSystem Anjay LwM2M SDK
4 * All rights reserved.
5 *
6 * Licensed under the AVSystem-5-clause License.
7 * See the attached LICENSE file for details.
8 */
9
10#ifndef ANJAY_INCLUDE_ANJAY_DM_H
11#define ANJAY_INCLUDE_ANJAY_DM_H
12
13#include <math.h>
14#include <stdint.h>
15
16#include <anjay/io.h>
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
22#define ANJAY_DM_OID_SECURITY 0
23#define ANJAY_DM_OID_SERVER 1
24#define ANJAY_DM_OID_ACCESS_CONTROL 2
25#define ANJAY_DM_OID_DEVICE 3
26#define ANJAY_DM_OID_FIRMWARE_UPDATE 5
27
29
36
38typedef struct {
40 int32_t min_period;
42 int32_t max_period;
47#ifdef ANJAY_WITH_CON_ATTR
50#endif // ANJAY_WITH_CON_ATTR
52
64
67#define ANJAY_ATTRIB_INTEGER_NONE (-1)
68
70#define ANJAY_ATTRIB_PERIOD_NONE ANJAY_ATTRIB_INTEGER_NONE
71
74#define ANJAY_ATTRIB_DOUBLE_NONE (NAN)
75
77#define ANJAY_ATTRIB_VALUE_NONE ANJAY_ATTRIB_DOUBLE_NONE
78
82
86
104 anjay_t *anjay,
105 const anjay_dm_object_def_t *const *obj_ptr,
106 anjay_ssid_t ssid,
108
126 anjay_t *anjay,
127 const anjay_dm_object_def_t *const *obj_ptr,
128 anjay_ssid_t ssid,
129 const anjay_dm_oi_attributes_t *attrs);
130
162typedef int
164 const anjay_dm_object_def_t *const *obj_ptr,
166
174 const anjay_dm_object_def_t *const *obj_ptr,
176
196typedef int
198 const anjay_dm_object_def_t *const *obj_ptr,
199 anjay_iid_t iid);
200
216typedef int
218 const anjay_dm_object_def_t *const *obj_ptr,
219 anjay_iid_t iid);
220
239typedef int
241 const anjay_dm_object_def_t *const *obj_ptr,
242 anjay_iid_t iid);
243
262 anjay_t *anjay,
263 const anjay_dm_object_def_t *const *obj_ptr,
264 anjay_iid_t iid,
265 anjay_ssid_t ssid,
267
286 anjay_t *anjay,
287 const anjay_dm_object_def_t *const *obj_ptr,
288 anjay_iid_t iid,
289 anjay_ssid_t ssid,
290 const anjay_dm_oi_attributes_t *attrs);
291
321typedef int
323 const anjay_dm_object_def_t *const *obj_ptr,
324 anjay_iid_t iid,
326
364typedef int
366 const anjay_dm_object_def_t *const *obj_ptr,
367 anjay_iid_t iid,
368 anjay_rid_t rid,
369 anjay_riid_t riid,
370 anjay_output_ctx_t *ctx);
371
399typedef int
401 const anjay_dm_object_def_t *const *obj_ptr,
402 anjay_iid_t iid,
403 anjay_rid_t rid,
404 anjay_riid_t riid,
405 anjay_input_ctx_t *ctx);
406
427typedef int
429 const anjay_dm_object_def_t *const *obj_ptr,
430 anjay_iid_t iid,
431 anjay_rid_t rid,
433
461typedef int
463 const anjay_dm_object_def_t *const *obj_ptr,
464 anjay_iid_t iid,
465 anjay_rid_t rid);
466
503typedef int
505 const anjay_dm_object_def_t *const *obj_ptr,
506 anjay_iid_t iid,
507 anjay_rid_t rid,
509
528typedef int
530 const anjay_dm_object_def_t *const *obj_ptr,
531 anjay_iid_t iid,
532 anjay_rid_t rid,
533 anjay_ssid_t ssid,
535
554typedef int
556 const anjay_dm_object_def_t *const *obj_ptr,
557 anjay_iid_t iid,
558 anjay_rid_t rid,
559 anjay_ssid_t ssid,
560 const anjay_dm_r_attributes_t *attrs);
561
582 anjay_t *anjay,
583 const anjay_dm_object_def_t *const *obj_ptr,
584 anjay_iid_t iid,
585 anjay_rid_t rid,
586 anjay_riid_t riid,
587 anjay_ssid_t ssid,
589
610 anjay_t *anjay,
611 const anjay_dm_object_def_t *const *obj_ptr,
612 anjay_iid_t iid,
613 anjay_rid_t rid,
614 anjay_riid_t riid,
615 anjay_ssid_t ssid,
616 const anjay_dm_r_attributes_t *attrs);
617
646typedef int
648 const anjay_dm_object_def_t *const *obj_ptr);
649
676typedef int
678 const anjay_dm_object_def_t *const *obj_ptr);
679
701typedef int
703 const anjay_dm_object_def_t *const *obj_ptr);
704
712 const anjay_dm_object_def_t *const *obj_ptr);
713
725typedef int
727 const anjay_dm_object_def_t *const *obj_ptr);
728
963
983
1003 anjay_oid_t oid,
1004 anjay_iid_t iid,
1005 anjay_rid_t rid);
1006
1024
1025#ifdef ANJAY_WITH_OBSERVATION_STATUS
1030# ifndef ANJAY_MAX_OBSERVATION_SERVERS_REPORTED_NUMBER
1031# define ANJAY_MAX_OBSERVATION_SERVERS_REPORTED_NUMBER 0
1032# endif // ANJAY_MAX_OBSERVATION_SERVERS_REPORTED_NUMBER
1033
1037typedef struct {
1047 int32_t min_period;
1055# if (ANJAY_MAX_OBSERVATION_SERVERS_REPORTED_NUMBER > 0)
1059 uint16_t servers_number;
1064# endif //(ANJAY_MAX_OBSERVATION_SERVERS_REPORTED_NUMBER > 0)
1066
1114 anjay_t *anjay, anjay_oid_t oid, anjay_iid_t iid, anjay_rid_t rid);
1115#endif // ANJAY_WITH_OBSERVATION_STATUS
1116
1132 const anjay_dm_object_def_t *const *def_ptr);
1133
1155 const anjay_dm_object_def_t *const *def_ptr);
1156
1163bool anjay_binding_mode_valid(const char *binding_mode);
1164
1169typedef enum {
1170 ANJAY_SECURITY_PSK = 0, //< Pre-Shared Key mode
1171 ANJAY_SECURITY_RPK = 1, //< Raw Public Key mode
1172 ANJAY_SECURITY_CERTIFICATE = 2, //< Certificate mode
1173 ANJAY_SECURITY_NOSEC = 3, //< NoSec mode
1174 ANJAY_SECURITY_EST = 4 //< Certificate mode with EST
1176
1177#ifdef ANJAY_WITH_SMS
1182typedef enum {
1183 ANJAY_SMS_SECURITY_DTLS_PSK = 1, //< DTLS in PSK mode
1184 ANJAY_SMS_SECURITY_SECURE_PACKET = 2, //< Secure Packet Structure
1185 ANJAY_SMS_SECURITY_NOSEC = 3 //< NoSec mode
1187#endif // ANJAY_WITH_SMS
1188
1189#define ANJAY_ACCESS_MASK_READ (1U << 0)
1190#define ANJAY_ACCESS_MASK_WRITE (1U << 1)
1191#define ANJAY_ACCESS_MASK_EXECUTE (1U << 2)
1192#define ANJAY_ACCESS_MASK_DELETE (1U << 3)
1193#define ANJAY_ACCESS_MASK_CREATE (1U << 4)
1194// clang-format off
1195#define ANJAY_ACCESS_MASK_FULL \
1196 (ANJAY_ACCESS_MASK_READ \
1197 | ANJAY_ACCESS_MASK_WRITE \
1198 | ANJAY_ACCESS_MASK_DELETE \
1199 | ANJAY_ACCESS_MASK_EXECUTE \
1200 | ANJAY_ACCESS_MASK_CREATE)
1201// clang-format on
1202#define ANJAY_ACCESS_MASK_NONE 0
1203#define ANJAY_ACCESS_LIST_OWNER_BOOTSTRAP UINT16_MAX
1204
1205typedef uint16_t anjay_access_mask_t;
1206
1207#ifdef __cplusplus
1208} /* extern "C" */
1209#endif
1210
1211#endif /*ANJAY_INCLUDE_ANJAY_DM_H*/
uint16_t anjay_oid_t
Definition core.h:1182
uint16_t anjay_rid_t
Definition core.h:1188
uint16_t anjay_iid_t
Definition core.h:1185
struct anjay_struct anjay_t
Definition core.h:45
uint16_t anjay_ssid_t
Definition core.h:31
uint16_t anjay_riid_t
Definition core.h:1191
int anjay_notify_instances_changed(anjay_t *anjay, anjay_oid_t oid)
anjay_sms_security_mode_t
Definition dm.h:1182
@ ANJAY_SMS_SECURITY_NOSEC
Definition dm.h:1185
@ ANJAY_SMS_SECURITY_DTLS_PSK
Definition dm.h:1183
@ ANJAY_SMS_SECURITY_SECURE_PACKET
Definition dm.h:1184
int anjay_notify_changed(anjay_t *anjay, anjay_oid_t oid, anjay_iid_t iid, anjay_rid_t rid)
int anjay_dm_instance_remove_t(anjay_t *anjay, const anjay_dm_object_def_t *const *obj_ptr, anjay_iid_t iid)
Definition dm.h:217
int anjay_register_object(anjay_t *anjay, const anjay_dm_object_def_t *const *def_ptr)
int anjay_dm_transaction_begin_t(anjay_t *anjay, const anjay_dm_object_def_t *const *obj_ptr)
Definition dm.h:647
int anjay_dm_object_write_default_attrs_t(anjay_t *anjay, const anjay_dm_object_def_t *const *obj_ptr, anjay_ssid_t ssid, const anjay_dm_oi_attributes_t *attrs)
Definition dm.h:125
int anjay_dm_resource_write_attrs_t(anjay_t *anjay, const anjay_dm_object_def_t *const *obj_ptr, anjay_iid_t iid, anjay_rid_t rid, anjay_ssid_t ssid, const anjay_dm_r_attributes_t *attrs)
Definition dm.h:555
anjay_resource_observation_status_t anjay_resource_observation_status(anjay_t *anjay, anjay_oid_t oid, anjay_iid_t iid, anjay_rid_t rid)
int anjay_dm_instance_read_default_attrs_t(anjay_t *anjay, const anjay_dm_object_def_t *const *obj_ptr, anjay_iid_t iid, anjay_ssid_t ssid, anjay_dm_oi_attributes_t *out)
Definition dm.h:261
const anjay_dm_r_attributes_t ANJAY_DM_R_ATTRIBUTES_EMPTY
int anjay_dm_instance_create_t(anjay_t *anjay, const anjay_dm_object_def_t *const *obj_ptr, anjay_iid_t iid)
Definition dm.h:240
int anjay_dm_resource_read_attrs_t(anjay_t *anjay, const anjay_dm_object_def_t *const *obj_ptr, anjay_iid_t iid, anjay_rid_t rid, anjay_ssid_t ssid, anjay_dm_r_attributes_t *out)
Definition dm.h:529
int anjay_dm_resource_instance_write_attrs_t(anjay_t *anjay, const anjay_dm_object_def_t *const *obj_ptr, anjay_iid_t iid, anjay_rid_t rid, anjay_riid_t riid, anjay_ssid_t ssid, const anjay_dm_r_attributes_t *attrs)
Definition dm.h:609
int anjay_dm_resource_reset_t(anjay_t *anjay, const anjay_dm_object_def_t *const *obj_ptr, anjay_iid_t iid, anjay_rid_t rid)
Definition dm.h:462
int anjay_unregister_object(anjay_t *anjay, const anjay_dm_object_def_t *const *def_ptr)
int anjay_dm_transaction_validate_t(anjay_t *anjay, const anjay_dm_object_def_t *const *obj_ptr)
Definition dm.h:677
anjay_dm_con_attr_t
Definition dm.h:31
@ ANJAY_DM_CON_ATTR_NON
Definition dm.h:33
@ ANJAY_DM_CON_ATTR_NONE
Definition dm.h:32
@ ANJAY_DM_CON_ATTR_CON
Definition dm.h:34
#define ANJAY_MAX_OBSERVATION_SERVERS_REPORTED_NUMBER
Definition dm.h:1031
bool anjay_binding_mode_valid(const char *binding_mode)
int anjay_dm_resource_instance_read_attrs_t(anjay_t *anjay, const anjay_dm_object_def_t *const *obj_ptr, anjay_iid_t iid, anjay_rid_t rid, anjay_riid_t riid, anjay_ssid_t ssid, anjay_dm_r_attributes_t *out)
Definition dm.h:581
uint16_t anjay_access_mask_t
Definition dm.h:1205
int anjay_dm_object_read_default_attrs_t(anjay_t *anjay, const anjay_dm_object_def_t *const *obj_ptr, anjay_ssid_t ssid, anjay_dm_oi_attributes_t *out)
Definition dm.h:103
int anjay_dm_resource_read_t(anjay_t *anjay, const anjay_dm_object_def_t *const *obj_ptr, anjay_iid_t iid, anjay_rid_t rid, anjay_riid_t riid, anjay_output_ctx_t *ctx)
Definition dm.h:365
int anjay_dm_instance_write_default_attrs_t(anjay_t *anjay, const anjay_dm_object_def_t *const *obj_ptr, anjay_iid_t iid, anjay_ssid_t ssid, const anjay_dm_oi_attributes_t *attrs)
Definition dm.h:285
int anjay_dm_list_instances_t(anjay_t *anjay, const anjay_dm_object_def_t *const *obj_ptr, anjay_dm_list_ctx_t *ctx)
Definition dm.h:163
const anjay_dm_oi_attributes_t ANJAY_DM_OI_ATTRIBUTES_EMPTY
int anjay_dm_transaction_NOOP(anjay_t *anjay, const anjay_dm_object_def_t *const *obj_ptr)
int anjay_dm_instance_reset_t(anjay_t *anjay, const anjay_dm_object_def_t *const *obj_ptr, anjay_iid_t iid)
Definition dm.h:197
int anjay_dm_resource_write_t(anjay_t *anjay, const anjay_dm_object_def_t *const *obj_ptr, anjay_iid_t iid, anjay_rid_t rid, anjay_riid_t riid, anjay_input_ctx_t *ctx)
Definition dm.h:400
int anjay_dm_list_resources_t(anjay_t *anjay, const anjay_dm_object_def_t *const *obj_ptr, anjay_iid_t iid, anjay_dm_resource_list_ctx_t *ctx)
Definition dm.h:322
int anjay_dm_list_resource_instances_t(anjay_t *anjay, const anjay_dm_object_def_t *const *obj_ptr, anjay_iid_t iid, anjay_rid_t rid, anjay_dm_list_ctx_t *ctx)
Definition dm.h:504
int anjay_dm_transaction_commit_t(anjay_t *anjay, const anjay_dm_object_def_t *const *obj_ptr)
Definition dm.h:702
int anjay_dm_transaction_rollback_t(anjay_t *anjay, const anjay_dm_object_def_t *const *obj_ptr)
Definition dm.h:726
int anjay_dm_resource_execute_t(anjay_t *anjay, const anjay_dm_object_def_t *const *obj_ptr, anjay_iid_t iid, anjay_rid_t rid, anjay_execute_ctx_t *ctx)
Definition dm.h:428
anjay_security_mode_t
Definition dm.h:1169
@ ANJAY_SECURITY_RPK
Definition dm.h:1171
@ ANJAY_SECURITY_NOSEC
Definition dm.h:1173
@ ANJAY_SECURITY_EST
Definition dm.h:1174
@ ANJAY_SECURITY_CERTIFICATE
Definition dm.h:1172
@ ANJAY_SECURITY_PSK
Definition dm.h:1170
int anjay_dm_list_instances_SINGLE(anjay_t *anjay, const anjay_dm_object_def_t *const *obj_ptr, anjay_dm_list_ctx_t *ctx)
struct anjay_dm_resource_list_ctx_struct anjay_dm_resource_list_ctx_t
Definition io.h:40
struct anjay_input_ctx_struct anjay_input_ctx_t
Definition io.h:413
struct anjay_dm_list_ctx_struct anjay_dm_list_ctx_t
Definition io.h:22
struct anjay_output_ctx_struct anjay_output_ctx_t
Definition io.h:123
struct anjay_execute_ctx_struct anjay_execute_ctx_t
Definition io.h:417
Definition dm.h:730
anjay_dm_resource_execute_t * resource_execute
Definition dm.h:847
anjay_dm_instance_create_t * instance_create
Definition dm.h:778
anjay_dm_resource_read_t * resource_read
Definition dm.h:829
anjay_dm_list_resource_instances_t * list_resource_instances
Definition dm.h:869
anjay_dm_resource_instance_read_attrs_t * resource_instance_read_attrs
Definition dm.h:948
anjay_dm_resource_reset_t * resource_reset
Definition dm.h:858
anjay_dm_object_write_default_attrs_t * object_write_default_attrs
Definition dm.h:750
anjay_dm_transaction_rollback_t * transaction_rollback
Definition dm.h:935
anjay_dm_transaction_validate_t * transaction_validate
Definition dm.h:912
anjay_dm_object_read_default_attrs_t * object_read_default_attrs
Definition dm.h:739
anjay_dm_instance_write_default_attrs_t * instance_write_default_attrs
Definition dm.h:810
anjay_dm_transaction_commit_t * transaction_commit
Definition dm.h:923
anjay_dm_instance_read_default_attrs_t * instance_read_default_attrs
Definition dm.h:799
anjay_dm_instance_remove_t * instance_remove
Definition dm.h:788
anjay_dm_list_instances_t * list_instances
Definition dm.h:760
anjay_dm_resource_write_t * resource_write
Definition dm.h:838
anjay_dm_resource_read_attrs_t * resource_read_attrs
Definition dm.h:879
anjay_dm_instance_reset_t * instance_reset
Definition dm.h:769
anjay_dm_transaction_begin_t * transaction_begin
Definition dm.h:900
anjay_dm_resource_write_attrs_t * resource_write_attrs
Definition dm.h:889
anjay_dm_resource_instance_write_attrs_t * resource_instance_write_attrs
Definition dm.h:961
anjay_dm_list_resources_t * list_resources
Definition dm.h:820
Definition dm.h:965
anjay_dm_handlers_t handlers
Definition dm.h:981
const char * version
Definition dm.h:978
anjay_oid_t oid
Definition dm.h:967
Definition dm.h:38
int32_t max_period
Definition dm.h:42
anjay_dm_con_attr_t con
Definition dm.h:49
int32_t min_period
Definition dm.h:40
int32_t max_eval_period
Definition dm.h:46
int32_t min_eval_period
Definition dm.h:44
Definition dm.h:54
double step
Definition dm.h:62
double less_than
Definition dm.h:60
double greater_than
Definition dm.h:58
anjay_dm_oi_attributes_t common
Definition dm.h:56
int32_t min_period
Definition dm.h:1047
bool is_observed
Definition dm.h:1041
int32_t max_eval_period
Definition dm.h:1054