tools/mesh-cfgclient: Fix saving KR phase to config file
PATCH 1/1 tools/mesh-cfgclient: Fix saving KR phase to config file
This eliminates extra write of KR phase when loading keys from the configuration file on initialization.
--- tools/mesh-cfgclient.c | 4 ++-- tools/mesh/keys.c | 4 ++-- tools/mesh/keys.h | 2 +- tools/mesh/mesh-db.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-)
tools/mesh-cfgclient.c +2 -2
@@ -944,7 +944,7 @@ static void subnet_set_phase_reply(struct l_dbus_proxy *proxy,if (phase ==KEY_REFRESH_PHASE_THREE ) phase =KEY_REFRESH_PHASE_NONE ; -keys_set_net_key_phase (net_idx, phase); +keys_set_net_key_phase (net_idx, phase, true); }static void subnet_set_phase_setup (struct l_dbus_message *msg,void *user_data)
@@ -1014,7 +1014,7 @@ static void mgr_key_reply(struct l_dbus_proxy *proxy,keys_del_net_key (idx);mesh_db_net_key_del (idx); }else if (!strcmp ("UpdateSubnet" , method)) { -keys_set_net_key_phase (idx,KEY_REFRESH_PHASE_ONE ); +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);
tools/mesh/keys.c +2 -2
@@ -99,7 +99,7 @@ void keys_del_net_key(uint16_t idx)l_free (key); } -void keys_set_net_key_phase (uint16_t net_idx,uint8_t phase) +void keys_set_net_key_phase (uint16_t net_idx,uint8_t phase,bool save) {struct net_key *key;
@@ -112,7 +112,7 @@ void keys_set_net_key_phase(uint16_t net_idx, uint8_t phase) key->phase = phase; -if (!mesh_db_net_key_phase_set (net_idx, phase)) +if (save && !mesh_db_net_key_phase_set (net_idx, phase))bt_shell_printf ("Failed to save updated KR phase\n" ); }
tools/mesh/keys.h +1 -1
@@ -20,7 +20,7 @@void keys_add_net_key (uint16_t net_idx);void keys_del_net_key (uint16_t net_idx); -void keys_set_net_key_phase (uint16_t net_idx,uint8_t phase); +void keys_set_net_key_phase (uint16_t net_idx,uint8_t phase,bool save);bool keys_get_net_key_phase (uint16_t net_idx,uint8_t *phase);void keys_add_app_key (uint16_t net_idx,uint16_t app_idx);void keys_del_app_key (uint16_t app_idx);
tools/mesh/mesh-db.c +1 -1
@@ -607,7 +607,7 @@ static bool load_keys(json_object *jobj)if (!get_int (jentry,"phase" , &phase))return false; -keys_set_net_key_phase (net_idx, (uint8_t ) phase); +keys_set_net_key_phase (net_idx, (uint8_t ) phase, false); }json_object_object_get_ex (jobj,"appKeys" , &jarray);
Signature · 1 line
2.21.1
Gix, Brian
AppliedApplied
Quoted 79 lines · Inga Stotland
This eliminates extra write of KR phase when loading keys from the configuration file on initialization.
--- tools/mesh-cfgclient.c | 4 ++-- tools/mesh/keys.c | 4 ++-- tools/mesh/keys.h | 2 +- tools/mesh/mesh-db.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-)tools/mesh-cfgclient.c +2
-2@@ -944,7 +944,7 @@ static void subnet_set_phase_reply(struct l_dbus_proxy *proxy,if (phase ==KEY_REFRESH_PHASE_THREE ) phase =KEY_REFRESH_PHASE_NONE ; -keys_set_net_key_phase (net_idx, phase); +keys_set_net_key_phase (net_idx, phase, true); }static void subnet_set_phase_setup (struct l_dbus_message *msg,void *user_data)@@ -1014,7 +1014,7 @@ static void mgr_key_reply(struct l_dbus_proxy *proxy,keys_del_net_key (idx);mesh_db_net_key_del (idx); }else if (!strcmp ("UpdateSubnet" , method)) { -keys_set_net_key_phase (idx,KEY_REFRESH_PHASE_ONE ); +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);tools/mesh/keys.c +2
-2@@ -99,7 +99,7 @@ void keys_del_net_key(uint16_t idx)l_free (key); } -void keys_set_net_key_phase (uint16_t net_idx,uint8_t phase) +void keys_set_net_key_phase (uint16_t net_idx,uint8_t phase,bool save) {struct net_key *key;@@ -112,7 +112,7 @@ void keys_set_net_key_phase(uint16_t net_idx, uint8_t phase) key->phase = phase; -if (!mesh_db_net_key_phase_set (net_idx, phase)) +if (save && !mesh_db_net_key_phase_set (net_idx, phase))bt_shell_printf ("Failed to save updated KR phase\n" ); }tools/mesh/keys.h +1
-1@@ -20,7 +20,7 @@void keys_add_net_key (uint16_t net_idx);void keys_del_net_key (uint16_t net_idx); -void keys_set_net_key_phase (uint16_t net_idx,uint8_t phase); +void keys_set_net_key_phase (uint16_t net_idx,uint8_t phase,bool save);bool keys_get_net_key_phase (uint16_t net_idx,uint8_t *phase);void keys_add_app_key (uint16_t net_idx,uint16_t app_idx);void keys_del_app_key (uint16_t app_idx);tools/mesh/mesh-db.c +1
-1@@ -607,7 +607,7 @@ static bool load_keys(json_object *jobj)if (!get_int (jentry,"phase" , &phase))return false; -keys_set_net_key_phase (net_idx, (uint8_t ) phase); +keys_set_net_key_phase (net_idx, (uint8_t ) phase, false); }json_object_object_get_ex (jobj,"appKeys" , &jarray);