diff options
author | Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> | 2009-11-04 10:05:38 -0500 |
---|---|---|
committer | Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> | 2009-11-06 06:32:21 -0500 |
commit | 339b4ca5f68c7fd02eae54e9ce49c4b5f5d8b545 (patch) | |
tree | 207c98a3bc33089269ae3021712cbc4393cd1b58 /net | |
parent | 405cd39f331826d344f5f55bac5dbbc10a1c2813 (diff) |
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')
-rw-r--r-- | net/ieee802154/ieee802154.h | 5 | ||||
-rw-r--r-- | 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 0790eb06d682..aadec428e6ec 100644 --- a/net/ieee802154/ieee802154.h +++ b/net/ieee802154/ieee802154.h | |||
@@ -38,8 +38,13 @@ void __exit ieee802154_nl_exit(void); | |||
38 | .dumpit = _dump, \ | 38 | .dumpit = _dump, \ |
39 | } | 39 | } |
40 | 40 | ||
41 | struct genl_info; | ||
42 | |||
41 | struct sk_buff *ieee802154_nl_create(int flags, u8 req); | 43 | struct sk_buff *ieee802154_nl_create(int flags, u8 req); |
42 | int ieee802154_nl_mcast(struct sk_buff *msg, unsigned int group); | 44 | int ieee802154_nl_mcast(struct sk_buff *msg, unsigned int group); |
45 | struct sk_buff *ieee802154_nl_new_reply(struct genl_info *info, | ||
46 | int flags, u8 req); | ||
47 | int ieee802154_nl_reply(struct sk_buff *msg, struct genl_info *info); | ||
43 | 48 | ||
44 | extern struct genl_family nl802154_family; | 49 | extern struct genl_family nl802154_family; |
45 | int nl802154_mac_register(void); | 50 | int nl802154_mac_register(void); |
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: | |||
75 | return -ENOBUFS; | 75 | return -ENOBUFS; |
76 | } | 76 | } |
77 | 77 | ||
78 | struct sk_buff *ieee802154_nl_new_reply(struct genl_info *info, | ||
79 | int flags, u8 req) | ||
80 | { | ||
81 | void *hdr; | ||
82 | struct sk_buff *msg = nlmsg_new(NLMSG_GOODSIZE, GFP_ATOMIC); | ||
83 | |||
84 | if (!msg) | ||
85 | return NULL; | ||
86 | |||
87 | hdr = genlmsg_put_reply(msg, info, | ||
88 | &nl802154_family, flags, req); | ||
89 | if (!hdr) { | ||
90 | nlmsg_free(msg); | ||
91 | return NULL; | ||
92 | } | ||
93 | |||
94 | return msg; | ||
95 | } | ||
96 | |||
97 | int ieee802154_nl_reply(struct sk_buff *msg, struct genl_info *info) | ||
98 | { | ||
99 | /* XXX: nlh is right at the start of msg */ | ||
100 | void *hdr = genlmsg_data(NLMSG_DATA(msg->data)); | ||
101 | |||
102 | if (genlmsg_end(msg, hdr) < 0) | ||
103 | goto out; | ||
104 | |||
105 | return genlmsg_reply(msg, info); | ||
106 | out: | ||
107 | nlmsg_free(msg); | ||
108 | return -ENOBUFS; | ||
109 | } | ||
110 | |||
78 | int __init ieee802154_nl_init(void) | 111 | int __init ieee802154_nl_init(void) |
79 | { | 112 | { |
80 | int rc; | 113 | int rc; |