From patchwork Thu Feb 16 17:19:42 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: 9577753 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 F2B3960244 for ; Thu, 16 Feb 2017 17:19:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E52932864C for ; Thu, 16 Feb 2017 17:19:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DA4F52864F; Thu, 16 Feb 2017 17:19:55 +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 CB8F62864C for ; Thu, 16 Feb 2017 17:19:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932499AbdBPRTy (ORCPT ); Thu, 16 Feb 2017 12:19:54 -0500 Received: from mail-lf0-f68.google.com ([209.85.215.68]:33671 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932505AbdBPRTw (ORCPT ); Thu, 16 Feb 2017 12:19:52 -0500 Received: by mail-lf0-f68.google.com with SMTP id x1so1992548lff.0; Thu, 16 Feb 2017 09:19:51 -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=m6FIAszU66p4TqgmQoEw/lgNm+/K+zK3lwOXtZ7IC1v6+CpgD+SBDnRBOmg0/W50kr j/GZvc123OQ8xmLCaWtWEl7mMMbS5BzVH2LmqVWfw7obYaXo890pkJo41gQVmz6SXiRx 18HMLJBeXd6ZVm533EW60XN34Mp4tj/wk/XUsr74E2DMBNK3t+OqUPrD81DsLGyzMr48 ryJ9gxKo6TPsCIyR7BfZ0knx8PhBDJqu7eOkRKzKksdrHLPVa3TPGhuS+QyyYBCo15k3 On0BdxIdOteN1A+LqiIgMv32/lXqT+lhBDqKO+4ZlelsRuH12kDiwE6M1NRkO1/D0oto y7Vw== 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=DcGR9aGENZF5yOxIlyt6E81xZmQE2Pg1l0ljjOG8XPuu+ixF72jg+2tvDT6qEhTlz/ wLb6xrGY7ueSGFZer7CJarbbo+Gr5hKltyGlcCorU88iK6p4PmPZa35Sw7XiIwJSFqbw N4OhM2dJwLlSs7kfZkqJBgyTR+ha6DHd9rAeIppcNS7nRSZ0AR4CPZYZFKK7D0i1rNrg JSOM7NPuI7UIrkAw4k1TJNWT8wbkl5iDtkZcYyM67FHRoHXPurtsnJChp7IWZJSAIccr TbKlwIB3fDkrxTjgfhMIcxz5L+9YXE7PUvkQmnWo+Y0xm48QE2TPbSKy1/cV1QLzMXWL PXQQ== X-Gm-Message-State: AMke39kcHl7Zx60nOSxb9UBhBbk/my0ICp0prABR0U72CoUklOCcnUYdYoBnGt7e7kNPEw== X-Received: by 10.46.87.12 with SMTP id l12mr984130ljb.106.1487265590359; Thu, 16 Feb 2017 09:19:50 -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 187sm1874292ljj.7.2017.02.16.09.19.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Feb 2017 09:19:49 -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 v2 1/5] bluetooth: Set 6 byte device addresses Date: Thu, 16 Feb 2017 19:19:42 +0200 Message-Id: <20170216171946.5105-2-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170216171946.5105-1-luiz.dentz@gmail.com> References: <20170216171946.5105-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 --- 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);