Project

General

Profile

« Previous | Next » 

Revision f193cf92

Added by Simon Cornelius P. Umacob over 16 years ago

Merge IPv6 changes

View differences:

usr/local/www/interfaces.php
40 40
##|*MATCH=interfaces.php*
41 41
##|-PRIV
42 42

  
43
require("guiconfig.inc");
43
require_once("guiconfig.inc");
44
require_once("IPv6.inc");
44 45

  
45 46
if ($_REQUEST['if'])
46 47
	$if = $_REQUEST['if'];
......
154 155
else
155 156
	$pconfig['enable'] = isset($wancfg['enable']);
156 157

  
157
if (is_array($config['aliases']['alias']))
158
foreach($config['aliases']['alias'] as $alias)
159
	if($alias['name'] == $wancfg['descr'])
160
		$input_errors[] = gettext("Sorry, an alias with the name {$wancfg['descr']} already exists.");
158
if (is_array($config['aliases']['alias'])) {
159
	foreach($config['aliases']['alias'] as $alias) {
160
		if($alias['name'] == $wancfg['descr']) {
161
			$input_errors[] = gettext("Sorry, an alias with the name {$wancfg['descr']} already exists.");
162
		}
163
	}
164
}
165

  
161 166
if ($wancfg['ipaddr'] == "dhcp") {
162 167
	$pconfig['type'] = "dhcp";
163 168
} else if ($wancfg['ipaddr'] == "carpdev-dhcp") {
......
167 172
	$pconfig['type'] = "pppoe";
168 173
} else if ($wancfg['ipaddr'] == "pptp") {
169 174
	$pconfig['type'] = "pptp";
170
} else if ($wancfg['ipaddr'] != "") {
171
	$pconfig['type'] = "static";
172
	$pconfig['ipaddr'] = $wancfg['ipaddr'];
173
	$pconfig['subnet'] = $wancfg['subnet'];
174
	$pconfig['gateway'] = $wancfg['gateway'];
175
	$pconfig['pointtopoint'] = $wancfg['pointtopoint'];
176
} else
175
} else if ($wancfg['ipaddr'] == "" && $wancfg['ipaddr_ipv6'] == "") {
177 176
	$pconfig['type'] = "none";
177
} else {
178
	if ($wancfg['ipaddr'] != "") {
179
		$pconfig['type'] = "static";
180
		$pconfig['ipaddr'] = $wancfg['ipaddr'];
181
		$pconfig['subnet'] = $wancfg['subnet'];
182
		$pconfig['gateway'] = $wancfg['gateway'];
183
		$pconfig['pointtopoint'] = $wancfg['pointtopoint'];
184
	}
185

  
186
	if ($wancfg['ipaddr_ipv6'] != "") {
187
		$pconfig['type'] = "static";
188
		$pconfig['ipaddr_ipv6'] = $wancfg['ipaddr_ipv6'];
189
		$pconfig['subnet_ipv6'] = $wancfg['subnet_ipv6'];
190
		$pconfig['gateway_ipv6'] = $wancfg['gateway_ipv6'];
191
		$pconfig['pointtopoint_ipv6'] = $wancfg['pointtopoint_ipv6'];
192
	}
193
}
178 194

  
179 195
$pconfig['blockpriv'] = isset($wancfg['blockpriv']);
180 196
$pconfig['blockbogons'] = isset($wancfg['blockbogons']);
......
296 312
	}
297 313
	/* input validation */
298 314
	if ($_POST['type'] == "static") {
299
		$reqdfields = explode(" ", "ipaddr subnet gateway");
300
		$reqdfieldsn = explode(",", "IP address,Subnet bit count,Gateway");
315
		if ($_POST['ipaddr'] != "") {
316
			$reqdfields = explode(" ", "ipaddr subnet gateway");
317
			$reqdfieldsn = explode(",", "IPv4 Address,IPv4 Subnet Bit Count,IPv4 Gateway");
318
		} else if ($_POST['ipaddr_ipv6'] != "") {
319
			$reqdfields = explode(" ", "ipaddr_ipv6 subnet_ipv6 gateway_ipv6");
320
			$reqdfieldsn = explode(",", "IPv6 Address,IPv6 Subnet Bit Count,IPv6 Gateway");
321
		} else {
322
			$input_errors[] = "An IPv4 or IPv6 Address is required.";
323
		}
324

  
301 325
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
302 326
	} else if ($_POST['type'] == "PPPoE") {
303 327
		if ($_POST['pppoe_dialondemand']) {
......
321 345
	/* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */
322 346
	$_POST['spoofmac'] = strtolower(str_replace("-", ":", $_POST['spoofmac']));
323 347
	if (($_POST['ipaddr'] && !is_ipaddr($_POST['ipaddr']))) 
324
		$input_errors[] = "A valid IP address must be specified.";
348
		$input_errors[] = "A valid IPv4 address must be specified.";
325 349
	if (($_POST['subnet'] && !is_numeric($_POST['subnet']))) 
326
		$input_errors[] = "A valid subnet bit count must be specified.";
350
		$input_errors[] = "A valid IPv4 subnet bit count must be specified.";
351
	if ($_POST['ipaddr_ipv6'] && !Net_IPv6::checkIPv6($_POST['ipaddr_ipv6']))
352
		$input_errors[] = "A valid IPv6 address must be specified.";
353
	if ($_POST['subnet_ipv6'] && !is_numeric($_POST['subnet_ipv6']))
354
		$input_errors[] = "A valid IPv6 prefix length must be specified.";
327 355
	if (($_POST['alias-address'] && !is_ipaddr($_POST['alias-address']))) 
328 356
		$input_errors[] = "A valid alias IP address must be specified.";
329 357
	if (($_POST['alias-subnet'] && !is_numeric($_POST['alias-subnet']))) 
......
337 365
			$input_errors[] = "A valid gateway must be specified.";
338 366
	}
339 367
	if (($_POST['pointtopoint'] && !is_ipaddr($_POST['pointtopoint']))) 
340
		$input_errors[] = "A valid point-to-point IP address must be specified.";
368
		$input_errors[] = "A valid IPv4 point-to-point address must be specified.";
369
	if (($_POST['pointtopoint_ipv6'] && !is_ipaddr($_POST['pointtopoint_ipv6'])))
370
		$input_errors[] = "A valid IPv6 point-to-point address must be specified.";
341 371
	if (($_POST['provider'] && !is_domain($_POST['provider']))) 
342 372
		$input_errors[] = "The service name contains invalid characters.";
343 373
	if (($_POST['pppoe_idletimeout'] != "") && !is_numericint($_POST['pppoe_idletimeout'])) 
......
408 438
		unset($wancfg['subnet']);
409 439
		unset($wancfg['gateway']);
410 440
		unset($wancfg['pointtopoint']);
441
		unset($wancfg['ipaddr_ipv6']);
442
		unset($wancfg['subnet_ipv6']);
443
		unset($wancfg['gateway_ipv6']);
444
		unset($wancfg['pointtopoint_ipv6']);
411 445
		unset($wancfg['dhcphostname']);
412 446
		unset($wancfg['pppoe_username']);
413 447
		unset($wancfg['pppoe_password']);
......
433 467
		if ($_POST['type'] == "static") {
434 468
			$wancfg['ipaddr'] = $_POST['ipaddr'];
435 469
			$wancfg['subnet'] = $_POST['subnet'];
436
			if ($_POST['gateway'] != "none")
470
			$wancfg['ipaddr_ipv6'] = $_POST['ipaddr_ipv6'];
471
			$wancfg['subnet_ipv6'] = $_POST['subnet_ipv6'];
472

  
473
			if ($_POST['gateway'] != "none") {
437 474
				$wancfg['gateway'] = $_POST['gateway'];
438
			if (isset($wancfg['ispointtopoint']))
475
				$wancfg['gateway_ipv6'] = $_POST['gateway_ipv6'];
476
			}
477
			if (isset($wancfg['ispointtopoint'])) {
439 478
				$wancfg['pointtopoint'] = $_POST['pointtopoint'];
479
				$wancfg['pointtopoint_ipv6'] = $_POST['pointtopoint_ipv6'];
480
			}
440 481
		} else if ($_POST['type'] == "dhcp") {
441 482
			$wancfg['ipaddr'] = "dhcp";
442 483
			$wancfg['dhcphostname'] = $_POST['dhcphostname'];
......
712 753
		else
713 754
			$('allcfg').hide();
714 755
	}
715
	
756

  
716 757
	function show_periodic_reset(obj) {
717 758
		if (obj.checked)
718 759
			$('presetwrap').show();
......
822 863
				<td colspan="2" style="padding:0px;">
823 864
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
824 865
						<tr>
825
							<td colspan="2" valign="top" class="listtopic">Static IP configuration</td>
866
							<td colspan="2" valign="top" class="listtopic">Static IPv4 configuration</td>
826 867
						</tr>
827 868
						<tr>
828 869
							<td width="22%" valign="top" class="vncellreq">IP address</td>
......
844 885
						</tr>
845 886
						<?php if (isset($wancfg['ispointtopoint'])): ?>
846 887
							<tr>
847
								<td width="22%" valign="top" class="vncellreq">Point-to-point IP address </td>
888
								<td width="22%" valign="top" class="vncellreq">Point-to-point IPv4 address </td>
848 889
								<td width"78%" class="vtable">
849 890
									<input name="pointtopoint" type="text" class="formfld unknown" id="pointtopoint" size="20" value="<?=htmlspecialchars($pconfig['pointtopoint']);?>">
850 891
								</td>
......
858 899
										<?php
859 900
										if(count($a_gateways) > 0) {
860 901
											foreach ($a_gateways as $gateway) {
861
												if($gateway['interface'] == $if) {
902
												if($gateway['interface'] == $if && $gateway['type'] == 'IPv4') {
862 903
										?>
863 904
												<option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gateway']) echo "selected"; ?>>
864
													<?=htmlspecialchars($gateway['name']);?>
905
												<?=htmlspecialchars($gateway['name']);?>
865 906
												</option>
866 907
										<?php
867 908
												}
......
917 958
										</table>
918 959
										</td></tr></table>
919 960
									<p/>
920
								</div>
921
							</td>
961
								</div> </td>
922 962
						</tr>
923 963
					</table>
964

  
965
			<!-- IPv6 begin -->
966
				<tr>
967
					<td colspan="2" valign="top" class="listtopic">Static IPv6 configuration</td>
968
				</tr>
969
				<tr>
970
					<td width="22%" valign="top" class="vncellreq">IP address</td>
971
					<td width="78%" class="vtable"> <input name="ipaddr_ipv6" type="text" class="formfld unknown" id="ipaddr_ipv6" size="20" value="<?=htmlspecialchars($pconfig['ipaddr_ipv6']);?>">
972
					/
973
					<select name="subnet_ipv6" class="formselect" id="subnet_ipv6">
974
						<?php
975
						for ($i = 64; $i > 0; $i -= 4) {
976
							if ($i == $pconfig['subnet_ipv6']) {
977
							echo "<option value=\"$i\" selected=\"selected\">$i</option>";
978
							} else {
979
							echo "<option value=\"$i\">$i</option>";
980
							}
981
						}
982
						?>
983
					</select>
984
					</td>
985
				</tr>
986
				<?php if (isset($wancfg['ispointtopoint'])): ?>
987
				<tr>
988
					<td width="22%" valign="top" class="vncellreq">Point-to-point IPv6 address </td>
989
					<td width"78%" class="vtable">
990
					<input name="pointtopoint_ipv6" type="text" class="formfld unknown" id="pointtopoint_ipv6" size="20" value="<?=htmlspecialchars($pconfig['pointtopoint_ipv6']);?>">
991
					</td>
992
				</tr><?php endif; ?>
993
				<tr>
994
					<td width="22%" valign="top" class="vncellreq">Gateway</td>
995
					<td width="78%" class="vtable"><select name="gateway_ipv6" class="formselect" id="gateway_ipv6">
996
								<option value="none" selected>None</option>
997
						<?php
998
						if(count($a_gateways) > 0) {
999
							foreach ($a_gateways as $gateway) {
1000
								if($gateway['interface'] == $if && $gateway['type'] == 'IPv6') {
1001
						?>
1002
								<option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gateway_ipv6']) echo "selected"; ?>>
1003
								<?=htmlspecialchars($gateway['name']);?>
1004
								</option>
1005
						<?php
1006
								}
1007
							}
1008
						}
1009
						?>
1010
						</select>
1011
						<br />
1012
						Select a existing Gateway from the list or add one on the <a href="/system_gateways.php">Gateways</a> page<br />
1013
						TODO: use Ajax, similar to IPv4
1014
					</td>
1015
				</tr>
1016
			<!-- IPv6 end -->
1017

  
924 1018
				</td>
925 1019
				</tr>
926 1020
				<tr style="display:none;" name="dhcp" id="dhcp">

Also available in: Unified diff