2004-10-04 Dan Williams <dcbw@redhat.com>

* src/NetworkManagerDevice.[ch]
		- Add a slightly more robust method of determining if the WEP key
			is correct or not, by checking the WEP-discarded packet count
			on the card

	* info-daemon/NetworkManagerInfo.c
		- (nmi_gconf_notify_callback): Fix GConf essid escaping, should
			un-escape values we pull out rather than escaping them


git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@189 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
Dan Williams 2004-10-04 15:44:00 +00:00
parent c4031a846d
commit 9383651b30
5 changed files with 68 additions and 8 deletions

View file

@ -1,3 +1,14 @@
2004-10-04 Dan Williams <dcbw@redhat.com>
* src/NetworkManagerDevice.[ch]
- Add a slightly more robust method of determining if the WEP key
is correct or not, by checking the WEP-discarded packet count
on the card
* info-daemon/NetworkManagerInfo.c
- (nmi_gconf_notify_callback): Fix GConf essid escaping, should
un-escape values we pull out rather than escaping them
2004-10-03 Marcel Telka <marcel@telka.sk>
* configure.in (ALL_LINGUAS): Added sk.

View file

@ -67,17 +67,17 @@ void nmi_gconf_notify_callback (GConfClient *client, guint connection_id, GConfE
{
char *network = g_strdup ((key + path_len));
char *slash_pos;
char *escaped_network;
char *unescaped_network;
/* If its a key under the network name, zero out the slash so we
* are left with only the network name.
*/
if ((slash_pos = strchr (network, '/')))
unescaped_network = gnome_vfs_unescape_string (network, "");
if ((slash_pos = strchr (unescaped_network, '/')))
*slash_pos = '\0';
escaped_network = gnome_vfs_escape_string (network);
nmi_dbus_signal_update_network (info->connection, network, NETWORK_TYPE_ALLOWED);
g_free (escaped_network);
nmi_dbus_signal_update_network (info->connection, unescaped_network, NETWORK_TYPE_ALLOWED);
g_free (unescaped_network);
g_free (network);
}
}

View file

@ -488,7 +488,7 @@ static DBusHandlerResult nmi_dbus_nmi_message_handler (DBusConnection *connectio
method = dbus_message_get_member (message);
path = dbus_message_get_path (message);
syslog (LOG_WARNING, "nmi_dbus_nmi_message_handler() got method %s for path %s", method, path);
/* syslog (LOG_WARNING, "nmi_dbus_nmi_message_handler() got method %s for path %s", method, path);*/
if (strcmp ("getKeyForNetwork", method) == 0)
{

View file

@ -910,6 +910,29 @@ guint8 nm_device_get_max_quality (NMDevice *dev)
}
/*
* nm_device_get_bad_crypt_packets
*
* Return the number of packets the card has dropped because
* they could not be successfully decrypted.
*
*/
guint32 nm_device_get_bad_crypt_packets (NMDevice *dev)
{
iwstats stats;
int sk;
int err;
g_return_val_if_fail (dev != NULL, 0);
g_return_val_if_fail (nm_device_is_wireless (dev), 0);
sk = iw_sockets_open ();
err = iw_get_stats (sk, nm_device_get_iface (dev), &stats, NULL, FALSE);
close (sk);
return (err == 0 ? stats.discard.code : 0);
}
/*
* nm_device_get_ip4_address
*
@ -1200,6 +1223,15 @@ static gboolean nm_device_activate_wireless (NMDevice *dev)
}
inline gboolean HAVE_LINK (NMDevice *dev, guint32 bad_crypt_packets)
{
g_return_val_if_fail (dev != NULL, FALSE);
g_return_val_if_fail (nm_device_is_wireless (dev), FALSE);
fprintf (stderr, "PACKETS: dev %d, previous %d\n", nm_device_get_bad_crypt_packets (dev), bad_crypt_packets);
return (nm_device_get_link_active (dev) && (nm_device_get_bad_crypt_packets (dev) <= bad_crypt_packets));
}
/*
* nm_device_activate_wireless_wait_for_link
*
@ -1211,6 +1243,7 @@ static gboolean nm_device_activate_wireless (NMDevice *dev)
void nm_device_activate_wireless_wait_for_link (NMDevice *dev)
{
NMAccessPoint *best_ap;
guint32 bad_crypt_packets = 0;
g_return_if_fail (dev != NULL);
@ -1222,6 +1255,7 @@ void nm_device_activate_wireless_wait_for_link (NMDevice *dev)
}
/* Try activating the device with the key and access point we have already */
bad_crypt_packets = nm_device_get_bad_crypt_packets (dev);
nm_device_activate_wireless (dev);
/* Wait until we have a link. Some things that might block us from
@ -1237,7 +1271,20 @@ void nm_device_activate_wireless_wait_for_link (NMDevice *dev)
* a "best" access point for us.
*
*/
while (!nm_device_get_link_active (dev))
/* There are two ways to check for a good link. If we are using WEP and Open System
* authentication, then we can associate with the base station regardless of whether the
* WEP key is right or not. Therefore, we have to monitor the # of packets the card discards
* when its unable to decrypt them, since that gives us some indicator of whether the WEP
* key is wrong. It seems that right after association, at least one packet is dropped by
* most cards if the WEP key is wrong.
*
* The second and better way (if all cards actually supported it) is to check the MAC address
* the card is associated with. However, this doesn't tell us if the WEP key is wrong when we
* are using Open System authentication. Also, not all drivers return an invalid MAC address
* when the card cannot communicate with the access point.
*/
while (!HAVE_LINK (dev, bad_crypt_packets))
{
if ((best_ap = nm_device_get_best_ap (dev)))
{
@ -1299,7 +1346,8 @@ void nm_device_activate_wireless_wait_for_link (NMDevice *dev)
return;
}
/* Try activating again with up-to-date access point and keys */
/* Try activating again with up-to-date access point and keys */
bad_crypt_packets = nm_device_get_bad_crypt_packets (dev);
nm_device_activate_wireless (dev);
}
else

View file

@ -64,6 +64,7 @@ gint8 nm_device_get_signal_strength (NMDevice *dev);
void nm_device_update_signal_strength (NMDevice *dev);
guint8 nm_device_get_noise (NMDevice *dev);
guint8 nm_device_get_max_quality (NMDevice *dev);
guint32 nm_device_get_bad_crypt_packets (NMDevice *dev);
NMAccessPoint *nm_device_get_best_ap (NMDevice *dev);
void nm_device_set_best_ap (NMDevice *dev, NMAccessPoint *ap);