diff options
author | Ermal Luçi <eri@pfsense.org> | 2008-10-19 09:47:51 +0000 |
---|---|---|
committer | Ermal Luçi <eri@pfsense.org> | 2008-10-19 09:47:51 +0000 |
commit | f620d00d373e3d397c5f4d0904f8df654633cdea (patch) | |
tree | cecc67dfd6f18f1a533794bc382bdf581691086f /etc | |
parent | 87a2efd1d8bb2d72247c5e805b4b0050f3bcefff (diff) | |
download | pfsense-f620d00d373e3d397c5f4d0904f8df654633cdea.zip pfsense-f620d00d373e3d397c5f4d0904f8df654633cdea.tar.gz |
style(9)
Diffstat (limited to 'etc')
-rw-r--r-- | etc/inc/interfaces.inc | 137 |
1 files changed, 84 insertions, 53 deletions
diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index 23119d1..b519200 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -40,21 +40,22 @@ require_once("functions.inc"); require_once("globals.inc"); -function interfaces_loopback_configure() { +function interfaces_loopback_configure() +{ mwexec("/sbin/ifconfig lo0 127.0.0.1"); mwexec("/sbin/ifconfig lo0 up"); return 0; } -function interfaces_vlan_configure() { +function interfaces_vlan_configure() +{ global $config; $i = 0; if (is_array($config['vlans']['vlan']) && count($config['vlans']['vlan'])) { foreach ($config['vlans']['vlan'] as $vlan) { - if(empty($vlan['vlanif'])) { + if(empty($vlan['vlanif'])) $vlan['vlanif'] = "vlan{$i}"; - } /* XXX: Maybe we should report any errors?! */ interface_vlan_configure($vlan['if'], $vlan['tag'], $vlan['vlanif']); $i++; @@ -62,7 +63,8 @@ function interfaces_vlan_configure() { } } -function interface_vlan_configure($if, $tag, $vlanif = "") { +function interface_vlan_configure($if, $tag, $vlanif = "") +{ global $config, $g; /* devices with native VLAN support */ @@ -117,15 +119,15 @@ function interface_vlan_configure($if, $tag, $vlanif = "") { return $vlanif; } -function interfaces_bridge_configure() { +function interfaces_bridge_configure() +{ global $config; $i = 0; if (is_array($config['bridges']['bridged']) && count($config['bridges']['bridged'])) { foreach ($config['bridges']['bridged'] as $bridge) { - if(empty($bridge['bridgeif'])) { + if(empty($bridge['bridgeif'])) $bridge['bridgeif'] = "bridge{$i}"; - } /* XXX: Maybe we should report any errors?! */ interface_bridge_configure($bridge); $i++; @@ -133,7 +135,8 @@ function interfaces_bridge_configure() { } } -function interface_bridge_configure(&$bridge) { +function interface_bridge_configure(&$bridge) +{ global $config, $g; if (!is_array($bridge)) @@ -255,15 +258,15 @@ function interface_bridge_configure(&$bridge) { return $bridgeif; } -function interfaces_lagg_configure() { +function interfaces_lagg_configure() +{ global $config; $i = 0; if (is_array($config['laggs']['lagg']) && count($config['laggs']['lagg'])) { foreach ($config['laggs']['lagg'] as $lagg) { - if(empty($lagg['laggif'])) { + if(empty($lagg['laggif'])) $lagg['laggif'] = "lagg{$i}"; - } /* XXX: Maybe we should report any errors?! */ interface_lagg_configure($lagg); $i++; @@ -271,7 +274,8 @@ function interfaces_lagg_configure() { } } -function interface_lagg_configure(&$lagg) { +function interface_lagg_configure(&$lagg) +{ global $config, $g; if (!is_array($lagg)) @@ -313,15 +317,15 @@ function interface_lagg_configure(&$lagg) { return $laggif; } -function interfaces_gre_configure() { +function interfaces_gre_configure() +{ global $config; $i = 0; if (is_array($config['gres']['gre']) && count($config['gres']['gre'])) { foreach ($config['gres']['gre'] as $gre) { - if(empty($gre['greif'])) { + if(empty($gre['greif'])) $gre['greif'] = "gre{$i}"; - } /* XXX: Maybe we should report any errors?! */ interface_gre_configure($gre); $i++; @@ -329,7 +333,8 @@ function interfaces_gre_configure() { } } -function interface_gre_configure(&$gre) { +function interface_gre_configure(&$gre) +{ global $config, $g; if (!is_array($gre)) @@ -364,15 +369,15 @@ function interface_gre_configure(&$gre) { return $greif; } -function interfaces_gif_configure() { +function interfaces_gif_configure() +{ global $config; $i = 0; if (is_array($config['gifs']['gif']) && count($config['gifs']['gif'])) { foreach ($config['gifs']['gif'] as $gif) { - if(empty($gif['gifif'])) { + if(empty($gif['gifif'])) $gre['gifif'] = "gif{$i}"; - } /* XXX: Maybe we should report any errors?! */ interface_gif_configure($gif); $i++; @@ -380,7 +385,8 @@ function interfaces_gif_configure() { } } -function interface_gif_configure(&$gif) { +function interface_gif_configure(&$gif) +{ global $config, $g; if (!is_array($gif)) @@ -413,7 +419,8 @@ function interface_gif_configure(&$gif) { return $gifif; } -function interfaces_configure() { +function interfaces_configure() +{ global $config, $g; /* set up VLAN virtual interfaces */ @@ -497,7 +504,7 @@ function interfaces_configure() { /* reload IPsec tunnels */ vpn_ipsec_configure(); - /* reload dhcpd (interface enabled/disabled/bridged status may have changed) */ + /* reload dhcpd (interface enabled/disabled status may have changed) */ services_dhcpd_configure(); /* restart dnsmasq */ @@ -513,22 +520,23 @@ function interfaces_configure() { return 0; } -function interface_bring_down($interface) { +function interface_bring_down($interface) +{ global $config; $cfg = $config['interfaces'][$interface]; mwexec("/sbin/ifconfig " . escapeshellarg($cfg['if']) . " delete down"); } -function interfaces_ppp_configure() { +function interfaces_ppp_configure() +{ global $config; $i = 0; if (is_array($config['ppps']['ppp']) && count($config['ppps']['ppp'])) { foreach ($config['ppps']['ppp'] as $ppp) { - if(empty($ppp['pppif'])) { + if(empty($ppp['pppif'])) $ppp['pppif'] = "ppp{$i}"; - } /* XXX: Maybe we should report any errors?! */ interface_ppp_configure($ppp); $i++; @@ -536,7 +544,8 @@ function interfaces_ppp_configure() { } } -function interface_ppp_configure($ifcfg) { +function interface_ppp_configure($ifcfg) +{ global $config, $g; /* Remove the /dev/ from the device name. */ @@ -641,7 +650,8 @@ function interface_ppp_configure($ifcfg) { return $realif; } -function interfaces_carp_configure() { +function interfaces_carp_configure() +{ global $g, $config; $balanacing = ""; $pfsyncinterface = ""; @@ -836,7 +846,8 @@ EOD; } -function interfaces_ipalias_configure() { +function interfaces_ipalias_configure() +{ global $g, $config; if(isset($config['system']['developerspew'])) { $mt = microtime(); @@ -853,7 +864,8 @@ function interfaces_ipalias_configure() { } } -function interface_wireless_configure($if, $wlcfg) { +function interface_wireless_configure($if, $wlcfg) +{ global $config, $g; /* open up a shell script that will be used to output the commands. @@ -1101,23 +1113,26 @@ EOD; } -function kill_hostapd($interface) { +function kill_hostapd($interface) +{ return "/bin/ps awwuxx | grep hostapd | grep $interface | awk '{ print \$2 }' | xargs kill\n"; } -function kill_wpasupplicant($interface) { +function kill_wpasupplicant($interface) +{ return "/bin/ps awwuxx | grep wpa_supplicant | grep $interface | awk '{ print \$2 }' | xargs kill\n"; } -function find_dhclient_process($interface) { - if (get_real_wan_interface($interface) <> "") - $realinterface = get_real_wan_interface($interface); +function find_dhclient_process($interface) +{ + $realinterface = get_real_wan_interface($interface); if($realinterface) $pid = `ps awwwux | grep dhclient | grep -v grep | grep {$realinterface} | awk '{ print \$2 }'`; return $pid; } -function interface_configure($interface = "wan") { +function interface_configure($interface = "wan") +{ global $config, $g; $wancfg = $config['interfaces'][$interface]; @@ -1260,7 +1275,8 @@ function interface_configure($interface = "wan") { return 0; } -function interface_carpdev_dhcp_configure($interface = "wan") { +function interface_carpdev_dhcp_configure($interface = "wan") +{ global $config, $g; $wancfg = $config['interfaces'][$interface]; @@ -1271,7 +1287,8 @@ function interface_carpdev_dhcp_configure($interface = "wan") { return 0; } -function interface_dhcp_configure($interface = "wan") { +function interface_dhcp_configure($interface = "wan") +{ global $config, $g; $wancfg = $config['interfaces'][$interface]; @@ -1335,7 +1352,8 @@ EOD; return 0; } -function interface_dhcp_down($interface = "wan") { +function interface_dhcp_down($interface = "wan") +{ global $config; if(get_real_wan_interface($interface) <> "") $realinterface = get_real_wan_interface($interface); @@ -1346,12 +1364,14 @@ function interface_dhcp_down($interface = "wan") { mwexec("kill {$pid}"); } -function interface_dhcp_up($interface = "wan") { +function interface_dhcp_up($interface = "wan") +{ interface_dhcp_configure($interface); sleep(1); } -function interface_pppoe_configure($interface = "wan") { +function interface_pppoe_configure($interface = "wan") +{ global $config, $g; $wancfg = $config['interfaces'][$interface]; @@ -1513,19 +1533,22 @@ EOD; return 0; } -function interface_pppoe_restart($interface = "wan") { +function interface_pppoe_restart($interface = "wan") +{ interface_pppoe_down($interface); sleep(1); interface_pppoe_up($interface); } -function interface_pppoe_down($interface = "wan") { +function interface_pppoe_down($interface = "wan") +{ global $g; killbypid("{$g['varrun_path']}/pppoe_{$interface}.pid"); sleep(1); } -function interface_pppoe_up($interface = "wan") { +function interface_pppoe_up($interface = "wan") +{ global $g; /* fire up mpd */ /* NB: keep in sync with interface_pppoe_configure */ @@ -1533,7 +1556,8 @@ function interface_pppoe_up($interface = "wan") { sleep(1); } -function interface_pptp_configure($interface) { +function interface_pptp_configure($interface) +{ global $config, $g; $wancfg = $config['interfaces'][$interface]; @@ -1652,19 +1676,22 @@ EOD; return 0; } -function interface_pptp_restart($interface = "wan") { +function interface_pptp_restart($interface = "wan") +{ interface_pptp_down($interface); sleep(1); interface_pptp_up($interface); } -function interface_pptp_down($interface = "wan") { +function interface_pptp_down($interface = "wan") +{ global $g; killbypid("{$g['varrun_path']}/pptp_{$interface}.pid"); sleep(1); } -function interface_pptp_up($interface = "wan") { +function interface_pptp_up($interface = "wan") +{ global $g; /* fire up mpd */ /* NB: Keep in sync with interface_pptp_configure */ @@ -1672,7 +1699,8 @@ function interface_pptp_up($interface = "wan") { sleep(1); } -function get_real_wan_interface($interface = "wan") { +function get_real_wan_interface($interface = "wan") +{ global $config; $wanif = $interface; @@ -1745,7 +1773,8 @@ function get_real_wan_interface($interface = "wan") { return $wanif; } -function get_current_wan_address($interface = "wan") { +function get_current_wan_address($interface = "wan") +{ global $config, $g; $realif = get_real_wan_interface($interface); @@ -1840,7 +1869,8 @@ function get_current_wan_address($interface = "wan") { * boolean - true or false ******/ -function is_altq_capable($int) { +function is_altq_capable($int) +{ /* Per: * http://www.freebsd.org/cgi/man.cgi?query=altq&manpath=FreeBSD+6.0-current&format=html * Only the following drivers have ALTQ support @@ -1894,7 +1924,8 @@ function get_wireless_modes($interface) return($wireless_modes); } -function get_interface_mac($interface) { +function get_interface_mac($interface) +{ /* build interface list with netstat */ $linkinfo = ""; |