5 #include <linux/slab.h>
6 #include <linux/kernel.h>
7 #include <linux/if_arp.h>
8 #include <linux/wireless.h>
26 #define MAX_RID_LEN 1024
32 const u8 *seq,
int seq_len)
39 if (!priv->
keys[index].key)
46 if (!priv->
keys[index].seq)
97 if (!netif_device_present(dev)) {
105 if (orinoco_lock(priv, &flags) != 0)
127 wstats->
qual.updated =
142 wstats->
qual.updated =
147 orinoco_unlock(priv, &flags);
155 static int orinoco_ioctl_setwap(
struct net_device *dev,
164 if (orinoco_lock(priv, &flags) != 0)
168 if (is_zero_ether_addr(ap_addr->
sa_data) ||
169 is_broadcast_ether_addr(ap_addr->
sa_data)) {
174 if (ap_addr->
sa_data[0] == 0) {
183 "support manual roaming\n",
191 "managed mode\n", dev->
name);
200 "manual roaming\n", dev->
name);
210 orinoco_unlock(priv, &flags);
214 static int orinoco_ioctl_getwap(
struct net_device *dev,
224 if (orinoco_lock(priv, &flags) != 0)
230 orinoco_unlock(priv, &flags);
235 static int orinoco_ioctl_setiwencode(
struct net_device *dev,
242 int setindex = priv->
tx_key;
260 if (orinoco_lock(priv, &flags) != 0)
281 if ((index != -1) || (erq->
flags == 0)) {
287 if (priv->
keys[index].key_len == 0) {
311 netif_carrier_ok(dev)) {
321 orinoco_unlock(priv, &flags);
326 static int orinoco_ioctl_getiwencode(
struct net_device *dev,
338 if (orinoco_lock(priv, &flags) != 0)
347 erq->
flags |= index + 1;
358 orinoco_unlock(priv, &flags);
362 static int orinoco_ioctl_setessid(
struct net_device *dev,
378 if (orinoco_lock(priv, &flags) != 0)
388 orinoco_unlock(priv, &flags);
393 static int orinoco_ioctl_getessid(
struct net_device *dev,
403 if (netif_running(dev)) {
409 if (orinoco_lock(priv, &flags) != 0)
413 orinoco_unlock(priv, &flags);
421 static int orinoco_ioctl_setfreq(
struct net_device *dev,
435 if ((frq->
e == 0) && (frq->
m <= 1000)) {
444 for (i = 0; i < (6 - frq->
e); i++)
447 chan = ieee80211_freq_to_dsss_chan(frq->
m / denom);
454 if (orinoco_lock(priv, &flags) != 0)
465 orinoco_unlock(priv, &flags);
470 static int orinoco_ioctl_getfreq(
struct net_device *dev,
483 frq->
m = tmp * 100000;
489 static int orinoco_ioctl_getsens(
struct net_device *dev,
503 if (orinoco_lock(priv, &flags) != 0)
505 err = hermes_read_wordrec(hw,
USER_BAP,
507 orinoco_unlock(priv, &flags);
518 static int orinoco_ioctl_setsens(
struct net_device *dev,
524 int val = srq->
value;
530 if ((val < 1) || (val > 3))
533 if (orinoco_lock(priv, &flags) != 0)
536 orinoco_unlock(priv, &flags);
541 static int orinoco_ioctl_setrate(
struct net_device *dev,
554 if (rrq->
value == -1)
557 if (rrq->
value % 100000)
559 bitrate = rrq->
value / 100000;
567 if (orinoco_lock(priv, &flags) != 0)
570 orinoco_unlock(priv, &flags);
575 static int orinoco_ioctl_getrate(
struct net_device *dev,
585 if (orinoco_lock(priv, &flags) != 0)
592 if (netif_running(dev)) {
599 bitrate = act_bitrate;
602 orinoco_unlock(priv, &flags);
611 static int orinoco_ioctl_setpower(
struct net_device *dev,
620 if (orinoco_lock(priv, &flags) != 0)
660 orinoco_unlock(priv, &flags);
665 static int orinoco_ioctl_getpower(
struct net_device *dev,
676 if (orinoco_lock(priv, &flags) != 0)
679 err = hermes_read_wordrec(hw,
USER_BAP,
684 err = hermes_read_wordrec(hw,
USER_BAP,
689 err = hermes_read_wordrec(hw,
USER_BAP,
694 err = hermes_read_wordrec(hw,
USER_BAP,
703 prq->
value = timeout * 1000;
706 prq->
value = period * 1000;
714 orinoco_unlock(priv, &flags);
719 static int orinoco_ioctl_set_encodeext(
struct net_device *dev,
731 if (orinoco_lock(priv, &flags) != 0)
737 if ((idx < 1) || (idx > 4))
786 tkip_iv = &ext->
rx_seq[0];
798 "\n", dev->
name, err);
808 orinoco_unlock(priv, &flags);
813 static int orinoco_ioctl_get_encodeext(
struct net_device *dev,
821 int idx, max_key_len;
825 if (orinoco_lock(priv, &flags) != 0)
829 max_key_len = encoding->
length -
sizeof(*ext);
835 if ((idx < 1) || (idx > 4))
841 encoding->
flags = idx + 1;
842 memset(ext, 0,
sizeof(*ext));
866 orinoco_unlock(priv, &flags);
871 static int orinoco_ioctl_set_auth(
struct net_device *dev,
881 if (orinoco_lock(priv, &flags) != 0)
922 ret = hermes_disable_port(hw, 0);
925 ret = hermes_enable_port(hw, 0);
953 orinoco_unlock(priv, &flags);
957 static int orinoco_ioctl_get_auth(
struct net_device *dev,
966 if (orinoco_lock(priv, &flags) != 0)
993 orinoco_unlock(priv, &flags);
997 static int orinoco_ioctl_set_genie(
struct net_device *dev,
1003 unsigned long flags;
1007 (wrqu->
data.length && (extra ==
NULL)))
1010 if (wrqu->
data.length) {
1017 if (orinoco_lock(priv, &flags) != 0) {
1034 orinoco_unlock(priv, &flags);
1038 static int orinoco_ioctl_get_genie(
struct net_device *dev,
1043 unsigned long flags;
1046 if (orinoco_lock(priv, &flags) != 0)
1050 wrqu->
data.length = 0;
1063 orinoco_unlock(priv, &flags);
1067 static int orinoco_ioctl_set_mlme(
struct net_device *dev,
1073 unsigned long flags;
1076 if (orinoco_lock(priv, &flags) != 0)
1079 switch (mlme->
cmd) {
1094 orinoco_unlock(priv, &flags);
1098 static int orinoco_ioctl_reset(
struct net_device *dev,
1122 static int orinoco_ioctl_setibssport(
struct net_device *dev,
1129 int val = *((
int *) extra);
1130 unsigned long flags;
1132 if (orinoco_lock(priv, &flags) != 0)
1140 orinoco_unlock(priv, &flags);
1144 static int orinoco_ioctl_getibssport(
struct net_device *dev,
1150 int *val = (
int *) extra;
1156 static int orinoco_ioctl_setport3(
struct net_device *dev,
1162 int val = *((
int *) extra);
1164 unsigned long flags;
1166 if (orinoco_lock(priv, &flags) != 0)
1197 orinoco_unlock(priv, &flags);
1202 static int orinoco_ioctl_getport3(
struct net_device *dev,
1208 int *val = (
int *) extra;
1214 static int orinoco_ioctl_setpreamble(
struct net_device *dev,
1220 unsigned long flags;
1231 val = *((
int *) extra);
1233 if (orinoco_lock(priv, &flags) != 0)
1241 orinoco_unlock(priv, &flags);
1246 static int orinoco_ioctl_getpreamble(
struct net_device *dev,
1252 int *val = (
int *) extra;
1266 static int orinoco_ioctl_getrid(
struct net_device *dev,
1273 int rid = data->
flags;
1276 unsigned long flags;
1283 if (rid < 0xfc00 || rid > 0xffff)
1286 if (orinoco_lock(priv, &flags) != 0)
1298 orinoco_unlock(priv, &flags);
1304 static int orinoco_ioctl_commit(
struct net_device *dev,
1310 unsigned long flags;
1316 if (orinoco_lock(priv, &flags) != 0)
1321 orinoco_unlock(priv, &flags);
1333 0,
"set_preamble" },
1337 0,
"set_ibssport" },
1349 static const iw_handler orinoco_handler[] = {
1393 static const iw_handler orinoco_private_handler[] = {
1407 .num_private =
ARRAY_SIZE(orinoco_private_handler),
1408 .num_private_args =
ARRAY_SIZE(orinoco_privtab),
1409 .standard = orinoco_handler,
1410 .private = orinoco_private_handler,
1411 .private_args = orinoco_privtab,
1412 .get_wireless_stats = orinoco_get_wireless_stats,