All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: patrik.flykt@linux.intel.com, linux-wpan@vger.kernel.org
Subject: [PATCH v2 5/7] build: Add IPSP plugin
Date: Thu, 26 Oct 2017 12:30:24 +0300	[thread overview]
Message-ID: <20171026093026.27952-6-luiz.dentz@gmail.com> (raw)
In-Reply-To: <20171026093026.27952-1-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This adds the initial plugin structure to handle IPSP profile.
---
 Makefile.plugins        |   5 ++
 configure.ac            |   4 ++
 profiles/network/ipsp.c | 132 ++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 141 insertions(+)
 create mode 100644 profiles/network/ipsp.c

diff --git a/Makefile.plugins b/Makefile.plugins
index 73377e532..b5127b697 100644
--- a/Makefile.plugins
+++ b/Makefile.plugins
@@ -53,6 +53,11 @@ builtin_sources += profiles/network/manager.c \
 			profiles/network/connection.c
 endif
 
+if IPSP
+builtin_modules += ipsp
+builtin_sources += profiles/network/ipsp.c
+endif
+
 if HID
 builtin_modules += input
 builtin_sources += profiles/input/manager.c \
diff --git a/configure.ac b/configure.ac
index 964101412..24489f7d2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -160,6 +160,10 @@ AC_ARG_ENABLE(network, AC_HELP_STRING([--disable-network],
 		[disable network profiles]), [enable_network=${enableval}])
 AM_CONDITIONAL(NETWORK, test "${enable_network}" != "no")
 
+AC_ARG_ENABLE(ipsp, AC_HELP_STRING([--disable-ipsp],
+		[disable ipsp profile]), [enable_ipsp=${enableval}])
+AM_CONDITIONAL(IPSP, test "${enable_ipsp}" != "no")
+
 AC_ARG_ENABLE(hid, AC_HELP_STRING([--disable-hid],
 		[disable HID profile]), [enable_hid=${enableval}])
 AM_CONDITIONAL(HID, test "${enable_hid}" != "no")
diff --git a/profiles/network/ipsp.c b/profiles/network/ipsp.c
new file mode 100644
index 000000000..2645b0598
--- /dev/null
+++ b/profiles/network/ipsp.c
@@ -0,0 +1,132 @@
+/*
+ *
+ *  BlueZ - Bluetooth protocol stack for Linux
+ *
+ *  Copyright (C) 2017 Intel Corporation
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <ctype.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <errno.h>
+
+#include "lib/bluetooth.h"
+#include "lib/hci.h"
+#include "lib/sdp.h"
+#include "lib/uuid.h"
+
+#include "src/shared/util.h"
+#include "src/shared/att.h"
+#include "src/shared/queue.h"
+#include "src/shared/gatt-db.h"
+#include "src/shared/gatt-client.h"
+#include "src/plugin.h"
+#include "src/adapter.h"
+#include "src/device.h"
+#include "src/profile.h"
+#include "src/service.h"
+#include "src/log.h"
+
+#define IPSP_UUID16 0x1820
+
+static int ipsp_probe(struct btd_service *service)
+{
+	struct btd_device *device = btd_service_get_device(service);
+	const char *path = device_get_path(device);
+
+	DBG("path %s", path);
+
+	return 0;
+}
+
+static void ipsp_remove(struct btd_service *service)
+{
+	struct btd_device *device = btd_service_get_device(service);
+	const char *path = device_get_path(device);
+
+	DBG("path %s", path);
+}
+
+static void foreach_ipsp_service(struct gatt_db_attribute *attr,
+						void *user_data)
+{
+	bool *found = user_data;
+
+	*found = true;
+}
+
+static int ipsp_accept(struct btd_service *service)
+{
+	struct btd_device *device = btd_service_get_device(service);
+	struct gatt_db *db = btd_device_get_gatt_db(device);
+	const char *path = device_get_path(device);
+	bool found = false;
+	bt_uuid_t ipsp_uuid;
+
+	DBG("path %s", path);
+
+	/* Handle the IPSP services */
+	bt_uuid16_create(&ipsp_uuid, IPSP_UUID16);
+	gatt_db_foreach_service(db, &ipsp_uuid, foreach_ipsp_service, &found);
+	if (!found) {
+		error("IPSP attribute not found");
+		return -EINVAL;
+	}
+
+	btd_service_connecting_complete(service, 0);
+
+	return 0;
+}
+
+static int ipsp_disconnect(struct btd_service *service)
+{
+	struct btd_device *device = btd_service_get_device(service);
+	const char *path = device_get_path(device);
+
+	DBG("path %s", path);
+
+	btd_service_disconnecting_complete(service, 0);
+
+	return 0;
+}
+
+static struct btd_profile ipsp_profile = {
+	.name		= "network-ipsp",
+	.remote_uuid	= IPSP_UUID,
+	.device_probe	= ipsp_probe,
+	.device_remove	= ipsp_remove,
+	.accept		= ipsp_accept,
+	.disconnect	= ipsp_disconnect,
+};
+
+static int ipsp_init(void)
+{
+	return btd_profile_register(&ipsp_profile);
+}
+
+static void ipsp_exit(void)
+{
+	btd_profile_unregister(&ipsp_profile);
+}
+
+BLUETOOTH_PLUGIN_DEFINE(ipsp, VERSION, BLUETOOTH_PLUGIN_PRIORITY_DEFAULT,
+			ipsp_init, ipsp_exit)
-- 
2.13.6


  parent reply	other threads:[~2017-10-26  9:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-26  9:30 [PATCH v2 0/7] 6LoWPAN userspace support Luiz Augusto von Dentz
2017-10-26  9:30 ` [PATCH v2 1/7] shared/io: Add io_recv Luiz Augusto von Dentz
2017-10-26  9:30 ` [PATCH v2 2/7] shared: Add initial code for 6LoWPAN Luiz Augusto von Dentz
2017-10-26  9:30 ` [PATCH v2 3/7] unit: Add initial test for bt_6lo Luiz Augusto von Dentz
2017-10-26  9:30 ` [PATCH v2 4/7] uuid: Add IPSP UUID Luiz Augusto von Dentz
2017-10-26  9:30 ` Luiz Augusto von Dentz [this message]
2017-10-26  9:30 ` [PATCH v2 6/7] ipsp: Connect to IPSP PSM Luiz Augusto von Dentz
2017-10-26  9:30 ` [PATCH v2 7/7] ipsp: Add support for bt_6lo Luiz Augusto von Dentz

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=20171026093026.27952-6-luiz.dentz@gmail.com \
    --to=luiz.dentz@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-wpan@vger.kernel.org \
    --cc=patrik.flykt@linux.intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.