400f606b53cfc23d0dfcedc52fc2b949e8230918
[platform/core/api/thread.git] / include / thread.h
1 /*
2  * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17
18 #ifndef __TIZEN_NETWORK_THREAD_H__
19 #define __TIZEN_NETWORK_THREAD_H__
20
21 #include <stdlib.h>
22 #include <unistd.h>
23 #include <stdbool.h>
24 #include <tizen_error.h>
25 #include <tizen.h>
26
27 #include <thread-type.h>
28
29 #ifndef TIZEN_DEPRECATED_API
30 #define TIZEN_DEPRECATED_API __attribute__((__visibility__("default"), deprecated))
31 #endif
32
33 #ifdef __cplusplus
34 extern "C"
35 {
36 #endif /* __cplusplus */
37
38 /**
39  * @file        thread.h
40  * @brief       API to control the Thread adapter and devices and communications.
41  * @ingroup     CAPI_NETWORK_THREAD_MODULE
42  */
43
44
45 /**
46  * @ingroup CAPI_NETWORK_THREAD_MODULE
47  * @brief Initializes the thread API.
48  * @since_tizen 7.0
49  *
50  * @remarks This function must be called before thread API starts. \n
51  *
52  * @return 0 on success, otherwise a negative error value.
53  * @retval #THREAD_ERROR_NONE  Successful
54  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
55  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
56  *
57  * @see  thread_deinitialize()
58  */
59 int thread_initialize(void);
60
61 /**
62  * @ingroup CAPI_NETWORK_THREAD_MODULE
63  * @brief Releases all resources of the thread API.
64  * @since_tizen 7.0
65  *
66  * @remarks This function must be called if thread API is no longer needed.
67  *
68  * @return 0 on success, otherwise a negative error value.
69  * @retval #THREAD_ERROR_NONE  Successful
70  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
71  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
72  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
73  *
74  * @pre thread API must be initialized with thread_initialize().
75  *
76  * @see thread_initialize()
77  */
78 int thread_deinitialize(void);
79
80 /**
81  * @ingroup CAPI_NETWORK_THREAD_MODULE
82  * @brief Enable thread Module
83  * @since_tizen 7.0
84  *
85  * @return 0 on success, otherwise a negative error value.
86  * @retval #THREAD_ERROR_NONE  Successful
87  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
88  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
89  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
90  *
91  * @pre thread API must be initialized with thread_initialize().
92  *
93  * @see thread_initialize()
94  */
95 int thread_enable(thread_instance_h *instance);
96
97 /**
98  * @ingroup CAPI_NETWORK_THREAD_MODULE
99  * @brief Disable thread Module
100  * @since_tizen 7.0
101  *
102  * @return 0 on success, otherwise a negative error value.
103  * @retval #THREAD_ERROR_NONE  Successful
104  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
105  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
106  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
107  *
108  * @pre thread API must be initialized with thread_initialize().
109  *
110  * @see thread_enable()
111  */
112 int thread_disable(thread_instance_h instance);
113
114 /**
115  * @ingroup CAPI_NETWORK_THREAD_MODULE
116  * @brief Start Thread
117  * @since_tizen 7.0
118  *
119  * @return 0 on success, otherwise a negative error value.
120  * @retval #THREAD_ERROR_NONE  Successful
121  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
122  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
123  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
124  *
125  * @pre thread API must be initialized with thread_initialize().
126  * @see thread_stop()
127  */
128 int thread_start(thread_instance_h instance);
129
130 /**
131  * @ingroup CAPI_NETWORK_THREAD_MODULE
132  * @brief Stop Thread
133  * @since_tizen 7.0
134  *
135  * @return 0 on success, otherwise a negative error value.
136  * @retval #THREAD_ERROR_NONE  Successful
137  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
138  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
139  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
140  *
141  * @pre thread API must be initialized with thread_initialize().
142  * @see thread_start()
143  */
144 int thread_stop(thread_instance_h instance);
145
146 /**
147  * @ingroup CAPI_NETWORK_THREAD_MODULE
148  * @brief Perform reset of OT hardware, tries to resume the network after reset
149  * @since_tizen 7.0
150  *
151  * @return 0 on success, otherwise a negative error value.
152  * @retval #THREAD_ERROR_NONE  Successful
153  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
154  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
155  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
156  *
157  * @pre thread API must be initialized with thread_initialize().
158  *
159  * @see thread_enable()
160  */
161 int thread_reset(thread_instance_h instance);
162
163 /**
164  * @ingroup CAPI_NETWORK_THREAD_MODULE
165  * @brief Perform Factory reset of OT hardware, wipes all Thread persistent data
166  * @since_tizen 7.0
167  *
168  * @return 0 on success, otherwise a negative error value.
169  * @retval #THREAD_ERROR_NONE  Successful
170  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
171  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
172  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
173  *
174  * @pre thread API must be initialized with thread_initialize().
175  *
176  * @see thread_enable()
177  */
178 int thread_factoryreset(thread_instance_h instance);
179
180 /**
181  * @ingroup CAPI_NETWORK_THREAD_MODULE
182  * @brief Get Thread Device Role
183  * @since_tizen 7.0
184  *
185  * @return 0 on success, otherwise a negative error value.
186  * @retval #THREAD_ERROR_NONE  Successful
187  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
188  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
189  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
190  *
191  * @pre thread API must be initialized with thread_initialize().
192  */
193 int thread_get_device_role(thread_instance_h instance, thread_device_role_e *device_role);
194
195 /**
196  * @ingroup CAPI_NETWORK_THREAD_MODULE
197  * @brief Set Thread Device Role changed callback
198  * @since_tizen 7.0
199  *
200  * @return 0 on success, otherwise a negative error value.
201  * @retval #THREAD_ERROR_NONE  Successful
202  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
203  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
204  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
205  *
206  * @pre thread API must be initialized with thread_initialize().
207  */
208 int thread_set_device_role_changed_cb(thread_instance_h instance,
209                 thread_device_role_cb callback, void *user_data);
210
211 /**
212  * @ingroup CAPI_NETWORK_THREAD_MODULE
213  * @brief Set Thread Device Type
214  * @since_tizen 7.0
215  *
216  * @return 0 on success, otherwise a negative error value.
217  * @retval #THREAD_ERROR_NONE  Successful
218  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
219  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
220  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
221  *
222  * @pre thread API must be initialized with thread_initialize().
223  */
224 int thread_set_device_type(thread_instance_h instance, thread_device_type_e device_type);
225
226 /**
227  * @ingroup CAPI_NETWORK_THREAD_MODULE
228  * @brief Get Thread Device Type
229  * @since_tizen 7.0
230  *
231  * @return 0 on success, otherwise a negative error value.
232  * @retval #THREAD_ERROR_NONE  Successful
233  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
234  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
235  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
236  *
237  * @pre thread API must be initialized with thread_initialize().
238  */
239 int thread_get_device_type(thread_instance_h instance, thread_device_type_e *device_type);
240
241 /**
242  * @ingroup CAPI_NETWORK_THREAD_MODULE
243  * @brief Create Thread Network Scan param
244  * @since_tizen 7.0
245  *
246  * @return 0 on success, otherwise a negative error value.
247  * @retval #THREAD_ERROR_NONE  Successful
248  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
249  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
250  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
251  *
252  * @pre thread API must be initialized with thread_initialize().
253  *
254  * @see thread_network_scan_result_cb()
255  */
256 int thread_scan_param_create(thread_instance_h instance,
257         uint16_t duration, thread_scan_param_h *param_handle);
258
259 /**
260  * @ingroup CAPI_NETWORK_THREAD_MODULE
261  * @brief Destroys Thread Network Scan param
262  * @since_tizen 7.0
263  *
264  * @return 0 on success, otherwise a negative error value.
265  * @retval #THREAD_ERROR_NONE  Successful
266  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
267  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
268  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
269  *
270  * @pre thread API must be initialized with thread_initialize().
271  *
272  * @see thread_network_scan_result_cb()
273  */
274 int thread_scan_param_destroy(thread_instance_h instance,
275         thread_scan_param_h param_handle);
276
277 /**
278  * @ingroup CAPI_NETWORK_THREAD_MODULE
279  * @brief Scan Thread Network
280  * @since_tizen 7.0
281  *
282  * @return 0 on success, otherwise a negative error value.
283  * @retval #THREAD_ERROR_NONE  Successful
284  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
285  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
286  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
287  *
288  * @pre thread API must be initialized with thread_initialize().
289  *
290  * @see thread_network_scan_result_cb()
291  */
292 int thread_scan(thread_instance_h instance, thread_scan_param_h handle,
293         thread_network_scan_result_cb callback, void *user_data);
294
295 /**
296  * @ingroup CAPI_NETWORK_THREAD_MODULE
297  * @brief Gets the extended address
298  * @since_tizen 7.0
299  *
300  * @return 0 on success, otherwise a negative error value.
301  * @retval #THREAD_ERROR_NONE  Successful
302  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
303  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
304  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
305  *
306  * @pre thread API must be initialized with thread_initialize().
307  */
308 int thread_get_extended_address(thread_instance_h instance, uint64_t *extended_address);
309
310 /**
311  * @ingroup CAPI_NETWORK_THREAD_MODULE
312  * @brief Gets the extended uuid(EUI-64) of the Thread Device
313  * @since_tizen 7.0
314  *
315  * @return 0 on success, otherwise a negative error value.
316  * @retval #THREAD_ERROR_NONE  Successful
317  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
318  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
319  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
320  *
321  * @pre thread API must be initialized with thread_initialize().
322  */
323 int thread_get_extended_uuid(thread_instance_h instance, const char **uuid);
324
325 /**
326  * @ingroup CAPI_NETWORK_THREAD_MODULE
327  * @brief Set Active operational Network dataset
328  * @since_tizen 7.0
329  *
330  * @return 0 on success, otherwise a negative error value.
331  * @retval #THREAD_ERROR_NONE  Successful
332  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
333  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
334  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
335  *
336  * @pre thread API must be initialized with thread_initialize().
337  *
338  * @see thread_active_dataset_tlvs_s
339  */
340 int thread_network_set_active_dataset_tlvs(thread_instance_h instance,
341         const uint8_t *tlvs_buffer, int length);
342
343 /**
344  * @ingroup CAPI_NETWORK_THREAD_MODULE
345  * @brief Get Active operational Network dataset
346  * @since_tizen 7.0
347  *
348  * @return 0 on success, otherwise a negative error value.
349  * @retval #THREAD_ERROR_NONE  Successful
350  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
351  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
352  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
353  *
354  * @remarks copy the data returned by buffer. It will go out of scope after API returns
355  *
356  * @pre thread API must be initialized with thread_initialize().
357  *
358  * @see thread_active_dataset_tlvs_s
359  * @see thread_set_active_dataset_tlvs()
360  */
361 int thread_network_get_active_dataset_tlvs(thread_instance_h instance,
362         uint8_t **tlvs_buffer, int *buf_len);
363
364 /**
365  * @ingroup CAPI_NETWORK_THREAD_MODULE
366  * @brief Get the PanId from Operational Network
367  * @since_tizen 7.0
368  *
369  * @param[out] panid The PanId
370  *
371  * @return 0 on success, otherwise a negative error value.
372  * @retval #THREAD_ERROR_NONE  Successful
373  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
374  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
375  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
376  *
377  * @pre thread API must be initialized with thread_initialize().
378  * @pre Active Operational Dataset must be set using thread_set_active_dataset_tlvs().
379  *
380  * @see thread_network_create()
381  * @see thread_set_operational_network()
382  * @see thread_set_active_dataset_tlvs()
383  */
384 int thread_network_get_panid(thread_instance_h instance, uint16_t *panid);
385
386 /**
387  * @ingroup CAPI_NETWORK_THREAD_MODULE
388  * @brief Attach the OT hardware to the active Operational Network, which is pre-set
389  * @since_tizen 7.0
390  *
391  * @return 0 on success, otherwise a negative error value.
392  * @retval #THREAD_ERROR_NONE  Successful
393  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
394  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
395  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
396  *
397  * @pre thread API must be initialized with thread_initialize().
398  * @pre Active Operational Dataset must be set using thread_set_active_dataset_tlvs().
399  *
400  * @see thread_set_active_dataset_tlvs()
401  */
402 int thread_network_attach(thread_instance_h instance);
403
404 /**
405  * @ingroup CAPI_NETWORK_THREAD_MODULE
406  * @brief Detach the OT hardware from the active Operational Network
407  * @since_tizen 7.0
408  *
409  * @return 0 on success, otherwise a negative error value.
410  * @retval #THREAD_ERROR_NONE  Successful
411  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
412  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
413  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
414  *
415  * @pre thread API must be initialized with thread_initialize().
416  * @pre Active Operational Dataset must be attached.
417  *
418  * @see thread_network_attach()
419  */
420 int thread_network_detach(thread_instance_h instance);
421
422 /**
423  * @ingroup CAPI_NETWORK_THREAD_BORDERROUTER_MODULE
424  * @brief Enable OT Border Routing
425  * @since_tizen 7.0
426  *
427  * @return 0 on success, otherwise a negative error value.
428  * @retval #THREAD_ERROR_NONE  Successful
429  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
430  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
431  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
432  *
433  * @pre thread API must be initialized with thread_initialize().
434  *
435  * @see thread_br_disable()
436  */
437 int thread_br_enable(thread_instance_h instance);
438
439 /**
440  * @ingroup CAPI_NETWORK_THREAD_BORDERROUTER_MODULE
441  * @brief Disable OT Border Routing
442  * @since_tizen 7.0
443  *
444  * @return 0 on success, otherwise a negative error value.
445  * @retval #THREAD_ERROR_NONE  Successful
446  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
447  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
448  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
449  *
450  * @pre thread API must be initialized with thread_initialize().
451  *
452  * @see thread_br_enable()
453  */
454 int thread_br_disable(thread_instance_h instance);
455
456 /**
457  * @ingroup CAPI_NETWORK_THREAD_BORDERROUTER_MODULE
458  * @brief Get All External Route informations
459  * @since_tizen 7.0
460  *
461  * @return 0 on success, otherwise a negative error value.
462  * @retval #THREAD_ERROR_NONE  Successful
463  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
464  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
465  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
466  *
467  * @pre thread API must be initialized with thread_initialize().
468  *
469  * @see thread_external_route_foreach_cb()
470  */
471 int thread_br_get_external_routes(thread_instance_h instance,
472         thread_external_route_foreach_cb callback, void *user_data);
473
474 /**
475  * @ingroup CAPI_NETWORK_THREAD_BORDERROUTER_MODULE
476  * @brief Get Route informations
477  * @since_tizen 7.0
478  *
479  * @return 0 on success, otherwise a negative error value.
480  * @retval #THREAD_ERROR_NONE  Successful
481  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
482  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
483  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
484  *
485  * @pre thread API must be initialized with thread_initialize().
486  *
487  * @see thread_external_route_foreach_cb()
488  */
489 int thread_br_get_route_info(thread_route_info_h route, uint8_t *ipv6_prefix,
490         uint8_t *ipv6_prefix_len, uint16_t *rloc16, int8_t *preference,
491         bool *is_stable, bool *is_device_nexthop);
492
493 /**
494  * @ingroup CAPI_NETWORK_THREAD_BORDERROUTER_MODULE
495  * @brief Add an external border routing rule to the network.
496  * @since_tizen 7.0
497  *
498  * @return 0 on success, otherwise a negative error value.
499  * @retval #THREAD_ERROR_NONE  Successful
500  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
501  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
502  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
503  *
504  * @pre thread API must be initialized with thread_initialize().
505  *
506  * @see thread_remove_external_route()
507  */
508 int thread_br_add_external_route(thread_instance_h instance,
509         const uint8_t *ipv6_prefix, uint8_t ipv6_prefix_len,
510         uint16_t rloc16, int8_t preference,
511         bool is_stable, bool is_device_nexthop,
512         thread_route_info_h *route_handle);
513
514 /**
515  * @ingroup CAPI_NETWORK_THREAD_BORDERROUTER_MODULE
516  * @brief Remove an external border routing rule from the network
517  * @since_tizen 7.0
518  *
519  * @return 0 on success, otherwise a negative error value.
520  * @retval #THREAD_ERROR_NONE  Successful
521  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
522  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
523  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
524  *
525  * @pre thread API must be initialized with thread_initialize().
526  *
527  * @see thread_add_external_route()
528  */
529 int thread_br_remove_external_route(thread_instance_h instance, thread_route_info_h route_handle);
530
531 /**
532  * @ingroup CAPI_NETWORK_THREAD_BORDERROUTER_MODULE
533  * @brief Add an on-mesh prefix to the network
534  * @since_tizen 7.0
535  *
536  * @return 0 on success, otherwise a negative error value.
537  * @retval #THREAD_ERROR_NONE  Successful
538  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
539  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
540  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
541  *
542  * @pre thread API must be initialized with thread_initialize().
543  *
544  * @see thread_remove_onmesh_prefix()
545  */
546 int thread_br_add_onmesh_prefix(thread_instance_h instance,
547         const uint8_t *ipv6_prefix, int ipv6_prefix_len, int8_t preference,
548         bool preferred, bool slaac, bool dhcp, bool configure, bool default_route,
549         bool on_mesh, bool stable, thread_onmesh_prefix_info_h *onmesh_prefix);
550
551 /**
552  * @ingroup CAPI_NETWORK_THREAD_BORDERROUTER_MODULE
553  * @brief Remove on-mesh prefix from the network
554  * @since_tizen 7.0
555  *
556  * @return 0 on success, otherwise a negative error value.
557  * @retval #THREAD_ERROR_NONE  Successful
558  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
559  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
560  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
561  *
562  * @pre thread API must be initialized with thread_initialize().
563  *
564  * @see thread_add_onmesh_prefix()
565  */
566 int thread_br_remove_onmesh_prefix(thread_instance_h instance, thread_onmesh_prefix_info_h prefix_info);
567
568 /**
569  * @ingroup CAPI_NETWORK_THREAD_NETWORK_MODULE
570  * @brief Create thread network
571  * @since_tizen 7.0
572  *
573  * @return 0 on success, otherwise a negative error value.
574  * @retval #THREAD_ERROR_NONE  Successful
575  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
576  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
577  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
578  *
579  * @pre thread API must be initialized with thread_initialize().
580  */
581 int thread_network_create(thread_network_h *network);
582
583 /**
584  * @ingroup CAPI_NETWORK_THREAD_NETWORK_MODULE
585  * @brief Destroy thread network
586  * @since_tizen 7.0
587  *
588  * @return 0 on success, otherwise a negative error value.
589  * @retval #THREAD_ERROR_NONE  Successful
590  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
591  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
592  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
593  *
594  * @pre thread API must be initialized with thread_initialize().
595  */
596 int thread_network_destroy(thread_network_h network);
597
598 /**
599  * @ingroup CAPI_NETWORK_THREAD_NETWORK_MODULE
600  * @brief Set the thread network name
601  * @since_tizen 7.0
602  *
603  * @return 0 on success, otherwise a negative error value.
604  * @retval #THREAD_ERROR_NONE  Successful
605  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
606  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
607  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
608  *
609  * @pre thread API must be initialized with thread_initialize().
610  */
611 int thread_network_set_name(thread_network_h network, const char *name);
612
613 /**
614  * @ingroup CAPI_NETWORK_THREAD_NETWORK_MODULE
615  * @brief Set the thread network key
616  * @since_tizen 7.0
617  *
618  * @return 0 on success, otherwise a negative error value.
619  * @retval #THREAD_ERROR_NONE  Successful
620  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
621  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
622  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
623  *
624  * @pre thread API must be initialized with thread_initialize().
625  */
626 int thread_network_set_key(thread_network_h network, const char *key);
627
628 /**
629  * @ingroup CAPI_NETWORK_THREAD_NETWORK_MODULE
630  * @brief Set the thread network pskc
631  * @since_tizen 7.0
632  *
633  * @return 0 on success, otherwise a negative error value.
634  * @retval #THREAD_ERROR_NONE  Successful
635  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
636  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
637  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
638  *
639  * @pre thread API must be initialized with thread_initialize().
640  */
641 int thread_network_set_pskc(thread_network_h network, const char *pskc);
642
643 /**
644  * @ingroup CAPI_NETWORK_THREAD_NETWORK_MODULE
645  * @brief Set the thread network channel
646  * @since_tizen 7.0
647  *
648  * @return 0 on success, otherwise a negative error value.
649  * @retval #THREAD_ERROR_NONE  Successful
650  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
651  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
652  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
653  *
654  * @pre thread API must be initialized with thread_initialize().
655  */
656 int thread_network_set_channel(thread_network_h network, uint32_t channel);
657
658 /**
659  * @ingroup CAPI_NETWORK_THREAD_NETWORK_MODULE
660  * @brief Set the thread network extended pan id
661  * @since_tizen 7.0
662  *
663  * @return 0 on success, otherwise a negative error value.
664  * @retval #THREAD_ERROR_NONE  Successful
665  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
666  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
667  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
668  *
669  * @pre thread API must be initialized with thread_initialize().
670  */
671 int thread_network_set_extended_panid(thread_network_h network, uint64_t extended_panid);
672
673 /**
674  * @ingroup CAPI_NETWORK_THREAD_NETWORK_MODULE
675  * @brief Set the thread network pan id
676  * @since_tizen 7.0
677  *
678  * @return 0 on success, otherwise a negative error value.
679  * @retval #THREAD_ERROR_NONE  Successful
680  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
681  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
682  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
683  *
684  * @pre thread API must be initialized with thread_initialize().
685  */
686 int thread_network_set_panid(thread_network_h network, uint16_t panid);
687
688 /**
689  * @ingroup CAPI_NETWORK_THREAD_NETWORK_MODULE
690  * @brief Set the thread network to instance
691  * @since_tizen 7.0
692  *
693  * @return 0 on success, otherwise a negative error value.
694  * @retval #THREAD_ERROR_NONE  Successful
695  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
696  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
697  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
698  *
699  * @pre thread API must be initialized with thread_initialize().
700  */
701 int thread_set_operational_network(thread_instance_h instance, thread_network_h network);
702
703 /**
704  * @ingroup CAPI_NETWORK_THREAD_NETWORK_MODULE
705  * @brief Unset the thread network from instance
706  * @since_tizen 7.0
707  *
708  * @return 0 on success, otherwise a negative error value.
709  * @retval #THREAD_ERROR_NONE  Successful
710  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
711  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
712  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
713  *
714  * @pre thread API must be initialized with thread_initialize().
715  */
716 int thread_unset_operational_network(thread_instance_h instance);
717
718 /**
719  * @ingroup CAPI_NETWORK_THREAD_JOINER_MODULE
720  * @brief Start Thread joining with detailed informations
721  * @since_tizen 7.0
722  *
723  * @return 0 on success, otherwise a negative error value.
724  * @retval #THREAD_ERROR_NONE  Successful
725  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
726  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
727  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
728  *
729  * @pre thread API must be initialized with thread_initialize().
730  * @see thread_joiner_stop()
731  */
732 int thread_joiner_start(thread_instance_h instance,
733         const char *pskd, const char *prov_url,
734         const char *vendor_name, const char *vendor_model,
735         const char *vendor_sw_ver, const char *vendor_data,
736         thread_joiner_result_cb callback, void *user_data);
737
738 /**
739  * @ingroup CAPI_NETWORK_THREAD_JOINER_MODULE
740  * @brief Stop Thread Joining
741  * @since_tizen 7.0
742  *
743  * @return 0 on success, otherwise a negative error value.
744  * @retval #THREAD_ERROR_NONE  Successful
745  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
746  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
747  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
748  *
749  * @pre thread API must be initialized with thread_initialize().
750  * @see thread_joiner_start()
751  */
752 int thread_joiner_stop(thread_instance_h instance);
753
754 /**
755  * @ingroup CAPI_NETWORK_THREAD_JOINER_MODULE
756  * @brief Join Thread Network by Network key (Out-Of-Band Commisioning)
757  * network key must be obtained by the commissioner via any trusted Out-Of-Band method
758  * @since_tizen 7.0
759  *
760  * @return 0 on success, otherwise a negative error value.
761  * @retval #THREAD_ERROR_NONE  Successful
762  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
763  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
764  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
765  *
766  * @pre thread API must be initialized with thread_initialize().
767  */
768 int thread_joiner_join_by_network_key(thread_instance_h instance, const char *network_key, const char *panid);
769
770 /**
771  * @ingroup CAPI_NETWORK_THREAD_COMMISSIONER_MODULE
772  * @brief Start thread commissioner (In-Band Commissioning)
773  * @since_tizen 7.0
774  *
775  * @return 0 on success, otherwise a negative error value.
776  * @retval #THREAD_ERROR_NONE  Successful
777  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
778  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
779  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
780  *
781  * @pre thread API must be initialized with thread_initialize().
782  */
783 int thread_commissioner_start(thread_instance_h instance);
784
785 /**
786  * @ingroup CAPI_NETWORK_THREAD_COMMISSIONER_MODULE
787  * @brief Set commissioning Data (In-Band Commissioning)
788  * @since_tizen 7.0
789  *
790  * @return 0 on success, otherwise a negative error value.
791  * @retval #THREAD_ERROR_NONE  Successful
792  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
793  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
794  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
795  *
796  * @pre thread API must be initialized with thread_initialize().
797  */
798 int thread_commissioner_set_commissioning_data(thread_instance_h instance, const char *joiner_uuid,
799         const char *joiner_passphrase);
800
801 /**
802  * @ingroup CAPI_NETWORK_THREAD_SRP_MODULE
803  * @brief Start SRP Client
804  * @since_tizen 7.0
805  *
806  * @return 0 on success, otherwise a negative error value.
807  * @retval #THREAD_ERROR_NONE  Successful
808  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
809  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
810  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
811  *
812  * @pre thread API must be initialized with thread_initialize().
813  * @see thread_srp_client_stop()
814  */
815 int thread_srp_client_start(thread_instance_h instance);
816
817 /**
818  * @ingroup CAPI_NETWORK_THREAD_SRP_MODULE
819  * @brief Stop SRP Client
820  * @since_tizen 7.0
821  *
822  * @return 0 on success, otherwise a negative error value.
823  * @retval #THREAD_ERROR_NONE  Successful
824  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
825  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
826  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
827  *
828  * @pre thread API must be initialized with thread_initialize().
829  * @see thread_srp_client_start()
830  */
831 int thread_srp_client_stop(thread_instance_h instance);
832
833 /**
834  * @ingroup CAPI_NETWORK_THREAD_SRP_MODULE
835  * @brief Remove already registered SRP host service
836  * @since_tizen 7.0
837  *
838  * @return 0 on success, otherwise a negative error value.
839  * @retval #THREAD_ERROR_NONE  Successful
840  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
841  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
842  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
843  *
844  * @pre thread API must be initialized with thread_initialize().
845  * @see thread_srp_client_start()
846  */
847 int thread_srp_client_remove_host(thread_instance_h instance);
848
849 /**
850  * @ingroup CAPI_NETWORK_THREAD_SRP_MODULE
851  * @brief Set Host name
852  * @since_tizen 7.0
853  *
854  * @return 0 on success, otherwise a negative error value.
855  * @retval #THREAD_ERROR_NONE  Successful
856  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
857  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
858  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
859  *
860  * @pre thread API must be initialized with thread_initialize().
861  * @see thread_srp_client_start()
862  */
863 int thread_srp_client_set_host_name(thread_instance_h instance, const char *host_name);
864
865 /**
866  * @ingroup CAPI_NETWORK_THREAD_SRP_MODULE
867  * @brief Set Host address
868  * @since_tizen 7.0
869  *
870  * @return 0 on success, otherwise a negative error value.
871  * @retval #THREAD_ERROR_NONE  Successful
872  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
873  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
874  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
875  *
876  * @pre thread API must be initialized with thread_initialize().
877  * @see thread_srp_client_start()
878  */
879 int thread_srp_client_set_host_address(thread_instance_h instance, const char *ipv6_address);
880
881 /**
882  * @ingroup CAPI_NETWORK_THREAD_SRP_MODULE
883  * @brief Register Service to SRP server
884  * @since_tizen 7.0
885  *
886  * @return 0 on success, otherwise a negative error value.
887  * @retval #THREAD_ERROR_NONE  Successful
888  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
889  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
890  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
891  *
892  * @pre thread API must be initialized with thread_initialize().
893  * @see thread_srp_client_start()
894  * @see thread_srp_client_set_host_address()
895  */
896 int thread_srp_client_register_service(thread_instance_h instance,
897         const char *service_name, const char *service_type, uint64_t port);
898
899 /**
900  * @ingroup CAPI_NETWORK_THREAD_SRP_MODULE
901  * @brief Start SRP Server
902  * @since_tizen 7.0
903  *
904  * @return 0 on success, otherwise a negative error value.
905  * @retval #THREAD_ERROR_NONE  Successful
906  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
907  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
908  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
909  *
910  * @pre thread API must be initialized with thread_initialize().
911  * @see thread_srp_server_stop()
912  */
913 int thread_srp_server_start(thread_instance_h instance);
914
915 /**
916  * @ingroup CAPI_NETWORK_THREAD_SRP_MODULE
917  * @brief Stop SRP Server
918  * @since_tizen 7.0
919  *
920  * @return 0 on success, otherwise a negative error value.
921  * @retval #THREAD_ERROR_NONE  Successful
922  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
923  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
924  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
925  *
926  * @pre thread API must be initialized with thread_initialize().
927  * @see thread_srp_server_start()
928  */
929 int thread_srp_server_stop(thread_instance_h instance);
930
931 /**
932  * @ingroup CAPI_NETWORK_THREAD_SRP_MODULE
933  * @brief Get registered service detail from the SRP server
934  * @since_tizen 7.0
935  *
936  * @return 0 on success, otherwise a negative error value.
937  * @retval #THREAD_ERROR_NONE  Successful
938  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
939  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
940  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
941  *
942  * @pre thread API must be initialized with thread_initialize().
943  * @see thread_srp_server_start()
944  */
945 int thread_srp_server_get_registered_service(thread_instance_h instance, const char **service_name,
946         const char **address, uint64_t *port, bool *is_deleted);
947
948 /**
949  * @ingroup CAPI_NETWORK_THREAD_SRP_MODULE
950  * @brief Get node ip address of the thread network node
951  * @since_tizen 7.0
952  *
953  * @return 0 on success, otherwise a negative error value.
954  * @retval #THREAD_ERROR_NONE  Successful
955  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
956  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
957  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
958  *
959  * @pre thread API must be initialized with thread_initialize() and
960  * enabled with thread_enable().
961  * @see thread_initialize() and thread_enable()
962  */
963 int thread_get_ipaddr(thread_instance_h instance, thread_ipaddr_foreach_cb callback,
964                 thread_ipaddr_type_e ipaddr_type, void *user_data);
965
966 /**
967  * @ingroup CAPI_NETWORK_THREAD_SRP_MODULE
968  * @brief Up the netwotk interface for the thread node.
969  * @since_tizen 7.0
970  *
971  * @return 0 on success, otherwise a negative error value.
972  * @retval #THREAD_ERROR_NONE  Successful
973  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
974  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
975  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
976  *
977  * @pre thread API must be initialized with thread_initialize() and
978  * enabled with thread_enable().
979  * @see thread_initialize() and thread_enable()
980  */
981 int thread_ifconfig_up(thread_instance_h instance);
982
983 /**
984  * @ingroup CAPI_NETWORK_THREAD_SRP_MODULE
985  * @brief Add Ipv6 address to the thread node.
986  * @since_tizen 7.0
987  *
988  * @param[in] ipv6_address Byte list
989  *
990  * @return 0 on success, otherwise a negative error value.
991  * @retval #THREAD_ERROR_NONE  Successful
992  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
993  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
994  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
995  *
996  * @pre thread API must be initialized with thread_initialize() and
997  * enabled with thread_enable().
998  * @see thread_initialize() and thread_enable()
999  */
1000 int thread_add_ipaddr(thread_instance_h instance, const uint8_t *ipv6_address);
1001
1002 /**
1003  * @ingroup CAPI_NETWORK_THREAD_SRP_MODULE
1004  * @brief Remove Ipv6 address from the thread node.
1005  * @since_tizen 7.0
1006  *
1007  * @param[in] ipv6_address Byte list
1008  *
1009  * @return 0 on success, otherwise a negative error value.
1010  * @retval #THREAD_ERROR_NONE  Successful
1011  * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
1012  * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
1013  * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
1014  *
1015  * @pre thread API must be initialized with thread_initialize() and
1016  * enabled with thread_enable().
1017  * @see thread_initialize() and thread_enable()
1018  */
1019 int thread_remove_ipaddr(thread_instance_h instance, const uint8_t *ipv6_address);
1020
1021 #ifdef __cplusplus
1022 }
1023 #endif /* __cplusplus */
1024
1025 #endif /* __TIZEN_NETWORK_THREAD_H__ */