From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.01.org
Subject: [PATCH 1/9] hwsim: add MatchTimes property
Date: Tue, 07 Sep 2021 14:14:42 -0700 [thread overview]
Message-ID: <20210907211450.27270-1-prestwoj@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 3045 bytes --]
This integer property can be set to only match a rule a number of
times rather than all packets. This is useful for testing behavior
of a single dropped frame or ack. Once the rule has been matched
'MatchTimes' the rules will no longer be applied (unless set again
to some integer greater than zero).
---
tools/hwsim.c | 42 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/tools/hwsim.c b/tools/hwsim.c
index cd4a99b7..18ba111a 100644
--- a/tools/hwsim.c
+++ b/tools/hwsim.c
@@ -131,6 +131,7 @@ struct hwsim_rule {
int delay;
uint8_t *prefix;
size_t prefix_len;
+ int match_times; /* negative value indicates unused */
};
struct hwsim_support {
@@ -1217,6 +1218,8 @@ static void process_rules(const struct radio_info_rec *src_radio,
}
/* Rule deemed to match frame, apply any changes */
+ if (rule->match_times == 0)
+ continue;
if (rule->signal)
frame->signal = rule->signal / 100;
@@ -1225,6 +1228,9 @@ static void process_rules(const struct radio_info_rec *src_radio,
if (delay)
*delay = rule->delay;
+
+ if (rule->match_times > 0)
+ rule->match_times--;
}
}
@@ -2008,6 +2014,7 @@ static struct l_dbus_message *rule_add(struct l_dbus *dbus,
rule->destination_any = true;
rule->delay = 0;
rule->enabled = false;
+ rule->match_times = -1;
if (!rules)
rules = l_queue_new();
@@ -2412,6 +2419,37 @@ static struct l_dbus_message *rule_property_set_enabled(
return l_dbus_message_new_method_return(message);
}
+static bool rule_property_get_match_times(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->match_times;
+
+ l_dbus_message_builder_append_basic(builder, 'q', &val);
+
+ return true;
+}
+
+static struct l_dbus_message *rule_property_set_match_times(
+ 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->match_times = val;
+
+ return l_dbus_message_new_method_return(message);
+}
+
static void setup_rule_interface(struct l_dbus_interface *interface)
{
l_dbus_interface_method(interface, "Remove", 0, rule_remove, "", "");
@@ -2456,6 +2494,10 @@ static void setup_rule_interface(struct l_dbus_interface *interface)
L_DBUS_PROPERTY_FLAG_AUTO_EMIT, "b",
rule_property_get_enabled,
rule_property_set_enabled);
+ l_dbus_interface_property(interface, "MatchTimes",
+ L_DBUS_PROPERTY_FLAG_AUTO_EMIT, "q",
+ rule_property_get_match_times,
+ rule_property_set_match_times);
}
static void request_name_callback(struct l_dbus *dbus, bool success,
--
2.31.1
next reply other threads:[~2021-09-07 21:14 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-07 21:14 James Prestwood [this message]
2021-09-07 21:14 ` [PATCH 2/9] auto-t: hwsim.py: add match_times property James Prestwood
2021-09-07 21:14 ` [PATCH 3/9] hwsim: add DropAck rule property James Prestwood
2021-09-07 21:14 ` [PATCH 4/9] auto-t: hwsim.py: add drop_ack property James Prestwood
2021-09-07 21:14 ` [PATCH 5/9] netdev: print error if CMD_ASSOCIATE fails James Prestwood
2021-09-07 21:14 ` [PATCH 6/9] sae: print state and transaction on received packets James Prestwood
2021-09-07 21:14 ` [PATCH 7/9] sae: fix a few spec violations regarding dropped frames James Prestwood
2021-09-08 1:05 ` Denis Kenzior
2021-09-07 21:14 ` [PATCH 8/9] sae: don't send commit in confirmed state James Prestwood
2021-09-07 23:02 ` Paul Menzel
2021-09-07 23:34 ` James Prestwood
2021-09-08 13:24 ` Paul Menzel
2021-09-08 16:40 ` James Prestwood
2021-09-07 21:14 ` [PATCH 9/9] auto-t: add sae test for non-acked commit James Prestwood
2021-09-08 1:03 ` [PATCH 1/9] hwsim: add MatchTimes property Denis Kenzior
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=20210907211450.27270-1-prestwoj@gmail.com \
--to=prestwoj@gmail.com \
--cc=iwd@lists.01.org \
/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 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).