summaryrefslogtreecommitdiffstats
path: root/usr
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2005-07-06 03:42:33 +0000
committerScott Ullrich <sullrich@pfsense.org>2005-07-06 03:42:33 +0000
commit6846116e619544c7098bb1fd7811152e0572a782 (patch)
treebd4c8ae78ce8299b70a6f643f58184cef91f53ac /usr
parentbef1268c3fa1a4255dab9bd285ab3bdcd1429330 (diff)
downloadpfsense-6846116e619544c7098bb1fd7811152e0572a782.zip
pfsense-6846116e619544c7098bb1fd7811152e0572a782.tar.gz
* Import latest code from m0n0wall
* Split functions into gen_bits_opt and gen_bits_lan
Diffstat (limited to 'usr')
-rwxr-xr-xusr/local/www/interfaces_lan.php2
-rwxr-xr-xusr/local/www/interfaces_opt.php2
-rwxr-xr-xusr/local/www/ip_helper.js24
3 files changed, 23 insertions, 5 deletions
diff --git a/usr/local/www/interfaces_lan.php b/usr/local/www/interfaces_lan.php
index ae17f30..73de5d3 100755
--- a/usr/local/www/interfaces_lan.php
+++ b/usr/local/www/interfaces_lan.php
@@ -123,7 +123,7 @@ include("head.inc");
<script language="JavaScript">
<!--
function ipaddr_change() {
- document.iform.subnet.value = gen_bits(document.iform.ipaddr.value);
+ document.iform.subnet.value = gen_bits_lan(document.iform.ipaddr.value);
}
// -->
</script>
diff --git a/usr/local/www/interfaces_opt.php b/usr/local/www/interfaces_opt.php
index 97926eb..a6ab5c4 100755
--- a/usr/local/www/interfaces_opt.php
+++ b/usr/local/www/interfaces_opt.php
@@ -179,7 +179,7 @@ function enable_change(enable_over) {
document.iform.subnet.disabled = endis;
}
function ipaddr_change() {
- document.iform.subnet.selectedIndex = gen_bits(document.iform.ipaddr.value);
+ document.iform.subnet.selectedIndex = gen_bits_opt(document.iform.ipaddr.value);
}
//-->
</script>
diff --git a/usr/local/www/ip_helper.js b/usr/local/www/ip_helper.js
index 29e892f..8473cb2 100755
--- a/usr/local/www/ip_helper.js
+++ b/usr/local/www/ip_helper.js
@@ -1,4 +1,23 @@
-function gen_bits(ipaddr) {
+function gen_bits_lan(ipaddr) {
+ if (ipaddr.search(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) != -1) {
+ var adr = ipaddr.split(/\./);
+ if (adr[0] > 255 || adr[1] > 255 || adr[2] > 255 || adr[3] > 255)
+ return "";
+ if (adr[0] == 0 && adr[1] == 0 && adr[2] == 0 && adr[3] == 0)
+ return "";
+
+ if (adr[0] <= 127)
+ return "8";
+ else if (adr[0] <= 191)
+ return "16";
+ else
+ return "24";
+ }
+ else
+ return "";
+}
+
+function gen_bits_opt(ipaddr) {
if (ipaddr.search(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) != -1) {
var adr = ipaddr.split(/\./);
if (adr[0] > 255 || adr[1] > 255 || adr[2] > 255 || adr[3] > 255)
@@ -15,5 +34,4 @@ function gen_bits(ipaddr) {
}
else
return 0;
-}
-
+} \ No newline at end of file
OpenPOWER on IntegriCloud