netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Aring <aar-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
To: linux-wpan-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: kernel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org,
	marcel-kz+m5ild9QBg9hUCZPvPmw@public.gmane.org,
	jukka.rissanen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org,
	hannes-tFNcAqjVMyqKXQKiL6tip0B+6BGkLq7r@public.gmane.org,
	stefan-JPH+aEBZ4P+UEJcrhfAQsw@public.gmane.org,
	mcr-SWp7JaYWvAQV+D8aMU/kSg@public.gmane.org,
	werner-SEdMjqphH88wryQfseakQg@public.gmane.org,
	linux-bluetooth-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Alexander Aring <aar-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
Subject: [RFC 11/12] 6lowpan: add support for getting short address
Date: Mon, 23 May 2016 21:22:07 +0200	[thread overview]
Message-ID: <1464031328-17524-12-git-send-email-aar@pengutronix.de> (raw)
In-Reply-To: <1464031328-17524-1-git-send-email-aar-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>

In case of sending RA messages we need some way to get the short address
from an 802.15.4 6LoWPAN interface. This patch will add a temporary
debugfs entry for experimental userspace api.

Signed-off-by: Alexander Aring <aar-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
---
 net/6lowpan/debugfs.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/net/6lowpan/debugfs.c b/net/6lowpan/debugfs.c
index acbaa3d..638ae59 100644
--- a/net/6lowpan/debugfs.c
+++ b/net/6lowpan/debugfs.c
@@ -245,6 +245,37 @@ static const struct file_operations lowpan_context_fops = {
 	.release	= single_release,
 };
 
+static int lowpan_short_addr_get(void *data, u64 *val)
+{
+	struct wpan_dev *wdev = data;
+
+	rtnl_lock();
+	*val = le16_to_cpu(wdev->short_addr);
+	rtnl_unlock();
+
+	return 0;
+}
+
+DEFINE_SIMPLE_ATTRIBUTE(lowpan_short_addr_fops, lowpan_short_addr_get,
+			NULL, "0x%04llx\n");
+
+static int lowpan_dev_debugfs_802154_init(const struct net_device *dev,
+					  struct lowpan_dev *ldev)
+{
+	struct dentry *dentry;
+
+	if (!lowpan_is_ll(dev, LOWPAN_LLTYPE_IEEE802154))
+		return 0;
+
+	dentry = debugfs_create_file("short_addr", 0444, ldev->iface_debugfs,
+				     lowpan_802154_dev(dev)->wdev->ieee802154_ptr,
+				     &lowpan_short_addr_fops);
+	if (!dentry)
+		return -EINVAL;
+
+	return 0;
+}
+
 int lowpan_dev_debugfs_init(struct net_device *dev)
 {
 	struct lowpan_dev *ldev = lowpan_dev(dev);
@@ -272,6 +303,10 @@ int lowpan_dev_debugfs_init(struct net_device *dev)
 			goto remove_root;
 	}
 
+	ret = lowpan_dev_debugfs_802154_init(dev, ldev);
+	if (ret < 0)
+		goto remove_root;
+
 	return 0;
 
 remove_root:
-- 
2.8.2

  parent reply	other threads:[~2016-05-23 19:22 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-23 19:21 [RFC 00/12] 6lowpan: introduce 6lowpan-nd Alexander Aring
2016-05-23 19:21 ` [RFC 02/12] 6lowpan: add 802.15.4 short addr slaac Alexander Aring
2016-05-23 19:22 ` [RFC 06/12] ndisc: get rid off dev parameter in ndisc_fill_addr_option Alexander Aring
2016-05-23 19:22 ` [RFC 07/12] addrconf: put prefix address add in an own function Alexander Aring
2016-05-27  9:45   ` Stefan Schmidt
2016-05-27 11:41     ` Alexander Aring
2016-05-27 13:17       ` Stefan Schmidt
2016-05-23 19:22 ` [RFC 08/12] ipv6: introduce neighbour discovery ops Alexander Aring
     [not found]   ` <1464031328-17524-9-git-send-email-aar-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2016-05-25  5:33     ` YOSHIFUJI Hideaki
2016-05-23 19:22 ` [RFC 09/12] ipv6: export several functions Alexander Aring
2016-05-27  9:56   ` Stefan Schmidt
     [not found] ` <1464031328-17524-1-git-send-email-aar-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2016-05-23 19:21   ` [RFC 01/12] 6lowpan: add private neighbour data Alexander Aring
2016-05-23 19:21   ` [RFC 03/12] 6lowpan: remove ipv6 module request Alexander Aring
2016-05-23 19:22   ` [RFC 04/12] ndisc: get rid off dev parameter in ndisc_opt_addr_space Alexander Aring
     [not found]     ` <1464031328-17524-5-git-send-email-aar-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2016-05-25  5:15       ` YOSHIFUJI Hideaki
2016-05-27 16:56         ` Hannes Frederic Sowa
2016-05-27 18:54           ` Alexander Aring
2016-05-23 19:22   ` [RFC 05/12] ndisc: get rid off dev parameter in ndisc_opt_addr_data Alexander Aring
2016-05-23 19:22   ` [RFC 10/12] 6lowpan: introduce 6lowpan-nd Alexander Aring
2016-05-27 10:16     ` Stefan Schmidt
2016-05-23 19:22   ` Alexander Aring [this message]
2016-05-27 10:05     ` [RFC 11/12] 6lowpan: add support for getting short address Stefan Schmidt
2016-05-27 11:03       ` Alexander Aring
2016-05-27 13:20         ` Stefan Schmidt
2016-05-23 19:22   ` [RFC 12/12] 6lowpan: add support for 802.15.4 short addr handling Alexander Aring
2016-05-25  5:13   ` [RFC 00/12] 6lowpan: introduce 6lowpan-nd YOSHIFUJI Hideaki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1464031328-17524-12-git-send-email-aar@pengutronix.de \
    --to=aar-bicnvbalz9megne8c9+irq@public.gmane.org \
    --cc=hannes-tFNcAqjVMyqKXQKiL6tip0B+6BGkLq7r@public.gmane.org \
    --cc=jukka.rissanen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
    --cc=kernel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org \
    --cc=linux-bluetooth-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-wpan-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=marcel-kz+m5ild9QBg9hUCZPvPmw@public.gmane.org \
    --cc=mcr-SWp7JaYWvAQV+D8aMU/kSg@public.gmane.org \
    --cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=stefan-JPH+aEBZ4P+UEJcrhfAQsw@public.gmane.org \
    --cc=werner-SEdMjqphH88wryQfseakQg@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).