1/*
2 * Router default NVRAM values
3 *
4 * Copyright (C) 2015, Broadcom Corporation. All Rights Reserved.
5 *
6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
13 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
15 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
16 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 *
18 * $Id: defaults.c 517676 2014-11-26 09:02:04Z $
19 */
20
21#include <epivers.h>
22#include "router_version.h"
23#include <typedefs.h>
24#include <string.h>
25#include <ctype.h>
26#include <bcmnvram.h>
27#include <wlioctl.h>
28#include <stdio.h>
29#include <ezc.h>
30#include <bcmconfig.h>
31#include <shutils.h>
32
33#define XSTR(s) STR(s)
34#define STR(s) #s
35
36struct nvram_tuple router_defaults[] = {
37	/* OS parameters */
38	{ "os_name", "", 0 },			 /* OS name string */
39	{ "os_version", ROUTER_VERSION_STR, 0 }, /* OS revision */
40	{ "os_date", __DATE__, 0 },		 /* OS date */
41	{ "wl_version", EPI_VERSION_STR, 0 },	 /* OS revision */
42
43	/* Version */
44	{ "nvram_version", NVRAM_SOFTWARE_VERSION, 0 },
45
46	/* Miscellaneous parameters */
47	{ "timer_interval", "3600", 0 },	/* Timer interval in seconds */
48	{ "ntp_server", "192.5.41.40 192.5.41.41 133.100.9.2", 0 },		/* NTP server */
49	{ "time_zone", "PST8PDT", 0 },		/* Time zone (GNU TZ format) */
50	{ "log_level", "0", 0 },		/* Bitmask 0:off 1:denied 2:accepted */
51	{ "upnp_enable", "1", 0 },		/* Start UPnP */
52#ifdef __CONFIG_DLNA_DMR__
53	{ "dlna_dmr_enable", "1", 0 },		/* Start DLNA Renderer */
54#endif
55#ifdef __CONFIG_DLNA_DMS__
56	{ "dlna_dms_enable", "1", 0 },		/* Start DLNA Server */
57#endif
58	{ "ezc_enable", "1", 0 },		/* Enable EZConfig updates */
59	{ "ezc_version", EZC_VERSION_STR, 0 },	/* EZConfig version */
60	{ "is_default", "1", 0 },		/* is it default setting: 1:yes 0:no */
61	{ "os_server", "", 0 },			/* URL for getting upgrades */
62	{ "stats_server", "", 0 },		/* URL for posting stats */
63	{ "console_loglevel", "1", 0 },		/* Kernel panics only */
64
65	/* Big switches */
66	{ "router_disable", "0", 0 },		/* lan_proto=static lan_stp=0 wan_proto=disabled */
67	{ "ure_disable", "1", 0 },		/* sets APSTA for radio and puts wirelesss
68						 * interfaces in correct lan
69						 */
70	{ "fw_disable", "0", 0 },		/* Disable firewall (allow new connections from the
71						 * WAN)
72						 */
73
74	{ "log_ipaddr", "", 0 },		/* syslog recipient */
75#ifdef BCMQOS
76	{ "wan_mtu",			"1500"			},
77#endif
78	/* LAN H/W parameters */
79	{ "lan_ifname", "", 0 },		/* LAN interface name */
80	{ "lan_ifnames", "", 0 },		/* Enslaved LAN interfaces */
81	{ "lan_hwnames", "", 0 },		/* LAN driver names (e.g. et0) */
82	{ "lan_hwaddr", "", 0 },		/* LAN interface MAC address */
83
84	/* LAN TCP/IP parameters */
85	{ "lan_dhcp", "0", 0 },			/* DHCP client [static|dhcp] */
86	{ "lan_ipaddr", "192.168.1.1", 0 },	/* LAN IP address */
87	{ "lan_netmask", "255.255.255.0", 0 },	/* LAN netmask */
88	{ "lan_gateway", "192.168.1.1", 0 },	/* LAN gateway */
89	{ "lan_proto", "dhcp", 0 },		/* DHCP server [static|dhcp] */
90	{ "lan_wins", "", 0 },			/* x.x.x.x x.x.x.x ... */
91	{ "lan_domain", "", 0 },		/* LAN domain name */
92	{ "lan_lease", "86400", 0 },		/* LAN lease time in seconds */
93	{ "lan_stp", "1", 0 },			/* LAN spanning tree protocol */
94	{ "lan_route", "", 0 },			/* Static routes
95						 * (ipaddr:netmask:gateway:metric:ifname ...)
96						 */
97	/* Guest H/W parameters */
98	{ "lan1_ifname", "", 0 },		/* LAN interface name */
99	{ "lan1_ifnames", "", 0 },		/* Enslaved LAN interfaces */
100	{ "lan1_hwnames", "", 0 },		/* LAN driver names (e.g. et0) */
101	{ "lan1_hwaddr", "", 0 },		/* LAN interface MAC address */
102
103	/* Guest TCP/IP parameters */
104	{ "lan1_dhcp", "0", 0 },			/* DHCP client [static|dhcp] */
105	{ "lan1_ipaddr", "192.168.2.1", 0 },	/* LAN IP address */
106	{ "lan1_netmask", "255.255.255.0", 0 },	/* LAN netmask */
107	{ "lan1_gateway", "192.168.2.1", 0 },	/* LAN gateway */
108	{ "lan1_proto", "dhcp", 0 },		/* DHCP server [static|dhcp] */
109	{ "lan1_wins", "", 0 },			/* x.x.x.x x.x.x.x ... */
110	{ "lan1_domain", "", 0 },		/* LAN domain name */
111	{ "lan1_lease", "86400", 0 },		/* LAN lease time in seconds */
112	{ "lan1_stp", "1", 0 },			/* LAN spanning tree protocol */
113	{ "lan1_route", "", 0 },			/* Static routes
114						 * (ipaddr:netmask:gateway:metric:ifname ...)
115						 */
116#ifdef __CONFIG_NAT__
117	/* WAN H/W parameters */
118	{ "wan_ifname", "", 0 },		/* WAN interface name */
119	{ "wan_ifnames", "", 0 },		/* WAN interface names */
120	{ "wan_hwname", "", 0 },		/* WAN driver name (e.g. et1) */
121	{ "wan_hwaddr", "", 0 },		/* WAN interface MAC address */
122
123	/* WAN TCP/IP parameters */
124	{ "wan_proto", "dhcp", 0 },		/* [static|dhcp|pppoe|disabled] */
125	{ "wan_ipaddr", "0.0.0.0", 0 },		/* WAN IP address */
126	{ "wan_netmask", "0.0.0.0", 0 },	/* WAN netmask */
127	{ "wan_gateway", "0.0.0.0", 0 },	/* WAN gateway */
128	{ "wan_dns", "", 0 },			/* x.x.x.x x.x.x.x ... */
129	{ "wan_wins", "", 0 },			/* x.x.x.x x.x.x.x ... */
130	{ "wan_hostname", "", 0 },		/* WAN hostname */
131	{ "wan_domain", "", 0 },		/* WAN domain name */
132	{ "wan_lease", "86400", 0 },		/* WAN lease time in seconds */
133
134	/* PPPoE parameters */
135	{ "wan_pppoe_ifname", "", 0 },		/* PPPoE enslaved interface */
136	{ "wan_pppoe_username", "", 0 },	/* PPP username */
137	{ "wan_pppoe_passwd", "", 0 },		/* PPP password */
138	{ "wan_pppoe_idletime", "60", 0 },	/* Dial on demand max idle time (seconds) */
139	{ "wan_pppoe_keepalive", "0", 0 },	/* Restore link automatically */
140	{ "wan_pppoe_demand", "0", 0 },		/* Dial on demand */
141	{ "wan_pppoe_mru", "1492", 0 },		/* Negotiate MRU to this value */
142	{ "wan_pppoe_mtu", "1492", 0 },		/* Negotiate MTU to the smaller of this value or
143						 * the peer MRU
144						 */
145	{ "wan_pppoe_service", "", 0 },		/* PPPoE service name */
146	{ "wan_pppoe_ac", "", 0 },		/* PPPoE access concentrator name */
147	/* Misc WAN parameters */
148	{ "wan_desc", "", 0 },			/* WAN connection description */
149	{ "wan_route", "", 0 },			/* Static routes
150						 * (ipaddr:netmask:gateway:metric:ifname ...)
151						 */
152	{ "wan_primary", "0", 0 },		/* Primary wan connection */
153
154	{ "wan_unit", "0", 0 },			/* Last configured connection */
155
156	/* Filters */
157	{ "filter_maclist", "", 0 },		/* xx:xx:xx:xx:xx:xx ... */
158	{ "filter_macmode", "deny", 0 },	/* "allow" only, "deny" only, or "disabled"
159						 * (allow all)
160						 */
161	{ "filter_client0", "", 0 },		/* [lan_ipaddr0-lan_ipaddr1|*]:lan_port0-lan_port1,
162						 * proto,enable,day_start-day_end,sec_start-sec_end,
163						 * desc
164						 */
165	{ "nat_type", "sym", 0 },               /* sym: Symmetric NAT, cone: Cone NAT */
166	/* Port forwards */
167	{ "dmz_ipaddr", "", 0 },		/* x.x.x.x (equivalent to 0-60999>dmz_ipaddr:
168						 * 0-60999)
169						 */
170	{ "forward_port0", "", 0 },		/* wan_port0-wan_port1>lan_ipaddr:
171						 * lan_port0-lan_port1[:,]proto[:,]enable[:,]desc
172						 */
173	{ "autofw_port0", "", 0 },		/* out_proto:out_port,in_proto:in_port0-in_port1>
174						 * to_port0-to_port1,enable,desc
175						 */
176#ifdef BCMQOS
177	{ "qos_orates",	"80-100,10-100,5-100,3-100,2-95,0-0,0-0,0-0,0-0,0-0", 0 },
178	{ "qos_irates",	"0,0,0,0,0,0,0,0,0,0", 0 },
179	{ "qos_enable",			"0"				},
180	{ "qos_method",			"0"				},
181	{ "qos_sticky",			"1"				},
182	{ "qos_ack",			"1"				},
183	{ "qos_icmp",			"0"				},
184	{ "qos_reset",			"0"				},
185	{ "qos_obw",			"384"			},
186	{ "qos_ibw",			"1500"			},
187	{ "qos_orules",			"" },
188	{ "qos_burst0",			""				},
189	{ "qos_burst1",			""				},
190	{ "qos_default",		"3"				},
191#endif /* BCMQOS */
192	/* DHCP server parameters */
193	{ "dhcp_start", "192.168.1.100", 0 },	/* First assignable DHCP address */
194	{ "dhcp_end", "192.168.1.150", 0 },	/* Last assignable DHCP address */
195	{ "dhcp1_start", "192.168.2.100", 0 },	/* First assignable DHCP address */
196	{ "dhcp1_end", "192.168.2.150", 0 },	/* Last assignable DHCP address */
197	{ "dhcp_domain", "wan", 0 },		/* Use WAN domain name first if available (wan|lan)
198						 */
199	{ "dhcp_wins", "wan", 0 },		/* Use WAN WINS first if available (wan|lan) */
200#endif	/* __CONFIG_NAT__ */
201
202	/* Web server parameters */
203	{ "http_username", "", 0 },		/* Username */
204	{ "http_passwd", "admin", 0 },		/* Password */
205	{ "http_wanport", "", 0 },		/* WAN port to listen on */
206	{ "http_lanport", "80", 0 },		/* LAN port to listen on */
207
208	/* Wireless parameters */
209	{ "wl_ifname", "", 0 },			/* Interface name */
210	{ "wl_hwaddr", "", 0 },			/* MAC address */
211	{ "wl_phytype", "b", 0 },		/* Current wireless band ("a" (5 GHz),
212						 * "b" (2.4 GHz), or "g" (2.4 GHz))
213						*/
214	{ "wl_corerev", "", 0 },		/* Current core revision */
215	{ "wl_phytypes", "", 0 },		/* List of supported wireless bands (e.g. "ga") */
216	{ "wl_radioids", "", 0 },		/* List of radio IDs */
217	{ "wl_ssid", "Broadcom", 0 },		/* Service set ID (network name) */
218	{ "wl_bss_enabled", "1", 0 },		/* Service set Enable (1) or disable (0) radio */
219
220#ifdef __CONFIG_HSPOT__
221	{ "wl_hsflag",		"1aa0", 0 },	/* Passpoint Flags */
222	{ "wl_hs2cap",		"1", 0 },	/* Passpoint Realese 2 (1), Realese 1 (0) radio */
223	{ "wl_opercls",		"3", 0 },	/* Operating Class */
224	{ "wl_anonai",		"anonymous.com", 0 },	/* Anonymous NAI */
225	{ "wl_wanmetrics",	"1:0:0=2500>384=0>0=0", 0 }, /* WAN Metrics */
226
227	{ "wl_oplist",		"Wi-Fi Alliance!eng|"
228	"\x57\x69\x2d\x46\x69\xe8\x81\x94\xe7\x9b\x9f!chi", 0 }, /* Operator Friendly Name List */
229
230	{ "wl_homeqlist",	"mail.example.com:rfc4282", 0 }, /* NAIHomeRealmQueryList */
231
232	{ "wl_osu_ssid",	"OSU", 0}, /* OSU SSID */
233
234	{ "wl_osu_frndname",	"SP Red Test Only!eng|"
235	"\x53\x50\x20\xEB\xB9\xA8\xEA\xB0\x95\x20\xED\x85\x8C"
236	"\xEC\x8A\xA4\xED\x8A\xB8\x20\xEC\xA0\x84\xEC\x9A\xA9!kor", 0}, /* OSU Friendly Name */
237
238	{ "wl_osu_uri",
239	"https://osu-server.r2-testbed.wi-fi.org/", 0}, /* OSU Server URI */
240
241	{ "wl_osu_nai",		"", 0}, /* OSU NAI */
242
243	{ "wl_osu_method",	"1", 0}, /* OSU Method */
244
245	{ "wl_osu_icons",
246	"icon_red_zxx.png+icon_red_eng.png", 0}, /* OSU Icons */
247
248	{ "wl_osu_servdesc", "Free service for test purpose!eng|"
249	"\xED\x85\x8C\xEC\x8A\xA4\xED\x8A\xB8\x20\xEB\xAA\xA9"
250	"\xEC\xA0\x81\xEC\x9C\xBC\xEB\xA1\x9C\x20\xEB\xAC\xB4"
251	"\xEB\xA3\x8C\x20\xEC\x84\x9C\xEB\xB9\x84\xEC\x8A\xA4!kor", 0}, /* OSU Serv Desc */
252
253	{ "wl_concaplist",	"1:0:0;6:20:1;6:22:0;"
254	"6:80:1;6:443:1;6:1723:0;6:5060:0;"
255	"17:500:1;17:5060:0;17:4500:1;50:0:1", 0 }, /* Connection Capability List */
256
257	{ "wl_qosmapie",
258	"35021606+8,15;0,7;255,255;16,31;32,39;255,255;40,47;255,255", 0 },	/* QoS Map IE */
259
260	/* ---- Passpoint Flags  ----------------------------------- */
261	{ "wl_gascbdel",	"0", 0 },	/* GAS CB Delay */
262	{ "hs2_debug_level",	"1", 0 },	/* HS2.0 debeug level default (1) ERROR */
263
264/* #endif  __CONFIG_HSPOT__ */
265/* #ifdef __CONFIG_802_11U__ */
266	{ "wl_iwnettype",	"2", 0 },	/* Select Access Network Type */
267	{ "wl_hessid",		"50:6F:9A:00:11:22",  0 },	/* Interworking HESSID */
268	{ "wl_ipv4addr",	"3", 0 },	/* Select IPV4 Address Type Availability */
269	{ "wl_ipv6addr",	"0", 0 },	/* Select IPV6 Address Type Availability */
270
271	{ "wl_netauthlist", "accepttc=+"
272	"httpred=https://tandc-server.wi-fi.org",  0 },	/* Network Authentication Type List */
273
274	{ "wl_venuegrp",	"2", 0 },	/* Venue Group */
275	{ "wl_venuetype",	"8", 0 },	/* Venue Type  */
276
277	{ "wl_venuelist",
278	"57692D466920416C6C69616E63650A"
279	"3239383920436F7070657220526F61640A"
280	"53616E746120436C6172612C2043412039"
281	"353035312C2055534121656E677C"
282	"57692D4669E88194E79B9FE5AE9EE9AA8CE5AEA40A"
283	"E4BA8CE4B99DE585ABE4B99DE5B9B4E5BA93E69F8FE8B7AF0A"
284	"E59CA3E5858BE68B89E68B892C20E58AA0E588A9E7A68FE5B0"
285	"BCE4BA9A39353035312C20E7BE8EE59BBD21636869",  0 },	/* Venue Name List */
286
287	{ "wl_ouilist",		"506F9A:1;001BC504BD:1", 0 },	/* Roaming Consortium List */
288	{ "wl_3gpplist",	"",  0 },	/* 3GPP Cellular Network Information List */
289	{ "wl_domainlist",	"",  0 },	/* Domain Name List */
290
291	{ "wl_realmlist",
292	"mail.example.com+0+21=2,4#5,7?"
293	"cisco.com+0+21=2,4#5,7?"
294	"wi-fi.org+0+21=2,4#5,7;13=5,6?"
295	"example.com+0+13=5,6",  0 },	/* NAI Realm List */
296
297#endif  /* __CONFIG_802_11U__ */
298
299	{ "wl_country_code", "", 0 },		/* Country Code (default obtained from driver) */
300	{ "wl_country_rev", "", 0 },	/* Regrev Code (default obtained from driver) */
301	{ "wl_radio", "1", 0 },			/* Enable (1) or disable (0) radio */
302	{ "wl_closed", "0", 0 },		/* Closed (hidden) network */
303	{ "wl_ap_isolate", "0", 0 },            /* AP isolate mode */
304#if defined(__CONFIG_PLC__)
305	{ "wl_wmf_bss_enable", "1", 0 },	/* WMF Enable for IPTV Media or WiFi+PLC */
306#else
307	{ "wl_wmf_bss_enable", "0", 0 },	/* WMF Enable/Disable */
308#endif	/* __CONFIG_PLC__ */
309	{ "wl_mcast_regen_bss_enable", "1", 0 },	/* MCAST REGEN Enable/Disable */
310	/* operational capabilities required for stations to associate to the BSS */
311	{ "wl_bss_opmode_cap_reqd", "0", 0 },
312	{ "wl_rxchain_pwrsave_enable", "1", 0 },	/* Rxchain powersave enable */
313	{ "wl_rxchain_pwrsave_quiet_time", "1800", 0 },	/* Quiet time for power save */
314	{ "wl_rxchain_pwrsave_pps", "10", 0 },	/* Packets per second threshold for power save */
315	{ "wl_rxchain_pwrsave_stas_assoc_check", "0", 0 }, /* STAs associated before powersave */
316	{ "wl_radio_pwrsave_enable", "0", 0 },	/* Radio powersave enable */
317	{ "wl_radio_pwrsave_quiet_time", "1800", 0 },	/* Quiet time for power save */
318	{ "wl_radio_pwrsave_pps", "10", 0 },	/* Packets per second threshold for power save */
319	{ "wl_radio_pwrsave_level", "0", 0 },	/* Radio power save level */
320	{ "wl_radio_pwrsave_stas_assoc_check", "0", 0 }, /* STAs associated before powersave */
321	{ "wl_mode", "ap", 0 },			/* AP mode (ap|sta|wds) */
322	{ "wl_lazywds", "0", 0 },		/* Enable "lazy" WDS mode (0|1) */
323	{ "wl_wds", "", 0 },			/* xx:xx:xx:xx:xx:xx ... */
324	{ "wl_wds_timeout", "1", 0 },		/* WDS link detection interval defualt 1 sec */
325	{ "wl_wep", "disabled", 0 },		/* WEP data encryption (enabled|disabled) */
326	{ "wl_auth", "0", 0 },			/* Shared key authentication optional (0) or
327						 * required (1)
328						 */
329	{ "wl_key", "1", 0 },			/* Current WEP key */
330	{ "wl_key1", "", 0 },			/* 5/13 char ASCII or 10/26 char hex */
331	{ "wl_key2", "", 0 },			/* 5/13 char ASCII or 10/26 char hex */
332	{ "wl_key3", "", 0 },			/* 5/13 char ASCII or 10/26 char hex */
333	{ "wl_key4", "", 0 },			/* 5/13 char ASCII or 10/26 char hex */
334	{ "wl_maclist", "", 0 },		/* xx:xx:xx:xx:xx:xx ... */
335	{ "wl_macmode", "disabled", 0 },	/* "allow" only, "deny" only, or "disabled"
336						 * (allow all)
337						 */
338	{ "wl_assoc_retry_max", "3", 0 },	/* Non-zero limit for association retries */
339	{ "wl_chanspec", "11", 0 },		/* Channel specification */
340	{ "wl_reg_mode", "off", 0 },		/* Regulatory: 802.11H(h)/802.11D(d)/off(off) */
341	{ "wl_rate", "0", 0 },			/* Rate (bps, 0 for auto) */
342	{ "wl_mrate", "0", 0 },			/* Mcast Rate (bps, 0 for auto) */
343	{ "wl_frameburst", "off", 0 },		/* BRCM Frambursting mode (off|on) */
344	{ "frameburst_dyn", "0", 0 },           /* Frameburst controlled dynamically if on */
345	{ "wl_rateset", "default", 0 },		/* "default" or "all" or "12" */
346	{ "wl_frag", "2346", 0 },		/* Fragmentation threshold */
347	{ "wl_rts", "2347", 0 },		/* RTS threshold */
348	{ "wl_dtim", "3", 0 },			/* DTIM period */
349	{ "wl_bcn", "100", 0 },			/* Beacon interval */
350	{ "wl_bcn_rotate", "1", 0 },		/* Beacon rotation */
351	{ "wl_plcphdr", "long", 0 },		/* 802.11b PLCP preamble type */
352	{ "wl_gmode", XSTR(GMODE_AUTO), 0 },	/* 54g mode */
353	{ "wl_gmode_protection", "auto", 0 },	/* 802.11g RTS/CTS protection (off|auto) */
354	{ "wl_wme", "auto", 0 },		/* WME mode (off|on|auto) */
355	{ "wl_wme_bss_disable", "0", 0 },	/* WME BSS disable advertising (off|on) */
356	{ "wl_antdiv", "-1", 0 },		/* Antenna Diversity (-1|0|1|3) */
357	{ "wl_infra", "1", 0 },			/* Network Type (BSS/IBSS) */
358	{ "wl_bw_cap", "1", 0},			/* BW Cap; 20 MHz */
359	{ "wl_nband", "2", 0},			/* N-BAND */
360	{ "wl_nmcsidx", "-1", 0},		/* MCS Index for N - rate */
361	{ "wl_nmode", "-1", 0},			/* N-mode */
362	{ "wl_rifs_advert", "auto", 0},		/* RIFS mode advertisement */
363	{ "wl_vlan_prio_mode", "off", 0},	/* VLAN Priority support */
364	{ "wl_leddc", "0x640000", 0},		/* 100% duty cycle for LED on router */
365	{ "wl_rxstreams", "0", 0},              /* 802.11n Rx Streams, 0 is invalid, WLCONF will
366						 * change it to a radio appropriate default
367						 */
368	{ "wl_txstreams", "0", 0},              /* 802.11n Tx Streams 0, 0 is invalid, WLCONF will
369						 * change it to a radio appropriate default
370						 */
371	{ "wl_stbc_tx", "auto", 0 },		/* Default STBC TX setting */
372	{ "wl_stbc_rx", "1", 0 },		/* Default STBC RX setting */
373	{ "wl_ampdu", "auto", 0 },		/* Default AMPDU setting */
374	/* Default AMPDU retry limit per-tid setting */
375	{ "wl_ampdu_rtylimit_tid", "5 5 5 5 5 5 5 5", 0 },
376	/* Default AMPDU regular rate retry limit per-tid setting */
377	{ "wl_ampdu_rr_rtylimit_tid", "2 2 2 2 2 2 2 2", 0 },
378	{ "wl_amsdu", "auto", 0 },		/* Default AMSDU setting */
379	{ "wl_obss_coex", "1", 0 },		/* Default OBSS Coexistence setting - OFF */
380
381	/* WPA parameters */
382	{ "wl_auth_mode", "none", 0 },		/* Network authentication mode (radius|none) */
383	{ "wl_wpa_psk", "", 0 },		/* WPA pre-shared key */
384	{ "wl_wpa_gtk_rekey", "0", 0 },		/* GTK rotation interval */
385	{ "wl_radius_ipaddr", "", 0 },		/* RADIUS server IP address */
386	{ "wl_radius_key", "", 0 },		/* RADIUS shared secret */
387	{ "wl_radius_port", "1812", 0 },	/* RADIUS server UDP port */
388	{ "wl_crypto", "tkip+aes", 0 },		/* WPA data encryption */
389	{ "wl_net_reauth", "36000", 0 },	/* Network Re-auth/PMK caching duration */
390	{ "wl_akm", "", 0 },			/* WPA akm list */
391#ifdef MFP
392	{ "wl_mfp", "-1", 0 },			/* Protected Management Frame */
393#endif
394	{ "wl_psr_mrpt", "0", 0 },		/* Default to one level repeating mode */
395
396#ifdef __CONFIG_WPS__
397	/* WSC parameters */
398	{ "wps_version2", "enabled", 0 },	 /* Must specified before other wps variables */
399	{ "wl_wps_mode", "enabled", 0 }, /* enabled wps */
400	{ "wl_wps_config_state", "0", 0 },	/* config state unconfiged */
401	{ "wps_device_pin", "12345670", 0 },
402	{ "wps_modelname", "Broadcom", 0 },
403	{ "wps_mfstring", "Broadcom", 0 },
404	{ "wps_device_name", "BroadcomAP", 0 },
405	{ "wl_wps_reg", "enabled", 0 },
406	{ "wps_sta_pin", "00000000", 0 },
407	{ "wps_modelnum", "123456", 0 },
408	/* Allow or Deny Wireless External Registrar get or configure AP security settings */
409	{ "wps_wer_mode", "allow", 0 },
410
411	{ "lan_wps_oob", "enabled", 0 },	/* OOB state */
412	{ "lan_wps_reg", "enabled", 0 },	/* For DTM 1.4 test */
413
414	{ "lan1_wps_oob", "enabled", 0 },
415	{ "lan1_wps_reg", "enabled", 0 },
416#endif /* __CONFIG_WPS__ */
417#ifdef __CONFIG_WFI__
418	{ "wl_wfi_enable", "0", 0 },	/* 0: disable, 1: enable WifiInvite */
419	{ "wl_wfi_pinmode", "0", 0 },	/* 0: auto pin, 1: manual pin */
420#endif /* __CONFIG_WFI__ */
421#ifdef __CONFIG_WAPI_IAS__
422	/* WAPI parameters */
423	{ "wl_wai_cert_name", "", 0 },		/* AP certificate name */
424	{ "wl_wai_cert_index", "1", 0 },	/* AP certificate index. 1:X.509, 2:GBW */
425	{ "wl_wai_cert_status", "0", 0 },	/* AP certificate status */
426	{ "wl_wai_as_ip", "", 0 },		/* ASU server IP address */
427	{ "wl_wai_as_port", "3810", 0 },	/* ASU server UDP port */
428#endif /* __CONFIG_WAPI_IAS__ */
429	/* WME parameters (cwmin cwmax aifsn txop_b txop_ag adm_control oldest_first) */
430	/* EDCA parameters for STA */
431	{ "wl_wme_sta_be", "15 1023 3 0 0 off off", 0 },	/* WME STA AC_BE parameters */
432	{ "wl_wme_sta_bk", "15 1023 7 0 0 off off", 0 },	/* WME STA AC_BK parameters */
433	{ "wl_wme_sta_vi", "7 15 2 6016 3008 off off", 0 },	/* WME STA AC_VI parameters */
434	{ "wl_wme_sta_vo", "3 7 2 3264 1504 off off", 0 },	/* WME STA AC_VO parameters */
435
436	/* EDCA parameters for AP */
437	{ "wl_wme_ap_be", "15 63 3 0 0 off off", 0 },		/* WME AP AC_BE parameters */
438	{ "wl_wme_ap_bk", "15 1023 7 0 0 off off", 0 },		/* WME AP AC_BK parameters */
439	{ "wl_wme_ap_vi", "7 15 1 6016 3008 off off", 0 },	/* WME AP AC_VI parameters */
440	{ "wl_wme_ap_vo", "3 7 1 3264 1504 off off", 0 },	/* WME AP AC_VO parameters */
441
442	{ "wl_wme_no_ack", "off", 0},		/* WME No-Acknowledgment mode */
443	{ "wl_wme_apsd", "on", 0},		/* WME APSD mode */
444
445#ifdef __CONFIG_ROUTER_MINI__
446	{ "wl_maxassoc", "64", 0},		/* Max associations driver could support */
447	{ "wl_bss_maxassoc", "64", 0},		/* Max associations driver could support */
448#else
449	{ "wl_maxassoc", "128", 0},		/* Max associations driver could support */
450	{ "wl_bss_maxassoc", "128", 0},		/* Max associations driver could support */
451#endif /* __CONFIG_ROUTER_MINI__ */
452
453	{ "wl_unit", "0", 0 },			/* Last configured interface */
454	{ "wl_sta_retry_time", "5", 0 }, /* Seconds between association attempts */
455
456#ifdef __CONFIG_EMF__
457	/* EMF defaults */
458	{ "emf_entry", "", 0 },			/* Static MFDB entry (mgrp:if) */
459	{ "emf_uffp_entry", "", 0 },		/* Unreg frames forwarding ports */
460	{ "emf_rtport_entry", "", 0 },		/* IGMP frames forwarding ports */
461#if defined(__CONFIG_PLC__)
462	{ "emf_enable", "1", 0 },		/* Enable EMF by default */
463#else
464	{ "emf_enable", "0", 0 },		/* Disable EMF by default */
465#endif /* __CONFIG_PLC__ */
466#endif /* __CONFIG_EMF__ */
467#ifdef __CONFIG_IPV6__
468	{ "lan_ipv6_mode", "3", 0 },		/* 0=disable 1=6to4 2=native 3=6to4+native! */
469	{ "lan_ipv6_dns", "", 0  },
470	{ "lan_ipv6_6to4id", "0", 0  }, /* 0~65535 */
471	{ "lan_ipv6_prefix", "2001:db8:1:0::/64", 0  },
472	{ "wan_ipv6_prefix", "2001:db0:1:0::/64", 0  },
473#endif /* __CONFIG_IPV6__ */
474#ifdef __CONFIG_NETBOOT__
475	{ "netboot_url", "", 0 },		/* netboot url */
476	{ "netboot_username", "", 0 },	/* netboot username */
477	{ "netboot_passwd", "", 0 },	/* netboor password */
478#endif /* __CONFIG_NETBOOT__ */
479	/* Restore defaults */
480	{ "restore_defaults", "0", 0 },		/* Set to 0 to not restore defaults on boot */
481#if defined(__CONFIG_EXTACS__)
482	{ "acs_ifnames", "", 0  },
483#endif /* defined(__CONFIG_EXTACS__) */
484#ifdef __CONFIG_SAMBA__
485	{ "samba_mode", "", 0  },
486	{ "samba_passwd", "", 0  },
487#endif
488
489	{ "igmp_enable", "0", 0 },		/* Enable igmp proxy in AP mode */
490
491	{ "wl_wet_tunnel", "0", 0  },   /* Disable wet tunnel */
492
493	{ "dpsta_ifnames", "", 0  },
494	{ "dpsta_policy", "1", 0  },
495	{ "dpsta_lan_uif", "1", 0  },
496#ifdef TRAFFIC_MGMT_RSSI_POLICY
497	{ "wl_trf_mgmt_rssi_policy", "0", 0 }, /* Disable RSSI (default) */
498#endif /* TRAFFIC_MGMT */
499#ifdef __CONFIG_EMF__
500	{ "wl_wmf_ucigmp_query", "0", 0 }, /* Disable Converting IGMP Query to ucast (default) */
501	{ "wl_wmf_mdata_sendup", "0", 0 }, /* Disable Sending Multicast Data to host  (default) */
502	{ "wl_wmf_ucast_upnp", "0", 0 }, /* Disable Converting upnp to ucast (default) */
503#endif /* __CONFIG_EMF__ */
504
505	/* Tx Beamforming */
506	{ "wl_txbf_bfr_cap", "1", 0 },
507	{ "wl_txbf_bfe_cap", "1", 0 },
508
509	/* PsPretend threshold and retry_limit */
510	{ "wl_pspretend_threshold", "0", 0 },
511	{ "wl_pspretend_retry_limit", "0", 0 },
512	{ "wl_txbf_imp", "1", 0 },
513
514	/* acsd setting */
515	{ "wl_acs_fcs_mode", "0", 0 },		/* acsd disable FCS mode */
516	{ "wl_dcs_csa_unicast", "0", 0 },	/* disable unicast csa */
517	{ "wl_acs_excl_chans", "", 0 },		/* acsd exclude chanspec list */
518	{ "wl_acs_dfs", "2", 0 },		/* acsd fcs disable init DFS chan */
519	{ "wl_acs_dfsr_immediate", "300 3", 0 },   /* immediate if > 3 switches last 5 minutes */
520	{ "wl_acs_dfsr_deferred", "604800 5", 0 }, /* deferred if > 5 switches in last 7 days */
521	{ "wl_acs_dfsr_activity", "30 10240", 0 }, /* active: >10k I/O in the last 30 seconds */
522	{ "wl_acs_cs_scan_timer", "900", 0 },	/* acsd fcs cs scan timeout */
523	{ "wl_acs_ci_scan_timer", "4", 0 },		/* acsd fcs CI scan period */
524	{ "wl_acs_ci_scan_timeout", "300", 0 },	/* acsd fcs CI scan timeout */
525	{ "wl_acs_scan_entry_expire", "3600", 0 },	/* acsd fcs scan expier time */
526	{ "wl_acs_tx_idle_cnt", "0", 0 },		/* acsd fcs tx idle thld */
527	{ "wl_acs_chan_dwell_time", "70", 0 },	/* acsd fcs chan dwell time */
528	{ "wl_acs_chan_flop_period", "70", 0 },	/* acsd fcs chan flip-flop time */
529	{ "wl_intfer_period", "1", 0 },		/* acsd fcs sample period */
530	{ "wl_intfer_cnt", "3", 0 },		/* acsd fcs sample cnt */
531	{ "wl_intfer_txfail", "5", 0 }, 	/* fcs non-TCP txfail threshold setting */
532	{ "wl_intfer_tcptxfail", "5", 0 }, 	/* fcs TCP txfail threshold setting */
533
534	{ "wl_pspretend_retry_limit", "0", 0 }, /* Disable PsPretend */
535	{ "wl_taf_enable", "0", 0 }, /* Disable TAF */
536
537	{ "bsd_role", "0", 0 },              /* Disable Band Steer Daemon */
538	{ "bsd_hport", "9877", 0 },          /* BSD helper port */
539	{ "bsd_pport", "9878", 0 },          /* BSD Primary port */
540	{ "bsd_helper", "192.168.1.2", 0 },  /* BSD primary ipaddr */
541	{ "bsd_primary", "192.168.1.1", 0 }, /* BSD Helper ipaddr */
542	{ "ssd_enable", "0", 0 },            /* Disable SSID Steer Daemon */
543	{ "wl_ssd_type", "0", 0 },           /* default ssd_type "disabled" */
544	{ "wl_dfs_pref", "" },               /* DFS Preferred channel value  */
545	{ "wl_probresp_mf", "0", 0 },	/* MAC filter based probe response  */
546	{ "wl_probresp_sw", "1", 0 },	/* SW probe response  */
547	{ "wl_vht_features", "-1", 0 },	/* VHT features  */
548#ifdef __CONFIG_VISUALIZATION__
549	{ "vis_dcon_ipaddr", "127.0.0.1", 0 },	/* Visualization Dcon IP address  */
550	{ "vis_do_remote_dcon", "0", 0 },	/* Visualization remote debugging enabled flag  */
551	{ "vis_debug_level", "1", 0}, /* Visualization debug messages to be printed */
552#endif /* __CONFIG_VISUALIZATION__ */
553	{ 0, 0, 0 }
554};
555
556/* nvram override default setting for Media Router */
557struct nvram_tuple router_defaults_override_type1[] = {
558	{ "router_disable", "1", 0 },		/* lan_proto=static lan_stp=0 wan_proto=disabled */
559	{ "lan_stp", "0", 0 },			/* LAN spanning tree protocol */
560	{ "wl_wmf_bss_enable", "1", 0 },	/* WMF Enable for IPTV Media or WiFi+PLC */
561	{ "wl_reg_mode", "h", 0 },		/* Regulatory: 802.11H(h) */
562	{ "wl_frameburst", "on", 0 },		/* BRCM Frambursting mode (off|on) */
563#ifdef __CONFIG_EMF__
564	{ "emf_enable", "1", 0 },		/* Enable EMF by default */
565	{ "wl_wmf_ucigmp_query", "1", 0 }, 	/* Enable Converting IGMP Query to ucast */
566	{ "wl_wmf_ucast_upnp", "1", 0 },	/* enable upnp to ucast conversion */
567#endif
568	{ "wl_acs_fcs_mode", "1", 0 },		/* enable acsd fcs mode */
569	{ "wl_dcs_csa_unicast", "1", 0 },	/* enable unicast csa */
570	/* Exclude ACSD to select 140l, 144u, 140/80, 144/80 to compatible with Ducati 11N */
571	{ "wl_acs_excl_chans", "0xd98e,0xd88e,0xe28a,0xe38a", 0 },
572	{ "wl_pspretend_retry_limit", "5", 0 }, /* Enable PsPretend */
573	{ "wl_taf_enable", "0", 0 },		/* Disable TAF */
574	{ "wl_amsdu", "off", 0 },		/* Disable AMSDU Tx by default */
575	{ "wl_rx_amsdu_in_ampdu", "off", 0 },	/* Disable AMSDU Rx by default */
576	{ "wl_cal_period", "0", 0 },			/* Disable periodic cal */
577	{ "wl_psta_inact", "0", 0 },		/* PSTA inactivity timer */
578	{ 0, 0, 0 }
579};
580
581/* Translates from, for example, wl0_ (or wl0.1_) to wl_. */
582/* Only single digits are currently supported */
583
584static void
585fix_name(const char *name, char *fixed_name)
586{
587	char *pSuffix = NULL;
588
589	/* Translate prefix wlx_ and wlx.y_ to wl_ */
590	/* Expected inputs are: wld_root, wld.d_root, wld.dd_root
591	 * We accept: wld + '_' anywhere
592	 */
593	pSuffix = strchr(name, '_');
594
595	if ((strncmp(name, "wl", 2) == 0) && isdigit(name[2]) && (pSuffix != NULL)) {
596		strcpy(fixed_name, "wl");
597		strcpy(&fixed_name[2], pSuffix);
598		return;
599	}
600
601	/* No match with above rules: default to input name */
602	strcpy(fixed_name, name);
603}
604
605
606/*
607 * Find nvram param name; return pointer which should be treated as const
608 * return NULL if not found.
609 *
610 * NOTE:  This routine special-cases the variable wl_bss_enabled.  It will
611 * return the normal default value if asked for wl_ or wl0_.  But it will
612 * return 0 if asked for a virtual BSS reference like wl0.1_.
613 */
614char *
615nvram_default_get(const char *name)
616{
617	int idx;
618	char fixed_name[NVRAM_MAX_VALUE_LEN];
619
620	fix_name(name, fixed_name);
621	if (strcmp(fixed_name, "wl_bss_enabled") == 0) {
622		if (name[3] == '.' || name[4] == '.') { /* Virtual interface */
623			return "0";
624		}
625	}
626
627	if (!strcmp(nvram_safe_get("devicemode"), "1")) {
628		for (idx = 0; router_defaults_override_type1[idx].name != NULL; idx++) {
629			if (strcmp(router_defaults_override_type1[idx].name, fixed_name) == 0) {
630				return router_defaults_override_type1[idx].value;
631			}
632		}
633	}
634
635	for (idx = 0; router_defaults[idx].name != NULL; idx++) {
636		if (strcmp(router_defaults[idx].name, fixed_name) == 0) {
637			return router_defaults[idx].value;
638		}
639	}
640
641	return NULL;
642}
643/* validate/restore all per-interface related variables */
644void
645nvram_validate_all(char *prefix, bool restore)
646{
647	struct nvram_tuple *t;
648	char tmp[100];
649	char *v;
650
651	for (t = router_defaults; t->name; t++) {
652		if (!strncmp(t->name, "wl_", 3)) {
653			strcat_r(prefix, &t->name[3], tmp);
654			if (!restore && nvram_get(tmp))
655				continue;
656			v = nvram_get(t->name);
657			nvram_set(tmp, v ? v : t->value);
658		}
659	}
660
661	/* override router type1 nvram setting */
662	if (!strcmp(nvram_safe_get("devicemode"), "1")) {
663		for (t = router_defaults_override_type1; t->name; t++) {
664			if (!strncmp(t->name, "wl_", 3)) {
665				strcat_r(prefix, &t->name[3], tmp);
666				if (!restore && nvram_get(tmp))
667					continue;
668				v = nvram_get(t->name);
669				nvram_set(tmp, v ? v : t->value);
670			}
671		}
672	}
673}
674
675/* restore specific per-interface variable */
676void
677nvram_restore_var(char *prefix, char *name)
678{
679	struct nvram_tuple *t;
680	char tmp[100];
681
682	for (t = router_defaults; t->name; t++) {
683		if (!strncmp(t->name, "wl_", 3) && !strcmp(&t->name[3], name)) {
684			nvram_set(strcat_r(prefix, name, tmp), t->value);
685			break;
686		}
687	}
688
689	/* override router type1 setting */
690	if (!strcmp(nvram_safe_get("devicemode"), "1")) {
691		for (t = router_defaults_override_type1; t->name; t++) {
692			if (!strncmp(t->name, "wl_", 3) && !strcmp(&t->name[3], name)) {
693				nvram_set(strcat_r(prefix, name, tmp), t->value);
694				break;
695			}
696		}
697	}
698}
699