summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorErik Fonnesbeck <efonnes@gmail.com>2012-04-15 15:37:39 -0600
committerErik Fonnesbeck <efonnes@gmail.com>2012-04-20 00:20:29 -0600
commit868cd12c52210b519b7ea150927cf820bfb63677 (patch)
tree81c6d0c7823ac3999ce870c68fbc7adc1d0b0882 /etc
parent4b340c903c4077425f8396e9f2080f44140be67a (diff)
downloadpfsense-868cd12c52210b519b7ea150927cf820bfb63677.zip
pfsense-868cd12c52210b519b7ea150927cf820bfb63677.tar.gz
Modify filter_get_direct_networks_list to optionally return an array instead, which includes subnet, friendly interface, and gateway (if applicable), for ticket #2240
Diffstat (limited to 'etc')
-rw-r--r--etc/inc/filter.inc46
1 files changed, 34 insertions, 12 deletions
diff --git a/etc/inc/filter.inc b/etc/inc/filter.inc
index 09c642d..f01c01b 100644
--- a/etc/inc/filter.inc
+++ b/etc/inc/filter.inc
@@ -760,9 +760,11 @@ function filter_get_vpns_list() {
return $vpns;
}
-/* returns space separated list of directly connected networks */
-function filter_get_direct_networks_list() {
- global $config, $FilterIflist;
+/* returns space separated list of directly connected networks
+ * optionally returns an array instead, including friendly interface and gateway (if applicable)
+ */
+function filter_get_direct_networks_list($returnsubnetsonly = true) {
+ global $config, $FilterIflist, $GatewaysList;
/* build list of directly connected interfaces and networks */
$networks = "";
$networks_arr = array();
@@ -772,27 +774,47 @@ function filter_get_direct_networks_list() {
foreach ($FilterIflist as $ifent => $ifcfg) {
$subnet = "{$ifcfg['sa']}/{$ifcfg['sn']}";
if(is_subnet($subnet)) {
- $networks_arr[] = $subnet;
+ if($returnsubnetsonly) {
+ $networks_arr[] = $subnet;
+ } else {
+ $networks_arr[] = array('subnet' => $subnet, 'if' => $ifent);
+ }
}
}
foreach(get_configured_ip_aliases_list(true) as $vip) {
$subnet = "{$vip['subnet']}/{$vip['subnet_bits']}";
if(is_subnet($subnet) && !(is_subnetv4($subnet) && $vip['subnet_bits'] == 32) && !(is_subnetv6($subnet) && $vip['subnet_bits'] == 128)) {
if(is_subnetv4($subnet))
- $networks_arr[] = gen_subnet($vip['subnet'], $vip['subnet_bits']) . "/{$vip['subnet_bits']}";
+ $subnet = gen_subnet($vip['subnet'], $vip['subnet_bits']) . "/{$vip['subnet_bits']}";
else if(is_subnetv6($subnet))
- $networks_arr[] = gen_subnetv6($vip['subnet'], $vip['subnet_bits']) . "/{$vip['subnet_bits']}";
+ $subnet = gen_subnetv6($vip['subnet'], $vip['subnet_bits']) . "/{$vip['subnet_bits']}";
+ if($returnsubnetsonly) {
+ $networks_arr[] = $subnet;
+ } else {
+ $networks_arr[] = array('subnet' => $subnet, 'if' => $vip['interface']);
+ }
}
}
- foreach(get_staticroutes(true) as $netent) {
- if(is_subnet($netent)) {
- $networks_arr[] = $netent;
+ foreach(get_staticroutes() as $netent) {
+ if(is_subnet($netent['network'])) {
+ if($returnsubnetsonly) {
+ $networks_arr[] = $netent['network'];
+ } else if(isset($GatewaysList[$netent['gateway']])) {
+ $networks_arr[] = array(
+ 'subnet' => $netent['network'],
+ 'if' => $GatewaysList[$netent['gateway']]['friendlyiface'],
+ 'gateway' => $GatewaysList[$netent['gateway']]['gateway']);
+ }
}
}
- if(!empty($networks_arr)) {
- $networks = implode(" ", $networks_arr);
+ if($returnsubnetsonly) {
+ if(!empty($networks_arr)) {
+ $networks = implode(" ", $networks_arr);
+ }
+ return $networks;
+ } else {
+ return $networks_arr;
}
- return $networks;
}
function filter_generate_optcfg_array() {
OpenPOWER on IntegriCloud