diff options
author | bcyrill <cyrill@bannwart.info> | 2013-02-06 10:51:33 +0100 |
---|---|---|
committer | bcyrill <cyrill@bannwart.info> | 2013-02-06 10:51:33 +0100 |
commit | 2027b4c7bcb45a3baf71469a90033268ddfe8943 (patch) | |
tree | 1e57a8d1f2446ae4f71ae719490b168d6b64144e /etc | |
parent | 0715ad5093226a9fd29b1abbbf57a9892efe4100 (diff) | |
download | pfsense-2027b4c7bcb45a3baf71469a90033268ddfe8943.zip pfsense-2027b4c7bcb45a3baf71469a90033268ddfe8943.tar.gz |
find_ip_interface() add IPv6 support
Diffstat (limited to 'etc')
-rw-r--r-- | etc/inc/interfaces.inc | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index e1020e1..e6a9d58 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -3835,20 +3835,27 @@ function guess_interface_from_ip($ipaddress) { * find_ip_interface($ip): return the interface where an ip is defined * (or if $bits is specified, where an IP within the subnet is defined) */ -function find_ip_interface($ip, $bits = null) -{ +function find_ip_interface($ip, $bits = null) { + if (!is_ipaddr($ip)) + return false; + + $isv6ip = is_ipaddrv6($ip); + /* if list */ $ifdescrs = get_configured_interface_list(); foreach ($ifdescrs as $ifdescr => $ifname) { + $ifip = ($isv6ip) ? get_interface_ipv6($ifname) : get_interface_ip($ifname); + if ($ifip === null) + continue; if ($bits === null) { - if ($ip == get_interface_ip($ifname)) { + if ($ip == $ifip) { $int = get_real_interface($ifname); return $int; } } else { - if (ip_in_subnet(get_interface_ip($ifname), $ip . "/" . $bits)) { + if (ip_in_subnet($ifip, $ip . "/" . $bits)) { $int = get_real_interface($ifname); return $int; } |