4 Copyright (C) 2006-2010 Jonathan Zarate
10 #include <sys/sysinfo.h>
12 #include <sys/types.h>
13 #include <sys/socket.h>
14 #include <arpa/inet.h>
18 // #define DEBUG_NOEXECSERVICE
19 #define DEBUG_NVRAMSET(k, v) _dprintf("nvram set %s=%s\n", k, v);
22 char *post_buf
= NULL
;
26 static void asp_css(int argc
, char **argv
);
27 static void asp_resmsg(int argc
, char **argv
);
30 static void wo_tomato(char *url
);
31 static void wo_update(char *url
);
32 static void wo_service(char *url
);
33 static void wo_shutdown(char *url
);
34 static void wo_nvcommit(char *url
);
35 // static void wo_logout(char *url);
38 // ----------------------------------------------------------------------------
41 void exec_service(const char *action
)
45 _dprintf("exec_service: %s\n", action
);
48 while ((!nvram_match("action_service", "")) && (i
-- > 0)) {
49 _dprintf("%s: waiting before %d\n", __FUNCTION__
, i
);
53 nvram_set("action_service", action
);
57 while ((nvram_match("action_service", (char *)action
)) && (i
-- > 0)) {
58 _dprintf("%s: waiting after %d\n", __FUNCTION__
, i
);
63 if (atoi(webcgi_safeget("_service_wait", ""))) {
65 while ((nvram_match("action_service", (char *)action)) && (i-- > 0)) {
66 _dprintf("%s: waiting after %d\n", __FUNCTION__, i);
73 static void wi_generic_noid(char *url
, int len
, char *boundary
)
76 if (len
>= (32 * 1024)) {
77 // syslog(LOG_WARNING, "POST max");
81 if (post_buf
) free(post_buf
);
82 if ((post_buf
= malloc(len
+ 1)) == NULL
) {
83 // syslog(LOG_CRIT, "Unable to allocate post buffer");
87 if (web_read_x(post_buf
, len
) != len
) {
91 webcgi_init(post_buf
);
95 void wi_generic(char *url
, int len
, char *boundary
)
97 wi_generic_noid(url
, len
, boundary
);
101 // !!TB - CGI Support
102 void wi_cgi_bin(char *url
, int len
, char *boundary
)
104 if (post_buf
) free(post_buf
);
108 if (len
>= (128 * 1024)) {
109 syslog(LOG_WARNING
, "POST length exceeded maximum allowed");
114 if ((post_buf
= malloc(len
+ 1)) == NULL
) {
117 if (web_read_x(post_buf
, len
) != len
) {
125 static void _execute_command(char *url
, char *command
, char *query
, wofilter_t wof
)
127 char webExecFile
[] = "/tmp/.wxXXXXXX";
128 char webQueryFile
[] = "/tmp/.wqXXXXXX";
129 char cmd
[sizeof(webExecFile
) + 10];
133 if ((fe
= mkstemp(webExecFile
)) < 0)
136 if ((fq
= mkstemp(webQueryFile
)) < 0) {
143 if ((f
= fdopen(fe
, "wb")) != NULL
) {
146 "export REQUEST_METHOD=\"%s\"\n"
150 post
? "POST" : "GET", getenv("PATH"),
151 command
? "" : "./", command
? command
: url
,
152 query
? "<" : "", query
? webQueryFile
: "");
160 unlink(webQueryFile
);
164 chmod(webExecFile
, 0700);
167 if ((f
= fdopen(fq
, "wb")) != NULL
) {
168 fprintf(f
, "%s\n", query
);
174 unlink(webQueryFile
);
179 sprintf(cmd
, "%s 2>&1", webExecFile
);
180 web_pipecmd(cmd
, wof
);
181 unlink(webQueryFile
);
185 static void wo_cgi_bin(char *url
)
187 if (!header_sent
) send_header(200, NULL
, mime_html
, 0);
188 _execute_command(url
, NULL
, post_buf
, WOF_NONE
);
195 static void wo_shell(char *url
)
197 web_puts("\ncmdresult = '");
198 _execute_command(NULL
, webcgi_get("command"), NULL
, WOF_JAVASCRIPT
);
202 static void wo_blank(char *url
)
204 web_puts("\n\n\n\n");
207 static void wo_favicon(char *url
)
209 send_header(200, NULL
, "image/vnd.microsoft.icon", 0);
212 if (nvram_match("web_favicon", "1")) {
213 send_header(200, NULL, "image/vnd.microsoft.icon", 0);
217 send_error(404, NULL, NULL);
222 static void wo_cfe(char *url
)
224 do_file(MTD_DEV(0ro
));
227 static void wo_nvram(char *url
)
229 web_pipecmd("nvram show", WOF_NONE
);
232 static void wo_iptables(char *url
)
234 web_pipecmd("iptables -nvL; echo; iptables -t nat -nvL; echo; iptables -t mangle -nvL", WOF_NONE
);
238 static void wo_ip6tables(char *url
)
240 web_pipecmd("ip6tables -nvL; echo; ip6tables -t mangle -nvL", WOF_NONE
);
245 static void wo_spin(char *url)
249 strlcpy(s, nvram_safe_get("web_css"), sizeof(s));
250 strlcat(s, "_spin.gif", sizeof(s));
251 if (f_exists(s)) do_file(s);
252 else do_file("_spin.gif");
256 void common_redirect(void)
258 if (atoi(webcgi_safeget("_ajax", ""))) {
259 send_header(200, NULL
, mime_html
, 0);
263 redirect(webcgi_safeget("_redirect", "/"));
267 // ----------------------------------------------------------------------------
269 const struct mime_handler mime_handlers
[] = {
270 { "update.cgi", mime_javascript
, 0, wi_generic
, wo_update
, 1 },
271 { "tomato.cgi", NULL
, 0, wi_generic
, wo_tomato
, 1 },
273 { "debug.js", mime_javascript
, 5, wi_generic_noid
, wo_blank
, 1 }, // while debugging
274 { "cfe/*.bin", mime_binary
, 0, wi_generic
, wo_cfe
, 1 },
275 { "nvram/*.txt", mime_binary
, 0, wi_generic
, wo_nvram
, 1 },
276 { "ipt/*.txt", mime_binary
, 0, wi_generic
, wo_iptables
, 1 },
278 { "ip6t/*.txt", mime_binary
, 0, wi_generic
, wo_ip6tables
, 1 },
280 { "cfg/*.cfg", NULL
, 0, wi_generic
, wo_backup
, 1 },
281 { "cfg/restore.cgi", mime_html
, 0, wi_restore
, wo_restore
, 1 },
282 { "cfg/defaults.cgi", NULL
, 0, wi_generic
, wo_defaults
, 1 },
284 { "bwm/*.gz", NULL
, 0, wi_generic
, wo_bwmbackup
, 1 },
285 { "bwm/restore.cgi", NULL
, 0, wi_bwmrestore
, wo_bwmrestore
, 1 },
287 { "ipt/*.gz", NULL
, 0, wi_generic
, wo_iptbackup
, 1 },
288 { "ipt/restore.cgi", NULL
, 0, wi_iptrestore
, wo_iptrestore
, 1 },
290 { "logs/view.cgi", NULL
, 0, wi_generic
, wo_viewlog
, 1 },
291 { "logs/*.txt", NULL
, 0, wi_generic
, wo_syslog
, 1 },
292 { "webmon_**", NULL
, 0, wi_generic
, wo_syslog
, 1 },
294 { "logout.asp", NULL
, 0, wi_generic
, wo_asp
, 1 },
295 { "clearcookies.asp", NULL
, 0, wi_generic
, wo_asp
, 1 },
297 // { "spin.gif", NULL, 0, wi_generic_noid, wo_spin, 1 },
299 { "**.asp", NULL
, 0, wi_generic_noid
, wo_asp
, 1 },
300 { "**.css", "text/css", 2, wi_generic_noid
, do_file
, 1 },
301 { "**.htm|**.html", mime_html
, 2, wi_generic_noid
, do_file
, 1 },
302 { "**.gif", "image/gif", 5, wi_generic_noid
, do_file
, 1 },
303 { "**.jpg", "image/jpeg", 5, wi_generic_noid
, do_file
, 1 },
304 { "**.png", "image/png", 5, wi_generic_noid
, do_file
, 1 },
305 { "**.js", mime_javascript
, 2, wi_generic_noid
, do_file
, 1 },
306 { "**.jsx", mime_javascript
, 0, wi_generic
, wo_asp
, 1 },
307 { "**.svg", "image/svg+xml", 2, wi_generic_noid
, do_file
, 1 },
308 { "**.txt", mime_plain
, 2, wi_generic_noid
, do_file
, 1 },
309 { "**.bin", mime_binary
, 0, wi_generic_noid
, do_file
, 1 },
310 { "**.bino", mime_octetstream
, 0, wi_generic_noid
, do_file
, 1 },
311 { "favicon.ico", NULL
, 5, wi_generic_noid
, wo_favicon
, 1 },
312 // !!TB - CGI Support, enable downloading archives
313 { "**/cgi-bin/**|**.sh", NULL
, 0, wi_cgi_bin
, wo_cgi_bin
, 1 },
314 { "**.tar|**.gz", mime_binary
, 0, wi_generic_noid
, do_file
, 1 },
315 { "shell.cgi", mime_javascript
, 0, wi_generic
, wo_shell
, 1 },
316 { "wpad.dat|proxy.pac", "application/x-ns-proxy-autoconfig", 0, wi_generic_noid
, do_file
, 0 },
318 { "webmon.cgi", mime_javascript
, 0, wi_generic
, wo_webmon
, 1 },
319 { "dhcpc.cgi", NULL
, 0, wi_generic
, wo_dhcpc
, 1 },
320 { "dhcpd.cgi", mime_javascript
, 0, wi_generic
, wo_dhcpd
, 1 },
321 { "nvcommit.cgi", NULL
, 0, wi_generic
, wo_nvcommit
, 1 },
322 { "ping.cgi", mime_javascript
, 0, wi_generic
, wo_ping
, 1 },
323 { "trace.cgi", mime_javascript
, 0, wi_generic
, wo_trace
, 1 },
324 { "upgrade.cgi", mime_html
, 0, wi_upgrade
, wo_flash
, 1 },
325 { "upnp.cgi", NULL
, 0, wi_generic
, wo_upnp
, 1 },
326 { "wakeup.cgi", NULL
, 0, wi_generic
, wo_wakeup
, 1 },
327 { "wlmnoise.cgi", mime_html
, 0, wi_generic
, wo_wlmnoise
, 1 },
328 { "wlradio.cgi", NULL
, 0, wi_generic
, wo_wlradio
, 1 },
329 { "resolve.cgi", mime_javascript
, 0, wi_generic
, wo_resolve
, 1 },
330 { "expct.cgi", mime_html
, 0, wi_generic
, wo_expct
, 1 },
331 { "service.cgi", NULL
, 0, wi_generic
, wo_service
, 1 },
332 // { "logout.cgi", NULL, 0, wi_generic, wo_logout, 0 },
334 { "shutdown.cgi", mime_html
, 0, wi_generic
, wo_shutdown
, 1 },
335 #ifdef TCONFIG_OPENVPN
336 { "vpnstatus.cgi", mime_javascript
, 0, wi_generic
, wo_vpn_status
, 1 },
339 { "pptpd.cgi", mime_javascript
, 0, wi_generic
, wo_pptpdcmd
, 1 }, //!!AB - PPTPD
342 { "usbcmd.cgi", mime_javascript
, 0, wi_generic
, wo_usbcommand
, 1 }, //!!TB - USB
345 { "blackhole.cgi", NULL
, 0, wi_blackhole
, NULL
, 1 },
348 { "uploadsplash.cgi", NULL
, 0, wi_uploadsplash
, wo_uploadsplash
, 1 },
349 { "ext/uploadsplash.cgi", NULL
, 0, wi_uploadsplash
, wo_uploadsplash
, 1 },
351 { NULL
, NULL
, 0, NULL
, NULL
, 1 }
354 const aspapi_t aspapi
[] = {
355 { "activeroutes", asp_activeroutes
},
356 { "arplist", asp_arplist
},
357 { "bandwidth", asp_bandwidth
},
358 { "build_time", asp_build_time
},
359 { "cgi_get", asp_cgi_get
},
360 { "compmac", asp_compmac
},
361 { "ctcount", asp_ctcount
},
362 { "ctdump", asp_ctdump
},
363 { "ctrate", asp_ctrate
},
364 { "ddnsx", asp_ddnsx
},
365 { "devlist", asp_devlist
},
366 { "webmon", asp_webmon
},
367 { "dhcpc_time", asp_dhcpc_time
},
369 { "ident", asp_ident
},
370 { "lanip", asp_lanip
},
371 { "layer7", asp_layer7
},
372 { "link_uptime", asp_link_uptime
},
373 { "lipp", asp_lipp
},
374 { "netdev", asp_netdev
},
376 { "iptraffic", asp_iptraffic
},
377 { "iptmon", asp_iptmon
},
378 { "ipt_bandwidth", asp_ipt_bandwidth
},
380 { "notice", asp_notice
},
382 { "nvram", asp_nvram
},
383 { "nvramseq", asp_nvramseq
},
384 { "nvstat", asp_nvstat
},
385 { "psup", asp_psup
},
386 { "qrate", asp_qrate
},
387 { "resmsg", asp_resmsg
},
388 { "rrule", asp_rrule
},
389 { "statfs", asp_statfs
},
390 { "sysinfo", asp_sysinfo
},
391 { "jiffies", asp_jiffies
},
392 { "time", asp_time
},
393 { "upnpinfo", asp_upnpinfo
},
394 { "version", asp_version
},
395 { "wanstatus", asp_wanstatus
},
396 { "wanup", asp_wanup
},
398 { "pptpd_userol", asp_pptpd_userol
},
400 { "wlstats", asp_wlstats
},
401 { "wlclient", asp_wlclient
},
402 { "wlnoise", asp_wlnoise
},
403 { "wlscan", asp_wlscan
},
404 { "wlchannels", asp_wlchannels
}, //!!TB
405 { "wlcountries", asp_wlcountries
},
406 { "wlifaces", asp_wlifaces
},
407 { "wlbands", asp_wlbands
},
409 { "usbdevices", asp_usbdevices
}, //!!TB - USB Support
412 { "mmcid", asp_mmcid
}, //MMC Support
414 { "etherstates", asp_etherstates
}, //Ethernet States
416 { "calc6rdlocalprefix", asp_calc6rdlocalprefix
},
423 // -----------------------------------------------------------------------------
425 static void asp_css(int argc
, char **argv
)
427 const char *css
= nvram_safe_get("web_css");
428 const char *ttb
= nvram_safe_get("ttb_css");
430 if( nvram_match( "web_css", "online" ) ) {
431 web_printf("<link rel='stylesheet' type='text/css' href='ext/%s.css'>", ttb
);
433 if (strcmp(css
, "tomato") != 0) {
434 web_printf("<link rel='stylesheet' type='text/css' href='%s.css'>", css
);
439 // -----------------------------------------------------------------------------
441 const char *resmsg_get(void)
443 return webcgi_safeget("resmsg", "");
446 void resmsg_set(const char *msg
)
448 webcgi_set("resmsg", strdup(msg
)); // m ok
451 int resmsg_fread(const char *fname
)
456 f_read_string(fname
, s
, sizeof(s
));
457 if ((p
= strchr(s
, '\n')) != NULL
) *p
= 0;
465 static void asp_resmsg(int argc
, char **argv
)
469 if ((p
= js_string(webcgi_safeget("resmsg", (argc
> 0) ? argv
[0] : ""))) == NULL
) return;
470 web_printf("\nresmsg='%s';\n", p
);
474 // ----------------------------------------------------------------------------
476 // verification... simple sanity checks. UI should verify all fields.
478 // todo: move and re-use for filtering - zzz
489 VT_NONE
, // no checking
490 VT_LENGTH
, // check length of string
491 VT_TEXT
, // strip \r, check length of string
492 VT_RANGE
, // expect an integer, check range
493 VT_IP
, // expect an ip address
494 VT_MAC
, // expect a mac address
496 VT_IPV6
, // expect an ipv6 address
498 VT_TEMP
// no checks, no commit
505 #define V_NONE VT_NONE, { }, { }
506 #define V_01 VT_RANGE, { .l = 0 }, { .l = 1 }
507 #define V_PORT VT_RANGE, { .l = 2 }, { .l = 65535 }
508 #define V_ONOFF VT_LENGTH, { .i = 2 }, { .i = 3 }
509 #define V_WORD VT_LENGTH, { .i = 1 }, { .i = 16 }
510 #define V_LENGTH(min, max) VT_LENGTH, { .i = min }, { .i = max }
511 #define V_TEXT(min, max) VT_TEXT, { .i = min }, { .i = max }
512 #define V_RANGE(min, max) VT_RANGE, { .l = min }, { .l = max }
513 #define V_IP VT_IP, { }, { }
514 #define V_OCTET VT_RANGE, { .l = 0 }, { .l = 255 }
515 #define V_NUM VT_RANGE, { .l = 0 }, { .l = 0x7FFFFFFF }
516 #define V_TEMP VT_TEMP, { }, { }
518 #define V_IPV6(required) VT_IPV6, { .i = required }, { }
521 static const nvset_t nvset_list
[] = {
524 { "router_name", V_LENGTH(0, 32) },
525 { "wan_hostname", V_LENGTH(0, 32) },
526 { "wan_domain", V_LENGTH(0, 32) },
529 { "tm_tz", V_LENGTH(1, 64) }, // PST8PDT
530 { "tm_sel", V_LENGTH(1, 64) }, // PST8PDT
532 { "ntp_updates", V_RANGE(-1, 24) },
533 { "ntp_tdod", V_01
},
534 { "ntp_server", V_LENGTH(1, 150) }, // x y z
535 { "ntp_kiss", V_LENGTH(0, 255) },
538 { "dhcpd_static", V_LENGTH(0, 108*251) }, // 108 (max chars per entry) x 250 entries
539 { "dhcpd_static_only", V_01
},
542 { "ddnsx0", V_LENGTH(0, 2048) },
543 { "ddnsx1", V_LENGTH(0, 2048) },
544 { "ddnsx0_cache", V_LENGTH(0, 1) }, // only to clear
545 { "ddnsx1_cache", V_LENGTH(0, 1) },
546 { "ddnsx_ip", V_LENGTH(0, 32) },
547 { "ddnsx_save", V_01
},
548 { "ddnsx_refresh", V_RANGE(0, 365) },
552 { "wan_proto", V_LENGTH(1, 16) }, // disabled, dhcp, static, pppoe, pptp, l2tp
553 { "wan_ipaddr", V_IP
},
554 { "wan_netmask", V_IP
},
555 { "wan_gateway", V_IP
},
556 { "hb_server_ip", V_LENGTH(0, 32) },
557 { "l2tp_server_ip", V_LENGTH(0, 128) },
558 { "pptp_server_ip", V_LENGTH(0, 128) },
559 { "pptp_dhcp", V_01
},
560 { "ppp_username", V_LENGTH(0, 60) },
561 { "ppp_passwd", V_LENGTH(0, 60) },
562 { "ppp_service", V_LENGTH(0, 50) },
563 { "ppp_demand", V_01
},
564 { "ppp_custom", V_LENGTH(0, 256) },
565 { "ppp_idletime", V_RANGE(0, 1440) },
566 { "ppp_redialperiod", V_RANGE(1, 86400) },
567 { "ppp_mlppp", V_01
},
568 { "mtu_enable", V_01
},
569 { "wan_mtu", V_RANGE(576, 1500) },
570 { "wan_islan", V_01
},
571 { "modem_ipaddr", V_IP
},
572 { "pppoe_lei", V_RANGE(1, 60) },
573 { "pppoe_lef", V_RANGE(1, 10) },
576 { "lan_ipaddr", V_IP
},
577 { "lan_netmask", V_IP
},
578 { "lan_gateway", V_IP
},
579 { "wan_dns", V_LENGTH(0, 50) }, // ip ip ip
581 #ifdef TCONFIG_DNSSEC
582 { "dnssec_enable", V_01
},
585 #ifdef TCONFIG_DNSCRYPT
586 { "dnscrypt_proxy", V_01
},
587 { "dnscrypt_priority", V_RANGE(0, 2) }, // 0=none, 1=preferred, 2=exclusive
588 { "dnscrypt_port", V_PORT
},
589 { "dnscrypt_resolver", V_LENGTH(0, 40) },
590 { "dnscrypt_log", V_RANGE(0, 99) },
591 { "dnscrypt_manual", V_01
},
592 { "dnscrypt_provider_name", V_LENGTH(0, 60) },
593 { "dnscrypt_provider_key", V_LENGTH(0, 80) },
594 { "dnscrypt_resolver_address", V_LENGTH(0, 50) },
596 { "lan_state", V_01
},
597 { "lan_desc", V_01
},
598 { "lan_invert", V_01
},
599 { "lan_proto", V_WORD
}, // static, dhcp
600 { "dhcp_start", V_LENGTH(0, 15) }, // remove !
601 { "dhcp_num", V_LENGTH(0, 4) }, // remove !
602 { "dhcpd_startip", V_LENGTH(0, 15) },
603 { "dhcpd_endip", V_LENGTH(0, 15) },
604 { "dhcp_lease", V_LENGTH(0, 5) },
605 { "wan_wins", V_IP
},
609 { "modem_pin", V_LENGTH(0,6) },
610 { "modem_dev", V_LENGTH(0,8) },
611 { "modem_init", V_LENGTH(0,25) },
612 { "modem_apn", V_LENGTH(0,25) },
613 { "modem_watchdog", V_RANGE(0,30) },
617 { "lan_ifname", V_LENGTH(0, 5) },
619 { "lan1_ifname", V_LENGTH(0, 5) },
620 { "lan1_ifnames", V_TEXT(0,64) },
621 { "lan1_ipaddr", V_LENGTH(0, 15) },
622 { "lan1_netmask", V_LENGTH(0, 15) },
623 { "lan1_proto", V_LENGTH(0, 6) },
624 { "lan1_stp", V_LENGTH(0, 1) },
625 { "dhcp1_start", V_LENGTH(0, 15) },
626 { "dhcp1_num", V_LENGTH(0, 4) },
627 { "dhcpd1_startip", V_LENGTH(0, 15) },
628 { "dhcpd1_endip", V_LENGTH(0, 15) },
629 { "dhcp1_lease", V_LENGTH(0, 5) },
631 { "lan2_ifname", V_LENGTH(0, 5) },
632 { "lan2_ifnames", V_TEXT(0,64) },
633 { "lan2_ipaddr", V_LENGTH(0, 15) },
634 { "lan2_netmask", V_LENGTH(0, 15) },
635 { "lan2_proto", V_LENGTH(0, 6) },
636 { "lan2_stp", V_LENGTH(0, 1) },
637 { "dhcp2_start", V_LENGTH(0, 15) },
638 { "dhcp2_num", V_LENGTH(0, 4) },
639 { "dhcpd2_startip", V_LENGTH(0, 15) },
640 { "dhcpd2_endip", V_LENGTH(0, 15) },
641 { "dhcp2_lease", V_LENGTH(0, 5) },
643 { "lan3_ifname", V_LENGTH(0, 5) },
644 { "lan3_ifnames", V_TEXT(0,64) },
645 { "lan3_ipaddr", V_LENGTH(0, 15) },
646 { "lan3_netmask", V_LENGTH(0, 15) },
647 { "lan3_proto", V_LENGTH(0, 6) },
648 { "lan3_stp", V_LENGTH(0, 1) },
649 { "dhcp3_start", V_LENGTH(0, 15) },
650 { "dhcp3_num", V_LENGTH(0, 4) },
651 { "dhcpd3_startip", V_LENGTH(0, 15) },
652 { "dhcpd3_endip", V_LENGTH(0, 15) },
653 { "dhcp3_lease", V_LENGTH(0, 5) },
656 { "wl_radio", V_01
},
657 { "wl_mode", V_LENGTH(2, 3) }, // ap, sta, wet, wds
658 { "wl_net_mode", V_LENGTH(5, 8) }, // disabled, mixed, b-only, g-only, bg-mixed, n-only [speedbooster]
659 { "wl_ssid", V_LENGTH(1, 32) },
660 { "wl_closed", V_01
},
661 { "wl_channel", V_RANGE(0, 216) },
663 { "wl_vifs", V_LENGTH(0, 64) }, // multiple/virtual BSSIDs
665 { "nas_alternate", V_01
}, // only meaningful for ND/K24 builds
668 { "wl_security_mode", V_LENGTH(1, 32) }, // disabled, radius, wep, wpa_personal, wpa_enterprise, wpa2_personal, wpa2_enterprise
669 { "wl_radius_ipaddr", V_IP
},
670 { "wl_radius_port", V_PORT
},
671 { "wl_radius_key", V_LENGTH(1, 64) },
672 { "wl_wep_bit", V_RANGE(64, 128) }, // 64 or 128
673 { "wl_passphrase", V_LENGTH(0, 20) },
674 { "wl_key", V_RANGE(1, 4) },
675 { "wl_key1", V_LENGTH(0, 26) },
676 { "wl_key2", V_LENGTH(0, 26) },
677 { "wl_key3", V_LENGTH(0, 26) },
678 { "wl_key4", V_LENGTH(0, 26) },
679 { "wl_crypto", V_LENGTH(3, 8) }, // tkip, aes, tkip+aes
680 { "wl_wpa_psk", V_LENGTH(8, 64) },
681 { "wl_wpa_gtk_rekey", V_RANGE(60, 7200) },
683 { "wl_lazywds", V_01
},
684 { "wl_wds", V_LENGTH(0, 180) }, // mac mac mac (x 10)
686 { "wl_wds_enable", V_01
},
687 { "wl_gmode", V_RANGE(-1, 6) },
688 { "wl_wep", V_LENGTH(1, 32) }, // off, on, restricted,tkip,aes,tkip+aes
689 { "wl_akm", V_LENGTH(0, 32) }, // wpa, wpa2, psk, psk2, wpa wpa2, psk psk2, ""
690 { "wl_auth_mode", V_LENGTH(4, 6) }, // none, radius
692 { "wl_nmode", V_NONE
},
693 { "wl_nband", V_RANGE(0, 2) }, // 2 - 2.4GHz, 1 - 5GHz, 0 - Auto
694 { "wl_nreqd", V_NONE
},
695 { "wl_nbw_cap", V_RANGE(0, 2) }, // 0 - 20MHz, 1 - 40MHz, 2 - Auto
696 { "wl_nbw", V_NONE
},
697 { "wl_mimo_preamble", V_WORD
}, // 802.11n Preamble: mm/gf/auto/gfbcm
698 { "wl_nctrlsb", V_NONE
}, // none, lower, upper
702 { "ipv6_service", V_LENGTH(0, 16) }, // '', native, native-pd, 6to4, sit, other
703 { "ipv6_prefix", V_IPV6(0) },
704 { "ipv6_prefix_length", V_RANGE(3, 127) },
705 { "ipv6_rtr_addr", V_IPV6(0) },
706 { "ipv6_radvd", V_01
},
707 { "ipv6_dhcpd", V_01
},
708 { "ipv6_accept_ra", V_NUM
},
709 { "ipv6_tun_addr", V_IPV6(1) },
710 { "ipv6_tun_addrlen", V_RANGE(3, 127) },
711 { "ipv6_ifname", V_LENGTH(0, 8) },
712 { "ipv6_tun_v4end", V_IP
},
713 { "ipv6_relay", V_RANGE(1, 254) },
714 { "ipv6_tun_mtu", V_NUM
}, // Tunnel MTU
715 { "ipv6_tun_ttl", V_NUM
}, // Tunnel TTL
716 { "ipv6_dns", V_LENGTH(0, 40*3) }, // ip6 ip6 ip6
717 { "ipv6_6rd_prefix", V_IPV6(0) },
718 { "ipv6_6rd_prefix_length", V_RANGE(3, 127) },
719 { "ipv6_6rd_borderrelay", V_IP
},
720 { "ipv6_6rd_ipv4masklen", V_RANGE(0, 32) },
721 { "ipv6_vlan", V_RANGE(0, 7) }, // Enable IPv6 on 1=LAN1 2=LAN2 4=LAN3
722 { "ipv6_pdonly", V_01
}, // Request DHCPv6 Prefix Delegation Only
723 { "ipv6_ipsec", V_01
}, // Enable Incoming IPv6 IPSec
727 { "wl_macmode", V_NONE
}, // allow, deny, disabled
728 { "wl_maclist", V_LENGTH(0, 18*201) }, // 18 x 200 (11:22:33:44:55:66 ...)
729 { "macnames", V_LENGTH(0, 62*201) }, // 62 (12+1+48+1) x 50 (112233445566<..>) todo: re-use -- zzz
733 { "ct_tcp_timeout", V_LENGTH(20, 70) },
734 { "ct_udp_timeout", V_LENGTH(5, 15) },
735 { "ct_timeout", V_LENGTH(5, 15) },
736 { "nf_ttl", V_LENGTH(1, 6) },
740 { "ct_hashsize", V_NUM
},
748 { "dhcpd_slt", V_RANGE(-1, 43200) }, // -1=infinite, 0=follow normal lease time, >=1 custom
749 { "dhcpd_dmdns", V_01
},
750 { "dhcpd_lmax", V_NUM
},
751 { "dhcpd_gwmode", V_NUM
},
752 { "dns_addget", V_01
},
753 { "dns_intcpt", V_01
},
754 { "dhcpc_minpkt", V_01
},
755 { "dhcpc_custom", V_LENGTH(0, 80) },
756 { "dns_norebind", V_01
},
757 { "dnsmasq_custom", V_TEXT(0, 2048) },
758 { "dnsmasq_q", V_RANGE(0,7) }, //bitfield quiet bit0=dhcp, 1=dhcp6, 2=ra
759 // { "dnsmasq_norw", V_01 },
762 { "block_wan", V_01
},
763 { "block_wan_limit", V_01
},
764 { "block_wan_limit_icmp", V_RANGE(1, 300) },
765 { "block_wan_limit_tr", V_RANGE(1, 300) },
766 { "multicast_pass", V_01
},
767 { "multicast_lan", V_01
},
768 { "multicast_lan1", V_01
},
769 { "multicast_lan2", V_01
},
770 { "multicast_lan3", V_01
},
771 { "block_loopback", V_01
},
772 { "udpxy_enable", V_01
},
773 { "udpxy_stats", V_01
},
774 { "udpxy_clients", V_RANGE(1, 5000) },
775 { "udpxy_port", V_RANGE(0, 65535) },
776 { "nf_loopback", V_NUM
},
777 { "ne_syncookies", V_01
},
778 { "DSCP_fix_enable", V_01
},
780 { "dhcp_pass", V_01
},
782 { "emf_entry", V_NONE
},
783 { "emf_uffp_entry", V_NONE
},
784 { "emf_rtport_entry", V_NONE
},
785 { "emf_enable", V_01
},
789 { "wait_time", V_RANGE(3, 20) },
790 { "wan_speed", V_RANGE(0, 4) },
791 { "jumbo_frame_enable", V_01
}, // Jumbo Frames support (for RT-N16/WNR3500L)
792 { "jumbo_frame_size", V_RANGE(1, 9720) },
794 { "ctf_disable", V_01
},
797 { "vlan0ports", V_TEXT(0,16) },
798 { "vlan1ports", V_TEXT(0,16) },
799 { "vlan2ports", V_TEXT(0,16) },
800 { "vlan3ports", V_TEXT(0,16) },
801 { "vlan4ports", V_TEXT(0,16) },
802 { "vlan5ports", V_TEXT(0,16) },
803 { "vlan6ports", V_TEXT(0,16) },
804 { "vlan7ports", V_TEXT(0,16) },
805 { "vlan8ports", V_TEXT(0,16) },
806 { "vlan9ports", V_TEXT(0,16) },
807 { "vlan10ports", V_TEXT(0,16) },
808 { "vlan11ports", V_TEXT(0,16) },
809 { "vlan12ports", V_TEXT(0,16) },
810 { "vlan13ports", V_TEXT(0,16) },
811 { "vlan14ports", V_TEXT(0,16) },
812 { "vlan15ports", V_TEXT(0,16) },
813 { "vlan0hwname", V_TEXT(0,8) },
814 { "vlan1hwname", V_TEXT(0,8) },
815 { "vlan2hwname", V_TEXT(0,8) },
816 { "vlan3hwname", V_TEXT(0,8) },
817 { "vlan4hwname", V_TEXT(0,8) },
818 { "vlan5hwname", V_TEXT(0,8) },
819 { "vlan6hwname", V_TEXT(0,8) },
820 { "vlan7hwname", V_TEXT(0,8) },
821 { "vlan8hwname", V_TEXT(0,8) },
822 { "vlan9hwname", V_TEXT(0,8) },
823 { "vlan10hwname", V_TEXT(0,8) },
824 { "vlan11hwname", V_TEXT(0,8) },
825 { "vlan12hwname", V_TEXT(0,8) },
826 { "vlan13hwname", V_TEXT(0,8) },
827 { "vlan14hwname", V_TEXT(0,8) },
828 { "vlan15hwname", V_TEXT(0,8) },
829 { "wan_ifnameX", V_TEXT(0,8) },
830 { "lan_ifnames", V_TEXT(0,64) },
831 { "manual_boot_nv", V_01
},
832 { "trunk_vlan_so", V_01
},
833 { "vlan0tag", V_TEXT(0,5) },
834 { "vlan0vid", V_TEXT(0,5) },
835 { "vlan1vid", V_TEXT(0,5) },
836 { "vlan2vid", V_TEXT(0,5) },
837 { "vlan3vid", V_TEXT(0,5) },
838 { "vlan4vid", V_TEXT(0,5) },
839 { "vlan5vid", V_TEXT(0,5) },
840 { "vlan6vid", V_TEXT(0,5) },
841 { "vlan7vid", V_TEXT(0,5) },
842 { "vlan8vid", V_TEXT(0,5) },
843 { "vlan9vid", V_TEXT(0,5) },
844 { "vlan10vid", V_TEXT(0,5) },
845 { "vlan11vid", V_TEXT(0,5) },
846 { "vlan12vid", V_TEXT(0,5) },
847 { "vlan13vid", V_TEXT(0,5) },
848 { "vlan14vid", V_TEXT(0,5) },
849 { "vlan15vid", V_TEXT(0,5) },
852 { "mac_wan", V_LENGTH(0, 17) },
853 { "wl_macaddr", V_LENGTH(0, 17) },
854 { "wl_hwaddr", V_LENGTH(0, 17) },
857 { "routes_static", V_LENGTH(0, 2048) },
858 { "dhcp_routes", V_01
},
859 { "lan_stp", V_RANGE(0, 1) },
860 { "wk_mode", V_LENGTH(1, 32) }, // gateway, router
862 { "dr_setting", V_RANGE(0, 3) },
863 { "dr_lan_tx", V_LENGTH(0, 32) },
864 { "dr_lan_rx", V_LENGTH(0, 32) },
865 { "dr_lan1_tx", V_LENGTH(0, 32) },
866 { "dr_lan1_rx", V_LENGTH(0, 32) },
867 { "dr_lan2_tx", V_LENGTH(0, 32) },
868 { "dr_lan2_rx", V_LENGTH(0, 32) },
869 { "dr_lan3_tx", V_LENGTH(0, 32) },
870 { "dr_lan3_rx", V_LENGTH(0, 32) },
871 { "dr_wan_tx", V_LENGTH(0, 32) },
872 { "dr_wan_rx", V_LENGTH(0, 32) },
876 { "lan_access", V_LENGTH(0, 4096) },
879 { "wl_country", V_LENGTH(0, 64) }, // !!TB - Country code
880 { "wl_country_code", V_LENGTH(0, 4) }, // !!TB - Country code
881 { "wl_btc_mode", V_RANGE(0, 2) }, // !!TB - BT Coexistence Mode: 0 (disable), 1 (enable), 2 (preemption)
882 { "wl_afterburner", V_LENGTH(2, 4) }, // off, on, auto
884 { "wl_rateset", V_LENGTH(2, 7) }, // all, default, 12
885 { "wl_rate", V_RANGE(0, 54 * 1000 * 1000) },
886 { "wl_mrate", V_RANGE(0, 54 * 1000 * 1000) },
887 { "wl_gmode_protection",V_LENGTH(3, 4) }, // off, auto
888 { "wl_frameburst", V_ONOFF
}, // off, on
889 { "wl_bcn", V_RANGE(1, 65535) },
890 { "wl_dtim", V_RANGE(1, 255) },
891 { "wl_frag", V_RANGE(256, 2346) },
892 { "wl_rts", V_RANGE(0, 2347) },
893 { "wl_ap_isolate", V_01
},
894 { "wl_plcphdr", V_LENGTH(4, 5) }, // long, short
895 { "wl_antdiv", V_RANGE(0, 3) },
896 { "wl_txant", V_RANGE(0, 3) },
897 { "wl_txpwr", V_RANGE(0, 400) },
898 { "wl_wme", V_WORD
}, // auto, off, on
899 { "wl_wme_no_ack", V_ONOFF
}, // off, on
900 { "wl_wme_apsd", V_ONOFF
}, // off, on
901 { "wl_maxassoc", V_RANGE(0, 255) },
902 { "wl_distance", V_LENGTH(0, 5) }, // "", 1-99999
903 { "wlx_hpamp", V_01
},
904 { "wlx_hperx", V_01
},
905 { "wl_reg_mode", V_LENGTH(1, 3) }, // !!TB - Regulatory: off, h, d
906 { "wl_mitigation", V_RANGE(0, 4) }, // Interference Mitigation Mode (0|1|2|3|4)
908 { "wl_nmode_protection", V_WORD
, }, // off, auto
909 { "wl_nmcsidx", V_RANGE(-2, 32), }, // -2 - 32
910 { "wl_obss_coex", V_01
},
911 { "wl_wmf_bss_enable", V_01
}, // Toastman
914 { "dmz_enable", V_01
},
915 { "dmz_ipaddr", V_LENGTH(0, 15) },
916 { "dmz_sip", V_LENGTH(0, 512) },
917 { "dmz_ifname", V_LENGTH(0, 5) },
921 { "upnp_enable", V_NUM
},
922 { "upnp_secure", V_01
},
923 { "upnp_port", V_RANGE(0, 65535) },
924 { "upnp_ssdp_interval", V_RANGE(10, 9999) },
925 { "upnp_mnp", V_01
},
926 { "upnp_clean", V_01
},
927 { "upnp_clean_interval", V_RANGE(60, 65535) },
928 { "upnp_clean_threshold", V_RANGE(0, 9999) },
929 { "upnp_min_port_int", V_PORT
},
930 { "upnp_max_port_int", V_PORT
},
931 { "upnp_min_port_ext", V_PORT
},
932 { "upnp_max_port_ext", V_PORT
},
933 { "upnp_lan", V_01
},
934 { "upnp_lan1", V_01
},
935 { "upnp_lan2", V_01
},
936 { "upnp_lan3", V_01
},
937 { "upnp_custom", V_TEXT(0, 2048) },
940 { "portforward", V_LENGTH(0, 4096) },
943 // forward-basic-ipv6
944 { "ipv6_portforward", V_LENGTH(0, 4096) },
948 { "trigforward", V_LENGTH(0, 4096) },
951 // access restriction
952 { "rruleN", V_RANGE(0, 99) },
953 // { "rrule##", V_LENGTH(0, 2048) }, // in save_variables()
956 { "http_enable", V_01
},
957 { "https_enable", V_01
},
958 { "https_crt_save", V_01
},
959 { "https_crt_cn", V_LENGTH(0, 64) },
960 { "https_crt_gen", V_TEMP
},
961 { "remote_management", V_01
},
962 { "remote_mgt_https", V_01
},
963 { "http_lanport", V_PORT
},
964 { "https_lanport", V_PORT
},
965 { "web_wl_filter", V_01
},
966 { "web_css", V_LENGTH(1, 32) },
967 { "web_dir", V_LENGTH(1, 32) },
968 { "ttb_css", V_LENGTH(0, 128) },
969 { "web_mx", V_LENGTH(0, 128) },
970 { "http_wanport", V_PORT
},
971 { "telnetd_eas", V_01
},
972 { "telnetd_port", V_PORT
},
973 { "sshd_eas", V_01
},
974 { "sshd_pass", V_01
},
975 { "sshd_port", V_PORT
},
976 { "sshd_remote", V_01
},
977 { "sshd_motd", V_01
},
978 { "sshd_forwarding", V_01
},
979 { "sshd_rport", V_PORT
},
980 { "sshd_authkeys", V_TEXT(0, 4096) },
981 { "rmgt_sip", V_LENGTH(0, 512) },
982 { "ne_shlimit", V_TEXT(1, 50) },
983 { "http_username", V_LENGTH(0, 32) },
984 { "http_root", V_01
},
987 { "rstats_enable", V_01
},
988 { "rstats_path", V_LENGTH(0, 48) },
989 { "rstats_stime", V_RANGE(1, 168) },
990 { "rstats_offset", V_RANGE(1, 31) },
991 { "rstats_exclude", V_LENGTH(0, 64) },
992 { "rstats_sshut", V_01
},
993 { "rstats_bak", V_01
},
996 { "cstats_enable", V_01
},
997 { "cstats_path", V_LENGTH(0, 48) },
998 { "cstats_stime", V_RANGE(1, 168) },
999 { "cstats_offset", V_RANGE(1, 31) },
1000 { "cstats_labels", V_RANGE(0, 2) },
1001 { "cstats_exclude", V_LENGTH(0, 512) },
1002 { "cstats_include", V_LENGTH(0, 2048) },
1003 { "cstats_all", V_01
},
1004 { "cstats_sshut", V_01
},
1005 { "cstats_bak", V_01
},
1008 { "sesx_led", V_RANGE(0, 255) }, // amber, white, aoss
1009 { "sesx_b0", V_RANGE(0, 5) }, // 0-5: toggle wireless, reboot, shutdown, script, usb unmount
1010 { "sesx_b1", V_RANGE(0, 5) }, // "
1011 { "sesx_b2", V_RANGE(0, 5) }, // "
1012 { "sesx_b3", V_RANGE(0, 5) }, // "
1013 { "sesx_script", V_TEXT(0, 1024) }, //
1014 { "script_brau", V_TEXT(0, 1024) }, //
1017 { "debug_nocommit", V_01
},
1018 { "debug_cprintf", V_01
},
1019 { "debug_cprintf_file", V_01
},
1020 // { "debug_keepfiles", V_01 },
1021 { "debug_ddns", V_01
},
1022 { "debug_norestart", V_TEXT(0, 128) },
1023 { "console_loglevel", V_RANGE(1, 8) },
1024 { "t_cafree", V_01
},
1025 { "t_hidelr", V_01
},
1028 { "sch_rboot", V_TEXT(0, 64) },
1029 { "sch_rcon", V_TEXT(0, 64) },
1030 { "sch_c1", V_TEXT(0, 64) },
1031 { "sch_c1_cmd", V_TEXT(0, 2048) },
1032 { "sch_c2", V_TEXT(0, 64) },
1033 { "sch_c2_cmd", V_TEXT(0, 2048) },
1034 { "sch_c3", V_TEXT(0, 64) },
1035 { "sch_c3_cmd", V_TEXT(0, 2048) },
1036 { "sch_c4", V_TEXT(0, 64) },
1037 { "sch_c4_cmd", V_TEXT(0, 2048) },
1038 { "sch_c5", V_TEXT(0, 64) },
1039 { "sch_c5_cmd", V_TEXT(0, 2048) },
1042 { "script_init", V_TEXT(0, 4096) },
1043 { "script_shut", V_TEXT(0, 4096) },
1044 { "script_fire", V_TEXT(0, 8192) },
1045 { "script_wanup", V_TEXT(0, 4096) },
1048 { "log_remote", V_01
},
1049 { "log_remoteip", V_LENGTH(0, 512) },
1050 { "log_remoteport", V_PORT
},
1051 { "log_file", V_01
},
1052 { "log_file_custom", V_01
},
1053 { "log_file_path", V_TEXT(0, 4096) },
1054 { "log_file_size", V_RANGE(0, 99999) },
1055 { "log_file_keep", V_RANGE(0, 99) },
1056 { "log_limit", V_RANGE(0, 2400) },
1057 { "log_in", V_RANGE(0, 3) },
1058 { "log_out", V_RANGE(0, 3) },
1059 { "log_mark", V_RANGE(0, 99999) },
1060 { "log_events", V_TEXT(0, 32) }, // "acre,crond,ntp"
1062 // admin-log-webmonitor
1064 { "log_wmtype", V_RANGE(0, 2) },
1065 { "log_wmip", V_LENGTH(0, 512) },
1066 { "log_wmdmax", V_RANGE(0, 9999) },
1067 { "log_wmsmax", V_RANGE(0, 9999) },
1068 { "webmon_bkp", V_01
},
1069 { "webmon_dir", V_LENGTH(0, 256) },
1070 { "webmon_shrink", V_01
},
1074 { "cifs1", V_LENGTH(1, 1024) },
1075 { "cifs2", V_LENGTH(1, 1024) },
1078 { "jffs2_on", V_01
},
1079 { "jffs2_exec", V_LENGTH(0, 64) },
1080 { "jffs2_format", V_01
},
1085 { "mmc_cs", V_RANGE(1, 7) }, // GPIO pin
1086 { "mmc_clk", V_RANGE(1, 7) }, // GPIO pin
1087 { "mmc_din", V_RANGE(1, 7) }, // GPIO pin
1088 { "mmc_dout", V_RANGE(1, 7) }, // GPIO pin
1089 { "mmc_fs_partition", V_RANGE(1, 4) }, // partition number in partition table
1090 { "mmc_fs_type", V_LENGTH(4, 4) }, // ext2, ext3, vfat
1091 { "mmc_exec_mount", V_LENGTH(0, 64) },
1092 { "mmc_exec_umount", V_LENGTH(0, 64) },
1097 { "usb_enable", V_01
},
1098 { "usb_uhci", V_RANGE(-1, 1) }, // -1 - disabled, 0 - off, 1 - on
1099 { "usb_ohci", V_RANGE(-1, 1) },
1100 { "usb_usb2", V_RANGE(-1, 1) },
1101 { "usb_irq_thresh", V_RANGE(0, 6) },
1102 { "usb_storage", V_01
},
1103 { "usb_printer", V_01
},
1104 { "usb_printer_bidirect", V_01
},
1105 { "usb_fs_ext3", V_01
},
1106 { "usb_fs_fat", V_01
},
1108 { "usb_fs_ntfs", V_01
},
1111 { "usb_fs_hfs", V_01
}, //!Victek
1113 { "usb_automount", V_01
},
1114 { "script_usbhotplug", V_TEXT(0, 2048) },
1115 { "script_usbmount", V_TEXT(0, 2048) },
1116 { "script_usbumount", V_TEXT(0, 2048) },
1117 { "idle_enable", V_01
},
1123 { "ftp_enable", V_RANGE(0, 2) },
1124 { "ftp_super", V_01
},
1125 { "ftp_anonymous", V_RANGE(0, 3) },
1126 { "ftp_dirlist", V_RANGE(0, 2) },
1127 { "ftp_port", V_PORT
},
1128 { "ftp_max", V_RANGE(0, 12) },
1129 { "ftp_ipmax", V_RANGE(0, 12) },
1130 { "ftp_staytimeout", V_RANGE(0, 65535) },
1131 { "ftp_rate", V_RANGE(0, 99999) },
1132 { "ftp_anonrate", V_RANGE(0, 99999) },
1133 { "ftp_anonroot", V_LENGTH(0, 256) },
1134 { "ftp_pubroot", V_LENGTH(0, 256) },
1135 { "ftp_pvtroot", V_LENGTH(0, 256) },
1136 { "ftp_users", V_LENGTH(0, 4096) },
1137 { "ftp_custom", V_TEXT(0, 2048) },
1138 { "ftp_sip", V_LENGTH(0, 512) },
1139 { "ftp_limit", V_TEXT(1, 50) },
1140 { "log_ftp", V_01
},
1144 { "snmp_enable", V_RANGE(0, 1) },
1145 { "snmp_port", V_RANGE(1, 65535) },
1146 { "snmp_remote", V_RANGE(0, 1) },
1147 { "snmp_remote_sip", V_LENGTH(0, 512) },
1148 { "snmp_location", V_LENGTH(0, 40) },
1149 { "snmp_contact", V_LENGTH(0, 40) },
1150 { "snmp_ro", V_LENGTH(0, 40) },
1153 #ifdef TCONFIG_SAMBASRV
1155 { "smbd_enable", V_RANGE(0, 2) },
1156 { "smbd_wgroup", V_LENGTH(0, 20) },
1157 { "smbd_master", V_01
},
1158 { "smbd_wins", V_01
},
1159 { "smbd_cpage", V_LENGTH(0, 4) },
1160 { "smbd_cset", V_LENGTH(0, 20) },
1161 { "smbd_custom", V_TEXT(0, 2048) },
1162 { "smbd_autoshare", V_RANGE(0, 3) },
1163 { "smbd_shares", V_LENGTH(0, 4096) },
1164 { "smbd_user", V_LENGTH(0, 50) },
1165 { "smbd_passwd", V_LENGTH(0, 50) },
1168 #ifdef TCONFIG_MEDIA_SERVER
1170 { "ms_enable", V_01
},
1171 { "ms_dirs", V_LENGTH(0, 1024) },
1172 { "ms_port", V_RANGE(0, 65535) },
1173 { "ms_dbdir", V_LENGTH(0, 256) },
1174 { "ms_tivo", V_01
},
1175 { "ms_stdlna", V_01
},
1176 { "ms_rescan", V_01
},
1181 { "qos_enable", V_01
},
1182 { "qos_ack", V_01
},
1183 { "qos_syn", V_01
},
1184 { "qos_fin", V_01
},
1185 { "qos_rst", V_01
},
1186 { "qos_icmp", V_01
},
1187 { "qos_udp", V_01
},
1188 { "qos_reset", V_01
},
1189 { "qos_pfifo", V_01
}, // !!TB
1190 { "qos_obw", V_RANGE(10, 999999) },
1191 { "qos_ibw", V_RANGE(10, 999999) },
1192 { "qos_orules", V_LENGTH(0, 16384) },
1193 { "qos_default", V_RANGE(0, 9) },
1194 { "qos_irates", V_LENGTH(0, 128) },
1195 { "qos_orates", V_LENGTH(0, 128) },
1196 { "qos_classnames", V_LENGTH(10, 128) }, // !!TOASTMAN
1197 { "atm_overhead", V_RANGE(-127, 128) },
1198 { "ne_vegas", V_01
},
1199 { "ne_valpha", V_NUM
},
1200 { "ne_vbeta", V_NUM
},
1201 { "ne_vgamma", V_NUM
},
1204 { "new_qoslimit_enable", V_01
},
1205 { "new_qoslimit_rules", V_LENGTH(0, 4096) },
1206 { "qosl_enable", V_01
},
1207 { "qosl_ulr", V_RANGE(0, 999999) },
1208 { "qosl_ulc", V_RANGE(0, 999999) },
1209 { "qosl_dlr", V_RANGE(0, 999999) },
1210 { "qosl_dlc", V_RANGE(0, 999999) },
1211 { "qosl_tcp", V_RANGE(0, 1000) },
1212 { "qosl_udp", V_RANGE(0, 100) },
1213 { "limit_br0_prio", V_RANGE(0, 5) },
1214 { "limit_br1_enable", V_01
},
1215 { "limit_br1_ulr", V_RANGE(0, 999999) },
1216 { "limit_br1_ulc", V_RANGE(0, 999999) },
1217 { "limit_br1_dlr", V_RANGE(0, 999999) },
1218 { "limit_br1_dlc", V_RANGE(0, 999999) },
1219 { "limit_br1_prio", V_RANGE(0, 5) },
1220 { "limit_br2_enable", V_01
},
1221 { "limit_br2_ulr", V_RANGE(0, 999999) },
1222 { "limit_br2_ulc", V_RANGE(0, 999999) },
1223 { "limit_br2_dlr", V_RANGE(0, 999999) },
1224 { "limit_br2_dlc", V_RANGE(0, 999999) },
1225 { "limit_br2_prio", V_RANGE(0, 5) },
1226 { "limit_br3_enable", V_01
},
1227 { "limit_br3_ulr", V_RANGE(0, 999999) },
1228 { "limit_br3_ulc", V_RANGE(0, 999999) },
1229 { "limit_br3_dlr", V_RANGE(0, 999999) },
1230 { "limit_br3_dlc", V_RANGE(0, 999999) },
1231 { "limit_br3_prio", V_RANGE(0, 5) },
1236 { "bt_enable", V_01
},
1237 { "bt_binary", V_LENGTH(0, 50) },
1238 { "bt_binary_custom", V_LENGTH(0, 50) },
1239 { "bt_custom", V_TEXT(0, 2048) },
1240 { "bt_port", V_PORT
},
1241 { "bt_dir", V_LENGTH(0, 50) },
1242 { "bt_settings", V_LENGTH(0, 50) },
1243 { "bt_settings_custom", V_LENGTH(0, 50) },
1244 { "bt_incomplete", V_01
},
1245 { "bt_rpc_enable", V_01
},
1246 { "bt_rpc_wan", V_01
},
1247 { "bt_auth", V_01
},
1248 { "bt_login", V_LENGTH(0, 50) },
1249 { "bt_password", V_LENGTH(0, 50) },
1250 { "bt_port_gui", V_PORT
},
1251 { "bt_dl_enable", V_01
},
1252 { "bt_ul_enable", V_01
},
1253 { "bt_dl", V_RANGE(0, 999999) },
1254 { "bt_ul", V_RANGE(0, 999999) },
1255 { "bt_peer_limit_global", V_RANGE(10, 1000) },
1256 { "bt_peer_limit_per_torrent", V_RANGE(1, 200) },
1257 { "bt_ul_slot_per_torrent", V_RANGE(1, 50) },
1258 { "bt_ratio_enable", V_01
},
1259 { "bt_ratio", V_LENGTH(0, 999999) },
1260 { "bt_ratio_idle_enable", V_01
},
1261 { "bt_ratio_idle", V_RANGE(1, 55) },
1266 { "bt_blocklist", V_01
},
1267 { "bt_blocklist_url", V_LENGTH(0, 80) },
1268 { "bt_sleep", V_RANGE(1, 60) },
1269 { "bt_check", V_01
},
1270 { "bt_check_time", V_RANGE(1, 55) },
1271 { "bt_dl_queue_enable", V_01
},
1272 { "bt_dl_queue_size", V_RANGE(1, 30) },
1273 { "bt_ul_queue_enable", V_01
},
1274 { "bt_ul_queue_size", V_RANGE(1, 30) },
1275 { "bt_message", V_RANGE(0, 3) },
1277 { "bt_log_path", V_LENGTH(0, 50) },
1282 { "nfs_enable", V_01
},
1283 { "nfs_exports", V_LENGTH(0, 4096) },
1286 //NotCatSplash. Victek.
1287 #ifdef TCONFIG_NOCAT
1288 { "NC_enable", V_01
},
1289 { "NC_Verbosity", V_RANGE(0, 10) },
1290 { "NC_GatewayName", V_LENGTH(0, 255) },
1291 { "NC_GatewayPort", V_PORT
},
1292 { "NC_ForcedRedirect", V_01
},
1293 { "NC_HomePage", V_LENGTH(0, 255) },
1294 { "NC_DocumentRoot", V_LENGTH(0, 255) },
1295 { "NC_SplashURL", V_LENGTH(0, 255) },
1296 { "NC_LoginTimeout", V_RANGE(0, 86400000) },
1297 { "NC_IdleTimeout", V_RANGE(0, 86400000) },
1298 { "NC_MaxMissedARP", V_RANGE(0, 10) },
1299 { "NC_PeerChecktimeout", V_RANGE(0, 60) },
1300 { "NC_ExcludePorts", V_LENGTH(0, 255) },
1301 { "NC_IncludePorts", V_LENGTH(0, 255) },
1302 { "NC_AllowedWebHosts", V_LENGTH(0, 255) },
1303 { "NC_MACWhiteList", V_LENGTH(0, 255) },
1304 { "NC_SplashFile", V_LENGTH(0, 8192) },
1305 { "NC_BridgeLAN", V_LENGTH(0, 50) },
1308 // NGinX Roadkill-Victek
1309 #ifdef TCONFIG_NGINX
1310 {"nginx_enable", V_01
}, // NGinX enabled
1311 {"nginx_php", V_01
}, // PHP enabled
1312 {"nginx_keepconf", V_01
}, // NGinX configuration files overwrite flag
1313 {"nginx_docroot", V_LENGTH(0, 255) }, // root files path
1314 {"nginx_port", V_PORT
}, // listening port
1315 {"nginx_fqdn", V_LENGTH(0, 255) }, // server name
1316 {"nginx_upload", V_LENGTH(1, 1000) }, // upload file size limit
1317 {"nginx_remote", V_01
},
1318 {"nginx_priority", V_LENGTH(0, 255) }, // server priority
1319 {"nginx_custom", V_TEXT(0, 4096) }, // user window to add parameters to nginx.conf
1320 {"nginx_httpcustom", V_TEXT(0, 4096) }, // user window to add parameters to nginx.conf
1321 {"nginx_servercustom", V_TEXT(0, 4096) }, // user window to add parameters to nginx.conf
1322 {"nginx_phpconf", V_TEXT(0, 4096) }, // user window to add parameters to php.ini
1323 {"nginx_user", V_LENGTH(0, 255) }, // user used to start nginx and spawn-fcgi
1324 {"nginx_override", V_01
},
1325 {"nginx_overridefile", V_TEXT(0, 4096) },
1328 { "mysql_enable", V_01
},
1329 { "mysql_sleep", V_RANGE(1,60) },
1330 { "mysql_check", V_01
},
1331 { "mysql_check_time", V_RANGE(1,55) },
1332 { "mysql_binary", V_LENGTH(0, 50) },
1333 { "mysql_binary_custom", V_LENGTH(0, 50) },
1334 { "mysql_usb_enable", V_01
},
1335 { "mysql_dlroot", V_LENGTH(0,50) },
1336 { "mysql_datadir", V_LENGTH(0,64) },
1337 { "mysql_tmpdir", V_LENGTH(0,64) },
1338 { "mysql_server_custom", V_TEXT(0,1024) },
1339 { "mysql_port", V_PORT
},
1340 { "mysql_allow_anyhost", V_01
},
1341 { "mysql_init_rootpass", V_01
},
1342 { "mysql_username", V_TEXT(0,50) }, // mysqladmin username
1343 { "mysql_passwd", V_TEXT(0,50) }, // mysqladmin password
1344 { "mysql_key_buffer", V_RANGE(0,1024) }, // MB
1345 { "mysql_max_allowed_packet", V_RANGE(0,1024) }, // MB
1346 { "mysql_thread_stack", V_RANGE(0,1024000) }, // KB
1347 { "mysql_thread_cache_size", V_RANGE(0,999999) },
1348 { "mysql_init_priv", V_01
},
1349 { "mysql_table_open_cache", V_RANGE(1,999999) },
1350 { "mysql_sort_buffer_size", V_RANGE(0,1024000) }, //KB
1351 { "mysql_read_buffer_size", V_RANGE(0,1024000) }, //KB
1352 { "mysql_query_cache_size", V_RANGE(0,1024) }, //MB
1353 { "mysql_read_rnd_buffer_size", V_RANGE(0,1024000) }, //KB
1354 { "mysql_net_buffer_length", V_RANGE(0,1024) }, //K
1355 { "mysql_max_connections", V_RANGE(0,999999) },
1358 #ifdef TCONFIG_OPENVPN
1360 { "vpn_debug", V_01
},
1361 { "vpn_server_eas", V_NONE
},
1362 { "vpn_server_dns", V_NONE
},
1363 { "vpn_server1_poll", V_RANGE(0, 1440) },
1364 { "vpn_server1_if", V_TEXT(3, 3) }, // tap, tun
1365 { "vpn_server1_proto", V_TEXT(3, 10) }, // udp, tcp-server
1366 { "vpn_server1_port", V_PORT
},
1367 { "vpn_server1_firewall", V_TEXT(0, 8) }, // auto, external, custom
1368 { "vpn_server1_crypt", V_TEXT(0, 6) }, // tls, secret, custom
1369 { "vpn_server1_comp", V_TEXT(0, 8) }, // yes, no, adaptive
1370 { "vpn_server1_cipher", V_TEXT(0, 16) },
1371 { "vpn_server1_dhcp", V_01
},
1372 { "vpn_server1_r1", V_IP
},
1373 { "vpn_server1_r2", V_IP
},
1374 { "vpn_server1_sn", V_IP
},
1375 { "vpn_server1_nm", V_IP
},
1376 { "vpn_server1_local", V_IP
},
1377 { "vpn_server1_remote", V_IP
},
1378 { "vpn_server1_reneg", V_RANGE(-1,2147483647)},
1379 { "vpn_server1_hmac", V_RANGE(-1, 2) },
1380 { "vpn_server1_plan", V_01
},
1381 { "vpn_server1_ccd", V_01
},
1382 { "vpn_server1_c2c", V_01
},
1383 { "vpn_server1_ccd_excl", V_01
},
1384 { "vpn_server1_ccd_val", V_NONE
},
1385 { "vpn_server1_pdns", V_01
},
1386 { "vpn_server1_rgw", V_01
},
1387 { "vpn_server1_userpass", V_01
},
1388 { "vpn_server1_nocert", V_01
},
1389 { "vpn_server1_users_val",V_NONE
},
1390 { "vpn_server1_custom", V_NONE
},
1391 { "vpn_server1_static", V_NONE
},
1392 { "vpn_server1_ca", V_NONE
},
1393 { "vpn_server1_crt", V_NONE
},
1394 { "vpn_server1_key", V_NONE
},
1395 { "vpn_server1_dh", V_NONE
},
1396 { "vpn_server1_br", V_LENGTH(0, 50) },
1397 { "vpn_server1_route", V_01
},
1398 { "vpn_server1_routing_val", V_NONE
},
1399 { "vpn_server2_poll", V_RANGE(0, 1440) },
1400 { "vpn_server2_if", V_TEXT(3, 3) }, // tap, tun
1401 { "vpn_server2_proto", V_TEXT(3, 10) }, // udp, tcp-server
1402 { "vpn_server2_port", V_PORT
},
1403 { "vpn_server2_firewall", V_TEXT(0, 8) }, // auto, external, custom
1404 { "vpn_server2_crypt", V_TEXT(0, 6) }, // tls, secret, custom
1405 { "vpn_server2_comp", V_TEXT(0, 8) }, // yes, no, adaptive
1406 { "vpn_server2_cipher", V_TEXT(0, 16) },
1407 { "vpn_server2_dhcp", V_01
},
1408 { "vpn_server2_r1", V_IP
},
1409 { "vpn_server2_r2", V_IP
},
1410 { "vpn_server2_sn", V_IP
},
1411 { "vpn_server2_nm", V_IP
},
1412 { "vpn_server2_local", V_IP
},
1413 { "vpn_server2_remote", V_IP
},
1414 { "vpn_server2_reneg", V_RANGE(-1,2147483647)},
1415 { "vpn_server2_hmac", V_RANGE(-1, 2) },
1416 { "vpn_server2_plan", V_01
},
1417 { "vpn_server2_pdns", V_01
},
1418 { "vpn_server2_rgw", V_01
},
1419 { "vpn_server2_userpass", V_01
},
1420 { "vpn_server2_nocert", V_01
},
1421 { "vpn_server2_users_val",V_NONE
},
1422 { "vpn_server2_custom", V_NONE
},
1423 { "vpn_server2_ccd", V_01
},
1424 { "vpn_server2_c2c", V_01
},
1425 { "vpn_server2_ccd_excl", V_01
},
1426 { "vpn_server2_ccd_val", V_NONE
},
1427 { "vpn_server2_static", V_NONE
},
1428 { "vpn_server2_ca", V_NONE
},
1429 { "vpn_server2_crt", V_NONE
},
1430 { "vpn_server2_key", V_NONE
},
1431 { "vpn_server2_dh", V_NONE
},
1432 { "vpn_server2_br", V_LENGTH(0, 50) },
1433 { "vpn_server2_route", V_01
},
1434 { "vpn_server2_routing_val", V_NONE
},
1435 { "vpn_client_eas", V_NONE
},
1436 { "vpn_client1_poll", V_RANGE(0, 1440) },
1437 { "vpn_client1_if", V_TEXT(3, 3) }, // tap, tun
1438 { "vpn_client1_bridge", V_01
},
1439 { "vpn_client1_nat", V_01
},
1440 { "vpn_client1_proto", V_TEXT(3, 10) }, // udp, tcp-server
1441 { "vpn_client1_addr", V_NONE
},
1442 { "vpn_client1_port", V_PORT
},
1443 { "vpn_client1_retry", V_RANGE(-1,32767) }, // -1 infinite, 0 disabled, >= 1 custom
1444 { "vpn_client1_firewall", V_TEXT(0, 6) }, // auto, custom
1445 { "vpn_client1_crypt", V_TEXT(0, 6) }, // tls, secret, custom
1446 { "vpn_client1_comp", V_TEXT(0, 8) }, // yes, no, adaptive
1447 { "vpn_client1_cipher", V_TEXT(0, 16) },
1448 { "vpn_client1_local", V_IP
},
1449 { "vpn_client1_remote", V_IP
},
1450 { "vpn_client1_nm", V_IP
},
1451 { "vpn_client1_reneg", V_RANGE(-1,2147483647)},
1452 { "vpn_client1_hmac", V_RANGE(-1, 2) },
1453 { "vpn_client1_adns", V_RANGE(0, 3) },
1454 { "vpn_client1_rgw", V_01
},
1455 { "vpn_client1_gw", V_TEXT(0, 15) },
1456 { "vpn_client1_custom", V_NONE
},
1457 { "vpn_client1_static", V_NONE
},
1458 { "vpn_client1_ca", V_NONE
},
1459 { "vpn_client1_crt", V_NONE
},
1460 { "vpn_client1_key", V_NONE
},
1461 { "vpn_client1_userauth", V_01
},
1462 { "vpn_client1_username", V_TEXT(0,50) },
1463 { "vpn_client1_password", V_TEXT(0,50) },
1464 { "vpn_client1_useronly", V_01
},
1465 { "vpn_client1_tlsremote",V_01
},
1466 { "vpn_client1_cn", V_NONE
},
1467 { "vpn_client1_br", V_LENGTH(0, 50) },
1468 { "vpn_client1_nopull", V_01
},
1469 { "vpn_client1_route", V_01
},
1470 { "vpn_client1_routing_val", V_NONE
},
1471 { "vpn_client2_poll", V_RANGE(0, 1440) },
1472 { "vpn_client2_if", V_TEXT(3, 3) }, // tap, tun
1473 { "vpn_client2_bridge", V_01
},
1474 { "vpn_client2_nat", V_01
},
1475 { "vpn_client2_proto", V_TEXT(3, 10) }, // udp, tcp-server
1476 { "vpn_client2_addr", V_NONE
},
1477 { "vpn_client2_port", V_PORT
},
1478 { "vpn_client2_retry", V_RANGE(-1,32767) }, // -1 infinite, 0 disabled, >= 1 custom
1479 { "vpn_client2_firewall", V_TEXT(0, 6) }, // auto, custom
1480 { "vpn_client2_crypt", V_TEXT(0, 6) }, // tls, secret, custom
1481 { "vpn_client2_comp", V_TEXT(0, 8) }, // yes, no, adaptive
1482 { "vpn_client2_cipher", V_TEXT(0, 16) },
1483 { "vpn_client2_local", V_IP
},
1484 { "vpn_client2_remote", V_IP
},
1485 { "vpn_client2_nm", V_IP
},
1486 { "vpn_client2_reneg", V_RANGE(-1,2147483647)},
1487 { "vpn_client2_hmac", V_RANGE(-1, 2) },
1488 { "vpn_client2_adns", V_RANGE(0, 3) },
1489 { "vpn_client2_rgw", V_01
},
1490 { "vpn_client2_gw", V_TEXT(0, 15) },
1491 { "vpn_client2_custom", V_NONE
},
1492 { "vpn_client2_static", V_NONE
},
1493 { "vpn_client2_ca", V_NONE
},
1494 { "vpn_client2_crt", V_NONE
},
1495 { "vpn_client2_key", V_NONE
},
1496 { "vpn_client2_userauth", V_01
},
1497 { "vpn_client2_username", V_TEXT(0,50) },
1498 { "vpn_client2_password", V_TEXT(0,50) },
1499 { "vpn_client2_useronly", V_01
},
1500 { "vpn_client2_tlsremote",V_01
},
1501 { "vpn_client2_cn", V_NONE
},
1502 { "vpn_client2_br", V_LENGTH(0, 50) },
1503 { "vpn_client2_nopull", V_01
},
1504 { "vpn_client2_route", V_01
},
1505 { "vpn_client2_routing_val", V_NONE
},
1508 #ifdef TCONFIG_PPTPD
1510 { "pptpd_enable", V_01
},
1511 { "pptpd_remoteip", V_TEXT(0,24) },
1512 { "pptpd_forcemppe", V_01
},
1513 { "pptpd_users", V_TEXT(0, 67*16) },
1514 { "pptpd_broadcast", V_TEXT(0,8) },
1515 { "pptpd_dns1", V_TEXT(0, 15) },
1516 { "pptpd_dns2", V_TEXT(0, 15) },
1517 { "pptpd_wins1", V_TEXT(0, 15) },
1518 { "pptpd_wins2", V_TEXT(0, 15) },
1519 { "pptpd_mtu", V_RANGE(576, 1500) },
1520 { "pptpd_mru", V_RANGE(576, 1500) },
1521 { "pptpd_custom", V_TEXT(0, 2048) },
1525 {"tinc_wanup", V_RANGE(0, 1) },
1526 {"tinc_name", V_LENGTH(0, 30) },
1527 {"tinc_devicetype", V_TEXT(3, 3) }, // tun, tap
1528 {"tinc_mode", V_TEXT(3, 6) }, // switch, hub
1529 {"tinc_vpn_netmask", V_IP
},
1530 {"tinc_private_rsa", V_NONE
},
1531 {"tinc_private_ed25519", V_NONE
},
1532 {"tinc_custom", V_NONE
},
1533 {"tinc_hosts", V_NONE
},
1534 {"tinc_manual_firewall", V_RANGE(0, 2) },
1535 {"tinc_manual_tinc_up", V_RANGE(0, 1) },
1537 {"tinc_tinc_up", V_NONE
},
1538 {"tinc_tinc_down", V_NONE
},
1539 {"tinc_host_up", V_NONE
},
1540 {"tinc_host_down", V_NONE
},
1541 {"tinc_subnet_up", V_NONE
},
1542 {"tinc_subnet_down", V_NONE
},
1543 {"tinc_firewall", V_NONE
},
1547 { "tor_enable", V_01
},
1548 { "tor_socksport", V_RANGE(1,65535) },
1549 { "tor_transport", V_RANGE(1,65535) },
1550 { "tor_dnsport", V_RANGE(1,65535) },
1551 { "tor_datadir", V_TEXT(0,24) },
1552 { "tor_iface", V_LENGTH(0, 50) },
1553 { "tor_users", V_LENGTH(0, 4096) },
1554 { "tor_custom", V_TEXT(0, 2048) },
1576 port_flow_control_1 0,1
1577 port_rate_limit_1 0-8
1579 port_flow_control_2 0,1
1580 port_rate_limit_2 0-8
1582 port_flow_control_3 0,1
1583 port_rate_limit_3 0-8
1585 port_flow_control_4 0,1
1586 port_rate_limit_4 0-8
1590 #ifdef TCONFIG_PPTPD
1591 { "pptp_client_enable", V_01
},
1592 { "pptp_client_peerdns", V_RANGE(0,2) },
1593 { "pptp_client_mtuenable",V_01
},
1594 { "pptp_client_mtu", V_RANGE(576, 1500) },
1595 { "pptp_client_mruenable",V_01
},
1596 { "pptp_client_mru", V_RANGE(576, 1500) },
1597 { "pptp_client_nat", V_01
},
1598 { "pptp_client_srvip", V_NONE
},
1599 { "pptp_client_srvsub", V_IP
},
1600 { "pptp_client_srvsubmsk",V_IP
},
1601 { "pptp_client_username", V_TEXT(0,50) },
1602 { "pptp_client_passwd", V_TEXT(0,50) },
1603 { "pptp_client_crypt", V_RANGE(0, 3) },
1604 { "pptp_client_custom", V_NONE
},
1605 { "pptp_client_dfltroute",V_01
},
1606 { "pptp_client_stateless",V_01
},
1613 static int webcgi_nvram_set(const nvset_t
*v
, const char *name
, int write
)
1622 struct in6_addr addr
;
1625 if ((p
= webcgi_get((char*)name
)) == NULL
) return 0;
1627 _dprintf("[%s] %s=%s\n", v
->name
, (char*)name
, p
);
1632 p
= unix_string(p
); // NOTE: p = malloc'd
1636 if ((n
< v
->va
.i
) || (n
> v
->vb
.i
)) ok
= 0;
1639 l
= strtol(p
, &e
, 10);
1640 if ((p
== e
) || (*e
) || (l
< v
->va
.l
) || (l
> v
->vb
.l
)) ok
= 0;
1643 if ((sscanf(p
, "%3u.%3u.%3u.%3u", &u
[0], &u
[1], &u
[2], &u
[3]) != 4) ||
1644 (u
[0] > 255) || (u
[1] > 255) || (u
[2] > 255) || (u
[3] > 255)) ok
= 0;
1647 if ((sscanf(p
, "%2x:%2x:%2x:%2x:%2x:%2x", &u
[0], &u
[1], &u
[2], &u
[3], &u
[4], &u
[5]) != 6) ||
1648 (u
[0] > 255) || (u
[1] > 255) || (u
[2] > 255) || (u
[3] > 255) || (u
[4] > 255) || (u
[5] > 255)) ok
= 0;
1652 if (strlen(p
) > 0 || v
->va
.i
) {
1653 if (inet_pton(AF_INET6
, p
, &addr
) != 1) ok
= 0;
1662 if (v
->vtype
== VT_TEXT
) free(p
);
1666 if (!nvram_match((char *)name
, p
)) {
1667 if (v
->vtype
!= VT_TEMP
) dirty
= 1;
1668 DEBUG_NVRAMSET(name
, p
);
1672 if (v
->vtype
== VT_TEXT
) free(p
);
1683 static int nv_wl_find(int idx
, int unit
, int subunit
, void *param
)
1685 nv_list_t
*p
= param
;
1687 int ok
= webcgi_nvram_set(p
->v
, wl_nvname(p
->v
->name
+ 3, unit
, subunit
), p
->write
);
1696 static int save_variables(int write
)
1704 static const char *msgf
= "The field \"%s\" is invalid. Please report this problem.";
1709 for (v
= nvset_list
; v
->name
; ++v
) {
1710 ok
= webcgi_nvram_set(v
, v
->name
, write
);
1712 if ((ok
>= 0) && (strncmp(v
->name
, "wl_", 3) == 0)) {
1715 if (foreach_wif(1, &nv
, nv_wl_find
) == 0)
1722 sprintf(s
, msgf
, v
->name
);
1732 if (((p1
= webcgi_get("set_password_1")) != NULL
) && (strcmp(p1
, "**********") != 0)) {
1733 if (((p2
= webcgi_get("set_password_2")) != NULL
) && (strcmp(p1
, p2
) == 0)) {
1734 if ((write
) && (!nvram_match("http_passwd", p1
))) {
1736 nvram_set("http_passwd", p1
);
1740 sprintf(s
, msgf
, "password");
1746 for (n
= 0; n
< 50; ++n
) {
1747 sprintf(s
, "rrule%d", n
);
1748 if ((p
= webcgi_get(s
)) != NULL
) {
1749 if (strlen(p
) > 8192) {
1750 sprintf(s
, msgf
, s
);
1754 if ((write
) && (!nvram_match(s
, p
))) {
1756 DEBUG_NVRAMSET(s
, p
);
1762 return (write
) ? dirty
: 1;
1765 static void wo_tomato(char *url
)
1775 // _dprintf("tomato.cgi\n");
1777 red
= webcgi_safeget("_redirect", "");
1778 if (!*red
) send_header(200, NULL
, mime_html
, 0);
1780 commit
= atoi(webcgi_safeget("_commit", "1"));
1781 force_commit
= atoi(webcgi_safeget("_force_commit", "0"));
1782 ajax
= atoi(webcgi_safeget("_ajax", "0"));
1784 nvset
= atoi(webcgi_safeget("_nvset", "1"));
1786 if (!save_variables(0)) {
1788 web_printf("@msg:%s", resmsg_get());
1791 parse_asp("error.asp");
1795 commit
= save_variables(1) && commit
;
1797 resmsg_set("Settings saved.");
1800 rboot
= atoi(webcgi_safeget("_reboot", "0"));
1802 parse_asp("reboot.asp");
1806 web_printf("@msg:%s", resmsg_get());
1808 else if (atoi(webcgi_safeget("_moveip", "0"))) {
1809 parse_asp("saved-moved.asp");
1812 parse_asp("saved.asp");
1816 if (commit
|| force_commit
) {
1817 _dprintf("commit from tomato.cgi\n");
1821 if ((v
= webcgi_get("_service")) != NULL
&& *v
!= 0) {
1823 if (ajax
) web_printf(" Some services are being restarted...");
1836 for (i
= atoi(webcgi_safeget("_sleep", "0")); i
> 0; --i
) sleep(1);
1838 if (*red
) redirect(red
);
1848 // ----------------------------------------------------------------------------
1851 static void wo_update(char *url
)
1853 const aspapi_t
*api
;
1859 if ((name
= webcgi_get("exec")) != NULL
) {
1860 for (api
= aspapi
; api
->name
; ++api
) {
1861 if (strcmp(api
->name
, name
) == 0) {
1862 for (argc
= 0; argc
< 16; ++argc
) {
1863 sprintf(s
, "arg%d", argc
);
1864 if ((argv
[argc
] = (char *)webcgi_get(s
)) == NULL
) break;
1866 api
->exec(argc
, argv
);
1873 static void wo_service(char *url
)
1877 exec_service(webcgi_safeget("_service", ""));
1879 if ((n
= atoi(webcgi_safeget("_sleep", "2"))) <= 0) n
= 2;
1885 static void wo_shutdown(char *url
)
1887 parse_asp("shutdown.asp");
1894 static void wo_nvcommit(char *url
)
1896 parse_asp("saved.asp");