Skip to content

Commit

Permalink
ieee802154: add two nl802154 helpers
Browse files Browse the repository at this point in the history
Add two nl802154 helpers: one for starting a reply message, one for sending.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
  • Loading branch information
Dmitry Eremin-Solenikov committed Nov 6, 2009
1 parent 405cd39 commit 339b4ca
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
5 changes: 5 additions & 0 deletions net/ieee802154/ieee802154.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
33 changes: 33 additions & 0 deletions net/ieee802154/netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,39 @@ int ieee802154_nl_mcast(struct sk_buff *msg, unsigned int group)
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;
Expand Down

0 comments on commit 339b4ca

Please sign in to comment.