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