From 5928bd75d7c7cd31ab8fd06a111bc1805204e51a Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Wed, 25 Apr 2007 18:10:03 +0000 Subject: Add is_private_ip function which will return true if an ip address falls within a private subnet range. --- etc/inc/pfsense-utils.inc | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'etc/inc/pfsense-utils.inc') diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc index 0c4f17f..f84beb0 100644 --- a/etc/inc/pfsense-utils.inc +++ b/etc/inc/pfsense-utils.inc @@ -33,6 +33,29 @@ * */ +/****f* pfsense-utils/is_private_ip + * NAME + * is_private_ip + * INPUTS + * none + * RESULT + * returns true if an ip address is in a private range + ******/ +function is_private_ip($iptocheck) { + $isprivate = false; + $ip_private_list=array( + "10.0.0.0/8", + "172.16.0.0/12", + "192.168.0.0/16", + "99.0.0.0/8" + ); + foreach($ip_private_list as $private) { + if(ip_in_subnet($iptocheck,$private)==true) + $isprivate = true; + } + return $isprivate; +} + /****f* pfsense-utils/get_tmp_file * NAME * get_tmp_file -- cgit v1.1