diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index 1c06d39434..fb9c8a336b 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -216,7 +216,6 @@ function interfaces_optional_configure_if($opti) { /* bridged? */ if ($optcfg['bridge']) { mwexec("/sbin/ifconfig " . escapeshellarg($optcfg['if']) . " delete up"); - /* use open/netBSD style bridge */ mwexec("/sbin/ifconfig bridge{$bridges_total} create"); mwexec("/sbin/brconfig bridge{$bridges_total} add {$optcfg['if']} add {$config['interfaces'][$optcfg['bridge']]['if']} up"); @@ -224,8 +223,13 @@ function interfaces_optional_configure_if($opti) { /* lets keep track of the amount of bridges initialized */ $bridges_total++; } else { - mwexec("/sbin/ifconfig " . escapeshellarg($optcfg['if']) . " " . - escapeshellarg($optcfg['ipaddr'] . "/" . $optcfg['subnet'])); + /* if user has selected DHCP type then act accordingly */ + if($optcfg['type'] == 'DHCP') { + interfaces_opt_dhcp_configure($opti); + } else { + mwexec("/sbin/ifconfig " . escapeshellarg($optcfg['if']) . " " . + escapeshellarg($optcfg['ipaddr'] . "/" . $optcfg['subnet'])); + } } } else { mwexec("/sbin/ifconfig " . escapeshellarg($optcfg['if']) . " delete down"); @@ -382,6 +386,11 @@ function interfaces_wireless_configure($if, $wlcfg) { } +function find_dhclient_process($interface) { + $pid = `ps ax | grep dhclient | grep {$interface} | cut -f" " -d2`; + return $pid; +} + function interfaces_wan_configure() { global $config, $g; @@ -389,16 +398,17 @@ function interfaces_wan_configure() { if(!$g['booting']) { mute_kernel_msgs(); - /* kill dhclient */ - killbypid("{$g['varrun_path']}/dhclient.pid"); + + /* find dhclient process for wan and kill it */ + killbypid(find_dhclient_process("wan")); /* kill PPPoE client (mpd) */ killbypid("{$g['varrun_path']}/mpd.pid"); /* wait for processes to die */ - sleep(2); + sleep(1); - unlink_if_exists("{$g['varetc_path']}/dhclient.conf"); + unlink_if_exists("{$g['varetc_path']}/dhclient_wan.conf"); unlink_if_exists("{$g['varetc_path']}/mpd.conf"); unlink_if_exists("{$g['varetc_path']}/mpd.links"); unlink_if_exists("{$g['vardb_path']}/wanip"); @@ -488,15 +498,54 @@ function interfaces_wan_configure() { return 0; } +function interfaces_opt_dhcp_configure($interface) { + global $config, $g; + + $optcfg = $config['interfaces'][$interface]; + + /* generate dhclient_wan.conf */ + $fd = fopen("{$g['varetc_path']}/dhclient_{$interface}.conf", "w"); + if (!$fd) { + printf("Error: cannot open dhclient_{$interface}.conf in interfaces_opt_dhcp_configure({$interface}) for writing.\n"); + return 1; + } + + $dhclientconf = ""; + + if ($optcfg['dhcphostname']) { + $dhclientconf .= << "" and $_POST['bandwidthtype'] <> "") { $optcfg['bandwidth'] = $_POST['bandwidth']; $optcfg['bandwidthtype'] = $_POST['bandwidthtype']; @@ -135,7 +147,17 @@ if ($_POST) { unset($optcfg['bandwidth']); unset($optcfg['bandwidthtype']); } - $optcfg['gateway'] = $_POST['gateway']; + + if ($_POST['type'] == "Static") { + $optcfg['ipaddr'] = $_POST['ipaddr']; + $optcfg['subnet'] = $_POST['subnet']; + $optcfg['gateway'] = $_POST['gateway']; + if (isset($optcfg['ispointtopoint'])) + $optcfg['pointtopoint'] = $_POST['pointtopoint']; + } else if ($_POST['type'] == "DHCP") { + $optcfg['ipaddr'] = "dhcp"; + $optcfg['dhcphostname'] = $_POST['dhcphostname']; + } write_config(); @@ -181,6 +203,20 @@ function enable_change(enable_over) { function ipaddr_change() { document.iform.subnet.selectedIndex = gen_bits_opt(document.iform.ipaddr.value); } +function type_change(enable_change,enable_change_pptp) { + switch (document.iform.type.selectedIndex) { + case 0: + document.iform.ipaddr.disabled = 0; + document.iform.subnet.disabled = 0; + document.iform.gateway.disabled = 0; + break; + case 1: + document.iform.ipaddr.disabled = 1; + document.iform.subnet.disabled = 1; + document.iform.gateway.disabled = 1; + break; + } +} //--> @@ -197,14 +233,59 @@ function ipaddr_change() { onClick="enable_change(false)"> Enable Optional interface - + Description
Enter a description (name) for the interface here. - - + + + + + + + + General configuration + + + Type + + + + MAC address + + + Copy my MAC address +
+ This field can be used to modify ("spoof") the MAC + address of the WAN interface
+ (may be required with some cable connections)
+ Enter a MAC address in the following format: xx:xx:xx:xx:xx:xx + or leave blank + + + MTU + +
+ If you enter a value in this field, then MSS clamping for + TCP connections to the value entered above minus 40 (TCP/IP + header size) will be in effect. If you leave this field blank, + an MTU of 1492 bytes for PPPoE and 1500 bytes for all other + connection types will be assumed. + +