Actually fix the DHCP handling, by using more robust detection of DHCP

setting.  While there, add some more debug messages explaining what is
happening, and some comments to improve readability.

Submitted by:	ceri
This commit is contained in:
Xin LI 2006-02-09 14:43:42 +00:00
parent 4f4a363562
commit f32c4f1dbd

View File

@ -126,8 +126,12 @@ mediaInitNetwork(Device *dev)
snprintf(ifconfig, 255, "%s%s", VAR_IFCONFIG, dev->name);
cp = variable_get(ifconfig);
if (cp) {
if (strcmp(cp, "DHCP")) {
msgDebug("ifconfig %s %s\n", dev->name, cp);
/*
* If this interface isn't a DHCP one, bring it up.
* If it is, then it's already up.
*/
if (strstr(cp, "DHCP") == NULL) {
msgDebug("Not a DHCP interface.\n");
i = vsystem("ifconfig %s %s", dev->name, cp);
if (i) {
msgConfirm("Unable to configure the %s interface!\n"
@ -144,6 +148,8 @@ mediaInitNetwork(Device *dev)
msgDebug("Adding default route to %s.\n", rp);
vsystem("route -n add default %s", rp);
}
} else {
msgDebug("A DHCP interface. Should already be up.\n");
}
} else if ((cp = variable_get(VAR_IPV6ADDR)) == NULL || *cp == '\0') {
msgConfirm("The %s device is not configured. You will need to do so\n"