OSDN Git Service

wpa_supplicant: Enable TDLS
[android-x86/external-wpa_supplicant_8.git] / hostapd / ctrl_iface.c
index 93b740e..2153329 100644 (file)
@@ -352,6 +352,59 @@ static int hostapd_ctrl_iface_wps_nfc_token(struct hostapd_data *hapd,
 
        return -1;
 }
+
+
+static int hostapd_ctrl_iface_nfc_get_handover_sel(struct hostapd_data *hapd,
+                                                  char *cmd, char *reply,
+                                                  size_t max_len)
+{
+       struct wpabuf *buf;
+       int res;
+       char *pos;
+       int ndef;
+
+       pos = os_strchr(cmd, ' ');
+       if (pos == NULL)
+               return -1;
+       *pos++ = '\0';
+
+       if (os_strcmp(cmd, "WPS") == 0)
+               ndef = 0;
+       else if (os_strcmp(cmd, "NDEF") == 0)
+               ndef = 1;
+       else
+               return -1;
+
+       if (os_strcmp(pos, "WPS-CR") == 0)
+               buf = hostapd_wps_nfc_hs_cr(hapd, ndef);
+       else
+               buf = NULL;
+       if (buf == NULL)
+               return -1;
+
+       res = wpa_snprintf_hex_uppercase(reply, max_len, wpabuf_head(buf),
+                                        wpabuf_len(buf));
+       reply[res++] = '\n';
+       reply[res] = '\0';
+
+       wpabuf_free(buf);
+
+       return res;
+}
+
+
+static int hostapd_ctrl_iface_nfc_report_handover(struct hostapd_data *hapd,
+                                                 char *cmd)
+{
+       /*
+        * Since NFC connection handover provided full WPS Credential, there is
+        * no need for additional operations within hostapd. Just report this in
+        * debug log.
+        */
+       wpa_printf(MSG_DEBUG, "NFC: Connection handover reported: %s", cmd);
+       return 0;
+}
+
 #endif /* CONFIG_WPS_NFC */
 
 
@@ -913,6 +966,12 @@ static void hostapd_ctrl_iface_receive(int sock, void *eloop_ctx,
        } else if (os_strncmp(buf, "WPS_NFC_TOKEN ", 14) == 0) {
                reply_len = hostapd_ctrl_iface_wps_nfc_token(
                        hapd, buf + 14, reply, reply_size);
+       } else if (os_strncmp(buf, "NFC_GET_HANDOVER_SEL ", 21) == 0) {
+               reply_len = hostapd_ctrl_iface_nfc_get_handover_sel(
+                       hapd, buf + 21, reply, reply_size);
+       } else if (os_strncmp(buf, "NFC_REPORT_HANDOVER ", 20) == 0) {
+               if (hostapd_ctrl_iface_nfc_report_handover(hapd, buf + 20))
+                       reply_len = -1;
 #endif /* CONFIG_WPS_NFC */
 #endif /* CONFIG_WPS */
 #ifdef CONFIG_WNM
@@ -1017,6 +1076,14 @@ int hostapd_ctrl_iface_init(struct hostapd_data *hapd)
                return -1;
        }
 
+       if (!hapd->conf->ctrl_interface_gid_set &&
+           hapd->iface->interfaces->ctrl_iface_group &&
+           chown(hapd->conf->ctrl_interface, -1,
+                 hapd->iface->interfaces->ctrl_iface_group) < 0) {
+               perror("chown[ctrl_interface]");
+               return -1;
+       }
+
 #ifdef ANDROID
        /*
         * Android is using umask 0077 which would leave the control interface
@@ -1089,6 +1156,13 @@ int hostapd_ctrl_iface_init(struct hostapd_data *hapd)
                goto fail;
        }
 
+       if (!hapd->conf->ctrl_interface_gid_set &&
+           hapd->iface->interfaces->ctrl_iface_group &&
+           chown(fname, -1, hapd->iface->interfaces->ctrl_iface_group) < 0) {
+               perror("chown[ctrl_interface/ifname]");
+               goto fail;
+       }
+
        if (chmod(fname, S_IRWXU | S_IRWXG) < 0) {
                perror("chmod[ctrl_interface/ifname]");
                goto fail;
@@ -1257,6 +1331,11 @@ int hostapd_global_ctrl_iface_init(struct hapd_interfaces *interface)
                        perror("mkdir[ctrl_interface]");
                        goto fail;
                }
+       } else if (interface->ctrl_iface_group &&
+                  chown(interface->global_iface_path, -1,
+                        interface->ctrl_iface_group) < 0) {
+               perror("chown[ctrl_interface]");
+               goto fail;
        }
 
        if (os_strlen(interface->global_iface_path) + 1 +
@@ -1310,6 +1389,12 @@ int hostapd_global_ctrl_iface_init(struct hapd_interfaces *interface)
                }
        }
 
+       if (interface->ctrl_iface_group &&
+           chown(fname, -1, interface->ctrl_iface_group) < 0) {
+               perror("chown[ctrl_interface]");
+               goto fail;
+       }
+
        if (chmod(fname, S_IRWXU | S_IRWXG) < 0) {
                perror("chmod[ctrl_interface/ifname]");
                goto fail;