]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
dbus: Pass in MAC address in CreateInterface method
authorJintao Lin <jintaolin@chromium.org>
Tue, 6 Dec 2022 00:37:04 +0000 (00:37 +0000)
committerJouni Malinen <j@w1.fi>
Sat, 17 Dec 2022 10:11:15 +0000 (12:11 +0200)
chromeOS uses random generated MAC address for AP interface so that the
device could remain anonymous and untrackable. Add an address parameter
for CreateInterface method to pass in OS managed MAC address.

Signed-off-by: Jintao Lin <jintaolin@chromium.org>
doc/dbus.doxygen
wpa_supplicant/dbus/dbus_new_handlers.c

index 3fc3146a7a6ebae76c2cd60b14ed7f094bd3f267..7950c9b2efddf860b29dde00c1e8435e9b0c5a6b 100644 (file)
@@ -43,6 +43,7 @@ registered in the bus with fi.w1.wpa_supplicant1 name.
              <tr><td>ConfigFile</td><td>s</td><td>Configuration file path</td><td>No</td>
              <tr><td>Create</td><td>b</td><td>Whether to create a new interface in the kernel</td><td>No</td>
              <tr><td>Type</td><td>s</td><td>Interface type to create (sta or ap)</td><td>No</td>
+             <tr><td>Address</td><td>s</td><td>MAC address in colon-delimited format to be used in the created interface</td><td>No</td>
            </table>
          </dd>
        </dl>
index d2c78ecfa70a3b951e1e632ad0f0444d6beecad9..83f46a9ebc251cafef0fe4ea5d6d09d6e0e66568 100644 (file)
@@ -774,6 +774,7 @@ DBusMessage * wpas_dbus_handler_create_interface(DBusMessage *message,
        char *confname = NULL;
        char *bridge_ifname = NULL;
        bool create_iface = false;
+       u8 *if_addr = NULL;
        enum wpa_driver_if_type if_type = WPA_IF_STATION;
 
        dbus_message_iter_init(message, &iter);
@@ -826,6 +827,18 @@ DBusMessage * wpas_dbus_handler_create_interface(DBusMessage *message,
                                goto error;
                        }
                        wpa_dbus_dict_entry_clear(&entry);
+               } else if (os_strcmp(entry.key, "Address") == 0 &&
+                          entry.type == DBUS_TYPE_STRING) {
+                       if_addr = os_malloc(ETH_ALEN);
+                       if (if_addr == NULL) {
+                               wpa_dbus_dict_entry_clear(&entry);
+                               goto oom;
+                       }
+                       if (hwaddr_aton(entry.str_value, if_addr)) {
+                               wpa_dbus_dict_entry_clear(&entry);
+                               goto error;
+                       }
+                       wpa_dbus_dict_entry_clear(&entry);
                } else {
                        wpa_dbus_dict_entry_clear(&entry);
                        goto error;
@@ -855,7 +868,7 @@ DBusMessage * wpas_dbus_handler_create_interface(DBusMessage *message,
                                   __func__, ifname);
                        if (!global->ifaces ||
                            wpa_drv_if_add(global->ifaces, if_type, ifname,
-                                          NULL, NULL, NULL, mac_addr,
+                                          if_addr, NULL, NULL, mac_addr,
                                           NULL) < 0) {
                                reply = wpas_dbus_error_unknown_error(
                                        message,
@@ -895,6 +908,7 @@ out:
        os_free(ifname);
        os_free(confname);
        os_free(bridge_ifname);
+       os_free(if_addr);
        return reply;
 
 error: