From patchwork Fri Oct 20 10:22:34 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: 10019487 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 95D68602CB for ; Fri, 20 Oct 2017 10:22:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 860E8285F1 for ; Fri, 20 Oct 2017 10:22:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7B01628EE0; Fri, 20 Oct 2017 10:22:56 +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 AB95E28ED3 for ; Fri, 20 Oct 2017 10:22:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752971AbdJTKWy (ORCPT ); Fri, 20 Oct 2017 06:22:54 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:56466 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752808AbdJTKWq (ORCPT ); Fri, 20 Oct 2017 06:22:46 -0400 Received: by mail-lf0-f65.google.com with SMTP id 90so12650363lfs.13; Fri, 20 Oct 2017 03:22:45 -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=WZhBmR+uKkLKjlh5zAgZRxETB75GuU/VKIX52vUm6oCM+fO7/s/Up2EXz1hDPj7i/5 SxjhcpS/eQ2awfYhG/LePkfI1hnqLd9NUKpLA75D9Rk8mM0up4PmZvolwgWGGFSYi/tP EbN/tdC4DOlpPMUK0fodo5Plv39f4qyu/SlYSgKtOlySSoBe6Iq47lr1oYn7aADInO9E 0y2J9cz3s9jHx9L9gXiixmClkpYC8mzFtlBim/dHBV1ymeh1i9eVB+SAw6ORJ4ecvGms 2HXyAC8Fa3wda0d/OdXxEJwFVPPO0ChK+E4k5C+Nojae/1X36FwlPQQKy/tOtIYM0ilx wPXw== 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=IbutLbb7S1mYITM7AmB9bcYii++unhhpNmARPHubiYqgJ9ImgPmsZAt+biZVP1gOO4 jdC+7fL0wQfpR+K2QZxG6OCbbJe3rM0zTKKzV9VTZNU8Sf42iOnyJwqab9UaMusAWILb hE/u1+tfgF51rCloO9b2blJq8V60UkTWNTdfBXSa3dvHeIQMN4xBjyyl4KRVxO537yzl g4AXyeEj/3iJi1dNBzCMhP4VKnu7fym1dk6kVOXCTZYsoNmWN3GMwUiNfo3rA61sK1ew 12BezHnRk9vgGzKvOpVnJhQ4LzUNG5et0VhLEhSol74wfYD+FWkj7UkmZKiRZd8m0f64 9jbw== X-Gm-Message-State: AMCzsaWskuGk+jMufVgzaNXPWk69wQjiIspqnH+NOKQWsD3vlceOEsx4 NfFemAKmnA9JQ+crWyjzpoiGGb4I X-Google-Smtp-Source: ABhQp+QO0j0TZniVnKTQyFWk+7tDeQ006Go0ctkq3HywIKhpV/8ajQNOJmJPFJRe4pffg6jU6Sb5NA== X-Received: by 10.25.83.76 with SMTP id h73mr1638391lfb.196.1508494964123; Fri, 20 Oct 2017 03:22:44 -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 z71sm168510lje.26.2017.10.20.03.22.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 20 Oct 2017 03:22:43 -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: [RFC 5/7] build: Add IPSP plugin Date: Fri, 20 Oct 2017 13:22:34 +0300 Message-Id: <20171020102236.17499-6-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171020102236.17499-1-luiz.dentz@gmail.com> References: <20171020102236.17499-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)