diff options
author | Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> | 2009-11-04 16:05:38 +0100 |
---|---|---|
committer | Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> | 2009-11-06 12:32:21 +0100 |
commit | 339b4ca5f68c7fd02eae54e9ce49c4b5f5d8b545 (patch) | |
tree | 207c98a3bc33089269ae3021712cbc4393cd1b58 /net/ieee802154/netlink.c | |
parent | fakehard: mlme_ops->get_phy implementation (diff) | |
download | linux-339b4ca5f68c7fd02eae54e9ce49c4b5f5d8b545.tar.xz linux-339b4ca5f68c7fd02eae54e9ce49c4b5f5d8b545.zip |
ieee802154: add two nl802154 helpers
Add two nl802154 helpers: one for starting a reply message, one for sending.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Diffstat (limited to 'net/ieee802154/netlink.c')
-rw-r--r-- | net/ieee802154/netlink.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/net/ieee802154/netlink.c b/net/ieee802154/netlink.c index 8a221737f75c..33137b99e471 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; |