Get a link-local IP when wired and DHCP fails
- From: Bastien Nocera <hadess hadess net>
- To: networkmanager-list gnome org
- Subject: Get a link-local IP when wired and DHCP fails
- Date: Thu, 30 Jun 2005 20:14:43 +0100
Heya,
Here's a (small) patch I wrote after a discussion with Dan.
The use-cases are:
- Plug my laptop and desktop together, via a crossed-cable or some cheap
hub, they both get a nice little IP address, and they can talk.
- Create an ad-hoc non-encrypted network on my desktop, join in on my
laptop, can't get a DHCP address (not running that kind of server on my
desktop, too lazy), gets a nice little IP address, and they can talk.
The only case left is when we have an ad-hoc encrypted network, as it's
not really possible to know whether the DHCP request failure is due to
no-DHCP server, or wrong WEP key.
I remember Apple's solution to a similar problem (detecting whether a
WEP key is accepted) being pretty ugly and Airport AP specific, but I
don't quite remember the details.
Any comments?
---
Bastien Nocera <hadess hadess net>
Index: NetworkManagerDevice.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/src/NetworkManagerDevice.c,v
retrieving revision 1.145
diff -u -p -r1.145 NetworkManagerDevice.c
--- NetworkManagerDevice.c 30 Jun 2005 14:28:52 -0000 1.145
+++ NetworkManagerDevice.c 30 Jun 2005 18:55:42 -0000
@@ -2751,9 +2751,20 @@ static gboolean nm_device_activate_stage
if (ap && nm_ap_get_user_created (ap))
ip4_config = nm_device_new_ip4_autoip_config (dev);
- else if (nm_device_get_use_dhcp (dev))
+ else if (nm_device_get_use_dhcp (dev)) {
ip4_config = nm_dhcp_manager_get_ip4_config (data->dhcp_manager, req);
- else
+
+ /* Couldn't get a DHCP address, so we'll try link-local
+ * for wired, and wireless non-encrypted networks, as if
+ * we have encryption on wireless, it could be a wrong
+ * WEP key causing the failure
+ */
+ if (ip4_config == NULL && nm_device_is_wired (dev)) {
+ ip4_config = nm_device_new_ip4_autoip_config (dev);
+ } else if (ip4_config == NULL && nm_device_is_wireless (dev) == FALSE && nm_ap_get_encrypted (ap) == FALSE) {
+ ip4_config = nm_device_new_ip4_autoip_config (dev);
+ }
+ } else
ip4_config = nm_system_device_new_ip4_system_config (dev);
if (nm_device_activation_should_cancel (dev))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]