/
interfaces.php
3393 lines (3259 loc) · 202 KB
/
interfaces.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/*
Copyright (C) 2014-2015 Deciso B.V.
Copyright (C) 2010 Erik Fonnesbeck
Copyright (C) 2008-2010 Ermal Luçi
Copyright (C) 2004-2008 Scott Ullrich <sullrich@gmail.com>
Copyright (C) 2006 Daniel S. Haischt
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
require_once("guiconfig.inc");
require_once("filter.inc");
require_once("rrd.inc");
require_once("system.inc");
require_once("interfaces.inc");
require_once("services.inc");
/***************************************************************************************************************
* imported from xmlparse_attr.inc
***************************************************************************************************************/
function startElement_attr($parser, $name, $attrs) {
global $parsedcfg, $depth, $curpath, $havedata, $listtags, $parsedattrs;
array_push($curpath, strtolower($name));
$ptr =& $parsedcfg;
if (!empty($attrs)) {
$attrptr =& $parsedattrs;
$writeattrs = true;
}
foreach ($curpath as $path) {
$ptr =& $ptr[$path];
if (isset($writeattrs)) {
$attrptr =& $attrptr[$path];
}
}
/* is it an element that belongs to a list? */
if (in_array(strtolower($name), $listtags)) {
/* is there an array already? */
if (!is_array($ptr)) {
/* make an array */
$ptr = array();
}
array_push($curpath, count($ptr));
if (isset($writeattrs)) {
if (!is_array($attrptr)) {
$attrptr = array();
}
$attrptr[count($ptr)] = $attrs;
}
} elseif (isset($ptr)) {
/* multiple entries not allowed for this element, bail out */
die(sprintf(gettext('XML error: %s at line %d cannot occur more than once') . "\n",
$name,
xml_get_current_line_number($parser)));
} elseif (isset($writeattrs)) {
$attrptr = $attrs;
}
$depth++;
$havedata = $depth;
}
function endElement_attr($parser, $name) {
global $depth, $curpath, $parsedcfg, $havedata, $listtags;
if ($havedata == $depth) {
$ptr =& $parsedcfg;
foreach ($curpath as $path) {
$ptr =& $ptr[$path];
}
$ptr = "";
}
array_pop($curpath);
if (in_array(strtolower($name), $listtags)) {
array_pop($curpath);
}
$depth--;
}
function cData_attr($parser, $data) {
global $depth, $curpath, $parsedcfg, $havedata;
$data = trim($data, "\t\n\r");
if ($data != "") {
$ptr =& $parsedcfg;
foreach ($curpath as $path) {
$ptr =& $ptr[$path];
}
if (is_string($ptr)) {
$ptr .= html_entity_decode($data);
} else {
if (trim($data, " ") != "") {
$ptr = html_entity_decode($data);
$havedata++;
}
}
}
}
function parse_xml_regdomain(&$rdattributes, $rdfile = '', $rootobj = 'regulatory-data')
{
global $listtags;
if (empty($rdfile)) {
$rdfile = '/etc/regdomain.xml';
}
$listtags = explode(" ", "band country flags freqband netband rd");
$parsed_xml = array();
if (file_exists('/tmp/regdomain.cache')) {
$parsed_xml = unserialize(file_get_contents('/tmp/regdomain.cache'));
if (!empty($parsed_xml)) {
$rdmain = $parsed_xml['main'];
$rdattributes = $parsed_xml['attributes'];
}
}
if (empty($parsed_xml) && file_exists('/etc/regdomain.xml')) {
$rdmain = parse_xml_config_raw_attr($rdfile, $rootobj, $rdattributes);
// unset parts that aren't used before making cache
foreach ($rdmain['regulatory-domains']['rd'] as $rdkey => $rdentry) {
if (isset($rdmain['regulatory-domains']['rd'][$rdkey]['netband'])) {
unset($rdmain['regulatory-domains']['rd'][$rdkey]['netband']);
}
if (isset($rdattributes['regulatory-domains']['rd'][$rdkey]['netband'])) {
unset($rdattributes['regulatory-domains']['rd'][$rdkey]['netband']);
}
}
if (isset($rdmain['shared-frequency-bands'])) {
unset($rdmain['shared-frequency-bands']);
}
if (isset($rdattributes['shared-frequency-bands'])) {
unset($rdattributes['shared-frequency-bands']);
}
$parsed_xml = array('main' => $rdmain, 'attributes' => $rdattributes);
$rdcache = fopen('/tmp/regdomain.cache', 'w');
fwrite($rdcache, serialize($parsed_xml));
fclose($rdcache);
}
return $rdmain;
}
function parse_xml_config_raw_attr($cffile, $rootobj, &$parsed_attributes, $isstring = "false") {
global $depth, $curpath, $parsedcfg, $havedata, $listtags, $parsedattrs;
$parsedcfg = array();
$curpath = array();
$depth = 0;
$havedata = 0;
if (isset($parsed_attributes)) {
$parsedattrs = array();
}
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement_attr", "endElement_attr");
xml_set_character_data_handler($xml_parser, "cData_attr");
xml_parser_set_option($xml_parser,XML_OPTION_SKIP_WHITE, 1);
if (!($fp = fopen($cffile, "r"))) {
log_error('Error: could not open XML input');
if (isset($parsed_attributes)) {
$parsed_attributes = array();
unset($parsedattrs);
}
return -1;
}
while ($data = fread($fp, 4096)) {
if (!xml_parse($xml_parser, $data, feof($fp))) {
log_error(sprintf('XML error: %s at line %d' . "\n",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
if (isset($parsed_attributes)) {
$parsed_attributes = array();
unset($parsedattrs);
}
return -1;
}
}
xml_parser_free($xml_parser);
if (!$parsedcfg[$rootobj]) {
log_error(sprintf('XML error: no %s object found!', $rootobj));
if (isset($parsed_attributes)) {
$parsed_attributes = array();
unset($parsedattrs);
}
return -1;
}
if (isset($parsed_attributes)) {
if ($parsedattrs[$rootobj]) {
$parsed_attributes = $parsedattrs[$rootobj];
}
unset($parsedattrs);
}
return $parsedcfg[$rootobj];
}
/***************************************************************************************************************
* End of import
***************************************************************************************************************/
function get_wireless_modes($interface) {
/* return wireless modes and channels */
$wireless_modes = array();
$cloned_interface = get_real_interface($interface);
if ($cloned_interface && is_interface_wireless($cloned_interface)) {
$chan_list = "/sbin/ifconfig {$cloned_interface} list chan";
$stack_list = "/usr/bin/awk -F\"Channel \" '{ gsub(/\\*/, \" \"); print \$2 \"\\\n\" \$3 }'";
$format_list = "/usr/bin/awk '{print \$5 \" \" \$6 \",\" \$1}'";
$interface_channels = "";
exec("$chan_list | $stack_list | sort -u | $format_list 2>&1", $interface_channels);
$interface_channel_count = count($interface_channels);
$c = 0;
while ($c < $interface_channel_count) {
$channel_line = explode(",", $interface_channels["$c"]);
$wireless_mode = trim($channel_line[0]);
$wireless_channel = trim($channel_line[1]);
if (trim($wireless_mode) != "") {
/* if we only have 11g also set 11b channels */
if ($wireless_mode == "11g") {
if (!isset($wireless_modes["11b"])) {
$wireless_modes["11b"] = array();
}
} elseif ($wireless_mode == "11g ht") {
if (!isset($wireless_modes["11b"])) {
$wireless_modes["11b"] = array();
} elseif (!isset($wireless_modes["11g"])) {
$wireless_modes["11g"] = array();
}
$wireless_mode = "11ng";
} elseif ($wireless_mode == "11a ht") {
if (!isset($wireless_modes["11a"])) {
$wireless_modes["11a"] = array();
}
$wireless_mode = "11na";
}
$wireless_modes["$wireless_mode"]["$c"] = $wireless_channel;
}
$c++;
}
}
return($wireless_modes);
}
/* return channel numbers, frequency, max txpower, and max regulation txpower */
function get_wireless_channel_info($interface) {
$wireless_channels = array();
$cloned_interface = get_real_interface($interface);
if ($cloned_interface && is_interface_wireless($cloned_interface)) {
$chan_list = "/sbin/ifconfig {$cloned_interface} list txpower";
$stack_list = "/usr/bin/awk -F\"Channel \" '{ gsub(/\\*/, \" \"); print \$2 \"\\\n\" \$3 }'";
$format_list = "/usr/bin/awk '{print \$1 \",\" \$3 \" \" \$4 \",\" \$5 \",\" \$7}'";
$interface_channels = "";
exec("$chan_list | $stack_list | sort -u | $format_list 2>&1", $interface_channels);
foreach ($interface_channels as $channel_line) {
$channel_line = explode(",", $channel_line);
if (!isset($wireless_channels[$channel_line[0]])) {
$wireless_channels[$channel_line[0]] = $channel_line;
}
}
}
return($wireless_channels);
}
// Get configured interface list
$ifdescrs = get_configured_interface_with_descr(false, true);
// reference to interface section
$a_interfaces = &config_read_array('interfaces');
$a_ppps = &config_read_array('ppps', 'ppp');
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
if (!empty($_GET['if']) && !empty($a_interfaces[$_GET['if']])) {
$if = $_GET['if'];
} else {
// no interface provided, redirect to interface assignments
header(url_safe('Location: /interfaces_assign.php'));
exit;
}
$pconfig = array();
$std_copy_fieldnames = array(
"if", "descr", "dhcphostname", "alias-address", "alias-subnet", "dhcprejectfrom", "ipaddr", "subnet", "gateway",
"ipaddrv6", "media", "mediaopt",
"adv_dhcp_pt_timeout", "adv_dhcp_pt_retry", "adv_dhcp_pt_select_timeout", "adv_dhcp_pt_reboot",
"adv_dhcp_pt_backoff_cutoff", "adv_dhcp_pt_initial_interval", "adv_dhcp_pt_values",
"adv_dhcp_send_options", "adv_dhcp_request_options", "adv_dhcp_required_options", "adv_dhcp_option_modifiers",
"adv_dhcp_config_advanced", "adv_dhcp_config_file_override", "adv_dhcp_config_file_override_path",
"adv_dhcp6_interface_statement_send_options", "adv_dhcp6_interface_statement_request_options",
"adv_dhcp6_interface_statement_information_only_enable", "adv_dhcp6_interface_statement_script",
"adv_dhcp6_id_assoc_statement_address_enable", "adv_dhcp6_id_assoc_statement_address", "adv_dhcp6_id_assoc_statement_address_id",
"adv_dhcp6_id_assoc_statement_address_pltime", "adv_dhcp6_id_assoc_statement_address_vltime",
"adv_dhcp6_id_assoc_statement_prefix_enable", "adv_dhcp6_id_assoc_statement_prefix", "adv_dhcp6_id_assoc_statement_prefix_id",
"adv_dhcp6_id_assoc_statement_prefix_pltime", "adv_dhcp6_id_assoc_statement_prefix_vltime",
"adv_dhcp6_prefix_interface_statement_sla_len",
"adv_dhcp6_authentication_statement_authname", "adv_dhcp6_authentication_statement_protocol", "adv_dhcp6_authentication_statement_algorithm",
"adv_dhcp6_authentication_statement_rdm", "adv_dhcp6_key_info_statement_keyname", "adv_dhcp6_key_info_statement_realm",
"adv_dhcp6_key_info_statement_keyid", "adv_dhcp6_key_info_statement_secret", "adv_dhcp6_key_info_statement_expire",
"adv_dhcp6_config_advanced", "adv_dhcp6_config_file_override", "adv_dhcp6_config_file_override_path",
"spoofmac", "mtu", "mss", 'dhcp6vlanprio',
"dhcp6-ia-pd-len", "track6-interface", "track6-prefix-id", "prefix-6rd", "prefix-6rd-v4plen", "gateway-6rd",
"ipaddrv6", "subnetv6", "gatewayv6"
);
foreach ($std_copy_fieldnames as $fieldname) {
$pconfig[$fieldname] = isset($a_interfaces[$if][$fieldname]) ? $a_interfaces[$if][$fieldname] : null;
}
$pconfig['enable'] = isset($a_interfaces[$if]['enable']);
$pconfig['lock'] = isset($a_interfaces[$if]['lock']);
$pconfig['blockpriv'] = isset($a_interfaces[$if]['blockpriv']);
$pconfig['blockbogons'] = isset($a_interfaces[$if]['blockbogons']);
$pconfig['dhcp6-ia-pd-send-hint'] = isset($a_interfaces[$if]['dhcp6-ia-pd-send-hint']);
$pconfig['dhcp6sendsolicit'] = isset($a_interfaces[$if]['dhcp6sendsolicit']);
$pconfig['dhcp6prefixonly'] = isset($a_interfaces[$if]['dhcp6prefixonly']);
$pconfig['dhcp6usev4iface'] = isset($a_interfaces[$if]['dhcp6usev4iface']);
$pconfig['dhcp6norelease'] = isset($a_interfaces[$if]['dhcp6norelease']);
$pconfig['adv_dhcp6_debug'] = isset($a_interfaces[$if]['adv_dhcp6_debug']);
$pconfig['track6-prefix-id--hex'] = sprintf("%x", empty($pconfig['track6-prefix-id']) ? 0 :$pconfig['track6-prefix-id']);
$pconfig['dhcpd6track6allowoverride'] = isset($a_interfaces[$if]['dhcpd6track6allowoverride']);
/*
* Due to the settings being split per interface type, we need
* to copy the settings that use the same config directive.
*/
$pconfig['staticv6usev4iface'] = $pconfig['dhcp6usev4iface'];
$pconfig['slaacusev4iface'] = $pconfig['dhcp6usev4iface'];
// ipv4 type (from ipaddr)
if (is_ipaddrv4($pconfig['ipaddr'])) {
$pconfig['type'] = "staticv4";
} else {
if (empty($pconfig['ipaddr'])) {
$pconfig['type'] = "none";
} else {
$pconfig['type'] = $pconfig['ipaddr'];
}
$pconfig['ipaddr'] = null;
}
// ipv6 type (from ipaddrv6)
if (is_ipaddrv6($pconfig['ipaddrv6'])) {
$pconfig['type6'] = "staticv6";
} else {
if (empty($pconfig['ipaddrv6'])) {
$pconfig['type6'] = "none";
} else {
$pconfig['type6'] = $pconfig['ipaddrv6'];
}
$pconfig['ipaddrv6'] = null;
}
/*
locate PPP details (if any)
*/
$pppid = count($a_ppps);
foreach ($a_ppps as $key => $ppp) {
if ($a_interfaces[$if]['if'] == $ppp['if']) {
$pppid = $key;
break;
}
}
$std_ppp_copy_fieldnames = array("ptpid", "ports", "username", "phone", "apn", "provider", "idletimeout", "localip", 'hostuniq');
foreach ($std_ppp_copy_fieldnames as $fieldname) {
$pconfig[$fieldname] = isset($a_ppps[$pppid][$fieldname]) ? $a_ppps[$pppid][$fieldname] : null;
}
$pconfig['password'] = base64_decode($a_ppps[$pppid]['password']); // ppp password field
$pconfig['pppoe_dialondemand'] = isset($a_ppps[$pppid]['ondemand']);
$pconfig['pptp_dialondemand'] = isset($a_ppps[$pppid]['ondemand']);
$pconfig['pppoe_password'] = $pconfig['password']; // pppoe password field
$pconfig['pppoe_username'] = $pconfig['username'];
$pconfig['pppoe_hostuniq'] = $pconfig['hostuniq'];
$pconfig['pppoe_idletimeout'] = $pconfig['idletimeout'];
$pconfig['pptp_username'] = $pconfig['username'];
$pconfig['pptp_password'] = $pconfig['password'];
$pconfig['pptp_subnet'] = $a_ppps[$pppid]['subnet'];
$pconfig['pptp_remote'] = $a_ppps[$pppid]['gateway'];
$pconfig['pptp_idletimeout'] = $a_ppps[$pppid]['timeout'];
if (isset($a_ppps[$pppid])) {
$pconfig['pppid'] = $pppid;
} else {
$pconfig['ptpid'] = interfaces_ptpid_next();
$pppid = count($a_ppps);
}
/*
Wireless interface
*/
if (isset($a_interfaces[$if]['wireless'])) {
/* Sync first to be sure it displays the actual settings that will be used */
interface_sync_wireless_clones($a_interfaces[$if], false);
/* Get wireless modes */
$wlanif = get_real_interface($if);
if (!does_interface_exist($wlanif)) {
interface_wireless_clone($wlanif, $a_interfaces[$if]);
}
$wlanbaseif = interface_get_wireless_base($a_interfaces[$if]['if']);
$std_wl_copy_fieldnames = array(
'standard', 'mode','protmode', 'ssid', 'channel', 'txpower', 'diversity', 'txantenna', 'rxantenna',
'regdomain', 'regcountry', 'reglocation', 'authmode', 'auth_server_addr', 'auth_server_port', 'auth_server_shared_secret',
'auth_server_addr2', 'auth_server_port2', 'auth_server_shared_secret2', 'mac_acl'
);
foreach ($std_wl_copy_fieldnames as $fieldname) {
$pconfig[$fieldname] = isset($a_interfaces[$if]['wireless'][$fieldname]) ? $a_interfaces[$if]['wireless'][$fieldname] : null;
}
$pconfig['persistcommonwireless'] = isset($config['wireless']['interfaces'][$wlanbaseif]);
$pconfig['wme_enable'] = isset($a_interfaces[$if]['wireless']['wme']['enable']);
$pconfig['apbridge_enable'] = isset($a_interfaces[$if]['wireless']['apbridge']['enable']);
$pconfig['hidessid_enable'] = isset($a_interfaces[$if]['wireless']['hidessid']['enable']);
$pconfig['wep_enable'] = isset($a_interfaces[$if]['wireless']['wep']['enable']);
if (isset($a_interfaces[$if]['wireless']['puren']['enable'])) {
$pconfig['puremode'] = '11n';
} elseif (isset($a_interfaces[$if]['wireless']['pureg']['enable'])) {
$pconfig['puremode'] = '11g';
} else {
$pconfig['puremode'] = 'any';
}
if (isset($a_interfaces[$if]['wireless']['wpa']) && is_array($a_interfaces[$if]['wireless']['wpa'])) {
$std_wl_wpa_copy_fieldnames = array(
'debug_mode', 'macaddr_acl', 'auth_algs', 'wpa_mode', 'wpa_key_mgmt', 'wpa_pairwise',
'wpa_group_rekey', 'wpa_gmk_rekey', 'passphrase', 'ext_wpa_sw'
);
foreach ($std_wl_wpa_copy_fieldnames as $fieldname) {
$pconfig[$fieldname] = isset($a_interfaces[$if]['wireless']['wpa'][$fieldname]) ? $a_interfaces[$if]['wireless']['wpa'][$fieldname] : null;
}
$pconfig['ieee8021x'] = isset($a_interfaces[$if]['wireless']['wpa']['ieee8021x']['enable']);
$pconfig['rsn_preauth'] = isset($a_interfaces[$if]['wireless']['wpa']['rsn_preauth']);
$pconfig['mac_acl_enable'] = isset($a_interfaces[$if]['wireless']['wpa']['mac_acl_enable']);
$pconfig['wpa_strict_rekey'] = isset($a_interfaces[$if]['wireless']['wpa']['wpa_strict_rekey']);
$pconfig['wpa_enable'] = isset($a_interfaces[$if]['wireless']['wpa']['enable']);
}
if (is_array($a_interfaces[$if]['wireless']['wep']) && is_array($a_interfaces[$if]['wireless']['wep']['key'])) {
$i = 1;
foreach ($a_interfaces[$if]['wireless']['wep']['key'] as $wepkey) {
$pconfig['key' . $i] = $wepkey['value'];
if (isset($wepkey['txkey'])) {
$pconfig['txkey'] = $i;
}
$i++;
}
if (!isset($wepkey['txkey'])) {
$pconfig['txkey'] = 1;
}
}
}
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
$pconfig = $_POST;
$input_errors = array();
if (!empty($_POST['if']) && !empty($a_interfaces[$_POST['if']])) {
$if = $_POST['if'];
// read physcial interface name from config.xml
$pconfig['if'] = $a_interfaces[$if]['if'];
}
if (!empty($pconfig['apply'])) {
if (!is_subsystem_dirty('interfaces')) {
$intput_errors[] = gettext("You have already applied your settings!");
} else {
clear_subsystem_dirty('interfaces');
if (file_exists('/tmp/.interfaces.apply')) {
$toapplylist = unserialize(file_get_contents('/tmp/.interfaces.apply'));
foreach ($toapplylist as $ifapply => $ifcfgo) {
interface_bring_down($ifapply, $ifcfgo);
if (isset($config['interfaces'][$ifapply]['enable'])) {
interface_configure(false, $ifapply, true);
}
}
}
/*
* XXX possibly wrong to configure interfaces through newwanip
* when the interface is dynamic and this gets called again...
*/
plugins_configure('newwanip');
/* sync filter configuration */
system_routing_configure();
setup_gateways_monitor();
filter_configure();
rrd_configure();
}
@unlink('/tmp/.interfaces.apply');
header(url_safe('Location: /interfaces.php?if=%s', array($if)));
exit;
} elseif (empty($pconfig['enable'])) {
if (isset($a_interfaces[$if]['enable'])) {
unset($a_interfaces[$if]['enable']);
}
if (!empty($pconfig['lock'])) {
$a_interfaces[$if]['lock'] = true;
} elseif (isset($a_interfaces[$if]['lock'])) {
unset($a_interfaces[$if]['lock']);
}
if (isset($a_interfaces[$if]['wireless'])) {
interface_sync_wireless_clones($a_interfaces[$if], false);
}
write_config("Interface {$pconfig['descr']}({$if}) is now disabled.");
mark_subsystem_dirty('interfaces');
if (file_exists('/tmp/.interfaces.apply')) {
$toapplylist = unserialize(file_get_contents('/tmp/.interfaces.apply'));
} else {
$toapplylist = array();
}
if (empty($toapplylist[$if])) {
// only flush if the running config is not in our list yet
$toapplylist[$if]['ifcfg'] = $a_interfaces[$if];
$toapplylist[$if]['ifcfg']['realif'] = get_real_interface($if);
$toapplylist[$if]['ifcfg']['realifv6'] = get_real_interface($if, "inet6");
$toapplylist[$if]['ppps'] = $a_ppps;
file_put_contents('/tmp/.interfaces.apply', serialize($toapplylist));
}
header(url_safe('Location: /interfaces.php?if=%s', array($if)));
exit;
} else {
// locate sequence in ppp list
$pppid = count($a_ppps);
foreach ($a_ppps as $key => $ppp) {
if ($a_interfaces[$if]['if'] == $ppp['if']) {
$pppid = $key;
break;
}
}
$old_ppps = $a_ppps;
/* description unique? */
foreach ($ifdescrs as $ifent => $ifdescr) {
if ($if != $ifent && $ifdescr == $pconfig['descr']) {
$input_errors[] = gettext("An interface with the specified description already exists.");
break;
}
}
/* input validation */
if (isset($config['dhcpd']) && isset($config['dhcpd'][$if]['enable']) && !preg_match('/^staticv4/', $pconfig['type'])) {
$input_errors[] = gettext("The DHCP Server is active on this interface and it can be used only with a static IP configuration. Please disable the DHCP Server service on this interface first, then change the interface configuration.");
}
if (isset($config['dhcpdv6']) && isset($config['dhcpdv6'][$if]['enable']) && !preg_match('/^staticv6/', $pconfig['type6']) && !isset($pconfig['dhcpd6track6allowoverride'])) {
$input_errors[] = gettext("The DHCPv6 Server is active on this interface and it can be used only with a static IPv6 configuration. Please disable the DHCPv6 Server service on this interface first, then change the interface configuration.");
}
switch (strtolower($pconfig['type'])) {
case "staticv4":
$reqdfields = explode(" ", "ipaddr subnet gateway");
$reqdfieldsn = array(gettext("IPv4 address"),gettext("Subnet bit count"),gettext("Gateway"));
do_input_validation($pconfig, $reqdfields, $reqdfieldsn, $input_errors);
break;
case "none":
if (isset($config['virtualip']['vip'])) {
foreach ($config['virtualip']['vip'] as $vip) {
if (is_ipaddrv4($vip['subnet']) && $vip['interface'] == $if) {
$input_errors[] = gettext("This interface is referenced by IPv4 VIPs. Please delete those before setting the interface to 'none' configuration.");
}
}
}
case "dhcp":
if (!empty($pconfig['adv_dhcp_config_file_override'] && !file_exists($pconfig['adv_dhcp_config_file_override_path']))) {
$input_errors[] = sprintf(gettext('The DHCP override file "%s" does not exist.'), $pconfig['adv_dhcp_config_file_override_path']);
}
break;
case "ppp":
$reqdfields = explode(" ", "ports phone");
$reqdfieldsn = array(gettext("Modem Port"),gettext("Phone Number"));
do_input_validation($pconfig, $reqdfields, $reqdfieldsn, $input_errors);
break;
case "pppoe":
if (!empty($pconfig['pppoe_dialondemand'])) {
$reqdfields = explode(" ", "pppoe_username pppoe_password pppoe_dialondemand pppoe_idletimeout");
$reqdfieldsn = array(gettext("PPPoE username"),gettext("PPPoE password"),gettext("Dial on demand"),gettext("Idle timeout value"));
} else {
$reqdfields = explode(" ", "pppoe_username pppoe_password");
$reqdfieldsn = array(gettext("PPPoE username"),gettext("PPPoE password"));
}
do_input_validation($pconfig, $reqdfields, $reqdfieldsn, $input_errors);
break;
case "pptp":
if (!empty($pconfig['pptp_dialondemand'])) {
$reqdfields = explode(" ", "pptp_username pptp_password localip pptp_subnet pptp_remote pptp_dialondemand pptp_idletimeout");
$reqdfieldsn = array(gettext("PPTP username"),gettext("PPTP password"),gettext("PPTP local IP address"),gettext("PPTP subnet"),gettext("PPTP remote IP address"),gettext("Dial on demand"),gettext("Idle timeout value"));
} else {
$reqdfields = explode(" ", "pptp_username pptp_password localip pptp_subnet pptp_remote");
$reqdfieldsn = array(gettext("PPTP username"),gettext("PPTP password"),gettext("PPTP local IP address"),gettext("PPTP subnet"),gettext("PPTP remote IP address"));
}
do_input_validation($pconfig, $reqdfields, $reqdfieldsn, $input_errors);
break;
case "l2tp":
if (!empty($pconfig['pptp_dialondemand'])) {
$reqdfields = explode(" ", "pptp_username pptp_password pptp_remote pptp_dialondemand pptp_idletimeout");
$reqdfieldsn = array(gettext("L2TP username"),gettext("L2TP password"),gettext("L2TP remote IP address"),gettext("Dial on demand"),gettext("Idle timeout value"));
} else {
$reqdfields = explode(" ", "pptp_username pptp_password pptp_remote");
$reqdfieldsn = array(gettext("L2TP username"),gettext("L2TP password"),gettext("L2TP remote IP address"));
}
do_input_validation($pconfig, $reqdfields, $reqdfieldsn, $input_errors);
break;
}
switch (strtolower($pconfig['type6'])) {
case "staticv6":
$reqdfields = explode(" ", "ipaddrv6 subnetv6 gatewayv6");
$reqdfieldsn = array(gettext("IPv6 address"),gettext("Subnet bit count"),gettext("Gateway"));
do_input_validation($pconfig, $reqdfields, $reqdfieldsn, $input_errors);
break;
case "dhcp6":
if (!empty($pconfig['adv_dhcp6_config_file_override'] && !file_exists($pconfig['adv_dhcp6_config_file_override_path']))) {
$input_errors[] = sprintf(gettext('The DHCPv6 override file "%s" does not exist.'), $pconfig['adv_dhcp6_config_file_override_path']);
}
break;
case "none":
if (isset($config['virtualip']['vip'])) {
foreach ($config['virtualip']['vip'] as $vip) {
if (is_ipaddrv6($vip['subnet']) && $vip['interface'] == $if) {
$input_errors[] = gettext("This interface is referenced by IPv6 VIPs. Please delete those before setting the interface to 'none' configuration.");
}
}
}
break;
case "6rd":
if (empty($pconfig['gateway-6rd']) || !is_ipaddrv4($pconfig['gateway-6rd'])) {
$input_errors[] = gettext('6RD border relay gateway must be a valid IPv4 address.');
}
if (empty($pconfig['prefix-6rd']) || !is_subnetv6($pconfig['prefix-6rd'])) {
$input_errors[] = gettext('6RD prefix must be a valid IPv6 subnet.');
}
if (!is_numeric($pconfig['prefix-6rd-v4plen'])) {
$input_errors[] = gettext('6RD IPv4 prefix length must be a number.');
}
foreach ($ifdescrs as $ifent => $ifdescr) {
if ($if != $ifent && ($config[interfaces][$ifent]['ipaddrv6'] == $pconfig['type6'])) {
if ($config[interfaces][$ifent]['prefix-6rd'] == $pconfig['prefix-6rd']) {
$input_errors[] = gettext("You can only have one interface configured in 6rd with same prefix.");
break;
}
}
}
break;
case "6to4":
foreach ($ifdescrs as $ifent => $ifdescr) {
if ($if != $ifent && ($config[interfaces][$ifent]['ipaddrv6'] == $pconfig['type6'])) {
$input_errors[] = sprintf(gettext("You can only have one interface configured as 6to4."), $pconfig['type6']);
break;
}
}
break;
case "track6":
if (!empty($pconfig['track6-prefix-id--hex']) && !ctype_xdigit($pconfig['track6-prefix-id--hex'])) {
$input_errors[] = gettext("You must enter a valid hexadecimal number for the IPv6 prefix ID.");
} elseif (!empty($pconfig['track6-interface'])) {
$ipv6_delegation_length = calculate_ipv6_delegation_length($pconfig['track6-interface']);
$ipv6_num_prefix_ids = pow(2, $ipv6_delegation_length);
$track6_prefix_id = intval($pconfig['track6-prefix-id--hex'], 16);
if ($track6_prefix_id < 0 || $track6_prefix_id >= $ipv6_num_prefix_ids) {
$input_errors[] = gettext("You specified an IPv6 prefix ID that is out of range.");
}
}
break;
}
/* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */
$staticroutes = get_staticroutes(true);
if (!empty($pconfig['ipaddr'])) {
if (!is_ipaddrv4($pconfig['ipaddr'])) {
$input_errors[] = gettext("A valid IPv4 address must be specified.");
} else {
if (is_ipaddr_configured($pconfig['ipaddr'], $if)) {
$input_errors[] = gettext("This IPv4 address is being used by another interface or VIP.");
}
/* Do not accept network or broadcast address, except if subnet is 31 or 32 */
if ($pconfig['subnet'] < 31) {
if ($pconfig['ipaddr'] == gen_subnet($pconfig['ipaddr'], $pconfig['subnet'])) {
$input_errors[] = gettext("This IPv4 address is the network address and cannot be used");
} elseif ($pconfig['ipaddr'] == gen_subnet_max($pconfig['ipaddr'], $pconfig['subnet'])) {
$input_errors[] = gettext("This IPv4 address is the broadcast address and cannot be used");
}
}
foreach ($staticroutes as $route_subnet) {
list($network, $subnet) = explode("/", $route_subnet);
if ($pconfig['subnet'] == $subnet && $network == gen_subnet($pconfig['ipaddr'], $pconfig['subnet'])) {
$input_errors[] = gettext("This IPv4 address conflicts with a Static Route.");
break;
}
unset($network, $subnet);
}
}
}
if (!empty($pconfig['ipaddrv6'])) {
if (!is_ipaddrv6($pconfig['ipaddrv6'])) {
$input_errors[] = gettext("A valid IPv6 address must be specified.");
} else {
if (is_ipaddr_configured($pconfig['ipaddrv6'], $if)) {
$input_errors[] = gettext("This IPv6 address is being used by another interface or VIP.");
}
foreach ($staticroutes as $route_subnet) {
list($network, $subnet) = explode("/", $route_subnet);
if ($pconfig['subnetv6'] == $subnet && $network == gen_subnetv6($pconfig['ipaddrv6'], $pconfig['subnetv6'])) {
$input_errors[] = gettext("This IPv6 address conflicts with a Static Route.");
break;
}
unset($network, $subnet);
}
}
}
if (!empty($pconfig['subnet']) && !is_numeric($pconfig['subnet'])) {
$input_errors[] = gettext("A valid subnet bit count must be specified.");
}
if (!empty($pconfig['subnetv6']) && !is_numeric($pconfig['subnetv6'])) {
$input_errors[] = gettext("A valid subnet bit count must be specified.");
}
if (!empty($pconfig['alias-address']) && !is_ipaddrv4($pconfig['alias-address'])) {
$input_errors[] = gettext("A valid alias IP address must be specified.");
}
if (!empty($pconfig['alias-subnet']) && !is_numeric($pconfig['alias-subnet'])) {
$input_errors[] = gettext("A valid alias subnet bit count must be specified.");
}
if (!empty($pconfig['dhcprejectfrom']) && !is_ipaddrv4($pconfig['dhcprejectfrom'])) {
$input_errors[] = gettext("A valid alias IP address must be specified to reject DHCP Leases from.");
}
if ($pconfig['gateway'] != "none" || $pconfig['gatewayv6'] != "none") {
$match = false;
if (!empty($config['gateways']['gateway_item'])) {
foreach($config['gateways']['gateway_item'] as $gateway) {
if (in_array($pconfig['gateway'], $gateway)) {
$match = true;
}
}
foreach($config['gateways']['gateway_item'] as $gateway) {
if (in_array($pconfig['gatewayv6'], $gateway)) {
$match = true;
}
}
}
if (!$match) {
$input_errors[] = gettext("A valid gateway must be specified.");
}
}
if (!empty($pconfig['provider']) && !is_domain($pconfig['provider'])){
$input_errors[] = gettext("The service name contains invalid characters.");
}
if (!empty($pconfig['pppoe_idletimeout']) && !is_numericint($pconfig['pppoe_idletimeout'])) {
$input_errors[] = gettext("The idle timeout value must be an integer.");
}
if (!empty($pconfig['localip']) && !is_ipaddrv4($pconfig['localip'])) {
$input_errors[] = gettext("A valid PPTP local IP address must be specified.");
}
if (!empty($pconfig['pptp_subnet']) && !is_numeric($pconfig['pptp_subnet'])) {
$input_errors[] = gettext("A valid PPTP subnet bit count must be specified.");
}
if (!empty($pconfig['pptp_remote']) && !is_ipaddrv4($pconfig['pptp_remote']) && !is_hostname($pconfig['gateway'][$iface])) {
$input_errors[] = gettext("A valid PPTP remote IP address must be specified.");
}
if (!empty($pconfig['pptp_idletimeout']) && !is_numericint($pconfig['pptp_idletimeout'])) {
$input_errors[] = gettext("The idle timeout value must be an integer.");
}
if (!empty($pconfig['spoofmac']) && !is_macaddr($pconfig['spoofmac'])) {
$input_errors[] = gettext("A valid MAC address must be specified.");
}
if (!empty($pconfig['mtu'])) {
if ($pconfig['mtu'] < 576 || $pconfig['mtu'] > 9000) {
$input_errors[] = gettext("The MTU must be greater than 576 bytes and less than 9000.");
}
if (stristr($a_interfaces[$if]['if'], "_vlan")) {
$parentif = get_parent_interface($a_interfaces[$if]['if'])[0];
$intf_details = legacy_interface_details($parentif);
if ($intf_details['mtu'] < $pconfig['mtu']) {
$input_errors[] = gettext("MTU of a vlan should not be bigger than parent interface.");
}
} else {
foreach ($config['interfaces'] as $idx => $ifdata) {
if (($idx == $if) || !preg_match('/_vlan[0-9]/', $ifdata['if'])) {
continue;
}
$realhwif_array = get_parent_interface($ifdata['if']);
// Need code to handle MLPPP if we ever use $realhwif for MLPPP handling
$parent_realhwif = $realhwif_array[0];
if ($parent_realhwif != $a_interfaces[$if]['if']) {
continue;
}
if (isset($ifdata['mtu']) && $ifdata['mtu'] > $pconfig['mtu']) {
$input_errors[] = sprintf(gettext("Interface %s (VLAN) has MTU set to a bigger value"), $ifdata['descr']);
}
}
}
}
if (!empty($pconfig['mss']) && $pconfig['mss'] < 576) {
$input_errors[] = gettext("The MSS must be greater than 576 bytes.");
}
/*
Wireless interface
*/
if (isset($a_interfaces[$if]['wireless'])) {
$reqdfields = array("mode");
$reqdfieldsn = array(gettext("Mode"));
if ($pconfig['mode'] == 'hostap') {
$reqdfields[] = "ssid";
$reqdfieldsn[] = gettext("SSID");
}
do_input_validation($pconfig, $reqdfields, $reqdfieldsn, $input_errors);
// check_wireless_mode (more wireless weirness)
// validations shouldn't perform actual actions, needs serious fixing at some point
if ($a_interfaces[$if]['wireless']['mode'] != $pconfig['mode']) {
if (does_interface_exist(interface_get_wireless_clone($wlanbaseif))) {
$clone_count = 1;
} else {
$clone_count = 0;
}
if (isset($config['wireless']['clone']) && is_array($config['wireless']['clone'])) {
foreach ($config['wireless']['clone'] as $clone) {
if ($clone['if'] == $wlanbaseif) {
$clone_count++;
}
}
}
if ($clone_count > 1) {
$wlanif = get_real_interface($if);
$old_wireless_mode = $a_interfaces[$if]['wireless']['mode'];
$a_interfaces[$if]['wireless']['mode'] = $pconfig['mode'];
if (!interface_wireless_clone("{$wlanif}_", $a_interfaces[$if])) {
$input_errors[] = sprintf(gettext("Unable to change mode to %s. You may already have the maximum number of wireless clones supported in this mode."), $wlan_modes[$a_interfaces[$if]['wireless']['mode']]);
} else {
mwexec("/sbin/ifconfig " . escapeshellarg($wlanif) . "_ destroy");
}
}
}
/* loop through keys and enforce size */
for ($i = 1; $i <= 4; $i++) {
if ($pconfig['key' . $i]) {
if (strlen($pconfig['key' . $i]) == 5) {
/* 64 bit */
continue;
} elseif (strlen($pconfig['key' . $i]) == 10) {
/* hex key */
if (stristr($pconfig['key' . $i], "0x") == false) {
$pconfig['key' . $i] = "0x" . $pconfig['key' . $i];
}
continue;
} elseif (strlen($pconfig['key' . $i]) == 12) {
/* hex key */
if (stristr($pconfig['key' . $i], "0x") == false) {
$pconfig['key' . $i] = "0x" . $pconfig['key' . $i];
}
continue;
} elseif (strlen($pconfig['key' . $i]) == 13) {
/* 128 bit */
continue;
} elseif (strlen($pconfig['key' . $i]) == 26) {
/* hex key */
if (stristr($pconfig['key' . $i], "0x") == false)
$_POST['key' . $i] = "0x" . $pconfig['key' . $i];
continue;
} elseif (strlen($pconfig['key' . $i]) == 28) {
continue;
} else {
$input_errors[] = gettext("Invalid WEP key size. Sizes should be 40 (64) bit keys or 104 (128) bit.");
}
}
}
if (!empty($pconfig['passphrase'])) {
$passlen = strlen($pconfig['passphrase']);
if ($passlen < 8 || $passlen > 63) {
$input_errors[] = gettext("The length of the passphrase should be between 8 and 63 characters.");
}
}
}
// save form data
if (count($input_errors) == 0) {
$old_config = $a_interfaces[$if];
// retrieve our interface names before anything changes
$old_config['realif'] = get_real_interface($if);
$old_config['realifv6'] = get_real_interface($if, "inet6");
$new_config = array();
$new_ppp_config = array();
// copy physical interface data (wireless is a strange case, partly managed via interface_sync_wireless_clones)
$new_config["if"] = $old_config["if"];
if (!empty($old_config['wireless'])) {
$new_config['wireless'] = $old_config['wireless'];
}
//
$new_config['descr'] = preg_replace('/[^a-z_0-9]/i', '', $pconfig['descr']);
$new_config['enable'] = !empty($pconfig['enable']);
$new_config['lock'] = !empty($pconfig['lock']);
$new_config['spoofmac'] = $pconfig['spoofmac'];
$new_config['blockpriv'] = !empty($pconfig['blockpriv']);
$new_config['blockbogons'] = !empty($pconfig['blockbogons']);
if (!empty($pconfig['mtu'])) {
$new_config['mtu'] = $pconfig['mtu'];
}
if (!empty($pconfig['mss'])) {
$new_config['mss'] = $pconfig['mss'];
}
if (!empty($pconfig['mediaopt'])) {
$mediaopts = explode(' ', $pconfig['mediaopt']);
if (isset($mediaopts[0])) {
$new_config['media'] = $mediaopts[0];
}
if (isset($mediaopts[0])) {
$new_config ['mediaopt'] = $mediaopts[1];
}
}
// switch ipv4 config by type
switch($pconfig['type']) {
case "staticv4":
$new_config['ipaddr'] = $pconfig['ipaddr'];
$new_config['subnet'] = $pconfig['subnet'];
if ($pconfig['gateway'] != "none") {
$new_config['gateway'] = $pconfig['gateway'];
}
break;
case "dhcp":
$new_config['ipaddr'] = "dhcp";
$new_config['dhcphostname'] = $pconfig['dhcphostname'];
$new_config['alias-address'] = $pconfig['alias-address'];
$new_config['alias-subnet'] = $pconfig['alias-subnet'];
$new_config['dhcprejectfrom'] = $pconfig['dhcprejectfrom'];
$new_config['adv_dhcp_pt_timeout'] = $pconfig['adv_dhcp_pt_timeout'];
$new_config['adv_dhcp_pt_retry'] = $pconfig['adv_dhcp_pt_retry'];
$new_config['adv_dhcp_pt_select_timeout'] = $pconfig['adv_dhcp_pt_select_timeout'];
$new_config['adv_dhcp_pt_reboot'] = $pconfig['adv_dhcp_pt_reboot'];
$new_config['adv_dhcp_pt_backoff_cutoff'] = $pconfig['adv_dhcp_pt_backoff_cutoff'];
$new_config['adv_dhcp_pt_initial_interval'] = $pconfig['adv_dhcp_pt_initial_interval'];
$new_config['adv_dhcp_pt_values'] = $pconfig['adv_dhcp_pt_values'];
$new_config['adv_dhcp_send_options'] = $pconfig['adv_dhcp_send_options'];
$new_config['adv_dhcp_request_options'] = $pconfig['adv_dhcp_request_options'];
$new_config['adv_dhcp_required_options'] = $pconfig['adv_dhcp_required_options'];
$new_config['adv_dhcp_option_modifiers'] = $pconfig['adv_dhcp_option_modifiers'];
$new_config['adv_dhcp_config_advanced'] = $pconfig['adv_dhcp_config_advanced'];
$new_config['adv_dhcp_config_file_override'] = $pconfig['adv_dhcp_config_file_override'];
$new_config['adv_dhcp_config_file_override_path'] = $pconfig['adv_dhcp_config_file_override_path'];
break;
case "ppp":
$new_config['if'] = $pconfig['type'] . $pconfig['ptpid'];