summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorErmal Luçi <eri@pfsense.org>2008-10-19 13:20:32 +0000
committerErmal Luçi <eri@pfsense.org>2008-10-19 13:20:32 +0000
commit80bf3f4aace8a21a1ba307afd6db2c702b2ffc7a (patch)
treee1800e84b40bcbc3256a85291121a3d0845731bc /etc
parentf620d00d373e3d397c5f4d0904f8df654633cdea (diff)
downloadpfsense-80bf3f4aace8a21a1ba307afd6db2c702b2ffc7a.zip
pfsense-80bf3f4aace8a21a1ba307afd6db2c702b2ffc7a.tar.gz
Refactor some code so frontend does not need to know about details that might change
during development.
Diffstat (limited to 'etc')
-rw-r--r--etc/inc/interfaces.inc111
1 files changed, 43 insertions, 68 deletions
diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc
index b519200..bc53069 100644
--- a/etc/inc/interfaces.inc
+++ b/etc/inc/interfaces.inc
@@ -520,12 +520,51 @@ function interfaces_configure()
return 0;
}
-function interface_bring_down($interface)
+function interface_reconfigure($interface = "wan")
{
- global $config;
+ interface_bring_down($interface);
+ sleep(1);
+ interface_configure($interface);
+}
+
+function interface_bring_down($interface = "wan")
+{
+ global $config, $g;
+
+ $ifcfg = $config['interfaces'][$interface];
+
+ $realif = get_real_wan_interface($interface);
- $cfg = $config['interfaces'][$interface];
- mwexec("/sbin/ifconfig " . escapeshellarg($cfg['if']) . " delete down");
+ switch ($ifcfg['ipaddr']) {
+ case "pppoe":
+ killbypid("{$g['varrun_path']}/pppoe_{$interface}.pid");
+ sleep(2);
+ break;
+ case "pptp":
+ killbypid("{$g['varrun_path']}/pptp_{$interface}.pid");
+ sleep(2);
+ break;
+ case "carpdev-dhcp":
+ /*
+ * NB: When carpdev gets enabled it would be better to be handled as all
+ * other interfaces!
+ */
+ case "dhcp":
+ mwexec("/sbin/ifconfig {$realinterface} down");
+ sleep(1);
+ $pid = find_dhclient_process($interface);
+ if($pid)
+ mwexec("kill {$pid}");
+ break;
+ default:
+ mwexec("/sbin/ifconfig " . escapeshellarg($realif) . " delete down");
+ break;
+ }
+
+ if (preg_match("/^tun|^ppp|^ovpn|^gif|^gre|^lagg|^bridge|^vlan/i", $realif))
+ mwexec("/sbin/ifconfig {$realif} destroy");
+
+ return;
}
function interfaces_ppp_configure()
@@ -1352,24 +1391,6 @@ EOD;
return 0;
}
-function interface_dhcp_down($interface = "wan")
-{
- global $config;
- if(get_real_wan_interface($interface) <> "")
- $realinterface = get_real_wan_interface($interface);
- mwexec("/sbin/ifconfig {$realinterface} down");
- sleep(1);
- $pid = find_dhclient_process($interface);
- if($pid)
- mwexec("kill {$pid}");
-}
-
-function interface_dhcp_up($interface = "wan")
-{
- interface_dhcp_configure($interface);
- sleep(1);
-}
-
function interface_pppoe_configure($interface = "wan")
{
global $config, $g;
@@ -1533,29 +1554,6 @@ EOD;
return 0;
}
-function interface_pppoe_restart($interface = "wan")
-{
- interface_pppoe_down($interface);
- sleep(1);
- interface_pppoe_up($interface);
-}
-
-function interface_pppoe_down($interface = "wan")
-{
- global $g;
- killbypid("{$g['varrun_path']}/pppoe_{$interface}.pid");
- sleep(1);
-}
-
-function interface_pppoe_up($interface = "wan")
-{
- global $g;
- /* fire up mpd */
- /* NB: keep in sync with interface_pppoe_configure */
- mwexec("/usr/local/sbin/mpd4 -b -d {$g['varetc_path']} -f mpd_{$interface}.conf -l mpd_{$interface}.links -p {$g['varrun_path']}/pppoe_{$interface}.pid pppoeclient");
- sleep(1);
-}
-
function interface_pptp_configure($interface)
{
global $config, $g;
@@ -1676,29 +1674,6 @@ EOD;
return 0;
}
-function interface_pptp_restart($interface = "wan")
-{
- interface_pptp_down($interface);
- sleep(1);
- interface_pptp_up($interface);
-}
-
-function interface_pptp_down($interface = "wan")
-{
- global $g;
- killbypid("{$g['varrun_path']}/pptp_{$interface}.pid");
- sleep(1);
-}
-
-function interface_pptp_up($interface = "wan")
-{
- global $g;
- /* fire up mpd */
- /* NB: Keep in sync with interface_pptp_configure */
- mwexec("/usr/local/sbin/mpd4 -b -d {$g['varetc_path']} -f mpd_{$interface}.conf -l mpd_{$interface}.links -p {$g['varrun_path']}/pptp_{$interface}.pid pptp");
- sleep(1);
-}
-
function get_real_wan_interface($interface = "wan")
{
global $config;
OpenPOWER on IntegriCloud