summaryrefslogtreecommitdiffstats
path: root/src/etc
diff options
context:
space:
mode:
authorPhil Davis <phil.davis@inf.org>2016-12-22 17:42:14 +0545
committerPhil Davis <phil.davis@inf.org>2016-12-22 17:42:14 +0545
commit0f2cf2a1c47192e8394cbcec6ee291b7e753ac4b (patch)
treedcb4e221b353b2eecbb3d760f1684342857ebf40 /src/etc
parent1c937bdc57b4a0d476e3ecc80b546b2af02f0559 (diff)
downloadpfsense-0f2cf2a1c47192e8394cbcec6ee291b7e753ac4b.zip
pfsense-0f2cf2a1c47192e8394cbcec6ee291b7e753ac4b.tar.gz
Fix #7031 Allow interfaces that use DHCP for OpenVPN
even though the interface (or gateway group) has not yet actually received an IP address. This is useful when setting up a new system that is currently offline.
Diffstat (limited to 'src/etc')
-rw-r--r--src/etc/inc/interfaces.inc46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/etc/inc/interfaces.inc b/src/etc/inc/interfaces.inc
index 60248eb..795be7b 100644
--- a/src/etc/inc/interfaces.inc
+++ b/src/etc/inc/interfaces.inc
@@ -5972,6 +5972,52 @@ function get_failover_interface($interface, $family = "all") {
return get_real_interface($interface, $family);
}
+/****f* interfaces/interface_has_dhcp
+ * NAME
+ * interface_has_dhcp - determine if the interface or gateway group uses DHCP
+ * INPUTS
+ * interface or gateway group name
+ * family - 4 (check for IPv4 DHCP) or 6 (check for IPv6 DHCP)
+ * RESULT
+ * true - if the interface uses DHCP/DHCP6, or the name is a gateway group which has any member that uses DHCP/DHCP6
+ * false - otherwise (DHCP/DHCP6 not in use, or the name is not an interface or gateway group)
+ ******/
+function interface_has_dhcp($interface, $family = 4) {
+ global $config;
+
+ if ($config['interfaces'][$interface]) {
+ if (($family == 4) && ($config['interfaces'][$interface]['ipaddr'] == "dhcp")) {
+ return true;
+ }
+ if (($family == 6) && ($config['interfaces'][$interface]['ipaddrv6'] == "dhcp6")) {
+ return true;
+ }
+ } else {
+ if (is_array($config['gateways']['gateway_group'])) {
+ if ($family == 6) {
+ $dhcp_string = "_DHCP6";
+ } else {
+ $dhcp_string = "_DHCP";
+ }
+
+ foreach ($config['gateways']['gateway_group'] as $group) {
+ if ($group['name'] == $interface) {
+ if (is_array($group['item'])) {
+ foreach ($group['item'] as $item) {
+ $item_data = explode("|", $item);
+ if (substr($item_data[0], -strlen($dhcp_string)) == $dhcp_string) {
+ return true;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return false;
+}
+
function remove_ifindex($ifname) {
return preg_replace("/[0-9]+$/", "", $ifname);
}
OpenPOWER on IntegriCloud