[WIP] send NULL packets via debugfs

Holger Schurig hs4233 at mail.mn-solutions.de
Tue Jul 3 04:46:36 EDT 2007


I don't suggest that this WIP patch ever get's applied, but I
used this code while debugging. With it, one can force the
sending of NULL packets (if it ever works, that is!) via
the debugfs.

echo 7 >/sys/kernel/debug/libertas_wireless/eth1/nullpkt

for example manufactures an empty TxPD with bits 0,1 and 2
in the Flags field set.

--- libertas-2.6.orig/drivers/net/wireless/libertas/debugfs.c
+++ libertas-2.6/drivers/net/wireless/libertas/debugfs.c
@@ -195,6 +195,37 @@
 	return count;
 }
 
+static ssize_t libertas_nullpkt(struct file *file, const char 
__user *userbuf,
+				  size_t count, loff_t *ppos)
+{
+	wlan_private *priv = file->private_data;
+	ssize_t buf_size, res;
+	int p1;
+	unsigned long addr = get_zeroed_page(GFP_KERNEL);
+	char *buf = (char *)addr;
+
+	buf_size = min(count, len - 1);
+	if (copy_from_user(buf, userbuf, buf_size)) {
+		res = -EFAULT;
+		goto out_unlock;
+	}
+	res = sscanf(buf, "%d", &p1);
+	if (res != 1) {
+		res = -EFAULT;
+		goto out_unlock;
+	}
+	res = libertas_send_null_packet(priv, p1);
+
+	if (!res)
+		res = count;
+	else
+		res = -EINVAL;
+
+out_unlock:
+	free_page(addr);
+	return res;
+}
+
 static int libertas_parse_chan(char *buf, size_t count,
 			struct wlan_ioctl_user_scan_cfg *scan_cfg, int dur)
 {
@@ -1631,6 +1662,7 @@
 	{ "sleepparams", 0644, FOPS(libertas_sleepparams_read,
 				libertas_sleepparams_write), },
 	{ "extscan", 0600, FOPS(NULL, libertas_extscan), },
+	{ "nullpkt", 0600, FOPS(NULL, libertas_nullpkt), },
 	{ "setuserscan", 0600, FOPS(NULL, libertas_setuserscan), },
 };
 



More information about the libertas-dev mailing list