hostapd: Fix AP ctrl events not send to hostapd_cli
Android hostapd aidl calls wpa_msg_register_cb() to register
onAsyncWpaEventCb to monitor ctrl events, this overwrites ctrl
iface's callback hostapd_ctrl_iface_msg_cb.
This results hostapd_cli not able to receive AP ctrl events from
hostapd.
This CL defines wpa_msg_register_aidl_cb() for Android hostapd
aidl to make sure both aidl and ctrl iface callbacks are triggered.
cp from pag/2244726
Bug: 237600228
Test: Manual Test
Change-Id: Ia2595657262d4166bddaacab6549e52bfe833510
diff --git a/src/utils/wpa_debug.c b/src/utils/wpa_debug.c
index a338a20..9875b0e 100644
--- a/src/utils/wpa_debug.c
+++ b/src/utils/wpa_debug.c
@@ -621,12 +621,17 @@
#ifndef CONFIG_NO_WPA_MSG
static wpa_msg_cb_func wpa_msg_cb = NULL;
+static wpa_msg_cb_func wpa_msg_aidl_cb = NULL;
void wpa_msg_register_cb(wpa_msg_cb_func func)
{
wpa_msg_cb = func;
}
+void wpa_msg_register_aidl_cb(wpa_msg_cb_func func)
+{
+ wpa_msg_aidl_cb = func;
+}
static wpa_msg_get_ifname_func wpa_msg_ifname_cb = NULL;
@@ -670,6 +675,8 @@
wpa_printf(level, "%s%s", prefix, buf);
if (wpa_msg_cb)
wpa_msg_cb(ctx, level, WPA_MSG_PER_INTERFACE, buf, len);
+ if (wpa_msg_aidl_cb)
+ wpa_msg_aidl_cb(ctx, level, WPA_MSG_PER_INTERFACE, buf, len);
bin_clear_free(buf, buflen);
}
@@ -681,7 +688,7 @@
int buflen;
int len;
- if (!wpa_msg_cb)
+ if (!wpa_msg_cb && !wpa_msg_aidl_cb)
return;
va_start(ap, fmt);
@@ -697,7 +704,10 @@
va_start(ap, fmt);
len = vsnprintf(buf, buflen, fmt, ap);
va_end(ap);
- wpa_msg_cb(ctx, level, WPA_MSG_PER_INTERFACE, buf, len);
+ if (wpa_msg_cb)
+ wpa_msg_cb(ctx, level, WPA_MSG_PER_INTERFACE, buf, len);
+ if (wpa_msg_aidl_cb)
+ wpa_msg_aidl_cb(ctx, level, WPA_MSG_PER_INTERFACE, buf, len);
bin_clear_free(buf, buflen);
}
@@ -725,6 +735,8 @@
wpa_printf(level, "%s", buf);
if (wpa_msg_cb)
wpa_msg_cb(ctx, level, WPA_MSG_GLOBAL, buf, len);
+ if (wpa_msg_aidl_cb)
+ wpa_msg_aidl_cb(ctx, level, WPA_MSG_GLOBAL, buf, len);
bin_clear_free(buf, buflen);
}
@@ -736,7 +748,7 @@
int buflen;
int len;
- if (!wpa_msg_cb)
+ if (!wpa_msg_cb && !wpa_msg_aidl_cb)
return;
va_start(ap, fmt);
@@ -752,7 +764,10 @@
va_start(ap, fmt);
len = vsnprintf(buf, buflen, fmt, ap);
va_end(ap);
- wpa_msg_cb(ctx, level, WPA_MSG_GLOBAL, buf, len);
+ if (wpa_msg_cb)
+ wpa_msg_cb(ctx, level, WPA_MSG_GLOBAL, buf, len);
+ if (wpa_msg_aidl_cb)
+ wpa_msg_aidl_cb(ctx, level, WPA_MSG_GLOBAL, buf, len);
bin_clear_free(buf, buflen);
}
@@ -780,6 +795,9 @@
wpa_printf(level, "%s", buf);
if (wpa_msg_cb)
wpa_msg_cb(ctx, level, WPA_MSG_NO_GLOBAL, buf, len);
+ if (wpa_msg_aidl_cb)
+ wpa_msg_aidl_cb(ctx, level, WPA_MSG_NO_GLOBAL, buf, len);
+
bin_clear_free(buf, buflen);
}
@@ -807,6 +825,8 @@
wpa_printf(level, "%s", buf);
if (wpa_msg_cb)
wpa_msg_cb(ctx, level, WPA_MSG_ONLY_GLOBAL, buf, len);
+ if (wpa_msg_aidl_cb)
+ wpa_msg_aidl_cb(ctx, level, WPA_MSG_ONLY_GLOBAL, buf, len);
os_free(buf);
}