[PATCH v2 1/6] nl80211: Add identifier to structs.

greearb at candelatech.com greearb
Thu Oct 20 13:21:19 PDT 2011


From: Ben Greear <greearb at candelatech.com>

This helps one figure out what type of struct the object is,
since they are usually passed around as void* ctx pointers.
Can be used in gdb currently, but run-time checks could
be added later if needed.

Signed-off-by: Ben Greear <greearb at candelatech.com>
---
:100644 100644 5693f59... 23fe8f2... M	src/drivers/driver_nl80211.c
 src/drivers/driver_nl80211.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index 5693f59..23fe8f2 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -104,12 +104,25 @@ static void nl80211_handle_destroy(struct nl_handle *handle)
 #define IF_OPER_UP 6
 #endif
 
+/* TODO:  Move this somewhere central and put struct_ids
+ * in all structs that are passed around as void* so that
+ * we can look at things in the debugger (if nothing else)
+ * have have a clue as to what we're dealing with.
+ */
+enum hostap_struct_id {
+	HAP_DRV_NL80211_GLOBAL = 1,
+	HAP_DRV_NL80211_BSS,
+	HAP_DRV_NL80211_DRV
+};
+
 struct nl80211_global {
+	enum hostap_struct_id struct_id;
 	struct dl_list interfaces;
 	int if_add_ifindex;
 };
 
 struct i802_bss {
+	enum hostap_struct_id struct_id;
 	struct wpa_driver_nl80211_data *drv;
 	struct i802_bss *next;
 	int ifindex;
@@ -121,6 +134,7 @@ struct i802_bss {
 };
 
 struct wpa_driver_nl80211_data {
+	enum hostap_struct_id struct_id;
 	struct nl80211_global *global;
 	struct dl_list list;
 	u8 addr[ETH_ALEN];
@@ -2149,10 +2163,12 @@ static void * wpa_driver_nl80211_init(void *ctx, const char *ifname,
 	drv = os_zalloc(sizeof(*drv));
 	if (drv == NULL)
 		return NULL;
+	drv->struct_id = HAP_DRV_NL80211_DRV;
 	drv->global = global_priv;
 	drv->ctx = ctx;
 	bss = &drv->first_bss;
 	bss->drv = drv;
+	bss->struct_id = HAP_DRV_NL80211_BSS;
 	os_strlcpy(bss->ifname, ifname, sizeof(bss->ifname));
 	drv->monitor_ifidx = -1;
 	drv->monitor_sock = -1;
@@ -7217,6 +7233,7 @@ static void * nl80211_global_init(void)
 	global = os_zalloc(sizeof(*global));
 	if (global == NULL)
 		return NULL;
+	global->struct_id = HAP_DRV_NL80211_GLOBAL;
 	dl_list_init(&global->interfaces);
 	global->if_add_ifindex = -1;
 	return global;
-- 
1.7.3.4




More information about the Hostap mailing list