Skip to contentSkip to conversation

iw: use updated structures and enums for packet pattern

PATCH Superseded Bing Zhao 1 participant 2 messages May 30, 2013

Subsystems (2)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Bing Zhao

author
#0 lore raw

PATCH v3 1/2 iw: use updated structures and enums for packet pattern

From: Amitkumar Karwar <[email protected]>

They are renamed in new nl80211.h so that they can be used for new feature. This patch uses those updated structures and enums to make the code look nicer.

---
v3: use new structure/enum names to make the code look nicer

 info.c   |  2 +-
 wowlan.c | 32 ++++++++++++++++----------------
 2 files changed, 17 insertions(+), 17 deletions(-)
info.c +1 -1
index 54d9a8d..d893ffc 100644
@@ -432,7 +432,7 @@ broken_combination:
 			[NL80211_WOWLAN_TRIG_RFKILL_RELEASE] = { .type = NLA_FLAG },
 			[NL80211_WOWLAN_TRIG_TCP_CONNECTION] = { .type = NLA_NESTED },
 		};
-		struct nl80211_wowlan_pattern_support *pat;
+		struct nl80211_pattern_support *pat;
 		int err;
 
 		err = nla_parse_nested(tb_wowlan, MAX_NL80211_WOWLAN_TRIG,
wowlan.c +16 -16
index b4a2715..d323ca7 100644
@@ -261,11 +261,11 @@ static int handle_wowlan_enable(struct nl80211_state *state, struct nl_cb *cb,
 			}
 
 			pattern = nla_nest_start(patterns, ++patnum);
-			NLA_PUT(patterns, NL80211_WOWLAN_PKTPAT_MASK,
+			NLA_PUT(patterns, NL80211_PKTPAT_MASK,
 				DIV_ROUND_UP(patlen, 8), mask);
-			NLA_PUT(patterns, NL80211_WOWLAN_PKTPAT_PATTERN,
-				patlen, pat);
-			NLA_PUT_U32(patterns, NL80211_WOWLAN_PKTPAT_OFFSET, pkt_offset);
+			NLA_PUT(patterns, NL80211_PKTPAT_PATTERN, patlen, pat);
+			NLA_PUT_U32(patterns, NL80211_PKTPAT_OFFSET,
+				    pkt_offset);
 			nla_nest_end(patterns, pattern);
 			free(mask);
 			free(pat);
@@ -356,29 +356,29 @@ static int print_wowlan_handler(struct nl_msg *msg, void *arg)
 		nla_for_each_nested(pattern,
 				    trig[NL80211_WOWLAN_TRIG_PKT_PATTERN],
 				    rem_pattern) {
-			struct nlattr *patattr[NUM_NL80211_WOWLAN_PKTPAT];
+			struct nlattr *patattr[NUM_NL80211_PKTPAT];
 			int i, patlen, masklen, pkt_offset;
 			uint8_t *mask, *pat;
-			nla_parse(patattr, MAX_NL80211_WOWLAN_PKTPAT,
-				  nla_data(pattern), nla_len(pattern),
-				  NULL);
-			if (!patattr[NL80211_WOWLAN_PKTPAT_MASK] ||
-			    !patattr[NL80211_WOWLAN_PKTPAT_PATTERN] ||
-			    !patattr[NL80211_WOWLAN_PKTPAT_OFFSET]) {
+			nla_parse(patattr, MAX_NL80211_PKTPAT,
+				  nla_data(pattern), nla_len(pattern), NULL);
+			if (!patattr[NL80211_PKTPAT_MASK] ||
+			    !patattr[NL80211_PKTPAT_PATTERN] ||
+			    !patattr[NL80211_PKTPAT_OFFSET]) {
 				printf(" * (invalid pattern specification)\n");
 				continue;
 			}
-			masklen = nla_len(patattr[NL80211_WOWLAN_PKTPAT_MASK]);
-			patlen = nla_len(patattr[NL80211_WOWLAN_PKTPAT_PATTERN]);
-			pkt_offset = nla_get_u32(patattr[NL80211_WOWLAN_PKTPAT_OFFSET]);
+			masklen = nla_len(patattr[NL80211_PKTPAT_MASK]);
+			patlen = nla_len(patattr[NL80211_PKTPAT_PATTERN]);
+			pkt_offset =
+				nla_get_u32(patattr[NL80211_PKTPAT_OFFSET]);
 			if (DIV_ROUND_UP(patlen, 8) != masklen) {
 				printf(" * (invalid pattern specification)\n");
 				continue;
 			}
 			printf(" * wake up on packet offset: %d", pkt_offset);
 			printf(" pattern: ");
-			pat = nla_data(patattr[NL80211_WOWLAN_PKTPAT_PATTERN]);
-			mask = nla_data(patattr[NL80211_WOWLAN_PKTPAT_MASK]);
+			pat = nla_data(patattr[NL80211_PKTPAT_PATTERN]);
+			mask = nla_data(patattr[NL80211_PKTPAT_MASK]);
 			for (i = 0; i < patlen; i++) {
 				if (mask[i / 8] & (1 << (i % 8)))
 					printf("%.2x", pat[i]);
Signature · 1 line
1.8.0
author
#1 lore raw

PATCH v3 2/2 iw: add coalesce support

From: Amitkumar Karwar <[email protected]>

User can add one coalesce rule at a time using 'iw coalesce add' command. The settings can be cleared using 'iw coalesce disable' command. 'iw coalesce show' displays current configuration.

---
v3: match cfg80211/nl80211 v3 patchset

 Makefile   |   2 +-
 coalesce.c | 229 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 info.c     |  14 ++++
 3 files changed, 244 insertions(+), 1 deletion(-)
 create mode 100644 coalesce.c
Makefile +1 -1
index c485b5e..f042e30 100644
@@ -16,7 +16,7 @@ OBJS = iw.o genl.o event.o info.o phy.o \
 	interface.o ibss.o station.o survey.o util.o \
 	mesh.o mpath.o scan.o reg.o version.o \
 	reason.o status.o connect.o link.o offch.o ps.o cqm.o \
-	bitrate.o wowlan.o roc.o p2p.o
+	bitrate.o wowlan.o coalesce.o roc.o p2p.o
 OBJS += sections.o
 
 OBJS-$(HWSIM) += hwsim.o
coalesce.c new file +229 -0

229 lines not on this page · raw message

info.c +14 -0
index d893ffc..849da67 100644
@@ -528,6 +528,20 @@ broken_combination:
 			printf("\tDevice supports AP scan.\n");
 	}
 
+	if (tb_msg[NL80211_ATTR_COALESCE_RULE]) {
+		struct nl80211_coalesce_rule_support *rule;
+		struct nl80211_pattern_support *pat;
+
+		printf("\tCoalesce support:\n");
+		rule = nla_data(tb_msg[NL80211_ATTR_COALESCE_RULE]);
+		pat = &rule->pat;
+		printf("\t\t * Maximum %u coalesce rules supported\n"
+		       "\t\t * Each rule contains upto %u patterns of %u-%u bytes,\n"
+		       "\t\t   maximum packet offset %u bytes\n",
+			rule->max_rules, pat->max_patterns, pat->min_pattern_len,
+			pat->max_pattern_len, pat->max_pkt_offset);
+	}
+
 	return NL_SKIP;
 }
 
Signature · 1 line
1.8.0