Project

General

Profile

Download (33.6 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	interfaces.inc
5
	Copyright (C) 2004 Scott Ullrich
6
	All rights reserved.
7

    
8
	originally part of m0n0wall (http://m0n0.ch/wall)
9
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
10
	All rights reserved.
11

    
12
	Redistribution and use in source and binary forms, with or without
13
	modification, are permitted provided that the following conditions are met:
14

    
15
	1. Redistributions of source code must retain the above copyright notice,
16
	   this list of conditions and the following disclaimer.
17

    
18
	2. Redistributions in binary form must reproduce the above copyright
19
	   notice, this list of conditions and the following disclaimer in the
20
	   documentation and/or other materials provided with the distribution.
21

    
22
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
23
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
24
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
26
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31
	POSSIBILITY OF SUCH DAMAGE.
32
*/
33

    
34
/* include all configuration functions */
35
require_once("functions.inc");
36

    
37
if(!is_numeric($bridges_total)) $bridges_total=0;
38

    
39
function interfaces_loopback_configure() {
40
	mwexec("/sbin/ifconfig lo0 127.0.0.1");
41

    
42
	return 0;
43
}
44

    
45
function interfaces_vlan_configure() {
46
	global $config;
47

    
48
	if (is_array($config['vlans']['vlan']) && count($config['vlans']['vlan'])) {
49

    
50
		/* devices with native VLAN support */
51
		$vlan_native_supp = explode(" ", "bge em gx nge ti txp");
52

    
53
		/* devices with long frame support */
54
		$vlan_long_supp = explode(" ", "dc fxp sis ste tl tx xl");
55

    
56
		$i = 0;
57

    
58
		foreach ($config['vlans']['vlan'] as $vlan) {
59

    
60
			$cmd = "/sbin/ifconfig vlan{$i} create vlan " .
61
				escapeshellarg($vlan['tag']) . " vlandev " .
62
				escapeshellarg($vlan['if']);
63

    
64
			/* get driver name */
65
			for ($j = 0; $j < strlen($vlan['if']); $j++) {
66
				if ($vlan['if'][$j] >= '0' && $vlan['if'][$j] <= '9')
67
					break;
68
			}
69
			$drvname = substr($vlan['if'], 0, $j);
70

    
71
			if (in_array($drvname, $vlan_native_supp))
72
				$cmd .= " link0";
73
			else if (in_array($drvname, $vlan_long_supp))
74
				$cmd .= " mtu 1500";
75

    
76
			mwexec($cmd);
77

    
78
			/* make sure the parent interface is up */
79
			mwexec("/sbin/ifconfig " . escapeshellarg($vlan['if']) . " up");
80

    
81
			$i++;
82
		}
83
	}
84

    
85
	return 0;
86
}
87

    
88
function interfaces_lan_configure() {
89
	global $config, $g, $bridges_total;
90

    
91
	$lancfg = $config['interfaces']['lan'];
92

    
93
	/* wireless configuration? */
94
	if (is_array($lancfg['wireless']))
95
		interfaces_wireless_configure($lancfg['if'], $lancfg['wireless']);
96

    
97
	/* MAC spoofing? */
98
	if ($lancfg['spoofmac']) {
99
		mwexec("/sbin/ifconfig " . escapeshellarg($lancfg['if']) .
100
			" link " . escapeshellarg($lancfg['spoofmac']));
101
	} else {
102
		$mac = get_interface_mac_address($lancfg['if']);
103
		if($mac == "ff:ff:ff:ff:ff:ff") {
104
			/*   this is not a valid mac address.  generate a
105
			 *   temporary mac address so the machine can get online.
106
			 */
107
			echo "Generating new MAC address.";
108
			$random_mac = generate_random_mac_address();
109
			mwexec("/sbin/ifconfig " . escapeshellarg($lancfg['if']) .
110
				" link " . escapeshellarg($random_mac));
111
			$lancfg['spoofmac'] = $random_mac;
112
			write_config();
113
			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");
114
		}
115
	}	
116

    
117
	/* bridged? */
118
	
119
	if ($lancfg['bridge']) {
120
		// mwexec("/sbin/ifconfig " . escapeshellarg($lancfg['if']) . " delete up");
121
		/* use open/netBSD style bridge */
122
		mwexec("/sbin/ifconfig bridge{$bridges_total} create");
123
		mwexec("/sbin/ifconfig bridge{$bridges_total} addm {$lancfg['if']} addm {$config['interfaces'][$lancfg['bridge']]['if']} up");
124
		mwexec("/sbin/ifconfig bridge{$bridges_total} stp {$lancfg['if']} add {$config['interfaces'][$lancfg['bridge']]['if']}");
125
		
126
		$fd = fopen("{$g['tmp_path']}/bridge_config_{$lancfg['if']}", "w");
127
		fwrite($fd, "/sbin/ifconfig bridge{$bridges_total} create\n");
128
		fwrite($fd, "/sbin/ifconfig bridge{$bridges_total} addm {$lancfg['if']} addm {$config['interfaces'][$lancfg['bridge']]['if']} up\n");
129
		fwrite($fd, "/sbin/ifconfig bridge{$bridges_total} stp {$lancfg['if']} add {$config['interfaces'][$lancfg['bridge']]['if']}\n");
130
		fclose($fd);
131
		
132
		/* lets keep track of the amount of bridges initialized */
133
		$bridges_total++;
134
	}
135
	
136
	/* media */
137
	if ($lancfg['media'] || $lancfg['mediaopt']) {
138
		$cmd = "/sbin/ifconfig " . escapeshellarg($lancfg['if']);
139
		if ($lancfg['media'])
140
			$cmd .= " media " . escapeshellarg($lancfg['media']);
141
		if ($lancfg['mediaopt'])
142
			$cmd .= " mediaopt " . escapeshellarg($lancfg['mediaopt']);
143
		mwexec($cmd);
144
	}
145

    
146
	mwexec("/sbin/ifconfig " . escapeshellarg($lancfg['if']) . " " .
147
		escapeshellarg($lancfg['ipaddr'] . "/" . $lancfg['subnet']));
148

    
149
	if (!$g['booting']) {
150
		/* make new hosts file */
151
		system_hosts_generate();
152

    
153
		/* reconfigure static routes (kernel may have deleted them) */
154
		system_routing_configure();
155

    
156
		/* set the reload filter dity flag */
157
		touch("{$g['tmp_path']}/filter_dirty");
158

    
159
		/* reload IPsec tunnels */
160
		vpn_ipsec_configure();
161

    
162
		/* reload dhcpd (gateway may have changed) */
163
		services_dhcpd_configure();
164

    
165
		/* reload dnsmasq */
166
		services_dnsmasq_configure();
167

    
168
		/* reload webgui */
169
		system_webgui_start();
170

    
171
		/* reload captive portal */
172
		captiveportal_configure();
173
	}
174

    
175
	return 0;
176
}
177

    
178
function interfaces_optional_configure() {
179
	global $config, $g;
180
	global $bridgeconfig;
181

    
182
	/* Reset bridge configuration.	Interfaces will add to it. */
183
	$bridgeconfig = "";
184

    
185
	for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
186
		interfaces_optional_configure_if($i);
187
	}
188

    
189
	if (!$g['booting']) {
190
		/* reconfigure static routes (kernel may have deleted them) */
191
		system_routing_configure();
192

    
193
		/* reload IPsec tunnels */
194
		vpn_ipsec_configure();
195

    
196
		/* reload dhcpd (interface enabled/disabled/bridged status may have changed) */
197
		services_dhcpd_configure();
198

    
199
		/* restart dnsmasq */
200
		services_dnsmasq_configure();
201

    
202
		/* set the reload filter dity flag */
203
		touch("{$g['tmp_path']}/filter_dirty");				
204
	}
205

    
206
	return 0;
207
}
208

    
209
function interfaces_optional_configure_if($opti) {
210
	global $config, $g;
211
	global $bridgeconfig;
212
	global $bridges_total;
213

    
214
	$optcfg = $config['interfaces']['opt' . $opti];
215

    
216
	if ($g['booting']) {
217
		$optdescr = "";
218
		if ($optcfg['descr'])
219
			$optdescr = " ({$optcfg['descr']})";
220
		print "\tOPT{$opti}{$optdescr}... ";
221
		mute_kernel_msgs();
222
	}
223

    
224
	if (isset($optcfg['enable'])) {
225
		/* wireless configuration? */
226
		if (is_array($optcfg['wireless']))
227
			interfaces_wireless_configure($optcfg['if'], $optcfg['wireless']);
228

    
229
		/* MAC spoofing? */
230
		if ($optcfg['spoofmac']) {
231
			mwexec("/sbin/ifconfig " . escapeshellarg($optcfg['if']) .
232
				" link " . escapeshellarg($optcfg['spoofmac']));
233
		} else {
234
			$mac = get_interface_mac_address($optcfg['if']);
235
			if($mac == "ff:ff:ff:ff:ff:ff") {
236
				/*   this is not a valid mac address.  generate a
237
				 *   temporary mac address so the machine can get online.
238
				 */
239
				echo "Generating new MAC address.";
240
				$random_mac = generate_random_mac_address();
241
				mwexec("/sbin/ifconfig " . escapeshellarg($optcfg['if']) .
242
					" link " . escapeshellarg($random_mac));
243
				$optcfg['spoofmac'] = $random_mac;
244
				write_config();
245
				file_notice("MAC Address altered", "The INVALID MAC address (ff:ff:ff:ff:ff:ff) on interface {$optcfg['if']} has been automatically replaced with {$random_mac}", "Interfaces");
246
			}
247
		}
248

    
249
		/* media */
250
		if ($optcfg['media'] || $optcfg['mediaopt']) {
251
			$cmd = "/sbin/ifconfig " . escapeshellarg($optcfg['if']);
252
			if ($optcfg['media'])
253
				$cmd .= " media " . escapeshellarg($optcfg['media']);
254
			if ($optcfg['mediaopt'])
255
				$cmd .= " mediaopt " . escapeshellarg($optcfg['mediaopt']);
256
			mwexec($cmd);
257
		}
258

    
259
		/* OpenVPN configuration? */
260
 		if (isset($optcfg['ovpn'])) {
261
 			if (strstr($optcfg['if'], "tap"))
262
 				ovpn_link_tap();
263
 		}
264

    
265
		/* bridged? */
266
		if ($optcfg['bridge']) {
267
			mwexec("/sbin/ifconfig " . escapeshellarg($optcfg['if']) . " delete up");
268
                        /* use open/netBSD style bridge */
269
			mwexec("/sbin/ifconfig bridge{$bridges_total} create");
270
                        mwexec("/sbin/ifconfig bridge{$bridges_total} addm {$optcfg['if']} addm {$config['interfaces'][$optcfg['bridge']]['if']} up");
271
			mwexec("/sbin/ifconfig bridge{$bridges_total} stp {$optcfg['if']} add {$config['interfaces'][$optcfg['bridge']]['if']}");
272
			
273
			$fd = fopen("{$g['tmp_path']}/bridge_config_{$optcfg['if']}", "w");
274
			fwrite($fd, "/sbin/ifconfig bridge{$bridges_total} create\n");
275
			fwrite($fd, "/sbin/ifconfig bridge{$bridges_total} addm {$optcfg['if']} addm {$config['interfaces'][$optcfg['bridge']]['if']} up\n");
276
			fwrite($fd, "/sbin/ifconfig bridge{$bridges_total} stp {$optcfg['if']} add {$config['interfaces'][$optcfg['bridge']]['if']}\n");
277
			fclose($fd);
278
			
279
			/* lets keep track of the amount of bridges initialized */
280
			$bridges_total++;
281
		} else {
282
			/* if user has selected DHCP type then act accordingly */
283
			if($optcfg['ipaddr'] == "dhcp") {
284
				interfaces_opt_dhcp_configure("opt{$opti}");
285
			} else {			
286
				mwexec("/sbin/ifconfig " . escapeshellarg($optcfg['if']) . " " .
287
				escapeshellarg($optcfg['ipaddr'] . "/" . $optcfg['subnet']));
288
			}
289
		}
290
	} else {
291
		mwexec("/sbin/ifconfig " . escapeshellarg($optcfg['if']) . " delete down");
292
	}
293

    
294
	return 0;
295
}
296

    
297
function interfaces_carp_configure() {
298
	global $g, $config;
299
	if ($g['booting']) {
300
		echo "Configuring CARP interfaces...";
301
		mute_kernel_msgs();
302
	}
303
	unlink_if_exists("/usr/local/etc/rc.d/carp.sh");
304
	unlink_if_exists("/usr/local/pkg/pf/carp.sh");
305
	unlink_if_exists("/usr/local/pkg/pf/carp_rules.sh");
306
	$carp_instances_counter = 0;
307
	$pfsync_instances_counter = 0;
308
	$total_carp_interfaces_defined = find_number_of_created_carp_interfaces();
309
	if (is_array($config['virtualip']['vip'])) {
310
		if(is_array($config['installedpackages']['carpsettings']['config'])) {
311
			foreach($config['installedpackages']['carpsettings']['config'] as $carp)
312
				if($carp['pfsyncenabled'] != "") {
313
					if($carp['premption'] != "")
314
						mwexec("/sbin/sysctl net.inet.carp.preempt=1");
315
					if($carp['balancing'] != "")
316
						mwexec("/sbin/sysctl net.inet.arpbalance=1");
317
					$carp_sync_int = convert_friendly_interface_to_real_interface_name($carp['pfsyncinterface']);
318
					mwexec("/sbin/ifconfig pfsync0 create");
319
					mwexec("/sbin/ifconfig pfsync0 syncdev " . $carp_sync_int);
320
					mwexec("/sbin/ifconfig pfsync0 syncif " . $carp_sync_int);
321
					mwexec("/sbin/ifconfig pfsync0 up");
322
					if($g['booting']) {
323
						/* install rules to alllow pfsync to sync up during boot
324
						* carp interfaces will remain down until the bootup sequence finishes
325
						*/
326
						exec("echo pass quick proto carp all keep state > /tmp/rules.boot");
327
						exec("echo pass quick proto pfsync all >> /tmp/rules.boot");
328
						exec("echo pass out proto { tcp, udp } from any to any port 53 keep state >> /tmp/rules.boot");
329
						exec("/sbin/pfctl -f /tmp/rules.boot");
330
					}
331
					$pfsync_instances_counter++;
332
				}
333
		}
334
		$viparr = &$config['virtualip']['vip'];
335
		foreach ($viparr as $vip) {
336
			if ($vip['mode'] == "carp") {
337
				/*
338
				*  create the carp interface
339
				*/
340
				mwexec("/sbin/ifconfig carp" . $carp_instances_counter . " create");
341
				mwexec("/sbin/ifconfig carp" . $carp_instances_counter . " down");
342
				$broadcast_address = gen_subnet_max($vip['subnet'], $vip['subnet_bits']);
343
				if($vip['password'] != "") {
344
					$password = " pass " . $vip['password'];
345
				}
346
				/* XXX: billm - carpdev not in our build?
347
				$carpdev = "";
348
				if(isset($vip['interface']) && ($vip['interface'] != "AUTO" && $vip['interface'] != "")) {
349
					$ci = filter_opt_interface_to_real($vip['interface']);
350
					$carpdev = " carpdev {$ci} ";
351
				}
352
				*/
353
				mwexec("/sbin/ifconfig carp" . $carp_instances_counter . " " . $vip['subnet'] . "/" . $vip['subnet_bits'] . " broadcast " . $broadcast_address . " vhid " . $vip['vhid'] . "{$carpdev} advskew " . $vip['advskew'] . $password);
354
				$carp_instances_counter++;
355
			}
356
		}
357
	} else {
358
		/* Hush little pfsync, don't say a word.
359
		   GeekGod's gonna buy you a mocking bird. */
360
		mwexec("/sbin/ifconfig pfsync0 syncdev lo0 up");
361
	}
362
	if ($g['booting']) {
363
		unmute_kernel_msgs();
364
		echo "done.\n";
365
	}
366
}
367

    
368
function interfaces_wireless_configure($if, $wlcfg) {
369
        global $config, $g;
370
	
371
	/* set values for /path/program */
372
	$hostapd = "/usr/sbin/hostapd";
373
	$wpa_supplicant = "/usr/sbin/wpa_supplicant";
374
	$ifconfig = "/sbin/ifconfig ";
375

    
376
	/* Clear all ifcargs before we begin */
377
	$ifcargs = "";
378

    
379
        /* wireless configuration */
380
        $ifcargs .= escapeshellarg($if) . " ssid " . escapeshellarg($wlcfg['ssid']) . " ";
381

    
382
        if ($wlcfg['stationname'])
383
                $ifcargs .= "stationname " . escapeshellarg($wlcfg['stationname']) . " ";
384
	
385
	if(!$wlcfg['mode']) {
386
		if (isset($wlcfg['wpa']['enable'])) {
387
		
388
	$wpa .= <<<EOD
389

    
390
ctrl_interface={$g['varrun_path']}/hostapd
391
ctrl_interface_group=0
392
ap_scan=1
393
#fast_reauth=1
394
network={
395
ssid={$wlcfg['ssid']}
396
scan_ssid=2
397
priority=5
398
key_mgmt={$wlcfg['wpa']['wpa_key_mgmt']}
399
psk={$wlcfg['wpa']['passphrase']}
400
pairwise={$wlcfg['wpa']['wpa_pairwise']}
401
group={$wlcfg['wpa']['wpa_pairwise']}
402
}
403

    
404
EOD;
405

    
406
		$fd = fopen("{$g['tmp_path']}/wpa_supplicant_{$if}.conf", "w");
407
		fwrite($fd, "{$wpa}");
408
		fclose($fd);
409

    
410
		if(is_process_running("wpa_supplicant")) {
411
			mwexec("$killall -HUP wpa_supplicant");
412
			} else {
413
			mwexec("$wpa_supplicant -i {$if} -c {$g['etc_path']}/wpa_supplicant_{$if}.conf"); 		}
414
		}
415
	}
416

    
417
        if (isset($wlcfg['wep']['enable']) && is_array($wlcfg['wep']['key'])) {
418
                $ifcargs .= "wepmode on ";
419

    
420
                $i = 1;
421
                foreach ($wlcfg['wep']['key'] as $wepkey) {
422
                        $ifcargs .= "wepkey " . escapeshellarg("{$i}:{$wepkey['value']}") . " ";
423
                        if (isset($wepkey['txkey'])) {
424
                                $ifcargs .= "weptxkey {$i} ";
425
                        }
426
                        $i++;
427
                }
428
        } else {
429
                $ifcargs .= "wepmode off ";
430
        }
431

    
432
	if(isset($wlcfg['pureg']['enable'])) {
433
		$ifcargs .= "mode 11g ";
434
	} else {
435
		if (preg_match($g['wireless_regex'], $if)) {
436
			if ($wlcfg['standard'])
437
				$ifcargs .= "mode " . escapeshellarg($wlcfg['standard']) . " ";
438
		}
439
	}
440

    
441
	/*   set wireless channel value.  if we're using 0 then
442
	 *   convert the channel to -
443
	 *   THIS NEEDS TO BE SET AFTER $ifcargs .= "mode " !!! lsf
444
	 */
445
	$channel = escapeshellarg($wlcfg['channel']);
446
	if($channel == "") {
447
		$channel = "";
448
		} else { $ifcargs .= "channel " . escapeshellarg($wlcfg['channel']) . " ";
449
	}
450

    
451
        switch ($wlcfg['mode']) {
452
                case 'hostap':
453
                        if (preg_match($g['wireless_regex'], $if)) 
454
                                $ifcargs .= "-mediaopt adhoc mediaopt hostap ";
455
                        else if (strstr($if, "wi"))
456
                                $ifcargs .= "-mediaopt ibss mediaopt hostap ";
457
				if (isset($wlcfg['wpa']['enable'])) {
458
$wpa .= <<<EOD
459

    
460
interface={$if}
461
driver=bsd
462
logger_syslog=-1
463
logger_syslog_level=0
464
logger_stdout=-1
465
logger_stdout_level=0
466
dump_file={$g['tmp_path']}/hostapd_{$if}.dump
467
ctrl_interface={$g['varrun_path']}/hostapd
468
ctrl_interface_group=wheel
469
#accept_mac_file={$g['tmp_path']}/hostapd_{$if}.accept
470
#deny_mac_file={$g['tmp_path']}/hostapd_{$if}.deny
471
ssid={$wlcfg['ssid']}
472
debug={$wlcfg['wpa']['debug_mode']}
473
#macaddr_acl={$wlcfg['wpa']['macaddr_acl']}
474
auth_algs={$wlcfg['wpa']['auth_algs']}
475
wpa={$wlcfg['wpa']['wpa_mode']}
476
wpa_key_mgmt={$wlcfg['wpa']['wpa_key_mgmt']}
477
wpa_pairwise={$wlcfg['wpa']['wpa_pairwise']}
478
#wpa_group_rekey={$wlcfg['wpa']['wpa_group_rekey']}
479
#wpa_gmk_rekey={$wlcfg['wpa']['wpa_gmk_rekey']}
480
#wpa_strict_rekey={$wlcfg['wpa']['wpa_strict_rekey']}
481
wpa_passphrase={$wlcfg['wpa']['passphrase']}
482
ieee8021x={$wlcfg['wpa']['ieee8021x']}
483

    
484
EOD;
485
					$fd = fopen("{$g['tmp_path']}/hostapd_{$if}.conf", "w");
486
					fwrite($fd, "{$wpa}");
487
					fclose($fd);
488
					if(is_process_running("hostapd")) {
489
						mwexec("$killall -HUP hostapd");
490
					} else {
491
						mwexec("$hostapd -B {$g['tmp_path']}/hostapd_{$if}.conf");
492
					}
493
				}
494
			break;
495

    
496
                case 'ibss':
497
                case 'IBSS':
498
                        if (preg_match($g['wireless_regex'], $if)) 
499
                                $ifcargs .= "-mediaopt hostap mediaopt adhoc ";
500
                        else if (strstr($if, "wi"))
501
                                $ifcargs .= "-mediaopt hostap mediaopt ibss ";
502
                        else if (strstr($if, "an"))
503
                                $ifcargs .= "mediaopt adhoc ";
504
                        break;
505
                case 'bss':
506
                case 'BSS':
507
                        if (preg_match($g['wireless_regex'], $if)) 
508
                                $ifcargs .= "-mediaopt hostap -mediaopt adhoc ";
509
                        else if (strstr($if, "wi"))
510
                                $ifcargs .= "-mediaopt hostap -mediaopt ibss ";
511
                        else if (strstr($if, "an"))
512
                                $ifcargs .= "-mediaopt adhoc ";
513
                        break;
514
        }
515
	
516
	/*   extra options during hostap mode
517
	 */
518
	if($wlcfg['mode'] == "hostap") {
519

    
520
		/* handle hide ssid option */
521
		if(isset($wlcfg['hidessid']['enable']))
522
			$ifcargs .= "hidessid ";
523
		else
524
			$ifcargs .= "-hidessid ";
525

    
526
		/* handle pureg (802.11g) only option */
527
		if(isset($wlcfg['pureg']['enable']))
528
			$ifcargs .= "pureg ";
529
		else
530
			$ifcargs .= "-pureg ";
531

    
532
		/* handle turbo option */
533
		if(isset($wlcfg['turbo']['enable']))
534
			$ifcargs .= "mediaopt turbo ";
535
		else
536
			$ifcargs .= "-mediaopt turbo ";
537

    
538
		/* handle txpower setting */
539
		if($wlcfg['txpower'] <> "")
540
			$ifcargs .= "txpower " . escapeshellarg($wlcfg['txpower']) . " ";
541
		
542
		/* handle wme option */
543
		if(isset($wlcfg['wme']['enable']))
544
			$ifcargs .= " wme";
545
		else
546
			$ifcargs .= " -wme";
547

    
548
	}
549

    
550
        
551
        mwexec($ifconfig . $if . " down"); 
552
	mwexec($ifconfig . $ifcargs);
553
	mwexec($ifconfig . " up");
554

    
555

    
556
	$fd = fopen("{$g['tmp_path']}/ifconfig_wireless", "w");
557
	fwrite($fd, "/sbin/ifconfig {$ifcargs}");
558
	fclose($fd);
559
	
560
	if(isset($wlcfg['useolsr']))
561
		setup_wireless_olsr(escapeshellarg($if));
562
	
563
        return 0;
564

    
565
}
566

    
567
function find_dhclient_process($interface) {
568
	if(filter_translate_type_to_real_interface($interface) <> "")
569
        	$realinterface = filter_translate_type_to_real_interface($interface);
570
	$pid = `ps ax | grep "[d]hclient" | grep {$realinterface} | awk -F" " '{print $1}'`;
571
	return $pid;
572
}
573

    
574
function interfaces_wan_configure() {
575
	global $config, $g;
576

    
577
	$wancfg = $config['interfaces']['wan'];
578

    
579
	if(!$g['booting']) {
580
		mute_kernel_msgs();
581

    
582
		/* find dhclient process for wan and kill it */
583
		killbypid(find_dhclient_process("wan"));
584

    
585
		/* kill PPPoE client (mpd) */
586
		killbypid("{$g['varrun_path']}/mpd.pid");
587

    
588
		/* wait for processes to die */
589
		sleep(1);
590

    
591
		unlink_if_exists("{$g['varetc_path']}/dhclient_wan.conf");
592
		unlink_if_exists("{$g['varetc_path']}/mpd.conf");
593
		unlink_if_exists("{$g['varetc_path']}/mpd.links");
594
		unlink_if_exists("{$g['vardb_path']}/wanip");
595
		unlink_if_exists("{$g['varetc_path']}/nameservers.conf");
596
	}
597

    
598
	/* remove all addresses first */
599
	while (mwexec("/sbin/ifconfig " . escapeshellarg($wancfg['if']) . " -alias") == 0);
600
	mwexec("/sbin/ifconfig " . escapeshellarg($wancfg['if']) . " down");
601

    
602
	/* wireless configuration? */
603
	if (is_array($wancfg['wireless']))
604
		interfaces_wireless_configure($wancfg['if'], $wancfg['wireless']);
605

    
606
	if ($wancfg['spoofmac']) {
607
		mwexec("/sbin/ifconfig " . escapeshellarg($wancfg['if']) .
608
			" link " . escapeshellarg($wancfg['spoofmac']));
609
	}  else {
610
		$mac = get_interface_mac_address($wancfg['if']);
611
		if($mac == "ff:ff:ff:ff:ff:ff") {
612
			/*   this is not a valid mac address.  generate a
613
			 *   temporary mac address so the machine can get online.
614
			 */
615
			echo "Generating new MAC address.";
616
			$random_mac = generate_random_mac_address();
617
			mwexec("/sbin/ifconfig " . escapeshellarg($wancfg['if']) .
618
				" link " . escapeshellarg($random_mac));
619
			$wancfg['spoofmac'] = $random_mac;
620
			write_config();
621
			file_notice("MAC Address altered", "The INVALID MAC address (ff:ff:ff:ff:ff:ff) on interface {$wancfg['if']} has been automatically replaced with {$random_mac}", "Interfaces");
622
		}
623
	}
624

    
625
	/* media */
626
	if ($wancfg['media'] || $wancfg['mediaopt']) {
627
		$cmd = "/sbin/ifconfig " . escapeshellarg($wancfg['if']);
628
		if ($wancfg['media'])
629
			$cmd .= " media " . escapeshellarg($wancfg['media']);
630
		if ($wancfg['mediaopt'])
631
			$cmd .= " mediaopt " . escapeshellarg($wancfg['mediaopt']);
632
		mwexec($cmd);
633
	}
634

    
635
	switch ($wancfg['ipaddr']) {
636

    
637
		case 'dhcp':
638
			interfaces_wan_dhcp_configure();
639
			break;
640

    
641
		case 'pppoe':
642
			interfaces_wan_pppoe_configure();
643
			break;
644

    
645
		case 'pptp':
646
			interfaces_wan_pptp_configure();
647
			break;
648

    
649
		case 'bigpond':
650
			/* just configure DHCP for now; fire up bpalogin when we've got the lease */
651
			interfaces_wan_dhcp_configure();
652
			break;
653

    
654
		default:
655
			if (isset($wancfg['ispointtopoint']) && $wancfg['pointtopoint']) {
656
				mwexec("/sbin/ifconfig " . escapeshellarg($wancfg['if']) . " " .
657
					escapeshellarg($wancfg['ipaddr'] . "/" . $wancfg['subnet']) .
658
					" " . escapeshellarg($wancfg['pointtopoint']) . " up");
659
			} else {
660
				mwexec("/sbin/ifconfig " . escapeshellarg($wancfg['if']) . " " .
661
					escapeshellarg($wancfg['ipaddr'] . "/" . $wancfg['subnet']));
662
			}
663
			/* install default route */
664
			mwexec("/sbin/route delete default");
665
			mwexec("/sbin/route add default " . escapeshellarg($config['system']['gateway']));
666

    
667
			/* resync pf (done automatically for DHCP/PPPoE/PPTP) */
668
			filter_configure();
669
	}
670

    
671
	if (!$g['booting']) {
672
		/* reconfigure static routes (kernel may have deleted them) */
673
		system_routing_configure();
674

    
675
		/* set the reload filter dity flag */
676
		touch("{$g['tmp_path']}/filter_dirty");
677

    
678
		/* reload ipsec tunnels */
679
		vpn_ipsec_configure();
680

    
681
		/* restart ez-ipupdate */
682
		services_dyndns_configure();
683

    
684
		/* force DNS update */
685
		services_dnsupdate_process();
686

    
687
		/* restart dnsmasq */
688
		services_dnsmasq_configure();
689
	}
690

    
691
	unmute_kernel_msgs();
692

    
693
	return 0;
694
}
695

    
696
function interfaces_opt_dhcp_configure($interface) {
697
	global $config, $g;
698

    
699
	$optcfg = $config['interfaces'][$interface];
700
	$optif = $optcfg['if'];
701

    
702
	/* generate dhclient_wan.conf */
703
	$fd = fopen("{$g['varetc_path']}/dhclient_{$optif}.conf", "w");
704
	if (!$fd) {
705
		printf("Error: cannot open dhclient_{$optif}.conf in interfaces_opt_dhcp_configure({$optif}) for writing.\n");
706
		return 1;
707
	}
708

    
709
	if ($optcfg['dhcphostname']) {
710
		$dhclientconf_hostname = "send dhcp-client-identifier \"{$optcfg['dhcphostname']}\";\n";
711
		$dhclientconf_hostname = "	send dhcp-client-identifier \"{$optcfg['dhcphostname']}\";\n";
712
	} else {
713
		$dhclientconf_hostname = "";
714
	}
715

    
716
 	$dhclientconf = "";
717

    
718
	$dhclientconf .= <<<EOD
719
interface "{$optif}" {
720
	send host-name "{$optcfg['dhcphostname']}";
721
	script "/sbin/dhclient-script";
722
	{$dhclientconf_hostname}
723
}
724

    
725
EOD;
726

    
727
	fwrite($fd, $dhclientconf);
728
	fclose($fd);
729

    
730
        /* bring interface up before starting dhclient */
731
        mwexec("/sbin/ifconfig {$optif} up");
732

    
733
        /* fire up dhclient */
734
        mwexec_bg("/sbin/dhclient -d -c {$g['varetc_path']}/dhclient_{$optif}.conf {$optif}");
735

    
736
	return 0;
737
}
738

    
739
function interfaces_dhcp_configure($interface) {
740
	global $config, $g;
741

    
742
	if(filter_translate_type_to_real_interface($interface) <> "")
743
        	$realinterface = filter_translate_type_to_real_interface($interface);
744

    
745
	$optcfg = $config['interfaces'][$interface];
746

    
747
	/* generate dhclient_$interface.conf */
748
	$fd = fopen("{$g['varetc_path']}/dhclient_{$interface}.conf", "w");
749
	if (!$fd) {
750
		printf("Error: cannot open dhclient_{$interface}.conf in interfaces_dhcp_configure({$$interface}) for writing.\n");
751
		return 1;
752
	}
753

    
754
	if ($optcfg['dhcphostname']) {
755
		$dhclientconf_hostname = "send dhcp-client-identifier \"{$optcfg['dhcphostname']}\";\n";
756
		$dhclientconf_hostname = "	send dhcp-client-identifier \"{$optcfg['dhcphostname']}\";\n";
757
	} else {
758
		$dhclientconf_hostname = "";
759
	}
760

    
761
 	$dhclientconf = "";
762

    
763
	$dhclientconf .= <<<EOD
764
interface "{$realinterface}" {
765
	script "/sbin/dhclient-script";
766
	{$dhclientconf_hostname}
767
}
768

    
769
EOD;
770

    
771
	fwrite($fd, $dhclientconf);
772
	fclose($fd);
773
	
774
	$optif = $optcfg['if'];
775
	
776
        /* bring wan interface up before starting dhclient */
777
        mwexec("/sbin/ifconfig {$optif} up");
778

    
779
        /* fire up dhclient */
780
        mwexec_bg("/sbin/dhclient -d -c {$g['varetc_path']}/dhclient_{$optif}.conf {$optif} >/tmp/{$optif}_output >/tmp/{$optif}_error_output");
781

    
782
	$fout = fopen("/tmp/ifconfig_{$optif}","w");
783
	fwrite($fout, "/sbin/dhclient -d -c {$g['varetc_path']}/dhclient_{$optif}.conf {$optif}");
784
	fclose($fout);
785

    
786
	return 0;
787
}
788

    
789
function interfaces_wan_dhcp_configure() {
790
	global $config, $g;
791

    
792
	$wancfg = $config['interfaces']['wan'];
793

    
794
	/* generate dhclient_wan.conf */
795
	$fd = fopen("{$g['varetc_path']}/dhclient_wan.conf", "w");
796
	if (!$fd) {
797
		printf("Error: cannot open dhclient_wan.conf in interfaces_wan_dhcp_configure() for writing.\n");
798
		return 1;
799
	}
800
	
801
	if ($wancfg['dhcphostname']) {
802
		$dhclientconf_hostname = "send dhcp-client-identifier \"{$wancfg['dhcphostname']}\";\n";
803
		$dhclientconf_hostname = "	send dhcp-client-identifier \"{$wancfg['dhcphostname']}\";\n";
804
	} else {
805
		$dhclientconf_hostname = "";
806
	}
807

    
808
 	$dhclientconf = "";
809

    
810
	$dhclientconf .= <<<EOD
811
interface "{$wancfg['if']}" {
812
	script "/sbin/dhclient-script";
813
	{$dhclientconf_hostname}
814
}
815

    
816
EOD;
817

    
818
	fwrite($fd, $dhclientconf);
819
	fclose($fd);
820
	
821
	$wanif = $wancfg['if'];
822
	
823
        /* bring wan interface up before starting dhclient */
824
        mwexec("/sbin/ifconfig {$wanif} up");
825

    
826
        /* fire up dhclient */
827
        mwexec_bg("/sbin/dhclient -d -c {$g['varetc_path']}/dhclient_wan.conf {$wanif} >/tmp/{$wanif}_output >/tmp/{$wanif}_error_output");
828

    
829
	$fout = fopen("/tmp/ifconfig_{$wanif}","w");
830
	fwrite($fout, "/sbin/dhclient -d -c {$g['varetc_path']}/dhclient_wan.conf {$wanif}");
831
	fclose($fout);
832

    
833
	return 0;
834
}
835

    
836
function interfaces_wan_dhcp_down() {
837
	global $config;
838
	$wancfg = $config['interfaces']['wan'];
839
	$wanif = $wancfg['if'];
840
	mwexec("/sbin/ifconfig {$wanif} delete");
841
	sleep(1);
842
}
843

    
844
function interfaces_dhcp_down($interface) {
845
	global $config;
846
	if(filter_translate_type_to_real_interface($interface) <> "")
847
		$realinterface = filter_translate_type_to_real_interface($interface);
848
	mwexec("/sbin/ifconfig {$realinterface} down");
849
	sleep(1);
850
	$pid = find_dhclient_process($interface);
851
	if($pid)
852
		mwexec("kill {$pid}");
853
}
854

    
855
function interfaces_dhcp_up($interface) {
856
	interfaces_dhcp_configure($interface);
857
	sleep(1);
858
}
859

    
860
function interfaces_wan_dhcp_up() {
861
	interfaces_wan_dhcp_configure();
862
	sleep(1);
863
}
864

    
865
function interfaces_wan_pppoe_configure() {
866
	global $config, $g;
867

    
868
	$wancfg = $config['interfaces']['wan'];
869
	$pppoecfg = $config['pppoe'];
870

    
871
	/* generate mpd.conf */
872
	$fd = fopen("{$g['varetc_path']}/mpd.conf", "w");
873
	if (!$fd) {
874
		printf("Error: cannot open mpd.conf in interfaces_wan_pppoe_configure().\n");
875
		return 1;
876
	}
877

    
878
	$idle = 0;
879

    
880
	if (isset($pppoecfg['ondemand'])) {
881
		$ondemand = "enable";
882
		if ($pppoecfg['timeout'])
883
			$idle = $pppoecfg['timeout'];
884
	} else {
885
		$ondemand = "disable";
886
	}
887

    
888
	$mpdconf = <<<EOD
889
pppoe:
890
	new -i ng0 pppoe pppoe
891
	set iface route default
892
	set iface {$ondemand} on-demand
893
	set iface idle {$idle}
894
	set iface up-script /usr/local/sbin/ppp-linkup
895

    
896
EOD;
897

    
898
	if (isset($pppoecfg['ondemand'])) {
899
		$mpdconf .= <<<EOD
900
	set iface addrs 10.0.0.1 10.0.0.2
901

    
902
EOD;
903
	}
904

    
905
	$mpdconf .= <<<EOD
906
	set bundle disable multilink
907
	set bundle authname "{$pppoecfg['username']}"
908
	set bundle password "{$pppoecfg['password']}"
909
	set link keep-alive 10 60
910
	set link max-redial 0
911
	set link no acfcomp protocomp
912
	set link disable pap chap
913
	set link accept chap
914
	set link mtu 1492
915
	set ipcp yes vjcomp
916
	set ipcp ranges 0.0.0.0/0 0.0.0.0/0
917

    
918
EOD;
919

    
920
	if (isset($config['system']['dnsallowoverride'])) {
921
		$mpdconf .= <<<EOD
922
	set ipcp enable req-pri-dns
923

    
924
EOD;
925
	}
926

    
927
	$mpdconf .= <<<EOD
928
	open iface
929

    
930
EOD;
931

    
932
	fwrite($fd, $mpdconf);
933
	fclose($fd);
934

    
935
	/* generate mpd.links */
936
	$fd = fopen("{$g['varetc_path']}/mpd.links", "w");
937
	if (!$fd) {
938
		printf("Error: cannot open mpd.links in interfaces_wan_pppoe_configure().\n");
939
		return 1;
940
	}
941

    
942
	$mpdconf = <<<EOD
943
pppoe:
944
	set link type pppoe
945
	set pppoe iface {$wancfg['if']}
946
	set pppoe service "{$pppoecfg['provider']}"
947
	set pppoe enable originate
948
	set pppoe disable incoming
949

    
950
EOD;
951

    
952
	fwrite($fd, $mpdconf);
953
	fclose($fd);
954

    
955
	/* if mpd is active, lets take it down */
956
	if(file_exists("{$g['varrun_path']}/mpd.pid")) {
957
		killbypid(file_get_contents("{$g['varrun_path']}/mpd.pid"));
958
		sleep(1);
959
	}
960

    
961
	/* fire up mpd */
962
	mwexec("/usr/local/sbin/mpd -b -d {$g['varetc_path']} -p {$g['varrun_path']}/mpd.pid pppoe");
963

    
964
	return 0;
965
}
966

    
967
function interfaces_wan_pppoe_down() {
968
	global $g;
969
	sigkillbypid("{$g['varrun_path']}/mpd.pid", "SIGUSR2");
970
	sleep(1);
971
}
972

    
973
function interfaces_wan_pppoe_up() {
974
	global $g;
975
	sigkillbypid("{$g['varrun_path']}/mpd.pid", "SIGUSR1");
976
	sleep(1);
977
}
978

    
979
function interfaces_wan_pptp_configure() {
980
	global $config, $g;
981

    
982
	$wancfg = $config['interfaces']['wan'];
983
	$pptpcfg = $config['pptp'];
984

    
985
	/* generate mpd.conf */
986
	$fd = fopen("{$g['varetc_path']}/mpd.conf", "w");
987
	if (!$fd) {
988
		printf("Error: cannot open mpd.conf in interfaces_wan_pptp_configure().\n");
989
		return 1;
990
	}
991

    
992
	$idle = 0;
993

    
994
	if (isset($pptpcfg['ondemand'])) {
995
		$ondemand = "enable";
996
		if ($pptpcfg['timeout'])
997
			$idle = $pptpcfg['timeout'];
998
	} else {
999
		$ondemand = "disable";
1000
	}
1001

    
1002
	$mpdconf = <<<EOD
1003
pptp:
1004
	new -i ng0 pptp pptp
1005
	set iface route default
1006
	set iface {$ondemand} on-demand
1007
	set iface idle {$idle}
1008
	set iface up-script /usr/local/sbin/ppp-linkup
1009

    
1010
EOD;
1011

    
1012
	if (isset($pptpcfg['ondemand'])) {
1013
		$mpdconf .= <<<EOD
1014
	set iface addrs 10.0.0.1 10.0.0.2
1015

    
1016
EOD;
1017
	}
1018

    
1019
	$mpdconf .= <<<EOD
1020
	set bundle disable multilink
1021
	set bundle authname "{$pptpcfg['username']}"
1022
	set bundle password "{$pptpcfg['password']}"
1023
	set link keep-alive 10 60
1024
	set link max-redial 0
1025
	set link no acfcomp protocomp
1026
	set link disable pap chap
1027
	set link accept chap
1028
	set ipcp no vjcomp
1029
	set ipcp ranges 0.0.0.0/0 0.0.0.0/0
1030

    
1031
EOD;
1032

    
1033
	if (isset($config['system']['dnsallowoverride'])) {
1034
		$mpdconf .= <<<EOD
1035
	set ipcp enable req-pri-dns
1036

    
1037
EOD;
1038
	}
1039

    
1040
	$mpdconf .= <<<EOD
1041
	open
1042

    
1043
EOD;
1044

    
1045
	fwrite($fd, $mpdconf);
1046
	fclose($fd);
1047

    
1048
	/* generate mpd.links */
1049
	$fd = fopen("{$g['varetc_path']}/mpd.links", "w");
1050
	if (!$fd) {
1051
		printf("Error: cannot open mpd.links in interfaces_wan_pptp_configure().\n");
1052
		return 1;
1053
	}
1054

    
1055
	$mpdconf = <<<EOD
1056
pptp:
1057
	set link type pptp
1058
	set pptp enable originate outcall
1059
	set pptp disable windowing
1060
	set pptp self {$pptpcfg['local']}
1061
	set pptp peer {$pptpcfg['remote']}
1062

    
1063
EOD;
1064

    
1065
	fwrite($fd, $mpdconf);
1066
	fclose($fd);
1067

    
1068
	/* configure interface */
1069
	mwexec("/sbin/ifconfig " . escapeshellarg($wancfg['if']) . " " .
1070
		escapeshellarg($pptpcfg['local'] . "/" . $pptpcfg['subnet']));
1071

    
1072
	/* fire up mpd */
1073
	mwexec("/usr/local/sbin/mpd -b -d {$g['varetc_path']} -p {$g['varrun_path']}/mpd.pid pptp");
1074

    
1075
	return 0;
1076
}
1077

    
1078
function interfaces_wan_pptp_down() {
1079
	global $g;
1080
	sigkillbypid("{$g['varrun_path']}/mpd.pid", "SIGUSR2");
1081
	sleep(1);
1082
}
1083

    
1084
function interfaces_wan_pptp_up() {
1085
	global $g;
1086
	sigkillbypid("{$g['varrun_path']}/mpd.pid", "SIGUSR1");
1087
	sleep(1);
1088
}
1089

    
1090
function interfaces_wan_bigpond_configure($curwanip) {
1091
	global $config, $g;
1092

    
1093
	$bpcfg = $config['bigpond'];
1094

    
1095
	if (!$curwanip) {
1096
		/* IP address not configured yet, exit */
1097
		return 0;
1098
	}
1099

    
1100
	/* kill bpalogin */
1101
	killbyname("bpalogin");
1102

    
1103
	/* wait a moment */
1104
	sleep(1);
1105

    
1106
	/* get the default domain */
1107
	$nfd = @fopen("{$g['varetc_path']}/defaultdomain.conf", "r");
1108
	if ($nfd) {
1109
		$defaultdomain = trim(fgets($nfd));
1110
		fclose($nfd);
1111
	}
1112

    
1113
	/* generate bpalogin.conf */
1114
	$fd = fopen("{$g['varetc_path']}/bpalogin.conf", "w");
1115
	if (!$fd) {
1116
		printf("Error: cannot open bpalogin.conf in interfaces_wan_bigpond_configure().\n");
1117
		return 1;
1118
	}
1119

    
1120
	if (!$bpcfg['authserver'])
1121
		$bpcfg['authserver'] = "dce-server";
1122
	if (!$bpcfg['authdomain'])
1123
		$bpcfg['authdomain'] = $defaultdomain;
1124

    
1125
	$bpconf = <<<EOD
1126
username {$bpcfg['username']}
1127
password {$bpcfg['password']}
1128
authserver {$bpcfg['authserver']}
1129
authdomain {$bpcfg['authdomain']}
1130
localport 5050
1131

    
1132
EOD;
1133

    
1134
	if ($bpcfg['minheartbeatinterval'])
1135
		$bpconf .= "minheartbeatinterval {$bpcfg['minheartbeatinterval']}\n";
1136

    
1137
	fwrite($fd, $bpconf);
1138
	fclose($fd);
1139

    
1140
	/* fire up bpalogin */
1141
	mwexec("/usr/local/sbin/bpalogin -c {$g['varetc_path']}/bpalogin.conf");
1142

    
1143
	return 0;
1144
}
1145

    
1146
function get_real_wan_interface() {
1147
	global $config, $g;
1148

    
1149
	$wancfg = $config['interfaces']['wan'];
1150

    
1151
	$wanif = $wancfg['if'];
1152
	if (($wancfg['ipaddr'] == "pppoe") || ($wancfg['ipaddr'] == "pptp")) {
1153
		$wanif = $g['pppoe_interface'];
1154
	}
1155

    
1156
	return $wanif;
1157
}
1158

    
1159
function get_current_wan_address() {
1160
	global $config, $g;
1161

    
1162
	$wancfg = $config['interfaces']['wan'];
1163

    
1164
	if (in_array($wancfg['ipaddr'], array('pppoe','dhcp','pptp','bigpond'))) {
1165
		/* dynamic WAN IP address, find out which one */
1166
		$wanif = get_real_wan_interface();
1167

    
1168
		/* get interface info with netstat */
1169
		exec("/usr/bin/netstat -nWI " . escapeshellarg($wanif) . " -f inet", $ifinfo);
1170

    
1171
		if (isset($ifinfo[1])) {
1172
			$aif = preg_split("/\s+/", $ifinfo[1]);
1173
			$curwanip = chop($aif[3]);
1174

    
1175
			if ($curwanip && is_ipaddr($curwanip) && ($curwanip != "0.0.0.0"))
1176
				return $curwanip;
1177
		}
1178

    
1179
		return null;
1180
	} else {
1181
		/* static WAN IP address */
1182
		return $wancfg['ipaddr'];
1183
	}
1184
}
1185

    
1186
/****f* interfaces/is_altq_capable
1187
 * NAME
1188
 *   is_altq_capable - Test if interface is capable of using ALTQ
1189
 * INPUTS
1190
 *   $int            - string containing interface name
1191
 * RESULT
1192
 *   boolean         - true or false
1193
 ******/
1194

    
1195
function is_altq_capable($int) {
1196
        /* Per:
1197
         * http://www.freebsd.org/cgi/man.cgi?query=altq&manpath=FreeBSD+6.0-current&format=html
1198
         * Only the following drivers have ALTQ support
1199
         */
1200
        $capable = array("an", "ath", "awi", "bfe", "bge", "dc", "de", "ed",
1201
		"em", "fxp", "hme", "lnc", "ndis", "rl", "sf", "sis", "sk",
1202
		"tun", "vr", "wi", "xl");
1203

    
1204
        $int_family = preg_split("/[0-9]+/", $int);
1205

    
1206
        if (in_array($int_family[0], $capable))
1207
                return true;
1208
        else
1209
                return false;
1210
}
1211

    
1212

    
1213
?>
(8-8/24)