@@ -8488,9 +8488,11 @@ static int wpa_supplicant_global_iface_add(struct wpa_global *global,
{
struct wpa_interface iface;
char *pos;
+ int create_iface = 0;
+ u8 mac_addr[ETH_ALEN];
/*
- * <ifname>TAB<confname>TAB<driver>TAB<ctrl_interface>TAB<driver_param>
+ * <ifname>TAB[<create>TAB]<confname>TAB<driver>TAB<ctrl_interface>TAB<driver_param>
* TAB<bridge_ifname>
*/
wpa_printf(MSG_DEBUG, "CTRL_IFACE GLOBAL INTERFACE_ADD '%s'", cmd);
@@ -8507,6 +8509,15 @@ static int wpa_supplicant_global_iface_add(struct wpa_global *global,
if (pos == NULL)
break;
+ if (os_strncmp(pos, "create", 6) == 0) {
+ create_iface = 1;
+ pos = os_strchr(pos, '\t');
+ if (pos)
+ pos++;
+ if (pos == NULL)
+ break;
+ }
+
iface.confname = pos;
pos = os_strchr(pos, '\t');
if (pos)
@@ -8553,6 +8564,19 @@ static int wpa_supplicant_global_iface_add(struct wpa_global *global,
break;
} while (0);
+ if (create_iface) {
+ wpa_printf(MSG_DEBUG, "CTRL_IFACE Creating interface '%s'", iface.ifname);
+ if (wpa_drv_if_add(global->ifaces, WPA_IF_STATION, iface.ifname,
+ NULL, NULL, NULL , mac_addr, NULL) < 0)
+ {
+ wpa_printf(MSG_ERROR, "CTRL_IFACE Interface creation failed");
+ return -1;
+ }
+
+ wpa_printf(MSG_DEBUG, "CTRL_IFACE Interface '%s' is created with mac addr:" MACSTR,
+ iface.ifname, MAC2STR(mac_addr));
+ }
+
if (wpa_supplicant_get_iface(global, iface.ifname))
return -1;
@@ -8564,13 +8588,35 @@ static int wpa_supplicant_global_iface_remove(struct wpa_global *global,
char *cmd)
{
struct wpa_supplicant *wpa_s;
+ int ret;
+ char *ifname;
+ char *pos;
+ int delete_iface = 0;
+
+ wpa_printf(MSG_ERROR, "CTRL_IFACE GLOBAL INTERFACE_REMOVE '%s'", cmd);
+
+ /*
+ * <ifname>TAB[<delete>]
+ */
+ ifname = cmd;
+ pos = os_strchr(cmd, '\t');
+ if (pos)
+ *pos++ = '\0';
- wpa_printf(MSG_DEBUG, "CTRL_IFACE GLOBAL INTERFACE_REMOVE '%s'", cmd);
+ if (os_strstr(pos, "delete")) {
+ /* Interface need to be deleted after de-initialization */
+ delete_iface = 1;
+ }
- wpa_s = wpa_supplicant_get_iface(global, cmd);
+ wpa_s = wpa_supplicant_get_iface(global, ifname);
if (wpa_s == NULL)
return -1;
- return wpa_supplicant_remove_iface(global, wpa_s, 0);
+ ret = wpa_supplicant_remove_iface(global, wpa_s, 0);
+ if (!ret && delete_iface) {
+ wpa_printf(MSG_DEBUG, "CTRL_IFACE Deleting the interface '%s'", ifname);
+ ret = wpa_drv_if_remove(global->ifaces, WPA_IF_STATION, ifname);
+ }
+ return ret;
}