Diff between c6851065bd47d2385a696de565b3ab7cf29f2c3a and 5c8816f0db64462a0f093b82c923c2d12dce95e0

Changed Files

File Additions Deletions Status
src/advertising.c +42 -10 modified

Full Patch

diff --git a/src/advertising.c b/src/advertising.c
index 3d4b15f..6f87dfc 100644
--- a/src/advertising.c
+++ b/src/advertising.c
@@ -874,6 +874,47 @@ static bool parse_discoverable_timeout(DBusMessageIter *iter,
 	return true;
 }
 
+static struct adv_secondary {
+	int flag;
+	const char *name;
+} secondary[] = {
+	{ MGMT_ADV_FLAG_SEC_1M, "1M" },
+	{ MGMT_ADV_FLAG_SEC_2M, "2M" },
+	{ MGMT_ADV_FLAG_SEC_CODED, "Codec" },
+	{ },
+};
+
+static bool parse_secondary(DBusMessageIter *iter,
+					struct btd_adv_client *client)
+{
+	const char *str;
+	struct adv_secondary *sec;
+
+	if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_STRING)
+		return false;
+
+	/* Reset secondary channels before parsing */
+	client->flags &= 0xfe00;
+
+	dbus_message_iter_get_basic(iter, &str);
+
+	for (sec = secondary; sec && sec->name; sec++) {
+		if (strcmp(str, sec->name))
+			continue;
+
+		if (!(client->manager->supported_flags & sec->flag))
+			return false;
+
+		DBG("Secondary Channel: %s", str);
+
+		client->flags |= sec->flag;
+
+		return true;
+	}
+
+	return false;
+}
+
 static struct adv_parser {
 	const char *name;
 	bool (*func)(DBusMessageIter *iter, struct btd_adv_client *client);
@@ -891,6 +932,7 @@ static struct adv_parser {
 	{ "Data", parse_data },
 	{ "Discoverable", parse_discoverable },
 	{ "DiscoverableTimeout", parse_discoverable_timeout },
+	{ "SecondaryChannel", parse_secondary },
 	{ },
 };
 
@@ -1234,16 +1276,6 @@ static gboolean get_supported_includes(const GDBusPropertyTable *property,
 	return TRUE;
 }
 
-static struct adv_secondary {
-	int flag;
-	const char *name;
-} secondary[] = {
-	{ MGMT_ADV_FLAG_SEC_1M, "1M" },
-	{ MGMT_ADV_FLAG_SEC_2M, "2M" },
-	{ MGMT_ADV_FLAG_SEC_CODED, "Codec" },
-	{ },
-};
-
 static void append_secondary(struct btd_adv_manager *manager,
 						DBusMessageIter *iter)
 {