summaryrefslogtreecommitdiffstats
path: root/etc/inc/services.inc
diff options
context:
space:
mode:
authorErmal <eri@pfsense.org>2010-08-19 18:32:51 +0000
committerErmal <eri@pfsense.org>2010-08-19 18:32:51 +0000
commit2f06cc3f6c9a15d7295323283703c418227c6b1b (patch)
treec106e19dc3434d5ad2a8c4a679eb67862bdddd71 /etc/inc/services.inc
parent2445e8515882368b5d8335409c50abeb9653b1e1 (diff)
downloadpfsense-2f06cc3f6c9a15d7295323283703c418227c6b1b.zip
pfsense-2f06cc3f6c9a15d7295323283703c418227c6b1b.tar.gz
Make dhcrelay GUI be simple and easy to use by collapsing the interface tabs to a multiselect control. Remove proxydhcp option because it is broken and is not trivial to make it usable(if user request for it a reconsideration will be made). Allow multiple server ips on the server input box separated by commas. Also on the interface list do not show interfaces without an ip because dhcrelay will not be happy with them. Upgrade code is also included in this commit.
Diffstat (limited to 'etc/inc/services.inc')
-rw-r--r--etc/inc/services.inc131
1 files changed, 64 insertions, 67 deletions
diff --git a/etc/inc/services.inc b/etc/inc/services.inc
index 877368a..86bb78c 100644
--- a/etc/inc/services.inc
+++ b/etc/inc/services.inc
@@ -477,20 +477,10 @@ function services_dhcrelay_configure() {
/* kill any running dhcrelay */
killbypid("{$g['varrun_path']}/dhcrelay.pid");
- $dhcrelaycfg = $config['dhcrelay'];
+ $dhcrelaycfg =& $config['dhcrelay'];
/* DHCPRelay enabled on any interfaces? */
- $dhcrelayenable = false;
- if(is_array($dhcrelaycfg)) {
- foreach ($dhcrelaycfg as $dhcrelayif => $dhcrelayifconf) {
- if (isset($dhcrelayifconf['enable']) ||
- (isset($config['interfaces'][$dhcrelayif]['enable']) &&
- (!link_interface_to_bridge($dhcrelayif))))
- $dhcrelayenable = true;
- }
- }
-
- if (!$dhcrelayenable)
+ if (!isset($dhcrelaycfg['enable']))
return 0;
if ($g['booting'])
@@ -498,72 +488,79 @@ function services_dhcrelay_configure() {
else
sleep(1);
- $dhcrelayifs = array();
- foreach ($dhcrelaycfg as $dhcrelayif => $dhcrelayifconf) {
-
- $ifcfg = $config['interfaces'][$dhcrelayif];
+ $iflist = get_configured_interface_list();
- if (!isset($dhcrelayifconf['enable']) ||
- (!isset($ifcfg['enable']) ||
- link_interface_to_bridge($dhcrelayif)))
+ $dhcifaces = explode(",", $dhcrelaycfg['interface']);
+ foreach ($dhcifaces as $dhcrelayif) {
+ if (!isset($iflist[$dhcrelayif]) ||
+ link_interface_to_bridge($dhcrelayif))
continue;
- $dhcrelayifs[] = get_real_interface($dhcrelayif);
+ if (is_ipaddr(get_interface_ip($dhcrelayif)))
+ $dhcrelayifs[] = get_real_interface($dhcrelayif);
}
- /* In order for the relay to work, it needs to be active on the
- interface in which the destination server sits */
- $iflist = get_configured_interface_list();
- foreach ($iflist as $ifname) {
- $subnet = get_interface_ip($ifname) . "/" . get_interface_subnet($ifname);
- if (ip_in_subnet($dhcrelaycfg['server'],$subnet)) {
- $destif = get_real_interface($ifname);
- break;
+ /*
+ * In order for the relay to work, it needs to be active
+ * on the interface in which the destination server sits.
+ */
+ $srvips = explode(",", $dhcrelaycfg['server']);
+ foreach ($srvips as $srcidx => $srvip) {
+ unset($destif);
+ foreach ($iflist as $ifname) {
+ $subnet = get_interface_ip($ifname);
+ if (!is_ipaddr($subnet))
+ continue;
+ $subnet .= "/" . get_interface_subnet($ifname);
+ if (ip_in_subnet($srvip, $subnet)) {
+ $destif = get_real_interface($ifname);
+ break;
+ }
}
- }
- if (!isset($destif)) {
- if (is_array($config['staticroutes']['route'])) {
- foreach ($config['staticroutes']['route'] as $rtent) {
- if (ip_in_subnet($dhcrelaycfg['server'], $rtent['network'])) {
- $a_gateways = return_gateways_array(true);
- $destif = $a_gateways[$rtent['gateway']]['interface'];
- break;
+ if (!isset($destif)) {
+ if (is_array($config['staticroutes']['route'])) {
+ foreach ($config['staticroutes']['route'] as $rtent) {
+ if (ip_in_subnet($srvip, $rtent['network'])) {
+ $a_gateways = return_gateways_array(true);
+ $destif = $a_gateways[$rtent['gateway']]['interface'];
+ break;
+ }
}
}
}
- }
- if (!isset($destif)) {
- /* Create a array from the existing route table */
- exec("/usr/bin/netstat -rnf inet", $route_str);
- array_shift($route_str);
- array_shift($route_str);
- array_shift($route_str);
- array_shift($route_str);
- $route_arr = array();
- foreach($route_str as $routeline) {
- $items = preg_split("/[ ]+/i", $routeline);
- if (ip_in_subnet($$dhcrelaycfg['server'], $items[0])) {
- $destif = trim($items[2]);
- break;
- }
- }
- }
-
- if (!isset($destif)) {
- if (is_array($config['gateways']['gateway_item'])) {
- foreach ($config['gateways']['gateway_item'] as $gateway) {
- if (isset($gateway['defaultgw'])) {
- $a_gateways = return_gateways_array(true);
- $destif = $a_gateways[$rtent['gateway']]['interface'];
+ if (!isset($destif)) {
+ /* Create a array from the existing route table */
+ exec("/usr/bin/netstat -rnWf inet", $route_str);
+ array_shift($route_str);
+ array_shift($route_str);
+ array_shift($route_str);
+ array_shift($route_str);
+ $route_arr = array();
+ foreach($route_str as $routeline) {
+ $items = preg_split("/[ ]+/i", $routeline);
+ if (ip_in_subnet($srvip, $items[0])) {
+ $destif = trim($items[2]);
break;
- }
- }
- } else
- $destif = get_real_interface("wan");
- }
+ }
+ }
+ }
+
+ if (!isset($destif)) {
+ if (is_array($config['gateways']['gateway_item'])) {
+ foreach ($config['gateways']['gateway_item'] as $gateway) {
+ if (isset($gateway['defaultgw'])) {
+ $a_gateways = return_gateways_array(true);
+ $destif = $a_gateways[$rtent['gateway']]['interface'];
+ break;
+ }
+ }
+ } else
+ $destif = get_real_interface("wan");
+ }
- $dhcrelayifs[] = $destif;
+ $dhcrelayifs[] = $destif;
+ }
$dhcrelayifs = array_unique($dhcrelayifs);
/* fire up dhcrelay */
@@ -572,7 +569,7 @@ function services_dhcrelay_configure() {
if (isset($dhcrelaycfg['agentoption']))
$cmd .= " -a -m replace";
- $cmd .= " {$dhcrelaycfg['server']}";
+ $cmd .= " " . implode(" ", $srvips);
mwexec($cmd);
return 0;
OpenPOWER on IntegriCloud