]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Replace int status/reason_code with u16 variable
authorJouni Malinen <j@w1.fi>
Mon, 22 Apr 2019 17:17:38 +0000 (20:17 +0300)
committerJouni Malinen <j@w1.fi>
Mon, 22 Apr 2019 19:08:07 +0000 (22:08 +0300)
These cases are for the IEEE 802.11 Status Code and Reason Code and
those fields are unsigned 16 bit values, so use the more appropriate
type consistently. This is mainly to document the uses and to make the
source code easier to understand.

Signed-off-by: Jouni Malinen <j@w1.fi>
20 files changed:
src/drivers/driver.h
src/drivers/driver_atheros.c
src/drivers/driver_bsd.c
src/drivers/driver_hostap.c
src/drivers/driver_ndis.c
src/drivers/driver_nl80211.c
src/drivers/driver_privsep.c
src/drivers/driver_wext.c
src/rsn_supp/wpa.h
src/rsn_supp/wpa_i.h
tests/eapol-fuzzer/eapol-fuzzer.c
tests/test-eapol.c
wpa_supplicant/driver_i.h
wpa_supplicant/ibss_rsn.c
wpa_supplicant/notify.c
wpa_supplicant/notify.h
wpa_supplicant/preauth_test.c
wpa_supplicant/wpa_supplicant.c
wpa_supplicant/wpa_supplicant_i.h
wpa_supplicant/wpas_glue.c

index e7c8f318f35d765e2c1ed43dc5ac3b561f42a745..cb561acba1aaaa1664c11610230ef4397a52f51a 100644 (file)
@@ -2337,7 +2337,7 @@ struct wpa_driver_ops {
         *
         * Returns: 0 on success, -1 on failure
         */
-       int (*deauthenticate)(void *priv, const u8 *addr, int reason_code);
+       int (*deauthenticate)(void *priv, const u8 *addr, u16 reason_code);
 
        /**
         * associate - Request driver to associate
@@ -2806,7 +2806,7 @@ struct wpa_driver_ops {
         * a Deauthentication frame to be sent to it.
         */
        int (*sta_deauth)(void *priv, const u8 *own_addr, const u8 *addr,
-                         int reason);
+                         u16 reason);
 
        /**
         * sta_disassoc - Disassociate a station (AP only)
@@ -2820,7 +2820,7 @@ struct wpa_driver_ops {
         * a Disassociation frame to be sent to it.
         */
        int (*sta_disassoc)(void *priv, const u8 *own_addr, const u8 *addr,
-                           int reason);
+                           u16 reason);
 
        /**
         * sta_remove - Remove a station entry (AP only)
index 807cd94691d0d8f39571564df85ebf1143fd5d5e..840d4ff4057ee96918bd9e855220c4826d114939 100644 (file)
@@ -86,7 +86,7 @@ struct atheros_driver_data {
 };
 
 static int atheros_sta_deauth(void *priv, const u8 *own_addr, const u8 *addr,
-                             int reason_code);
+                             u16 reason_code);
 static int atheros_set_privacy(void *priv, int enabled);
 
 static const char * athr_get_ioctl_name(int op)
@@ -761,7 +761,7 @@ atheros_set_opt_ie(void *priv, const u8 *ie, size_t ie_len)
 
 static int
 atheros_sta_deauth(void *priv, const u8 *own_addr, const u8 *addr,
-                  int reason_code)
+                  u16 reason_code)
 {
        struct atheros_driver_data *drv = priv;
        struct ieee80211req_mlme mlme;
@@ -785,7 +785,7 @@ atheros_sta_deauth(void *priv, const u8 *own_addr, const u8 *addr,
 
 static int
 atheros_sta_disassoc(void *priv, const u8 *own_addr, const u8 *addr,
-                    int reason_code)
+                    u16 reason_code)
 {
        struct atheros_driver_data *drv = priv;
        struct ieee80211req_mlme mlme;
index 46754968f13d7e84a98a65adb7aa44a2f27e675b..82ca0612eefa00b53e4f194bd2aabc80fc84a6b1 100644 (file)
@@ -663,7 +663,7 @@ rtbuf_len(void)
 #undef WPA_OUI_TYPE
 
 static int bsd_sta_deauth(void *priv, const u8 *own_addr, const u8 *addr,
-                         int reason_code);
+                         u16 reason_code);
 
 static const char *
 ether_sprintf(const u8 *addr)
@@ -755,7 +755,7 @@ bsd_read_sta_driver_data(void *priv, struct hostap_sta_driver_data *data,
 }
 
 static int
-bsd_sta_deauth(void *priv, const u8 *own_addr, const u8 *addr, int reason_code)
+bsd_sta_deauth(void *priv, const u8 *own_addr, const u8 *addr, u16 reason_code)
 {
        return bsd_send_mlme_param(priv, IEEE80211_MLME_DEAUTH, reason_code,
                                   addr);
@@ -763,7 +763,7 @@ bsd_sta_deauth(void *priv, const u8 *own_addr, const u8 *addr, int reason_code)
 
 static int
 bsd_sta_disassoc(void *priv, const u8 *own_addr, const u8 *addr,
-                int reason_code)
+                u16 reason_code)
 {
        return bsd_send_mlme_param(priv, IEEE80211_MLME_DISASSOC, reason_code,
                                   addr);
@@ -1026,7 +1026,7 @@ wpa_driver_bsd_set_drop_unencrypted(void *priv, int enabled)
 }
 
 static int
-wpa_driver_bsd_deauthenticate(void *priv, const u8 *addr, int reason_code)
+wpa_driver_bsd_deauthenticate(void *priv, const u8 *addr, u16 reason_code)
 {
        return bsd_send_mlme_param(priv, IEEE80211_MLME_DEAUTH, reason_code,
                                   addr);
index 61b39b19721c1cf5789f62c7410636ce78432ea1..186eccbf2181e33153f345bd2c2eb3dd2b3ebc51 100644 (file)
@@ -1028,7 +1028,7 @@ static void hostap_driver_deinit(void *priv)
 
 
 static int hostap_sta_deauth(void *priv, const u8 *own_addr, const u8 *addr,
-                            int reason)
+                            u16 reason)
 {
        struct hostap_driver_data *drv = priv;
        struct ieee80211_mgmt mgmt;
@@ -1076,7 +1076,7 @@ static int hostap_set_freq(void *priv, struct hostapd_freq_params *freq)
 
 
 static int hostap_sta_disassoc(void *priv, const u8 *own_addr, const u8 *addr,
-                              int reason)
+                              u16 reason)
 {
        struct hostap_driver_data *drv = priv;
        struct ieee80211_mgmt mgmt;
index 614c4521e6ff4c2320e6b506d489a41f49f8ffae..5b4b9247ecd157c4acb139bed9b303fcddaf9b5a 100644 (file)
@@ -719,7 +719,7 @@ static int wpa_driver_ndis_disconnect(struct wpa_driver_ndis_data *drv)
 
 
 static int wpa_driver_ndis_deauthenticate(void *priv, const u8 *addr,
-                                         int reason_code)
+                                         u16 reason_code)
 {
        struct wpa_driver_ndis_data *drv = priv;
        return wpa_driver_ndis_disconnect(drv);
index 54fe3900096a83063c77d1781b4090bbb340c089..5da8a793b165e455a46041a4093c982ec2510179 100644 (file)
@@ -236,7 +236,7 @@ static int nl80211_put_mesh_config(struct nl_msg *msg,
                                   struct wpa_driver_mesh_bss_params *params);
 #endif /* CONFIG_MESH */
 static int i802_sta_disassoc(void *priv, const u8 *own_addr, const u8 *addr,
-                            int reason);
+                            u16 reason);
 
 
 /* Converts nl80211_chan_width to a common format */
@@ -3282,7 +3282,7 @@ int wpa_driver_nl80211_mlme(struct wpa_driver_nl80211_data *drv,
 
 
 static int wpa_driver_nl80211_disconnect(struct wpa_driver_nl80211_data *drv,
-                                        int reason_code,
+                                        u16 reason_code,
                                         struct nl_handle *nl_connect)
 {
        int ret;
@@ -3304,7 +3304,7 @@ static int wpa_driver_nl80211_disconnect(struct wpa_driver_nl80211_data *drv,
 
 
 static int wpa_driver_nl80211_deauthenticate(struct i802_bss *bss,
-                                            const u8 *addr, int reason_code)
+                                            const u8 *addr, u16 reason_code)
 {
        struct wpa_driver_nl80211_data *drv = bss->drv;
        int ret;
@@ -6550,7 +6550,7 @@ static int i802_sta_clear_stats(void *priv, const u8 *addr)
 
 
 static int i802_sta_deauth(void *priv, const u8 *own_addr, const u8 *addr,
-                          int reason)
+                          u16 reason)
 {
        struct i802_bss *bss = priv;
        struct wpa_driver_nl80211_data *drv = bss->drv;
@@ -6585,7 +6585,7 @@ static int i802_sta_deauth(void *priv, const u8 *own_addr, const u8 *addr,
 
 
 static int i802_sta_disassoc(void *priv, const u8 *own_addr, const u8 *addr,
-                            int reason)
+                            u16 reason)
 {
        struct i802_bss *bss = priv;
        struct wpa_driver_nl80211_data *drv = bss->drv;
@@ -8585,7 +8585,7 @@ static int driver_nl80211_scan2(void *priv,
 
 
 static int driver_nl80211_deauthenticate(void *priv, const u8 *addr,
-                                        int reason_code)
+                                        u16 reason_code)
 {
        struct i802_bss *bss = priv;
        return wpa_driver_nl80211_deauthenticate(bss, addr, reason_code);
index a3f0837e156960727e20f81aa4955ac813d75008..55cf61885741936dbf2e9a19f17e53f515cf4f79 100644 (file)
@@ -368,7 +368,7 @@ static int wpa_driver_privsep_get_ssid(void *priv, u8 *ssid)
 
 
 static int wpa_driver_privsep_deauthenticate(void *priv, const u8 *addr,
-                                         int reason_code)
+                                            u16 reason_code)
 {
        //struct wpa_driver_privsep_data *drv = priv;
        wpa_printf(MSG_DEBUG, "%s addr=" MACSTR " reason_code=%d",
index f7755cccde27bf9ef42b4e54b2d6824375a97bf5..4d4a05d0cb7213b85bdccf3d2816d205800194fa 100644 (file)
@@ -1915,7 +1915,7 @@ static int wpa_driver_wext_set_drop_unencrypted(void *priv,
 
 
 static int wpa_driver_wext_mlme(struct wpa_driver_wext_data *drv,
-                               const u8 *addr, int cmd, int reason_code)
+                               const u8 *addr, int cmd, u16 reason_code)
 {
        struct iwreq iwr;
        struct iw_mlme mlme;
@@ -1998,7 +1998,7 @@ static void wpa_driver_wext_disconnect(struct wpa_driver_wext_data *drv)
 
 
 static int wpa_driver_wext_deauthenticate(void *priv, const u8 *addr,
-                                         int reason_code)
+                                         u16 reason_code)
 {
        struct wpa_driver_wext_data *drv = priv;
        int ret;
index 8903f8e14c691ead13161b1a4e7dcd6de3129e1c..ae9cd6484baa3e3c043972b7ff3f990a83b8ed24 100644 (file)
@@ -26,7 +26,7 @@ struct wpa_sm_ctx {
 
        void (*set_state)(void *ctx, enum wpa_states state);
        enum wpa_states (*get_state)(void *ctx);
-       void (*deauthenticate)(void * ctx, int reason_code);
+       void (*deauthenticate)(void * ctx, u16 reason_code);
        int (*set_key)(void *ctx, enum wpa_alg alg,
                       const u8 *addr, int key_idx, int set_tx,
                       const u8 *seq, size_t seq_len,
index 0c5955c66f882b4eb9596801afc83c96fc677d4e..d86734b0df55925d47acba040be952a63e949368 100644 (file)
@@ -188,7 +188,7 @@ static inline enum wpa_states wpa_sm_get_state(struct wpa_sm *sm)
        return sm->ctx->get_state(sm->ctx->ctx);
 }
 
-static inline void wpa_sm_deauthenticate(struct wpa_sm *sm, int reason_code)
+static inline void wpa_sm_deauthenticate(struct wpa_sm *sm, u16 reason_code)
 {
        WPA_ASSERT(sm->ctx->deauthenticate);
        sm->ctx->deauthenticate(sm->ctx->ctx, reason_code);
index 634278fd1c6a50ce12ffbfa41a6abe4191c27559..b54614991dafc0610c1b53ad6b7c91359e97885e 100644 (file)
@@ -72,7 +72,7 @@ static void set_state(void *arg, enum wpa_states state)
 }
 
 
-static void deauthenticate(void *arg, int reason_code)
+static void deauthenticate(void *arg, u16 reason_code)
 {
 }
 
index 0a0844b636fbb4857c58ec190e1727bc7b71ed84..57f2118e2bea170952829fbeb07c8dcc8a536214 100644 (file)
@@ -270,7 +270,7 @@ static void * supp_get_network_ctx(void *ctx)
 }
 
 
-static void supp_deauthenticate(void *ctx, int reason_code)
+static void supp_deauthenticate(void *ctx, u16 reason_code)
 {
        wpa_printf(MSG_DEBUG, "SUPP: %s(%d)", __func__, reason_code);
 }
index 4a9f472e84eed1c7a14fa728bb30aa4ade75d4e0..f073b8a6d14bc1eecc20e869a03dbc887b34d03e 100644 (file)
@@ -168,7 +168,7 @@ static inline int wpa_drv_get_seqnum(struct wpa_supplicant *wpa_s,
 }
 
 static inline int wpa_drv_sta_deauth(struct wpa_supplicant *wpa_s,
-                                    const u8 *addr, int reason_code)
+                                    const u8 *addr, u16 reason_code)
 {
        if (wpa_s->driver->sta_deauth) {
                return wpa_s->driver->sta_deauth(wpa_s->drv_priv,
@@ -179,7 +179,7 @@ static inline int wpa_drv_sta_deauth(struct wpa_supplicant *wpa_s,
 }
 
 static inline int wpa_drv_deauthenticate(struct wpa_supplicant *wpa_s,
-                                        const u8 *addr, int reason_code)
+                                        const u8 *addr, u16 reason_code)
 {
        if (wpa_s->driver->deauthenticate) {
                return wpa_s->driver->deauthenticate(wpa_s->drv_priv, addr,
index e96ea65a788751032739bd1e80e7b9d934235884..6934c4725da3f4447764d689ed903686bff5ea89 100644 (file)
@@ -193,7 +193,7 @@ static void supp_cancel_auth_timeout(void *ctx)
 }
 
 
-static void supp_deauthenticate(void * ctx, int reason_code)
+static void supp_deauthenticate(void * ctx, u16 reason_code)
 {
        wpa_printf(MSG_DEBUG, "SUPP: %s (TODO)", __func__);
 }
index bedb74b34440cebf1cb78298802eeb76a011245a..b0865096b2d7239ca95e5d451b3ecc9c6ec41e62 100644 (file)
@@ -901,7 +901,7 @@ void wpas_notify_mesh_group_started(struct wpa_supplicant *wpa_s,
 
 void wpas_notify_mesh_group_removed(struct wpa_supplicant *wpa_s,
                                    const u8 *meshid, u8 meshid_len,
-                                   int reason_code)
+                                   u16 reason_code)
 {
        if (wpa_s->p2p_mgmt)
                return;
@@ -922,7 +922,7 @@ void wpas_notify_mesh_peer_connected(struct wpa_supplicant *wpa_s,
 
 
 void wpas_notify_mesh_peer_disconnected(struct wpa_supplicant *wpa_s,
-                                       const u8 *peer_addr, int reason_code)
+                                       const u8 *peer_addr, u16 reason_code)
 {
        if (wpa_s->p2p_mgmt)
                return;
index 65f513ea9770803e010610f5109ca60e96428288..d3e73f0b269e2a49a1024c8748a0855c270f7dd7 100644 (file)
@@ -151,10 +151,10 @@ void wpas_notify_mesh_group_started(struct wpa_supplicant *wpa_s,
                                    struct wpa_ssid *ssid);
 void wpas_notify_mesh_group_removed(struct wpa_supplicant *wpa_s,
                                    const u8 *meshid, u8 meshid_len,
-                                   int reason_code);
+                                   u16 reason_code);
 void wpas_notify_mesh_peer_connected(struct wpa_supplicant *wpa_s,
                                     const u8 *peer_addr);
 void wpas_notify_mesh_peer_disconnected(struct wpa_supplicant *wpa_s,
-                                       const u8 *peer_addr, int reason_code);
+                                       const u8 *peer_addr, u16 reason_code);
 
 #endif /* NOTIFY_H */
index f2fff550aa81e79d98baeca784ca316fb0f2d108..3f2da34e5bf011a80cf254c5ea59d57183d5c62b 100644 (file)
@@ -35,7 +35,7 @@ struct preauth_test_data {
 };
 
 
-static void _wpa_supplicant_deauthenticate(void *wpa_s, int reason_code)
+static void _wpa_supplicant_deauthenticate(void *wpa_s, u16 reason_code)
 {
        wpa_supplicant_deauthenticate(wpa_s, reason_code);
 }
index 8050ad3e7620b0ccf911f17f9d387709dc5b15a5..2ddd4f2d3a6fd428107e63cffe6690a09010731a 100644 (file)
@@ -3422,7 +3422,7 @@ static void wpa_supplicant_clear_connection(struct wpa_supplicant *wpa_s,
  * current AP.
  */
 void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s,
-                                  int reason_code)
+                                  u16 reason_code)
 {
        u8 *addr = NULL;
        union wpa_event_data event;
@@ -3474,7 +3474,7 @@ void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s,
        if (addr) {
                wpa_drv_deauthenticate(wpa_s, addr, reason_code);
                os_memset(&event, 0, sizeof(event));
-               event.deauth_info.reason_code = (u16) reason_code;
+               event.deauth_info.reason_code = reason_code;
                event.deauth_info.locally_generated = 1;
                wpa_supplicant_event(wpa_s, EVENT_DEAUTH, &event);
                if (zero_addr)
index 16e4db62aeef1dbdd4cd119d4edc272aba7ad3ac..8ea3c5a1d7c7987b95eec047da6f0e2de26c5716 100644 (file)
@@ -1291,7 +1291,7 @@ struct wpa_ssid * wpa_supplicant_get_ssid(struct wpa_supplicant *wpa_s);
 const char * wpa_supplicant_get_eap_mode(struct wpa_supplicant *wpa_s);
 void wpa_supplicant_cancel_auth_timeout(struct wpa_supplicant *wpa_s);
 void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s,
-                                  int reason_code);
+                                  u16 reason_code);
 
 struct wpa_ssid * wpa_supplicant_add_network(struct wpa_supplicant *wpa_s);
 int wpa_supplicant_remove_network(struct wpa_supplicant *wpa_s, int id);
index 449e04acded8a754adeb5ea903e17f2506d884da..e98bf11474f4038609398e1c5defe88a961b3333 100644 (file)
@@ -464,7 +464,7 @@ static enum wpa_states _wpa_supplicant_get_state(void *wpa_s)
 }
 
 
-static void _wpa_supplicant_deauthenticate(void *wpa_s, int reason_code)
+static void _wpa_supplicant_deauthenticate(void *wpa_s, u16 reason_code)
 {
        wpa_supplicant_deauthenticate(wpa_s, reason_code);
        /* Schedule a scan to make sure we continue looking for networks */