| 1 |
/* |
|---|
| 2 |
* sysinit.c |
|---|
| 3 |
* |
|---|
| 4 |
* Copyright (C) 2007 Sebastian Gottschall <gottschall@dd-wrt.com> |
|---|
| 5 |
* |
|---|
| 6 |
* This program is free software; you can redistribute it and/or |
|---|
| 7 |
* modify it under the terms of the GNU General Public License |
|---|
| 8 |
* as published by the Free Software Foundation; either version 2 |
|---|
| 9 |
* of the License. |
|---|
| 10 |
* |
|---|
| 11 |
* This program is distributed in the hope that it will be useful, |
|---|
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 14 |
* GNU General Public License for more details. |
|---|
| 15 |
* |
|---|
| 16 |
* You should have received a copy of the GNU General Public License |
|---|
| 17 |
* along with this program; if not, write to the Free Software |
|---|
| 18 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|---|
| 19 |
* |
|---|
| 20 |
* $Id: |
|---|
| 21 |
*/ |
|---|
| 22 |
|
|---|
| 23 |
#include <stdio.h> |
|---|
| 24 |
#include <stdlib.h> |
|---|
| 25 |
#include <limits.h> |
|---|
| 26 |
#include <time.h> |
|---|
| 27 |
#include <unistd.h> |
|---|
| 28 |
#include <errno.h> |
|---|
| 29 |
#include <syslog.h> |
|---|
| 30 |
#include <signal.h> |
|---|
| 31 |
#include <string.h> |
|---|
| 32 |
#include <termios.h> |
|---|
| 33 |
|
|---|
| 34 |
#include <sys/klog.h> |
|---|
| 35 |
#include <sys/types.h> |
|---|
| 36 |
#include <sys/mount.h> |
|---|
| 37 |
#include <sys/reboot.h> |
|---|
| 38 |
#include <sys/stat.h> |
|---|
| 39 |
#include <sys/sysmacros.h> |
|---|
| 40 |
#include <sys/time.h> |
|---|
| 41 |
#include <sys/utsname.h> |
|---|
| 42 |
#include <sys/wait.h> |
|---|
| 43 |
#include <dirent.h> |
|---|
| 44 |
|
|---|
| 45 |
#include <epivers.h> |
|---|
| 46 |
#include <bcmnvram.h> |
|---|
| 47 |
#include <mtd.h> |
|---|
| 48 |
#include <shutils.h> |
|---|
| 49 |
#include <rc.h> |
|---|
| 50 |
#include <netconf.h> |
|---|
| 51 |
#include <nvparse.h> |
|---|
| 52 |
#include <bcmdevs.h> |
|---|
| 53 |
|
|---|
| 54 |
#include <wlutils.h> |
|---|
| 55 |
#include <utils.h> |
|---|
| 56 |
#include <cyutils.h> |
|---|
| 57 |
#include <code_pattern.h> |
|---|
| 58 |
#include <cy_conf.h> |
|---|
| 59 |
// #include <mkfiles.h> |
|---|
| 60 |
#include <typedefs.h> |
|---|
| 61 |
#include <bcmnvram.h> |
|---|
| 62 |
#include <bcmutils.h> |
|---|
| 63 |
#include <shutils.h> |
|---|
| 64 |
#include <wlutils.h> |
|---|
| 65 |
#include <cy_conf.h> |
|---|
| 66 |
#include <cymac.h> |
|---|
| 67 |
// #include <ledcontrol.h> |
|---|
| 68 |
|
|---|
| 69 |
#define WL_IOCTL(name, cmd, buf, len) (ret = wl_ioctl((name), (cmd), (buf), (len))) |
|---|
| 70 |
|
|---|
| 71 |
#define TXPWR_MAX 251 |
|---|
| 72 |
#define TXPWR_DEFAULT 28 |
|---|
| 73 |
|
|---|
| 74 |
void start_restore_defaults(void); |
|---|
| 75 |
static void rc_signal(int sig); |
|---|
| 76 |
extern void start_overclocking(void); |
|---|
| 77 |
extern int check_cfe_nv(void); |
|---|
| 78 |
extern int check_pmon_nv(void); |
|---|
| 79 |
static void unset_nvram(void); |
|---|
| 80 |
void start_nvram(void); |
|---|
| 81 |
|
|---|
| 82 |
extern struct nvram_tuple *srouter_defaults; |
|---|
| 83 |
extern void load_defaults(void); |
|---|
| 84 |
extern void free_defaults(void); |
|---|
| 85 |
|
|---|
| 86 |
int endswith(char *str, char *cmp) |
|---|
| 87 |
{ |
|---|
| 88 |
int cmp_len, str_len, i; |
|---|
| 89 |
|
|---|
| 90 |
cmp_len = strlen(cmp); |
|---|
| 91 |
str_len = strlen(str); |
|---|
| 92 |
if (cmp_len > str_len) |
|---|
| 93 |
return (0); |
|---|
| 94 |
for (i = 0; i < cmp_len; i++) { |
|---|
| 95 |
if (str[(str_len - 1) - i] != cmp[(cmp_len - 1) - i]) |
|---|
| 96 |
return (0); |
|---|
| 97 |
} |
|---|
| 98 |
return (1); |
|---|
| 99 |
} |
|---|
| 100 |
|
|---|
| 101 |
#ifdef HAVE_MACBIND |
|---|
| 102 |
#include "../../../opt/mac.h" |
|---|
| 103 |
#endif |
|---|
| 104 |
void runStartup(char *folder, char *extension) |
|---|
| 105 |
{ |
|---|
| 106 |
struct dirent *entry; |
|---|
| 107 |
DIR *directory; |
|---|
| 108 |
|
|---|
| 109 |
directory = opendir(folder); |
|---|
| 110 |
if (directory == NULL) { |
|---|
| 111 |
return; |
|---|
| 112 |
} |
|---|
| 113 |
// list all files in this directory |
|---|
| 114 |
while ((entry = readdir(directory)) != NULL) { |
|---|
| 115 |
if (endswith(entry->d_name, extension)) { |
|---|
| 116 |
#ifdef HAVE_REGISTER |
|---|
| 117 |
if (!isregistered_real()) { |
|---|
| 118 |
if (endswith |
|---|
| 119 |
(entry->d_name, "wdswatchdog.startup")) |
|---|
| 120 |
continue; |
|---|
| 121 |
if (endswith |
|---|
| 122 |
(entry->d_name, "schedulerb.startup")) |
|---|
| 123 |
continue; |
|---|
| 124 |
if (endswith |
|---|
| 125 |
(entry->d_name, "proxywatchdog.startup")) |
|---|
| 126 |
continue; |
|---|
| 127 |
} |
|---|
| 128 |
#endif |
|---|
| 129 |
sysprintf("%s/%s 2>&1 > /dev/null&\n", folder, |
|---|
| 130 |
entry->d_name); |
|---|
| 131 |
// execute script |
|---|
| 132 |
} |
|---|
| 133 |
} |
|---|
| 134 |
closedir(directory); |
|---|
| 135 |
} |
|---|
| 136 |
|
|---|
| 137 |
/* |
|---|
| 138 |
* SeG dd-wrt addition for module startup scripts |
|---|
| 139 |
*/ |
|---|
| 140 |
void start_modules(void) |
|---|
| 141 |
{ |
|---|
| 142 |
runStartup("/etc/config", ".startup"); |
|---|
| 143 |
|
|---|
| 144 |
#ifdef HAVE_RB500 |
|---|
| 145 |
runStartup("/usr/local/etc/config", ".startup"); // if available |
|---|
| 146 |
#elif HAVE_X86 |
|---|
| 147 |
runStartup("/usr/local/etc/config", ".startup"); // if available |
|---|
| 148 |
#else |
|---|
| 149 |
runStartup("/jffs/etc/config", ".startup"); // if available |
|---|
| 150 |
runStartup("/mmc/etc/config", ".startup"); // if available |
|---|
| 151 |
#endif |
|---|
| 152 |
return; |
|---|
| 153 |
} |
|---|
| 154 |
|
|---|
| 155 |
void start_wanup(void) |
|---|
| 156 |
{ |
|---|
| 157 |
runStartup("/etc/config", ".wanup"); |
|---|
| 158 |
#ifdef HAVE_RB500 |
|---|
| 159 |
runStartup("/usr/local/etc/config", ".wanup"); // if available |
|---|
| 160 |
#elif HAVE_X86 |
|---|
| 161 |
runStartup("/usr/local/etc/config", ".wanup"); // if available |
|---|
| 162 |
#else |
|---|
| 163 |
runStartup("/jffs/etc/config", ".wanup"); // if available |
|---|
| 164 |
runStartup("/mmc/etc/config", ".wanup"); // if available |
|---|
| 165 |
runStartup("/tmp/etc/config", ".wanup"); // if available |
|---|
| 166 |
#endif |
|---|
| 167 |
return; |
|---|
| 168 |
} |
|---|
| 169 |
|
|---|
| 170 |
void start_run_rc_startup(void) |
|---|
| 171 |
{ |
|---|
| 172 |
create_rc_file(RC_STARTUP); |
|---|
| 173 |
if (f_exists("/tmp/.rc_startup")) |
|---|
| 174 |
system("/tmp/.rc_startup"); |
|---|
| 175 |
return; |
|---|
| 176 |
} |
|---|
| 177 |
|
|---|
| 178 |
void start_run_rc_shutdown(void) |
|---|
| 179 |
{ |
|---|
| 180 |
create_rc_file(RC_SHUTDOWN); |
|---|
| 181 |
if (f_exists("/tmp/.rc_shutdown")) |
|---|
| 182 |
system("/tmp/.rc_shutdown"); |
|---|
| 183 |
return; |
|---|
| 184 |
} |
|---|
| 185 |
|
|---|
| 186 |
int create_rc_file(char *name) |
|---|
| 187 |
{ |
|---|
| 188 |
FILE *fp; |
|---|
| 189 |
char *p = nvram_safe_get(name); |
|---|
| 190 |
char tmp_file[100] = { 0 }; |
|---|
| 191 |
|
|---|
| 192 |
if ((void *)0 == name || 0 == p[0]) |
|---|
| 193 |
return -1; |
|---|
| 194 |
|
|---|
| 195 |
snprintf(tmp_file, 100, "/tmp/.%s", name); |
|---|
| 196 |
unlink(tmp_file); |
|---|
| 197 |
|
|---|
| 198 |
fp = fopen(tmp_file, "w"); |
|---|
| 199 |
if (fp) { |
|---|
| 200 |
// filter Windows <cr>ud |
|---|
| 201 |
while (*p) { |
|---|
| 202 |
if (*p != 0x0d) |
|---|
| 203 |
fprintf(fp, "%c", *p); |
|---|
| 204 |
p++; |
|---|
| 205 |
} |
|---|
| 206 |
} |
|---|
| 207 |
fclose(fp); |
|---|
| 208 |
chmod(tmp_file, 0700); |
|---|
| 209 |
|
|---|
| 210 |
return 0; |
|---|
| 211 |
} |
|---|
| 212 |
|
|---|
| 213 |
static void ses_cleanup(void) |
|---|
| 214 |
{ |
|---|
| 215 |
/* |
|---|
| 216 |
* well known event to cleanly initialize state machine |
|---|
| 217 |
*/ |
|---|
| 218 |
nvram_set("ses_event", "2"); |
|---|
| 219 |
|
|---|
| 220 |
/* |
|---|
| 221 |
* Delete lethal dynamically generated variables |
|---|
| 222 |
*/ |
|---|
| 223 |
nvram_unset("ses_bridge_disable"); |
|---|
| 224 |
} |
|---|
| 225 |
|
|---|
| 226 |
static void ses_restore_defaults(void) |
|---|
| 227 |
{ |
|---|
| 228 |
char tmp[100], prefix[] = "wlXXXXXXXXXX_ses_"; |
|---|
| 229 |
int i; |
|---|
| 230 |
|
|---|
| 231 |
/* |
|---|
| 232 |
* Delete dynamically generated variables |
|---|
| 233 |
*/ |
|---|
| 234 |
for (i = 0; i < MAX_NVPARSE; i++) { |
|---|
| 235 |
sprintf(prefix, "wl%d_ses_", i); |
|---|
| 236 |
nvram_unset(strcat_r(prefix, "ssid", tmp)); |
|---|
| 237 |
nvram_unset(strcat_r(prefix, "closed", tmp)); |
|---|
| 238 |
nvram_unset(strcat_r(prefix, "wpa_psk", tmp)); |
|---|
| 239 |
nvram_unset(strcat_r(prefix, "auth", tmp)); |
|---|
| 240 |
nvram_unset(strcat_r(prefix, "wep", tmp)); |
|---|
| 241 |
nvram_unset(strcat_r(prefix, "auth_mode", tmp)); |
|---|
| 242 |
nvram_unset(strcat_r(prefix, "crypto", tmp)); |
|---|
| 243 |
nvram_unset(strcat_r(prefix, "akm", tmp)); |
|---|
| 244 |
} |
|---|
| 245 |
} |
|---|
| 246 |
|
|---|
| 247 |
void start_restore_defaults(void) |
|---|
| 248 |
{ |
|---|
| 249 |
|
|---|
| 250 |
#ifdef HAVE_RB500 |
|---|
| 251 |
struct nvram_tuple generic[] = { |
|---|
| 252 |
{"lan_ifname", "br0", 0}, |
|---|
| 253 |
{"lan_ifnames", |
|---|
| 254 |
"eth1 eth2 eth3 eth4 eth5 eth6 eth7 eth8 ath0 ath1 ath2 ath3 ath4 ath5", |
|---|
| 255 |
0}, |
|---|
| 256 |
{"wan_ifname", "eth0", 0}, |
|---|
| 257 |
{"wan_ifnames", "eth0", 0}, |
|---|
| 258 |
{0, 0, 0} |
|---|
| 259 |
}; |
|---|
| 260 |
#elif HAVE_GEMTEK |
|---|
| 261 |
struct nvram_tuple generic[] = { |
|---|
| 262 |
{"lan_ifname", "br0", 0}, |
|---|
| 263 |
{"lan_ifnames", "eth1 ath0", 0}, |
|---|
| 264 |
{"wan_ifname", "eth0", 0}, |
|---|
| 265 |
{"wan_ifnames", "eth0", 0}, |
|---|
| 266 |
{0, 0, 0} |
|---|
| 267 |
}; |
|---|
| 268 |
#elif HAVE_RT2880 |
|---|
| 269 |
struct nvram_tuple generic[] = { |
|---|
| 270 |
{"lan_ifname", "br0", 0}, |
|---|
| 271 |
{"lan_ifnames", "vlan1 vlan2 ra0", |
|---|
| 272 |
0}, |
|---|
| 273 |
{"wan_ifname2", "vlan2", 0}, |
|---|
| 274 |
{"wan_ifname", "vlan2", 0}, |
|---|
| 275 |
{"wan_default", "vlan2", 0}, |
|---|
| 276 |
{"wan_ifnames", "vlan2", 0}, |
|---|
| 277 |
{0, 0, 0} |
|---|
| 278 |
}; |
|---|
| 279 |
#elif HAVE_GATEWORX |
|---|
| 280 |
#ifdef HAVE_XIOCOM |
|---|
| 281 |
struct nvram_tuple generic[] = { |
|---|
| 282 |
{"lan_ifname", "br0", 0}, |
|---|
| 283 |
{"lan_ifnames", "ixp1 ath0 ath1 ath2 ath3", |
|---|
| 284 |
0}, |
|---|
| 285 |
{"wan_ifname2", "ixp0", 0}, |
|---|
| 286 |
{"wan_ifname", "ixp0", 0}, |
|---|
| 287 |
{"wan_default", "ixp0", 0}, |
|---|
| 288 |
{"wan_ifnames", "ixp0", 0}, |
|---|
| 289 |
{0, 0, 0} |
|---|
| 290 |
}; |
|---|
| 291 |
#else |
|---|
| 292 |
struct nvram_tuple generic[] = { |
|---|
| 293 |
{"lan_ifname", "br0", 0}, |
|---|
| 294 |
{"lan_ifnames", "ixp0 ath0 ath1 ath2 ath3", |
|---|
| 295 |
0}, |
|---|
| 296 |
{"wan_ifname2", "ixp1", 0}, |
|---|
| 297 |
{"wan_ifname", "ixp1", 0}, |
|---|
| 298 |
{"wan_default", "ixp1", 0}, |
|---|
| 299 |
{"wan_ifnames", "ixp1", 0}, |
|---|
| 300 |
{0, 0, 0} |
|---|
| 301 |
}; |
|---|
| 302 |
#endif |
|---|
| 303 |
#elif HAVE_X86 |
|---|
| 304 |
struct nvram_tuple generic[] = { |
|---|
| 305 |
{"lan_ifname", "br0", 0}, |
|---|
| 306 |
#ifdef HAVE_NOWIFI |
|---|
| 307 |
{"lan_ifnames", |
|---|
| 308 |
"eth1 eth2 eth3 eth4 eth5 eth6 eth7 eth8 eth9 eth10", |
|---|
| 309 |
0}, |
|---|
| 310 |
#else |
|---|
| 311 |
#ifdef HAVE_GW700 |
|---|
| 312 |
{"lan_ifnames", |
|---|
| 313 |
"eth0 eth2 eth3 eth4 eth5 eth6 eth7 eth8 eth9 eth10 ath0 ath1 ath2 ath3 ath5 ath6 ath7 ath8", |
|---|
| 314 |
0}, |
|---|
| 315 |
#else |
|---|
| 316 |
{"lan_ifnames", |
|---|
| 317 |
"eth1 eth2 eth3 eth4 eth5 eth6 eth7 eth8 eth9 eth10 ath0 ath1 ath2 ath3 ath5 ath6 ath7 ath8", |
|---|
| 318 |
0}, |
|---|
| 319 |
#endif |
|---|
| 320 |
#endif |
|---|
| 321 |
#ifdef HAVE_GW700 |
|---|
| 322 |
{"wan_ifname", "eth1", 0}, |
|---|
| 323 |
{"wan_ifname2", "eth1", 0}, |
|---|
| 324 |
{"wan_ifnames", "eth1", 0}, |
|---|
| 325 |
#else |
|---|
| 326 |
{"wan_ifname", "eth0", 0}, |
|---|
| 327 |
{"wan_ifname2", "eth0", 0}, |
|---|
| 328 |
{"wan_ifnames", "eth0", 0}, |
|---|
| 329 |
#endif |
|---|
| 330 |
{0, 0, 0} |
|---|
| 331 |
}; |
|---|
| 332 |
#elif HAVE_XSCALE |
|---|
| 333 |
struct nvram_tuple generic[] = { |
|---|
| 334 |
{"lan_ifname", "br0", 0}, |
|---|
| 335 |
{"lan_ifnames", |
|---|
| 336 |
"ixp0.1 ixp0.2 ath0 ath1", |
|---|
| 337 |
0}, |
|---|
| 338 |
{"wan_ifname", "ixp1", 0}, |
|---|
| 339 |
{"wan_ifname2", "ixp1", 0}, |
|---|
| 340 |
{"wan_ifnames", "ixp1", 0}, |
|---|
| 341 |
{"wan_default", "ixp1", 0}, |
|---|
| 342 |
{0, 0, 0} |
|---|
| 343 |
}; |
|---|
| 344 |
#elif HAVE_MAGICBOX |
|---|
| 345 |
struct nvram_tuple generic[] = { |
|---|
| 346 |
{"lan_ifname", "br0", 0}, |
|---|
| 347 |
{"lan_ifnames", "eth1 ath0", |
|---|
| 348 |
0}, |
|---|
| 349 |
{"wan_ifname", "eth0", 0}, |
|---|
| 350 |
{"wan_ifname2", "eth0", 0}, |
|---|
| 351 |
{"wan_ifnames", "eth0", 0}, |
|---|
| 352 |
{"wan_default", "eth0", 0}, |
|---|
| 353 |
{0, 0, 0} |
|---|
| 354 |
}; |
|---|
| 355 |
#elif HAVE_FONERA |
|---|
| 356 |
struct nvram_tuple generic[] = { |
|---|
| 357 |
{"lan_ifname", "br0", 0}, |
|---|
| 358 |
{"lan_ifnames", "vlan0 ath0", 0}, |
|---|
| 359 |
{"wan_ifname", "", 0}, |
|---|
| 360 |
{"wan_ifname2", "", 0}, |
|---|
| 361 |
{"wan_default", "", 0}, |
|---|
| 362 |
{"wan_ifnames", "eth0 vlan1", 0}, |
|---|
| 363 |
{0, 0, 0} |
|---|
| 364 |
}; |
|---|
| 365 |
#elif HAVE_BWRG1000 |
|---|
| 366 |
struct nvram_tuple generic[] = { |
|---|
| 367 |
{"lan_ifname", "br0", 0}, |
|---|
| 368 |
{"lan_ifnames", "vlan0 vlan2 ath0", 0}, |
|---|
| 369 |
{"wan_ifname", "vlan2", 0}, |
|---|
| 370 |
{"wan_ifname2", "vlan2", 0}, |
|---|
| 371 |
{"wan_ifnames", "vlan2", 0}, |
|---|
| 372 |
{"wan_default", "vlan2", 0}, |
|---|
| 373 |
{0, 0, 0} |
|---|
| 374 |
}; |
|---|
| 375 |
#elif HAVE_LS2 |
|---|
| 376 |
struct nvram_tuple generic[] = { |
|---|
| 377 |
{"lan_ifname", "br0", 0}, |
|---|
| 378 |
{"lan_ifnames", "vlan0 vlan2 ath0", 0}, |
|---|
| 379 |
{"wan_ifname", "vlan0", 0}, |
|---|
| 380 |
{"wan_ifname2", "vlan0", 0}, |
|---|
| 381 |
{"wan_ifnames", "vlan0", 0}, |
|---|
| 382 |
{"wan_default", "vlan0", 0}, |
|---|
| 383 |
{0, 0, 0} |
|---|
| 384 |
}; |
|---|
| 385 |
#elif HAVE_RS |
|---|
| 386 |
struct nvram_tuple generic[] = { |
|---|
| 387 |
{"lan_ifname", "br0", 0}, |
|---|
| 388 |
{"lan_ifnames", "eth0 eth1 ath0 ath1 ath2", 0}, |
|---|
| 389 |
{"wan_ifname", "eth0", 0}, |
|---|
| 390 |
{"wan_ifname2", "eth0", 0}, |
|---|
| 391 |
{"wan_ifnames", "eth0", 0}, |
|---|
| 392 |
{"wan_default", "eth0", 0}, |
|---|
| 393 |
{0, 0, 0} |
|---|
| 394 |
}; |
|---|
| 395 |
#elif HAVE_LSX |
|---|
| 396 |
struct nvram_tuple generic[] = { |
|---|
| 397 |
{"lan_ifname", "br0", 0}, |
|---|
| 398 |
{"lan_ifnames", "eth0 ath0", 0}, |
|---|
| 399 |
{"wan_ifname", "", 0}, |
|---|
| 400 |
{"wan_ifname2", "", 0}, |
|---|
| 401 |
{"wan_ifnames", "", 0}, |
|---|
| 402 |
{"wan_default", "", 0}, |
|---|
| 403 |
{0, 0, 0} |
|---|
| 404 |
}; |
|---|
| 405 |
#elif HAVE_DANUBE |
|---|
| 406 |
struct nvram_tuple generic[] = { |
|---|
| 407 |
{"lan_ifname", "br0", 0}, |
|---|
| 408 |
{"lan_ifnames", "eth0 ath0", 0}, |
|---|
| 409 |
{"wan_ifname", "", 0}, |
|---|
| 410 |
{"wan_ifname2", "", 0}, |
|---|
| 411 |
{"wan_ifnames", "", 0}, |
|---|
| 412 |
{"wan_default", "", 0}, |
|---|
| 413 |
{0, 0, 0} |
|---|
| 414 |
}; |
|---|
| 415 |
#elif HAVE_STORM |
|---|
| 416 |
struct nvram_tuple generic[] = { |
|---|
| 417 |
{"lan_ifname", "br0", 0}, |
|---|
| 418 |
{"lan_ifnames", "eth0 ath0", 0}, |
|---|
| 419 |
{"wan_ifname", "", 0}, |
|---|
| 420 |
{"wan_ifname2", "", 0}, |
|---|
| 421 |
{"wan_ifnames", "", 0}, |
|---|
| 422 |
{"wan_default", "", 0}, |
|---|
| 423 |
{0, 0, 0} |
|---|
| 424 |
}; |
|---|
| 425 |
#elif HAVE_WP54G |
|---|
| 426 |
struct nvram_tuple generic[] = { |
|---|
| 427 |
{"lan_ifname", "br0", 0}, |
|---|
| 428 |
{"lan_ifnames", "eth0 ath0", 0}, |
|---|
| 429 |
{"wan_ifname", "eth1", 0}, |
|---|
| 430 |
{"wan_ifname2", "eth1", 0}, |
|---|
| 431 |
{"wan_ifnames", "eth1", 0}, |
|---|
| 432 |
{"wan_default", "eth1", 0}, |
|---|
| 433 |
{0, 0, 0} |
|---|
| 434 |
}; |
|---|
| 435 |
#elif HAVE_NP28G |
|---|
| 436 |
struct nvram_tuple generic[] = { |
|---|
| 437 |
{"lan_ifname", "br0", 0}, |
|---|
| 438 |
{"lan_ifnames", "eth0 ath0", 0}, |
|---|
| 439 |
{"wan_ifname", "eth1", 0}, |
|---|
| 440 |
{"wan_ifname2", "eth1", 0}, |
|---|
| 441 |
{"wan_ifnames", "eth1", 0}, |
|---|
| 442 |
{"wan_default", "eth1", 0}, |
|---|
| 443 |
{0, 0, 0} |
|---|
| 444 |
}; |
|---|
| 445 |
#elif HAVE_ADM5120 |
|---|
| 446 |
struct nvram_tuple generic[] = { |
|---|
| 447 |
{"lan_ifname", "br0", 0}, |
|---|
| 448 |
{"lan_ifnames", "eth0 ath0", 0}, |
|---|
| 449 |
{"wan_ifname", "", 0}, |
|---|
| 450 |
{"wan_ifname2", "", 0}, |
|---|
| 451 |
{"wan_ifnames", "", 0}, |
|---|
| 452 |
{"wan_default", "", 0}, |
|---|
| 453 |
{0, 0, 0} |
|---|
| 454 |
}; |
|---|
| 455 |
#elif HAVE_LS5 |
|---|
| 456 |
struct nvram_tuple generic[] = { |
|---|
| 457 |
{"lan_ifname", "br0", 0}, |
|---|
| 458 |
{"lan_ifnames", "ath0", 0}, |
|---|
| 459 |
{"wan_ifname", "eth0", 0}, |
|---|
| 460 |
{"wan_ifname2", "eth0", 0}, |
|---|
| 461 |
{"wan_ifnames", "eth0", 0}, |
|---|
| 462 |
{"wan_default", "eth0", 0}, |
|---|
| 463 |
{0, 0, 0} |
|---|
| 464 |
}; |
|---|
| 465 |
#elif HAVE_WHRAG108 |
|---|
| 466 |
struct nvram_tuple generic[] = { |
|---|
| 467 |
{"lan_ifname", "br0", 0}, |
|---|
| 468 |
{"lan_ifnames", "eth0 ath0 ath1", 0}, |
|---|
| 469 |
{"wan_ifname2", "eth1", 0}, |
|---|
| 470 |
{"wan_ifname", "eth1", 0}, |
|---|
| 471 |
{"wan_ifnames", "eth1", 0}, |
|---|
| 472 |
{"wan_default", "eth1", 0}, |
|---|
| 473 |
{0, 0, 0} |
|---|
| 474 |
}; |
|---|
| 475 |
#elif HAVE_PB42 |
|---|
| 476 |
struct nvram_tuple generic[] = { |
|---|
| 477 |
{"lan_ifname", "br0", 0}, |
|---|
| 478 |
{"lan_ifnames", "eth1 ath0 ath1", 0}, |
|---|
| 479 |
{"wan_ifname2", "eth0", 0}, |
|---|
| 480 |
{"wan_ifname", "eth0", 0}, |
|---|
| 481 |
{"wan_ifnames", "eth0", 0}, |
|---|
| 482 |
{"wan_default", "eth0", 0}, |
|---|
| 483 |
{0, 0, 0} |
|---|
| 484 |
}; |
|---|
| 485 |
#elif HAVE_TW6600 |
|---|
| 486 |
struct nvram_tuple generic[] = { |
|---|
| 487 |
{"lan_ifname", "br0", 0}, |
|---|
| 488 |
{"lan_ifnames", "ath0 ath1", 0}, |
|---|
| 489 |
{"wan_ifname2", "eth0", 0}, |
|---|
| 490 |
{"wan_ifname", "eth0", 0}, |
|---|
| 491 |
{"wan_ifnames", "eth0", 0}, |
|---|
| 492 |
{"wan_default", "eth0", 0}, |
|---|
| 493 |
{0, 0, 0} |
|---|
| 494 |
}; |
|---|
| 495 |
#elif HAVE_CA8PRO |
|---|
| 496 |
struct nvram_tuple generic[] = { |
|---|
| 497 |
{"lan_ifname", "br0", 0}, |
|---|
| 498 |
{"lan_ifnames", "vlan0 ath0", 0}, |
|---|
| 499 |
{"wan_ifname", "vlan1", 0}, |
|---|
| 500 |
{"wan_ifname2", "vlan1", 0}, |
|---|
| 501 |
{"wan_ifnames", "vlan1", 0}, |
|---|
| 502 |
{"wan_default", "vlan1", 0}, |
|---|
| 503 |
{0, 0, 0} |
|---|
| 504 |
}; |
|---|
| 505 |
#elif HAVE_CA8 |
|---|
| 506 |
struct nvram_tuple generic[] = { |
|---|
| 507 |
{"lan_ifname", "br0", 0}, |
|---|
| 508 |
{"lan_ifnames", "ath0", 0}, |
|---|
| 509 |
{"wan_ifname", "eth0", 0}, |
|---|
| 510 |
{"wan_ifname2", "eth0", 0}, |
|---|
| 511 |
{"wan_ifnames", "eth0", 0}, |
|---|
| 512 |
{"wan_default", "eth0", 0}, |
|---|
| 513 |
{0, 0, 0} |
|---|
| 514 |
}; |
|---|
| 515 |
#else |
|---|
| 516 |
struct nvram_tuple generic[] = { |
|---|
| 517 |
{"lan_ifname", "br0", 0}, |
|---|
| 518 |
{"lan_ifnames", "eth0 eth2 eth3 eth4", 0}, |
|---|
| 519 |
{"wan_ifname", "eth1", 0}, |
|---|
| 520 |
{"wan_ifname2", "eth1", 0}, |
|---|
| 521 |
{"wan_ifnames", "eth1", 0}, |
|---|
| 522 |
{"wan_default", "eth1", 0}, |
|---|
| 523 |
{0, 0, 0} |
|---|
| 524 |
}; |
|---|
| 525 |
struct nvram_tuple vlan[] = { |
|---|
| 526 |
{"lan_ifname", "br0", 0}, |
|---|
| 527 |
{"lan_ifnames", "vlan0 eth1 eth2 eth3", 0}, |
|---|
| 528 |
{"wan_ifname", "vlan1", 0}, |
|---|
| 529 |
{"wan_ifname2", "vlan1", 0}, |
|---|
| 530 |
{"wan_ifnames", "vlan1", 0}, |
|---|
| 531 |
{"wan_default", "vlan1", 0}, |
|---|
| 532 |
{0, 0, 0} |
|---|
| 533 |
}; |
|---|
| 534 |
|
|---|
| 535 |
struct nvram_tuple wrt350vlan[] = { |
|---|
| 536 |
{"lan_ifname", "br0", 0}, |
|---|
| 537 |
{"lan_ifnames", "vlan1 eth0", 0}, |
|---|
| 538 |
{"wan_ifname", "vlan2", 0}, |
|---|
| 539 |
{"wan_ifname2", "vlan2", 0}, |
|---|
| 540 |
{"wan_ifnames", "vlan2", 0}, |
|---|
| 541 |
{"wan_default", "vlan2", 0}, |
|---|
| 542 |
{0, 0, 0} |
|---|
| 543 |
}; |
|---|
| 544 |
|
|---|
| 545 |
struct nvram_tuple wrt30011vlan[] = { |
|---|
| 546 |
{"lan_ifname", "br0", 0}, |
|---|
| 547 |
{"lan_ifnames", "vlan0 eth0", 0}, |
|---|
| 548 |
{"wan_ifname", "vlan1", 0}, |
|---|
| 549 |
{"wan_ifname2", "vlan1", 0}, |
|---|
| 550 |
{"wan_ifnames", "vlan1", 0}, |
|---|
| 551 |
{"wan_default", "vlan1", 0}, |
|---|
| 552 |
{0, 0, 0} |
|---|
| 553 |
}; |
|---|
| 554 |
|
|---|
| 555 |
struct nvram_tuple wrt600vlan[] = { |
|---|
| 556 |
{"lan_ifname", "br0", 0}, |
|---|
| 557 |
{"lan_ifnames", "vlan0 eth0 eth1", 0}, |
|---|
| 558 |
{"wan_ifname", "vlan2", 0}, |
|---|
| 559 |
{"wan_ifname2", "vlan2", 0}, |
|---|
| 560 |
{"wan_ifnames", "vlan2", 0}, |
|---|
| 561 |
{"wan_default", "vlan2", 0}, |
|---|
| 562 |
{0, 0, 0} |
|---|
| 563 |
}; |
|---|
| 564 |
|
|---|
| 565 |
struct nvram_tuple wrt60011vlan[] = { |
|---|
| 566 |
{"lan_ifname", "br0", 0}, |
|---|
| 567 |
{"lan_ifnames", "vlan1 eth0 eth1", 0}, |
|---|
| 568 |
{"wan_ifname", "vlan2", 0}, |
|---|
| 569 |
{"wan_ifname2", "vlan2", 0}, |
|---|
| 570 |
{"wan_ifnames", "vlan2", 0}, |
|---|
| 571 |
{"wan_default", "vlan2", 0}, |
|---|
| 572 |
{0, 0, 0} |
|---|
| 573 |
}; |
|---|
| 574 |
|
|---|
| 575 |
struct nvram_tuple wzr144nhvlan[] = { |
|---|
| 576 |
{"lan_ifname", "br0", 0}, |
|---|
| 577 |
{"lan_ifnames", "vlan2 eth0", 0}, |
|---|
| 578 |
{"wan_ifname", "vlan1", 0}, |
|---|
| 579 |
{"wan_ifname2", "vlan1", 0}, |
|---|
| 580 |
{"wan_ifnames", "vlan1", 0}, |
|---|
| 581 |
{"wan_default", "vlan1", 0}, |
|---|
| 582 |
{0, 0, 0} |
|---|
| 583 |
}; |
|---|
| 584 |
|
|---|
| 585 |
struct nvram_tuple generic_2[] = { |
|---|
| 586 |
{"lan_ifname", "br0", 0}, |
|---|
| 587 |
{"lan_ifnames", "eth1 eth2", 0}, |
|---|
| 588 |
{"wan_ifname", "eth0", 0}, |
|---|
| 589 |
{"wan_ifname2", "eth0", 0}, |
|---|
| 590 |
{"wan_ifnames", "eth0", 0}, |
|---|
| 591 |
{"wan_default", "eth0", 0}, |
|---|
| 592 |
{0, 0, 0} |
|---|
| 593 |
}; |
|---|
| 594 |
|
|---|
| 595 |
struct nvram_tuple generic_3[] = { |
|---|
| 596 |
{"lan_ifname", "br0", 0}, |
|---|
| 597 |
{"lan_ifnames", "eth0 eth1", 0}, |
|---|
| 598 |
{"wan_ifname", "eth2", 0}, |
|---|
| 599 |
{"wan_ifname2", "eth2", 0}, |
|---|
| 600 |
{"wan_ifnames", "eth2", 0}, |
|---|
| 601 |
{"wan_default", "eth2", 0}, |
|---|
| 602 |
{0, 0, 0} |
|---|
| 603 |
}; |
|---|
| 604 |
#endif |
|---|
| 605 |
|
|---|
| 606 |
struct nvram_tuple *linux_overrides; |
|---|
| 607 |
struct nvram_tuple *t, *u; |
|---|
| 608 |
int restore_defaults = 0; |
|---|
| 609 |
|
|---|
| 610 |
// uint boardflags; |
|---|
| 611 |
|
|---|
| 612 |
/* |
|---|
| 613 |
* Restore defaults if told to. |
|---|
| 614 |
* |
|---|
| 615 |
* Note: an intentional side effect is that when upgrading from a |
|---|
| 616 |
* firmware without the sv_restore_defaults var, defaults will also be |
|---|
| 617 |
* restored. |
|---|
| 618 |
*/ |
|---|
| 619 |
char *et0mac = nvram_safe_get("et0macaddr"); |
|---|
| 620 |
char *et1mac = nvram_safe_get("et1macaddr"); |
|---|
| 621 |
|
|---|
| 622 |
// unsigned char mac[20]; |
|---|
| 623 |
// if (getRouterBrand () == ROUTER_BUFFALO_WZRG144NH) |
|---|
| 624 |
// { |
|---|
| 625 |
// if (nvram_get ("il0macaddr") == NULL) |
|---|
| 626 |
// { |
|---|
| 627 |
// strcpy (mac, et0mac); |
|---|
| 628 |
// MAC_ADD (mac); |
|---|
| 629 |
// nvram_set ("il0macaddr", mac); |
|---|
| 630 |
// } |
|---|
| 631 |
// } |
|---|
| 632 |
load_defaults(); |
|---|
| 633 |
#ifdef HAVE_RB500 |
|---|
| 634 |
linux_overrides = generic; |
|---|
| 635 |
int brand = getRouterBrand(); |
|---|
| 636 |
#elif HAVE_XSCALE |
|---|
| 637 |
linux_overrides = generic; |
|---|
| 638 |
int brand = getRouterBrand(); |
|---|
| 639 |
|
|---|
| 640 |
if (nvram_invmatch("sv_restore_defaults", "0")) // || |
|---|
| 641 |
// nvram_invmatch("os_name", |
|---|
| 642 |
// "linux")) |
|---|
| 643 |
{ |
|---|
| 644 |
restore_defaults = 1; |
|---|
| 645 |
} |
|---|
| 646 |
#elif HAVE_X86 |
|---|
| 647 |
linux_overrides = generic; |
|---|
| 648 |
int brand = getRouterBrand(); |
|---|
| 649 |
|
|---|
| 650 |
if (nvram_invmatch("sv_restore_defaults", "0")) // || |
|---|
| 651 |
// nvram_invmatch("os_name", |
|---|
| 652 |
// "linux")) |
|---|
| 653 |
{ |
|---|
| 654 |
restore_defaults = 1; |
|---|
| 655 |
} |
|---|
| 656 |
#elif HAVE_MAGICBOX |
|---|
| 657 |
linux_overrides = generic; |
|---|
| 658 |
int brand = getRouterBrand(); |
|---|
| 659 |
|
|---|
| 660 |
if (nvram_invmatch("sv_restore_defaults", "0")) // || |
|---|
| 661 |
// nvram_invmatch("os_name", |
|---|
| 662 |
// "linux")) |
|---|
| 663 |
{ |
|---|
| 664 |
restore_defaults = 1; |
|---|
| 665 |
} |
|---|
| 666 |
#elif HAVE_GATEWORX |
|---|
| 667 |
linux_overrides = generic; |
|---|
| 668 |
int brand = getRouterBrand(); |
|---|
| 669 |
|
|---|
| 670 |
if (nvram_invmatch("sv_restore_defaults", "0")) // || |
|---|
| 671 |
// nvram_invmatch("os_name", |
|---|
| 672 |
// "linux")) |
|---|
| 673 |
{ |
|---|
| 674 |
restore_defaults = 1; |
|---|
| 675 |
} |
|---|
| 676 |
#elif HAVE_FONERA |
|---|
| 677 |
linux_overrides = generic; |
|---|
| 678 |
int brand = getRouterBrand(); |
|---|
| 679 |
|
|---|
| 680 |
if (nvram_invmatch("sv_restore_defaults", "0")) // || |
|---|
| 681 |
// nvram_invmatch("os_name", |
|---|
| 682 |
// "linux")) |
|---|
| 683 |
{ |
|---|
| 684 |
restore_defaults = 1; |
|---|
| 685 |
} |
|---|
| 686 |
#elif HAVE_RT2880 |
|---|
| 687 |
linux_overrides = generic; |
|---|
| 688 |
int brand = getRouterBrand(); |
|---|
| 689 |
|
|---|
| 690 |
if (nvram_invmatch("sv_restore_defaults", "0")) // || |
|---|
| 691 |
// nvram_invmatch("os_name", |
|---|
| 692 |
// "linux")) |
|---|
| 693 |
{ |
|---|
| 694 |
restore_defaults = 1; |
|---|
| 695 |
} |
|---|
| 696 |
#elif HAVE_LS2 |
|---|
| 697 |
linux_overrides = generic; |
|---|
| 698 |
int brand = getRouterBrand(); |
|---|
| 699 |
|
|---|
| 700 |
if (nvram_invmatch("sv_restore_defaults", "0")) // || |
|---|
| 701 |
// nvram_invmatch("os_name", |
|---|
| 702 |
// "linux")) |
|---|
| 703 |
{ |
|---|
| 704 |
restore_defaults = 1; |
|---|
| 705 |
} |
|---|
| 706 |
#elif HAVE_LS5 |
|---|
| 707 |
linux_overrides = generic; |
|---|
| 708 |
int brand = getRouterBrand(); |
|---|
| 709 |
|
|---|
| 710 |
if (nvram_invmatch("sv_restore_defaults", "0")) // || |
|---|
| 711 |
// nvram_invmatch("os_name", |
|---|
| 712 |
// "linux")) |
|---|
| 713 |
{ |
|---|
| 714 |
restore_defaults = 1; |
|---|
| 715 |
} |
|---|
| 716 |
#elif HAVE_WHRAG108 |
|---|
| 717 |
linux_overrides = generic; |
|---|
| 718 |
int brand = getRouterBrand(); |
|---|
| 719 |
|
|---|
| 720 |
if (nvram_invmatch("sv_restore_defaults", "0")) // || |
|---|
| 721 |
// nvram_invmatch("os_name", |
|---|
| 722 |
// "linux")) |
|---|
| 723 |
{ |
|---|
| 724 |
restore_defaults = 1; |
|---|
| 725 |
} |
|---|
| 726 |
#elif HAVE_TW6600 |
|---|
| 727 |
linux_overrides = generic; |
|---|
| 728 |
int brand = getRouterBrand(); |
|---|
| 729 |
|
|---|
| 730 |
if (nvram_invmatch("sv_restore_defaults", "0")) // || |
|---|
| 731 |
// nvram_invmatch("os_name", |
|---|
| 732 |
// "linux")) |
|---|
| 733 |
{ |
|---|
| 734 |
restore_defaults = 1; |
|---|
| 735 |
} |
|---|
| 736 |
#elif HAVE_PB42 |
|---|
| 737 |
linux_overrides = generic; |
|---|
| 738 |
int brand = getRouterBrand(); |
|---|
| 739 |
|
|---|
| 740 |
if (nvram_invmatch("sv_restore_defaults", "0")) // || |
|---|
| 741 |
// nvram_invmatch("os_name", |
|---|
| 742 |
// "linux")) |
|---|
| 743 |
{ |
|---|
| 744 |
restore_defaults = 1; |
|---|
| 745 |
} |
|---|
| 746 |
#elif HAVE_LSX |
|---|
| 747 |
linux_overrides = generic; |
|---|
| 748 |
int brand = getRouterBrand(); |
|---|
| 749 |
|
|---|
| 750 |
if (nvram_invmatch("sv_restore_defaults", "0")) // || |
|---|
| 751 |
// nvram_invmatch("os_name", |
|---|
| 752 |
// "linux")) |
|---|
| 753 |
{ |
|---|
| 754 |
restore_defaults = 1; |
|---|
| 755 |
} |
|---|
| 756 |
#elif HAVE_DANUBE |
|---|
| 757 |
linux_overrides = generic; |
|---|
| 758 |
int brand = getRouterBrand(); |
|---|
| 759 |
|
|---|
| 760 |
if (nvram_invmatch("sv_restore_defaults", "0")) // || |
|---|
| 761 |
// nvram_invmatch("os_name", |
|---|
| 762 |
// "linux")) |
|---|
| 763 |
{ |
|---|
| 764 |
restore_defaults = 1; |
|---|
| 765 |
} |
|---|
| 766 |
#elif HAVE_STORM |
|---|
| 767 |
linux_overrides = generic; |
|---|
| 768 |
int brand = getRouterBrand(); |
|---|
| 769 |
|
|---|
| 770 |
if (nvram_invmatch("sv_restore_defaults", "0")) // || |
|---|
| 771 |
// nvram_invmatch("os_name", |
|---|
| 772 |
// "linux")) |
|---|
| 773 |
{ |
|---|
| 774 |
restore_defaults = 1; |
|---|
| 775 |
} |
|---|
| 776 |
#elif HAVE_ADM5120 |
|---|
| 777 |
linux_overrides = generic; |
|---|
| 778 |
int brand = getRouterBrand(); |
|---|
| 779 |
|
|---|
| 780 |
if (nvram_invmatch("sv_restore_defaults", "0")) // || |
|---|
| 781 |
// nvram_invmatch("os_name", |
|---|
| 782 |
// "linux")) |
|---|
| 783 |
{ |
|---|
| 784 |
restore_defaults = 1; |
|---|
| 785 |
} |
|---|
| 786 |
#elif HAVE_CA8 |
|---|
| 787 |
linux_overrides = generic; |
|---|
| 788 |
int brand = getRouterBrand(); |
|---|
| 789 |
|
|---|
| 790 |
if (nvram_invmatch("sv_restore_defaults", "0")) // || |
|---|
| 791 |
// nvram_invmatch("os_name", |
|---|
| 792 |
// "linux")) |
|---|
| 793 |
{ |
|---|
| 794 |
restore_defaults = 1; |
|---|
| 795 |
} |
|---|
| 796 |
#elif HAVE_GEMTEK |
|---|
| 797 |
linux_overrides = generic; |
|---|
| 798 |
int brand = getRouterBrand(); |
|---|
| 799 |
#else |
|---|
| 800 |
int brand = getRouterBrand(); |
|---|
| 801 |
|
|---|
| 802 |
if (nvram_invmatch("sv_restore_defaults", "0")) // || |
|---|
| 803 |
// nvram_invmatch("os_name", |
|---|
| 804 |
// "linux")) |
|---|
| 805 |
{ |
|---|
| 806 |
// nvram_unset("sv_restore_defaults"); |
|---|
| 807 |
restore_defaults = 1; |
|---|
| 808 |
} |
|---|
| 809 |
if (nvram_match("product_name", "INSPECTION")) { |
|---|
| 810 |
nvram_unset("product_name"); |
|---|
| 811 |
restore_defaults = 1; |
|---|
| 812 |
} |
|---|
| 813 |
if (nvram_get("router_name") == NULL) |
|---|
| 814 |
restore_defaults = 1; |
|---|
| 815 |
|
|---|
| 816 |
if (restore_defaults) { |
|---|
| 817 |
cprintf("Restoring defaults...\n"); |
|---|
| 818 |
/* |
|---|
| 819 |
* these unsets are important for routers where we can't erase nvram |
|---|
| 820 |
* and only software restore defaults |
|---|
| 821 |
*/ |
|---|
| 822 |
nvram_unset("wan_to_lan"); |
|---|
| 823 |
nvram_unset("wl_vifs"); |
|---|
| 824 |
nvram_unset("wl0_vifs"); |
|---|
| 825 |
} |
|---|
| 826 |
// } |
|---|
| 827 |
|
|---|
| 828 |
/* |
|---|
| 829 |
* Delete dynamically generated variables |
|---|
| 830 |
*/ |
|---|
| 831 |
/* |
|---|
| 832 |
* Choose default lan/wan i/f list. |
|---|
| 833 |
*/ |
|---|
| 834 |
char *ds; |
|---|
| 835 |
|
|---|
| 836 |
switch (brand) { |
|---|
| 837 |
#ifndef HAVE_BUFFALO |
|---|
| 838 |
case ROUTER_WRTSL54GS: |
|---|
| 839 |
case ROUTER_WRT150N: |
|---|
| 840 |
case ROUTER_WRT160N: |
|---|
| 841 |
case ROUTER_WRT300N: |
|---|
| 842 |
case ROUTER_NETGEAR_WNR834B: |
|---|
| 843 |
case ROUTER_NETGEAR_WNR834BV2: |
|---|
| 844 |
case ROUTER_NETGEAR_WNDR3300: |
|---|
| 845 |
case ROUTER_ASUS_WL500G: |
|---|
| 846 |
case ROUTER_ASUS_WL500W: |
|---|
| 847 |
#endif |
|---|
| 848 |
case ROUTER_BUFFALO_WZRG300N: |
|---|
| 849 |
case ROUTER_BUFFALO_WLAH_G54: |
|---|
| 850 |
case ROUTER_BUFFALO_WAPM_HP_AM54G54: |
|---|
| 851 |
case ROUTER_BUFFALO_WZRRSG54: |
|---|
| 852 |
case ROUTER_ASKEY_RT220XD: |
|---|
| 853 |
linux_overrides = generic; |
|---|
| 854 |
break; |
|---|
| 855 |
#ifndef HAVE_BUFFALO |
|---|
| 856 |
case ROUTER_ASUS_WL500GD: |
|---|
| 857 |
case ROUTER_ASUS_WL550GE: |
|---|
| 858 |
case ROUTER_BELKIN_F5D7230_V3000: |
|---|
| 859 |
linux_overrides = vlan; |
|---|
| 860 |
break; |
|---|
| 861 |
case ROUTER_WRT350N: |
|---|
| 862 |
linux_overrides = wrt350vlan; |
|---|
| 863 |
break; |
|---|
| 864 |
case ROUTER_WRT310N: |
|---|
| 865 |
linux_overrides = wrt350vlan; |
|---|
| 866 |
break; |
|---|
| 867 |
case ROUTER_WRT300NV11: |
|---|
| 868 |
linux_overrides = wrt30011vlan; |
|---|
| 869 |
break; |
|---|
| 870 |
case ROUTER_WRT600N: |
|---|
| 871 |
if (nvram_match("switch_type", "BCM5395")) |
|---|
| 872 |
linux_overrides = wrt60011vlan; |
|---|
| 873 |
else |
|---|
| 874 |
linux_overrides = wrt600vlan; |
|---|
| 875 |
break; |
|---|
| 876 |
case ROUTER_WRT610N: |
|---|
| 877 |
linux_overrides = wrt60011vlan; |
|---|
| 878 |
break; |
|---|
| 879 |
#endif |
|---|
| 880 |
case ROUTER_BUFFALO_WZRG144NH: |
|---|
| 881 |
linux_overrides = wzr144nhvlan; |
|---|
| 882 |
break; |
|---|
| 883 |
#ifndef HAVE_BUFFALO |
|---|
| 884 |
case ROUTER_MOTOROLA_WE800G: |
|---|
| 885 |
case ROUTER_WAP54G_V1: |
|---|
| 886 |
case ROUTER_SITECOM_WL105B: |
|---|
| 887 |
#endif |
|---|
| 888 |
case ROUTER_BUFFALO_WLI2_TX1_G54: |
|---|
| 889 |
case ROUTER_BUFFALO_WLAG54C: |
|---|
| 890 |
linux_overrides = generic_2; |
|---|
| 891 |
break; |
|---|
| 892 |
#ifndef HAVE_BUFFALO |
|---|
| 893 |
case ROUTER_WAP54G_V2: |
|---|
| 894 |
case ROUTER_VIEWSONIC_WAPBR_100: |
|---|
| 895 |
case ROUTER_USR_5430: |
|---|
| 896 |
case ROUTER_BELKIN_F5D7230_V2000: |
|---|
| 897 |
case ROUTER_NETGEAR_WG602_V3: |
|---|
| 898 |
case ROUTER_NETGEAR_WG602_V4: |
|---|
| 899 |
#endif |
|---|
| 900 |
case ROUTER_BUFFALO_WLA2G54C: |
|---|
| 901 |
case ROUTER_BUFFALO_WLI_TX4_G54HP: |
|---|
| 902 |
linux_overrides = generic_3; |
|---|
| 903 |
break; |
|---|
| 904 |
#ifndef HAVE_BUFFALO |
|---|
| 905 |
case ROUTER_RT480W: |
|---|
| 906 |
case ROUTER_RT210W: |
|---|
| 907 |
#endif |
|---|
| 908 |
case ROUTER_BRCM4702_GENERIC: |
|---|
| 909 |
ds = nvram_safe_get("dhcp_start"); |
|---|
| 910 |
if (ds != NULL && strlen(ds) > 3) { |
|---|
| 911 |
fprintf(stderr, "cleaning nvram variables\n"); |
|---|
| 912 |
for (t = srouter_defaults; t->name; t++) { |
|---|
| 913 |
nvram_unset(t->name); |
|---|
| 914 |
} |
|---|
| 915 |
restore_defaults = 1; |
|---|
| 916 |
} |
|---|
| 917 |
|
|---|
| 918 |
/* |
|---|
| 919 |
* ds = nvram_safe_get ("http_passwd"); if (ds == NULL || strlen |
|---|
| 920 |
* (ds) == 0) //fix for empty default password { nvram_set |
|---|
| 921 |
* ("http_passwd", "admin"); } ds = nvram_safe_get ("language"); |
|---|
| 922 |
* if (ds != NULL && strlen (ds) < 3) { nvram_set ("language", |
|---|
| 923 |
* "english"); } |
|---|
| 924 |
*/ |
|---|
| 925 |
// fall through |
|---|
| 926 |
default: |
|---|
| 927 |
if (check_vlan_support()) |
|---|
| 928 |
linux_overrides = vlan; |
|---|
| 929 |
else |
|---|
| 930 |
linux_overrides = generic; |
|---|
| 931 |
break; |
|---|
| 932 |
} |
|---|
| 933 |
#endif |
|---|
| 934 |
/* |
|---|
| 935 |
* int i; for (i=0;i<4;i++) |
|---|
| 936 |
* nvram_set(linux_overrides[i].name,linux_overrides[i].value); |
|---|
| 937 |
*/ |
|---|
| 938 |
|
|---|
| 939 |
/* |
|---|
| 940 |
* Restore defaults |
|---|
| 941 |
*/ |
|---|
| 942 |
#ifdef HAVE_FON |
|---|
| 943 |
int reset = 0; |
|---|
| 944 |
char *rev = nvram_safe_get("fon_revision"); |
|---|
| 945 |
|
|---|
| 946 |
if (rev == NULL || strlen(rev) == 0) |
|---|
| 947 |
reset = 1; |
|---|
| 948 |
if (strlen(rev) > 0) { |
|---|
| 949 |
int n = atoi(rev); |
|---|
| 950 |
|
|---|
| 951 |
if (atoi(srouter_defaults[0].value) != n) |
|---|
| 952 |
reset = 1; |
|---|
| 953 |
} |
|---|
| 954 |
if (reset) { |
|---|
| 955 |
for (t = srouter_defaults; t->name; t++) { |
|---|
| 956 |
for (u = linux_overrides; u && u->name; u++) { |
|---|
| 957 |
if (!strcmp(t->name, u->name)) { |
|---|
| 958 |
nvram_set(u->name, u->value); |
|---|
| 959 |
break; |
|---|
| 960 |
} |
|---|
| 961 |
} |
|---|
| 962 |
if (!u || !u->name) |
|---|
| 963 |
nvram_set(t->name, t->value); |
|---|
| 964 |
} |
|---|
| 965 |
} |
|---|
| 966 |
#endif |
|---|
| 967 |
#ifdef HAVE_GATEWORX |
|---|
| 968 |
if (restore_defaults) { |
|---|
| 969 |
eval("erase", "nvram"); |
|---|
| 970 |
} |
|---|
| 971 |
#elif HAVE_XSCALE |
|---|
| 972 |
if (restore_defaults) |
|---|
| 973 |
eval("rm", "-f", "/etc/nvram/*"); // delete nvram database |
|---|
| 974 |
#endif |
|---|
| 975 |
#ifdef HAVE_MAGICBOX |
|---|
| 976 |
if (restore_defaults) { |
|---|
| 977 |
eval("rm", "-f", "/tmp/nvram/*"); // delete nvram database |
|---|
| 978 |
eval("rm", "-f", "/tmp/nvram/.lock"); // delete nvram database |
|---|
| 979 |
eval("erase", "nvram"); |
|---|
| 980 |
} |
|---|
| 981 |
#endif |
|---|
| 982 |
#ifdef HAVE_RT2880 |
|---|
| 983 |
if (restore_defaults) { |
|---|
| 984 |
eval("erase", "nvram"); |
|---|
| 985 |
} |
|---|
| 986 |
#endif |
|---|
| 987 |
#ifdef HAVE_FONERA |
|---|
| 988 |
if (restore_defaults) { |
|---|
| 989 |
eval("erase", "nvram"); |
|---|
| 990 |
} |
|---|
| 991 |
#endif |
|---|
| 992 |
#ifdef HAVE_LS2 |
|---|
| 993 |
if (restore_defaults) { |
|---|
| 994 |
eval("erase", "nvram"); |
|---|
| 995 |
} |
|---|
| 996 |
#endif |
|---|
| 997 |
#ifdef HAVE_LS5 |
|---|
| 998 |
if (restore_defaults) { |
|---|
| 999 |
eval("erase", "nvram"); |
|---|
| 1000 |
} |
|---|
| 1001 |
#endif |
|---|
| 1002 |
#ifdef HAVE_WHRAG108 |
|---|
| 1003 |
if (restore_defaults) { |
|---|
| 1004 |
eval("erase", "nvram"); |
|---|
| 1005 |
} |
|---|
| 1006 |
#endif |
|---|
| 1007 |
#ifdef HAVE_TW6600 |
|---|
| 1008 |
if (restore_defaults) { |
|---|
| 1009 |
eval("erase", "nvram"); |
|---|
| 1010 |
} |
|---|
| 1011 |
#endif |
|---|
| 1012 |
int nvcnt = 0; |
|---|
| 1013 |
|
|---|
| 1014 |
// if (!nvram_match("default_init","1")) |
|---|
| 1015 |
{ |
|---|
| 1016 |
for (t = srouter_defaults; t->name; t++) { |
|---|
| 1017 |
if (restore_defaults || !nvram_get(t->name)) { |
|---|
| 1018 |
for (u = linux_overrides; u && u->name; u++) { |
|---|
| 1019 |
if (!strcmp(t->name, u->name)) { |
|---|
| 1020 |
nvcnt++; |
|---|
| 1021 |
nvram_set(u->name, u->value); |
|---|
| 1022 |
break; |
|---|
| 1023 |
} |
|---|
| 1024 |
} |
|---|
| 1025 |
if (!u || !u->name) { |
|---|
| 1026 |
nvcnt++; |
|---|
| 1027 |
nvram_set(t->name, t->value); |
|---|
| 1028 |
} |
|---|
| 1029 |
} |
|---|
| 1030 |
} |
|---|
| 1031 |
} |
|---|
| 1032 |
free_defaults(); |
|---|
| 1033 |
if (strlen(nvram_safe_get("http_username")) == 0) { |
|---|
| 1034 |
nvram_set("http_username", zencrypt("root")); |
|---|
| 1035 |
nvram_set("http_passwd", zencrypt("admin")); |
|---|
| 1036 |
} |
|---|
| 1037 |
#ifndef HAVE_FON |
|---|
| 1038 |
if (restore_defaults) { |
|---|
| 1039 |
switch (brand) { |
|---|
| 1040 |
case ROUTER_ASUS_WL520G: |
|---|
| 1041 |
case ROUTER_ASUS_WL500G_PRE_V2: |
|---|
| 1042 |
case ROUTER_BELKIN_F5D7230_V3000: |
|---|
| 1043 |
nvram_set("vlan0ports", "0 1 2 3 5*"); |
|---|
| 1044 |
nvram_set("vlan1ports", "4 5"); |
|---|
| 1045 |
break; |
|---|
| 1046 |
case ROUTER_LINKSYS_WTR54GS: |
|---|
| 1047 |
nvram_set("vlan0ports", "0 5*"); |
|---|
| 1048 |
nvram_set("vlan1ports", "1 5"); |
|---|
| 1049 |
break; |
|---|
| 1050 |
case ROUTER_ASUS_WL550GE: |
|---|
| 1051 |
nvram_set("vlan0ports", "1 2 3 4 5*"); |
|---|
| 1052 |
nvram_set("vlan1ports", "0 5"); |
|---|
| 1053 |
break; |
|---|
| 1054 |
case ROUTER_MOTOROLA: |
|---|
| 1055 |
case ROUTER_WRT54G_V8: |
|---|
| 1056 |
nvram_set("vlan0ports", "3 2 1 0 5*"); |
|---|
| 1057 |
nvram_set("vlan1ports", "4 5"); |
|---|
| 1058 |
break; |
|---|
| 1059 |
case ROUTER_LINKSYS_WRH54G: |
|---|
| 1060 |
case ROUTER_ASUS_WL500GD: |
|---|
| 1061 |
case ROUTER_BUFFALO_WBR2G54S: |
|---|
| 1062 |
nvram_set("vlan0ports", "4 3 2 1 5*"); |
|---|
| 1063 |
nvram_set("vlan1ports", "0 5"); |
|---|
| 1064 |
break; |
|---|
| 1065 |
case ROUTER_USR_5461: |
|---|
| 1066 |
nvram_set("vlan0ports", "4 1 2 3 5*"); |
|---|
| 1067 |
nvram_set("vlan1ports", "0 5"); |
|---|
| 1068 |
break; |
|---|
| 1069 |
default: |
|---|
| 1070 |
if (nvram_match("boardnum", "WAP54GV3_8M_0614")) { |
|---|
| 1071 |
nvram_set("vlan0ports", "3 2 1 0 5*"); |
|---|
| 1072 |
nvram_set("vlan1ports", "4 5"); |
|---|
| 1073 |
} |
|---|
| 1074 |
break; |
|---|
| 1075 |
} |
|---|
| 1076 |
#ifdef HAVE_SPUTNIK |
|---|
| 1077 |
nvram_set("lan_ipaddr", "192.168.180.1"); |
|---|
| 1078 |
#elif HAVE_BUFFALO |
|---|
| 1079 |
nvram_set("lan_ipaddr", "192.168.11.1"); |
|---|
| 1080 |
#else |
|---|
| 1081 |
nvram_set("lan_ipaddr", "192.168.1.1"); |
|---|
| 1082 |
#endif |
|---|
| 1083 |
} |
|---|
| 1084 |
#else |
|---|
| 1085 |
if (restore_defaults) { |
|---|
| 1086 |
nvram_set("lan_ipaddr", "192.168.10.1"); |
|---|
| 1087 |
} |
|---|
| 1088 |
#endif |
|---|
| 1089 |
#ifdef HAVE_SKYTRON |
|---|
| 1090 |
if (restore_defaults) { |
|---|
| 1091 |
nvram_set("lan_ipaddr", "192.168.0.1"); |
|---|
| 1092 |
} |
|---|
| 1093 |
#endif |
|---|
| 1094 |
if (brand == ROUTER_WRT600N) { |
|---|
| 1095 |
if (nvram_match("switch_type", "BCM5395")) // fix for WRT600N |
|---|
| 1096 |
// v1.1 (BCM5395 does |
|---|
| 1097 |
// not suppport vid |
|---|
| 1098 |
// 0, so gemtek |
|---|
| 1099 |
// internally |
|---|
| 1100 |
// configured vid 1 |
|---|
| 1101 |
// as lan) |
|---|
| 1102 |
{ |
|---|
| 1103 |
nvram_set("vlan0ports", " "); |
|---|
| 1104 |
nvram_set("vlan1ports", "1 2 3 4 8*"); |
|---|
| 1105 |
nvram_set("vlan2ports", "0 8*"); |
|---|
| 1106 |
nvram_set("vlan0hwname", " "); |
|---|
| 1107 |
nvram_set("vlan1hwname", "et0"); |
|---|
| 1108 |
nvram_set("landevs", "vlan1 wl0 wl1"); |
|---|
| 1109 |
nvram_set("lan_ifnames", "vlan1 eth0 eth1"); |
|---|
| 1110 |
} else { |
|---|
| 1111 |
if (!nvram_get("vlan0ports") |
|---|
| 1112 |
|| nvram_match("vlan0ports", "")) { |
|---|
| 1113 |
nvram_set("vlan0ports", "1 2 3 4 8*"); |
|---|
| 1114 |
nvram_set("vlan2ports", "0 8*"); |
|---|
| 1115 |
} |
|---|
| 1116 |
if (!nvram_get("vlan2ports") |
|---|
| 1117 |
|| nvram_match("vlan2ports", "")) { |
|---|
| 1118 |
nvram_set("vlan0ports", "1 2 3 4 8*"); |
|---|
| 1119 |
nvram_set("vlan2ports", "0 8*"); |
|---|
| 1120 |
} |
|---|
| 1121 |
} |
|---|
| 1122 |
} else if (brand == ROUTER_WRT610N) { |
|---|
| 1123 |
if (!nvram_get("vlan1ports") || nvram_match("vlan1ports", "")) { |
|---|
| 1124 |
nvram_set("vlan1ports", "1 2 3 4 8*"); |
|---|
| 1125 |
nvram_set("vlan2ports", "0 8"); |
|---|
| 1126 |
} |
|---|
| 1127 |
if (!nvram_get("vlan2ports") || nvram_match("vlan2ports", "")) { |
|---|
| 1128 |
nvram_set("vlan1ports", "1 2 3 4 8*"); |
|---|
| 1129 |
nvram_set("vlan2ports", "0 8"); |
|---|
| 1130 |
} |
|---|
| 1131 |
} else if (brand == ROUTER_WRT350N) { |
|---|
| 1132 |
|
|---|
| 1133 |
if (!nvram_get("vlan1ports") || nvram_match("vlan1ports", "")) { |
|---|
| 1134 |
nvram_set("vlan1ports", "1 2 3 4 8*"); |
|---|
| 1135 |
nvram_set("vlan2ports", "0 8"); |
|---|
| 1136 |
} |
|---|
| 1137 |
if (!nvram_get("vlan2ports") || nvram_match("vlan2ports", "")) { |
|---|
| 1138 |
nvram_set("vlan1ports", "1 2 3 4 8*"); |
|---|
| 1139 |
nvram_set("vlan2ports", "0 8"); |
|---|
| 1140 |
} |
|---|
| 1141 |
|
|---|
| 1142 |
} else if (brand == ROUTER_WRT310N) { |
|---|
| 1143 |
|
|---|
| 1144 |
if (!nvram_get("vlan1ports") || nvram_match("vlan1ports", "")) { |
|---|
| 1145 |
nvram_set("vlan1ports", "1 2 3 4 8*"); |
|---|
| 1146 |
nvram_set("vlan2ports", "0 8"); |
|---|
| 1147 |
} |
|---|
| 1148 |
if (!nvram_get("vlan2ports") || nvram_match("vlan2ports", "")) { |
|---|
| 1149 |
nvram_set("vlan1ports", "1 2 3 4 8*"); |
|---|
| 1150 |
nvram_set("vlan2ports", "0 8"); |
|---|
| 1151 |
} |
|---|
| 1152 |
|
|---|
| 1153 |
} else if (brand == ROUTER_WRT300NV11) { |
|---|
| 1154 |
|
|---|
| 1155 |
if (!nvram_get("vlan0ports") || nvram_match("vlan0ports", "")) { |
|---|
| 1156 |
nvram_set("vlan0ports", "1 2 3 4 5*"); |
|---|
| 1157 |
nvram_set("vlan1ports", "0 5"); |
|---|
| 1158 |
} |
|---|
| 1159 |
if (!nvram_get("vlan1ports") || nvram_match("vlan1ports", "")) { |
|---|
| 1160 |
nvram_set("vlan0ports", "1 2 3 4 5*"); |
|---|
| 1161 |
nvram_set("vlan1ports", "0 5"); |
|---|
| 1162 |
} |
|---|
| 1163 |
|
|---|
| 1164 |
} else if (brand == ROUTER_BUFFALO_WZRG144NH) { |
|---|
| 1165 |
if (!nvram_get("vlan1ports") || nvram_match("vlan1ports", "")) { |
|---|
| 1166 |
nvram_set("vlan1ports", "4 8"); |
|---|
| 1167 |
nvram_set("vlan2ports", "0 1 2 3 8*"); |
|---|
| 1168 |
} |
|---|
| 1169 |
if (!nvram_get("vlan2ports") || nvram_match("vlan2ports", "")) { |
|---|
| 1170 |
nvram_set("vlan1ports", "4 8"); |
|---|
| 1171 |
nvram_set("vlan2ports", "0 1 2 3 8*"); |
|---|
| 1172 |
} |
|---|
| 1173 |
|
|---|
| 1174 |
} else { |
|---|
| 1175 |
if (!nvram_get("vlan0hwname") || nvram_match("vlan0hwname", "")) |
|---|
| 1176 |
nvram_set("vlan0hwname", "et0"); |
|---|
| 1177 |
if (!nvram_get("vlan1hwname") || nvram_match("vlan1hwname", "")) |
|---|
| 1178 |
nvram_set("vlan1hwname", "et0"); |
|---|
| 1179 |
|
|---|
| 1180 |
switch (brand) { |
|---|
| 1181 |
case ROUTER_MOTOROLA: |
|---|
| 1182 |
case ROUTER_MOTOROLA_V1: |
|---|
| 1183 |
case ROUTER_MOTOROLA_WE800G: |
|---|
| 1184 |
case ROUTER_RT210W: |
|---|
| 1185 |
if (et0mac != NULL) |
|---|
| 1186 |
nvram_set("et0macaddr", et0mac); |
|---|
| 1187 |
if (et1mac != NULL) |
|---|
| 1188 |
nvram_set("et1macaddr", et1mac); |
|---|
| 1189 |
break; |
|---|
| 1190 |
} |
|---|
| 1191 |
|
|---|
| 1192 |
if (!nvram_get("vlan0ports") || nvram_match("vlan0ports", "")) { |
|---|
| 1193 |
switch (brand) { |
|---|
| 1194 |
case ROUTER_LINKSYS_WTR54GS: |
|---|
| 1195 |
nvram_set("vlan0ports", "0 5*"); |
|---|
| 1196 |
break; |
|---|
| 1197 |
case ROUTER_ASUS_WL500G_PRE: |
|---|
| 1198 |
nvram_set("vlan0ports", "1 2 3 4 5*"); |
|---|
| 1199 |
break; |
|---|
| 1200 |
case ROUTER_MOTOROLA: |
|---|
| 1201 |
case ROUTER_WRT54G_V8: |
|---|
| 1202 |
case ROUTER_BELKIN_F5D7231_V2000: |
|---|
| 1203 |
nvram_set("vlan0ports", "3 2 1 0 5*"); |
|---|
| 1204 |
break; |
|---|
| 1205 |
case ROUTER_LINKSYS_WRT55AG: |
|---|
| 1206 |
case ROUTER_RT480W: |
|---|
| 1207 |
case ROUTER_DELL_TRUEMOBILE_2300_V2: |
|---|
| 1208 |
case ROUTER_ASUS_WL520G: |
|---|
| 1209 |
case ROUTER_ASUS_WL500G_PRE_V2: |
|---|
| 1210 |
case ROUTER_WRT54G_V81: |
|---|
| 1211 |
case ROUTER_BELKIN_F5D7230_V3000: |
|---|
| 1212 |
nvram_set("vlan0ports", "0 1 2 3 5*"); |
|---|
| 1213 |
break; |
|---|
| 1214 |
case ROUTER_LINKSYS_WRH54G: |
|---|
| 1215 |
case ROUTER_ASUS_WL500GD: |
|---|
| 1216 |
case ROUTER_BUFFALO_WBR2G54S: |
|---|
| 1217 |
nvram_set("vlan0ports", "4 3 2 1 5*"); |
|---|
| 1218 |
break; |
|---|
| 1219 |
case ROUTER_USR_5461: |
|---|
| 1220 |
nvram_set("vlan0ports", "4 1 2 3 5*"); |
|---|
| 1221 |
break; |
|---|
| 1222 |
default: |
|---|
| 1223 |
if (nvram_match("bootnv_ver", "4") |
|---|
| 1224 |
|| nvram_match("boardnum", |
|---|
| 1225 |
"WAP54GV3_8M_0614")) |
|---|
| 1226 |
nvram_set("vlan0ports", "3 2 1 0 5*"); |
|---|
| 1227 |
else |
|---|
| 1228 |
nvram_set("vlan0ports", "1 2 3 4 5*"); |
|---|
| 1229 |
break; |
|---|
| 1230 |
} |
|---|
| 1231 |
} |
|---|
| 1232 |
|
|---|
| 1233 |
if (!nvram_get("vlan1ports") || nvram_match("vlan1ports", "")) { |
|---|
| 1234 |
switch (brand) { |
|---|
| 1235 |
case ROUTER_LINKSYS_WTR54GS: |
|---|
| 1236 |
nvram_set("vlan1ports", "1 5"); |
|---|
| 1237 |
break; |
|---|
| 1238 |
case ROUTER_ASUS_WL500G_PRE: |
|---|
| 1239 |
case ROUTER_LINKSYS_WRH54G: |
|---|
| 1240 |
case ROUTER_USR_5461: |
|---|
| 1241 |
nvram_set("vlan1ports", "0 5"); |
|---|
| 1242 |
break; |
|---|
| 1243 |
case ROUTER_MOTOROLA: |
|---|
| 1244 |
case ROUTER_WRT54G_V8: |
|---|
| 1245 |
case ROUTER_WRT54G_V81: |
|---|
| 1246 |
case ROUTER_LINKSYS_WRT55AG: |
|---|
| 1247 |
case ROUTER_RT480W: |
|---|
| 1248 |
case ROUTER_DELL_TRUEMOBILE_2300_V2: |
|---|
| 1249 |
case ROUTER_ASUS_WL520G: |
|---|
| 1250 |
case ROUTER_ASUS_WL500G_PRE_V2: |
|---|
| 1251 |
case ROUTER_BELKIN_F5D7230_V3000: |
|---|
| 1252 |
case ROUTER_BELKIN_F5D7231_V2000: |
|---|
| 1253 |
nvram_set("vlan1ports", "4 5"); |
|---|
| 1254 |
break; |
|---|
| 1255 |
default: |
|---|
| 1256 |
if (nvram_match("bootnv_ver", "4") |
|---|
| 1257 |
|| nvram_match("boardnum", |
|---|
| 1258 |
"WAP54GV3_8M_0614")) |
|---|
| 1259 |
nvram_set("vlan1ports", "4 5"); |
|---|
| 1260 |
else |
|---|
| 1261 |
nvram_set("vlan1ports", "0 5"); |
|---|
| 1262 |
break; |
|---|
| 1263 |
} |
|---|
| 1264 |
} |
|---|
| 1265 |
|
|---|
| 1266 |
} |
|---|
| 1267 |
if (brand == ROUTER_WRT54G || brand == ROUTER_WRT54G1X |
|---|
| 1268 |
|| brand == ROUTER_LINKSYS_WRT55AG) { |
|---|
| 1269 |
if (!nvram_get("aa0")) |
|---|
| 1270 |
nvram_set("aa0", "3"); |
|---|
| 1271 |
if (!nvram_get("ag0")) |
|---|
| 1272 |
nvram_set("ag0", "255"); |
|---|
| 1273 |
if (!nvram_get("gpio2")) |
|---|
| 1274 |
nvram_set("gpio2", "adm_eecs"); |
|---|
| 1275 |
if (!nvram_get("gpio3")) |
|---|
| 1276 |
nvram_set("gpio3", "adm_eesk"); |
|---|
| 1277 |
if (!nvram_get("gpio5")) |
|---|
| 1278 |
nvram_set("gpio5", "adm_eedi"); |
|---|
| 1279 |
if (!nvram_get("gpio6")) |
|---|
| 1280 |
nvram_set("gpio6", "adm_rc"); |
|---|
| 1281 |
if (!nvram_get("boardrev") || nvram_match("boardrev", "")) |
|---|
| 1282 |
nvram_set("boardrev", "0x10"); |
|---|
| 1283 |
if (!nvram_get("boardflags") || nvram_match("boardflags", "")) |
|---|
| 1284 |
nvram_set("boardflags", "0x0388"); |
|---|
| 1285 |
if (!nvram_get("boardflags2")) |
|---|
| 1286 |
nvram_set("boardflags2", "0"); |
|---|
| 1287 |
} |
|---|
| 1288 |
/* |
|---|
| 1289 |
* Always set OS defaults |
|---|
| 1290 |
*/ |
|---|
| 1291 |
nvram_set("os_name", "linux"); |
|---|
| 1292 |
nvram_set("os_version", EPI_VERSION_STR); |
|---|
| 1293 |
|
|---|
| 1294 |
#ifdef HAVE_SPUTNIK_APD |
|---|
| 1295 |
/* |
|---|
| 1296 |
* Added for Sputnik Agent |
|---|
| 1297 |
*/ |
|---|
| 1298 |
nvram_unset("sputnik_mjid"); |
|---|
| 1299 |
nvram_unset("sputnik_rereg"); |
|---|
| 1300 |
#endif |
|---|
| 1301 |
nvram_unset("probe_blacklist"); |
|---|
| 1302 |
|
|---|
| 1303 |
if (nvram_get("overclocking") == NULL) |
|---|
| 1304 |
nvram_set("overclocking", nvram_safe_get("clkfreq")); |
|---|
| 1305 |
cprintf("start overclocking\n"); |
|---|
| 1306 |
start_overclocking(); |
|---|
| 1307 |
cprintf("done()"); |
|---|
| 1308 |
if (nvram_get("http_username") != NULL) { |
|---|
| 1309 |
if (nvram_match("http_username", "")) { |
|---|
| 1310 |
#ifdef HAVE_POWERNOC |
|---|
| 1311 |
nvram_set("http_username", "bJz7PcC1rCRJQ"); // admin |
|---|
| 1312 |
#else |
|---|
| 1313 |
nvram_set("http_username", "bJ/GddyoJuiU2"); // root |
|---|
| 1314 |
#endif |
|---|
| 1315 |
} |
|---|
| 1316 |
} |
|---|
| 1317 |
if (atoi(nvram_safe_get("nvram_ver")) < 3) { |
|---|
| 1318 |
nvram_set("nvram_ver", "3"); |
|---|
| 1319 |
nvram_set("block_multicast", "1"); |
|---|
| 1320 |
} |
|---|
| 1321 |
nvram_set("gozila_action", "0"); |
|---|
| 1322 |
nvram_set("generate_key", "0"); |
|---|
| 1323 |
nvram_set("clone_wan_mac", "0"); |
|---|
| 1324 |
nvram_unset("flash_active"); |
|---|
| 1325 |
|
|---|
| 1326 |
cprintf("check CFE nv\n"); |
|---|
| 1327 |
if (check_now_boot() == PMON_BOOT) |
|---|
| 1328 |
check_pmon_nv(); |
|---|
| 1329 |
else |
|---|
| 1330 |
check_cfe_nv(); |
|---|
| 1331 |
cprintf("restore defaults\n"); |
|---|
| 1332 |
|
|---|
| 1333 |
/* |
|---|
| 1334 |
* Commit values |
|---|
| 1335 |
*/ |
|---|
| 1336 |
if (restore_defaults) { |
|---|
| 1337 |
int i; |
|---|
| 1338 |
|
|---|
| 1339 |
unset_nvram(); |
|---|
| 1340 |
nvram_commit(); |
|---|
| 1341 |
cprintf("done\n"); |
|---|
| 1342 |
for (i = 0; i < MAX_NVPARSE; i++) { |
|---|
| 1343 |
del_wds_wsec(0, i); |
|---|
| 1344 |
del_wds_wsec(1, i); |
|---|
| 1345 |
} |
|---|
| 1346 |
} |
|---|
| 1347 |
} |
|---|
| 1348 |
|
|---|
| 1349 |
void start_drivers(void) |
|---|
| 1350 |
{ |
|---|
| 1351 |
/* |
|---|
| 1352 |
* #ifdef HAVE_USB //load usb driver. we will add samba server, ftp |
|---|
| 1353 |
* server and ctorrent support in future modules = "usbcore usb-ohci |
|---|
| 1354 |
* usb-uhci ehci-hcd scsi_mod usb-storage ide-core ide-detect |
|---|
| 1355 |
* ide-disk ide-scsi cdrom ide-cd printer sd_mod sr_mod" foreach |
|---|
| 1356 |
* (module, modules, next) { cprintf ("loading %s\n", module); |
|---|
| 1357 |
* insmod(module); } #endif |
|---|
| 1358 |
*/ |
|---|
| 1359 |
|
|---|
| 1360 |
#ifdef HAVE_USB |
|---|
| 1361 |
|
|---|
| 1362 |
if (nvram_match("usb_enable", "1")) { |
|---|
| 1363 |
led_control(LED_USB, LED_ON); |
|---|
| 1364 |
|
|---|
| 1365 |
cprintf("loading usbcore\n"); |
|---|
| 1366 |
insmod("usbcore"); |
|---|
| 1367 |
|
|---|
| 1368 |
if (nvram_match("usb_uhci", "1")) { |
|---|
| 1369 |
cprintf("loading usb-uhci\n"); |
|---|
| 1370 |
insmod("usb-uhci"); |
|---|
| 1371 |
} |
|---|
| 1372 |
|
|---|
| 1373 |
if (nvram_match("usb_ohci", "1")) { |
|---|
| 1374 |
cprintf("loading usb-ohci\n"); |
|---|
| 1375 |
insmod("usb-ohci"); |
|---|
| 1376 |
} |
|---|
| 1377 |
|
|---|
| 1378 |
if (nvram_match("usb_usb2", "1")) { |
|---|
| 1379 |
cprintf("loading usb2 module\n"); |
|---|
| 1380 |
insmod("ehci-hcd"); |
|---|
| 1381 |
} |
|---|
| 1382 |
|
|---|
| 1383 |
if (nvram_match("usb_storage", "1")) { |
|---|
| 1384 |
cprintf("loading scsi_mod\n"); |
|---|
| 1385 |
insmod("scsi_mod"); |
|---|
| 1386 |
cprintf("loading sd_mod\n"); |
|---|
| 1387 |
insmod("sd_mod"); |
|---|
| 1388 |
cprintf("loading usb-storage\n"); |
|---|
| 1389 |
insmod("usb-storage"); |
|---|
| 1390 |
|
|---|
| 1391 |
if (nvram_match("usb_fs_ext3", "1")) { |
|---|
| 1392 |
cprintf("loading jbd\n"); |
|---|
| 1393 |
insmod("mbcache"); |
|---|
| 1394 |
cprintf("loading ext2\n"); |
|---|
| 1395 |
insmod("ext2"); |
|---|
| 1396 |
#ifdef HAVE_USB_ADVANCED |
|---|
| 1397 |
cprintf("loading jbd\n"); |
|---|
| 1398 |
insmod("jbd"); |
|---|
| 1399 |
cprintf("loading ext3\n"); |
|---|
| 1400 |
insmod("ext3"); |
|---|
| 1401 |
#endif |
|---|
| 1402 |
} |
|---|
| 1403 |
|
|---|
| 1404 |
if (nvram_match("usb_fs_fat", "1")) { |
|---|
| 1405 |
cprintf("loading usb_fs_fat\n"); |
|---|
| 1406 |
insmod("fat"); |
|---|
| 1407 |
cprintf("loading usb_fs_vfat\n"); |
|---|
| 1408 |
insmod("vfat"); |
|---|
| 1409 |
cprintf("loading fs_msdos\n"); |
|---|
| 1410 |
insmod("msdos"); |
|---|
| 1411 |
} |
|---|
| 1412 |
|
|---|
| 1413 |
if (nvram_match("usb_fs_xfs", "1")) { |
|---|
| 1414 |
cprintf("loading usb_fs_xfs\n"); |
|---|
| 1415 |
insmod("xfs"); |
|---|
| 1416 |
} |
|---|
| 1417 |
// if (nvram_match ("usb_fs_xfs", "1")) |
|---|
| 1418 |
// { |
|---|
| 1419 |
// cprintf ("loading usb_fs_xfs\n"); |
|---|
| 1420 |
// insmod("xfs"); |
|---|
| 1421 |
// } |
|---|
| 1422 |
} |
|---|
| 1423 |
|
|---|
| 1424 |
if (nvram_match("usb_printer", "1")) { |
|---|
| 1425 |
cprintf("loading printer\n"); |
|---|
| 1426 |
insmod("printer"); |
|---|
| 1427 |
} |
|---|
| 1428 |
} else { |
|---|
| 1429 |
led_control(LED_USB, LED_OFF); |
|---|
| 1430 |
} |
|---|
| 1431 |
#endif |
|---|
| 1432 |
|
|---|
| 1433 |
} |
|---|
| 1434 |
|
|---|
| 1435 |
/* |
|---|
| 1436 |
* States |
|---|
| 1437 |
*/ |
|---|
| 1438 |
enum { |
|---|
| 1439 |
RESTART, |
|---|
| 1440 |
STOP, |
|---|
| 1441 |
START, |
|---|
| 1442 |
TIMER, |
|---|
| 1443 |
USER, |
|---|
| 1444 |
IDLE, |
|---|
| 1445 |
}; |
|---|
| 1446 |
static int state = START; |
|---|
| 1447 |
static int signalled = -1; |
|---|
| 1448 |
|
|---|
| 1449 |
/* |
|---|
| 1450 |
* Signal handling |
|---|
| 1451 |
*/ |
|---|
| 1452 |
static void rc_signal(int sig) |
|---|
| 1453 |
{ |
|---|
| 1454 |
if (state == IDLE) { |
|---|
| 1455 |
if (sig == SIGHUP) { |
|---|
| 1456 |
printf("signalling RESTART\n"); |
|---|
| 1457 |
signalled = RESTART; |
|---|
| 1458 |
} else if (sig == SIGUSR2) { |
|---|
| 1459 |
printf("signalling START\n"); |
|---|
| 1460 |
signalled = START; |
|---|
| 1461 |
} else if (sig == SIGINT) { |
|---|
| 1462 |
printf("signalling STOP\n"); |
|---|
| 1463 |
signalled = STOP; |
|---|
| 1464 |
} else if (sig == SIGALRM) { |
|---|
| 1465 |
printf("signalling TIMER\n"); |
|---|
| 1466 |
signalled = TIMER; |
|---|
| 1467 |
} else if (sig == SIGUSR1) { // Receive from WEB |
|---|
| 1468 |
printf("signalling USER1\n"); |
|---|
| 1469 |
signalled = USER; |
|---|
| 1470 |
} |
|---|
| 1471 |
|
|---|
| 1472 |
} |
|---|
| 1473 |
} |
|---|
| 1474 |
|
|---|
| 1475 |
/* |
|---|
| 1476 |
* Timer procedure |
|---|
| 1477 |
*/ |
|---|
| 1478 |
int do_timer(void) |
|---|
| 1479 |
{ |
|---|
| 1480 |
// do_ntp(); |
|---|
| 1481 |
return 0; |
|---|
| 1482 |
} |
|---|
| 1483 |
|
|---|
| 1484 |
#define CONVERT_NV(old, new) \ |
|---|
| 1485 |
if(nvram_get(old)) \ |
|---|
| 1486 |
nvram_set(new, nvram_safe_get(old)); |
|---|
| 1487 |
|
|---|
| 1488 |
void start_nvram(void) |
|---|
| 1489 |
{ |
|---|
| 1490 |
int i = 0; |
|---|
| 1491 |
|
|---|
| 1492 |
/* |
|---|
| 1493 |
* broadcom 3.11.48.7 change some nvram name |
|---|
| 1494 |
*/ |
|---|
| 1495 |
|
|---|
| 1496 |
nvram_unset("wl0_hwaddr"); // When disbale wireless, we must get |
|---|
| 1497 |
// |
|---|
| 1498 |
// null wireless mac */ |
|---|
| 1499 |
|
|---|
| 1500 |
nvram_set("wan_get_dns", ""); |
|---|
| 1501 |
nvram_set("filter_id", "1"); |
|---|
| 1502 |
nvram_set("wl_active_add_mac", "0"); |
|---|
| 1503 |
nvram_set("ddns_change", ""); |
|---|
| 1504 |
nvram_unset("action_service"); |
|---|
| 1505 |
nvram_set("wan_get_domain", ""); |
|---|
| 1506 |
|
|---|
| 1507 |
// if(!nvram_get("wl_macmode1")){ |
|---|
| 1508 |
// if(nvram_match("wl_macmode","disabled")) |
|---|
| 1509 |
// nvram_set("wl_macmode1","disabled"); |
|---|
| 1510 |
// else |
|---|
| 1511 |
// nvram_set("wl_macmode1","other"); |
|---|
| 1512 |
// } |
|---|
| 1513 |
if (nvram_match("wl_gmode", "5")) // Mixed mode had been |
|---|
| 1514 |
// changed to 5 |
|---|
| 1515 |
nvram_set("wl_gmode", "1"); |
|---|
| 1516 |
|
|---|
| 1517 |
if (nvram_match("wl_gmode", "4")) // G-ONLY mode had been |
|---|
| 1518 |
// changed to 2, after 1.40.1 |
|---|
| 1519 |
// for WiFi G certication |
|---|
| 1520 |
nvram_set("wl_gmode", "2"); |
|---|
| 1521 |
|
|---|
| 1522 |
// nvram_set("wl_country","Worldwide"); // The country always Worldwide |
|---|
| 1523 |
|
|---|
| 1524 |
nvram_set("ping_ip", ""); |
|---|
| 1525 |
nvram_set("ping_times", ""); |
|---|
| 1526 |
// nvram_set ("traceroute_ip", ""); |
|---|
| 1527 |
|
|---|
| 1528 |
nvram_set("filter_port", ""); // The name have been disbaled from |
|---|
| 1529 |
// 1.41.3 |
|---|
| 1530 |
|
|---|
| 1531 |
#ifdef HAVE_UPNP |
|---|
| 1532 |
if ((nvram_match("restore_defaults", "1")) |
|---|
| 1533 |
|| (nvram_match("upnpcas", "1"))) { |
|---|
| 1534 |
nvram_set("upnp_clear", "1"); |
|---|
| 1535 |
} else { |
|---|
| 1536 |
char s[32]; |
|---|
| 1537 |
char *nv; |
|---|
| 1538 |
|
|---|
| 1539 |
for (i = 0; i < MAX_NVPARSE; ++i) { |
|---|
| 1540 |
sprintf(s, "forward_port%d", i); |
|---|
| 1541 |
if ((nv = nvram_get(s)) != NULL) { |
|---|
| 1542 |
if (strstr(nv, "msmsgs")) |
|---|
| 1543 |
nvram_unset(s); |
|---|
| 1544 |
} |
|---|
| 1545 |
} |
|---|
| 1546 |
} |
|---|
| 1547 |
nvram_set("upnp_wan_proto", ""); |
|---|
| 1548 |
#endif |
|---|
| 1549 |
|
|---|
| 1550 |
/* |
|---|
| 1551 |
* The tkip and aes already are changed to wl_crypto from v3.63.3.0 |
|---|
| 1552 |
*/ |
|---|
| 1553 |
if (nvram_match("wl_wep", "tkip")) { |
|---|
| 1554 |
nvram_set("wl_crypto", "tkip"); |
|---|
| 1555 |
} else if (nvram_match("wl_wep", "aes")) { |
|---|
| 1556 |
nvram_set("wl_crypto", "aes"); |
|---|
| 1557 |
} else if (nvram_match("wl_wep", "tkip+aes")) { |
|---|
| 1558 |
nvram_set("wl_crypto", "tkip+aes"); |
|---|
| 1559 |
} |
|---|
| 1560 |
|
|---|
| 1561 |
if (nvram_match("wl_wep", "restricted")) |
|---|
| 1562 |
nvram_set("wl_wep", "enabled"); // the nas need this value, |
|---|
| 1563 |
// the "restricted" is no |
|---|
| 1564 |
// longer need. (20040624 by |
|---|
| 1565 |
// honor) |
|---|
| 1566 |
|
|---|
| 1567 |
#ifdef HAVE_SET_BOOT |
|---|
| 1568 |
if (!nvram_match("boot_wait_web", "0")) |
|---|
| 1569 |
nvram_set("boot_wait_web", "1"); |
|---|
| 1570 |
#endif |
|---|
| 1571 |
#ifndef HAVE_BUFFALO |
|---|
| 1572 |
if (check_hw_type() == BCM5352E_CHIP) { |
|---|
| 1573 |
nvram_set("opo", "0"); // OFDM power reducement in quarter |
|---|
| 1574 |
// dbm (2 dbm in this case) |
|---|
| 1575 |
nvram_set("ag0", "0"); // Antenna Gain definition in dbm |
|---|
| 1576 |
} |
|---|
| 1577 |
#endif |
|---|
| 1578 |
|
|---|
| 1579 |
if (nvram_match("svqos_port1bw", "full")) |
|---|
| 1580 |
nvram_set("svqos_port1bw", "FULL"); |
|---|
| 1581 |
if (nvram_match("svqos_port2bw", "full")) |
|---|
| 1582 |
nvram_set("svqos_port2bw", "FULL"); |
|---|
| 1583 |
if (nvram_match("svqos_port3bw", "full")) |
|---|
| 1584 |
nvram_set("svqos_port3bw", "FULL"); |
|---|
| 1585 |
if (nvram_match("svqos_port4bw", "full")) |
|---|
| 1586 |
nvram_set("svqos_port4bw", "FULL"); |
|---|
| 1587 |
// dirty fix for WBR2 units |
|---|
| 1588 |
|
|---|
| 1589 |
// clean old filter_servicesX to free nvram |
|---|
| 1590 |
nvram_unset("filter_services0"); |
|---|
| 1591 |
nvram_unset("filter_services1"); |
|---|
| 1592 |
nvram_unset("filter_services2"); |
|---|
| 1593 |
nvram_unset("filter_services3"); |
|---|
| 1594 |
nvram_unset("filter_services4"); |
|---|
| 1595 |
nvram_unset("filter_services5"); |
|---|
| 1596 |
nvram_unset("filter_services6"); |
|---|
| 1597 |
nvram_unset("filter_services7"); |
|---|
| 1598 |
|
|---|
| 1599 |
nvram_unset("vdsl_state"); // important (this value should never |
|---|
| 1600 |
// |
|---|
| 1601 |
// be commited, but if this will fix |
|---|
| 1602 |
// the vlan7 issue) |
|---|
| 1603 |
nvram_unset("fromvdsl"); // important (this value should never be |
|---|
| 1604 |
// commited, but if this will fix the vlan7 |
|---|
| 1605 |
// issue) |
|---|
| 1606 |
|
|---|
| 1607 |
nvram_unset("do_reboot"); //for GUI, see broadcom.c |
|---|
| 1608 |
|
|---|
| 1609 |
#ifdef DIST |
|---|
| 1610 |
nvram_set("dist_type", DIST); |
|---|
| 1611 |
#endif |
|---|
| 1612 |
|
|---|
| 1613 |
{ |
|---|
| 1614 |
|
|---|
| 1615 |
#ifdef DIST |
|---|
| 1616 |
#ifndef HAVE_TW6600 |
|---|
| 1617 |
#ifdef HAVE_MICRO |
|---|
| 1618 |
// if dist_type micro, check styles, and force to elegant if needed |
|---|
| 1619 |
|
|---|
| 1620 |
#ifdef HAVE_ROUTERSTYLE |
|---|
| 1621 |
char *style = nvram_safe_get("router_style"); |
|---|
| 1622 |
|
|---|
| 1623 |
if (!strstr("blue cyan elegant green orange red yellow", style)) |
|---|
| 1624 |
#endif |
|---|
| 1625 |
{ |
|---|
| 1626 |
nvram_set("router_style", "elegant"); |
|---|
| 1627 |
} |
|---|
| 1628 |
#endif |
|---|
| 1629 |
#endif |
|---|
| 1630 |
#endif |
|---|
| 1631 |
} |
|---|
| 1632 |
|
|---|
| 1633 |
#ifdef HAVE_WIVIZ |
|---|
| 1634 |
if (!strlen(nvram_safe_get("hopseq")) |
|---|
| 1635 |
|| !strlen(nvram_safe_get("hopdwell"))) { |
|---|
| 1636 |
char *channel = nvram_safe_get("wl0_channel"); |
|---|
| 1637 |
|
|---|
| 1638 |
nvram_set("hopdwell", "1000"); |
|---|
| 1639 |
nvram_set("hopseq", channel); |
|---|
| 1640 |
} |
|---|
| 1641 |
#endif |
|---|
| 1642 |
nvram_unset("lasthour"); |
|---|
| 1643 |
#ifdef HAVE_AQOS |
|---|
| 1644 |
//filter hostapd shaping rules |
|---|
| 1645 |
char *qos_mac = nvram_safe_get("svqos_macs"); |
|---|
| 1646 |
|
|---|
| 1647 |
if (strlen(qos_mac) > 0) { |
|---|
| 1648 |
char *newqos = malloc(strlen(qos_mac)); |
|---|
| 1649 |
|
|---|
| 1650 |
memset(newqos, 0, strlen(qos_mac)); |
|---|
| 1651 |
char level[32], level2[32], data[32], type[32]; |
|---|
| 1652 |
|
|---|
| 1653 |
do { |
|---|
| 1654 |
if (sscanf |
|---|
| 1655 |
(qos_mac, "%31s %31s %31s %31s |", data, level, |
|---|
| 1656 |
level2, type) < 4) |
|---|
| 1657 |
break; |
|---|
| 1658 |
if (strcmp(type, "hostapd") && strcmp(type, "pppd")) { |
|---|
| 1659 |
if (strlen(newqos) > 0) |
|---|
| 1660 |
sprintf(newqos, "%s %s %s %s %s |", |
|---|
| 1661 |
newqos, data, level, level2, |
|---|
| 1662 |
type); |
|---|
| 1663 |
else |
|---|
| 1664 |
sprintf(newqos, "%s %s %s %s |", data, |
|---|
| 1665 |
level, level2, type); |
|---|
| 1666 |
|
|---|
| 1667 |
} |
|---|
| 1668 |
} |
|---|
| 1669 |
while ((qos_mac = strpbrk(++qos_mac, "|")) && qos_mac++); |
|---|
| 1670 |
nvram_set("svqos_macs", newqos); |
|---|
| 1671 |
free(newqos); |
|---|
| 1672 |
} |
|---|
| 1673 |
#endif |
|---|
| 1674 |
return; |
|---|
| 1675 |
} |
|---|
| 1676 |
|
|---|
| 1677 |
static void unset_nvram(void) |
|---|
| 1678 |
{ |
|---|
| 1679 |
#ifndef MPPPOE_SUPPORT |
|---|
| 1680 |
nvram_safe_unset("ppp_username_1"); |
|---|
| 1681 |
nvram_safe_unset("ppp_passwd_1"); |
|---|
| 1682 |
nvram_safe_unset("ppp_idletime_1"); |
|---|
| 1683 |
nvram_safe_unset("ppp_demand_1"); |
|---|
| 1684 |
nvram_safe_unset("ppp_redialperiod_1"); |
|---|
| 1685 |
nvram_safe_unset("ppp_service_1"); |
|---|
| 1686 |
nvram_safe_unset("mpppoe_enable"); |
|---|
| 1687 |
nvram_safe_unset("mpppoe_dname"); |
|---|
| 1688 |
#endif |
|---|
| 1689 |
#ifndef HAVE_HTTPS |
|---|
| 1690 |
nvram_safe_unset("remote_mgt_https"); |
|---|
| 1691 |
#endif |
|---|
| 1692 |
#ifndef HSIAB_SUPPORT |
|---|
| 1693 |
nvram_safe_unset("hsiab_mode"); |
|---|
| 1694 |
nvram_safe_unset("hsiab_provider"); |
|---|
| 1695 |
nvram_safe_unset("hsiab_device_id"); |
|---|
| 1696 |
nvram_safe_unset("hsiab_device_password"); |
|---|
| 1697 |
nvram_safe_unset("hsiab_admin_url"); |
|---|
| 1698 |
nvram_safe_unset("hsiab_registered"); |
|---|
| 1699 |
nvram_safe_unset("hsiab_configured"); |
|---|
| 1700 |
nvram_safe_unset("hsiab_register_ops"); |
|---|
| 1701 |
nvram_safe_unset("hsiab_session_ops"); |
|---|
| 1702 |
nvram_safe_unset("hsiab_config_ops"); |
|---|
| 1703 |
nvram_safe_unset("hsiab_manual_reg_ops"); |
|---|
| 1704 |
nvram_safe_unset("hsiab_proxy_host"); |
|---|
| 1705 |
nvram_safe_unset("hsiab_proxy_port"); |
|---|
| 1706 |
nvram_safe_unset("hsiab_conf_time"); |
|---|
| 1707 |
nvram_safe_unset("hsiab_stats_time"); |
|---|
| 1708 |
nvram_safe_unset("hsiab_session_time"); |
|---|
| 1709 |
nvram_safe_unset("hsiab_sync"); |
|---|
| 1710 |
nvram_safe_unset("hsiab_config"); |
|---|
| 1711 |
#endif |
|---|
| 1712 |
|
|---|
| 1713 |
#ifndef HEARTBEAT_SUPPORT |
|---|
| 1714 |
nvram_safe_unset("hb_server_ip"); |
|---|
| 1715 |
nvram_safe_unset("hb_server_domain"); |
|---|
| 1716 |
#endif |
|---|
| 1717 |
|
|---|
| 1718 |
#ifndef PARENTAL_CONTROL_SUPPORT |
|---|
| 1719 |
nvram_safe_unset("artemis_enable"); |
|---|
| 1720 |
nvram_safe_unset("artemis_SVCGLOB"); |
|---|
| 1721 |
nvram_safe_unset("artemis_HB_DB"); |
|---|
| 1722 |
nvram_safe_unset("artemis_provisioned"); |
|---|
| 1723 |
#endif |
|---|
| 1724 |
|
|---|
| 1725 |
#ifndef WL_STA_SUPPORT |
|---|
| 1726 |
// nvram_safe_unset("wl_ap_ssid"); |
|---|
| 1727 |
// nvram_safe_unset("wl_ap_ip"); |
|---|
| 1728 |
#endif |
|---|
| 1729 |
|
|---|
| 1730 |
} |
|---|