From patchwork Thu Oct 26 09:30:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 10027903 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C83AF6032C for ; Thu, 26 Oct 2017 09:30:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BCD6328D94 for ; Thu, 26 Oct 2017 09:30:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B1A9628D89; Thu, 26 Oct 2017 09:30:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 033DF28D75 for ; Thu, 26 Oct 2017 09:30:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751961AbdJZJal (ORCPT ); Thu, 26 Oct 2017 05:30:41 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:55205 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751476AbdJZJaf (ORCPT ); Thu, 26 Oct 2017 05:30:35 -0400 Received: by mail-lf0-f68.google.com with SMTP id a2so2951360lfh.11; Thu, 26 Oct 2017 02:30:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0obxS5O0Jx9DBnQlKWmoWoK4XlPoUhQzDrb/w695QUg=; b=e/JuCsoMxbiCdF6Hqpy09Z8v6ClmqPGWFetYBNbb53i6W5+wWe0APJDCEUW0oZDv2m ri41xrtivtVpksE9SAMYxvOkSZXSTyaVncLjilp/8qIl2JoujoiXD5C4X8GC6cMMeOco c5rm3kbtlxyEPeucD4TqJC2V+S67zLAhtja7eUJpazdiJtn4tf9iS7XmmuZo791BsKMK 1z4R676sWYSSP0rlpcNcu6FEvAl4SCpgWIMsNM0xMJ3slWGJl1fusYtktvj2ONHPjAY2 oARRxIRkxh7KF4N2oxBZkG2sTx5h3e0FRWwckQPnvXe+MO4uqr7rW3Y/paEDtdWJFfxM PT8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=0obxS5O0Jx9DBnQlKWmoWoK4XlPoUhQzDrb/w695QUg=; b=moQI9lN1yciPc4IvqpFitj9BarlC05r0SnanGw4rqYLqnp87nQUOxQ1pzMb8oRy0CG V08YFtadkv5lO/STqBpQ0Jj8rp/xEDBzuJkRQmWdN32bpanDZL9GkrzUjqu2mX/v79x0 rhF8zCEsEH+/124XAlEuvlXk2EFw9xlKFObjNHOWompTg9dZYmTM6ywMKY18Uiqp2x6Z TFkHxcDpbxAP2dWp+qxgs1oQTt//7ju2sDPt/Dy9wBX+ndJ3+R59HaujHH85GqfCV0y6 fuRrIlE8gvux68lXmH3ThMMhhmNneDLe5nArDxLlpgMFrf4Sc013nS3ujYlrNIPCah6u efdg== X-Gm-Message-State: AMCzsaWxBzzZD49C8JLanU5dJi1IaI/ZltiELgSLjw94CrAEAxcFbnfD 4FLDIDDyQaE6iRtoNzP3eQ6jB9rc X-Google-Smtp-Source: ABhQp+TJxg0ijxmh/b4nUVp5YC+GuqRDSXok1fcE2tfln74s0iNJoYZKrS7wsadGyOs5c3gP8uQu2Q== X-Received: by 10.25.204.211 with SMTP id c202mr7607096lfg.220.1509010233539; Thu, 26 Oct 2017 02:30:33 -0700 (PDT) Received: from vudentzs-t460s.pp.htv.fi (89-27-7-11.bb.dnainternet.fi. [89.27.7.11]) by smtp.gmail.com with ESMTPSA id p28sm1322691lje.13.2017.10.26.02.30.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 26 Oct 2017 02:30:32 -0700 (PDT) From: Luiz Augusto von Dentz 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 Message-Id: <20171026093026.27952-6-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171026093026.27952-1-luiz.dentz@gmail.com> References: <20171026093026.27952-1-luiz.dentz@gmail.com> Sender: linux-wpan-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wpan@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Luiz Augusto von Dentz 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 +#endif + +#include +#include +#include +#include + +#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)