summaryrefslogtreecommitdiffstats
path: root/etc/rc.initial.setlanip
diff options
context:
space:
mode:
authorRenato Botelho <garga@FreeBSD.org>2013-12-06 08:54:23 -0200
committerRenato Botelho <garga@FreeBSD.org>2013-12-06 09:39:50 -0200
commit97049b79c9ddaa13b0d0fff814e4ecf2f25be3c3 (patch)
tree0eb06717140a3c2236dce43018cd9ab8243d36f4 /etc/rc.initial.setlanip
parenta6d96f9b80714638f029c291a454c4f51acc7553 (diff)
downloadpfsense-97049b79c9ddaa13b0d0fff814e4ecf2f25be3c3.zip
pfsense-97049b79c9ddaa13b0d0fff814e4ecf2f25be3c3.tar.gz
When user attempt to set network or broadcast address, ask again for the IP address. Issue #3196
Diffstat (limited to 'etc/rc.initial.setlanip')
-rwxr-xr-xetc/rc.initial.setlanip133
1 files changed, 69 insertions, 64 deletions
diff --git a/etc/rc.initial.setlanip b/etc/rc.initial.setlanip
index 8273073..058e628 100755
--- a/etc/rc.initial.setlanip
+++ b/etc/rc.initial.setlanip
@@ -253,78 +253,83 @@ function console_configure_ip_address($version) {
}
if($isintdhcp == false or $interface <> "wan") {
- do {
- echo "\n" . sprintf(gettext("Enter the new %s %s address. Press <ENTER> for none:"),
- $upperifname, $label_IPvX) . "\n> ";
- $intip = chop(fgets($fp));
- $is_ipaddr = ($version === 6) ? is_ipaddrv6($intip) : is_ipaddrv4($intip);
- if ($is_ipaddr && is_ipaddr_configured($intip, $interface, true)) {
- $ip_conflict = true;
- echo gettext("This IP address conflicts with another interface or a VIP") . "\n";
- } else
- $ip_conflict = false;
- } while (($ip_conflict === true) || !($is_ipaddr || $intip == ''));
- if ($intip != '') {
- echo "\n" . sprintf(gettext("Subnet masks are entered as bit counts (as in CIDR notation) in %s."),
- $g['product_name']) . "\n";
- if ($version === 6) {
- echo "e.g. ffff:ffff:ffff:ffff:ffff:ffff:ffff:ff00 = 120\n";
- echo " ffff:ffff:ffff:ffff:ffff:ffff:ffff:0 = 112\n";
- echo " ffff:ffff:ffff:ffff:ffff:ffff:0:0 = 96\n";
- echo " ffff:ffff:ffff:ffff:ffff:0:0:0 = 80\n";
- echo " ffff:ffff:ffff:ffff:0:0:0:0 = 64\n";
- } else {
- echo "e.g. 255.255.255.0 = 24\n";
- echo " 255.255.0.0 = 16\n";
- echo " 255.0.0.0 = 8\n";
- }
+ while(true) {
do {
- $upperifname = strtoupper($interface);
- echo "\n" . sprintf(gettext("Enter the new %s %s subnet bit count:"),
- $upperifname, $label_IPvX) . "\n> ";
- $intbits = chop(fgets($fp));
- $intbits_ok = is_numeric($intbits) && (($intbits >= 1) || ($intbits <= $maxbits));
- $restart_dhcpd = true;
-
- if ($version === 4 && $intbits < $maxbits) {
- if ($intip == gen_subnet($intip, $intbits)) {
- echo gettext("You cannot set network address to an interface");
- $intbits_ok = false;
- } else if ($intip == gen_subnet_max($intip, $intbits)) {
- echo gettext("You cannot set broadcast address to an interface");
- $intbits_ok = false;
+ echo "\n" . sprintf(gettext("Enter the new %s %s address. Press <ENTER> for none:"),
+ $upperifname, $label_IPvX) . "\n> ";
+ $intip = chop(fgets($fp));
+ $is_ipaddr = ($version === 6) ? is_ipaddrv6($intip) : is_ipaddrv4($intip);
+ if ($is_ipaddr && is_ipaddr_configured($intip, $interface, true)) {
+ $ip_conflict = true;
+ echo gettext("This IP address conflicts with another interface or a VIP") . "\n";
+ } else
+ $ip_conflict = false;
+ } while (($ip_conflict === true) || !($is_ipaddr || $intip == ''));
+ if ($intip != '') {
+ echo "\n" . sprintf(gettext("Subnet masks are entered as bit counts (as in CIDR notation) in %s."),
+ $g['product_name']) . "\n";
+ if ($version === 6) {
+ echo "e.g. ffff:ffff:ffff:ffff:ffff:ffff:ffff:ff00 = 120\n";
+ echo " ffff:ffff:ffff:ffff:ffff:ffff:ffff:0 = 112\n";
+ echo " ffff:ffff:ffff:ffff:ffff:ffff:0:0 = 96\n";
+ echo " ffff:ffff:ffff:ffff:ffff:0:0:0 = 80\n";
+ echo " ffff:ffff:ffff:ffff:0:0:0:0 = 64\n";
+ } else {
+ echo "e.g. 255.255.255.0 = 24\n";
+ echo " 255.255.0.0 = 16\n";
+ echo " 255.0.0.0 = 8\n";
+ }
+ do {
+ $upperifname = strtoupper($interface);
+ echo "\n" . sprintf(gettext("Enter the new %s %s subnet bit count:"),
+ $upperifname, $label_IPvX) . "\n> ";
+ $intbits = chop(fgets($fp));
+ $intbits_ok = is_numeric($intbits) && (($intbits >= 1) || ($intbits <= $maxbits));
+ $restart_dhcpd = true;
+
+ if ($version === 4 && $intbits < $maxbits) {
+ if ($intip == gen_subnet($intip, $intbits)) {
+ echo gettext("You cannot set network address to an interface");
+ continue 2;
+ $intbits_ok = false;
+ } else if ($intip == gen_subnet_max($intip, $intbits)) {
+ echo gettext("You cannot set broadcast address to an interface");
+ continue 2;
+ $intbits_ok = false;
+ }
}
+ } while (!$intbits_ok);
+
+ if ($version === 6) {
+ $subnet = gen_subnetv6($intip, $intbits);
+ } else {
+ $subnet = gen_subnet($intip, $intbits);
}
- } while (!$intbits_ok);
+ do {
+ echo "\n" . sprintf(gettext("Enter the new %s %s gateway address. Press <ENTER> for none:"),
+ $upperifname, $label_IPvX) . "\n> ";
+ $gwip = chop(fgets($fp));
+ $is_ipaddr = ($version === 6) ? is_ipaddrv6($gwip) : is_ipaddrv4($gwip);
+ $is_in_subnet = $is_ipaddr && ip_in_subnet($gwip, $subnet . "/" . $intbits);
+ if ($gwip != '') {
+ if (!$is_ipaddr) {
+ echo sprintf(gettext("not an %s IP address!"), $label_IPvX) . "\n";
+ } else if (!$is_in_subnet) {
+ echo gettext("not in subnet!") . "\n";
+ }
+ }
+ } while (!($gwip == '' || ($is_ipaddr && $is_in_subnet)));
- if ($version === 6) {
- $subnet = gen_subnetv6($intip, $intbits);
- } else {
- $subnet = gen_subnet($intip, $intbits);
- }
- do {
- echo "\n" . sprintf(gettext("Enter the new %s %s gateway address. Press <ENTER> for none:"),
- $upperifname, $label_IPvX) . "\n> ";
- $gwip = chop(fgets($fp));
- $is_ipaddr = ($version === 6) ? is_ipaddrv6($gwip) : is_ipaddrv4($gwip);
- $is_in_subnet = $is_ipaddr && ip_in_subnet($gwip, $subnet . "/" . $intbits);
if ($gwip != '') {
- if (!$is_ipaddr) {
- echo sprintf(gettext("not an %s IP address!"), $label_IPvX) . "\n";
- } else if (!$is_in_subnet) {
- echo gettext("not in subnet!") . "\n";
- }
+ $inet_type = ($version === 6) ? "inet6" : "inet";
+ $gwname = add_gateway_to_config($interface, $gwip, $inet_type);
}
- } while (!($gwip == '' || ($is_ipaddr && $is_in_subnet)));
-
- if ($gwip != '') {
- $inet_type = ($version === 6) ? "inet6" : "inet";
- $gwname = add_gateway_to_config($interface, $gwip, $inet_type);
}
+ $ifppp = console_get_interface_from_ppp(get_real_interface($interface));
+ if (!empty($ifppp))
+ $ifaceassigned = $ifppp;
+ break;
}
- $ifppp = console_get_interface_from_ppp(get_real_interface($interface));
- if (!empty($ifppp))
- $ifaceassigned = $ifppp;
}
return array($intip, $intbits, $gwname);
OpenPOWER on IntegriCloud