[PATCH] Improvements for iwconfig output if the device is off

Pavel Roskin proski
Tue Jun 7 14:26:20 PDT 2005


Hello!

iwconfig shows some artifacts on interfaces that are down.  In
particular, if I set ESSID on a disabled interface in managed more,
iwconfig still shows the old essid.  However, when the interface goes
up, the new ESSID is used.

I understand the efforts to provide access to raw card RIDs whenever
possible, but sometime it's extremely confusing and can be considered a
bug.

The patch does following:

Wireless stats are not provided for disabled interfaces.

Wireless stats are marked as invalid when the driver cannot provide real
data.  This doesn't affect iwconfig output due to a bug in wireless
tools, but it will be fixed some day.

Data rate is not provided for disabled interfaces.

ESSID for disabled interfaces is read from memory, not from the
hardware.

If ESSID is empty, it's marked inactive, so iwconfig shows it as
off/any.

Signed-off-by: Pavel Roskin <proski at gnu.org>

--- driver/modules/hostap_ioctl.c
+++ driver/modules/hostap_ioctl.c
@@ -34,7 +34,8 @@ static struct iw_statistics *hostap_get_
 	wstats->discard.fragment =
 		local->comm_tallies.rx_message_in_bad_msg_fragments;
 
-	if (local->iw_mode != IW_MODE_MASTER &&
+	if (local->dev_enabled &&
+	    local->iw_mode != IW_MODE_MASTER &&
 	    local->iw_mode != IW_MODE_REPEAT) {
 		int update = 1;
 #ifdef in_atomic
@@ -58,7 +59,7 @@ static struct iw_statistics *hostap_get_
 		wstats->qual.qual = 0;
 		wstats->qual.level = 0;
 		wstats->qual.noise = 0;
-		wstats->qual.updated = 0;
+		wstats->qual.updated = 0x70; /* invalid data */
 	}
 
 	return wstats;
@@ -446,6 +447,9 @@ static int prism2_ioctl_giwrate(struct n
 	local_info_t *local = iface->local;
 	int ret = 0;
 
+	if (!local->dev_enabled)
+		return -ENETDOWN;
+
 	if (local->func->get_rid(dev, HFA384X_RID_TXRATECONTROL, &val, 2, 1) <
 	    0)
 		return -EINVAL;
@@ -920,8 +924,7 @@ static int prism2_ioctl_giwessid(struct 
 	if (iface->type == HOSTAP_INTERFACE_WDS)
 		return -EOPNOTSUPP;
 
-	data->flags = 1; /* active */
-	if (local->iw_mode == IW_MODE_MASTER) {
+	if ((local->iw_mode == IW_MODE_MASTER) || !local->dev_enabled) {
 		data->length = strlen(local->essid);
 		memcpy(essid, local->essid, IW_ESSID_MAX_SIZE);
 	} else {
@@ -937,6 +940,7 @@ static int prism2_ioctl_giwessid(struct 
 		data->length = val;
 		memcpy(essid, ssid + 2, IW_ESSID_MAX_SIZE);
 	}
+	data->flags = (data->length > 0); /* active if not empty */
 
 	return 0;
 }


-- 
Regards,
Pavel Roskin





More information about the Hostap mailing list