From patchwork Sun Mar 12 08:19:33 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: 9619267 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 9470060522 for ; Sun, 12 Mar 2017 08:19:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8544D28511 for ; Sun, 12 Mar 2017 08:19:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7A2F328520; Sun, 12 Mar 2017 08:19:59 +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 289BB28514 for ; Sun, 12 Mar 2017 08:19:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933698AbdCLITw (ORCPT ); Sun, 12 Mar 2017 04:19:52 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:33762 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754372AbdCLITo (ORCPT ); Sun, 12 Mar 2017 04:19:44 -0400 Received: by mail-lf0-f66.google.com with SMTP id r36so9716339lfi.0; Sun, 12 Mar 2017 00:19:42 -0800 (PST) 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=eHPOtmwgaWs0ct/wypRi8S74EZwv8OU2ZNScjhjIkl8=; b=R2LYp3K5lAEawenSaWdg18rjnssoC1xuxQe6VVCOk3Mrqx6rDs+46NCi/Zx0idGAEC ymXhrKW+tKJ7z/zUWi52YmxOv2YDoE05vYOKHtSPKO2UWZjVO3m48gl4KRV3xQhm67mh tEIkFiGcG7ilvZ/iPe1B9uQPCsekqgKi/4b7zOfOmoV+bRXA5MknQ0r9UITJElxEqSBx JONCv2P1wFfZsjfJWg4DB7YtNHMoosLvLYl9Qzsvgy9Wt2TU82fpCzZTafQ74xER2Odd WFV1rnnbdWadSVI7Hk4f+JHi2d0x+jWHmwgrBlQaTYP7dTWTh78FOgtFA3nzPOy2epew AUdw== 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=eHPOtmwgaWs0ct/wypRi8S74EZwv8OU2ZNScjhjIkl8=; b=uffKDGXcheVvoxPN7RFAD9SJj0I8hcLMz7wEy9lzK0l065RagFOkpsIBwoKxx5CmER 3J92D5T1Rdz7e77D1k8MqDJIQ9QcVy5mmsvszmxF5LtFAjYW75YeKAAEhEDJfcMic/wN vwRDkVEx77CXnRDMbdFaW/osXJVwvw05MlgcgH/+TX2OeYcI11yiuvZgN98XVBh5NEI5 0XfVld7fXP9gWk4jLAstb/l0yVn81yw967rZ10azv8aFjnB+j4iNj5ve3KgU8TgL38ZE xFz+c4D6GyV8E8jt7G7D5z1rUQ2VyA9xUMYA/gsq+dzvQwNV+zu75sHFBdN4ihuPFkkP 5baA== X-Gm-Message-State: AMke39lfMZSuF79HMXMc/9d2zrc3CjOCEc1Yeuoiv5HkXL8EgGdGPkwU+8J6NCK63KdjFg== X-Received: by 10.25.162.211 with SMTP id l202mr6872982lfe.97.1489306781693; Sun, 12 Mar 2017 00:19:41 -0800 (PST) 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 i24sm2874937lfk.50.2017.03.12.00.19.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 12 Mar 2017 00:19:41 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Cc: patrik.flykt@linux.intel.com, aar@pengutronix.de, jukka.rissanen@linux.intel.com, linux-wpan@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v7 1/6] bluetooth: Set 6 byte device addresses Date: Sun, 12 Mar 2017 10:19:33 +0200 Message-Id: <20170312081938.11700-2-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170312081938.11700-1-luiz.dentz@gmail.com> References: <20170312081938.11700-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: Patrik Flykt Set BTLE MAC addresses that are 6 bytes long and not 8 bytes that are used in other places with 6lowpan. Signed-off-by: Patrik Flykt Signed-off-by: Luiz Augusto von Dentz Reviewed-by: Stefan Schmidt --- net/bluetooth/6lowpan.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c index 1904a93..1456b01 100644 --- a/net/bluetooth/6lowpan.c +++ b/net/bluetooth/6lowpan.c @@ -80,6 +80,8 @@ struct lowpan_btle_dev { struct delayed_work notify_peers; }; +static void set_addr(u8 *eui, u8 *addr, u8 addr_type); + static inline struct lowpan_btle_dev * lowpan_btle_dev(const struct net_device *netdev) { @@ -272,9 +274,10 @@ static int give_skb_to_upper(struct sk_buff *skb, struct net_device *dev) static int iphc_decompress(struct sk_buff *skb, struct net_device *netdev, struct l2cap_chan *chan) { - const u8 *saddr, *daddr; + const u8 *saddr; struct lowpan_btle_dev *dev; struct lowpan_peer *peer; + unsigned char eui64_daddr[EUI64_ADDR_LEN]; dev = lowpan_btle_dev(netdev); @@ -285,9 +288,9 @@ static int iphc_decompress(struct sk_buff *skb, struct net_device *netdev, return -EINVAL; saddr = peer->eui64_addr; - daddr = dev->netdev->dev_addr; + set_addr(&eui64_daddr[0], chan->src.b, chan->src_type); - return lowpan_header_decompress(skb, netdev, daddr, saddr); + return lowpan_header_decompress(skb, netdev, &eui64_daddr, saddr); } static int recv_pkt(struct sk_buff *skb, struct net_device *dev, @@ -681,13 +684,6 @@ static void set_addr(u8 *eui, u8 *addr, u8 addr_type) BT_DBG("type %d addr %*phC", addr_type, 8, eui); } -static void set_dev_addr(struct net_device *netdev, bdaddr_t *addr, - u8 addr_type) -{ - netdev->addr_assign_type = NET_ADDR_PERM; - set_addr(netdev->dev_addr, addr->b, addr_type); -} - static void ifup(struct net_device *netdev) { int err; @@ -803,7 +799,8 @@ static int setup_netdev(struct l2cap_chan *chan, struct lowpan_btle_dev **dev) if (!netdev) return -ENOMEM; - set_dev_addr(netdev, &chan->src, chan->src_type); + netdev->addr_assign_type = NET_ADDR_PERM; + baswap((void *)netdev->dev_addr, &chan->src); netdev->netdev_ops = &netdev_ops; SET_NETDEV_DEV(netdev, &chan->conn->hcon->hdev->dev);