node.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /* SPDX-License-Identifier: LGPL-2.1-or-later */
  2. /*
  3. *
  4. * BlueZ - Bluetooth protocol stack for Linux
  5. *
  6. * Copyright (C) 2017 Intel Corporation. All rights reserved.
  7. *
  8. *
  9. */
  10. struct mesh_node;
  11. #define ACTION_ADD 1
  12. #define ACTION_UPDATE 2
  13. #define ACTION_DELETE 3
  14. struct prov_svc_data {
  15. uint16_t oob;
  16. uint8_t dev_uuid[16];
  17. };
  18. struct mesh_node_composition {
  19. bool relay;
  20. bool proxy;
  21. bool lpn;
  22. bool friend;
  23. uint16_t cid;
  24. uint16_t pid;
  25. uint16_t vid;
  26. uint16_t crpl;
  27. };
  28. struct mesh_publication {
  29. uint16_t app_idx;
  30. union {
  31. uint16_t addr16;
  32. uint8_t va_128[16];
  33. } u;
  34. uint8_t ttl;
  35. uint8_t credential;
  36. uint8_t period;
  37. uint8_t retransmit;
  38. };
  39. typedef bool (*node_model_recv_callback)(uint16_t src, uint8_t *data,
  40. uint16_t len, void *user_data);
  41. typedef int (*node_model_bind_callback)(uint16_t app_idx, int action);
  42. typedef void (*node_model_pub_callback)(struct mesh_publication *pub);
  43. typedef void (*node_model_sub_callback)(uint16_t sub_addr, int action);
  44. struct mesh_model_ops {
  45. node_model_recv_callback recv;
  46. node_model_bind_callback bind;
  47. node_model_pub_callback pub;
  48. node_model_sub_callback sub;
  49. };
  50. struct mesh_node *node_find_by_addr(uint16_t addr);
  51. struct mesh_node *node_find_by_uuid(uint8_t uuid[16]);
  52. struct mesh_node *node_create_new(struct prov_svc_data *prov);
  53. struct mesh_node *node_new(void);
  54. void node_free(struct mesh_node *node);
  55. bool node_is_provisioned(struct mesh_node *node);
  56. void *node_get_prov(struct mesh_node *node);
  57. void node_set_prov(struct mesh_node *node, void *prov);
  58. bool node_app_key_add(struct mesh_node *node, uint16_t idx);
  59. bool node_net_key_add(struct mesh_node *node, uint16_t index);
  60. bool node_app_key_delete(struct mesh_node *node, uint16_t net_idx,
  61. uint16_t idx);
  62. bool node_net_key_delete(struct mesh_node *node, uint16_t index);
  63. void node_set_primary(struct mesh_node *node, uint16_t unicast);
  64. uint16_t node_get_primary(struct mesh_node *node);
  65. uint16_t node_get_primary_net_idx(struct mesh_node *node);
  66. void node_set_device_key(struct mesh_node *node, uint8_t *key);
  67. uint8_t *node_get_device_key(struct mesh_node *node);
  68. void node_set_num_elements(struct mesh_node *node, uint8_t num_ele);
  69. uint8_t node_get_num_elements(struct mesh_node *node);
  70. bool node_parse_composition(struct mesh_node *node, uint8_t *buf, uint16_t len);
  71. GList *node_get_net_keys(struct mesh_node *node);
  72. GList *node_get_app_keys(struct mesh_node *node);
  73. void node_cleanup(void);
  74. bool node_set_local_node(struct mesh_node *node);
  75. struct mesh_node *node_get_local_node(void);
  76. void node_local_data_handler(uint16_t src, uint32_t dst,
  77. uint32_t iv_index, uint32_t seq_num,
  78. uint16_t app_idx, uint8_t *data, uint16_t len);
  79. bool node_local_model_register(uint8_t element_idx, uint16_t model_id,
  80. struct mesh_model_ops *ops, void *user_data);
  81. bool node_local_vendor_model_register(uint8_t element_idx, uint32_t model_id,
  82. struct mesh_model_ops *ops, void *user_data);
  83. bool node_set_element(struct mesh_node *node, uint8_t ele_idx);
  84. bool node_set_model(struct mesh_node *node, uint8_t ele_idx, uint32_t id);
  85. struct mesh_node_composition *node_get_composition(struct mesh_node *node);
  86. bool node_set_composition(struct mesh_node *node,
  87. struct mesh_node_composition *comp);
  88. bool node_add_binding(struct mesh_node *node, uint8_t ele_idx,
  89. uint32_t model_id, uint16_t app_idx);
  90. bool node_add_subscription(struct mesh_node *node, uint8_t ele_idx,
  91. uint32_t model_id, uint16_t addr);
  92. uint8_t node_get_default_ttl(struct mesh_node *node);
  93. bool node_set_default_ttl(struct mesh_node *node, uint8_t ttl);
  94. bool node_set_sequence_number(struct mesh_node *node, uint32_t seq);
  95. uint32_t node_get_sequence_number(struct mesh_node *node);
  96. bool node_set_iv_index(struct mesh_node *node, uint32_t iv_index);
  97. uint32_t node_get_iv_index(struct mesh_node *node);
  98. bool node_model_pub_set(struct mesh_node *node, uint8_t ele, uint32_t model_id,
  99. struct mesh_publication *pub);
  100. struct mesh_publication *node_model_pub_get(struct mesh_node *node, uint8_t ele,
  101. uint32_t model_id);