aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJouke Witteveen <j.witteveen@gmail.com>2009-02-03 11:13:54 (GMT)
committerJouni Malinen <j@w1.fi>2009-02-08 10:28:52 (GMT)
commit24ecc10df8215187702e1583092fc1d585fa943a (patch)
tree886954786eaddf6d8828059be93e3013f48d2f2c /src
parent4786b13b0b2051af53184bc2ce7cff51ceaa02d3 (diff)
downloadhostap-06-24ecc10df8215187702e1583092fc1d585fa943a.zip
hostap-06-24ecc10df8215187702e1583092fc1d585fa943a.tar.gz
hostap-06-24ecc10df8215187702e1583092fc1d585fa943a.tar.bz2
Better support in RoboSwitch driver
The RoboSwitch driver of wpa_supplicant had one shortcoming: not supporting the 5365 series. I believe the patch attached fixes this problem. Furthermore it contains a small readability rewrite. It basically is an explicit loop-rollout so that the wpa_driver_roboswitch_leave style matches that of wpa_driver_roboswitch_join. (cherry picked from commit c0a0c97aa946d11f152eb3e75950d2f3012cc646)
Diffstat (limited to 'src')
-rw-r--r--src/drivers/driver_roboswitch.c60
1 files changed, 39 insertions, 21 deletions
diff --git a/src/drivers/driver_roboswitch.c b/src/drivers/driver_roboswitch.c
index 519f893..b25a72b 100644
--- a/src/drivers/driver_roboswitch.c
+++ b/src/drivers/driver_roboswitch.c
@@ -1,6 +1,6 @@
/*
* WPA Supplicant - roboswitch driver interface
- * Copyright (c) 2008 Jouke Witteveen
+ * Copyright (c) 2008-2009 Jouke Witteveen
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@ -47,6 +47,7 @@
/* VLAN page registers */
#define ROBO_VLAN_ACCESS 0x06 /* VLAN table Access register */
+#define ROBO_VLAN_ACCESS_5365 0x08 /* VLAN table Access register (5365) */
#define ROBO_VLAN_READ 0x0C /* VLAN read register */
@@ -240,32 +241,44 @@ static int wpa_driver_roboswitch_leave(struct wpa_driver_roboswitch_data *drv,
const u8 *addr)
{
int i;
- u8 mport[4] = { ROBO_ARLCTRL_VEC_1, ROBO_ARLCTRL_ADDR_1,
- ROBO_ARLCTRL_VEC_2, ROBO_ARLCTRL_ADDR_2 };
u16 _read[3], zero = 0;
- /* same as at join */
- u16 addr_word[ETH_ALEN / 2];
+ u16 addr_word[ETH_ALEN / 2]; /* same as at join */
for (i = 0; i < ETH_ALEN; i += 2)
addr_word[(ETH_ALEN - i) / 2 - 1] = WPA_GET_BE16(addr + i);
- /* find our address/vector pair */
- for (i = 0; i < 4; i += 2) {
- wpa_driver_roboswitch_read(drv, ROBO_ARLCTRL_PAGE, mport[i],
- _read, 1);
- if (_read[0] == drv->ports) {
- wpa_driver_roboswitch_read(drv, ROBO_ARLCTRL_PAGE,
- mport[i + 1], _read, 3);
- if (os_memcmp(_read, addr_word, 6) == 0)
- break;
+ /* check if multiport address 1 was used */
+ wpa_driver_roboswitch_read(drv, ROBO_ARLCTRL_PAGE, ROBO_ARLCTRL_VEC_1,
+ _read, 1);
+ if (_read[0] == drv->ports) {
+ wpa_driver_roboswitch_read(drv, ROBO_ARLCTRL_PAGE,
+ ROBO_ARLCTRL_ADDR_1, _read, 3);
+ if (os_memcmp(_read, addr_word, 6) == 0) {
+ wpa_driver_roboswitch_write(drv, ROBO_ARLCTRL_PAGE,
+ ROBO_ARLCTRL_VEC_1, &zero,
+ 1);
+ goto clean_up;
+ }
+ }
+
+ /* check if multiport address 2 was used */
+ wpa_driver_roboswitch_read(drv, ROBO_ARLCTRL_PAGE, ROBO_ARLCTRL_VEC_2,
+ _read, 1);
+ if (_read[0] == drv->ports) {
+ wpa_driver_roboswitch_read(drv, ROBO_ARLCTRL_PAGE,
+ ROBO_ARLCTRL_ADDR_2, _read, 3);
+ if (os_memcmp(_read, addr_word, 6) == 0) {
+ wpa_driver_roboswitch_write(drv, ROBO_ARLCTRL_PAGE,
+ ROBO_ARLCTRL_VEC_2, &zero,
+ 1);
+ goto clean_up;
}
}
- /* check if we found our address/vector pair and deactivate it */
- if (i == 4)
- return -1;
- wpa_driver_roboswitch_write(drv, ROBO_ARLCTRL_PAGE, mport[i], &zero,
- 1);
+ /* used multiport address not found */
+ return -1;
+
+clean_up:
/* leave the multiport registers in a sane state */
wpa_driver_roboswitch_read(drv, ROBO_ARLCTRL_PAGE, ROBO_ARLCTRL_VEC_1,
_read, 1);
@@ -306,7 +319,7 @@ static void * wpa_driver_roboswitch_init(void *ctx, const char *ifname)
{
struct wpa_driver_roboswitch_data *drv;
int len = -1, sep = -1;
- u16 vlan = 0, vlan_read[2];
+ u16 _read, vlan = 0, vlan_read[2];
drv = os_zalloc(sizeof(*drv));
if (drv == NULL) return NULL;
@@ -369,9 +382,14 @@ static void * wpa_driver_roboswitch_init(void *ctx, const char *ifname)
}
vlan |= 1 << 13;
- /* The BCM5365 uses a different register and is not accounted for. */
wpa_driver_roboswitch_write(drv, ROBO_VLAN_PAGE, ROBO_VLAN_ACCESS,
&vlan, 1);
+ /* Read back: The BCM5365 uses a different register */
+ wpa_driver_roboswitch_read(drv, ROBO_VLAN_PAGE, ROBO_VLAN_ACCESS,
+ &_read, 1);
+ if (_read != vlan)
+ wpa_driver_roboswitch_write(drv, ROBO_VLAN_PAGE,
+ ROBO_VLAN_ACCESS_5365, &vlan, 1);
wpa_driver_roboswitch_read(drv, ROBO_VLAN_PAGE, ROBO_VLAN_READ,
vlan_read, 2);
if (!(vlan_read[1] & (1 << 4))) {