All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luca Coelho <luca@coelho.fi>
To: johannes@sipsolutions.net
Cc: linux-wireless@vger.kernel.org,
	Ayala Beker <ayala.beker@intel.com>,
	Andrei Otcheretianski <andrei.otcheretianski@intel.com>,
	Emmanuel Grumbach <emmanuel.grumbach@intel.com>,
	Luca Coelho <luciano.coelho@intel.com>
Subject: [PATCH v2 6/9] cfg80211: Provide an API to report NAN function termination
Date: Fri, 16 Sep 2016 11:33:18 +0300	[thread overview]
Message-ID: <20160916083321.5840-7-luca@coelho.fi> (raw)
In-Reply-To: <20160916083321.5840-1-luca@coelho.fi>

From: Ayala Beker <ayala.beker@intel.com>

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>
---
 include/net/cfg80211.h       | 16 ++++++++++++
 include/uapi/linux/nl80211.h | 15 ++++++++++++
 net/wireless/nl80211.c       | 58 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 89 insertions(+)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index a08d7da..81770d6 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -5676,6 +5676,22 @@ struct cfg80211_nan_match_params {
 void cfg80211_nan_match(struct wireless_dev *wdev,
 			struct cfg80211_nan_match_params *match, gfp_t gfp);
 
+/**
+ * cfg80211_nan_func_terminated - notify about NAN function termination.
+ *
+ * @wdev: the wireless device reporting the match
+ * @inst_id: the local instance id
+ * @reason: termination reason (one of the NL80211_NAN_FUNC_TERM_REASON_*)
+ * @cookie: unique NAN function identifier
+ * @gfp: allocation flags
+ *
+ * This function reports that the a NAN function is terminated.
+ */
+void cfg80211_nan_func_terminated(struct wireless_dev *wdev,
+				  u8 inst_id,
+				  enum nl80211_nan_func_term_reason reason,
+				  u64 cookie, gfp_t gfp);
+
 /* ethtool helper */
 void cfg80211_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info);
 
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index badb4a6..fd86be6 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -4978,6 +4978,21 @@ enum nl80211_nan_publish_type {
 	NL80211_NAN_UNSOLICITED_PUBLISH = 1 << 1,
 };
 
+/**
+ * enum nl80211_nan_func_term_reason - NAN functions termination reason
+ *
+ * Defines termination reasons of a NAN function
+ *
+ * @NL80211_NAN_FUNC_TERM_REASON_USER_REQUEST: requested by user
+ * @NL80211_NAN_FUNC_TERM_REASON_TTL_EXPIRED: timeout
+ * @NL80211_NAN_FUNC_TERM_REASON_ERROR: errored
+ */
+enum nl80211_nan_func_term_reason {
+	NL80211_NAN_FUNC_TERM_REASON_USER_REQUEST,
+	NL80211_NAN_FUNC_TERM_REASON_TTL_EXPIRED,
+	NL80211_NAN_FUNC_TERM_REASON_ERROR,
+};
+
 #define NL80211_NAN_FUNC_SERVICE_ID_LEN 6
 #define NL80211_NAN_FUNC_SERVICE_SPEC_INFO_MAX_LEN 0xff
 #define NL80211_NAN_FUNC_SRF_MAX_LEN 0xff
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 4d37717..f817105 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -10945,6 +10945,64 @@ nla_put_failure:
 }
 EXPORT_SYMBOL(cfg80211_nan_match);
 
+void cfg80211_nan_func_terminated(struct wireless_dev *wdev,
+				  u8 inst_id,
+				  enum nl80211_nan_func_term_reason reason,
+				  u64 cookie, gfp_t gfp)
+{
+	struct wiphy *wiphy = wdev->wiphy;
+	struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
+	struct sk_buff *msg;
+	struct nlattr *func_attr;
+	void *hdr;
+
+	if (WARN_ON(!inst_id))
+		return;
+
+	msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
+	if (!msg)
+		return;
+
+	hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_RM_NAN_FUNCTION);
+	if (!hdr) {
+		nlmsg_free(msg);
+		return;
+	}
+
+	if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
+	    (wdev->netdev && nla_put_u32(msg, NL80211_ATTR_IFINDEX,
+					 wdev->netdev->ifindex)) ||
+	    nla_put_u64(msg, NL80211_ATTR_WDEV, wdev_id(wdev)))
+		goto nla_put_failure;
+
+	if (nla_put_u64(msg, NL80211_ATTR_COOKIE, cookie))
+		goto nla_put_failure;
+
+	func_attr = nla_nest_start(msg, NL80211_ATTR_NAN_FUNC);
+	if (!func_attr)
+		goto nla_put_failure;
+
+	if (nla_put_u8(msg, NL80211_NAN_FUNC_INSTANCE_ID, inst_id) ||
+	    nla_put_u8(msg, NL80211_NAN_FUNC_TERM_REASON, reason))
+		goto nla_put_failure;
+
+	nla_nest_end(msg, func_attr);
+	genlmsg_end(msg, hdr);
+
+	if (!wdev->owner_nlportid)
+		genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy),
+					msg, 0, NL80211_MCGRP_NAN, gfp);
+	else
+		genlmsg_unicast(wiphy_net(&rdev->wiphy), msg,
+				wdev->owner_nlportid);
+
+	return;
+
+nla_put_failure:
+	nlmsg_free(msg);
+}
+EXPORT_SYMBOL(cfg80211_nan_func_terminated);
+
 static int nl80211_get_protocol_features(struct sk_buff *skb,
 					 struct genl_info *info)
 {
-- 
2.9.3

  parent reply	other threads:[~2016-09-16  8:33 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-16  8:33 [PATCH v2 0/9] Add support for Neighbor Awareness Networking Luca Coelho
2016-09-16  8:33 ` [PATCH v2 1/9] cfg80211: add start / stop NAN commands Luca Coelho
2016-09-16 10:58   ` Arend Van Spriel
2016-09-16 11:00     ` Johannes Berg
2016-09-18  7:44     ` Otcheretianski, Andrei
2016-09-18 18:54       ` Arend Van Spriel
2016-09-19  7:25         ` Otcheretianski, Andrei
2016-09-16  8:33 ` [PATCH v2 2/9] mac80211: add boilerplate code for start / stop NAN Luca Coelho
2016-09-16 11:08   ` Arend Van Spriel
2016-09-18  7:59     ` Otcheretianski, Andrei
2016-09-18 19:01       ` Arend Van Spriel
2016-09-20 11:45         ` Beker, Ayala
2016-09-20 12:29           ` Arend Van Spriel
2016-09-20 14:36             ` Luca Coelho
2016-09-21  8:00               ` Arend Van Spriel
2016-09-16  8:33 ` [PATCH v2 3/9] cfg80211: add add_nan_func / rm_nan_func Luca Coelho
2016-09-16 10:46   ` kbuild test robot
2016-09-16 12:20   ` kbuild test robot
2016-09-18 19:28   ` Arend Van Spriel
2016-09-19  7:56     ` Otcheretianski, Andrei
2016-09-18 19:54   ` Arend Van Spriel
2016-09-19  8:09     ` Otcheretianski, Andrei
2016-09-16  8:33 ` [PATCH v2 4/9] cfg80211: allow the user space to change current NAN configuration Luca Coelho
2016-09-18 19:43   ` Arend Van Spriel
2016-09-19  8:07     ` Otcheretianski, Andrei
2016-09-16  8:33 ` [PATCH v2 5/9] cfg80211: provide a function to report a match for NAN Luca Coelho
2016-09-16  8:33 ` Luca Coelho [this message]
2016-09-18 19:56   ` [PATCH v2 6/9] cfg80211: Provide an API to report NAN function termination Arend Van Spriel
2016-09-18 20:00     ` Arend Van Spriel
2016-09-19  8:54       ` Otcheretianski, Andrei
2016-09-16  8:33 ` [PATCH v2 7/9] mac80211: implement nan_change_conf Luca Coelho
2016-09-16  8:33 ` [PATCH v2 8/9] mac80211: Implement add_nan_func and rm_nan_func Luca Coelho
2016-09-16  8:33 ` [PATCH v2 9/9] mac80211: Add API to report NAN function match Luca Coelho
2016-09-16  9:00 ` [PATCH v2 0/9] Add support for Neighbor Awareness Networking Arend Van Spriel
2016-09-16 10:26   ` Luca Coelho

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160916083321.5840-7-luca@coelho.fi \
    --to=luca@coelho.fi \
    --cc=andrei.otcheretianski@intel.com \
    --cc=ayala.beker@intel.com \
    --cc=emmanuel.grumbach@intel.com \
    --cc=johannes@sipsolutions.net \
    --cc=linux-wireless@vger.kernel.org \
    --cc=luciano.coelho@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.