Newer
Older
# Third party data model integration
It is also possible to itegrate thrid party data model to the uspd to expose it to the ubus. To do so certain APIs in data model library needs to be implemented to make the data model compatible with uspd. APIs are described below.
## List of libbbf methods used in uspd to integrate third party data model
Deatils of bbf data model librabry can be found at [link](https://dev.iopsys.eu/iopsys/bbf/-/tree/devel/docs)
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
following are the libbbf methods used in uspd to access the data model defined in libbbf
``` dm_get_supported_dm
dm_entry_param_method
dm_entry_apply
dm_ctx_init
dm_ctx_init_sub
dm_ctx_clean
dm_ctx_clean_sub
set_bbfdatamodel_type
dm_entry_restart_services
dm_entry_revert_changes
dm_debug_browse_path
get_dm_type
dm_entry_manage_services
dm_config_ubus
```
## Methods
Description of the methods are given below
### dm_get_supported_dm
used to get the complete data model schema in one browse
```
int dm_get_supported_dm(struct dmctx *ctx, char *path, bool first_level, schema_type_t schema_type)
inputs
struct dmctx *ctx
pointer to struct dmctx strunture. The list of parameters will be updated in ctx.list_parameter. each node in the list is of type
struct dm_parameter which contains char *name (name of the parameter), char *data, char *type and char *additional_data;
the content of fields are as follows-
| Type | Data | Addtional Data |
|------------- |------------ |--------------------- |
|DMT_COMMAND |in parameters |command type(sync/async) |
| |out parameter | |
|DMT_EVENT |in parameters |NA |
|$ref(type) |writable(0/1) |unique keys |
| | | |
char * path
Complete object element path for which the data model schema is to be read. default path is "Device."
bool first_level
if true, read only paramters at next level to path
schem_type_t schema_type
enumeration to type of the schema to be get. Possible values are
ALL_SCHEMA - Complete schema
PARAM_ONLY - Parameters only
EVENT_ONLY - Events only
COMMAND_ONLY - Commands only
return
int fault
contains the fault code if API is not able to read the data model.
```
### dm_entry_param_method
used to read the data model based on the input given
```
int dm_entry_param_method(struct dmctx *ctx, int cmd, char *inparam, char *arg1, char *arg2)
inputs
struct dmctx *ctx
pointer to struct dmctx strunture. The list of parameter will be updated in ctx.list_parameter. each node in the list is of type
struct dm_parameter which contains char *name, char *data, char *type and char *additional_data;
the content of fields are updated based on the cmd and are as follows-
cmd | Name | Type | Data | Addtional Data |
|------------- |------------- |------------- |------------ |--------------------- |
|CMD_GET_VALUE |Parameter |$ref(type) |Value | NA |
|CMD_GET_NAME |Parameter |$ref(type) |writable(0/1) | NA |
|CMD_SET_VALUE |path | NA | NA | NA |
|CMD_ADD_OBJECT |path | NA | NA | NA |
|CMD_DEL_OBJECT |path | NA | NA | NA |
|CMD_USP_OPERATE |path | NA | NA | NA |
|CMD_USP_LIST_OPERATE |parameter |DMT_COMMAND |in/out parameters |cmd type (sync/async) |
|CMD_USP_LIST_EVENT |paramter |DMT_EVENT |in parameters |NA |
|CMD_GET_SCHEMA |paramter ||$ref(type) |writable(0/1) |unique keys |
|CMD_GET_INSTANCES |parameter | NA |NA |NA |
int cmd
command to API to tell how the data model is to be read, possible values are
CMD_GET_VALUE - Read the values of the parameters from data model
CMD_GET_NAME - Read the names of the parameters from data model
CMD_SET_VALUE - Set value of specified parameters in the data model
CMD_ADD_OBJECT - Add object in a multi instance parameter in the data model
CMD_DEL_OBJECT - Delete object from a multi instance parameter in the data model
CMD_USP_OPERATE - execute the specified command
CMD_USP_LIST_OPERATE - Read all the command type parameter from data model.
CMD_USP_LIST_EVENT - Read all the event type parameter from data model.
CMD_GET_SCHEMA - Read all the parameter type parameter from data model.
CMD_GET_INSTANCES - Read all the instance of multi instance parameter from data model.
char * inparam
Complete object element path for which the data model schema is to be read. default path is "Device."
char *arg1 and char *arg2
arguments specific to commands.
return
int fault
contains the fault code if API is not able to read the data model. returns 0 on success.
```
### dm_entry_apply
This method is called to apply the changes done to data model. used with set_value
```
int dm_entry_apply(struct dmctx *ctx, int cmd)
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
inputs
struct dmctx *ctx
pointer to struct dmctx strunture. The list of parameter will be updated in ctx.list_parameter
int cmd
command to API to tell how the data model is to be read, possible values are
CMD_SET_VALUE - Set value of specified parameters in the data model
char *arg1
return
int fault
contains the fault code if API is not able to read the data model.
```
### dm_ctx_init
This method is used to initialize the dmctx structure object to read the data model.
```
int dm_ctx_init(struct dmctx *ctx, unsigned int instance_mode)
inputs
struct dmctx *ctx
pointer to struct dmctx strunture to be initialized.
unsigned int instance_mode
instance mode of the dmctx to be set.
return
int fault
returns 0 on success.
```
### dm_ctx_init_sub
This method is an extension of dm_ctx_init method. only difference it only intializes dmctx structure object and does not intializes other resources used in reading data model
```
int dm_ctx_init_sub(struct dmctx *ctx, unsigned int instance_mode)
inputs
struct dmctx *ctx
pointer to struct dmctx strunture to be initialized.
unsigned int instance_mode
instance mode of the dmctx to be set.
return
int fault
returns 0 on success.
```
### dm_ctx_clean
This method is used to free the dmctx structure object and other resources post reading the data model.
```
int dm_ctx_clean(struct dmctx *ctx)
input
struct dmctx *ctx
pointer to struct dmctx strunture to be freed.
return
int fault
returns 0 on success.
```
### dm_ctx_clean_sub
This method is an extension of dm_ctx_clean method. only difference is it frees the dmctx structure and does not free other resources used in reading data model
```
int dm_ctx_clean_sub(struct dmctx *ctx)
input
struct dmctx *ctx
pointer to struct dmctx strunture to be freed.
return
int fault
returns 0 on success.
```
### set_bbfdatamodel_type
This method is used to set the type of protocol for which the data model is to be read
```
int set_bbfdatamodel_type(int bbf_type)
input
int cmd
the protocol through which the data model is to be read, possible values are
BBFDM_USP - Protocol USP
BBFDM_CWMP - Protocol CWMP
BBFDM_BOTH - Both USP and CWMP
return
int
returns 0 on success.
```
### dm_entry_restart_services
This method is used to restart the state of data model whenever its state is changed
```
int dm_entry_restart_services(void)
input
None
return
int
returns 0 on success.
```
### dm_entry_revert_changes
This method is used to restart the state of data model whenever its state is changed
```
int dm_entry_revert_changes(void)
input
None
return
int
returns 0 on success.
```
### dm_debug_browse_path
This method returns the last accessed path in the data model
```
int dm_debug_browse_path(char *buff, size_t len)
input
char *buff
pointer to the buffer in which the path will be returned
size_t len
length of the buffer
return
int
returns 0 on success.
```
### get_dm_type
This method is used to get the type assigned to the data model parameter.
```
int get_dm_type(char *dm_str)
input
char *dm_str
data model parameter type, eg. xsd:string, xsd:unit etc.
return
int
type of data model assigned to the object eg. DMT_STRING, DMT_UNINT etc.
```
### dm_entry_manage_services
This method is used to commit the changes made to the data model using either ubus call or uci commit.
```
int dm_entry_manage_services(struct blob_buf *bb, bool restart)
input
struct blob_buf *bb
pointer to the struct blob_buf object. contains all the packages updated.
bool restart
if true packages will be updated through ubus call.
if false packages will be updated through uci.
return
int - returns 0 on success.
```
### dm_entry_restart_services
this method is used to commit all the changes made to the data model.
```
int dm_entry_restart_services(void)
return
int - returns 0 on success.
```
### dm_config_ubus
This method is used to configure ubus.
```
void dm_config_ubus(struct ubus_context *ctx)
input
struct ubus_context *ctx
pointer to struct ubus_context object to be intialized.