driver_nl80211: Return correct value
[libeap.git] / hostapd / driver_nl80211.c
index 2fdfa57..cd2c66a 100644 (file)
@@ -65,6 +65,7 @@ struct i802_driver_data {
        int we_version;
        struct nl_handle *nl_handle;
        struct nl_cache *nl_cache;
+       struct nl_cb *nl_cb;
        struct genl_family *nl80211;
        int dtim_period, beacon_int;
        unsigned int beacon_set:1;
@@ -219,7 +220,7 @@ static int i802_set_encryption(const char *iface, void *priv, const char *alg,
        if (nl_send_auto_complete(drv->nl_handle, msg) < 0 ||
            (err = nl_wait_for_ack(drv->nl_handle)) < 0) {
                if (err != -ENOENT) {
-                       err = 0;
+                       ret = 0;
                        goto out;
                }
        }
@@ -248,7 +249,7 @@ static int i802_set_encryption(const char *iface, void *priv, const char *alg,
        if (nl_send_auto_complete(drv->nl_handle, msg) < 0 ||
            (err = nl_wait_for_ack(drv->nl_handle)) < 0) {
                if (err != -ENOENT) {
-                       err = 0;
+                       ret = 0;
                        goto out;
                }
        }
@@ -313,7 +314,7 @@ static int i802_get_seqnum(const char *iface, void *priv, const u8 *addr,
        NLA_PUT_U8(msg, NL80211_ATTR_KEY_IDX, idx);
        NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(iface));
 
-       cb = nl_cb_alloc(NL_CB_CUSTOM);
+       cb = nl_cb_clone(drv->nl_cb);
        if (!cb)
                goto out;
 
@@ -574,7 +575,7 @@ static int i802_flush(void *priv)
                goto out;
 
        genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
-                   0, NL80211_CMD_NEW_STATION, 0);
+                   0, NL80211_CMD_DEL_STATION, 0);
 
        /*
         * XXX: FIX! this needs to flush all VLANs too
@@ -660,7 +661,7 @@ static int i802_read_sta_data(void *priv, struct hostap_sta_driver_data *data,
        NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, addr);
        NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(drv->iface));
 
-       cb = nl_cb_alloc(NL_CB_CUSTOM);
+       cb = nl_cb_clone(drv->nl_cb);
        if (!cb)
                goto out;
 
@@ -1415,7 +1416,7 @@ static struct hostapd_hw_modes *i802_get_hw_feature_data(void *priv,
        struct nl_msg *msg;
        int err = -1;
        struct nl_cb *cb = NULL;
-       int finished;
+       int finished = 0;
        struct phy_info_arg result = {
                .num_modes = num_modes,
                .modes = NULL,
@@ -1434,7 +1435,7 @@ static struct hostapd_hw_modes *i802_get_hw_feature_data(void *priv,
 
        NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(drv->iface));
 
-       cb = nl_cb_alloc(NL_CB_CUSTOM);
+       cb = nl_cb_clone(drv->nl_cb);
        if (!cb)
                goto out;
 
@@ -1895,7 +1896,13 @@ static int i802_init_sockets(struct i802_driver_data *drv, const u8 *bssid)
        /*
         * initialise generic netlink and nl80211
         */
-       drv->nl_handle = nl_handle_alloc();
+       drv->nl_cb = nl_cb_alloc(NL_CB_DEFAULT);
+       if (!drv->nl_cb) {
+               printf("Failed to allocate netlink callbacks.\n");
+               return -1;
+       }
+
+       drv->nl_handle = nl_handle_alloc_cb(drv->nl_cb);
        if (!drv->nl_handle) {
                printf("Failed to allocate netlink handle.\n");
                return -1;
@@ -2330,6 +2337,7 @@ static void i802_deinit(void *priv)
        genl_family_put(drv->nl80211);
        nl_cache_free(drv->nl_cache);
        nl_handle_destroy(drv->nl_handle);
+       nl_cb_put(drv->nl_cb);
 
        if (drv->if_indices != drv->default_if_indices)
                free(drv->if_indices);