[RFC 07/13] nl80211: Move functions to get rid of forward declarations.

greearb at candelatech.com greearb
Fri Oct 14 15:34:31 PDT 2011


From: Ben Greear <greearb at candelatech.com>

No functional code changes in this commit.

Signed-off-by: Ben Greear <greearb at candelatech.com>
---
:100644 100644 121bbb9... d1fdfa8... M	src/drivers/driver_nl80211.c
 src/drivers/driver_nl80211.c |  273 +++++++++++++++++++++---------------------
 1 files changed, 135 insertions(+), 138 deletions(-)

diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index 121bbb9..d1fdfa8 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -43,9 +43,6 @@
 #include "driver.h"
 
 
-static void wpa_driver_nl80211_deinit(void *priv);
-static void nl80211_global_deinit(void *priv);
-
 #ifdef CONFIG_LIBNL20
 /* libnl 2.0 compatibility code */
 #define nl_handle nl_sock
@@ -2054,6 +2051,105 @@ static void nl80211_l2_read(void *ctx, const u8 *src_addr, const u8 *buf,
 #endif /* CONFIG_AP */
 
 
+static int wpa_driver_nl80211_del_beacon(struct wpa_driver_nl80211_data *drv)
+{
+	struct nl_msg *msg;
+
+	msg = nlmsg_alloc();
+	if (!msg)
+		return -ENOMEM;
+
+	genlmsg_put(msg, 0, 0, genl_family_get_id(drv->global->nl80211), 0,
+		    0, NL80211_CMD_DEL_BEACON, 0);
+	NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, drv->ifindex);
+
+	return send_and_recv_msgs(drv, msg, NULL, NULL);
+ nla_put_failure:
+	return -ENOBUFS;
+}
+
+
+/**
+ * wpa_driver_nl80211_deinit - Deinitialize nl80211 driver interface
+ * @priv: Pointer to private nl80211 data from wpa_driver_nl80211_init()
+ *
+ * Shut down driver interface and processing of driver events. Free
+ * private data buffer if one was allocated in wpa_driver_nl80211_init().
+ */
+static void wpa_driver_nl80211_deinit(void *priv)
+{
+	struct i802_bss *bss = priv;
+	struct wpa_driver_nl80211_data *drv = bss->drv;
+
+#ifdef CONFIG_AP
+	if (drv->l2)
+		l2_packet_deinit(drv->l2);
+#endif /* CONFIG_AP */
+
+	if (drv->probe_req_report)
+		wpa_driver_nl80211_probe_req_report(bss, 0);
+
+	if (bss->added_if_into_bridge) {
+		if (linux_br_del_if(drv->ioctl_sock, bss->brname, bss->ifname)
+		    < 0)
+			wpa_msg(drv->ctx, MSG_INFO, "nl80211: Failed to remove "
+				"interface %s from bridge %s: %s",
+				bss->ifname, bss->brname, strerror(errno));
+	}
+	if (bss->added_bridge) {
+		if (linux_br_del(drv->ioctl_sock, bss->brname) < 0)
+			wpa_msg(drv->ctx, MSG_INFO, "nl80211: Failed to remove "
+				"bridge %s: %s",
+				bss->brname, strerror(errno));
+	}
+
+	nl80211_remove_monitor_interface(drv);
+
+	if (is_ap_interface(drv->nlmode))
+		wpa_driver_nl80211_del_beacon(drv);
+
+#ifdef HOSTAPD
+	if (drv->last_freq_ht) {
+		/* Clear HT flags from the driver */
+		struct hostapd_freq_params freq;
+		os_memset(&freq, 0, sizeof(freq));
+		freq.freq = drv->last_freq;
+		i802_set_freq(priv, &freq);
+	}
+
+	if (drv->eapol_sock >= 0) {
+		eloop_unregister_read_sock(drv->eapol_sock);
+		close(drv->eapol_sock);
+	}
+
+	if (drv->if_indices != drv->default_if_indices)
+		os_free(drv->if_indices);
+#endif /* HOSTAPD */
+
+	if (drv->disable_11b_rates)
+		nl80211_disable_11b_rates(drv, drv->ifindex, 0);
+
+	netlink_send_oper_ifla(drv->global->netlink, drv->ifindex, 0, IF_OPER_UP);
+	if (drv->rfkill)
+		rfkill_deinit(drv->rfkill);
+
+	eloop_cancel_timeout(wpa_driver_nl80211_scan_timeout, drv, drv->ctx);
+
+	(void) linux_set_iface_flags(drv->ioctl_sock, bss->ifname, 0);
+	wpa_driver_nl80211_set_mode(bss, NL80211_IFTYPE_STATION);
+
+	if (drv->ioctl_sock >= 0)
+		close(drv->ioctl_sock);
+
+	os_free(drv->filter_ssids);
+
+	if (drv->global)
+		dl_list_del(&drv->list);
+
+	os_free(drv);
+}
+
+
 /**
  * wpa_driver_nl80211_init - Initialize nl80211 driver interface
  * @ctx: context to be used when calling wpa_supplicant functions,
@@ -2283,105 +2379,6 @@ wpa_driver_nl80211_finish_drv_init(struct wpa_driver_nl80211_data *drv)
 }
 
 
-static int wpa_driver_nl80211_del_beacon(struct wpa_driver_nl80211_data *drv)
-{
-	struct nl_msg *msg;
-
-	msg = nlmsg_alloc();
-	if (!msg)
-		return -ENOMEM;
-
-	genlmsg_put(msg, 0, 0, genl_family_get_id(drv->global->nl80211), 0,
-		    0, NL80211_CMD_DEL_BEACON, 0);
-	NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, drv->ifindex);
-
-	return send_and_recv_msgs(drv, msg, NULL, NULL);
- nla_put_failure:
-	return -ENOBUFS;
-}
-
-
-/**
- * wpa_driver_nl80211_deinit - Deinitialize nl80211 driver interface
- * @priv: Pointer to private nl80211 data from wpa_driver_nl80211_init()
- *
- * Shut down driver interface and processing of driver events. Free
- * private data buffer if one was allocated in wpa_driver_nl80211_init().
- */
-static void wpa_driver_nl80211_deinit(void *priv)
-{
-	struct i802_bss *bss = priv;
-	struct wpa_driver_nl80211_data *drv = bss->drv;
-
-#ifdef CONFIG_AP
-	if (drv->l2)
-		l2_packet_deinit(drv->l2);
-#endif /* CONFIG_AP */
-
-	if (drv->probe_req_report)
-		wpa_driver_nl80211_probe_req_report(bss, 0);
-
-	if (bss->added_if_into_bridge) {
-		if (linux_br_del_if(drv->ioctl_sock, bss->brname, bss->ifname)
-		    < 0)
-			wpa_msg(drv->ctx, MSG_INFO, "nl80211: Failed to remove "
-				"interface %s from bridge %s: %s",
-				bss->ifname, bss->brname, strerror(errno));
-	}
-	if (bss->added_bridge) {
-		if (linux_br_del(drv->ioctl_sock, bss->brname) < 0)
-			wpa_msg(drv->ctx, MSG_INFO, "nl80211: Failed to remove "
-				"bridge %s: %s",
-				bss->brname, strerror(errno));
-	}
-
-	nl80211_remove_monitor_interface(drv);
-
-	if (is_ap_interface(drv->nlmode))
-		wpa_driver_nl80211_del_beacon(drv);
-
-#ifdef HOSTAPD
-	if (drv->last_freq_ht) {
-		/* Clear HT flags from the driver */
-		struct hostapd_freq_params freq;
-		os_memset(&freq, 0, sizeof(freq));
-		freq.freq = drv->last_freq;
-		i802_set_freq(priv, &freq);
-	}
-
-	if (drv->eapol_sock >= 0) {
-		eloop_unregister_read_sock(drv->eapol_sock);
-		close(drv->eapol_sock);
-	}
-
-	if (drv->if_indices != drv->default_if_indices)
-		os_free(drv->if_indices);
-#endif /* HOSTAPD */
-
-	if (drv->disable_11b_rates)
-		nl80211_disable_11b_rates(drv, drv->ifindex, 0);
-
-	netlink_send_oper_ifla(drv->global->netlink, drv->ifindex, 0, IF_OPER_UP);
-	if (drv->rfkill)
-		rfkill_deinit(drv->rfkill);
-
-	eloop_cancel_timeout(wpa_driver_nl80211_scan_timeout, drv, drv->ctx);
-
-	(void) linux_set_iface_flags(drv->ioctl_sock, bss->ifname, 0);
-	wpa_driver_nl80211_set_mode(bss, NL80211_IFTYPE_STATION);
-
-	if (drv->ioctl_sock >= 0)
-		close(drv->ioctl_sock);
-
-	os_free(drv->filter_ssids);
-
-	if (drv->global)
-		dl_list_del(&drv->list);
-
-	os_free(drv);
-}
-
-
 /**
  * wpa_driver_nl80211_scan_timeout - Scan timeout to report scan completion
  * @eloop_ctx: Driver private data
@@ -6986,6 +6983,42 @@ static int nl80211_set_param(void *priv, const char *param)
 }
 
 
+static void nl80211_global_deinit(void *priv)
+{
+	struct nl80211_global *global = priv;
+	if (global == NULL)
+		return;
+	if (!dl_list_empty(&global->interfaces)) {
+		wpa_msg(NULL, MSG_ERROR, "nl80211: %u interface(s) remain at "
+			"nl80211_global_deinit",
+			dl_list_len(&global->interfaces));
+	}
+
+	nl80211_global_deinit_handle_preq(global);
+
+	if (global->netlink)
+		netlink_deinit(global->netlink);
+
+	if (global->nl_cache_event)
+		nl_cache_free(global->nl_cache_event);
+	if (global->nl_cache)
+		nl_cache_free(global->nl_cache);
+	if (global->nl_handle_event)
+		nl80211_handle_destroy(global->nl_handle_event);
+	if (global->nl_handle)
+		nl80211_handle_destroy(global->nl_handle);
+	if (global->nl_cb)
+		nl_cb_put(global->nl_cb);
+	if (global->nl80211)
+		genl_family_put(global->nl80211);
+
+	if (global == global_ptr)
+		global_ptr = NULL;
+
+	os_free(global);
+}
+
+
 static void * nl80211_global_init(void)
 {
 	struct nl80211_global *global = NULL;
@@ -7128,42 +7161,6 @@ err:
 }
 
 
-static void nl80211_global_deinit(void *priv)
-{
-	struct nl80211_global *global = priv;
-	if (global == NULL)
-		return;
-	if (!dl_list_empty(&global->interfaces)) {
-		wpa_msg(NULL, MSG_ERROR, "nl80211: %u interface(s) remain at "
-			"nl80211_global_deinit",
-			dl_list_len(&global->interfaces));
-	}
-
-	nl80211_global_deinit_handle_preq(global);
-
-	if (global->netlink)
-		netlink_deinit(global->netlink);
-
-	if (global->nl_cache_event)
-		nl_cache_free(global->nl_cache_event);
-	if (global->nl_cache)
-		nl_cache_free(global->nl_cache);
-	if (global->nl_handle_event)
-		nl80211_handle_destroy(global->nl_handle_event);
-	if (global->nl_handle)
-		nl80211_handle_destroy(global->nl_handle);
-	if (global->nl_cb)
-		nl_cb_put(global->nl_cb);
-	if (global->nl80211)
-		genl_family_put(global->nl80211);
-
-	if (global == global_ptr)
-		global_ptr = NULL;
-
-	os_free(global);
-}
-
-
 static const char * nl80211_get_radio_name(void *priv)
 {
 	struct i802_bss *bss = priv;
-- 
1.7.3.4




More information about the Hostap mailing list