From ed7edf071c62f3250357d53c1d59ce701127a5dc Mon Sep 17 00:00:00 2001 From: Ermal Date: Wed, 14 Aug 2013 23:04:38 +0000 Subject: Use pfSense module functions for finding interface v6 addresses. The addresses will be not in friendly format as returned by getnameinfo --- etc/inc/interfaces.inc | 37 +++++++++---------------------------- etc/inc/util.inc | 2 +- 2 files changed, 10 insertions(+), 29 deletions(-) (limited to 'etc') diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index 7dcc1aa..a9279a6 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -4360,26 +4360,10 @@ function find_interface_ipv6($interface, $flush = false) { /* Setup IP cache */ if (!isset($interface_ipv6_arr_cache[$interface]) or $flush) { - // FIXME: Add IPv6 support to the pfSense module - $ifinfo = array(); + $ifinfo = pfSense_get_interface_addresses($interface); exec("/sbin/ifconfig {$interface} inet6", $output); - foreach($output as $line) { - if(preg_match("/inet6/", $line)) { - $parts = explode(" ", $line); - if(!is_linklocal($parts[1])) { - $ifinfo['ipaddrv6'] = $parts[1]; - if($parts[2] == "-->") { - $parts[5] = "126"; - $ifinfo['subnetbitsv6'] = $parts[5]; - } else { - $ifinfo['subnetbitsv6'] = $parts[3]; - } - break; - } - } - } - $interface_ipv6_arr_cache[$interface] = $ifinfo['ipaddrv6']; - $interface_snv6_arr_cache[$interface] = $ifinfo['subnetbitsv6']; + $interface_ipv6_arr_cache[$interface] = $ifinfo['ipaddr6']; + $interface_snv6_arr_cache[$interface] = $ifinfo['subnetbits6']; } return $interface_ipv6_arr_cache[$interface]; @@ -4399,15 +4383,12 @@ function find_interface_ipv6_ll($interface, $flush = false) { /* Setup IP cache */ if (!isset($interface_llv6_arr_cache[$interface]) or $flush) { - $ifinfo = pfSense_get_interface_addresses($interface); - // FIXME: Add IPv6 support to the pfSense module - exec("/sbin/ifconfig {$interface} inet6", $output); - foreach($output as $line) { - if(preg_match("/inet6/", $line)) { - $parts = explode(" ", $line); - if(is_linklocal($parts[1])) { - $partsaddress = explode("%", $parts[1]); - $ifinfo['linklocal'] = $partsaddress[0]; + $ifinfo = pfSense_getall_interface_addresses($interface); + foreach($ifinfo as $line) { + if (strstr($line, ":")) { + $parts = explode("/", $line); + if(is_linklocal($parts[0])) { + $ifinfo['linklocal'] = $parts[0]; } } } diff --git a/etc/inc/util.inc b/etc/inc/util.inc index 54cf85b..e5ff1dd 100644 --- a/etc/inc/util.inc +++ b/etc/inc/util.inc @@ -496,7 +496,7 @@ function is_ipaddrv4($ipaddr) { /* returns true if $ipaddr is a valid linklocal address */ function is_linklocal($ipaddr) { - return preg_match('/^fe80:/i', $ipaddr); + return (substr($ipaddr, 0, 5) == "fe80:"); } /* returns true if $ipaddr is a valid literal IPv6 address */ -- cgit v1.1