tools/mesh-cfgclient: Rename mesh-db APIs for consistency
authorInga Stotland <inga.stotland@intel.com>
Thu, 23 Sep 2021 03:25:55 +0000 (20:25 -0700)
committerAyush Garg <ayush.garg@samsung.com>
Fri, 11 Mar 2022 13:38:37 +0000 (19:08 +0530)
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
tools/mesh-cfgclient.c
tools/mesh/cfgcli.c
tools/mesh/keys.c
tools/mesh/mesh-db.c
tools/mesh/mesh-db.h
tools/mesh/remote.c

index 418601a..3d06899 100644 (file)
@@ -1043,15 +1043,15 @@ static void mgr_key_reply(struct l_dbus_proxy *proxy,
 
        if (!strcmp("CreateSubnet", method)) {
                keys_add_net_key(idx);
-               mesh_db_net_key_add(idx);
+               mesh_db_add_net_key(idx);
        } else if (!strcmp("DeleteSubnet", method)) {
                keys_del_net_key(idx);
-               mesh_db_net_key_del(idx);
+               mesh_db_del_net_key(idx);
        } else if (!strcmp("UpdateSubnet", method)) {
                keys_set_net_key_phase(idx, KEY_REFRESH_PHASE_ONE, true);
        } else if (!strcmp("DeleteAppKey", method)) {
                keys_del_app_key(idx);
-               mesh_db_app_key_del(idx);
+               mesh_db_del_app_key(idx);
        }
 }
 
@@ -1135,13 +1135,13 @@ static void add_key_reply(struct l_dbus_proxy *proxy,
 
        if (!strcmp(method, "ImportSubnet")) {
                keys_add_net_key(net_idx);
-               mesh_db_net_key_add(net_idx);
+               mesh_db_add_net_key(net_idx);
                return;
        }
 
        app_idx = (uint16_t) req->arg2;
        keys_add_app_key(net_idx, app_idx);
-       mesh_db_app_key_add(net_idx, app_idx);
+       mesh_db_add_app_key(net_idx, app_idx);
 }
 
 static void import_appkey_setup(struct l_dbus_message *msg, void *user_data)
@@ -1826,7 +1826,7 @@ static struct l_dbus_message *join_complete(struct l_dbus *dbus,
        }
 
        keys_add_net_key(PRIMARY_NET_IDX);
-       mesh_db_net_key_add(PRIMARY_NET_IDX);
+       mesh_db_add_net_key(PRIMARY_NET_IDX);
 
        remote_add_node(app.uuid, 0x0001, 1, PRIMARY_NET_IDX);
        mesh_db_add_node(app.uuid, 0x0001, 1, PRIMARY_NET_IDX);
index 9399228..b30edca 100644 (file)
@@ -617,7 +617,7 @@ static bool msg_recvd(uint16_t src, uint16_t idx, uint8_t *data,
                        return true;
 
                bt_shell_printf("Node %4.4x Default TTL %d\n", src, data[0]);
-               saved = mesh_db_node_ttl_set(src, data[0]);
+               saved = mesh_db_node_set_ttl(src, data[0]);
 
                break;
 
index c08348b..134c1a1 100644 (file)
@@ -54,7 +54,7 @@ static void delete_bound_appkey(void *a)
 {
        uint32_t idx = L_PTR_TO_UINT(a);
 
-       mesh_db_app_key_del(idx);
+       mesh_db_del_app_key(idx);
 }
 
 void keys_add_net_key(uint16_t net_idx)
@@ -102,7 +102,7 @@ void keys_set_net_key_phase(uint16_t net_idx, uint8_t phase, bool save)
 
        key->phase = phase;
 
-       if (save && !mesh_db_net_key_phase_set(net_idx, phase))
+       if (save && !mesh_db_set_net_key_phase(net_idx, phase))
                bt_shell_printf("Failed to save updated KR phase\n");
 }
 
index 61b5c87..6247c88 100644 (file)
@@ -650,7 +650,7 @@ fail:
        return false;
 }
 
-bool mesh_db_node_ttl_set(uint16_t unicast, uint8_t ttl)
+bool mesh_db_node_set_ttl(uint16_t unicast, uint8_t ttl)
 {
        json_object *jnode;
 
@@ -1108,7 +1108,7 @@ static bool delete_key(json_object *jobj, const char *desc, uint16_t idx)
        return save_config();
 }
 
-bool mesh_db_node_net_key_add(uint16_t unicast, uint16_t idx)
+bool mesh_db_node_add_net_key(uint16_t unicast, uint16_t idx)
 {
        json_object *jnode;
 
@@ -1122,7 +1122,7 @@ bool mesh_db_node_net_key_add(uint16_t unicast, uint16_t idx)
        return add_node_key(jnode, "netKeys", idx);
 }
 
-bool mesh_db_node_net_key_del(uint16_t unicast, uint16_t net_idx)
+bool mesh_db_node_del_net_key(uint16_t unicast, uint16_t net_idx)
 {
        json_object *jnode;
 
@@ -1170,12 +1170,12 @@ static bool key_update(uint16_t unicast, int16_t idx, bool updated,
        return false;
 }
 
-bool mesh_db_node_net_key_update(uint16_t unicast, uint16_t idx, bool updated)
+bool mesh_db_node_update_net_key(uint16_t unicast, uint16_t idx, bool updated)
 {
        return key_update(unicast, idx, updated, "netKeys");
 }
 
-bool mesh_db_node_app_key_add(uint16_t unicast, uint16_t idx)
+bool mesh_db_node_add_app_key(uint16_t unicast, uint16_t idx)
 {
        json_object *jnode;
 
@@ -1189,7 +1189,7 @@ bool mesh_db_node_app_key_add(uint16_t unicast, uint16_t idx)
        return add_node_key(jnode, "appKeys", idx);
 }
 
-bool mesh_db_node_app_key_del(uint16_t unicast, uint16_t idx)
+bool mesh_db_node_del_app_key(uint16_t unicast, uint16_t idx)
 {
        json_object *jnode;
 
@@ -1203,7 +1203,7 @@ bool mesh_db_node_app_key_del(uint16_t unicast, uint16_t idx)
        return delete_key(jnode, "appKeys", idx);
 }
 
-bool mesh_db_node_app_key_update(uint16_t unicast, uint16_t idx, bool updated)
+bool mesh_db_node_update_app_key(uint16_t unicast, uint16_t idx, bool updated)
 {
        return key_update(unicast, idx, updated, "appKeys");
 }
@@ -1262,7 +1262,7 @@ static bool load_keys(json_object *jobj)
        return true;
 }
 
-bool mesh_db_net_key_add(uint16_t net_idx)
+bool mesh_db_add_net_key(uint16_t net_idx)
 {
        json_object *jkey, *jarray;
        char buf[12];
@@ -1305,7 +1305,7 @@ fail:
        return false;
 }
 
-bool mesh_db_net_key_del(uint16_t net_idx)
+bool mesh_db_del_net_key(uint16_t net_idx)
 {
        if (!cfg || !cfg->jcfg)
                return false;
@@ -1313,7 +1313,7 @@ bool mesh_db_net_key_del(uint16_t net_idx)
        return delete_key(cfg->jcfg, "netKeys", net_idx);
 }
 
-bool mesh_db_net_key_phase_set(uint16_t net_idx, uint8_t phase)
+bool mesh_db_set_net_key_phase(uint16_t net_idx, uint8_t phase)
 {
        json_object *jval, *jarray, *jkey;
 
@@ -1337,7 +1337,7 @@ bool mesh_db_net_key_phase_set(uint16_t net_idx, uint8_t phase)
        return save_config();
 }
 
-bool mesh_db_app_key_add(uint16_t net_idx, uint16_t app_idx)
+bool mesh_db_add_app_key(uint16_t net_idx, uint16_t app_idx)
 {
        if (!cfg || !cfg->jcfg)
                return false;
@@ -1348,7 +1348,7 @@ bool mesh_db_app_key_add(uint16_t net_idx, uint16_t app_idx)
        return save_config();
 }
 
-bool mesh_db_app_key_del(uint16_t app_idx)
+bool mesh_db_del_app_key(uint16_t app_idx)
 {
        if (!cfg || !cfg->jcfg)
                return false;
index 5dddf04..ee7d765 100644 (file)
@@ -20,13 +20,13 @@ bool mesh_db_load(const char *fname);
 bool mesh_db_get_token(uint8_t token[8]);
 bool mesh_db_set_iv_index(uint32_t ivi);
 uint32_t mesh_db_get_iv_index(void);
-bool mesh_db_net_key_add(uint16_t idx);
-bool mesh_db_net_key_del(uint16_t idx);
-bool mesh_db_net_key_phase_set(uint16_t net_idx, uint8_t phase);
-bool mesh_db_app_key_add(uint16_t net_idx, uint16_t app_idx);
-bool mesh_db_app_key_del(uint16_t app_idx);
-bool mesh_db_get_addr_range(uint16_t *low, uint16_t *high);
 
+bool mesh_db_add_net_key(uint16_t idx);
+bool mesh_db_del_net_key(uint16_t idx);
+bool mesh_db_set_net_key_phase(uint16_t net_idx, uint8_t phase);
+bool mesh_db_add_app_key(uint16_t net_idx, uint16_t app_idx);
+bool mesh_db_del_app_key(uint16_t app_idx);
+bool mesh_db_get_addr_range(uint16_t *low, uint16_t *high);
 bool mesh_db_add_node(uint8_t uuid[16], uint8_t num_els, uint16_t unicast,
                                                        uint16_t net_idx);
 bool mesh_db_del_node(uint16_t unicast);
@@ -37,13 +37,13 @@ bool mesh_db_add_provisioner(const char *name, uint8_t uuid[16],
                                uint16_t group_low, uint16_t group_high);
 bool mesh_db_node_set_net_transmit(uint16_t unicast, uint8_t cnt,
                                                        uint16_t interval);
-bool mesh_db_node_net_key_add(uint16_t unicast, uint16_t idx);
-bool mesh_db_node_net_key_del(uint16_t unicast, uint16_t idx);
-bool mesh_db_node_net_key_update(uint16_t unicast, uint16_t idx, bool updated);
-bool mesh_db_node_app_key_add(uint16_t unicast, uint16_t idx);
-bool mesh_db_node_app_key_del(uint16_t unicast, uint16_t idx);
-bool mesh_db_node_app_key_update(uint16_t unicast, uint16_t idx, bool updated);
-bool mesh_db_node_ttl_set(uint16_t unicast, uint8_t ttl);
+bool mesh_db_node_add_net_key(uint16_t unicast, uint16_t idx);
+bool mesh_db_node_del_net_key(uint16_t unicast, uint16_t idx);
+bool mesh_db_node_update_net_key(uint16_t unicast, uint16_t idx, bool updated);
+bool mesh_db_node_add_app_key(uint16_t unicast, uint16_t idx);
+bool mesh_db_node_del_app_key(uint16_t unicast, uint16_t idx);
+bool mesh_db_node_update_app_key(uint16_t unicast, uint16_t idx, bool updated);
+bool mesh_db_node_set_ttl(uint16_t unicast, uint8_t ttl);
 bool mesh_db_node_write_mode(uint16_t unicast, const char *keyword, int value);
 bool mesh_db_node_model_bind(uint16_t unicast, uint16_t ele_addr, bool vendor,
                                        uint32_t mod_id, uint16_t app_idx);
index dd294fe..054da53 100644 (file)
@@ -233,7 +233,7 @@ bool remote_add_net_key(uint16_t addr, uint16_t net_idx, bool save)
        l_queue_push_tail(rmt->net_keys, key);
 
        if (save)
-               return mesh_db_node_net_key_add(addr, net_idx);
+               return mesh_db_node_add_net_key(addr, net_idx);
        else
                return true;
 }
@@ -252,14 +252,14 @@ bool remote_del_net_key(uint16_t addr, uint16_t net_idx)
        if (!key)
                return false;
 
-       mesh_db_node_net_key_del(addr, net_idx);
+       mesh_db_node_del_net_key(addr, net_idx);
 
        l_free(key);
        key = l_queue_remove_if(rmt->app_keys, match_bound_key,
                                                L_UINT_TO_PTR(net_idx));
 
        while (key) {
-               mesh_db_node_app_key_del(rmt->unicast, key->idx);
+               mesh_db_node_del_app_key(rmt->unicast, key->idx);
                l_free(key);
 
                key = l_queue_remove_if(rmt->app_keys, match_bound_key,
@@ -284,7 +284,7 @@ bool remote_update_net_key(uint16_t addr, uint16_t net_idx, bool update,
        key->updated = update;
 
        if (save)
-               return mesh_db_node_net_key_update(addr, net_idx, update);
+               return mesh_db_node_update_net_key(addr, net_idx, update);
        else
                return true;
 }
@@ -310,7 +310,7 @@ bool remote_add_app_key(uint16_t addr, uint16_t app_idx, bool save)
        l_queue_push_tail(rmt->app_keys, key);
 
        if (save)
-               return mesh_db_node_app_key_add(addr, app_idx);
+               return mesh_db_node_add_app_key(addr, app_idx);
        else
                return true;
 }
@@ -328,7 +328,7 @@ bool remote_del_app_key(uint16_t addr, uint16_t app_idx)
                                                L_UINT_TO_PTR(app_idx));
        l_free(key);
 
-       return mesh_db_node_app_key_del(addr, app_idx);
+       return mesh_db_node_del_app_key(addr, app_idx);
 }
 
 bool remote_update_app_key(uint16_t addr, uint16_t app_idx, bool update,
@@ -346,7 +346,7 @@ bool remote_update_app_key(uint16_t addr, uint16_t app_idx, bool update,
        key->updated = update;
 
        if (save)
-               return mesh_db_node_app_key_update(addr, app_idx, update);
+               return mesh_db_node_update_app_key(addr, app_idx, update);
        else
                return true;
 }
@@ -375,7 +375,7 @@ bool remote_finish_key_refresh(uint16_t addr, uint16_t net_idx)
 
                key->updated = false;
 
-               res &= mesh_db_node_app_key_update(addr, key->idx, false);
+               res &= mesh_db_node_update_app_key(addr, key->idx, false);
        }
 
        return res;