iwd.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/5] hwsim: add PrefixOffset rule property
@ 2021-09-08 22:47 James Prestwood
  2021-09-08 22:47 ` [PATCH 2/5] auto-t: hwsim.py: add prefix_offset property James Prestwood
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: James Prestwood @ 2021-09-08 22:47 UTC (permalink / raw)
  To: iwd

[-- Attachment #1: Type: text/plain, Size: 2793 bytes --]

If set, a rule will start matching a prefix some number of bytes
into the frame. This is useful since header information, addresses,
and sequence numbers may be unpredictable between test runs.
---
 tools/hwsim.c | 45 +++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 43 insertions(+), 2 deletions(-)

diff --git a/tools/hwsim.c b/tools/hwsim.c
index 8fb9b0a4..9a7a90a9 100644
--- a/tools/hwsim.c
+++ b/tools/hwsim.c
@@ -132,6 +132,7 @@ struct hwsim_rule {
 	int delay;
 	uint8_t *prefix;
 	size_t prefix_len;
+	uint16_t prefix_offset;
 	int match_times; /* negative value indicates unused */
 };
 
@@ -1212,8 +1213,13 @@ static void process_rules(const struct radio_info_rec *src_radio,
 		if (rule->frequency && rule->frequency != frame->frequency)
 			continue;
 
-		if (rule->prefix && frame->payload_len >= rule->prefix_len) {
-			if (memcmp(rule->prefix, frame->payload,
+		if (rule->prefix) {
+			if (frame->payload_len <
+					rule->prefix_len + rule->prefix_offset)
+				continue;
+
+			if (memcmp(rule->prefix,
+					frame->payload + rule->prefix_offset,
 					rule->prefix_len) != 0)
 				continue;
 		}
@@ -2394,6 +2400,37 @@ invalid_args:
 	return dbus_error_invalid_args(message);
 }
 
+static bool rule_property_get_prefix_offset(struct l_dbus *dbus,
+					struct l_dbus_message *message,
+					struct l_dbus_message_builder *builder,
+					void *user_data)
+{
+	struct hwsim_rule *rule = user_data;
+	uint16_t val = rule->prefix_offset;
+
+	l_dbus_message_builder_append_basic(builder, 'q', &val);
+
+	return true;
+}
+
+static struct l_dbus_message *rule_property_set_prefix_offset(
+					struct l_dbus *dbus,
+					struct l_dbus_message *message,
+					struct l_dbus_message_iter *new_value,
+					l_dbus_property_complete_cb_t complete,
+					void *user_data)
+{
+	struct hwsim_rule *rule = user_data;
+	uint16_t val;
+
+	if (!l_dbus_message_iter_get_variant(new_value, "q", &val))
+		return dbus_error_invalid_args(message);
+
+	rule->prefix_offset = val;
+
+	return l_dbus_message_new_method_return(message);
+}
+
 static bool rule_property_get_enabled(struct l_dbus *dbus,
 					struct l_dbus_message *message,
 					struct l_dbus_message_builder *builder,
@@ -2527,6 +2564,10 @@ static void setup_rule_interface(struct l_dbus_interface *interface)
 					L_DBUS_PROPERTY_FLAG_AUTO_EMIT, "ay",
 					rule_property_get_prefix,
 					rule_property_set_prefix);
+	l_dbus_interface_property(interface, "PrefixOffset",
+					L_DBUS_PROPERTY_FLAG_AUTO_EMIT, "q",
+					rule_property_get_prefix_offset,
+					rule_property_set_prefix_offset);
 	l_dbus_interface_property(interface, "Enabled",
 					L_DBUS_PROPERTY_FLAG_AUTO_EMIT, "b",
 					rule_property_get_enabled,
-- 
2.31.1

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

end of thread, other threads:[~2021-09-09 19:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-08 22:47 [PATCH 1/5] hwsim: add PrefixOffset rule property James Prestwood
2021-09-08 22:47 ` [PATCH 2/5] auto-t: hwsim.py: add prefix_offset property James Prestwood
2021-09-08 22:47 ` [PATCH 3/5] auto-t: change testSAE timeout_test to use prefix_offset James Prestwood
2021-09-09 19:47   ` Denis Kenzior
2021-09-08 22:47 ` [PATCH 4/5] auto-t: add SAE test for a non-ACKed confirm James Prestwood
2021-09-08 22:47 ` [PATCH 5/5] auto-t: add SAE test for no supported groups James Prestwood

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).