linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iw: Use NL80211_FREQUENCY_ATTR_NO_IR channel attribute
@ 2013-11-12 15:46 Ilan Peer
  2013-11-13 18:23 ` Johannes Berg
  0 siblings, 1 reply; 3+ messages in thread
From: Ilan Peer @ 2013-11-12 15:46 UTC (permalink / raw)
  To: linux-wireless; +Cc: Ilan Peer

Align iw with the change in nl80211.h where NL80211_FREQUENCY_ATTR_NO_IBSS
and NL80211_FREQUENCY_ATTR_PASSIVE_SCAN were replaced by
NL80211_FREQUENCY_ATTR_NO_IR.

In case both NL80211_FREQUENCY_ATTR_NO_IR and __NL80211_FREQUENCY_ATTR_NO_IBSS
are set, assume that a new kernel is used and use the NO_IR notation,
otherwise use the previous notation.

This change requires nl80211.h with the new definitions

Signed-off-by: Ilan Peer <ilan.peer@intel.com>
---
 event.c |   24 ++++++++++++++----------
 info.c  |   18 ++++++++++++------
 reg.c   |   10 ++++++++--
 3 files changed, 34 insertions(+), 18 deletions(-)

diff --git a/event.c b/event.c
index 603b072..bfdb0fb 100644
--- a/event.c
+++ b/event.c
@@ -11,7 +11,7 @@ static int no_seq_check(struct nl_msg *msg, void *arg)
 
 struct ieee80211_beacon_channel {
 	__u16 center_freq;
-	bool passive_scan;
+	bool no_ir;
 	bool no_ibss;
 };
 
@@ -21,8 +21,8 @@ static int parse_beacon_hint_chan(struct nlattr *tb,
 	struct nlattr *tb_freq[NL80211_FREQUENCY_ATTR_MAX + 1];
 	static struct nla_policy beacon_freq_policy[NL80211_FREQUENCY_ATTR_MAX + 1] = {
 		[NL80211_FREQUENCY_ATTR_FREQ] = { .type = NLA_U32 },
-		[NL80211_FREQUENCY_ATTR_PASSIVE_SCAN] = { .type = NLA_FLAG },
-		[NL80211_FREQUENCY_ATTR_NO_IBSS] = { .type = NLA_FLAG },
+		[NL80211_FREQUENCY_ATTR_NO_IR] = { .type = NLA_FLAG },
+		[__NL80211_FREQUENCY_ATTR_NO_IBSS] = { .type = NLA_FLAG },
 	};
 
 	if (nla_parse_nested(tb_freq,
@@ -33,9 +33,9 @@ static int parse_beacon_hint_chan(struct nlattr *tb,
 
 	chan->center_freq = nla_get_u32(tb_freq[NL80211_FREQUENCY_ATTR_FREQ]);
 
-	if (tb_freq[NL80211_FREQUENCY_ATTR_PASSIVE_SCAN])
-		chan->passive_scan = true;
-	if (tb_freq[NL80211_FREQUENCY_ATTR_NO_IBSS])
+	if (tb_freq[NL80211_FREQUENCY_ATTR_NO_IR])
+		chan->no_ir = true;
+	if (tb_freq[__NL80211_FREQUENCY_ATTR_NO_IBSS])
 		chan->no_ibss = true;
 
 	return 0;
@@ -394,10 +394,14 @@ static int print_event(struct nl_msg *msg, void *arg)
 		       chan_before_beacon.center_freq,
 		       ieee80211_frequency_to_channel(chan_before_beacon.center_freq));
 
-		if (chan_before_beacon.passive_scan && !chan_after_beacon.passive_scan)
-			printf("\to active scanning enabled\n");
-		if (chan_before_beacon.no_ibss && !chan_after_beacon.no_ibss)
-			printf("\to beaconing enabled\n");
+		if (chan_before_beacon.no_ir && !chan_after_beacon.no_ir) {
+			if (chan_before_beacon.no_ibss && !chan_after_beacon.no_ibss)
+				printf("\to Initiating radiation enabled\n");
+			else
+				printf("\to active scan enabled\n");
+		} else if (chan_before_beacon.no_ibss && !chan_after_beacon.no_ibss) {
+			printf("\to ibss enabled\n");
+		}
 
 		break;
 	case NL80211_CMD_NEW_STATION:
diff --git a/info.c b/info.c
index 7e61e88..b918439 100644
--- a/info.c
+++ b/info.c
@@ -74,8 +74,8 @@ static int print_phy_handler(struct nl_msg *msg, void *arg)
 	static struct nla_policy freq_policy[NL80211_FREQUENCY_ATTR_MAX + 1] = {
 		[NL80211_FREQUENCY_ATTR_FREQ] = { .type = NLA_U32 },
 		[NL80211_FREQUENCY_ATTR_DISABLED] = { .type = NLA_FLAG },
-		[NL80211_FREQUENCY_ATTR_PASSIVE_SCAN] = { .type = NLA_FLAG },
-		[NL80211_FREQUENCY_ATTR_NO_IBSS] = { .type = NLA_FLAG },
+		[NL80211_FREQUENCY_ATTR_NO_IR] = { .type = NLA_FLAG },
+		[__NL80211_FREQUENCY_ATTR_NO_IBSS] = { .type = NLA_FLAG },
 		[NL80211_FREQUENCY_ATTR_RADAR] = { .type = NLA_FLAG },
 		[NL80211_FREQUENCY_ATTR_MAX_TX_POWER] = { .type = NLA_U32 },
 	};
@@ -172,10 +172,16 @@ static int print_phy_handler(struct nl_msg *msg, void *arg)
 						print_flag("disabled", &open);
 						goto next;
 					}
-					if (tb_freq[NL80211_FREQUENCY_ATTR_PASSIVE_SCAN])
-						print_flag("passive scanning", &open);
-					if (tb_freq[NL80211_FREQUENCY_ATTR_NO_IBSS])
-						print_flag("no IBSS", &open);
+
+					/* If both flags are set assume an new kernel */
+					if (tb_freq[NL80211_FREQUENCY_ATTR_NO_IR] && tb_freq[__NL80211_FREQUENCY_ATTR_NO_IBSS]) {
+						print_flag("not allowed to initiate radiation", &open);
+					} else if (tb_freq[NL80211_FREQUENCY_ATTR_PASSIVE_SCAN]) {
+						print_flag("passive scan", &open);
+					} else if (tb_freq[__NL80211_FREQUENCY_ATTR_NO_IBSS]){
+						print_flag("no ibss", &open);
+					}
+
 					if (tb_freq[NL80211_FREQUENCY_ATTR_RADAR])
 						print_flag("radar detection", &open);
 next:
diff --git a/reg.c b/reg.c
index 9a60cec..f2481fe 100644
--- a/reg.c
+++ b/reg.c
@@ -193,8 +193,14 @@ static int print_reg_handler(struct nl_msg *msg, void *arg)
 		PARSE_FLAG(NL80211_RRF_NO_OUTDOOR, "NO-OUTDOOR");
 		PARSE_FLAG(NL80211_RRF_DFS, "DFS");
 		PARSE_FLAG(NL80211_RRF_PTP_ONLY, "PTP-ONLY");
-		PARSE_FLAG(NL80211_RRF_PASSIVE_SCAN, "PASSIVE-SCAN");
-		PARSE_FLAG(NL80211_RRF_NO_IBSS, "NO-IBSS");
+
+		/* Kernels that support NO_IR always turn on both flags */
+		if ((flags & NL80211_RRF_NO_IR) && (flags & __NL80211_RRF_NO_IBSS)) {
+			printf(", NO-IR");
+		} else {
+			PARSE_FLAG(NL80211_RRF_PASSIVE_SCAN, "PASSIVE-SCAN");
+			PARSE_FLAG(__NL80211_RRF_NO_IBSS, "NO-IBSS");
+		}
 
 		printf("\n");
 	}
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] iw: Use NL80211_FREQUENCY_ATTR_NO_IR channel attribute
  2013-11-12 15:46 [PATCH] iw: Use NL80211_FREQUENCY_ATTR_NO_IR channel attribute Ilan Peer
@ 2013-11-13 18:23 ` Johannes Berg
  2013-11-14  7:13   ` Peer, Ilan
  0 siblings, 1 reply; 3+ messages in thread
From: Johannes Berg @ 2013-11-13 18:23 UTC (permalink / raw)
  To: Ilan Peer; +Cc: linux-wireless

On Tue, 2013-11-12 at 17:46 +0200, Ilan Peer wrote:

> +					/* If both flags are set assume an new kernel */
> +					if (tb_freq[NL80211_FREQUENCY_ATTR_NO_IR] && tb_freq[__NL80211_FREQUENCY_ATTR_NO_IBSS]) {
> +						print_flag("not allowed to initiate radiation", &open);

That seems excessive, any way to shorten that string?

		Frequencies:
			* 5180 MHz [36] (15.0 dBm) (not allowed to initiate radiation)
			* 5200 MHz [40] (15.0 dBm) (not allowed to initiate radiation)
			* 5220 MHz [44] (15.0 dBm) (not allowed to initiate radiation)
			* 5240 MHz [48] (15.0 dBm) (not allowed to initiate radiation)
			* 5260 MHz [52] (15.0 dBm) (not allowed to initiate radiation, radar detection)
			  DFS state: usable (for 41141 sec)


johannes


^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH] iw: Use NL80211_FREQUENCY_ATTR_NO_IR channel attribute
  2013-11-13 18:23 ` Johannes Berg
@ 2013-11-14  7:13   ` Peer, Ilan
  0 siblings, 0 replies; 3+ messages in thread
From: Peer, Ilan @ 2013-11-14  7:13 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless

PiBGcm9tOiBKb2hhbm5lcyBCZXJnIFttYWlsdG86am9oYW5uZXNAc2lwc29sdXRpb25zLm5ldF0N
Cj4gU2VudDogV2VkbmVzZGF5LCBOb3ZlbWJlciAxMywgMjAxMyAyMDoyMw0KPiBUbzogUGVlciwg
SWxhbg0KPiBDYzogbGludXgtd2lyZWxlc3NAdmdlci5rZXJuZWwub3JnDQo+IFN1YmplY3Q6IFJl
OiBbUEFUQ0hdIGl3OiBVc2UgTkw4MDIxMV9GUkVRVUVOQ1lfQVRUUl9OT19JUiBjaGFubmVsDQo+
IGF0dHJpYnV0ZQ0KPiANCj4gT24gVHVlLCAyMDEzLTExLTEyIGF0IDE3OjQ2ICswMjAwLCBJbGFu
IFBlZXIgd3JvdGU6DQo+IA0KPiA+ICsJCQkJCS8qIElmIGJvdGggZmxhZ3MgYXJlIHNldCBhc3N1
bWUgYW4NCj4gbmV3IGtlcm5lbCAqLw0KPiA+ICsJCQkJCWlmDQo+ICh0Yl9mcmVxW05MODAyMTFf
RlJFUVVFTkNZX0FUVFJfTk9fSVJdICYmDQo+IHRiX2ZyZXFbX19OTDgwMjExX0ZSRVFVRU5DWV9B
VFRSX05PX0lCU1NdKSB7DQo+ID4gKwkJCQkJCXByaW50X2ZsYWcoIm5vdCBhbGxvd2VkIHRvDQo+
IGluaXRpYXRlIHJhZGlhdGlvbiIsICZvcGVuKTsNCj4gDQo+IFRoYXQgc2VlbXMgZXhjZXNzaXZl
LCBhbnkgd2F5IHRvIHNob3J0ZW4gdGhhdCBzdHJpbmc/DQo+IA0KDQpTdXJlLiBXaWxsIGNoYW5n
ZSBpdCB0byAibm8gSVIiIChhbHNvIHRyaWVkICJjYW5ub3QgaW5pdGlhdGUgcmFkaWF0aW9uIiBi
dXQgdGhpcyBhbHNvIHNlZW1zIGEgYml0IGxvbmcgLi4uKQ0KDQpUaGFua3MsDQoNCklsYW4uDQo=

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-11-14  7:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-12 15:46 [PATCH] iw: Use NL80211_FREQUENCY_ATTR_NO_IR channel attribute Ilan Peer
2013-11-13 18:23 ` Johannes Berg
2013-11-14  7:13   ` Peer, Ilan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).