aboutsummaryrefslogtreecommitdiffstats
path: root/packages/kexecboot/linux-kexecboot-2.6.26/hostap-monitor-mode.patch
blob: 641fd19e503d0e06f3d378a1801def21fbd70597 (generated by cgit 1.2.3-korg (git 2.39.0) at 2024-06-17 12:06:50 +0000
ghlight .sh { color: #e6db74 } /* Literal.String.Heredoc */ .highlight .si { color: #e6db74 } /* Literal.String.Interpol */ .highlight .sx { color: #e6db74 } /* Literal.String.Other */ .highlight .sr { color: #e6db74 } /* Literal.String.Regex */ .highlight .s1 { color: #e6db74 } /* Literal.String.Single */ .highlight .ss { color: #e6db74 } /* Literal.String.Symbol */ .highlight .bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #a6e22e } /* Name.Function.Magic */ .highlight .vc { color: #f8f8f2 } /* Name.Variable.Class */ .highlight .vg { color: #f8f8f2 } /* Name.Variable.Global */ .highlight .vi { color: #f8f8f2 } /* Name.Variable.Instance */ .highlight .vm { color: #f8f8f2 } /* Name.Variable.Magic */ .highlight .il { color: #ae81ff } /* Literal.Number.Integer.Long */ } @media (prefers-color-scheme: light) { .highlight .hll { background-color: #ffffcc } .highlight .c { color: #888888 } /* Comment */ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ .highlight .k { color: #008800; font-weight: bold } /* Keyword */ .highlight .ch { color: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
This is a patch that I've been maintaining for a few years, and I'd 
really like to see it added to the mainstream zaurus kernel so I can 
finally stop distributing my own.

This patch only effects the card while in monitor mode, and does not 
cause any known stability issues.

http://patches.aircrack-ng.org/hostap-kernel-2.6.18.patch

Rick Farina (Zero_Chaos)

diff -ur linux-2.6.18-gentoo/drivers/net/wireless/hostap/hostap_80211_tx.c linux-2.6.18-gentoo-rawtx/drivers/net/wireless/hostap/hostap_80211_tx.c
--- linux-2.6.18-gentoo/drivers/net/wireless/hostap/hostap_80211_tx.c	2006-09-21 01:26:27.000000000 -0400
+++ linux-2.6.18-gentoo-rawtx/drivers/net/wireless/hostap/hostap_80211_tx.c	2006-09-21 01:30:18.000000000 -0400
@@ -69,6 +69,9 @@
 	iface = netdev_priv(dev);
 	local = iface->local;
 
+	if (local->iw_mode == IW_MODE_MONITOR)
+		goto xmit;
+
 	if (skb->len < ETH_HLEN) {
 		printk(KERN_DEBUG "%s: hostap_data_start_xmit: short skb "
 		       "(len=%d)\n", dev->name, skb->len);
@@ -234,6 +237,7 @@
 		memcpy(skb_put(skb, ETH_ALEN), &hdr.addr4, ETH_ALEN);
 	}
 
+xmit:
 	iface->stats.tx_packets++;
 	iface->stats.tx_bytes += skb->len;
 
@@ -404,8 +408,6 @@
 	}
 
 	if (skb->len < 24) {
-		printk(KERN_DEBUG "%s: hostap_master_start_xmit: short skb "
-		       "(len=%d)\n", dev->name, skb->len);
 		ret = 0;
 		iface->stats.tx_dropped++;
 		goto fail;
Only in linux-2.6.18-gentoo-rawtx/drivers/net/wireless/hostap: hostap_cs.c.orig
Only in linux-2.6.18-gentoo-rawtx/drivers/net/wireless/hostap: hostap_cs.c.rej
diff -ur linux-2.6.18-gentoo/drivers/net/wireless/hostap/hostap_hw.c linux-2.6.18-gentoo-rawtx/drivers/net/wireless/hostap/hostap_hw.c
--- linux-2.6.18-gentoo/drivers/net/wireless/hostap/hostap_hw.c	2006-09-21 01:26:27.000000000 -0400
+++ linux-2.6.18-gentoo-rawtx/drivers/net/wireless/hostap/hostap_hw.c	2006-09-21 01:30:18.000000000 -0400
@@ -1005,6 +1005,35 @@
 	return fid;
 }
 
+static int prism2_monitor_enable(struct net_device *dev)
+{
+	if (hostap_set_word(dev, HFA384X_RID_CNFPORTTYPE, 5)) {
+		printk(KERN_DEBUG "Port type setting for monitor mode "
+			"failed\n");
+		return -EOPNOTSUPP;
+	}
+
+	if (hfa384x_cmd(dev, HFA384X_CMDCODE_TEST | (0x0a << 8),
+			     0, NULL, NULL)) {
+		printk(KERN_DEBUG "Could not enter testmode 0x0a\n");
+		return -EOPNOTSUPP;
+	}
+
+	if (hostap_set_word(dev, HFA384X_RID_CNFWEPFLAGS,
+			    HFA384X_WEPFLAGS_PRIVACYINVOKED |
+			    HFA384X_WEPFLAGS_HOSTENCRYPT |
+			    HFA384X_WEPFLAGS_HOSTDECRYPT)) {
+		printk(KERN_DEBUG "WEP flags setting failed\n");
+		return -EOPNOTSUPP;
+	}
+
+	if (hostap_set_word(dev, HFA384X_RID_PROMISCUOUSMODE, 1)) {
+		printk(KERN_DEBUG "Could not set promiscuous mode\n");
+		return -EOPNOTSUPP;
+	}
+
+	return 0;
+}
 
 static int prism2_reset_port(struct net_device *dev)
 {
@@ -1031,6 +1060,10 @@
 			       "port\n", dev->name);
 	}
 
+	if (local->iw_mode == IW_MODE_MONITOR)
+		/* force mode 0x0a after port 0 reset */
+		return prism2_monitor_enable(dev);
+
 	/* It looks like at least some STA firmware versions reset
 	 * fragmentation threshold back to 2346 after enable command. Restore
 	 * the configured value, if it differs from this default. */
@@ -1466,6 +1499,10 @@
 		return 1;
 	}
 
+	if (local->iw_mode == IW_MODE_MONITOR)
+		/* force mode 0x0a after port 0 reset */
+		prism2_monitor_enable(dev);
+
 	local->hw_ready = 1;
 	local->hw_reset_tries = 0;
 	local->hw_resetting = 0;
@@ -3156,6 +3193,7 @@
 	local->func->hw_config = prism2_hw_config;
 	local->func->hw_reset = prism2_hw_reset;
 	local->func->hw_shutdown = prism2_hw_shutdown;
+	local->func->monitor_enable = prism2_monitor_enable;
 	local->func->reset_port = prism2_reset_port;
 	local->func->schedule_reset = prism2_schedule_reset;
 #ifdef PRISM2_DOWNLOAD_SUPPORT
Only in linux-2.6.18-gentoo-rawtx/drivers/net/wireless/hostap: hostap_hw.c.orig
diff -ur linux-2.6.18-gentoo/drivers/net/wireless/hostap/hostap_ioctl.c linux-2.6.18-gentoo-rawtx/drivers/net/wireless/hostap/hostap_ioctl.c
--- linux-2.6.18-gentoo/drivers/net/wireless/hostap/hostap_ioctl.c	2006-09-21 01:26:27.000000000 -0400
+++ linux-2.6.18-gentoo-rawtx/drivers/net/wireless/hostap/hostap_ioctl.c	2006-09-21 01:30:18.000000000 -0400
@@ -1104,33 +1104,7 @@
 
 	printk(KERN_DEBUG "Enabling monitor mode\n");
 	hostap_monitor_set_type(local);
-
-	if (hostap_set_word(dev, HFA384X_RID_CNFPORTTYPE,
-			    HFA384X_PORTTYPE_PSEUDO_IBSS)) {
-		printk(KERN_DEBUG "Port type setting for monitor mode "
-		       "failed\n");
-		return -EOPNOTSUPP;
-	}
-
-	/* Host decrypt is needed to get the IV and ICV fields;
-	 * however, monitor mode seems to remove WEP flag from frame
-	 * control field */
-	if (hostap_set_word(dev, HFA384X_RID_CNFWEPFLAGS,
-			    HFA384X_WEPFLAGS_HOSTENCRYPT |
-			    HFA384X_WEPFLAGS_HOSTDECRYPT)) {
-		printk(KERN_DEBUG "WEP flags setting failed\n");
-		return -EOPNOTSUPP;
-	}
-
-	if (local->func->reset_port(dev) ||
-	    local->func->cmd(dev, HFA384X_CMDCODE_TEST |
-			     (HFA384X_TEST_MONITOR << 8),
-			     0, NULL, NULL)) {
-		printk(KERN_DEBUG "Setting monitor mode failed\n");
-		return -EOPNOTSUPP;
-	}
-
-	return 0;
+	return local->func->reset_port(dev);
 }
 
 
@@ -1199,7 +1173,7 @@
 	local->iw_mode = *mode;
 
 	if (local->iw_mode == IW_MODE_MONITOR)
-		hostap_monitor_mode_enable(local);
+		return hostap_monitor_mode_enable(local);
 	else if (local->iw_mode == IW_MODE_MASTER && !local->host_encrypt &&
 		 !local->fw_encrypt_ok) {
 		printk(KERN_DEBUG "%s: defaulting to host-based encryption as "
diff -ur linux-2.6.18-gentoo/drivers/net/wireless/hostap/hostap_main.c linux-2.6.18-gentoo-rawtx/drivers/net/wireless/hostap/hostap_main.c
--- linux-2.6.18-gentoo/drivers/net/wireless/hostap/hostap_main.c	2006-09-21 01:26:27.000000000 -0400
+++ linux-2.6.18-gentoo-rawtx/drivers/net/wireless/hostap/hostap_main.c	2006-09-21 01:30:18.000000000 -0400
@@ -331,7 +331,7 @@
 	if (local->iw_mode == IW_MODE_REPEAT)
 		return HFA384X_PORTTYPE_WDS;
 	if (local->iw_mode == IW_MODE_MONITOR)
-		return HFA384X_PORTTYPE_PSEUDO_IBSS;
+		return 5; /*HFA384X_PORTTYPE_PSEUDO_IBSS;*/
 	return HFA384X_PORTTYPE_HOSTAP;
 }
 
Only in linux-2.6.18-gentoo-rawtx/drivers/net/wireless/hostap: hostap_main.c.orig
diff -ur linux-2.6.18-gentoo/drivers/net/wireless/hostap/hostap_pci.c linux-2.6.18-gentoo-rawtx/drivers/net/wireless/hostap/hostap_pci.c
--- linux-2.6.18-gentoo/drivers/net/wireless/hostap/hostap_pci.c	2006-09-21 01:26:27.000000000 -0400
+++ linux-2.6.18-gentoo-rawtx/drivers/net/wireless/hostap/hostap_pci.c	2006-09-21 01:30:18.000000000 -0400
@@ -48,6 +48,8 @@
 	{ 0x1260, 0x3873, PCI_ANY_ID, PCI_ANY_ID },
 	/* Samsung MagicLAN SWL-2210P */
 	{ 0x167d, 0xa000, PCI_ANY_ID, PCI_ANY_ID },
+	/* NETGEAR MA311 */
+	{ 0x1385, 0x3872, PCI_ANY_ID, PCI_ANY_ID },
 	{ 0 }
 };
 
Only in linux-2.6.18-gentoo-rawtx/drivers/net/wireless/hostap: hostap_pci.c.orig
diff -ur linux-2.6.18-gentoo/drivers/net/wireless/hostap/hostap_plx.c linux-2.6.18-gentoo-rawtx/drivers/net/wireless/hostap/hostap_plx.c
--- linux-2.6.18-gentoo/drivers/net/wireless/hostap/hostap_plx.c	2006-09-21 01:26:27.000000000 -0400
+++ linux-2.6.18-gentoo-rawtx/drivers/net/wireless/hostap/hostap_plx.c	2006-09-21 01:30:18.000000000 -0400
@@ -101,6 +101,7 @@
 	{ 0xc250, 0x0002 } /* EMTAC A2424i */,
 	{ 0xd601, 0x0002 } /* Z-Com XI300 */,
 	{ 0xd601, 0x0005 } /* Zcomax XI-325H 200mW */,
+	{ 0xd601, 0x0010 } /* Zcomax XI-325H 100mW */,
 	{ 0, 0}
 };
 
Only in linux-2.6.18-gentoo-rawtx/drivers/net/wireless/hostap: hostap_plx.c.orig
diff -ur linux-2.6.18-gentoo/drivers/net/wireless/hostap/hostap_wlan.h linux-2.6.18-gentoo-rawtx/drivers/net/wireless/hostap/hostap_wlan.h
--- linux-2.6.18-gentoo/drivers/net/wireless/hostap/hostap_wlan.h	2006-09-21 01:26:27.000000000 -0400
+++ linux-2.6.18-gentoo-rawtx/drivers/net/wireless/hostap/hostap_wlan.h	2006-09-21 01:30:18.000000000 -0400
@@ -575,6 +575,7 @@
 	int (*hw_config)(struct net_device *dev, int initial);
 	void (*hw_reset)(struct net_device *dev);
 	void (*hw_shutdown)(struct net_device *dev, int no_disable);
+	int (*monitor_enable)(struct net_device *dev);
 	int (*reset_port)(struct net_device *dev);
 	void (*schedule_reset)(local_info_t *local);
 	int (*download)(local_info_t *local,