mirror of
https://github.com/gryf/wicd.git
synced 2025-12-20 04:48:00 +01:00
Support udhcpc, this is needed to smoothly run on the OpenMoko FreeRunner.
Thanks to Luca Capello <gismo@debian.org> for porting the patch to 1.5.9, and to "madmo" from the linked forum for making the patch. Patch originally taken from http://wicd.net/punbb/viewtopic.php?id=132 Patch ported to 1.6.0 code by David Paleino <d.paleino@gmail.com>.
This commit is contained in:
@@ -93,6 +93,7 @@ class PrefsDialog(urwid.WidgetWrap):
|
|||||||
dhcp1_t = 'dhclient'
|
dhcp1_t = 'dhclient'
|
||||||
dhcp2_t = 'dhcpcd'
|
dhcp2_t = 'dhcpcd'
|
||||||
dhcp3_t = 'pump'
|
dhcp3_t = 'pump'
|
||||||
|
dhcp4_t = 'udhcpc'
|
||||||
|
|
||||||
wired_detect_header_t = ('header',language["wired_detect"])
|
wired_detect_header_t = ('header',language["wired_detect"])
|
||||||
wired1_t = 'ethtool'
|
wired1_t = 'ethtool'
|
||||||
@@ -185,7 +186,8 @@ class PrefsDialog(urwid.WidgetWrap):
|
|||||||
self.dhcp1 = DynRadioButton(self.dhcp_l,dhcp1_t)
|
self.dhcp1 = DynRadioButton(self.dhcp_l,dhcp1_t)
|
||||||
self.dhcp2 = DynRadioButton(self.dhcp_l,dhcp2_t)
|
self.dhcp2 = DynRadioButton(self.dhcp_l,dhcp2_t)
|
||||||
self.dhcp3 = DynRadioButton(self.dhcp_l,dhcp3_t)
|
self.dhcp3 = DynRadioButton(self.dhcp_l,dhcp3_t)
|
||||||
self.dhcp_l = [self.dhcp0,self.dhcp1,self.dhcp2,self.dhcp3]
|
self.dhcp4 = DynRadioButton(self.dhcp_l,dhcp4_t)
|
||||||
|
self.dhcp_l = [self.dhcp0,self.dhcp1,self.dhcp2,self.dhcp3,self.dhcp4]
|
||||||
|
|
||||||
self.wired_l = []
|
self.wired_l = []
|
||||||
self.wired_detect_header = urwid.Text(wired_detect_header_t)
|
self.wired_detect_header = urwid.Text(wired_detect_header_t)
|
||||||
@@ -202,7 +204,7 @@ class PrefsDialog(urwid.WidgetWrap):
|
|||||||
self.flush_l = [self.flush0,self.flush1,self.flush2]
|
self.flush_l = [self.flush0,self.flush1,self.flush2]
|
||||||
|
|
||||||
externalLB = urwid.ListBox([self.dhcp_header,
|
externalLB = urwid.ListBox([self.dhcp_header,
|
||||||
self.dhcp0,self.dhcp2,self.dhcp3,self.dhcp1,
|
self.dhcp0,self.dhcp2,self.dhcp3,self.dhcp1,self.dhcp4,
|
||||||
_blank,
|
_blank,
|
||||||
self.wired_detect_header,
|
self.wired_detect_header,
|
||||||
self.wired0,self.wired1,self.wired2,
|
self.wired0,self.wired1,self.wired2,
|
||||||
@@ -351,8 +353,10 @@ class PrefsDialog(urwid.WidgetWrap):
|
|||||||
dhcp_client = misc.DHCLIENT
|
dhcp_client = misc.DHCLIENT
|
||||||
elif self.dhcp2.get_state():
|
elif self.dhcp2.get_state():
|
||||||
dhcp_client = misc.DHCPCD
|
dhcp_client = misc.DHCPCD
|
||||||
else:
|
elif self.dhcp3.get_state():
|
||||||
dhcp_client = misc.PUMP
|
dhcp_client = misc.PUMP
|
||||||
|
else:
|
||||||
|
dhcp_client = misc.UDHCPC
|
||||||
daemon.SetDHCPClient(dhcp_client)
|
daemon.SetDHCPClient(dhcp_client)
|
||||||
|
|
||||||
if self.wired0.get_state():
|
if self.wired0.get_state():
|
||||||
|
|||||||
@@ -1171,6 +1171,21 @@ is already active.</property>
|
|||||||
<property name="position">2</property>
|
<property name="position">2</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<widget class="GtkRadioButton" id="udhcpc_radio">
|
||||||
|
<property name="label" translatable="yes">udhcpc</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">False</property>
|
||||||
|
<property name="active">True</property>
|
||||||
|
<property name="draw_indicator">True</property>
|
||||||
|
<property name="group">dhclient_radio</property>
|
||||||
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="position">4</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
</widget>
|
</widget>
|
||||||
</child>
|
</child>
|
||||||
</widget>
|
</widget>
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ AUTO = 0
|
|||||||
DHCLIENT = 1
|
DHCLIENT = 1
|
||||||
DHCPCD = 2
|
DHCPCD = 2
|
||||||
PUMP = 3
|
PUMP = 3
|
||||||
|
UDHCPC = 4
|
||||||
|
|
||||||
# Link detection tools
|
# Link detection tools
|
||||||
ETHTOOL = 1
|
ETHTOOL = 1
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ class PreferencesDialog(object):
|
|||||||
self.preferwiredcheckbox.set_active(daemon.GetPreferWiredNetwork())
|
self.preferwiredcheckbox.set_active(daemon.GetPreferWiredNetwork())
|
||||||
|
|
||||||
dhcp_list = [self.dhcpautoradio, self.dhclientradio, self.dhcpcdradio,
|
dhcp_list = [self.dhcpautoradio, self.dhclientradio, self.dhcpcdradio,
|
||||||
self.pumpradio]
|
self.pumpradio, self.udhcpcradio]
|
||||||
self._setup_external_app_radios(dhcp_list, daemon.GetDHCPClient,
|
self._setup_external_app_radios(dhcp_list, daemon.GetDHCPClient,
|
||||||
daemon.SetDHCPClient)
|
daemon.SetDHCPClient)
|
||||||
|
|
||||||
@@ -210,8 +210,10 @@ class PreferencesDialog(object):
|
|||||||
dhcp_client = misc.DHCLIENT
|
dhcp_client = misc.DHCLIENT
|
||||||
elif self.dhcpcdradio.get_active():
|
elif self.dhcpcdradio.get_active():
|
||||||
dhcp_client = misc.DHCPCD
|
dhcp_client = misc.DHCPCD
|
||||||
else:
|
elif self.pumpradio.get_active():
|
||||||
dhcp_client = misc.PUMP
|
dhcp_client = misc.PUMP
|
||||||
|
else:
|
||||||
|
dhcp_client = misc.UDHCPC
|
||||||
daemon.SetDHCPClient(dhcp_client)
|
daemon.SetDHCPClient(dhcp_client)
|
||||||
|
|
||||||
if self.linkautoradio.get_active():
|
if self.linkautoradio.get_active():
|
||||||
@@ -347,6 +349,7 @@ class PreferencesDialog(object):
|
|||||||
self.dhclientradio = self.wTree.get_widget("dhclient_radio")
|
self.dhclientradio = self.wTree.get_widget("dhclient_radio")
|
||||||
self.pumpradio = self.wTree.get_widget("pump_radio")
|
self.pumpradio = self.wTree.get_widget("pump_radio")
|
||||||
self.dhcpcdradio = self.wTree.get_widget("dhcpcd_radio")
|
self.dhcpcdradio = self.wTree.get_widget("dhcpcd_radio")
|
||||||
|
self.udhcpcradio = self.wTree.get_widget("udhcpc_radio")
|
||||||
|
|
||||||
# Wired Link Detection Apps
|
# Wired Link Detection Apps
|
||||||
self.linkautoradio = setup_label("link_auto_radio", 'wicd_auto_config')
|
self.linkautoradio = setup_label("link_auto_radio", 'wicd_auto_config')
|
||||||
|
|||||||
@@ -250,6 +250,9 @@ class BaseInterface(object):
|
|||||||
cmd = self.dhclient_cmd
|
cmd = self.dhclient_cmd
|
||||||
if self.dhclient_needs_verbose:
|
if self.dhclient_needs_verbose:
|
||||||
cmd += ' -v'
|
cmd += ' -v'
|
||||||
|
elif self.udhcpc_cmd and cl in [misc.UDHCPC, misc.AUTO]:
|
||||||
|
client = "udhcpc"
|
||||||
|
cmd = self.udhcpc_cmd
|
||||||
else:
|
else:
|
||||||
client = None
|
client = None
|
||||||
cmd = ""
|
cmd = ""
|
||||||
@@ -257,20 +260,25 @@ class BaseInterface(object):
|
|||||||
|
|
||||||
client_dict = {
|
client_dict = {
|
||||||
"dhclient" :
|
"dhclient" :
|
||||||
{'connect' : r"%s %s",
|
{'connect' : r"%(cmd)s %(iface)s",
|
||||||
'release' : r"%s -r %s",
|
'release' : r"%(cmd)s -r %(iface)s",
|
||||||
'id' : misc.DHCLIENT,
|
'id' : misc.DHCLIENT,
|
||||||
},
|
},
|
||||||
"pump" :
|
"pump" :
|
||||||
{ 'connect' : r"%s -i %s",
|
{ 'connect' : r"%(cmd)s -i %(iface)s",
|
||||||
'release' : r"%s -r -i %s",
|
'release' : r"%(cmd)s -r -i %(iface)s",
|
||||||
'id' : misc.PUMP,
|
'id' : misc.PUMP,
|
||||||
},
|
},
|
||||||
"dhcpcd" :
|
"dhcpcd" :
|
||||||
{'connect' : r"%s %s",
|
{'connect' : r"%(cmd)s %(iface)s",
|
||||||
'release' : r"%s -k %s",
|
'release' : r"%(cmd)s -k %(iface)s",
|
||||||
'id' : misc.DHCPCD,
|
'id' : misc.DHCPCD,
|
||||||
},
|
},
|
||||||
|
"udhcpc":
|
||||||
|
{'connect' : r"%(cmd)s -n -i %(iface)s",
|
||||||
|
'release' : r"killall -SIGUSR2 %(cmd)s",
|
||||||
|
'id' : misc.UDHCPC,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
(client_name, cmd) = get_client_name(self.DHCP_CLIENT)
|
(client_name, cmd) = get_client_name(self.DHCP_CLIENT)
|
||||||
if not client_name or not cmd:
|
if not client_name or not cmd:
|
||||||
@@ -278,9 +286,9 @@ class BaseInterface(object):
|
|||||||
return ""
|
return ""
|
||||||
|
|
||||||
if flavor == "connect":
|
if flavor == "connect":
|
||||||
return client_dict[client_name]['connect'] % (cmd, self.iface)
|
return client_dict[client_name]['connect'] % {"cmd":cmd, "iface":self.iface}
|
||||||
elif flavor == "release":
|
elif flavor == "release":
|
||||||
return client_dict[client_name]['release'] % (cmd, self.iface)
|
return client_dict[client_name]['release'] % {"cmd":cmd, "iface":self.iface}
|
||||||
else:
|
else:
|
||||||
return client_dict[client_name]['id']
|
return client_dict[client_name]['id']
|
||||||
|
|
||||||
@@ -327,6 +335,7 @@ class BaseInterface(object):
|
|||||||
self.dhclient_needs_verbose = False
|
self.dhclient_needs_verbose = False
|
||||||
self.dhcpcd_cmd = self._find_program_path("dhcpcd")
|
self.dhcpcd_cmd = self._find_program_path("dhcpcd")
|
||||||
self.pump_cmd = self._find_program_path("pump")
|
self.pump_cmd = self._find_program_path("pump")
|
||||||
|
self.udhcpc_cmd = self._find_program_path("udhcpc")
|
||||||
|
|
||||||
def CheckWiredTools(self):
|
def CheckWiredTools(self):
|
||||||
""" Check for the existence of ethtool and mii-tool. """
|
""" Check for the existence of ethtool and mii-tool. """
|
||||||
@@ -486,6 +495,30 @@ class BaseInterface(object):
|
|||||||
|
|
||||||
return self._check_dhcp_result(dhcpcd_success)
|
return self._check_dhcp_result(dhcpcd_success)
|
||||||
|
|
||||||
|
def _parse_udhcpc(self, pipe):
|
||||||
|
""" Determines if obtaining an IP using udhcpc succeeded.
|
||||||
|
|
||||||
|
Keyword arguments:
|
||||||
|
pipe -- stdout pipe to the dhcpcd process.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
'success' if successful, an error code string otherwise.
|
||||||
|
|
||||||
|
"""
|
||||||
|
udhcpc_complete = False
|
||||||
|
udhcpc_success = True
|
||||||
|
|
||||||
|
while not udhcpc_complete:
|
||||||
|
line = pipe.readline()
|
||||||
|
if line.endswith("failing"):
|
||||||
|
udhcpc_success = False
|
||||||
|
udhcpc_complete = True
|
||||||
|
elif line == '':
|
||||||
|
udhcpc_complete = True
|
||||||
|
print line
|
||||||
|
|
||||||
|
return self._check_dhcp_result(udhcpc_success)
|
||||||
|
|
||||||
def _check_dhcp_result(self, success):
|
def _check_dhcp_result(self, success):
|
||||||
""" Print and return the correct DHCP connection result.
|
""" Print and return the correct DHCP connection result.
|
||||||
|
|
||||||
@@ -524,6 +557,8 @@ class BaseInterface(object):
|
|||||||
return self._parse_pump(pipe)
|
return self._parse_pump(pipe)
|
||||||
elif DHCP_CLIENT == misc.DHCPCD:
|
elif DHCP_CLIENT == misc.DHCPCD:
|
||||||
return self._parse_dhcpcd(pipe)
|
return self._parse_dhcpcd(pipe)
|
||||||
|
elif DHCP_CLIENT == misc.UDHCPC:
|
||||||
|
return self._parse_udhcpc(pipe)
|
||||||
else:
|
else:
|
||||||
print 'ERROR no dhclient found!'
|
print 'ERROR no dhclient found!'
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user