From patchwork Fri Feb 17 15:49:59 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: 9580249 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 DD4416042F for ; Fri, 17 Feb 2017 15:50:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CFB0928721 for ; Fri, 17 Feb 2017 15:50:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C3DA128724; Fri, 17 Feb 2017 15:50:12 +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 727F228721 for ; Fri, 17 Feb 2017 15:50:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934635AbdBQPuL (ORCPT ); Fri, 17 Feb 2017 10:50:11 -0500 Received: from mail-lf0-f66.google.com ([209.85.215.66]:36603 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934226AbdBQPuK (ORCPT ); Fri, 17 Feb 2017 10:50:10 -0500 Received: by mail-lf0-f66.google.com with SMTP id h65so4122666lfi.3; Fri, 17 Feb 2017 07:50:10 -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=CxXHFAZYoZn4TbNLAfxobBQsUS92o1Sf+tJH0lL0FFQ=; b=vVDcdXT0IolQTZcgTVFDTenv/DqiCG0HSEih2JkTPoCBxb3NHkt6/HX7OW8bU+6pcA 4OtJCMSrDZJANfjhgMoB3E2VGWV4b6rAVUw2xb14uk38udocYgUSJx7bjhwjde5X91ma GoLboRjb6T50Wv31v9yzZfS/nP7zf/pQWSYU3Gk593cf10bEhJBD8AZr+sdAahgot3jM wyp4jVhaY+nadEZW7yihYzkQwzr1TVe13b9zeEIKhq768L2sEzJrG541rmxRHn7HFasA Bkfi0CiBsVGweuHrqQOctcS7cEH6b27bU2AZowTeWf1zkNFQQpcN7j5nEaIluPbfSZ+t IcLw== 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=CxXHFAZYoZn4TbNLAfxobBQsUS92o1Sf+tJH0lL0FFQ=; b=OVhqjYuPGuGYJtHdxkLoIfisIhhPmhhuBGvBtY9EHtPMAQZIWp2a+FKhxDQuwhWUtu +pK2bly11no8VbxOI2FYdWwXACMsej0zIa8PtI4JCylTUCRHpbtvA2VSP/WJYTWnNWf8 FqEFUL8FgWTRLo2Pb3b0EIXbsRXkxNexPulKZG7fZMJTy5ViFoztFhFhfINSexjusuXO d87Hevk7P4nSIU7O7uxcn9cYidn4kIpAh51SuKSrAtMuUP7VGU/v3IDM7E4mcHNIqppS XQC7OTSPkdYy2l26FE76pySPrg2Dh0+H0vnfQ257KPPugTy+feqSudNnO/jKexV+WkrU SYuw== X-Gm-Message-State: AMke39m4ACS0MfJj6KQ6bhzS4UE71WoVs5pTRWOJdUelJ6tMBJDAYFhJu9rNeE4HG/QLmg== X-Received: by 10.25.203.87 with SMTP id b84mr2468207lfg.158.1487346608874; Fri, 17 Feb 2017 07:50:08 -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 c18sm2600726ljd.52.2017.02.17.07.50.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Feb 2017 07:50:07 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Cc: patrik.flykt@linux.intel.com, aar@pengutronix.de, linux-wpan@vger.kernel.org Subject: [PATCH v3 1/5] bluetooth: Set 6 byte device addresses Date: Fri, 17 Feb 2017 17:49:59 +0200 Message-Id: <20170217155003.4594-2-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170217155003.4594-1-luiz.dentz@gmail.com> References: <20170217155003.4594-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);