hwsim: move frame processing into a separate function

The ADD/DEL_MAC_ADDR events come through the unicast handler so
move the frame processing to a separate function so these other
events can be handled.
This commit is contained in:
James Prestwood 2023-06-28 13:20:32 -07:00 committed by Denis Kenzior
parent cda7644557
commit 5f4f15a600
1 changed files with 24 additions and 6 deletions

View File

@ -1572,7 +1572,9 @@ static void process_frame(struct hwsim_frame *frame)
hwsim_frame_unref(frame);
}
static void unicast_handler(struct l_genl_msg *msg, void *user_data)
static void hwsim_frame_event(struct l_genl_msg *msg)
{
struct hwsim_frame *frame;
const struct mmpdu_header *mpdu;
@ -1581,9 +1583,6 @@ static void unicast_handler(struct l_genl_msg *msg, void *user_data)
const void *data;
const uint8_t *transmitter = NULL, *freq = NULL, *flags = NULL;
if (l_genl_msg_get_command(msg) != HWSIM_CMD_FRAME)
return;
if (!l_genl_attr_init(&attr, msg))
return;
@ -1683,6 +1682,24 @@ static void unicast_handler(struct l_genl_msg *msg, void *user_data)
process_frame(frame);
}
static void hwsim_unicast_handler(struct l_genl_msg *msg, void *user_data)
{
uint8_t cmd;
if (l_genl_msg_get_error(msg) < 0)
return;
cmd = l_genl_msg_get_command(msg);
switch (cmd) {
case HWSIM_CMD_FRAME:
hwsim_frame_event(msg);
break;
default:
break;
}
}
static void radio_manager_create_callback(struct l_genl_msg *msg,
void *user_data)
{
@ -2939,8 +2956,9 @@ static void hwsim_ready(void)
}
if (!l_genl_add_unicast_watch(genl, "MAC80211_HWSIM",
unicast_handler, NULL, NULL)) {
l_error("Failed to set unicast handler");
hwsim_unicast_handler,
NULL, NULL)) {
l_error("Failed to set hwsim unicast handler");
goto error;
}