2017-07-27 11:18:41

by ERAMOTO Masaya

[permalink] [raw]
Subject: [PATCH Bluez 0/6] core: Add checking for Policy/GATT in main.conf

This patches add checking for Policy/GATT in main.conf as below:
bluetoothd[XXXX]: Unknown key Cache for group Policy in main.conf
bluetoothd[XXXX]: Unknown key Timeout for group GATT in main.conf

ERAMOTO Masaya (6):
core: Add group information to warning message for main.conf
core: Split check_config() function
core: Fix General options in main.conf
core: Add checking for unknown Policy options
core: Add checking for unknown GATT options
core: Make easier to manage checked groups

src/main.c | 81 ++++++++++++++++++++++++++++++++++++++++++++------------------
1 file changed, 58 insertions(+), 23 deletions(-)

--
2.7.4




2017-07-27 14:24:37

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [PATCH Bluez 0/6] core: Add checking for Policy/GATT in main.conf

Hi Eramoto,

On Thu, Jul 27, 2017 at 2:18 PM, ERAMOTO Masaya
<[email protected]> wrote:
> This patches add checking for Policy/GATT in main.conf as below:
> bluetoothd[XXXX]: Unknown key Cache for group Policy in main.conf
> bluetoothd[XXXX]: Unknown key Timeout for group GATT in main.conf
>
> ERAMOTO Masaya (6):
> core: Add group information to warning message for main.conf
> core: Split check_config() function
> core: Fix General options in main.conf
> core: Add checking for unknown Policy options
> core: Add checking for unknown GATT options
> core: Make easier to manage checked groups
>
> src/main.c | 81 ++++++++++++++++++++++++++++++++++++++++++++------------------
> 1 file changed, 58 insertions(+), 23 deletions(-)
>
> --
> 2.7.4

Great set, applied.

--
Luiz Augusto von Dentz

2017-07-27 11:24:04

by ERAMOTO Masaya

[permalink] [raw]
Subject: [PATCH Bluez 6/6] core: Make easier to manage checked groups

This makes easier to manage groups which need to be checked for.
---
src/main.c | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/src/main.c b/src/main.c
index 2d00478..f33c64d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -106,6 +106,17 @@ static const char * const gatt_options[] = {
NULL
};

+static const struct group_table {
+ const char *name;
+ const char * const *options;
+} valid_groups[] = {
+ { "General", supported_options },
+ { "Policy", policy_options },
+ { "GATT", gatt_options },
+ { }
+};
+
+
GKeyFile *btd_get_main_conf(void)
{
return main_conf;
@@ -207,9 +218,9 @@ static void check_options(GKeyFile *config, const char *group,

static void check_config(GKeyFile *config)
{
- const char *valid_groups[] = { "General", "Policy", "GATT", NULL };
char **keys;
int i;
+ const struct group_table *group;

if (!config)
return;
@@ -217,11 +228,10 @@ static void check_config(GKeyFile *config)
keys = g_key_file_get_groups(config, NULL);

for (i = 0; keys != NULL && keys[i] != NULL; i++) {
- const char **group;
bool match = false;

- for (group = valid_groups; *group; group++) {
- if (g_str_equal(keys[i], *group)) {
+ for (group = valid_groups; group && group->name ; group++) {
+ if (g_str_equal(keys[i], group->name)) {
match = true;
break;
}
@@ -233,9 +243,8 @@ static void check_config(GKeyFile *config)

g_strfreev(keys);

- check_options(config, "General", supported_options);
- check_options(config, "Policy", policy_options);
- check_options(config, "GATT", gatt_options);
+ for (group = valid_groups; group && group->name; group++)
+ check_options(config, group->name, group->options);
}

static int get_mode(const char *str)
--
2.7.4



2017-07-27 11:23:40

by ERAMOTO Masaya

[permalink] [raw]
Subject: [PATCH Bluez 5/6] core: Add checking for unknown GATT options

This adds to check for unknown GATT options.
---
src/main.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/src/main.c b/src/main.c
index 566a64c..2d00478 100644
--- a/src/main.c
+++ b/src/main.c
@@ -101,6 +101,11 @@ static const char * const policy_options[] = {
NULL
};

+static const char * const gatt_options[] = {
+ "Cache",
+ NULL
+};
+
GKeyFile *btd_get_main_conf(void)
{
return main_conf;
@@ -230,6 +235,7 @@ static void check_config(GKeyFile *config)

check_options(config, "General", supported_options);
check_options(config, "Policy", policy_options);
+ check_options(config, "GATT", gatt_options);
}

static int get_mode(const char *str)
--
2.7.4




2017-07-27 11:23:17

by ERAMOTO Masaya

[permalink] [raw]
Subject: [PATCH Bluez 4/6] core: Add checking for unknown Policy options

This adds to check for unknown Policy options.
---
src/main.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/src/main.c b/src/main.c
index 90ff6e7..566a64c 100644
--- a/src/main.c
+++ b/src/main.c
@@ -93,6 +93,14 @@ static const char * const supported_options[] = {
NULL
};

+static const char * const policy_options[] = {
+ "ReconnectUUIDs",
+ "ReconnectAttempts",
+ "ReconnectIntervals",
+ "AutoEnable",
+ NULL
+};
+
GKeyFile *btd_get_main_conf(void)
{
return main_conf;
@@ -221,6 +229,7 @@ static void check_config(GKeyFile *config)
g_strfreev(keys);

check_options(config, "General", supported_options);
+ check_options(config, "Policy", policy_options);
}

static int get_mode(const char *str)
--
2.7.4



2017-07-27 11:30:07

by ERAMOTO Masaya

[permalink] [raw]
Subject: [PATCH Bluez 3/6] core: Fix General options in main.conf

For supported_options struct,
- adds FastConnectable.
(That was added at 1cd65e52665cfbf939c923baea51748e359abfa5.)
- removes AlwaysPairable.
(That was removed at 12464916d39fa88f2ade96ccbc1d8efd6ea37789.)
---
src/main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main.c b/src/main.c
index 7482706..90ff6e7 100644
--- a/src/main.c
+++ b/src/main.c
@@ -80,7 +80,6 @@ static const char * const supported_options[] = {
"Name",
"Class",
"DiscoverableTimeout",
- "AlwaysPairable",
"PairableTimeout",
"AutoConnectTimeout",
"DeviceID",
@@ -89,6 +88,7 @@ static const char * const supported_options[] = {
"DebugKeys",
"ControllerMode",
"MultiProfile",
+ "FastConnectable",
"Privacy",
NULL
};
--
2.7.4



2017-07-27 11:22:10

by ERAMOTO Masaya

[permalink] [raw]
Subject: [PATCH Bluez 2/6] core: Split check_config() function

Split to check_config() and check_options() that checks main.conf options.
---
src/main.c | 50 ++++++++++++++++++++++++++++++--------------------
1 file changed, 30 insertions(+), 20 deletions(-)

diff --git a/src/main.c b/src/main.c
index 578b262..7482706 100644
--- a/src/main.c
+++ b/src/main.c
@@ -90,6 +90,7 @@ static const char * const supported_options[] = {
"ControllerMode",
"MultiProfile",
"Privacy",
+ NULL
};

GKeyFile *btd_get_main_conf(void)
@@ -163,6 +164,34 @@ static bt_gatt_cache_t parse_gatt_cache(const char *cache)
}
}

+static void check_options(GKeyFile *config, const char *group,
+ const char * const *options)
+{
+ char **keys;
+ int i;
+
+ keys = g_key_file_get_keys(config, group, NULL, NULL);
+
+ for (i = 0; keys != NULL && keys[i] != NULL; i++) {
+ bool found;
+ unsigned int j;
+
+ found = false;
+ for (j = 0; options != NULL && options[j] != NULL; j++) {
+ if (g_str_equal(keys[i], options[j])) {
+ found = true;
+ break;
+ }
+ }
+
+ if (!found)
+ warn("Unknown key %s for group %s in main.conf",
+ keys[i], group);
+ }
+
+ g_strfreev(keys);
+}
+
static void check_config(GKeyFile *config)
{
const char *valid_groups[] = { "General", "Policy", "GATT", NULL };
@@ -191,26 +220,7 @@ static void check_config(GKeyFile *config)

g_strfreev(keys);

- keys = g_key_file_get_keys(config, "General", NULL, NULL);
-
- for (i = 0; keys != NULL && keys[i] != NULL; i++) {
- bool found;
- unsigned int j;
-
- found = false;
- for (j = 0; j < G_N_ELEMENTS(supported_options); j++) {
- if (g_str_equal(keys[i], supported_options[j])) {
- found = true;
- break;
- }
- }
-
- if (!found)
- warn("Unknown key %s for group %s in main.conf",
- keys[i], "General");
- }
-
- g_strfreev(keys);
+ check_options(config, "General", supported_options);
}

static int get_mode(const char *str)
--
2.7.4



2017-07-27 11:21:35

by ERAMOTO Masaya

[permalink] [raw]
Subject: [PATCH Bluez 1/6] core: Add group information to warning message for main.conf

Into warning message for main.conf, this adds group information like:
bluetoothd[XXXX]: Unknown key PirableTimeout for group General in main.conf
---
src/main.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/main.c b/src/main.c
index b88cf11..578b262 100644
--- a/src/main.c
+++ b/src/main.c
@@ -206,7 +206,8 @@ static void check_config(GKeyFile *config)
}

if (!found)
- warn("Unknown key %s in main.conf", keys[i]);
+ warn("Unknown key %s for group %s in main.conf",
+ keys[i], "General");
}

g_strfreev(keys);
--
2.7.4