From: Inga Stotland <inga.stotland@intel.com>
To: linux-bluetooth@vger.kernel.org
Cc: brian.gix@intel.com, michal.lowas-rzechonek@silvair.com,
jakub.witowski@silvair.com,
Inga Stotland <inga.stotland@intel.com>
Subject: [PATCH BlueZ 5/9] mesh: Change variable prefix "jconfig" to "config"
Date: Tue, 9 Jul 2019 22:09:55 -0700 [thread overview]
Message-ID: <20190710050959.7321-6-inga.stotland@intel.com> (raw)
In-Reply-To: <20190710050959.7321-1-inga.stotland@intel.com>
This adjust variable naming by changing "jconfig" prefix to more generic
"config. This also removes #include json-c/json.h for model.c,
cfg-server.c and node.c as they no longer rely on the specifics of node
configuration storage implementation.
---
mesh/cfgmod-server.c | 16 +++++++---------
mesh/model.c | 1 -
mesh/node.c | 25 ++++++++++++-------------
mesh/node.h | 4 ++--
mesh/storage.c | 34 +++++++++++++++++-----------------
5 files changed, 38 insertions(+), 42 deletions(-)
diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c
index 0479a9185..1aa7c85da 100644
--- a/mesh/cfgmod-server.c
+++ b/mesh/cfgmod-server.c
@@ -24,8 +24,6 @@
#include <sys/time.h>
#include <ell/ell.h>
-#include "json-c/json.h"
-
#include "mesh/mesh-defs.h"
#include "mesh/node.h"
#include "mesh/net.h"
@@ -197,7 +195,7 @@ static bool config_pub_set(struct mesh_node *node, uint16_t src, uint16_t dst,
/* Remove model publication from config file */
if (status == MESH_STATUS_SUCCESS)
- mesh_config_model_pub_del(node_jconfig_get(node),
+ mesh_config_model_pub_del(node_config_get(node),
ele_addr, vendor ? mod_id : mod_id & 0x0000ffff,
vendor);
goto done;
@@ -219,7 +217,7 @@ static bool config_pub_set(struct mesh_node *node, uint16_t src, uint16_t dst,
memcpy(db_pub.virt_addr, pub_addr, 16);
/* Save model publication to config file */
- if (!mesh_config_model_pub_add(node_jconfig_get(node), ele_addr,
+ if (!mesh_config_model_pub_add(node_config_get(node), ele_addr,
vendor ? mod_id : mod_id & 0x0000ffff,
vendor, &db_pub))
status = MESH_STATUS_STORAGE_FAIL;
@@ -331,18 +329,18 @@ static bool save_config_sub(struct mesh_node *node, uint16_t ele_addr,
if (opcode == OP_CONFIG_MODEL_SUB_VIRT_OVERWRITE ||
opcode == OP_CONFIG_MODEL_SUB_OVERWRITE)
- mesh_config_model_sub_del_all(node_jconfig_get(node),
+ mesh_config_model_sub_del_all(node_config_get(node),
ele_addr, vendor ? mod_id : mod_id & 0x0000ffff,
vendor);
if (opcode != OP_CONFIG_MODEL_SUB_VIRT_DELETE &&
opcode != OP_CONFIG_MODEL_SUB_DELETE)
- return mesh_config_model_sub_add(node_jconfig_get(node),
+ return mesh_config_model_sub_add(node_config_get(node),
ele_addr,
vendor ? mod_id : mod_id & 0x0000ffff,
vendor, &db_sub);
else
- return mesh_config_model_sub_del(node_jconfig_get(node),
+ return mesh_config_model_sub_del(node_config_get(node),
ele_addr,
vendor ? mod_id : mod_id & 0x0000ffff,
vendor, &db_sub);
@@ -419,7 +417,7 @@ static void config_sub_set(struct mesh_node *node, uint16_t src, uint16_t dst,
status = mesh_model_sub_del_all(node, ele_addr, mod_id);
if (status == MESH_STATUS_SUCCESS)
- mesh_config_model_sub_del_all(node_jconfig_get(node),
+ mesh_config_model_sub_del_all(node_config_get(node),
ele_addr, vendor ? mod_id : mod_id & 0x0000ffff,
vendor);
break;
@@ -878,7 +876,7 @@ static bool cfg_srv_pkt(uint16_t src, uint32_t dst,
count = (pkt[0] >> 5) + 1;
interval = ((pkt[0] & 0x1f) + 1) * 10;
- if (storage_set_transmit_params(node_jconfig_get(node), count,
+ if (storage_set_transmit_params(node_config_get(node), count,
interval))
mesh_net_transmit_params_set(net, count, interval);
/* Fall Through */
diff --git a/mesh/model.c b/mesh/model.c
index 9331e1044..0f10727b4 100644
--- a/mesh/model.c
+++ b/mesh/model.c
@@ -23,7 +23,6 @@
#include <sys/time.h>
#include <ell/ell.h>
-#include <json-c/json.h>
#include "mesh/mesh-defs.h"
diff --git a/mesh/node.c b/mesh/node.c
index 6ebdcf588..82d917337 100644
--- a/mesh/node.c
+++ b/mesh/node.c
@@ -26,7 +26,6 @@
#include <sys/time.h>
#include <ell/ell.h>
-#include <json-c/json.h>
#include "mesh/mesh-defs.h"
#include "mesh/mesh.h"
@@ -81,7 +80,7 @@ struct mesh_node {
char *app_path;
char *owner;
char *path;
- void *jconfig;
+ void *config;
char *node_path;
uint32_t disc_watch;
time_t upd_sec;
@@ -719,7 +718,7 @@ bool node_proxy_mode_set(struct mesh_node *node, bool enable)
return false;
proxy = enable ? MESH_MODE_ENABLED : MESH_MODE_DISABLED;
- res = storage_set_mode(node->jconfig, proxy, "proxy");
+ res = storage_set_mode(node->config, proxy, "proxy");
if (res) {
node->proxy = proxy;
@@ -746,7 +745,7 @@ bool node_beacon_mode_set(struct mesh_node *node, bool enable)
return false;
beacon = enable ? MESH_MODE_ENABLED : MESH_MODE_DISABLED;
- res = storage_set_mode(node->jconfig, beacon, "beacon");
+ res = storage_set_mode(node->config, beacon, "beacon");
if (res) {
node->beacon = beacon;
@@ -773,7 +772,7 @@ bool node_friend_mode_set(struct mesh_node *node, bool enable)
return false;
friend = enable ? MESH_MODE_ENABLED : MESH_MODE_DISABLED;
- res = storage_set_mode(node->jconfig, friend, "friend");
+ res = storage_set_mode(node->config, friend, "friend");
if (res) {
node->friend = friend;
@@ -1431,16 +1430,16 @@ static bool add_local_node(struct mesh_node *node, uint16_t unicast, bool kr,
mesh_net_set_iv_index(node->net, iv_idx, ivu);
- if (!mesh_config_write_uint16_hex(node->jconfig, "unicastAddress",
+ if (!mesh_config_write_uint16_hex(node->config, "unicastAddress",
unicast))
return false;
l_getrandom(node->token, sizeof(node->token));
- if (!mesh_config_write_token(node->jconfig, node->token))
+ if (!mesh_config_write_token(node->config, node->token))
return false;
memcpy(node->dev_key, dev_key, 16);
- if (!mesh_config_write_device_key(node->jconfig, dev_key))
+ if (!mesh_config_write_device_key(node->config, dev_key))
return false;
node->primary = unicast;
@@ -1456,7 +1455,7 @@ static bool add_local_node(struct mesh_node *node, uint16_t unicast, bool kr,
MESH_STATUS_SUCCESS)
return false;
- if (!mesh_config_net_key_set_phase(node->jconfig, net_key_idx,
+ if (!mesh_config_net_key_set_phase(node->config, net_key_idx,
KEY_REFRESH_PHASE_TWO))
return false;
}
@@ -2016,14 +2015,14 @@ bool node_add_pending_local(struct mesh_node *node, void *prov_node_info)
info->device_key, info->net_index, info->net_key);
}
-void node_jconfig_set(struct mesh_node *node, void *jconfig)
+void node_config_set(struct mesh_node *node, void *config)
{
- node->jconfig = jconfig;
+ node->config = config;
}
-void *node_jconfig_get(struct mesh_node *node)
+void *node_config_get(struct mesh_node *node)
{
- return node->jconfig;
+ return node->config;
}
void node_path_set(struct mesh_node *node, char *path)
diff --git a/mesh/node.h b/mesh/node.h
index 142527b30..055862a7f 100644
--- a/mesh/node.h
+++ b/mesh/node.h
@@ -95,7 +95,7 @@ void node_id_set(struct mesh_node *node, uint16_t node_id);
uint16_t node_id_get(struct mesh_node *node);
bool node_dbus_init(struct l_dbus *bus);
void node_cleanup_all(void);
-void node_jconfig_set(struct mesh_node *node, void *jconfig);
-void *node_jconfig_get(struct mesh_node *node);
+void node_config_set(struct mesh_node *node, void *config);
+void *node_config_get(struct mesh_node *node);
void node_path_set(struct mesh_node *node, char *path);
char *node_path_get(struct mesh_node *node);
diff --git a/mesh/storage.c b/mesh/storage.c
index 601669791..e87b58c59 100644
--- a/mesh/storage.c
+++ b/mesh/storage.c
@@ -169,7 +169,7 @@ static bool parse_config(char *in_file, char *out_dir, const uint8_t uuid[16])
node_remove(node);
}
- node_jconfig_set(node, jnode);
+ node_config_set(node, jnode);
node_path_set(node, out_dir);
done:
@@ -182,7 +182,7 @@ done:
bool storage_set_ttl(struct mesh_node *node, uint8_t ttl)
{
- json_object *jnode = node_jconfig_get(node);
+ json_object *jnode = node_config_get(node);
if (!mesh_config_write_int(jnode, "defaultTTL", ttl))
return false;
@@ -194,7 +194,7 @@ bool storage_set_ttl(struct mesh_node *node, uint8_t ttl)
bool storage_set_relay(struct mesh_node *node, bool enable,
uint8_t count, uint8_t interval)
{
- json_object *jnode = node_jconfig_get(node);
+ json_object *jnode = node_config_get(node);
if (!mesh_config_write_relay_mode(jnode, enable, count, interval))
return false;
@@ -206,7 +206,7 @@ bool storage_set_relay(struct mesh_node *node, bool enable,
bool storage_set_transmit_params(struct mesh_node *node, uint8_t count,
uint8_t interval)
{
- json_object *jnode = node_jconfig_get(node);
+ json_object *jnode = node_config_get(node);
if (!mesh_config_write_net_transmit(jnode, count, interval))
return false;
@@ -218,7 +218,7 @@ bool storage_set_transmit_params(struct mesh_node *node, uint8_t count,
bool storage_set_mode(struct mesh_node *node, uint8_t mode,
const char *mode_name)
{
- json_object *jnode = node_jconfig_get(node);
+ json_object *jnode = node_config_get(node);
if (!mesh_config_write_mode(jnode, mode_name, mode))
return false;
@@ -238,7 +238,7 @@ bool storage_model_bind(struct mesh_node *node, uint16_t addr, uint32_t mod_id,
if (ele_idx < 0)
return false;
- jnode = node_jconfig_get(node);
+ jnode = node_config_get(node);
if (unbind)
stored = mesh_config_model_binding_del(jnode, ele_idx,
@@ -260,7 +260,7 @@ bool storage_app_key_add(struct mesh_net *net, uint16_t net_idx,
struct mesh_node *node = mesh_net_node_get(net);
bool stored;
- jnode = node_jconfig_get(node);
+ jnode = node_config_get(node);
if (!jnode)
return false;
@@ -281,7 +281,7 @@ bool storage_app_key_del(struct mesh_net *net, uint16_t net_idx,
json_object *jnode;
struct mesh_node *node = mesh_net_node_get(net);
- jnode = node_jconfig_get(node);
+ jnode = node_config_get(node);
if (!jnode)
return false;
@@ -296,7 +296,7 @@ bool storage_net_key_add(struct mesh_net *net, uint16_t net_idx,
const uint8_t key[16], bool update)
{
struct mesh_node *node = mesh_net_node_get(net);
- json_object *jnode = node_jconfig_get(node);
+ json_object *jnode = node_config_get(node);
bool stored;
if (!update)
@@ -313,7 +313,7 @@ bool storage_net_key_add(struct mesh_net *net, uint16_t net_idx,
bool storage_net_key_del(struct mesh_net *net, uint16_t net_idx)
{
struct mesh_node *node = mesh_net_node_get(net);
- json_object *jnode = node_jconfig_get(node);
+ json_object *jnode = node_config_get(node);
if (!mesh_config_net_key_del(jnode, net_idx))
return false;
@@ -326,7 +326,7 @@ bool storage_set_iv_index(struct mesh_net *net, uint32_t iv_index,
bool update)
{
struct mesh_node *node = mesh_net_node_get(net);
- json_object *jnode = node_jconfig_get(node);
+ json_object *jnode = node_config_get(node);
if (!mesh_config_write_iv_index(jnode, iv_index, update))
return false;
@@ -339,7 +339,7 @@ bool storage_set_key_refresh_phase(struct mesh_net *net, uint16_t net_idx,
uint8_t phase)
{
struct mesh_node *node = mesh_net_node_get(net);
- json_object *jnode = node_jconfig_get(node);
+ json_object *jnode = node_config_get(node);
if (!mesh_config_net_key_set_phase(jnode, net_idx, phase))
return false;
@@ -351,7 +351,7 @@ bool storage_set_key_refresh_phase(struct mesh_net *net, uint16_t net_idx,
bool storage_write_sequence_number(struct mesh_net *net, uint32_t seq)
{
struct mesh_node *node = mesh_net_node_get(net);
- json_object *jnode = node_jconfig_get(node);
+ json_object *jnode = node_config_get(node);
if (!mesh_config_write_int(jnode, "sequenceNumber", seq))
return false;
@@ -421,7 +421,7 @@ void storage_save_config(struct mesh_node *node, bool no_wait,
struct write_info *info;
info = l_new(struct write_info, 1);
- info->jnode = node_jconfig_get(node);
+ info->jnode = node_config_get(node);
info->node_path = node_path_get(node);
info->cb = cb;
info->user_data = user_data;
@@ -557,7 +557,7 @@ bool storage_create_node_config(struct mesh_node *node, void *data)
if (!save_config(jnode, name_buf))
goto fail;
- node_jconfig_set(node, jnode);
+ node_config_set(node, jnode);
return true;
fail:
@@ -594,11 +594,11 @@ void storage_remove_node_config(struct mesh_node *node)
return;
/* Free the node config json object */
- jnode = node_jconfig_get(node);
+ jnode = node_config_get(node);
if (jnode)
json_object_put(jnode);
- node_jconfig_set(node, NULL);
+ node_config_set(node, NULL);
node_path = node_path_get(node);
l_debug("Delete node config %s", node_path);
--
2.21.0
next prev parent reply other threads:[~2019-07-10 5:10 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-10 5:09 [PATCH BlueZ 0/9] mesh: Configuration storage re-org Inga Stotland
2019-07-10 5:09 ` [PATCH BlueZ 1/9] mesh: Move network config setup from storage.c to node.c Inga Stotland
2019-07-10 5:09 ` [PATCH BlueZ 2/9] mesh: Rename mesh-db.c to mesh-config-json.c Inga Stotland
2019-07-10 5:09 ` [PATCH BlueZ 3/9] mesh: Change mesh_db prefix to mesh_config Inga Stotland
2019-07-10 5:09 ` [PATCH BlueZ 4/9] mesh: Generalize mesh-config APIs Inga Stotland
2019-07-10 7:38 ` Michał Lowas-Rzechonek
2019-07-10 15:01 ` Michał Lowas-Rzechonek
2019-07-10 15:58 ` Stotland, Inga
2019-07-10 5:09 ` Inga Stotland [this message]
2019-07-10 8:29 ` [PATCH BlueZ 5/9] mesh: Change variable prefix "jconfig" to "config" Michał Lowas-Rzechonek
2019-07-10 5:09 ` [PATCH BlueZ 6/9] mesh: Define storage format specific read/write routines Inga Stotland
2019-07-10 7:52 ` Michał Lowas-Rzechonek
2019-07-10 16:53 ` Stotland, Inga
2019-07-10 17:00 ` michal.lowas-rzechonek
2019-07-10 17:20 ` Gix, Brian
2019-07-10 19:32 ` Michal Lowas-Rzechonek
2019-07-10 5:09 ` [PATCH BlueZ 7/9] mesh: Implement config read/write for mesh json format Inga Stotland
2019-07-10 5:09 ` [PATCH BlueZ 8/9] mesh: Switch to using mesh-config routines for storage Inga Stotland
2019-07-10 5:09 ` [PATCH BlueZ 9/9] mesh: Make storage.c json-c agnostic Inga Stotland
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190710050959.7321-6-inga.stotland@intel.com \
--to=inga.stotland@intel.com \
--cc=brian.gix@intel.com \
--cc=jakub.witowski@silvair.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=michal.lowas-rzechonek@silvair.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox