diff options
author | Renato Botelho <renato@netgate.com> | 2016-02-24 09:53:21 -0300 |
---|---|---|
committer | Renato Botelho <renato@netgate.com> | 2016-02-24 11:01:49 -0300 |
commit | 30c8a2902a70e2dba7fcd6292f0c523fbb9b71d1 (patch) | |
tree | 5b0d5eecb42a66a28c11dd311bcef2996bfac311 | |
parent | 0e6a3434096a62598775b6eaa7c8cfa70e5ffa7e (diff) | |
download | pfsense-30c8a2902a70e2dba7fcd6292f0c523fbb9b71d1.zip pfsense-30c8a2902a70e2dba7fcd6292f0c523fbb9b71d1.tar.gz |
Use high level functions
-rw-r--r-- | src/etc/inc/openvpn.inc | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/etc/inc/openvpn.inc b/src/etc/inc/openvpn.inc index 9456192..fc61afc 100644 --- a/src/etc/inc/openvpn.inc +++ b/src/etc/inc/openvpn.inc @@ -792,7 +792,7 @@ function openvpn_reconfigure($mode, $settings) { } case 'p2p_shared_key': if (!empty($ip) && !empty($mask)) { - list($ip1, $ip2) = openvpn_get_interface_ip($ip, $mask); + list($ip1, $ip2) = openvpn_get_interface_ip($ip, $cidr); if ($settings['dev_mode'] == 'tun') { $conf .= "ifconfig {$ip1} {$ip2}\n"; } else { @@ -939,9 +939,9 @@ function openvpn_reconfigure($mode, $settings) { } if (!empty($settings['tunnel_network'])) { - list($ip, $mask) = explode('/', $settings['tunnel_network']); - $mask = gen_subnet_mask($mask); - list($ip1, $ip2) = openvpn_get_interface_ip($ip, $mask); + list($ip, $cidr) = explode('/', $settings['tunnel_network']); + $mask = gen_subnet_mask($cidr); + list($ip1, $ip2) = openvpn_get_interface_ip($tunnel_ip, $cidr); if ($settings['dev_mode'] == 'tun') { $conf .= "ifconfig {$ip2} {$ip1}\n"; } else { @@ -1716,10 +1716,10 @@ function openvpn_create_dirs() { } } -function openvpn_get_interface_ip($ip, $mask) { - $baselong = ip2long32($ip) & ip2long($mask); - $ip1 = long2ip32($baselong + 1); - $ip2 = long2ip32($baselong + 2); +function openvpn_get_interface_ip($ip, $cidr) { + $subnet = gen_subnetv4($ip, $cidr); + $ip1 = ip_after($subnet); + $ip2 = ip_after($ip1); return array($ip1, $ip2); } @@ -1754,7 +1754,7 @@ function openvpn_clear_route($mode, $settings) { } if ($clear_route && !empty($ip) && !empty($mask)) { - list($ip1, $ip2) = openvpn_get_interface_ip($ip, $mask); + list($ip1, $ip2) = openvpn_get_interface_ip($ip, $cidr); $ip_to_clear = ($mode == "server") ? $ip1 : $ip2; /* XXX: Family for route? */ mwexec("/sbin/route -q delete {$ip_to_clear}"); |