]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
driver: Move sta_auth() arguments to a struct
authorJeffin Mammen <jmammen@qti.qualcomm.com>
Fri, 21 Apr 2017 15:15:37 +0000 (18:15 +0300)
committerJouni Malinen <j@w1.fi>
Sun, 23 Apr 2017 14:47:12 +0000 (17:47 +0300)
This makes it easier to add more parameters without having to change the
callback function prototype.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
src/ap/ap_drv_ops.c
src/drivers/driver.h
src/drivers/driver_atheros.c

index e7b6800c113044b87a56dddcdfcf567a4f79f2e0..b60f77001adfe2d258bfd140c90a5dca5ce441ef 100644 (file)
@@ -347,10 +347,21 @@ int hostapd_add_sta_node(struct hostapd_data *hapd, const u8 *addr,
 int hostapd_sta_auth(struct hostapd_data *hapd, const u8 *addr,
                     u16 seq, u16 status, const u8 *ie, size_t len)
 {
+       struct wpa_driver_sta_auth_params params;
+
        if (hapd->driver == NULL || hapd->driver->sta_auth == NULL)
                return 0;
-       return hapd->driver->sta_auth(hapd->drv_priv, hapd->own_addr, addr,
-                                     seq, status, ie, len);
+
+       os_memset(&params, 0, sizeof(params));
+
+       params.own_addr = hapd->own_addr;
+       params.addr = addr;
+       params.seq = seq;
+       params.status = status;
+       params.ie = ie;
+       params.len = len;
+
+       return hapd->driver->sta_auth(hapd->drv_priv, &params);
 }
 
 
index 0becfac07d1bba5f62b993f28a6f1b93286cea04..3a3a3dff1aa4f8f5ac0a0ad541d0e0f07c91f4eb 100644 (file)
@@ -684,6 +684,43 @@ struct hostapd_freq_params {
        int bandwidth;
 };
 
+/**
+ * struct wpa_driver_sta_auth_params - Authentication parameters
+ * Data for struct wpa_driver_ops::sta_auth().
+ */
+struct wpa_driver_sta_auth_params {
+
+       /**
+        * own_addr - Source address and BSSID for authentication frame
+        */
+       const u8 *own_addr;
+
+       /**
+        * addr - MAC address of the station to associate
+        */
+       const u8 *addr;
+
+       /**
+        * seq - authentication sequence number
+        */
+       u16 seq;
+
+       /**
+        * status - authentication response status code
+        */
+       u16 status;
+
+       /**
+        * ie - authentication frame ie buffer
+        */
+       const u8 *ie;
+
+       /**
+        * len - ie buffer length
+        */
+       size_t len;
+};
+
 /**
  * struct wpa_driver_associate_params - Association parameters
  * Data for struct wpa_driver_ops::associate().
@@ -3313,19 +3350,13 @@ struct wpa_driver_ops {
 
        /**
         * sta_auth - Station authentication indication
-        * @priv: Private driver interface data
-        * @own_addr: Source address and BSSID for authentication frame
-        * @addr: MAC address of the station to associate
-        * @seq: authentication sequence number
-        * @status: authentication response status code
-        * @ie: authentication frame ie buffer
-        * @len: ie buffer length
+        * @priv: private driver interface data
+        * @params: Station authentication parameters
         *
-        * This function indicates the driver to send Authentication frame
-        * to the station.
+        * Returns: 0 on success, -1 on failure
         */
-        int (*sta_auth)(void *priv, const u8 *own_addr, const u8 *addr,
-                        u16 seq, u16 status, const u8 *ie, size_t len);
+        int (*sta_auth)(void *priv,
+                        struct wpa_driver_sta_auth_params *params);
 
        /**
         * add_tspec - Add traffic stream
index 88fded25636c763151a1b475f3ae203f89720bb7..c64183ccc849a39266f862379058dd8835d1289d 100644 (file)
@@ -1056,30 +1056,29 @@ atheros_set_ap_wps_ie(void *priv, const struct wpabuf *beacon,
 
 #if defined(CONFIG_IEEE80211R) || defined(CONFIG_IEEE80211W) || defined(CONFIG_FILS)
 static int
-atheros_sta_auth(void *priv, const u8 *own_addr, const u8 *addr, u16 seq,
-                u16 status_code, const u8 *ie, size_t len)
+atheros_sta_auth(void *priv, struct wpa_driver_sta_auth_params *params)
 {
        struct atheros_driver_data *drv = priv;
        struct ieee80211req_mlme mlme;
        int ret;
 
        wpa_printf(MSG_DEBUG, "%s: addr=%s status_code=%d",
-                  __func__, ether_sprintf(addr), status_code);
+                  __func__, ether_sprintf(params->addr), params->status);
 
        mlme.im_op = IEEE80211_MLME_AUTH;
-       mlme.im_reason = status_code;
-       mlme.im_seq = seq;
-       os_memcpy(mlme.im_macaddr, addr, IEEE80211_ADDR_LEN);
-       mlme.im_optie_len = len;
-       if (len) {
-               if (len < IEEE80211_MAX_OPT_IE) {
-                       os_memcpy(mlme.im_optie, ie, len);
+       mlme.im_reason = params->status;
+       mlme.im_seq = params->seq;
+       os_memcpy(mlme.im_macaddr, params->addr, IEEE80211_ADDR_LEN);
+       mlme.im_optie_len = params->len;
+       if (params->len) {
+               if (params->len < IEEE80211_MAX_OPT_IE) {
+                       os_memcpy(mlme.im_optie, params->ie, params->len);
                } else {
                        wpa_printf(MSG_DEBUG, "%s: Not enough space to copy "
                                   "opt_ie STA (addr " MACSTR " reason %d, "
                                   "ie_len %d)",
-                                  __func__, MAC2STR(addr), status_code,
-                                  (int) len);
+                                  __func__, MAC2STR(params->addr),
+                                  params->status, (int) params->len);
                        return -1;
                }
        }
@@ -1087,7 +1086,7 @@ atheros_sta_auth(void *priv, const u8 *own_addr, const u8 *addr, u16 seq,
        if (ret < 0) {
                wpa_printf(MSG_DEBUG, "%s: Failed to auth STA (addr " MACSTR
                           " reason %d)",
-                          __func__, MAC2STR(addr), status_code);
+                          __func__, MAC2STR(params->addr), params->status);
        }
        return ret;
 }