wpa_cli: Support action scripts with global ctrl_iface
This extends "wpa_cli -a<action script>" functionality to work with the global wpa_supplicant control interface. The IFNAME=<ifname> prefix is removed from the event messages and converted to the control interface name when present. Previously, action scripts could only be used with the per-interface control interfaces. Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
This commit is contained in:
parent
063f85043d
commit
55c2bfa9eb
1 changed files with 29 additions and 15 deletions
|
@ -3178,15 +3178,29 @@ static void wpa_cli_action_process(const char *msg)
|
|||
{
|
||||
const char *pos;
|
||||
char *copy = NULL, *id, *pos2;
|
||||
const char *ifname = ctrl_ifname;
|
||||
char ifname_buf[100];
|
||||
|
||||
pos = msg;
|
||||
if (os_strncmp(pos, "IFNAME=", 7) == 0) {
|
||||
const char *end;
|
||||
end = os_strchr(pos + 7, ' ');
|
||||
if (end && (unsigned int) (end - pos) < sizeof(ifname_buf)) {
|
||||
pos += 7;
|
||||
os_memcpy(ifname_buf, pos, end - pos);
|
||||
ifname_buf[end - pos] = '\0';
|
||||
ifname = ifname_buf;
|
||||
pos = end + 1;
|
||||
}
|
||||
}
|
||||
if (*pos == '<') {
|
||||
const char *prev = pos;
|
||||
/* skip priority */
|
||||
pos = os_strchr(pos, '>');
|
||||
if (pos)
|
||||
pos++;
|
||||
else
|
||||
pos = msg;
|
||||
pos = prev;
|
||||
}
|
||||
|
||||
if (str_match(pos, WPA_EVENT_CONNECTED)) {
|
||||
|
@ -3223,37 +3237,37 @@ static void wpa_cli_action_process(const char *msg)
|
|||
if (wpa_cli_connected <= 0 || new_id != wpa_cli_last_id) {
|
||||
wpa_cli_connected = 1;
|
||||
wpa_cli_last_id = new_id;
|
||||
wpa_cli_exec(action_file, ctrl_ifname, "CONNECTED");
|
||||
wpa_cli_exec(action_file, ifname, "CONNECTED");
|
||||
}
|
||||
} else if (str_match(pos, WPA_EVENT_DISCONNECTED)) {
|
||||
if (wpa_cli_connected) {
|
||||
wpa_cli_connected = 0;
|
||||
wpa_cli_exec(action_file, ctrl_ifname, "DISCONNECTED");
|
||||
wpa_cli_exec(action_file, ifname, "DISCONNECTED");
|
||||
}
|
||||
} else if (str_match(pos, P2P_EVENT_GROUP_STARTED)) {
|
||||
wpa_cli_exec(action_file, ctrl_ifname, pos);
|
||||
wpa_cli_exec(action_file, ifname, pos);
|
||||
} else if (str_match(pos, P2P_EVENT_GROUP_REMOVED)) {
|
||||
wpa_cli_exec(action_file, ctrl_ifname, pos);
|
||||
wpa_cli_exec(action_file, ifname, pos);
|
||||
} else if (str_match(pos, P2P_EVENT_CROSS_CONNECT_ENABLE)) {
|
||||
wpa_cli_exec(action_file, ctrl_ifname, pos);
|
||||
wpa_cli_exec(action_file, ifname, pos);
|
||||
} else if (str_match(pos, P2P_EVENT_CROSS_CONNECT_DISABLE)) {
|
||||
wpa_cli_exec(action_file, ctrl_ifname, pos);
|
||||
wpa_cli_exec(action_file, ifname, pos);
|
||||
} else if (str_match(pos, P2P_EVENT_GO_NEG_FAILURE)) {
|
||||
wpa_cli_exec(action_file, ctrl_ifname, pos);
|
||||
wpa_cli_exec(action_file, ifname, pos);
|
||||
} else if (str_match(pos, WPS_EVENT_SUCCESS)) {
|
||||
wpa_cli_exec(action_file, ctrl_ifname, pos);
|
||||
wpa_cli_exec(action_file, ifname, pos);
|
||||
} else if (str_match(pos, WPS_EVENT_FAIL)) {
|
||||
wpa_cli_exec(action_file, ctrl_ifname, pos);
|
||||
wpa_cli_exec(action_file, ifname, pos);
|
||||
} else if (str_match(pos, AP_STA_CONNECTED)) {
|
||||
wpa_cli_exec(action_file, ctrl_ifname, pos);
|
||||
wpa_cli_exec(action_file, ifname, pos);
|
||||
} else if (str_match(pos, AP_STA_DISCONNECTED)) {
|
||||
wpa_cli_exec(action_file, ctrl_ifname, pos);
|
||||
wpa_cli_exec(action_file, ifname, pos);
|
||||
} else if (str_match(pos, ESS_DISASSOC_IMMINENT)) {
|
||||
wpa_cli_exec(action_file, ctrl_ifname, pos);
|
||||
wpa_cli_exec(action_file, ifname, pos);
|
||||
} else if (str_match(pos, HS20_SUBSCRIPTION_REMEDIATION)) {
|
||||
wpa_cli_exec(action_file, ctrl_ifname, pos);
|
||||
wpa_cli_exec(action_file, ifname, pos);
|
||||
} else if (str_match(pos, HS20_DEAUTH_IMMINENT_NOTICE)) {
|
||||
wpa_cli_exec(action_file, ctrl_ifname, pos);
|
||||
wpa_cli_exec(action_file, ifname, pos);
|
||||
} else if (str_match(pos, WPA_EVENT_TERMINATING)) {
|
||||
printf("wpa_supplicant is terminating - stop monitoring\n");
|
||||
wpa_cli_quit = 1;
|
||||
|
|
Loading…
Reference in a new issue