int wpa_ie_len;
unsigned char rsn_ie[40];
int rsn_ie_len;
+
+ int has_wep;
+ int has_wpa;
+ int has_rsn;
};
struct iface_data {
static void report_station(struct connman_iface *iface,
struct station_data *station)
{
+ int security = 0;
+
if (station == NULL)
return;
if (station->name == NULL)
return;
- connman_iface_indicate_station(iface, station->name, station->qual);
+ if (station->has_wep)
+ security |= 0x01;
+ if (station->has_wpa)
+ security |= 0x02;
+ if (station->has_rsn)
+ security |= 0x04;
+
+ connman_iface_indicate_station(iface, station->name,
+ station->qual, security);
}
static struct station_data *create_station(struct iface_data *iface,
// station->address, station->mode,
// station->name, station->qual);
+ if (station->name == NULL)
+ continue;
+
g_key_file_set_string(keyfile, station->address,
"Name", station->name);
__supplicant_start(iface);
- __supplicant_connect(iface, data->network, data->passphrase);
+ if (data->network != NULL)
+ __supplicant_connect(iface, data->network, data->passphrase);
return 0;
}
printf("[802.11] disconnect %s\n", data->ifname);
+ if (data->network != NULL)
+ __supplicant_disconnect(iface);
+
__supplicant_stop(iface);
return 0;
printf("[802.11] set network %s\n", data->ifname);
+ if (data->network != NULL)
+ __supplicant_disconnect(iface);
+
g_free(data->network);
data->network = g_strdup(network);
+
+ if (data->network != NULL)
+ __supplicant_connect(iface, data->network, data->passphrase);
}
static void iface_set_passphrase(struct connman_iface *iface,
printf("[802.11] set passphrase %s\n", data->ifname);
+ if (data->network != NULL)
+ __supplicant_disconnect(iface);
+
g_free(data->passphrase);
data->passphrase = g_strdup(passphrase);
+
+ if (data->network != NULL)
+ __supplicant_connect(iface, data->network, data->passphrase);
}
static void parse_genie(struct station_data *station,
switch (data[offset]) {
case 0xdd: /* WPA1 (and other) */
+ station->has_wpa = 1;
break;
case 0x30: /* WPA2 (RSN) */
+ station->has_rsn = 1;
break;
default:
break;
break;
case SIOCGIWESSID:
if (station != NULL) {
- station->name = malloc(event->len - 7);
+ station->name = malloc(event->len - IW_EV_POINT_LEN + 1);
if (station->name != NULL) {
- memset(station->name, 0, event->len - 7);
- memcpy(station->name, ptr + 8,
- event->len - 8);
+ memset(station->name, 0,
+ event->len - IW_EV_POINT_LEN + 1);
+ memcpy(station->name, ptr + IW_EV_POINT_LEN,
+ event->len - IW_EV_POINT_LEN);
}
}
break;
break;
case SIOCGIWENCODE:
if (station != NULL) {
- if (!(event->u.data.flags & IW_ENCODE_DISABLED)) {
- /* privacy */
- }
+ if (!(event->u.data.flags & IW_ENCODE_DISABLED))
+ station->has_wep = 1;
}
break;
case SIOCGIWRATE:
done = 1;
} else {
parse_scan_results(iface, iwr.u.data.pointer,
- iwr.u.data.length);
+ iwr.u.data.length);
done = 1;
}
}