diff options
author | Ayala Beker <ayala.beker@intel.com> | 2016-09-20 10:31:18 -0400 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2016-09-30 07:21:37 -0400 |
commit | 368e5a7b4ecb71b3d347799cb9351b0dce5dec70 (patch) | |
tree | cda90e8ee392418e6471d920a7043f1b55e72e5e /net/wireless | |
parent | 50bcd31d9992e99c231820f5276e70346cbfbc51 (diff) |
cfg80211: Provide an API to report NAN function termination
Provide a function that reports NAN DE function termination. The function
may be terminated due to one of the following reasons: user request,
ttl expiration or failure.
If the NAN instance is tied to the owner, the notification will be
sent to the socket that started the NAN interface only
Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/wireless')
-rw-r--r-- | net/wireless/nl80211.c | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 0bbd9ed28318..92eb6f0b9f3d 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c | |||
@@ -11033,6 +11033,66 @@ nla_put_failure: | |||
11033 | } | 11033 | } |
11034 | EXPORT_SYMBOL(cfg80211_nan_match); | 11034 | EXPORT_SYMBOL(cfg80211_nan_match); |
11035 | 11035 | ||
11036 | void cfg80211_nan_func_terminated(struct wireless_dev *wdev, | ||
11037 | u8 inst_id, | ||
11038 | enum nl80211_nan_func_term_reason reason, | ||
11039 | u64 cookie, gfp_t gfp) | ||
11040 | { | ||
11041 | struct wiphy *wiphy = wdev->wiphy; | ||
11042 | struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy); | ||
11043 | struct sk_buff *msg; | ||
11044 | struct nlattr *func_attr; | ||
11045 | void *hdr; | ||
11046 | |||
11047 | if (WARN_ON(!inst_id)) | ||
11048 | return; | ||
11049 | |||
11050 | msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp); | ||
11051 | if (!msg) | ||
11052 | return; | ||
11053 | |||
11054 | hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_DEL_NAN_FUNCTION); | ||
11055 | if (!hdr) { | ||
11056 | nlmsg_free(msg); | ||
11057 | return; | ||
11058 | } | ||
11059 | |||
11060 | if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || | ||
11061 | (wdev->netdev && nla_put_u32(msg, NL80211_ATTR_IFINDEX, | ||
11062 | wdev->netdev->ifindex)) || | ||
11063 | nla_put_u64_64bit(msg, NL80211_ATTR_WDEV, wdev_id(wdev), | ||
11064 | NL80211_ATTR_PAD)) | ||
11065 | goto nla_put_failure; | ||
11066 | |||
11067 | if (nla_put_u64_64bit(msg, NL80211_ATTR_COOKIE, cookie, | ||
11068 | NL80211_ATTR_PAD)) | ||
11069 | goto nla_put_failure; | ||
11070 | |||
11071 | func_attr = nla_nest_start(msg, NL80211_ATTR_NAN_FUNC); | ||
11072 | if (!func_attr) | ||
11073 | goto nla_put_failure; | ||
11074 | |||
11075 | if (nla_put_u8(msg, NL80211_NAN_FUNC_INSTANCE_ID, inst_id) || | ||
11076 | nla_put_u8(msg, NL80211_NAN_FUNC_TERM_REASON, reason)) | ||
11077 | goto nla_put_failure; | ||
11078 | |||
11079 | nla_nest_end(msg, func_attr); | ||
11080 | genlmsg_end(msg, hdr); | ||
11081 | |||
11082 | if (!wdev->owner_nlportid) | ||
11083 | genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), | ||
11084 | msg, 0, NL80211_MCGRP_NAN, gfp); | ||
11085 | else | ||
11086 | genlmsg_unicast(wiphy_net(&rdev->wiphy), msg, | ||
11087 | wdev->owner_nlportid); | ||
11088 | |||
11089 | return; | ||
11090 | |||
11091 | nla_put_failure: | ||
11092 | nlmsg_free(msg); | ||
11093 | } | ||
11094 | EXPORT_SYMBOL(cfg80211_nan_func_terminated); | ||
11095 | |||
11036 | static int nl80211_get_protocol_features(struct sk_buff *skb, | 11096 | static int nl80211_get_protocol_features(struct sk_buff *skb, |
11037 | struct genl_info *info) | 11097 | struct genl_info *info) |
11038 | { | 11098 | { |