1 |
5b74202b
|
Scott Ullrich
|
<?php
|
2 |
09221bc3
|
Renato Botelho
|
/*
|
3 |
ac24dc24
|
Renato Botelho
|
* config.console.inc
|
4 |
|
|
*
|
5 |
|
|
* part of pfSense (https://www.pfsense.org)
|
6 |
38809d47
|
Renato Botelho do Couto
|
* Copyright (c) 2004-2013 BSD Perimeter
|
7 |
|
|
* Copyright (c) 2013-2016 Electric Sheep Fencing
|
8 |
402c98a2
|
Reid Linnemann
|
* Copyright (c) 2014-2023 Rubicon Communications, LLC (Netgate)
|
9 |
ac24dc24
|
Renato Botelho
|
* All rights reserved.
|
10 |
|
|
*
|
11 |
|
|
* originally part of m0n0wall (http://m0n0.ch/wall)
|
12 |
c5d81585
|
Renato Botelho
|
* Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
13 |
ac24dc24
|
Renato Botelho
|
* All rights reserved.
|
14 |
|
|
*
|
15 |
b12ea3fb
|
Renato Botelho
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
16 |
|
|
* you may not use this file except in compliance with the License.
|
17 |
|
|
* You may obtain a copy of the License at
|
18 |
ac24dc24
|
Renato Botelho
|
*
|
19 |
b12ea3fb
|
Renato Botelho
|
* http://www.apache.org/licenses/LICENSE-2.0
|
20 |
ac24dc24
|
Renato Botelho
|
*
|
21 |
b12ea3fb
|
Renato Botelho
|
* Unless required by applicable law or agreed to in writing, software
|
22 |
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
23 |
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
24 |
|
|
* See the License for the specific language governing permissions and
|
25 |
|
|
* limitations under the License.
|
26 |
ac24dc24
|
Renato Botelho
|
*/
|
27 |
5b74202b
|
Scott Ullrich
|
|
28 |
5eab8157
|
doktornotor
|
require_once("config.inc");
|
29 |
|
|
require_once("globals.inc");
|
30 |
|
|
require_once("interfaces.inc");
|
31 |
|
|
require_once("util.inc");
|
32 |
|
|
|
33 |
87d2f8cd
|
Luiz Souza
|
/*
|
34 |
|
|
* returns:
|
35 |
|
|
* -2: error
|
36 |
|
|
* -1: no interface found
|
37 |
|
|
* 0: interface(s) assigned
|
38 |
|
|
* 1: user quit
|
39 |
|
|
*/
|
40 |
5b74202b
|
Scott Ullrich
|
function set_networking_interfaces_ports() {
|
41 |
|
|
global $config;
|
42 |
|
|
global $g;
|
43 |
|
|
global $fp;
|
44 |
|
|
|
45 |
|
|
$fp = fopen('php://stdin', 'r');
|
46 |
|
|
|
47 |
|
|
$memory = get_memory();
|
48 |
493360f5
|
Phil Davis
|
$physmem = $memory[0];
|
49 |
|
|
$realmem = $memory[1];
|
50 |
5b74202b
|
Scott Ullrich
|
|
51 |
2568e151
|
Christian McDonald
|
if ($physmem < g_get('minimum_ram_warning')) {
|
52 |
5b74202b
|
Scott Ullrich
|
echo "\n\n\n";
|
53 |
814f9e64
|
Carlos Eduardo Ramos
|
echo gettext("DANGER! WARNING! ACHTUNG!") . "\n\n";
|
54 |
2568e151
|
Christian McDonald
|
printf(gettext('%1$s requires *AT LEAST* %2$s RAM to function correctly.%3$s'), g_get('product_label'), g_get('minimum_ram_warning_text'), "\n");
|
55 |
|
|
printf(gettext('Only (%1$s) MB RAM has been detected, with (%2$s) available to %3$s.%4$s'), $realmem, $physmem, g_get('product_label'), "\n");
|
56 |
814f9e64
|
Carlos Eduardo Ramos
|
echo "\n" . gettext("Press ENTER to continue.") . " ";
|
57 |
5b74202b
|
Scott Ullrich
|
fgets($fp);
|
58 |
|
|
echo "\n";
|
59 |
|
|
}
|
60 |
|
|
|
61 |
f8cc5da5
|
Viktor G
|
$iflist = get_interface_list('active', 'physical', true);
|
62 |
5b74202b
|
Scott Ullrich
|
|
63 |
60f164f3
|
Renato Botelho
|
/* Function flow is based on $key or the lack thereof */
|
64 |
5b74202b
|
Scott Ullrich
|
$key = null;
|
65 |
|
|
|
66 |
|
|
echo <<<EOD
|
67 |
|
|
|
68 |
|
|
Valid interfaces are:
|
69 |
|
|
|
70 |
|
|
|
71 |
|
|
EOD;
|
72 |
|
|
|
73 |
1e0b1727
|
Phil Davis
|
if (!is_array($iflist)) {
|
74 |
814f9e64
|
Carlos Eduardo Ramos
|
echo gettext("No interfaces found!") . "\n";
|
75 |
78347c9b
|
Luiz Souza
|
return (-1);
|
76 |
5b74202b
|
Scott Ullrich
|
} else {
|
77 |
fd020a2d
|
Phil Davis
|
// ifsmallist is kept with spaces at the beginning and end to assist with str_replace() operations
|
78 |
|
|
$ifsmallist = " ";
|
79 |
5b74202b
|
Scott Ullrich
|
foreach ($iflist as $iface => $ifa) {
|
80 |
179377b0
|
robjarsen
|
$friendly = convert_real_interface_to_friendly_interface_name($iface);
|
81 |
123efede
|
Reid Linnemann
|
$ifstatus = get_interface_addresses(config_get_path("interfaces/{$friendly}/if", ""));
|
82 |
16feb55d
|
Luiz Otavio O Souza
|
if (is_array($ifstatus) && $ifstatus['linkstateup'])
|
83 |
|
|
$status = " (up)";
|
84 |
|
|
else
|
85 |
|
|
$status = "(down)";
|
86 |
fd020a2d
|
Phil Davis
|
$ifsmallist = $ifsmallist . $iface. " ";
|
87 |
a5c7f533
|
Luiz Souza
|
echo sprintf("%-7s %s %s %s\n", $iface, $ifa['mac'],
|
88 |
b54a3743
|
nagyrobi
|
$status, substr($ifa['dmesg'], 0, 46));
|
89 |
5b74202b
|
Scott Ullrich
|
}
|
90 |
|
|
}
|
91 |
|
|
|
92 |
530e4707
|
NOYB
|
echo "\n" . gettext("Do VLANs need to be set up first?");
|
93 |
0b3799f1
|
Phil Davis
|
echo "\n" .
|
94 |
|
|
gettext(
|
95 |
530e4707
|
NOYB
|
"If VLANs will not be used, or only for optional interfaces, it is typical to\n" .
|
96 |
0b3799f1
|
Phil Davis
|
"say no here and use the webConfigurator to configure VLANs later, if required.") .
|
97 |
|
|
"\n";
|
98 |
34ee6639
|
NOYB
|
echo "\n" . gettext("Should VLANs be set up now [y|n]?") . " ";
|
99 |
5b74202b
|
Scott Ullrich
|
|
100 |
60f164f3
|
Renato Botelho
|
$key = chop(fgets($fp));
|
101 |
5b74202b
|
Scott Ullrich
|
|
102 |
60f164f3
|
Renato Botelho
|
//Manually assign interfaces
|
103 |
|
|
if (in_array($key, array('y', 'Y'))) {
|
104 |
|
|
vlan_setup();
|
105 |
|
|
}
|
106 |
5b74202b
|
Scott Ullrich
|
|
107 |
29bed760
|
Reid Linnemann
|
$vlans = config_get_path('vlans/vlan', []);
|
108 |
|
|
if (is_array($vlans) && count($vlans)) {
|
109 |
60f164f3
|
Renato Botelho
|
echo "\n\n" . gettext("VLAN interfaces:") . "\n\n";
|
110 |
29bed760
|
Reid Linnemann
|
foreach ($vlans as $vlan) {
|
111 |
12bcf7e9
|
Luiz Souza
|
echo sprintf("% -16s%s\n", vlan_interface($vlan),
|
112 |
60f164f3
|
Renato Botelho
|
"VLAN tag {$vlan['tag']}, parent interface {$vlan['if']}");
|
113 |
12bcf7e9
|
Luiz Souza
|
$iflist[vlan_interface($vlan)] = array();
|
114 |
|
|
$ifsmallist = $ifsmallist . vlan_interface($vlan) . " ";
|
115 |
60f164f3
|
Renato Botelho
|
}
|
116 |
|
|
}
|
117 |
5b74202b
|
Scott Ullrich
|
|
118 |
60f164f3
|
Renato Botelho
|
echo <<<EOD
|
119 |
5b74202b
|
Scott Ullrich
|
|
120 |
60f164f3
|
Renato Botelho
|
If the names of the interfaces are not known, auto-detection can
|
121 |
|
|
be used instead. To use auto-detection, please disconnect all
|
122 |
|
|
interfaces before pressing 'a' to begin the process.
|
123 |
5b74202b
|
Scott Ullrich
|
|
124 |
|
|
EOD;
|
125 |
|
|
|
126 |
60f164f3
|
Renato Botelho
|
do {
|
127 |
|
|
echo "\n" . gettext("Enter the WAN interface name or 'a' for auto-detection") . " ";
|
128 |
1579e70f
|
Phil Davis
|
printf(gettext('%1$s(%2$s or a): '), "\n", trim($ifsmallist));
|
129 |
60f164f3
|
Renato Botelho
|
$wanif = chop(fgets($fp));
|
130 |
|
|
if ($wanif === "") {
|
131 |
87d2f8cd
|
Luiz Souza
|
return (1);
|
132 |
1e0b1727
|
Phil Davis
|
}
|
133 |
60f164f3
|
Renato Botelho
|
if ($wanif === "a") {
|
134 |
|
|
$wanif = autodetect_interface("WAN", $fp);
|
135 |
|
|
} else if (!array_key_exists($wanif, $iflist)) {
|
136 |
1579e70f
|
Phil Davis
|
printf(gettext('%1$sInvalid interface name \'%2$s\'%3$s'), "\n", $wanif, "\n");
|
137 |
60f164f3
|
Renato Botelho
|
unset($wanif);
|
138 |
|
|
continue;
|
139 |
|
|
}
|
140 |
|
|
$ifsmallist = str_replace(" " . $wanif . " ", " ", $ifsmallist);
|
141 |
|
|
} while (!$wanif);
|
142 |
1e0b1727
|
Phil Davis
|
|
143 |
60f164f3
|
Renato Botelho
|
do {
|
144 |
1579e70f
|
Phil Davis
|
printf(gettext('%1$sEnter the LAN interface name or \'a\' for auto-detection %2$s' .
|
145 |
|
|
'NOTE: this enables full Firewalling/NAT mode.%3$s' .
|
146 |
|
|
'(%4$s a or nothing if finished):%5$s'), "\n", "\n", "\n", trim($ifsmallist), " ");
|
147 |
1e0b1727
|
Phil Davis
|
|
148 |
60f164f3
|
Renato Botelho
|
$lanif = chop(fgets($fp));
|
149 |
1e0b1727
|
Phil Davis
|
|
150 |
60f164f3
|
Renato Botelho
|
if ($lanif == "exit") {
|
151 |
|
|
exit;
|
152 |
5b74202b
|
Scott Ullrich
|
}
|
153 |
1e0b1727
|
Phil Davis
|
|
154 |
60f164f3
|
Renato Botelho
|
if ($lanif == "") {
|
155 |
|
|
/* It is OK to have just a WAN, without a LAN so break if the user does not want LAN. */
|
156 |
|
|
break;
|
157 |
|
|
}
|
158 |
1e0b1727
|
Phil Davis
|
|
159 |
60f164f3
|
Renato Botelho
|
if ($lanif === "a") {
|
160 |
|
|
$lanif = autodetect_interface("LAN", $fp);
|
161 |
|
|
} else if (!array_key_exists($lanif, $iflist)) {
|
162 |
1579e70f
|
Phil Davis
|
printf(gettext('%1$sInvalid interface name \'%2$s\'%3$s'), "\n", $lanif, "\n");
|
163 |
60f164f3
|
Renato Botelho
|
unset($lanif);
|
164 |
|
|
continue;
|
165 |
|
|
}
|
166 |
|
|
$ifsmallist = str_replace(" " . $lanif . " ", " ", $ifsmallist);
|
167 |
|
|
} while (!$lanif);
|
168 |
1e0b1727
|
Phil Davis
|
|
169 |
60f164f3
|
Renato Botelho
|
/* optional interfaces */
|
170 |
|
|
$i = 0;
|
171 |
|
|
$optif = array();
|
172 |
1e0b1727
|
Phil Davis
|
|
173 |
60f164f3
|
Renato Botelho
|
if ($lanif <> "") {
|
174 |
d326425e
|
Luiz Souza
|
while (strlen(trim($ifsmallist)) > 0) {
|
175 |
|
|
if (!empty($optif[$i])) {
|
176 |
60f164f3
|
Renato Botelho
|
$i++;
|
177 |
5b74202b
|
Scott Ullrich
|
}
|
178 |
60f164f3
|
Renato Botelho
|
$io = $i + 1;
|
179 |
1e0b1727
|
Phil Davis
|
|
180 |
60f164f3
|
Renato Botelho
|
if ($config['interfaces']['opt' . $io]['descr']) {
|
181 |
1579e70f
|
Phil Davis
|
printf(gettext('%1$sOptional interface %2$s description found: %3$s'), "\n", $io, $config['interfaces']['opt' . $io]['descr']);
|
182 |
5b74202b
|
Scott Ullrich
|
}
|
183 |
1e0b1727
|
Phil Davis
|
|
184 |
1579e70f
|
Phil Davis
|
printf(gettext('%1$sEnter the Optional %2$s interface name or \'a\' for auto-detection%3$s' .
|
185 |
|
|
'(%4$s a or nothing if finished):%5$s'), "\n", $io, "\n", trim($ifsmallist), " ");
|
186 |
1e0b1727
|
Phil Davis
|
|
187 |
60f164f3
|
Renato Botelho
|
$optif[$i] = chop(fgets($fp));
|
188 |
1e0b1727
|
Phil Davis
|
|
189 |
60f164f3
|
Renato Botelho
|
if ($optif[$i]) {
|
190 |
|
|
if ($optif[$i] === "a") {
|
191 |
|
|
$ad = autodetect_interface(gettext("Optional") . " " . $io, $fp);
|
192 |
|
|
if ($ad) {
|
193 |
|
|
$optif[$i] = $ad;
|
194 |
|
|
} else {
|
195 |
5b74202b
|
Scott Ullrich
|
unset($optif[$i]);
|
196 |
|
|
}
|
197 |
60f164f3
|
Renato Botelho
|
} else if (!array_key_exists($optif[$i], $iflist)) {
|
198 |
1579e70f
|
Phil Davis
|
printf(gettext('%1$sInvalid interface name \'%2$s\'%3$s'), "\n", $optif[$i], "\n");
|
199 |
5b74202b
|
Scott Ullrich
|
unset($optif[$i]);
|
200 |
60f164f3
|
Renato Botelho
|
continue;
|
201 |
5b74202b
|
Scott Ullrich
|
}
|
202 |
60f164f3
|
Renato Botelho
|
$ifsmallist = str_replace(" " . $optif[$i] . " ", " ", $ifsmallist);
|
203 |
|
|
} else {
|
204 |
|
|
unset($optif[$i]);
|
205 |
|
|
break;
|
206 |
5b74202b
|
Scott Ullrich
|
}
|
207 |
|
|
}
|
208 |
60f164f3
|
Renato Botelho
|
}
|
209 |
1e0b1727
|
Phil Davis
|
|
210 |
60f164f3
|
Renato Botelho
|
/* check for double assignments */
|
211 |
|
|
$ifarr = array_merge(array($lanif, $wanif), $optif);
|
212 |
1e0b1727
|
Phil Davis
|
|
213 |
60f164f3
|
Renato Botelho
|
for ($i = 0; $i < (count($ifarr)-1); $i++) {
|
214 |
|
|
for ($j = ($i+1); $j < count($ifarr); $j++) {
|
215 |
|
|
if ($ifarr[$i] == $ifarr[$j]) {
|
216 |
|
|
echo <<<EOD
|
217 |
1e0b1727
|
Phil Davis
|
|
218 |
530e4707
|
NOYB
|
Error: The same interface name cannot be assigned twice!
|
219 |
1e0b1727
|
Phil Davis
|
|
220 |
5b74202b
|
Scott Ullrich
|
EOD;
|
221 |
60f164f3
|
Renato Botelho
|
fclose($fp);
|
222 |
87d2f8cd
|
Luiz Souza
|
return (-2);
|
223 |
5b74202b
|
Scott Ullrich
|
}
|
224 |
|
|
}
|
225 |
60f164f3
|
Renato Botelho
|
}
|
226 |
1e0b1727
|
Phil Davis
|
|
227 |
60f164f3
|
Renato Botelho
|
echo "\n" . gettext("The interfaces will be assigned as follows:") . "\n\n";
|
228 |
1e0b1727
|
Phil Davis
|
|
229 |
60f164f3
|
Renato Botelho
|
echo "WAN -> " . $wanif . "\n";
|
230 |
|
|
if ($lanif != "") {
|
231 |
|
|
echo "LAN -> " . $lanif . "\n";
|
232 |
|
|
}
|
233 |
|
|
for ($i = 0; $i < count($optif); $i++) {
|
234 |
|
|
echo "OPT" . ($i+1) . " -> " . $optif[$i] . "\n";
|
235 |
5b74202b
|
Scott Ullrich
|
}
|
236 |
|
|
|
237 |
60f164f3
|
Renato Botelho
|
echo "\n" . gettext("Do you want to proceed [y|n]?") . " ";
|
238 |
|
|
$key = chop(fgets($fp));
|
239 |
|
|
|
240 |
5b74202b
|
Scott Ullrich
|
if (in_array($key, array('y', 'Y'))) {
|
241 |
1e0b1727
|
Phil Davis
|
if ($lanif) {
|
242 |
86d1c9c2
|
Luiz Otavio O Souza
|
if (is_array($config['interfaces']['lan'])) {
|
243 |
|
|
$upints = pfSense_interface_listget(IFF_UP);
|
244 |
|
|
if (in_array($config['interfaces']['lan']['if'], $upints))
|
245 |
|
|
interface_bring_down('lan', true);
|
246 |
|
|
}
|
247 |
1e0b1727
|
Phil Davis
|
if (!is_array($config['interfaces']['lan'])) {
|
248 |
e503c44a
|
Ermal
|
$config['interfaces']['lan'] = array();
|
249 |
1e0b1727
|
Phil Davis
|
}
|
250 |
5b74202b
|
Scott Ullrich
|
$config['interfaces']['lan']['if'] = $lanif;
|
251 |
|
|
$config['interfaces']['lan']['enable'] = true;
|
252 |
60f164f3
|
Renato Botelho
|
} elseif (!platform_booting()) {
|
253 |
5b74202b
|
Scott Ullrich
|
|
254 |
0b3799f1
|
Phil Davis
|
echo "\n" . gettext("You have chosen to remove the LAN interface.") . "\n";
|
255 |
|
|
echo "\n" . gettext("Would you like to remove the LAN IP address and \nunload the interface now [y|n]?") . " ";
|
256 |
5b74202b
|
Scott Ullrich
|
|
257 |
1e0b1727
|
Phil Davis
|
if (strcasecmp(chop(fgets($fp)), "y") == 0) {
|
258 |
|
|
if (isset($config['interfaces']['lan']) && $config['interfaces']['lan']['if']) {
|
259 |
|
|
mwexec("/sbin/ifconfig " . $config['interfaces']['lan']['if'] . " delete");
|
260 |
5b74202b
|
Scott Ullrich
|
}
|
261 |
1e0b1727
|
Phil Davis
|
}
|
262 |
|
|
if (isset($config['interfaces']['lan'])) {
|
263 |
88774881
|
Christian McDonald
|
config_del_path('interfaces/lan');
|
264 |
1e0b1727
|
Phil Davis
|
}
|
265 |
|
|
if (isset($config['dhcpd']['lan'])) {
|
266 |
88774881
|
Christian McDonald
|
config_del_path('dhcpd/lan');
|
267 |
1e0b1727
|
Phil Davis
|
}
|
268 |
bb213758
|
Chris Buechler
|
if (isset($config['dhcpdv6']['lan'])) {
|
269 |
88774881
|
Christian McDonald
|
config_del_path('dhcpdv6/lan');
|
270 |
bb213758
|
Chris Buechler
|
}
|
271 |
1e0b1727
|
Phil Davis
|
if (isset($config['interfaces']['lan']['if'])) {
|
272 |
88774881
|
Christian McDonald
|
config_del_path('interfaces/lan/if');
|
273 |
1e0b1727
|
Phil Davis
|
}
|
274 |
|
|
if (isset($config['interfaces']['wan']['blockpriv'])) {
|
275 |
88774881
|
Christian McDonald
|
config_del_path('interfaces/wan/blockpriv');
|
276 |
1e0b1727
|
Phil Davis
|
}
|
277 |
|
|
if (isset($config['shaper'])) {
|
278 |
88774881
|
Christian McDonald
|
config_del_path('shaper');
|
279 |
1e0b1727
|
Phil Davis
|
}
|
280 |
|
|
if (isset($config['ezshaper'])) {
|
281 |
88774881
|
Christian McDonald
|
config_del_path('ezshaper');
|
282 |
1e0b1727
|
Phil Davis
|
}
|
283 |
|
|
if (isset($config['nat'])) {
|
284 |
88774881
|
Christian McDonald
|
config_del_path('nat');
|
285 |
1e0b1727
|
Phil Davis
|
}
|
286 |
5b74202b
|
Scott Ullrich
|
} else {
|
287 |
1e0b1727
|
Phil Davis
|
if (isset($config['interfaces']['lan']['if'])) {
|
288 |
5b74202b
|
Scott Ullrich
|
mwexec("/sbin/ifconfig " . $config['interfaces']['lan']['if'] . " delete");
|
289 |
1e0b1727
|
Phil Davis
|
}
|
290 |
|
|
if (isset($config['interfaces']['lan'])) {
|
291 |
88774881
|
Christian McDonald
|
config_del_path('interfaces/lan');
|
292 |
1e0b1727
|
Phil Davis
|
}
|
293 |
|
|
if (isset($config['dhcpd']['lan'])) {
|
294 |
88774881
|
Christian McDonald
|
config_del_path('dhcpd/lan');
|
295 |
1e0b1727
|
Phil Davis
|
}
|
296 |
e85efdca
|
Stephen Jones
|
if (isset($config['dhcpdv6']['lan'])) {
|
297 |
88774881
|
Christian McDonald
|
config_del_path('dhcpdv6/lan');
|
298 |
e85efdca
|
Stephen Jones
|
}
|
299 |
1e0b1727
|
Phil Davis
|
if (isset($config['interfaces']['lan']['if'])) {
|
300 |
88774881
|
Christian McDonald
|
config_del_path('interfaces/lan/if');
|
301 |
1e0b1727
|
Phil Davis
|
}
|
302 |
|
|
if (isset($config['interfaces']['wan']['blockpriv'])) {
|
303 |
88774881
|
Christian McDonald
|
config_del_path('interfaces/wan/blockpriv');
|
304 |
1e0b1727
|
Phil Davis
|
}
|
305 |
|
|
if (isset($config['shaper'])) {
|
306 |
88774881
|
Christian McDonald
|
config_del_path('shaper');
|
307 |
1e0b1727
|
Phil Davis
|
}
|
308 |
|
|
if (isset($config['ezshaper'])) {
|
309 |
88774881
|
Christian McDonald
|
config_del_path('ezshaper');
|
310 |
1e0b1727
|
Phil Davis
|
}
|
311 |
|
|
if (isset($config['nat'])) {
|
312 |
88774881
|
Christian McDonald
|
config_del_path('nat');
|
313 |
1e0b1727
|
Phil Davis
|
}
|
314 |
5b74202b
|
Scott Ullrich
|
}
|
315 |
2568e151
|
Christian McDonald
|
if (preg_match(g_get('wireless_regex'), $lanif)) {
|
316 |
5b74202b
|
Scott Ullrich
|
if (is_array($config['interfaces']['lan']) &&
|
317 |
ae52d165
|
Renato Botelho
|
!is_array($config['interfaces']['lan']['wireless'])) {
|
318 |
5b74202b
|
Scott Ullrich
|
$config['interfaces']['lan']['wireless'] = array();
|
319 |
1e0b1727
|
Phil Davis
|
}
|
320 |
5b74202b
|
Scott Ullrich
|
} else {
|
321 |
1e0b1727
|
Phil Davis
|
if (isset($config['interfaces']['lan'])) {
|
322 |
88774881
|
Christian McDonald
|
config_del_path('interfaces/lan/wireless');
|
323 |
1e0b1727
|
Phil Davis
|
}
|
324 |
5b74202b
|
Scott Ullrich
|
}
|
325 |
|
|
|
326 |
86d1c9c2
|
Luiz Otavio O Souza
|
if (is_array($config['interfaces']['wan'])) {
|
327 |
|
|
$upints = pfSense_interface_listget(IFF_UP);
|
328 |
|
|
if (in_array($config['interfaces']['wan']['if'], $upints))
|
329 |
|
|
interface_bring_down('wan', true);
|
330 |
|
|
}
|
331 |
1e0b1727
|
Phil Davis
|
if (!is_array($config['interfaces']['wan'])) {
|
332 |
e503c44a
|
Ermal
|
$config['interfaces']['wan'] = array();
|
333 |
1e0b1727
|
Phil Davis
|
}
|
334 |
5b74202b
|
Scott Ullrich
|
$config['interfaces']['wan']['if'] = $wanif;
|
335 |
|
|
$config['interfaces']['wan']['enable'] = true;
|
336 |
2568e151
|
Christian McDonald
|
if (preg_match(g_get('wireless_regex'), $wanif)) {
|
337 |
5b74202b
|
Scott Ullrich
|
if (is_array($config['interfaces']['wan']) &&
|
338 |
ae52d165
|
Renato Botelho
|
!is_array($config['interfaces']['wan']['wireless'])) {
|
339 |
5b74202b
|
Scott Ullrich
|
$config['interfaces']['wan']['wireless'] = array();
|
340 |
1e0b1727
|
Phil Davis
|
}
|
341 |
5b74202b
|
Scott Ullrich
|
} else {
|
342 |
1e0b1727
|
Phil Davis
|
if (isset($config['interfaces']['wan'])) {
|
343 |
88774881
|
Christian McDonald
|
config_del_path('interfaces/wan/wireless');
|
344 |
1e0b1727
|
Phil Davis
|
}
|
345 |
5b74202b
|
Scott Ullrich
|
}
|
346 |
|
|
|
347 |
|
|
for ($i = 0; $i < count($optif); $i++) {
|
348 |
86d1c9c2
|
Luiz Otavio O Souza
|
if (is_array($config['interfaces']['opt' . ($i+1)])) {
|
349 |
|
|
$upints = pfSense_interface_listget(IFF_UP);
|
350 |
|
|
if (in_array($config['interfaces']['opt' . ($i+1)]['if'], $upints))
|
351 |
|
|
interface_bring_down('opt' . ($i+1), true);
|
352 |
|
|
}
|
353 |
1e0b1727
|
Phil Davis
|
if (!is_array($config['interfaces']['opt' . ($i+1)])) {
|
354 |
5b74202b
|
Scott Ullrich
|
$config['interfaces']['opt' . ($i+1)] = array();
|
355 |
1e0b1727
|
Phil Davis
|
}
|
356 |
5b74202b
|
Scott Ullrich
|
|
357 |
|
|
$config['interfaces']['opt' . ($i+1)]['if'] = $optif[$i];
|
358 |
|
|
|
359 |
|
|
/* wireless interface? */
|
360 |
2568e151
|
Christian McDonald
|
if (preg_match(g_get('wireless_regex'), $optif[$i])) {
|
361 |
1e0b1727
|
Phil Davis
|
if (!is_array($config['interfaces']['opt' . ($i+1)]['wireless'])) {
|
362 |
5b74202b
|
Scott Ullrich
|
$config['interfaces']['opt' . ($i+1)]['wireless'] = array();
|
363 |
1e0b1727
|
Phil Davis
|
}
|
364 |
5b74202b
|
Scott Ullrich
|
} else {
|
365 |
7e3ea4a8
|
Christian McDonald
|
config_del_path('interfaces/opt' . ($i+1) . '/wireless');
|
366 |
5b74202b
|
Scott Ullrich
|
}
|
367 |
|
|
|
368 |
62784b05
|
Ermal
|
if (empty($config['interfaces']['opt' . ($i+1)]['descr'])) {
|
369 |
|
|
$config['interfaces']['opt' . ($i+1)]['descr'] = "OPT" . ($i+1);
|
370 |
7e3ea4a8
|
Christian McDonald
|
config_del_path('interfaces/opt' . ($i+1) . '/enable');
|
371 |
62784b05
|
Ermal
|
}
|
372 |
5b74202b
|
Scott Ullrich
|
}
|
373 |
|
|
|
374 |
|
|
/* remove all other (old) optional interfaces */
|
375 |
1e0b1727
|
Phil Davis
|
for (; isset($config['interfaces']['opt' . ($i+1)]); $i++) {
|
376 |
7e3ea4a8
|
Christian McDonald
|
config_del_path('interfaces/opt' . ($i+1));
|
377 |
1e0b1727
|
Phil Davis
|
}
|
378 |
5b74202b
|
Scott Ullrich
|
|
379 |
814f9e64
|
Carlos Eduardo Ramos
|
printf(gettext("%sWriting configuration..."), "\n");
|
380 |
d18f3f6e
|
Phil Davis
|
write_config(gettext("Console assignment of interfaces"));
|
381 |
814f9e64
|
Carlos Eduardo Ramos
|
printf(gettext("done.%s"), "\n");
|
382 |
5b74202b
|
Scott Ullrich
|
|
383 |
|
|
fclose($fp);
|
384 |
c9fa8254
|
Scott Ullrich
|
|
385 |
34ee6639
|
NOYB
|
echo gettext("One moment while the settings are reloading...");
|
386 |
5b74202b
|
Scott Ullrich
|
touch("{$g['tmp_path']}/assign_complete");
|
387 |
|
|
|
388 |
20f8233d
|
Luiz Souza
|
if (file_exists("{$g['conf_path']}/trigger_initial_wizard")) {
|
389 |
75a1149e
|
Phil Davis
|
// Let the system know that the interface assign part of initial setup has been done.
|
390 |
|
|
touch("{$g['conf_path']}/assign_complete");
|
391 |
|
|
}
|
392 |
87d2f8cd
|
Luiz Souza
|
|
393 |
|
|
echo gettext(" done!") . "\n";
|
394 |
|
|
return (0);
|
395 |
5b74202b
|
Scott Ullrich
|
}
|
396 |
29bed760
|
Reid Linnemann
|
return (1);
|
397 |
5b74202b
|
Scott Ullrich
|
}
|
398 |
|
|
|
399 |
|
|
function autodetect_interface($ifname, $fp) {
|
400 |
|
|
$iflist_prev = get_interface_list("media");
|
401 |
|
|
echo <<<EOD
|
402 |
|
|
|
403 |
|
|
Connect the {$ifname} interface now and make sure that the link is up.
|
404 |
|
|
Then press ENTER to continue.
|
405 |
|
|
|
406 |
|
|
EOD;
|
407 |
|
|
fgets($fp);
|
408 |
|
|
$iflist = get_interface_list("media");
|
409 |
|
|
|
410 |
|
|
foreach ($iflist_prev as $ifn => $ifa) {
|
411 |
|
|
if (!$ifa['up'] && $iflist[$ifn]['up']) {
|
412 |
1579e70f
|
Phil Davis
|
printf(gettext('Detected link-up on interface %1$s.%2$s'), $ifn, "\n");
|
413 |
5b74202b
|
Scott Ullrich
|
return $ifn;
|
414 |
|
|
}
|
415 |
|
|
}
|
416 |
|
|
|
417 |
814f9e64
|
Carlos Eduardo Ramos
|
printf(gettext("No link-up detected.%s"), "\n");
|
418 |
5b74202b
|
Scott Ullrich
|
|
419 |
|
|
return null;
|
420 |
|
|
}
|
421 |
|
|
|
422 |
c9fa8254
|
Scott Ullrich
|
function interfaces_setup() {
|
423 |
1ae906ba
|
Reid Linnemann
|
global $iflist;
|
424 |
c9fa8254
|
Scott Ullrich
|
|
425 |
|
|
$iflist = get_interface_list();
|
426 |
|
|
}
|
427 |
|
|
|
428 |
5b74202b
|
Scott Ullrich
|
function vlan_setup() {
|
429 |
1ae906ba
|
Reid Linnemann
|
global $iflist, $config, $fp;
|
430 |
5b74202b
|
Scott Ullrich
|
|
431 |
|
|
$iflist = get_interface_list();
|
432 |
|
|
|
433 |
10ad2540
|
Reid Linnemann
|
$vlancfg = config_get_path('vlans/vlan');
|
434 |
|
|
if (is_array($vlancfg) && count($vlancfg)) {
|
435 |
0b3799f1
|
Phil Davis
|
echo "\n" . gettext("WARNING: all existing VLANs will be cleared if you proceed!") . "\n";
|
436 |
|
|
echo "\n" . gettext("Do you want to proceed [y|n]?") . " ";
|
437 |
5b74202b
|
Scott Ullrich
|
|
438 |
1e0b1727
|
Phil Davis
|
if (strcasecmp(chop(fgets($fp)), "y") != 0) {
|
439 |
|
|
return;
|
440 |
|
|
}
|
441 |
5b74202b
|
Scott Ullrich
|
}
|
442 |
|
|
|
443 |
45f95753
|
jim-p
|
init_config_arr(array('vlans', 'vlan'));
|
444 |
5b74202b
|
Scott Ullrich
|
echo "\n";
|
445 |
|
|
|
446 |
|
|
$vlanif = 0;
|
447 |
|
|
|
448 |
|
|
while (1) {
|
449 |
|
|
$vlan = array();
|
450 |
|
|
|
451 |
814f9e64
|
Carlos Eduardo Ramos
|
echo "\n\n" . gettext("VLAN Capable interfaces:") . "\n\n";
|
452 |
1e0b1727
|
Phil Davis
|
if (!is_array($iflist)) {
|
453 |
814f9e64
|
Carlos Eduardo Ramos
|
echo gettext("No interfaces found!") . "\n";
|
454 |
5b74202b
|
Scott Ullrich
|
} else {
|
455 |
6c07db48
|
Phil Davis
|
$vlan_capable = 0;
|
456 |
5b74202b
|
Scott Ullrich
|
foreach ($iflist as $iface => $ifa) {
|
457 |
08fe7601
|
Renato Botelho
|
echo sprintf("% -8s%s%s\n", $iface, $ifa['mac'],
|
458 |
|
|
$ifa['up'] ? " (up)" : "");
|
459 |
|
|
$vlan_capable++;
|
460 |
5b74202b
|
Scott Ullrich
|
}
|
461 |
|
|
}
|
462 |
|
|
|
463 |
1e0b1727
|
Phil Davis
|
if ($vlan_capable == 0) {
|
464 |
814f9e64
|
Carlos Eduardo Ramos
|
echo gettext("No VLAN capable interfaces detected.") . "\n";
|
465 |
5b74202b
|
Scott Ullrich
|
return;
|
466 |
|
|
}
|
467 |
|
|
|
468 |
814f9e64
|
Carlos Eduardo Ramos
|
echo "\n" . gettext("Enter the parent interface name for the new VLAN (or nothing if finished):") . " ";
|
469 |
5b74202b
|
Scott Ullrich
|
$vlan['if'] = chop(fgets($fp));
|
470 |
|
|
|
471 |
|
|
if ($vlan['if']) {
|
472 |
08fe7601
|
Renato Botelho
|
if (!array_key_exists($vlan['if'], $iflist)) {
|
473 |
|
|
printf(gettext(
|
474 |
|
|
'%1$sInvalid interface name \'%2$s\'%3$s'),
|
475 |
|
|
"\n", $vlan['if'], "\n");
|
476 |
5b74202b
|
Scott Ullrich
|
continue;
|
477 |
|
|
}
|
478 |
|
|
} else {
|
479 |
|
|
break;
|
480 |
|
|
}
|
481 |
|
|
|
482 |
814f9e64
|
Carlos Eduardo Ramos
|
echo gettext("Enter the VLAN tag (1-4094):") . " ";
|
483 |
5b74202b
|
Scott Ullrich
|
$vlan['tag'] = chop(fgets($fp));
|
484 |
12bcf7e9
|
Luiz Souza
|
$vlan['vlanif'] = vlan_interface($vlan);
|
485 |
5b74202b
|
Scott Ullrich
|
if (!is_numericint($vlan['tag']) || ($vlan['tag'] < 1) || ($vlan['tag'] > 4094)) {
|
486 |
1579e70f
|
Phil Davis
|
printf(gettext('%1$sInvalid VLAN tag \'%2$s\'%3$s'), "\n", $vlan['tag'], "\n");
|
487 |
5b74202b
|
Scott Ullrich
|
continue;
|
488 |
|
|
}
|
489 |
1e0b1727
|
Phil Davis
|
|
490 |
ff4665f0
|
Chris Buechler
|
if (is_array($config['vlans']['vlan'])) {
|
491 |
ac0a027f
|
Christian McDonald
|
foreach (config_get_path('vlans/vlan', []) as $existingvlan) {
|
492 |
ff4665f0
|
Chris Buechler
|
if ($vlan['if'] == $existingvlan['if'] && $vlan['tag'] == $existingvlan['tag']) {
|
493 |
|
|
printf("\n\n" . gettext("This parent interface and VLAN already created."));
|
494 |
|
|
continue 2;
|
495 |
|
|
}
|
496 |
|
|
}
|
497 |
|
|
}
|
498 |
5b74202b
|
Scott Ullrich
|
$config['vlans']['vlan'][] = $vlan;
|
499 |
|
|
$vlanif++;
|
500 |
|
|
}
|
501 |
|
|
}
|
502 |
|
|
|
503 |
b49e6c01
|
Phil Davis
|
function check_for_alternate_interfaces() {
|
504 |
|
|
global $config;
|
505 |
|
|
|
506 |
|
|
// If the WAN and/or LAN devices in the factory default config do not exist,
|
507 |
|
|
// then look for alternate devices.
|
508 |
|
|
// This lets many systems boot a factory default config without being
|
509 |
|
|
// forced to do interface assignment on the console.
|
510 |
|
|
|
511 |
|
|
$specplatform = system_identify_specific_platform();
|
512 |
|
|
$default_device = array();
|
513 |
|
|
|
514 |
|
|
// If we recognise the platform, then specify the devices directly.
|
515 |
|
|
switch ($specplatform['name']) {
|
516 |
|
|
case 'alix':
|
517 |
|
|
$default_device['wan'] = "vr1";
|
518 |
|
|
$default_device['lan'] = "vr0";
|
519 |
|
|
break;
|
520 |
|
|
case 'APU':
|
521 |
|
|
$default_device['wan'] = "re1";
|
522 |
|
|
$default_device['lan'] = "re2";
|
523 |
|
|
break;
|
524 |
f301aa59
|
jim-p
|
case 'Turbot Dual-E':
|
525 |
|
|
$config['interfaces']['wan']['if'] = 'igb0';
|
526 |
|
|
$config['interfaces']['lan']['if'] = 'igb1';
|
527 |
|
|
break;
|
528 |
|
|
case 'C2758':
|
529 |
|
|
$config['interfaces']['wan']['if'] = 'igb0';
|
530 |
|
|
$config['interfaces']['lan']['if'] = 'igb1';
|
531 |
|
|
$config['interfaces']['opt1'] = array(
|
532 |
|
|
'if' => 'igb2',
|
533 |
|
|
'descr' => 'OPT1'
|
534 |
|
|
);
|
535 |
|
|
$config['interfaces']['opt2'] = array(
|
536 |
|
|
'if' => 'igb3',
|
537 |
|
|
'descr' => 'OPT2'
|
538 |
|
|
);
|
539 |
|
|
break;
|
540 |
b49e6c01
|
Phil Davis
|
case 'RCC-VE':
|
541 |
f301aa59
|
jim-p
|
case 'SG-2220':
|
542 |
3c3f9397
|
Luiz Otavio O Souza
|
/* SG-4860 or SG-8860 */
|
543 |
|
|
if (does_interface_exist('igb4')) {
|
544 |
|
|
$config['interfaces']['wan']['if'] = 'igb1';
|
545 |
|
|
$config['interfaces']['lan']['if'] = 'igb0';
|
546 |
|
|
} else {
|
547 |
|
|
$config['interfaces']['wan']['if'] = 'igb0';
|
548 |
|
|
$config['interfaces']['lan']['if'] = 'igb1';
|
549 |
|
|
}
|
550 |
f301aa59
|
jim-p
|
/* It has 4 ports */
|
551 |
|
|
if (does_interface_exist('igb3')) {
|
552 |
|
|
$config['interfaces']['opt1'] = array(
|
553 |
|
|
'if' => 'igb2',
|
554 |
|
|
'descr' => 'OPT1'
|
555 |
|
|
);
|
556 |
|
|
$config['interfaces']['opt2'] = array(
|
557 |
|
|
'if' => 'igb3',
|
558 |
|
|
'descr' => 'OPT2'
|
559 |
|
|
);
|
560 |
|
|
}
|
561 |
|
|
/* It has 6 ports */
|
562 |
|
|
if (does_interface_exist('igb5')) {
|
563 |
|
|
$config['interfaces']['opt3'] = array(
|
564 |
|
|
'if' => 'igb4',
|
565 |
|
|
'descr' => 'OPT3'
|
566 |
|
|
);
|
567 |
|
|
$config['interfaces']['opt4'] = array(
|
568 |
|
|
'if' => 'igb5',
|
569 |
|
|
'descr' => 'OPT4'
|
570 |
|
|
);
|
571 |
|
|
}
|
572 |
b49e6c01
|
Phil Davis
|
break;
|
573 |
df945787
|
Luiz Otavio O Souza
|
case '1537':
|
574 |
f301aa59
|
jim-p
|
if (does_interface_exist('cxl0')) {
|
575 |
|
|
/* It has 10G SFP+ addon */
|
576 |
|
|
$config['interfaces']['wan']['if'] = 'cxl0';
|
577 |
|
|
$config['interfaces']['lan']['if'] = 'cxl1';
|
578 |
|
|
$config['interfaces']['opt1'] = array(
|
579 |
|
|
'if' => 'igb0',
|
580 |
|
|
'descr' => 'OPT1'
|
581 |
|
|
);
|
582 |
|
|
$config['interfaces']['opt2'] = array(
|
583 |
|
|
'enable' => true,
|
584 |
|
|
'if' => 'ix0',
|
585 |
|
|
'descr' => 'OPT2'
|
586 |
|
|
);
|
587 |
|
|
$config['interfaces']['opt3'] = array(
|
588 |
|
|
'if' => 'igb1',
|
589 |
|
|
'descr' => 'OPT3'
|
590 |
|
|
);
|
591 |
|
|
$config['interfaces']['opt4'] = array(
|
592 |
|
|
'enable' => true,
|
593 |
|
|
'if' => 'ix1',
|
594 |
|
|
'descr' => 'OPT4'
|
595 |
|
|
);
|
596 |
|
|
} elseif (does_interface_exist('igb4')) {
|
597 |
|
|
/* It has 4 port ethernet addon */
|
598 |
|
|
$config['interfaces']['wan']['if'] = 'igb4';
|
599 |
|
|
$config['interfaces']['lan']['if'] = 'igb5';
|
600 |
|
|
$config['interfaces']['opt1'] = array(
|
601 |
|
|
'enable' => true,
|
602 |
|
|
'if' => 'ix0',
|
603 |
|
|
'descr' => 'OPT1'
|
604 |
|
|
);
|
605 |
|
|
$config['interfaces']['opt2'] = array(
|
606 |
|
|
'enable' => true,
|
607 |
|
|
'if' => 'ix1',
|
608 |
|
|
'descr' => 'OPT2'
|
609 |
|
|
);
|
610 |
|
|
$config['interfaces']['opt3'] = array(
|
611 |
|
|
'if' => 'igb3',
|
612 |
|
|
'descr' => 'OPT3'
|
613 |
|
|
);
|
614 |
|
|
$config['interfaces']['opt4'] = array(
|
615 |
|
|
'if' => 'igb2',
|
616 |
|
|
'descr' => 'OPT4'
|
617 |
|
|
);
|
618 |
|
|
$config['interfaces']['opt5'] = array(
|
619 |
|
|
'if' => 'igb1',
|
620 |
|
|
'descr' => 'OPT5'
|
621 |
|
|
);
|
622 |
|
|
$config['interfaces']['opt6'] = array(
|
623 |
|
|
'if' => 'igb0',
|
624 |
|
|
'descr' => 'OPT6'
|
625 |
|
|
);
|
626 |
|
|
} else {
|
627 |
|
|
$config['interfaces']['wan']['if'] = 'igb0';
|
628 |
|
|
$config['interfaces']['lan']['if'] = 'igb1';
|
629 |
|
|
$config['interfaces']['opt1'] = array(
|
630 |
|
|
'enable' => true,
|
631 |
|
|
'if' => 'ix0',
|
632 |
|
|
'descr' => 'OPT1'
|
633 |
|
|
);
|
634 |
|
|
$config['interfaces']['opt2'] = array(
|
635 |
|
|
'enable' => true,
|
636 |
|
|
'if' => 'ix1',
|
637 |
|
|
'descr' => 'OPT2'
|
638 |
|
|
);
|
639 |
|
|
}
|
640 |
|
|
break;
|
641 |
df945787
|
Luiz Otavio O Souza
|
case '1540':
|
642 |
|
|
case '1541':
|
643 |
f301aa59
|
jim-p
|
if (does_interface_exist('igb2')) {
|
644 |
|
|
/* It has 4 port Intel 1Gb expansion card */
|
645 |
|
|
$config['interfaces']['wan']['if'] = 'igb4';
|
646 |
|
|
$config['interfaces']['lan']['if'] = 'igb5';
|
647 |
|
|
$config['interfaces']['opt1'] = array(
|
648 |
|
|
'enable' => true,
|
649 |
|
|
'if' => 'ix0',
|
650 |
|
|
'descr' => 'OPT1'
|
651 |
|
|
);
|
652 |
|
|
$config['interfaces']['opt2'] = array(
|
653 |
|
|
'enable' => true,
|
654 |
|
|
'if' => 'ix1',
|
655 |
|
|
'descr' => 'OPT2'
|
656 |
|
|
);
|
657 |
|
|
$config['interfaces']['opt3'] = array(
|
658 |
|
|
'if' => 'igb3',
|
659 |
|
|
'descr' => 'OPT3'
|
660 |
|
|
);
|
661 |
|
|
$config['interfaces']['opt4'] = array(
|
662 |
|
|
'if' => 'igb2',
|
663 |
|
|
'descr' => 'OPT4'
|
664 |
|
|
);
|
665 |
|
|
$config['interfaces']['opt5'] = array(
|
666 |
|
|
'if' => 'igb1',
|
667 |
|
|
'descr' => 'OPT5'
|
668 |
|
|
);
|
669 |
|
|
$config['interfaces']['opt6'] = array(
|
670 |
|
|
'if' => 'igb0',
|
671 |
|
|
'descr' => 'OPT6'
|
672 |
|
|
);
|
673 |
|
|
} elseif (does_interface_exist('cxl0')) {
|
674 |
|
|
/* It has 2 port Chelsio 10Gb expansion card */
|
675 |
|
|
$config['interfaces']['wan']['if'] = 'cxl0';
|
676 |
|
|
$config['interfaces']['lan']['if'] = 'cxl1';
|
677 |
|
|
$config['interfaces']['opt1'] = array(
|
678 |
|
|
'if' => 'igb0',
|
679 |
|
|
'descr' => 'OPT1'
|
680 |
|
|
);
|
681 |
|
|
$config['interfaces']['opt2'] = array(
|
682 |
|
|
'enable' => true,
|
683 |
|
|
'if' => 'ix0',
|
684 |
|
|
'descr' => 'OPT2'
|
685 |
|
|
);
|
686 |
|
|
$config['interfaces']['opt3'] = array(
|
687 |
|
|
'if' => 'igb1',
|
688 |
|
|
'descr' => 'OPT3'
|
689 |
|
|
);
|
690 |
|
|
$config['interfaces']['opt4'] = array(
|
691 |
|
|
'enable' => true,
|
692 |
|
|
'if' => 'ix1',
|
693 |
|
|
'descr' => 'OPT4'
|
694 |
|
|
);
|
695 |
|
|
} else {
|
696 |
|
|
$config['interfaces']['wan']['if'] = 'ix0';
|
697 |
|
|
$config['interfaces']['lan']['if'] = 'ix1';
|
698 |
|
|
$config['interfaces']['opt1'] = array(
|
699 |
|
|
'if' => 'igb0',
|
700 |
|
|
'descr' => 'OPT1'
|
701 |
|
|
);
|
702 |
|
|
$config['interfaces']['opt2'] = array(
|
703 |
|
|
'if' => 'igb1',
|
704 |
|
|
'descr' => 'OPT2'
|
705 |
|
|
);
|
706 |
|
|
}
|
707 |
|
|
break;
|
708 |
|
|
case 'RCC':
|
709 |
|
|
if (does_interface_exist('igb7')) {
|
710 |
|
|
// has quad port expansion card
|
711 |
|
|
$config['interfaces']['opt5'] = array(
|
712 |
|
|
'if' => 'igb0',
|
713 |
|
|
'descr' => 'OPT5'
|
714 |
|
|
);
|
715 |
|
|
$config['interfaces']['opt6'] = array(
|
716 |
|
|
'if' => 'igb1',
|
717 |
|
|
'descr' => 'OPT6'
|
718 |
|
|
);
|
719 |
|
|
$config['interfaces']['opt7'] = array(
|
720 |
|
|
'if' => 'igb2',
|
721 |
|
|
'descr' => 'OPT7'
|
722 |
|
|
);
|
723 |
|
|
$config['interfaces']['opt8'] = array(
|
724 |
|
|
'if' => 'igb3',
|
725 |
|
|
'descr' => 'OPT8'
|
726 |
|
|
);
|
727 |
|
|
$config['interfaces']['wan']['if'] = 'igb4';
|
728 |
|
|
$config['interfaces']['lan']['if'] = 'igb6';
|
729 |
|
|
$config['interfaces']['opt1'] = array(
|
730 |
|
|
'if' => 'igb5',
|
731 |
|
|
'descr' => 'OPT1'
|
732 |
|
|
);
|
733 |
|
|
$config['interfaces']['opt2'] = array(
|
734 |
|
|
'if' => 'igb7',
|
735 |
|
|
'descr' => 'OPT2'
|
736 |
|
|
);
|
737 |
|
|
} else {
|
738 |
|
|
$config['interfaces']['wan']['if'] = 'igb0';
|
739 |
|
|
$config['interfaces']['lan']['if'] = 'igb2';
|
740 |
|
|
$config['interfaces']['opt1'] = array(
|
741 |
|
|
'if' => 'igb1',
|
742 |
|
|
'descr' => 'OPT1'
|
743 |
|
|
);
|
744 |
|
|
$config['interfaces']['opt2'] = array(
|
745 |
|
|
'if' => 'igb3',
|
746 |
|
|
'descr' => 'OPT2'
|
747 |
|
|
);
|
748 |
|
|
}
|
749 |
|
|
$config['interfaces']['opt3'] = array(
|
750 |
|
|
'enable' => true,
|
751 |
|
|
'if' => 'ix0',
|
752 |
|
|
'descr' => 'OPT3'
|
753 |
|
|
);
|
754 |
|
|
$config['interfaces']['opt4'] = array(
|
755 |
|
|
'enable' => true,
|
756 |
|
|
'if' => 'ix1',
|
757 |
|
|
'descr' => 'OPT4'
|
758 |
|
|
);
|
759 |
|
|
break;
|
760 |
df945787
|
Luiz Otavio O Souza
|
case '5100':
|
761 |
8b3345dc
|
Renato Botelho
|
$config['interfaces']['wan']['if'] = 'igb0';
|
762 |
|
|
$config['interfaces']['lan']['if'] = 'igb1';
|
763 |
f301aa59
|
jim-p
|
$config['interfaces']['opt1'] = array(
|
764 |
|
|
'enable' => true,
|
765 |
|
|
'if' => 'ix0',
|
766 |
|
|
'descr' => 'OPT1'
|
767 |
|
|
);
|
768 |
|
|
$config['interfaces']['opt2'] = array(
|
769 |
|
|
'enable' => true,
|
770 |
|
|
'if' => 'ix1',
|
771 |
|
|
'descr' => 'OPT2'
|
772 |
|
|
);
|
773 |
|
|
$config['interfaces']['opt3'] = array(
|
774 |
|
|
'enable' => true,
|
775 |
|
|
'if' => 'ix2',
|
776 |
|
|
'descr' => 'OPT3'
|
777 |
|
|
);
|
778 |
|
|
$config['interfaces']['opt4'] = array(
|
779 |
|
|
'enable' => true,
|
780 |
|
|
'if' => 'ix3',
|
781 |
|
|
'descr' => 'OPT4'
|
782 |
|
|
);
|
783 |
f26a816b
|
Renato Botelho do Couto
|
break;
|
784 |
b49e6c01
|
Phil Davis
|
default:
|
785 |
|
|
$default_device['wan'] = "";
|
786 |
|
|
$default_device['lan'] = "";
|
787 |
|
|
break;
|
788 |
|
|
}
|
789 |
|
|
|
790 |
|
|
// Other common device names can be put here and will be looked for
|
791 |
|
|
// if the system was not one of the known platforms.
|
792 |
|
|
$other_devices_arr['wan'] = array("vr1", "re1", "igb0", "em0");
|
793 |
|
|
$other_devices_arr['lan'] = array("vr0", "re2", "igb1", "em1");
|
794 |
|
|
$interface_assignment_changed = false;
|
795 |
|
|
|
796 |
|
|
foreach ($other_devices_arr as $ifname => $other_devices) {
|
797 |
|
|
if (!does_interface_exist($config['interfaces'][$ifname]['if'])) {
|
798 |
|
|
if (does_interface_exist($default_device[$ifname])) {
|
799 |
|
|
$config['interfaces'][$ifname]['if'] = $default_device[$ifname];
|
800 |
|
|
$interface_assignment_changed = true;
|
801 |
|
|
} else {
|
802 |
|
|
foreach ($other_devices as $other_device) {
|
803 |
|
|
if (does_interface_exist($other_device)) {
|
804 |
|
|
$config['interfaces'][$ifname]['if'] = $other_device;
|
805 |
|
|
$interface_assignment_changed = true;
|
806 |
|
|
break;
|
807 |
|
|
}
|
808 |
|
|
}
|
809 |
|
|
}
|
810 |
|
|
}
|
811 |
|
|
}
|
812 |
|
|
|
813 |
|
|
if ($interface_assignment_changed) {
|
814 |
|
|
write_config("Factory default boot detected WAN " . $config['interfaces']['wan']['if'] . " and LAN " . $config['interfaces']['lan']['if']);
|
815 |
|
|
}
|
816 |
|
|
}
|
817 |
|
|
|
818 |
814f9e64
|
Carlos Eduardo Ramos
|
?>
|