Project

General

Profile

« Previous | Next » 

Revision 4476d447

Added by Ermal Luçi almost 17 years ago

Merge lan configuration to the interfaces_wan.php page wich does the configuration of all
other assigned interfaces.

View differences:

etc/inc/interfaces.inc
412 412
        return $gifif;
413 413
}
414 414

  
415
function interfaces_lan_configure() {
416
	global $config, $g;
417

  
418
	$lancfg = $config['interfaces']['lan'];
419

  
420
	/* if user has removed ip address, clear it*/
421
	if($lancfg['ipaddr'] == "")
422
		mwexec("/sbin/ifconfig {$lancfg['if']} delete");
423

  
424
	/* wireless configuration? */
425
	if (is_array($lancfg['wireless']))
426
		interfaces_wireless_configure($lancfg['if'], $lancfg['wireless']);
427

  
428
	/* MAC spoofing? */
429
	if ($lancfg['spoofmac']) {
430
		mwexec("/sbin/ifconfig " . escapeshellarg($lancfg['if']) .
431
			" link " . escapeshellarg($lancfg['spoofmac']));
432
	} else {
433
		$mac = get_interface_mac_address($lancfg['if']);
434
		if($mac == "ff:ff:ff:ff:ff:ff") {
435
			/*   this is not a valid mac address.  generate a
436
			 *   temporary mac address so the machine can get online.
437
			 */
438
			echo "Generating new MAC address.";
439
			$random_mac = generate_random_mac_address();
440
			mwexec("/sbin/ifconfig " . escapeshellarg($lancfg['if']) .
441
				" link " . escapeshellarg($random_mac));
442
			$lancfg['spoofmac'] = $random_mac;
443
			write_config();
444
			file_notice("MAC Address altered", "The INVALID MAC address (ff:ff:ff:ff:ff:ff) on interface {$lancfg['if']} has been automatically replaced with {$random_mac}", "Interfaces");
445
		}
446
	}
447

  
448
	/* media */
449
	if ($lancfg['media'] || $lancfg['mediaopt']) {
450
		$cmd = "/sbin/ifconfig " . escapeshellarg($lancfg['if']);
451
		if ($lancfg['media'])
452
			$cmd .= " media " . escapeshellarg($lancfg['media']);
453
		if ($lancfg['mediaopt'])
454
			$cmd .= " mediaopt " . escapeshellarg($lancfg['mediaopt']);
455
		mwexec($cmd);
456
	}
457

  
458
	mwexec("/sbin/ifconfig " . escapeshellarg($lancfg['if']) . " " .
459
		escapeshellarg($lancfg['ipaddr'] . "/" . $lancfg['subnet']));
460

  
461
	if (!$g['booting']) {
462
		/* make new hosts file */
463
		system_hosts_generate();
464

  
465
		/* reconfigure static routes (kernel may have deleted them) */
466
		system_routing_configure();
467

  
468
		/* set the reload filter dity flag */
469
		touch("{$g['tmp_path']}/filter_dirty");
470

  
471
		/* reload IPsec tunnels */
472
		vpn_ipsec_configure();
473

  
474
		/* reload dhcpd (gateway may have changed) */
475
		services_dhcpd_configure();
476

  
477
		/* reload dnsmasq */
478
		services_dnsmasq_configure();
479

  
480
		/* reload captive portal */
481
		captiveportal_configure();
482

  
483
	}
484

  
485
	return 0;
486
}
487

  
488 415
function interfaces_configure() {
489 416
	global $g;
490 417

  
......
496 423
		if($debug)
497 424
 	               log_error("Configuring {$ifname}");
498 425

  
499
		if ($if == "lan")
500
			interfaces_lan_configure();
501
		else
502
			interfaces_wan_configure($if);
426
		interfaces_wan_configure($if);
427

  
503 428
		if ($g['booting']) 
504 429
                	echo "done.\n";
505 430
	}
......
1189 1114

  
1190 1115
	/* XXX: Shouldn't the caller do this?! */
1191 1116
	if (!$g['booting']) {
1117
		/* XXX */
1118
		if ($interface = "lan")
1119
			/* make new hosts file */
1120
                	system_hosts_generate();
1121

  
1192 1122
		/* reconfigure static routes (kernel may have deleted them) */
1193 1123
		system_routing_configure();
1194 1124

  
......
1198 1128
		/* reload ipsec tunnels */
1199 1129
		vpn_ipsec_configure();
1200 1130

  
1201
		/* restart ez-ipupdate */
1131
		/* update dyndns */
1202 1132
		services_dyndns_configure();
1203 1133

  
1204 1134
		/* force DNS update */

Also available in: Unified diff