mesh: Add key storage
PATCH 1/1 mesh: Add key storage
This implements internal key storage add/delete/fetch for the three basic key types managed in Mesh: Network, Application and Device.
This key storage is separate from keys assigned to nodes within the mesh, and are used to support Configuration Client functionality.
--- mesh/node.c | 13 +++ mesh/node.h | 2 + mesh/storage.c | 363 ++++++++++++++++++++++++++++++++++++++++++++++++++++----- mesh/storage.h | 30 +++++ 4 files changed, 382 insertions(+), 26 deletions(-)
mesh/node.c +13 -0
@@ -79,6 +79,7 @@ struct mesh_node {char *path;void *jconfig;char *cfg_file; +char *node_path;uint32_t disc_watch;time_t upd_sec;uint32_t seq_number;
@@ -235,6 +236,8 @@ static void free_node_resources(void *data)l_free (node->comp);l_free (node->app_path);l_free (node->owner); +l_free (node->cfg_file); +l_free (node->node_path);if (node->disc_watch)l_dbus_remove_watch (dbus_get_bus (), node->disc_watch);
@@ -1883,6 +1886,16 @@ char *node_cfg_file_get(struct mesh_node *node)return node->cfg_file; } +void node_path_set (struct mesh_node *node,char *path) +{ + node->node_path = path; +} + +char *node_path_get (struct mesh_node *node) +{ +return node->node_path; +} +struct mesh_net *node_get_net (struct mesh_node *node) {return node->net;
mesh/node.h +2 -0
@@ -97,3 +97,5 @@ void node_jconfig_set(struct mesh_node *node, void *jconfig);void *node_jconfig_get (struct mesh_node *node);void node_cfg_file_set (struct mesh_node *node,char *cfg);char *node_cfg_file_get (struct mesh_node *node); +void node_path_set (struct mesh_node *node,char *path); +char *node_path_get (struct mesh_node *node);
mesh/storage.c +337 -26
400 lines not on this page · raw message
mesh/storage.h +30 -0
@@ -20,6 +20,20 @@struct mesh_net ;struct mesh_node ; +struct net_key_storage { +uint16_t net_idx; +uint8_t phase; +uint8_t old_key[16 ]; +uint8_t new_key[16 ]; +}; + +struct app_key_storage { +uint16_t app_idx; +uint16_t net_idx; +uint8_t old_key[16 ]; +uint8_t new_key[16 ]; +}; +bool storage_load_nodes (const char *dir);bool storage_create_node_config (struct mesh_node *node,void *db_node);void storage_remove_node_config (struct mesh_node *node);
@@ -49,3 +63,19 @@ bool storage_set_device_key(struct mesh_node *node, uint8_t dev_key[16]);bool storage_set_unicast (struct mesh_node *node,uint16_t unicast);bool storage_set_key_refresh_phase (struct mesh_net *net,uint16_t net_idx,uint8_t phase); +bool storage_put_net_key (struct mesh_node *node,uint16_t net_idx, +struct net_key_storage *key); +bool storage_get_net_key (struct mesh_node *node,uint16_t net_idx, +struct net_key_storage *key); +bool storage_del_net_key (struct mesh_node *node,uint16_t net_idx); +bool storage_put_app_key (struct mesh_node *node,uint16_t app_idx, +uint16_t net_idx,struct app_key_storage *key); +bool storage_get_app_key (struct mesh_node *node,uint16_t app_idx, +struct app_key_storage *key); +bool storage_del_app_key (struct mesh_node *node,uint16_t app_idx); +bool storage_get_remote_dev_key (struct mesh_node *node,uint16_t unicast, +uint8_t dev_key[16 ]); +bool storage_put_remote_dev_key (struct mesh_node *node,uint16_t unicast, +uint8_t count,uint8_t dev_key[16 ]); +bool storage_del_remote_dev_key (struct mesh_node *node,uint16_t unicast, +uint8_t count);
Signature · 1 line
2.14.5