diff options
author | Ermal Luci <eri@pfsense.org> | 2009-01-20 17:53:58 +0000 |
---|---|---|
committer | Ermal Luci <eri@pfsense.org> | 2009-01-20 17:53:58 +0000 |
commit | c47b0b2b4a45bed148a06d38525d198814795887 (patch) | |
tree | 10bab2376fbb6aeadeb814d3323c759c4ff1af2d /etc/inc/interfaces.inc | |
parent | ed40c952bbfd770ea06f66488e6517de663cf440 (diff) | |
parent | ad8622208cf9c6f3978bc1a41f2c58b9deafe300 (diff) | |
download | pfsense-c47b0b2b4a45bed148a06d38525d198814795887.zip pfsense-c47b0b2b4a45bed148a06d38525d198814795887.tar.gz |
Merge branch 'master' of git@rcs.pfsense.org:pfsense/mainline
Diffstat (limited to 'etc/inc/interfaces.inc')
-rw-r--r-- | etc/inc/interfaces.inc | 88 |
1 files changed, 71 insertions, 17 deletions
diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index 1bf71ed..33945b1 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -51,6 +51,7 @@ function interfaces_bring_up($interface) { function interfaces_loopback_configure() { mwexec("/sbin/ifconfig lo0 127.0.0.1"); + mwexec("/sbin/ifconfig lo0 inet6 ::1 prefixlen 128"); interfaces_bring_up("lo0"); return 0; } @@ -337,6 +338,8 @@ function interface_lagg_configure(&$lagg) { } else $laggif = exec("/sbin/ifconfig lagg create"); + mwexec("/sbin/ifconfig {$laggif} {$lagg['proto']}"); + /* Calculate smaller mtu and enforce it */ $smallermtu = 0; foreach ($members as $member) { @@ -365,8 +368,6 @@ function interface_lagg_configure(&$lagg) { mwexec("/sbin/ifconfig {laggif} laggport {$realif}"); } - mwexec("/sbin/ifconfig {$laggif} {$lagg['proto']}"); - interfaces_bring_up($laggif); return $laggif; @@ -970,7 +971,8 @@ EOD; } -function interfaces_ipalias_configure() { +function interfaces_ipalias_configure() +{ global $g, $config; if(isset($config['system']['developerspew'])) { $mt = microtime(); @@ -981,7 +983,11 @@ function interfaces_ipalias_configure() { foreach ($viparr as $vip) { if ($vip['mode'] == "ipalias") { $if = get_real_interface($vip['interface']); - mwexec("/sbin/ifconfig " . escapeshellarg($if) . " " . $vip['subnet'] . "/" . escapeshellarg($vip['subnet_bits']) . " alias"); + if ($vip['subnet_ipv6'] != '') { + mwexec("/sbin/ifconfig " . escapeshellarg($if) . " inet6 {$vip['subnet_ipv6']} alias"); + } else { + mwexec("/sbin/ifconfig " . escapeshellarg($if) . " " . $vip['subnet'] . "/" . escapeshellarg($vip['subnet_bits']) . " alias"); + } } } } @@ -1258,12 +1264,21 @@ function interface_configure($interface = "wan") { $realif = get_real_interface($interface); - if(!$g['booting']) { - /* remove all addresses first */ + if (!$g['booting']) { + /* remove all IPv4 addresses */ while (mwexec("/sbin/ifconfig " . escapeshellarg($realif) . " -alias", true) == 0); interface_bring_down($interface); + + /* remove all IPv6 addresses */ + $str = <<<EOD + while i="`/sbin/ifconfig $realif | /usr/bin/grep inet6 | /usr/bin/grep -m 1 -v '%'`"; do + ifconfig $realif \$i delete + done +EOD; + mwexec("($str)"); mwexec("/sbin/ifconfig " . escapeshellarg($wancfg['if']) . " down"); - } + } + /* wireless configuration? */ if (is_array($wancfg['wireless'])) interface_wireless_configure($realif, $wancfg['wireless']); @@ -1326,15 +1341,32 @@ function interface_configure($interface = "wan") { escapeshellarg($wancfg['ipaddr'] . "/" . $wancfg['subnet']) . " " . escapeshellarg($wancfg['pointtopoint']) . " up"); } else { - if($wancfg['ipaddr'] && $wancfg['subnet']) + if($wancfg['ipaddr'] && $wancfg['subnet']) { mwexec("/sbin/ifconfig " . escapeshellarg($realif) . " " . escapeshellarg($wancfg['ipaddr'] . "/" . $wancfg['subnet'])); + } + } + } + + if ($wancfg['ipaddr_ipv6'] <> "" && $wancfg['subnet_ipv6'] <> "") { + if (isset($wancfg['ispointtopoint_ipv6']) && $wancfg['pointtopoint_ipv6']) { + // TODO: do something + } else { + mwexec("/sbin/ifconfig " . escapeshellarg($realif) . + " inet6 " . escapeshellarg($wancfg['ipaddr_ipv6'] . "/" . + $wancfg['subnet_ipv6'])); } } - if (is_ipaddr($wancfg['gateway'])) + if (is_ipaddr($wancfg['gateway'])) { file_put_contents("/tmp/{$realif}_router", $wancfg['gateway']); + } + + if (Net_IPv6::checkIPv6($wancfg['gateway_ipv6'])) { + // TODO: IPv6 needs to be configured too + file_put_contents("/tmp/{$realif}_router_ipv6", $wancfg['gateway_ipv6']); + } } if($wancfg['if']) interfaces_bring_up($wancfg['if']); @@ -1502,6 +1534,10 @@ pppoeclient: EOD; + /* + * XXX: mpd seems to use netgraph interfaces so ngX interfaces are created + * instead of pppoeX. =) -simoncpu- + */ if ($interface == "wan") $realif = "pppoe0"; else { @@ -1816,6 +1852,10 @@ function get_real_interface($interface = "wan") { } break; case "pppoe": + /* + * XXX: mpd seems to use netgraph interfaces so ngX interfaces are created + * instead of pppoeX. =) -simoncpu- + */ if ($if == "wan") $wanif = "pppoe0"; else @@ -1841,28 +1881,42 @@ function get_real_interface($interface = "wan") { return $wanif; } -function get_interface_ip($interface = "wan") { +function get_interface_ip($interface = "wan", $type = "ipv4") +{ + global $config, $g; + $realif = get_real_interface($interface); /* Do we really come here for these interfaces ?! */ if (in_array($realif, array("pptp", "pppoe", "openvpn", "enc0" /* , "ppp" */))) return ""; - $curip = find_interface_ip($realif); - if ($curip && is_ipaddr($curip) && ($curip != "0.0.0.0")) - return $curip; + $curip = find_interface_ip($realif, false, $type); + + if ($type == 'ipv6') { + if ($curip && Net_IPv6::checkIPv6($curip)) { + return $curip; + } + } else { + if ($curip && is_ipaddr($curip) && ($curip != "0.0.0.0")) { + return $curip; + } + } return null; } -function get_interface_subnet($interface = "wan") { +function get_interface_subnet($interface = "wan", $type = "ipv4") +{ $realif = get_real_interface($interface); /* Do we really come here for these interfaces ?! */ - if (in_array($realif, array("pptp", "pppoe", "openvpn", "enc0" /* , "ppp" */))) + if (in_array($realif, array("pptp", "pppoe", "openvpn", "enc0" /* , "ppp" */))) { return ""; + } - $cursn = find_interface_subnet($realif); - if (!empty($cursn)) + $cursn = find_interface_subnet($realif, false, $type); + if (!empty($cursn)) { return $cursn; + } return null; } |