diff options
author | Ermal Luçi <eri@pfsense.org> | 2009-03-30 00:37:45 +0000 |
---|---|---|
committer | Ermal Luçi <eri@pfsense.org> | 2009-03-30 00:38:36 +0000 |
commit | a55e9c701c2fc8914e0aebf12e37038f59b07cf8 (patch) | |
tree | 05b5a1bc85f8742706649429ec164f576d240975 /etc/inc/pfsense-utils.inc | |
parent | cc460ee980e427bf4acdb8a4903e3278df59ea94 (diff) | |
download | pfsense-a55e9c701c2fc8914e0aebf12e37038f59b07cf8.zip pfsense-a55e9c701c2fc8914e0aebf12e37038f59b07cf8.tar.gz |
* Hide interfaces internals to other code and use the propper interfaces.
Basically use get_interface*() functions instead of accessing fields like 'ipaddr'/'descr' etc...
* Make get_interfaces_with_gateway less heavyweight by getting information from the configuration stored in config.xml
* Some other missed custom interface list building and substituing with propper get_configured_interface*()
NOTE: This should give indipendce on dynamic interfaces on some services that before could not be used on top of this type of interfaces.
Diffstat (limited to 'etc/inc/pfsense-utils.inc')
-rw-r--r-- | etc/inc/pfsense-utils.inc | 54 |
1 files changed, 17 insertions, 37 deletions
diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc index 9d6403d..ac86a89 100644 --- a/etc/inc/pfsense-utils.inc +++ b/etc/inc/pfsense-utils.inc @@ -561,12 +561,11 @@ function tdr_install_set() { mwexec("/sbin/ipfw add 1 check-state"); mwexec("/sbin/ipfw delete 65534"); mwexec("/sbin/ipfw add 1 allow all from me to any keep-state"); - if (!isset ($config['system']['webgui']['noantilockout'])) { + if (!isset ($config['system']['webgui']['noantilockout']) && count($config['interfaces']) > 1) { /* lan ip lockout */ - $lancfg = $config['interfaces']['lan']; - $lanip = $lancfg['ipaddr']; - $lansn = $lancfg['subnet']; - $lansa = gen_subnet($lancfg['ipaddr'], $lancfg['subnet']); + $lanip = get_interface_ip("lan"); + $lansn = get_interface_subnet("lan"); + $lansa = gen_subnet($lanip, $lansn); mwexec("/sbin/ipfw add 1 allow all from {$lansa}/{$lansn} to $lanip keep-state"); } mwexec("/sbin/ipfw add 65534 check-state"); @@ -1249,12 +1248,11 @@ function link_carp_interface_to_parent($interface) { $carp_subnet = find_virtual_ip_netmask($carp_ip); $starting_ip = gen_subnet("{$carp_ip}", "{$carp_subnet}"); $carp_ints = ""; - $num_carp_ints = find_number_of_created_carp_interfaces(); foreach ($ifdescrs as $ifdescr => $ifname) { if(interface_has_gateway($ifname)) { - $interfaceip = $config['interfaces'][$ifname]['ipaddr']; - $subnet_bits = $config['interfaces'][$ifname]['subnet']; + $interfaceip = get_interface_ip($ifname); + $subnet_bits = get_interface_subnet($ifname); $subnet_ip = gen_subnet("{$interfaceip}", "{$subnet_bits}"); if(ip_in_subnet($carp_ip, "{$subnet_ip}/{$subnet_bits}")) { return $ifname; @@ -2855,39 +2853,24 @@ function is_dhcp_server_enabled() /* return outside interfaces with a gateway */ function get_interfaces_with_gateway() { global $config; + $ints = array(); - $vfaces = array( - 'bridge.?*', - 'ppp.?*', - 'sl.?*', - 'gif.?*', - 'faith.?*', - 'lo.?*', - 'ng.?*', - 'vlan.?*', - 'pflog.?*', - 'pfsync.?*', - 'enc.?*', - 'tun.?*', - 'carp.?*' - ); - $ifdescrs = get_interface_list("active","physical",$vfaces); + $ifdescrs = get_configured_interface_list(false, true); /* loop interfaces, check config for outbound */ foreach ($ifdescrs as $ifdescr => $ifname) { - $friendly = $ifname['friendly']; - switch ($config['interfaces'][$friendly]['ipaddr']) { + switch ($config['interfaces'][$ifname]['ipaddr']) { case "dhcp": case "carpdev-dhcp": case "pppoe": case "pptp": - $ints[] = $friendly; + $ints[] = $ifname; break; default: - if ($config['interfaces'][$friendly]['pointtopoint']) - $ints[] = $friendly; - else if ($config['interfaces'][$friendly]['gateway'] <> "") - $ints[] = $friendly; + if ($config['interfaces'][$ifname]['pointtopoint']) + $ints[] = $ifname; + else if (!empty($config['interfaces'][$ifname]['gateway'])) + $ints[] = $ifname; break; } } @@ -2897,13 +2880,10 @@ function get_interfaces_with_gateway() { /* return true if interface has a gateway */ function interface_has_gateway($friendly) { $friendly = strtolower($friendly); - if(in_array($friendly, get_interfaces_with_gateway())) { + if (in_array($friendly, get_interfaces_with_gateway())) return true; - } else { - /* extra check for real interface names if it falls through */ - $friendly = convert_real_interface_to_friendly_interface_name($friendly); - return(in_array($friendly, get_interfaces_with_gateway())); - } + + return false; } /****f* pfsense-utils/isAjax |