From patchwork Fri Feb 24 12:14:35 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: 9590003 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 73071601AE for ; Fri, 24 Feb 2017 12:15:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 94E122872D for ; Fri, 24 Feb 2017 12:15:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 89C4028791; Fri, 24 Feb 2017 12:15: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 F373D2872D for ; Fri, 24 Feb 2017 12:15:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751214AbdBXMPY (ORCPT ); Fri, 24 Feb 2017 07:15:24 -0500 Received: from mail-lf0-f65.google.com ([209.85.215.65]:32861 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751218AbdBXMPB (ORCPT ); Fri, 24 Feb 2017 07:15:01 -0500 Received: by mail-lf0-f65.google.com with SMTP id j2so1349478lfe.0; Fri, 24 Feb 2017 04:14:44 -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=cJnIbToUxNuF5JmzyR6Wz1Zdqsn3N28YqPDP2aIam+iRfZD1HDLz5QjvidDDsgbzdd eBgvmcwxlJKFTqo4bXjlW3ERUlFcEy3t8QBSELqgar/FVK9LyJ+atkw/u37SSoxcvt4Q n9LGOzo0b2Z0m4yGTcwAIDxOvTuGwiS4U/Rrofyx2Vm+5cGrwm/nWg6qxy7eImGTQiE8 gFD98+k0dnvFFgG6eM2bl9spMG6TZyiHh4QoHcyrignmk/Y302+Uc2RraAeerKZFROq2 4nLHxrXh0Q5PQlSKQZPYEqwYAgg8PlNS3Jnqht+Tm5Yv6Tc7iRYjBWguhMZa6Y1VCj38 jfQw== 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=fTrg0brI6KDa/qMoLUJyEtlewK2UNcJrIi4+YYrETkOoGyJuI58jIlPaxmpa7xj0aR o9llRLiWESocT7tN/EiS+W8edHF/b3UxF+Cl8LRmhE/eQL7Uw0reap3ASxPhGeKXsOyW MiJ5EWcY0Eb/l9oUT1DDnglWT2PAtLZgDwocjVy/V58gMyYg7/jVntUjeoUvUmW3P74q wWU8QXd78qvs2YobuLG5VMiOvmRrUa2k7WrB2YF3+wkSgg2xf/RwPwJ4+rnPy33+AIjB s/yM/F+HcwyhxUYlyoA3N9Yp4tiWZb3Nl07qAgaNHrzFQU5i5uxnwWtZ9BNo1KCehDpD yJPw== X-Gm-Message-State: AMke39kNR0ZWpHSbax9JxDmQjhm1VXRRmc+wku0qEw75gyFTTKePLBIZn3p/cFKQSXUCLg== X-Received: by 10.25.205.3 with SMTP id d3mr767367lfg.65.1487938483432; Fri, 24 Feb 2017 04:14:43 -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 26sm8569196ljo.21.2017.02.24.04.14.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Feb 2017 04:14:42 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Cc: patrik.flykt@linux.intel.com, jukka.rissanen@linux.intel.com, stefan@osg.samsung.com, aar@pengutronix.de, linux-wpan@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v5 1/6] bluetooth: Set 6 byte device addresses Date: Fri, 24 Feb 2017 14:14:35 +0200 Message-Id: <20170224121440.32269-2-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170224121440.32269-1-luiz.dentz@gmail.com> References: <20170224121440.32269-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);