Project

General

Profile

« Previous | Next » 

Revision c5a33683

Added by Luiz Souza almost 8 years ago

Accept 'IP/mask' notation in 'Set interface IP address' from initial menu, there is no need to force use to enter the netmask in a different input.

View differences:

src/etc/rc.initial.setlanip
269 269
				echo "\n" . sprintf(gettext('Enter the new %1$s %2$s address.  Press <ENTER> for none:'),
270 270
							$upperifname, $label_IPvX) . "\n> ";
271 271
				$intip = chop(fgets($fp));
272
				$intbits_ok = false;
273
				if (strstr($intip, "/")) {
274
					list($intip, $intbits) = explode("/", $intip);
275
					$intbits_ok = (is_numeric($intbits) && (($intbits >= 1) && ($intbits <= $maxbits))) ? true : false;
276
				}
272 277
				$is_ipaddr = ($version === 6) ? is_ipaddrv6($intip) : is_ipaddrv4($intip);
273 278
				if ($is_ipaddr && is_ipaddr_configured($intip, $interface, true)) {
274 279
					$ip_conflict = true;
......
277 282
					$ip_conflict = false;
278 283
				}
279 284
			} while (($ip_conflict === true) || !($is_ipaddr || $intip == ''));
280
			if ($intip != '') {
281
				echo "\n" . sprintf(gettext("Subnet masks are entered as bit counts (as in CIDR notation) in %s."),
285
			if ($is_ipaddr && $intip != '') {
286
				if ($intbits_ok == false) {
287
					echo "\n" . sprintf(gettext("Subnet masks are entered as bit counts (as in CIDR notation) in %s."),
282 288
							$g['product_name']) . "\n";
283
				if ($version === 6) {
284
					echo "e.g. ffff:ffff:ffff:ffff:ffff:ffff:ffff:ff00 = 120\n";
285
					echo "     ffff:ffff:ffff:ffff:ffff:ffff:ffff:0    = 112\n";
286
					echo "     ffff:ffff:ffff:ffff:ffff:ffff:0:0       =  96\n";
287
					echo "     ffff:ffff:ffff:ffff:ffff:0:0:0          =  80\n";
288
					echo "     ffff:ffff:ffff:ffff:0:0:0:0             =  64\n";
289
				} else {
290
					echo "e.g. 255.255.255.0 = 24\n";
291
					echo "     255.255.0.0   = 16\n";
292
					echo "     255.0.0.0     = 8\n";
289
					if ($version === 6) {
290
						echo "e.g. ffff:ffff:ffff:ffff:ffff:ffff:ffff:ff00 = 120\n";
291
						echo "     ffff:ffff:ffff:ffff:ffff:ffff:ffff:0    = 112\n";
292
						echo "     ffff:ffff:ffff:ffff:ffff:ffff:0:0       =  96\n";
293
						echo "     ffff:ffff:ffff:ffff:ffff:0:0:0          =  80\n";
294
						echo "     ffff:ffff:ffff:ffff:0:0:0:0             =  64\n";
295
					} else {
296
						echo "e.g. 255.255.255.0 = 24\n";
297
						echo "     255.255.0.0   = 16\n";
298
						echo "     255.0.0.0     = 8\n";
299
					}
293 300
				}
294
				do {
301
				while ($intbits_ok == false) {
295 302
					$upperifname = strtoupper($interface);
296 303
					echo "\n" . sprintf(gettext('Enter the new %1$s %2$s subnet bit count (1 to %3$s):'),
297 304
								$upperifname, $label_IPvX, $maxbits) . "\n> ";
......
310 317
							$intbits_ok = false;
311 318
						}
312 319
					}
313
				} while (!$intbits_ok);
320
				}
314 321

  
315 322
				if ($version === 6) {
316 323
					$subnet = gen_subnetv6($intip, $intbits);

Also available in: Unified diff