aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorDavid Kilroy <kilroyd@googlemail.com>2009-08-05 16:23:28 -0400
committerJohn W. Linville <linville@tuxdriver.com>2009-08-14 09:12:42 -0400
commit5c9f41e285ad60013f0962746192769f899757be (patch)
treef834a575208c6b93e84c9ff57df65118399296fe /drivers/net
parentbb7e43c061ad1e52a4738d5b45595ec9e1638b6a (diff)
orinoco: use local types for auth alg and sequence length
This helps in the refactorring required to convert the driver to cfg80211. Signed-off-by: David Kilroy <kilroyd@googlemail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/wireless/orinoco/hw.c12
-rw-r--r--drivers/net/wireless/orinoco/main.c6
-rw-r--r--drivers/net/wireless/orinoco/orinoco.h10
-rw-r--r--drivers/net/wireless/orinoco/wext.c30
4 files changed, 33 insertions, 25 deletions
diff --git a/drivers/net/wireless/orinoco/hw.c b/drivers/net/wireless/orinoco/hw.c
index fa508af1a351..d069fe8b6033 100644
--- a/drivers/net/wireless/orinoco/hw.c
+++ b/drivers/net/wireless/orinoco/hw.c
@@ -642,7 +642,7 @@ int orinoco_hw_get_tkip_iv(struct orinoco_private *priv, int key, u8 *tsc)
642{ 642{
643 hermes_t *hw = &priv->hw; 643 hermes_t *hw = &priv->hw;
644 int err = 0; 644 int err = 0;
645 u8 tsc_arr[4][IW_ENCODE_SEQ_MAX_SIZE]; 645 u8 tsc_arr[4][ORINOCO_SEQ_LEN];
646 646
647 if ((key < 0) || (key > 4)) 647 if ((key < 0) || (key > 4))
648 return -EINVAL; 648 return -EINVAL;
@@ -840,14 +840,14 @@ int __orinoco_hw_setup_enc(struct orinoco_private *priv)
840 840
841 if (priv->wpa_enabled) 841 if (priv->wpa_enabled)
842 enc_flag = 2; 842 enc_flag = 2;
843 else if (priv->encode_alg == IW_ENCODE_ALG_WEP) 843 else if (priv->encode_alg == ORINOCO_ALG_WEP)
844 enc_flag = 1; 844 enc_flag = 1;
845 else 845 else
846 enc_flag = 0; 846 enc_flag = 0;
847 847
848 switch (priv->firmware_type) { 848 switch (priv->firmware_type) {
849 case FIRMWARE_TYPE_AGERE: /* Agere style WEP */ 849 case FIRMWARE_TYPE_AGERE: /* Agere style WEP */
850 if (priv->encode_alg == IW_ENCODE_ALG_WEP) { 850 if (priv->encode_alg == ORINOCO_ALG_WEP) {
851 /* Enable the shared-key authentication. */ 851 /* Enable the shared-key authentication. */
852 err = hermes_write_wordrec(hw, USER_BAP, 852 err = hermes_write_wordrec(hw, USER_BAP,
853 HERMES_RID_CNFAUTHENTICATION_AGERE, 853 HERMES_RID_CNFAUTHENTICATION_AGERE,
@@ -872,7 +872,7 @@ int __orinoco_hw_setup_enc(struct orinoco_private *priv)
872 872
873 case FIRMWARE_TYPE_INTERSIL: /* Intersil style WEP */ 873 case FIRMWARE_TYPE_INTERSIL: /* Intersil style WEP */
874 case FIRMWARE_TYPE_SYMBOL: /* Symbol style WEP */ 874 case FIRMWARE_TYPE_SYMBOL: /* Symbol style WEP */
875 if (priv->encode_alg == IW_ENCODE_ALG_WEP) { 875 if (priv->encode_alg == ORINOCO_ALG_WEP) {
876 if (priv->wep_restrict || 876 if (priv->wep_restrict ||
877 (priv->firmware_type == FIRMWARE_TYPE_SYMBOL)) 877 (priv->firmware_type == FIRMWARE_TYPE_SYMBOL))
878 master_wep_flag = HERMES_WEP_PRIVACY_INVOKED | 878 master_wep_flag = HERMES_WEP_PRIVACY_INVOKED |
@@ -913,11 +913,11 @@ int __orinoco_hw_set_tkip_key(struct orinoco_private *priv, int key_idx,
913{ 913{
914 struct { 914 struct {
915 __le16 idx; 915 __le16 idx;
916 u8 rsc[IW_ENCODE_SEQ_MAX_SIZE]; 916 u8 rsc[ORINOCO_SEQ_LEN];
917 u8 key[TKIP_KEYLEN]; 917 u8 key[TKIP_KEYLEN];
918 u8 tx_mic[MIC_KEYLEN]; 918 u8 tx_mic[MIC_KEYLEN];
919 u8 rx_mic[MIC_KEYLEN]; 919 u8 rx_mic[MIC_KEYLEN];
920 u8 tsc[IW_ENCODE_SEQ_MAX_SIZE]; 920 u8 tsc[ORINOCO_SEQ_LEN];
921 } __attribute__ ((packed)) buf; 921 } __attribute__ ((packed)) buf;
922 hermes_t *hw = &priv->hw; 922 hermes_t *hw = &priv->hw;
923 int ret; 923 int ret;
diff --git a/drivers/net/wireless/orinoco/main.c b/drivers/net/wireless/orinoco/main.c
index e8c550a61f33..931f7deddb54 100644
--- a/drivers/net/wireless/orinoco/main.c
+++ b/drivers/net/wireless/orinoco/main.c
@@ -380,7 +380,7 @@ static int orinoco_xmit(struct sk_buff *skb, struct net_device *dev)
380 380
381 tx_control = HERMES_TXCTRL_TX_OK | HERMES_TXCTRL_TX_EX; 381 tx_control = HERMES_TXCTRL_TX_OK | HERMES_TXCTRL_TX_EX;
382 382
383 if (priv->encode_alg == IW_ENCODE_ALG_TKIP) 383 if (priv->encode_alg == ORINOCO_ALG_TKIP)
384 tx_control |= (priv->tx_key << HERMES_MIC_KEY_ID_SHIFT) | 384 tx_control |= (priv->tx_key << HERMES_MIC_KEY_ID_SHIFT) |
385 HERMES_TXCTRL_MIC; 385 HERMES_TXCTRL_MIC;
386 386
@@ -462,7 +462,7 @@ static int orinoco_xmit(struct sk_buff *skb, struct net_device *dev)
462 } 462 }
463 463
464 /* Calculate Michael MIC */ 464 /* Calculate Michael MIC */
465 if (priv->encode_alg == IW_ENCODE_ALG_TKIP) { 465 if (priv->encode_alg == ORINOCO_ALG_TKIP) {
466 u8 mic_buf[MICHAEL_MIC_LEN + 1]; 466 u8 mic_buf[MICHAEL_MIC_LEN + 1];
467 u8 *mic; 467 u8 *mic;
468 size_t offset; 468 size_t offset;
@@ -2040,7 +2040,7 @@ int orinoco_init(struct orinoco_private *priv)
2040 priv->channel = 0; /* use firmware default */ 2040 priv->channel = 0; /* use firmware default */
2041 2041
2042 priv->promiscuous = 0; 2042 priv->promiscuous = 0;
2043 priv->encode_alg = IW_ENCODE_ALG_NONE; 2043 priv->encode_alg = ORINOCO_ALG_NONE;
2044 priv->tx_key = 0; 2044 priv->tx_key = 0;
2045 priv->wpa_enabled = 0; 2045 priv->wpa_enabled = 0;
2046 priv->tkip_cm_active = 0; 2046 priv->tkip_cm_active = 0;
diff --git a/drivers/net/wireless/orinoco/orinoco.h b/drivers/net/wireless/orinoco/orinoco.h
index 2a4eef1b96cc..badfc5665242 100644
--- a/drivers/net/wireless/orinoco/orinoco.h
+++ b/drivers/net/wireless/orinoco/orinoco.h
@@ -25,6 +25,7 @@
25 25
26#define MAX_SCAN_LEN 4096 26#define MAX_SCAN_LEN 4096
27 27
28#define ORINOCO_SEQ_LEN 8
28#define ORINOCO_MAX_KEY_SIZE 14 29#define ORINOCO_MAX_KEY_SIZE 14
29#define ORINOCO_MAX_KEYS 4 30#define ORINOCO_MAX_KEYS 4
30 31
@@ -42,6 +43,12 @@ struct orinoco_tkip_key {
42 u8 rx_mic[MIC_KEYLEN]; 43 u8 rx_mic[MIC_KEYLEN];
43}; 44};
44 45
46enum orinoco_alg {
47 ORINOCO_ALG_NONE,
48 ORINOCO_ALG_WEP,
49 ORINOCO_ALG_TKIP
50};
51
45typedef enum { 52typedef enum {
46 FIRMWARE_TYPE_AGERE, 53 FIRMWARE_TYPE_AGERE,
47 FIRMWARE_TYPE_INTERSIL, 54 FIRMWARE_TYPE_INTERSIL,
@@ -111,7 +118,8 @@ struct orinoco_private {
111 118
112 /* Configuration paramaters */ 119 /* Configuration paramaters */
113 enum nl80211_iftype iw_mode; 120 enum nl80211_iftype iw_mode;
114 u16 encode_alg, wep_restrict, tx_key; 121 enum orinoco_alg encode_alg;
122 u16 wep_restrict, tx_key;
115 struct orinoco_key keys[ORINOCO_MAX_KEYS]; 123 struct orinoco_key keys[ORINOCO_MAX_KEYS];
116 int bitratemode; 124 int bitratemode;
117 char nick[IW_ESSID_MAX_SIZE+1]; 125 char nick[IW_ESSID_MAX_SIZE+1];
diff --git a/drivers/net/wireless/orinoco/wext.c b/drivers/net/wireless/orinoco/wext.c
index b6ff3dbb7dd6..33d81b4823a2 100644
--- a/drivers/net/wireless/orinoco/wext.c
+++ b/drivers/net/wireless/orinoco/wext.c
@@ -180,7 +180,7 @@ static int orinoco_ioctl_setiwencode(struct net_device *dev,
180 struct orinoco_private *priv = ndev_priv(dev); 180 struct orinoco_private *priv = ndev_priv(dev);
181 int index = (erq->flags & IW_ENCODE_INDEX) - 1; 181 int index = (erq->flags & IW_ENCODE_INDEX) - 1;
182 int setindex = priv->tx_key; 182 int setindex = priv->tx_key;
183 int encode_alg = priv->encode_alg; 183 enum orinoco_alg encode_alg = priv->encode_alg;
184 int restricted = priv->wep_restrict; 184 int restricted = priv->wep_restrict;
185 u16 xlen = 0; 185 u16 xlen = 0;
186 int err = -EINPROGRESS; /* Call commit handler */ 186 int err = -EINPROGRESS; /* Call commit handler */
@@ -202,7 +202,7 @@ static int orinoco_ioctl_setiwencode(struct net_device *dev,
202 return -EBUSY; 202 return -EBUSY;
203 203
204 /* Clear any TKIP key we have */ 204 /* Clear any TKIP key we have */
205 if ((priv->has_wpa) && (priv->encode_alg == IW_ENCODE_ALG_TKIP)) 205 if ((priv->has_wpa) && (priv->encode_alg == ORINOCO_ALG_TKIP))
206 (void) orinoco_clear_tkip_key(priv, setindex); 206 (void) orinoco_clear_tkip_key(priv, setindex);
207 207
208 if (erq->length > 0) { 208 if (erq->length > 0) {
@@ -212,15 +212,13 @@ static int orinoco_ioctl_setiwencode(struct net_device *dev,
212 /* Adjust key length to a supported value */ 212 /* Adjust key length to a supported value */
213 if (erq->length > SMALL_KEY_SIZE) 213 if (erq->length > SMALL_KEY_SIZE)
214 xlen = LARGE_KEY_SIZE; 214 xlen = LARGE_KEY_SIZE;
215 else if (erq->length > 0) 215 else /* (erq->length > 0) */
216 xlen = SMALL_KEY_SIZE; 216 xlen = SMALL_KEY_SIZE;
217 else
218 xlen = 0;
219 217
220 /* Switch on WEP if off */ 218 /* Switch on WEP if off */
221 if ((encode_alg != IW_ENCODE_ALG_WEP) && (xlen > 0)) { 219 if (encode_alg != ORINOCO_ALG_WEP) {
222 setindex = index; 220 setindex = index;
223 encode_alg = IW_ENCODE_ALG_WEP; 221 encode_alg = ORINOCO_ALG_WEP;
224 } 222 }
225 } else { 223 } else {
226 /* Important note : if the user do "iwconfig eth0 enc off", 224 /* Important note : if the user do "iwconfig eth0 enc off",
@@ -242,7 +240,7 @@ static int orinoco_ioctl_setiwencode(struct net_device *dev,
242 } 240 }
243 241
244 if (erq->flags & IW_ENCODE_DISABLED) 242 if (erq->flags & IW_ENCODE_DISABLED)
245 encode_alg = IW_ENCODE_ALG_NONE; 243 encode_alg = ORINOCO_ALG_NONE;
246 if (erq->flags & IW_ENCODE_OPEN) 244 if (erq->flags & IW_ENCODE_OPEN)
247 restricted = 0; 245 restricted = 0;
248 if (erq->flags & IW_ENCODE_RESTRICTED) 246 if (erq->flags & IW_ENCODE_RESTRICTED)
@@ -825,7 +823,7 @@ static int orinoco_ioctl_set_encodeext(struct net_device *dev,
825 /* Set the requested key first */ 823 /* Set the requested key first */
826 switch (alg) { 824 switch (alg) {
827 case IW_ENCODE_ALG_NONE: 825 case IW_ENCODE_ALG_NONE:
828 priv->encode_alg = alg; 826 priv->encode_alg = ORINOCO_ALG_NONE;
829 priv->keys[idx].len = 0; 827 priv->keys[idx].len = 0;
830 break; 828 break;
831 829
@@ -837,7 +835,7 @@ static int orinoco_ioctl_set_encodeext(struct net_device *dev,
837 else 835 else
838 goto out; 836 goto out;
839 837
840 priv->encode_alg = alg; 838 priv->encode_alg = ORINOCO_ALG_WEP;
841 priv->keys[idx].len = cpu_to_le16(key_len); 839 priv->keys[idx].len = cpu_to_le16(key_len);
842 840
843 key_len = min(ext->key_len, key_len); 841 key_len = min(ext->key_len, key_len);
@@ -854,7 +852,7 @@ static int orinoco_ioctl_set_encodeext(struct net_device *dev,
854 (ext->key_len > sizeof(priv->tkip_key[0]))) 852 (ext->key_len > sizeof(priv->tkip_key[0])))
855 goto out; 853 goto out;
856 854
857 priv->encode_alg = alg; 855 priv->encode_alg = ORINOCO_ALG_TKIP;
858 memset(&priv->tkip_key[idx], 0, 856 memset(&priv->tkip_key[idx], 0,
859 sizeof(priv->tkip_key[idx])); 857 sizeof(priv->tkip_key[idx]));
860 memcpy(&priv->tkip_key[idx], ext->key, ext->key_len); 858 memcpy(&priv->tkip_key[idx], ext->key, ext->key_len);
@@ -914,19 +912,21 @@ static int orinoco_ioctl_get_encodeext(struct net_device *dev,
914 encoding->flags = idx + 1; 912 encoding->flags = idx + 1;
915 memset(ext, 0, sizeof(*ext)); 913 memset(ext, 0, sizeof(*ext));
916 914
917 ext->alg = priv->encode_alg;
918 switch (priv->encode_alg) { 915 switch (priv->encode_alg) {
919 case IW_ENCODE_ALG_NONE: 916 case ORINOCO_ALG_NONE:
917 ext->alg = IW_ENCODE_ALG_NONE;
920 ext->key_len = 0; 918 ext->key_len = 0;
921 encoding->flags |= IW_ENCODE_DISABLED; 919 encoding->flags |= IW_ENCODE_DISABLED;
922 break; 920 break;
923 case IW_ENCODE_ALG_WEP: 921 case ORINOCO_ALG_WEP:
922 ext->alg = IW_ENCODE_ALG_WEP;
924 ext->key_len = min_t(u16, le16_to_cpu(priv->keys[idx].len), 923 ext->key_len = min_t(u16, le16_to_cpu(priv->keys[idx].len),
925 max_key_len); 924 max_key_len);
926 memcpy(ext->key, priv->keys[idx].data, ext->key_len); 925 memcpy(ext->key, priv->keys[idx].data, ext->key_len);
927 encoding->flags |= IW_ENCODE_ENABLED; 926 encoding->flags |= IW_ENCODE_ENABLED;
928 break; 927 break;
929 case IW_ENCODE_ALG_TKIP: 928 case ORINOCO_ALG_TKIP:
929 ext->alg = IW_ENCODE_ALG_TKIP;
930 ext->key_len = min_t(u16, sizeof(struct orinoco_tkip_key), 930 ext->key_len = min_t(u16, sizeof(struct orinoco_tkip_key),
931 max_key_len); 931 max_key_len);
932 memcpy(ext->key, &priv->tkip_key[idx], ext->key_len); 932 memcpy(ext->key, &priv->tkip_key[idx], ext->key_len);