summaryrefslogtreecommitdiffstats
path: root/etc/inc/util.inc
diff options
context:
space:
mode:
authorErmal <eri@pfsense.org>2013-02-07 09:46:21 +0000
committerErmal <eri@pfsense.org>2013-02-07 09:46:44 +0000
commit83a1242265cb514dcdd69498b167d37d293a7895 (patch)
treec34e10195baf5f31a5302c932c28534e3206c2e9 /etc/inc/util.inc
parent88cc00dbf56c7b900a6258a47f7f07329c2c19c8 (diff)
downloadpfsense-83a1242265cb514dcdd69498b167d37d293a7895.zip
pfsense-83a1242265cb514dcdd69498b167d37d293a7895.tar.gz
Correct name of function call and use directly its return value as its boolean as needed. Also correct the function to be more readble and put a note for v4 checks that might be needed
Diffstat (limited to 'etc/inc/util.inc')
-rw-r--r--etc/inc/util.inc13
1 files changed, 5 insertions, 8 deletions
diff --git a/etc/inc/util.inc b/etc/inc/util.inc
index e137c68..4404815 100644
--- a/etc/inc/util.inc
+++ b/etc/inc/util.inc
@@ -1234,15 +1234,12 @@ function ipcmp($a, $b) {
/* return true if $addr is in $subnet, false if not */
function ip_in_subnet($addr,$subnet) {
if(is_ipaddrv6($addr)) {
- $result = Net_IPv6::IsInNetmask($addr, $subnet);
- if($result)
- return true;
- else
- return false;
+ return (Net_IPv6::isInNetmask($addr, $subnet));
+ } else { /* XXX: Maybe check for IPv4 */
+ list($ip, $mask) = explode('/', $subnet);
+ $mask = (0xffffffff << (32 - $mask)) & 0xffffffff;
+ return ((ip2long($addr) & $mask) == (ip2long($ip) & $mask));
}
- list($ip, $mask) = explode('/', $subnet);
- $mask = (0xffffffff << (32 - $mask)) & 0xffffffff;
- return ((ip2long($addr) & $mask) == (ip2long($ip) & $mask));
}
/* verify (and remove) the digital signature on a file - returns 0 if OK */
OpenPOWER on IntegriCloud