diff options
Diffstat (limited to 'net/ieee802154/netlink.c')
| -rw-r--r-- | net/ieee802154/netlink.c | 78 | 
1 files changed, 52 insertions, 26 deletions
diff --git a/net/ieee802154/netlink.c b/net/ieee802154/netlink.c index c8097ae2482..26efcf4fd2f 100644 --- a/net/ieee802154/netlink.c +++ b/net/ieee802154/netlink.c @@ -44,7 +44,7 @@ struct genl_family nl802154_family = {  struct sk_buff *ieee802154_nl_create(int flags, u8 req)  {  	void *hdr; -	struct sk_buff *msg = nlmsg_new(NLMSG_GOODSIZE, GFP_ATOMIC); +	struct sk_buff *msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_ATOMIC);  	unsigned long f;  	if (!msg) @@ -64,13 +64,13 @@ struct sk_buff *ieee802154_nl_create(int flags, u8 req)  int ieee802154_nl_mcast(struct sk_buff *msg, unsigned int group)  { -	/* XXX: nlh is right at the start of msg */ -	void *hdr = genlmsg_data(NLMSG_DATA(msg->data)); +	struct nlmsghdr *nlh = nlmsg_hdr(msg); +	void *hdr = genlmsg_data(nlmsg_data(nlh));  	if (genlmsg_end(msg, hdr) < 0)  		goto out; -	return genlmsg_multicast(msg, 0, group, GFP_ATOMIC); +	return genlmsg_multicast(&nl802154_family, msg, 0, group, GFP_ATOMIC);  out:  	nlmsg_free(msg);  	return -ENOBUFS; @@ -80,7 +80,7 @@ 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); +	struct sk_buff *msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_ATOMIC);  	if (!msg)  		return NULL; @@ -97,8 +97,8 @@ struct sk_buff *ieee802154_nl_new_reply(struct genl_info *info,  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)); +	struct nlmsghdr *nlh = nlmsg_hdr(msg); +	void *hdr = genlmsg_data(nlmsg_data(nlh));  	if (genlmsg_end(msg, hdr) < 0)  		goto out; @@ -109,31 +109,57 @@ out:  	return -ENOBUFS;  } -int __init ieee802154_nl_init(void) -{ -	int rc; - -	rc = genl_register_family(&nl802154_family); -	if (rc) -		goto fail; - -	rc = nl802154_mac_register(); -	if (rc) -		goto fail; +static const struct genl_ops ieee8021154_ops[] = { +	/* see nl-phy.c */ +	IEEE802154_DUMP(IEEE802154_LIST_PHY, ieee802154_list_phy, +			ieee802154_dump_phy), +	IEEE802154_OP(IEEE802154_ADD_IFACE, ieee802154_add_iface), +	IEEE802154_OP(IEEE802154_DEL_IFACE, ieee802154_del_iface), +	/* see nl-mac.c */ +	IEEE802154_OP(IEEE802154_ASSOCIATE_REQ, ieee802154_associate_req), +	IEEE802154_OP(IEEE802154_ASSOCIATE_RESP, ieee802154_associate_resp), +	IEEE802154_OP(IEEE802154_DISASSOCIATE_REQ, ieee802154_disassociate_req), +	IEEE802154_OP(IEEE802154_SCAN_REQ, ieee802154_scan_req), +	IEEE802154_OP(IEEE802154_START_REQ, ieee802154_start_req), +	IEEE802154_DUMP(IEEE802154_LIST_IFACE, ieee802154_list_iface, +			ieee802154_dump_iface), +	IEEE802154_OP(IEEE802154_SET_MACPARAMS, ieee802154_set_macparams), +	IEEE802154_OP(IEEE802154_LLSEC_GETPARAMS, ieee802154_llsec_getparams), +	IEEE802154_OP(IEEE802154_LLSEC_SETPARAMS, ieee802154_llsec_setparams), +	IEEE802154_DUMP(IEEE802154_LLSEC_LIST_KEY, NULL, +			ieee802154_llsec_dump_keys), +	IEEE802154_OP(IEEE802154_LLSEC_ADD_KEY, ieee802154_llsec_add_key), +	IEEE802154_OP(IEEE802154_LLSEC_DEL_KEY, ieee802154_llsec_del_key), +	IEEE802154_DUMP(IEEE802154_LLSEC_LIST_DEV, NULL, +			ieee802154_llsec_dump_devs), +	IEEE802154_OP(IEEE802154_LLSEC_ADD_DEV, ieee802154_llsec_add_dev), +	IEEE802154_OP(IEEE802154_LLSEC_DEL_DEV, ieee802154_llsec_del_dev), +	IEEE802154_DUMP(IEEE802154_LLSEC_LIST_DEVKEY, NULL, +			ieee802154_llsec_dump_devkeys), +	IEEE802154_OP(IEEE802154_LLSEC_ADD_DEVKEY, ieee802154_llsec_add_devkey), +	IEEE802154_OP(IEEE802154_LLSEC_DEL_DEVKEY, ieee802154_llsec_del_devkey), +	IEEE802154_DUMP(IEEE802154_LLSEC_LIST_SECLEVEL, NULL, +			ieee802154_llsec_dump_seclevels), +	IEEE802154_OP(IEEE802154_LLSEC_ADD_SECLEVEL, +		      ieee802154_llsec_add_seclevel), +	IEEE802154_OP(IEEE802154_LLSEC_DEL_SECLEVEL, +		      ieee802154_llsec_del_seclevel), +}; -	rc = nl802154_phy_register(); -	if (rc) -		goto fail; +static const struct genl_multicast_group ieee802154_mcgrps[] = { +	[IEEE802154_COORD_MCGRP] = { .name = IEEE802154_MCAST_COORD_NAME, }, +	[IEEE802154_BEACON_MCGRP] = { .name = IEEE802154_MCAST_BEACON_NAME, }, +}; -	return 0; -fail: -	genl_unregister_family(&nl802154_family); -	return rc; +int __init ieee802154_nl_init(void) +{ +	return genl_register_family_with_ops_groups(&nl802154_family, +						    ieee8021154_ops, +						    ieee802154_mcgrps);  }  void __exit ieee802154_nl_exit(void)  {  	genl_unregister_family(&nl802154_family);  } -  | 
