Should finally work with open networks

This commit is contained in:
Pierre Pronchery 2014-03-18 00:30:17 +09:00
parent 3d9d82de2c
commit 3028b62c9f

View File

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */ * along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* TODO: /* TODO:
* - make sure it works with WEP and open networks * - make sure it works with WEP networks
* - remove the network list from the applet * - remove the network list from the applet
* - manage the network list from the browser (networks without reception...) * - manage the network list from the browser (networks without reception...)
* - automatically save the configuration by default (and remove the button) * - automatically save the configuration by default (and remove the button)
@ -613,6 +613,7 @@ static int _wpa_queue(WPA * wpa, WPAChannel * channel, WPACommand command, ...)
uint32_t flags = 0; uint32_t flags = 0;
char const * s; char const * s;
char const * t; char const * t;
char const * format;
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "DEBUG: %s(%u, ...)\n", __func__, command); fprintf(stderr, "DEBUG: %s(%u, ...)\n", __func__, command);
@ -663,8 +664,9 @@ static int _wpa_queue(WPA * wpa, WPAChannel * channel, WPACommand command, ...)
u = va_arg(ap, unsigned int); u = va_arg(ap, unsigned int);
s = va_arg(ap, char const *); s = va_arg(ap, char const *);
t = va_arg(ap, char const *); t = va_arg(ap, char const *);
cmd = g_strdup_printf("SET_NETWORK %u %s \"%s\"", u, s, format = (t != NULL) ? "SET_NETWORK %u %s \"%s\""
t); : "SET_NETWORK %u %s NONE";
cmd = g_strdup_printf(format, u, s, t);
break; break;
case WC_SET_PASSWORD: case WC_SET_PASSWORD:
/* FIXME really uses SET_NETWORK (and may not be psk) */ /* FIXME really uses SET_NETWORK (and may not be psk) */
@ -1347,7 +1349,7 @@ static void _read_add_network(WPA * wpa, WPAChannel * channel, char const * buf,
unsigned int id; unsigned int id;
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "DEBUG: %s(\"%s\")\n", __func__, ssid); fprintf(stderr, "DEBUG: %s(\"%s\", 0x%08x)\n", __func__, ssid, flags);
#endif #endif
if(cnt < 2 || buf[cnt - 1] != '\n') if(cnt < 2 || buf[cnt - 1] != '\n')
return; return;
@ -1361,8 +1363,7 @@ static void _read_add_network(WPA * wpa, WPAChannel * channel, char const * buf,
_wpa_queue(wpa, channel, WC_SET_NETWORK, id, "ssid", ssid); _wpa_queue(wpa, channel, WC_SET_NETWORK, id, "ssid", ssid);
if((flags & (WSRF_WPA | WSRF_WPA2)) == 0) if((flags & (WSRF_WPA | WSRF_WPA2)) == 0)
/* required to be able to connect to open or WEP networks */ /* required to be able to connect to open or WEP networks */
_wpa_queue(wpa, channel, WC_SET_NETWORK, id, "key_mgmt", _wpa_queue(wpa, channel, WC_SET_NETWORK, id, "key_mgmt", NULL);
"NONE");
if(wpa->autosave) if(wpa->autosave)
_wpa_queue(wpa, channel, WC_SAVE_CONFIGURATION); _wpa_queue(wpa, channel, WC_SAVE_CONFIGURATION);
/* XXX make this optional */ /* XXX make this optional */