netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
To: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org, Sergey Lapin <slapin@ossfans.org>
Subject: [PATCH 15/17] ieee802154: add two nl802154 helpers
Date: Fri,  6 Nov 2009 15:39:39 +0300	[thread overview]
Message-ID: <1257511181-19403-16-git-send-email-dbaryshkov@gmail.com> (raw)
In-Reply-To: <1257511181-19403-1-git-send-email-dbaryshkov@gmail.com>

Add two nl802154 helpers: one for starting a reply message, one for sending.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 net/ieee802154/ieee802154.h |    5 +++++
 net/ieee802154/netlink.c    |   33 +++++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/net/ieee802154/ieee802154.h b/net/ieee802154/ieee802154.h
index 0790eb0..aadec42 100644
--- a/net/ieee802154/ieee802154.h
+++ b/net/ieee802154/ieee802154.h
@@ -38,8 +38,13 @@ void __exit ieee802154_nl_exit(void);
 		.dumpit	= _dump,			\
 	}
 
+struct genl_info;
+
 struct sk_buff *ieee802154_nl_create(int flags, u8 req);
 int ieee802154_nl_mcast(struct sk_buff *msg, unsigned int group);
+struct sk_buff *ieee802154_nl_new_reply(struct genl_info *info,
+		int flags, u8 req);
+int ieee802154_nl_reply(struct sk_buff *msg, struct genl_info *info);
 
 extern struct genl_family nl802154_family;
 int nl802154_mac_register(void);
diff --git a/net/ieee802154/netlink.c b/net/ieee802154/netlink.c
index 8a22173..33137b9 100644
--- a/net/ieee802154/netlink.c
+++ b/net/ieee802154/netlink.c
@@ -75,6 +75,39 @@ out:
 	return -ENOBUFS;
 }
 
+struct sk_buff *ieee802154_nl_new_reply(struct genl_info *info,
+		int flags, u8 req)
+{
+	void *hdr;
+	struct sk_buff *msg = nlmsg_new(NLMSG_GOODSIZE, GFP_ATOMIC);
+
+	if (!msg)
+		return NULL;
+
+	hdr = genlmsg_put_reply(msg, info,
+			&nl802154_family, flags, req);
+	if (!hdr) {
+		nlmsg_free(msg);
+		return NULL;
+	}
+
+	return msg;
+}
+
+int ieee802154_nl_reply(struct sk_buff *msg, struct genl_info *info)
+{
+	/* XXX: nlh is right at the start of msg */
+	void *hdr = genlmsg_data(NLMSG_DATA(msg->data));
+
+	if (genlmsg_end(msg, hdr) < 0)
+		goto out;
+
+	return genlmsg_reply(msg, info);
+out:
+	nlmsg_free(msg);
+	return -ENOBUFS;
+}
+
 int __init ieee802154_nl_init(void)
 {
 	int rc;
-- 
1.6.5


  parent reply	other threads:[~2009-11-06 12:41 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-06 12:39 [NEXT PULL 00/17] IEEE 802.15.4 stack updates Dmitry Eremin-Solenikov
2009-11-06 12:39 ` [PATCH 01/17] wpan-phy: add a helper to put the wpan_phy device Dmitry Eremin-Solenikov
2009-11-06 12:39 ` [PATCH 02/17] wpan-phy: add wpan-phy iteration functions Dmitry Eremin-Solenikov
2009-11-06 12:39 ` [PATCH 03/17] wpan-phy: init channel/page fields Dmitry Eremin-Solenikov
2009-11-06 12:39 ` [PATCH 04/17] wpan-phy: use snprintf to limit the amount of chars written Dmitry Eremin-Solenikov
2009-11-06 12:39 ` [PATCH 05/17] wpan-phy: allow specifying a per-page channel mask Dmitry Eremin-Solenikov
2009-11-06 12:39 ` [PATCH 06/17] wpan-phy: follow usual patter of devices registration Dmitry Eremin-Solenikov
2009-11-06 12:39 ` [PATCH 07/17] ieee802154: constify struct net_device in some operations Dmitry Eremin-Solenikov
2009-11-06 12:39 ` [PATCH 08/17] ieee802154: merge nl802154 and wpan-class in single module Dmitry Eremin-Solenikov
2009-11-06 12:39 ` [PATCH 09/17] ieee802154: split away MAC commands implementation Dmitry Eremin-Solenikov
2009-11-06 12:39 ` [PATCH 10/17] ieee802154: add LIST_PHY command support Dmitry Eremin-Solenikov
2009-11-06 12:39 ` [PATCH 11/17] fakehard: no need to export net_to_phy, make it static Dmitry Eremin-Solenikov
2009-11-06 12:39 ` [PATCH 12/17] fakehard: claim all 2.4 Ghz channels as supported Dmitry Eremin-Solenikov
2009-11-06 12:39 ` [PATCH 13/17] ieee802154: add an mlme_ops call to retrieve PHY object Dmitry Eremin-Solenikov
2009-11-06 12:39 ` [PATCH 14/17] fakehard: mlme_ops->get_phy implementation Dmitry Eremin-Solenikov
2009-11-06 12:39 ` Dmitry Eremin-Solenikov [this message]
2009-11-06 12:39 ` [PATCH 16/17] ieee802154: add PHY_NAME to LIST_IFACE command results Dmitry Eremin-Solenikov
2009-11-06 12:39 ` [PATCH 17/17] ieee802154: add support for creation/removal of logic interfaces Dmitry Eremin-Solenikov
2009-11-07  2:02 ` [NEXT PULL 00/17] IEEE 802.15.4 stack updates 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=1257511181-19403-16-git-send-email-dbaryshkov@gmail.com \
    --to=dbaryshkov@gmail.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=slapin@ossfans.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).