All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Aring <aar@pengutronix.de>
To: linux-wpan@vger.kernel.org
Cc: kernel@pengutronix.de, marcel@holtmann.org,
	jukka.rissanen@linux.intel.com, hannes@stressinduktion.org,
	stefan@osg.samsung.com, mcr@sandelman.ca, werner@almesberger.net,
	linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org,
	Alexander Aring <aar@pengutronix.de>
Subject: [PATCHv4 net-next 11/12] 6lowpan: add support for getting short address
Date: Wed, 15 Jun 2016 21:20:26 +0200	[thread overview]
Message-ID: <20160615192027.4064-12-aar@pengutronix.de> (raw)
In-Reply-To: <20160615192027.4064-1-aar@pengutronix.de>

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.

Reviewed-by: Stefan Schmidt <stefan@osg.samsung.com>
Signed-off-by: Alexander Aring <aar@pengutronix.de>
---
 net/6lowpan/debugfs.c | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/net/6lowpan/debugfs.c b/net/6lowpan/debugfs.c
index acbaa3d..24915e0 100644
--- a/net/6lowpan/debugfs.c
+++ b/net/6lowpan/debugfs.c
@@ -245,6 +245,41 @@ 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, *root;
+
+	if (!lowpan_is_ll(dev, LOWPAN_LLTYPE_IEEE802154))
+		return 0;
+
+	root = debugfs_create_dir("ieee802154", ldev->iface_debugfs);
+	if (!root)
+		return -EINVAL;
+
+	dentry = debugfs_create_file("short_addr", 0444, root,
+				     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 +307,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.3

  parent reply	other threads:[~2016-06-15 19:21 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-15 19:20 [PATCHv4 net-next 00/12] 6lowpan: introduce 6lowpan-nd Alexander Aring
2016-06-15 19:20 ` Alexander Aring
     [not found] ` <20160615192027.4064-1-aar-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2016-06-15 19:20   ` [PATCHv4 net-next 01/12] 6lowpan: add private neighbour data Alexander Aring
2016-06-15 19:20     ` Alexander Aring
2016-06-15 19:20   ` [PATCHv4 net-next 04/12] ndisc: add __ndisc_opt_addr_space function Alexander Aring
2016-06-15 19:20     ` Alexander Aring
     [not found]     ` <20160615192027.4064-5-aar-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2016-06-16 10:44       ` Hannes Frederic Sowa
2016-06-16 10:44         ` Hannes Frederic Sowa
2016-06-15 19:20   ` [PATCHv4 net-next 05/12] ndisc: add __ndisc_opt_addr_data function Alexander Aring
2016-06-15 19:20     ` Alexander Aring
     [not found]     ` <20160615192027.4064-6-aar-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2016-06-16 10:44       ` Hannes Frederic Sowa
2016-06-16 10:44         ` Hannes Frederic Sowa
2016-06-15 19:20   ` [PATCHv4 net-next 08/12] ipv6: introduce neighbour discovery ops Alexander Aring
2016-06-15 19:20     ` Alexander Aring
2016-06-15 19:20   ` [PATCHv4 net-next 09/12] ipv6: export several functions Alexander Aring
2016-06-15 19:20     ` Alexander Aring
2016-06-15 19:20 ` [PATCHv4 net-next 02/12] 6lowpan: add 802.15.4 short addr slaac Alexander Aring
2016-06-15 19:20 ` [PATCHv4 net-next 03/12] 6lowpan: remove ipv6 module request Alexander Aring
2016-06-15 19:20 ` [PATCHv4 net-next 06/12] ndisc: add __ndisc_fill_addr_option function Alexander Aring
     [not found]   ` <20160615192027.4064-7-aar-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2016-06-16 10:44     ` Hannes Frederic Sowa
2016-06-16 10:44       ` Hannes Frederic Sowa
2016-06-15 19:20 ` [PATCHv4 net-next 07/12] addrconf: put prefix address add in an own function Alexander Aring
2016-06-16 10:51   ` Hannes Frederic Sowa
2016-06-15 19:20 ` [PATCHv4 net-next 10/12] 6lowpan: introduce 6lowpan-nd Alexander Aring
2016-06-15 19:20 ` Alexander Aring [this message]
2016-06-15 19:20 ` [PATCHv4 net-next 12/12] 6lowpan: add support for 802.15.4 short addr handling Alexander Aring
2016-06-16  3:45 ` [PATCHv4 net-next 00/12] 6lowpan: introduce 6lowpan-nd David Miller

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=20160615192027.4064-12-aar@pengutronix.de \
    --to=aar@pengutronix.de \
    --cc=hannes@stressinduktion.org \
    --cc=jukka.rissanen@linux.intel.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-wpan@vger.kernel.org \
    --cc=marcel@holtmann.org \
    --cc=mcr@sandelman.ca \
    --cc=netdev@vger.kernel.org \
    --cc=stefan@osg.samsung.com \
    --cc=werner@almesberger.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.