dnscrypto-proxy: Support files updated.
[tomato.git] / release / src / router / httpd / tomato.c
blob63641c00f1434b510e3c079a0ce8ead8843fe9aa
1 /*
3 Tomato Firmware
4 Copyright (C) 2006-2010 Jonathan Zarate
6 */
8 #include "tomato.h"
10 #include <sys/sysinfo.h>
11 #include <sys/stat.h>
12 #include <sys/types.h>
13 #include <sys/socket.h>
14 #include <arpa/inet.h>
15 #include <time.h>
18 // #define DEBUG_NOEXECSERVICE
19 #define DEBUG_NVRAMSET(k, v) _dprintf("nvram set %s=%s\n", k, v);
22 char *post_buf = NULL;
23 int rboot = 0;
24 extern int post;
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)
43 int i;
45 _dprintf("exec_service: %s\n", action);
47 i = 10;
48 while ((!nvram_match("action_service", "")) && (i-- > 0)) {
49 _dprintf("%s: waiting before %d\n", __FUNCTION__, i);
50 sleep(1);
53 nvram_set("action_service", action);
54 kill(1, SIGUSR1);
56 i = 3;
57 while ((nvram_match("action_service", (char *)action)) && (i-- > 0)) {
58 _dprintf("%s: waiting after %d\n", __FUNCTION__, i);
59 sleep(1);
63 if (atoi(webcgi_safeget("_service_wait", ""))) {
64 i = 10;
65 while ((nvram_match("action_service", (char *)action)) && (i-- > 0)) {
66 _dprintf("%s: waiting after %d\n", __FUNCTION__, i);
67 sleep(1);
73 static void wi_generic_noid(char *url, int len, char *boundary)
75 if (post == 1) {
76 if (len >= (32 * 1024)) {
77 // syslog(LOG_WARNING, "POST max");
78 exit(1);
81 if (post_buf) free(post_buf);
82 if ((post_buf = malloc(len + 1)) == NULL) {
83 // syslog(LOG_CRIT, "Unable to allocate post buffer");
84 exit(1);
87 if (web_read_x(post_buf, len) != len) {
88 exit(1);
90 post_buf[len] = 0;
91 webcgi_init(post_buf);
95 void wi_generic(char *url, int len, char *boundary)
97 wi_generic_noid(url, len, boundary);
98 check_id(url);
101 // !!TB - CGI Support
102 void wi_cgi_bin(char *url, int len, char *boundary)
104 if (post_buf) free(post_buf);
105 post_buf = NULL;
107 if (post) {
108 if (len >= (128 * 1024)) {
109 syslog(LOG_WARNING, "POST length exceeded maximum allowed");
110 exit(1);
113 if (len > 0) {
114 if ((post_buf = malloc(len + 1)) == NULL) {
115 exit(1);
117 if (web_read_x(post_buf, len) != len) {
118 exit(1);
120 post_buf[len] = 0;
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];
130 FILE *f;
131 int fe, fq = -1;
133 if ((fe = mkstemp(webExecFile)) < 0)
134 exit(1);
135 if (query) {
136 if ((fq = mkstemp(webQueryFile)) < 0) {
137 close(fe);
138 unlink(webExecFile);
139 exit(1);
143 if ((f = fdopen(fe, "wb")) != NULL) {
144 fprintf(f,
145 "#!/bin/sh\n"
146 "export REQUEST_METHOD=\"%s\"\n"
147 "export PATH=%s\n"
148 ". /etc/profile\n"
149 "%s%s %s%s\n",
150 post ? "POST" : "GET", getenv("PATH"),
151 command ? "" : "./", command ? command : url,
152 query ? "<" : "", query ? webQueryFile : "");
153 fclose(f);
155 else {
156 close(fe);
157 unlink(webExecFile);
158 if (query) {
159 close(fq);
160 unlink(webQueryFile);
162 exit(1);
164 chmod(webExecFile, 0700);
166 if (query) {
167 if ((f = fdopen(fq, "wb")) != NULL) {
168 fprintf(f, "%s\n", query);
169 fclose(f);
171 else {
172 unlink(webExecFile);
173 close(fq);
174 unlink(webQueryFile);
175 exit(1);
179 sprintf(cmd, "%s 2>&1", webExecFile);
180 web_pipecmd(cmd, wof);
181 unlink(webQueryFile);
182 unlink(webExecFile);
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);
189 if (post_buf) {
190 free(post_buf);
191 post_buf = NULL;
195 static void wo_shell(char *url)
197 web_puts("\ncmdresult = '");
198 _execute_command(NULL, webcgi_get("command"), NULL, WOF_JAVASCRIPT);
199 web_puts("';");
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);
210 do_file(url);
212 if (nvram_match("web_favicon", "1")) {
213 send_header(200, NULL, "image/vnd.microsoft.icon", 0);
214 do_file(url);
216 else {
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);
237 #ifdef TCONFIG_IPV6
238 static void wo_ip6tables(char *url)
240 web_pipecmd("ip6tables -nvL; echo; ip6tables -t mangle -nvL", WOF_NONE);
242 #endif
245 static void wo_spin(char *url)
247 char s[64];
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);
260 web_puts("OK");
262 else {
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 },
277 #ifdef TCONFIG_IPV6
278 { "ip6t/*.txt", mime_binary, 0, wi_generic, wo_ip6tables, 1 },
279 #endif
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 },
333 // see httpd.c
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 },
337 #endif
338 #ifdef TCONFIG_PPTPD
339 { "pptpd.cgi", mime_javascript, 0, wi_generic, wo_pptpdcmd, 1 }, //!!AB - PPTPD
340 #endif
341 #ifdef TCONFIG_USB
342 { "usbcmd.cgi", mime_javascript, 0, wi_generic, wo_usbcommand, 1 }, //!!TB - USB
343 #endif
344 #ifdef BLACKHOLE
345 { "blackhole.cgi", NULL, 0, wi_blackhole, NULL, 1 },
346 #endif
347 #ifdef TCONFIG_NOCAT
348 { "uploadsplash.cgi", NULL, 0, wi_uploadsplash, wo_uploadsplash, 1 },
349 { "ext/uploadsplash.cgi", NULL, 0, wi_uploadsplash, wo_uploadsplash, 1 },
350 #endif
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 },
368 { "dns", asp_dns },
369 { "ident", asp_ident },
370 { "lanip", asp_lanip },
371 { "layer7", asp_layer7 },
372 { "link_uptime", asp_link_uptime },
373 { "link_starttime", asp_link_starttime },
374 { "lipp", asp_lipp },
375 { "netdev", asp_netdev },
376 { "iptraffic", asp_iptraffic },
377 { "iptmon", asp_iptmon },
378 { "ipt_bandwidth", asp_ipt_bandwidth },
379 { "notice", asp_notice },
380 { "nv", asp_nv },
381 { "nvram", asp_nvram },
382 { "nvramseq", asp_nvramseq },
383 { "nvstat", asp_nvstat },
384 { "psup", asp_psup },
385 { "qrate", asp_qrate },
386 { "resmsg", asp_resmsg },
387 { "rrule", asp_rrule },
388 { "statfs", asp_statfs },
389 { "sysinfo", asp_sysinfo },
390 { "jiffies", asp_jiffies },
391 { "time", asp_time },
392 { "upnpinfo", asp_upnpinfo },
393 { "version", asp_version },
394 { "wanstatus", asp_wanstatus },
395 { "wanup", asp_wanup },
396 #ifdef TCONFIG_PPTPD
397 { "pptpd_userol", asp_pptpd_userol },
398 #endif
399 { "wlstats", asp_wlstats },
400 { "wlclient", asp_wlclient },
401 { "wlnoise", asp_wlnoise },
402 { "wlscan", asp_wlscan },
403 { "wlchannels", asp_wlchannels }, //!!TB
404 { "wlcountries", asp_wlcountries },
405 { "wlifaces", asp_wlifaces },
406 { "wlbands", asp_wlbands },
407 #ifdef TCONFIG_USB
408 { "usbdevices", asp_usbdevices }, //!!TB - USB Support
409 #endif
410 { "etherstates", asp_etherstates }, //Ethernet States
411 #ifdef TCONFIG_IPV6
412 { "calc6rdlocalprefix", asp_calc6rdlocalprefix },
413 #endif
415 { "css", asp_css },
416 { NULL, NULL }
419 // -----------------------------------------------------------------------------
421 static void asp_css(int argc, char **argv)
423 const char *css = nvram_safe_get("web_css");
425 if (strcmp(css, "tomato") != 0) {
426 web_printf("<link rel='stylesheet' type='text/css' href='%s.css'>", css);
430 // -----------------------------------------------------------------------------
432 const char *resmsg_get(void)
434 return webcgi_safeget("resmsg", "");
437 void resmsg_set(const char *msg)
439 webcgi_set("resmsg", strdup(msg)); // m ok
442 int resmsg_fread(const char *fname)
444 char s[256];
445 char *p;
447 f_read_string(fname, s, sizeof(s));
448 if ((p = strchr(s, '\n')) != NULL) *p = 0;
449 if (s[0]) {
450 resmsg_set(s);
451 return 1;
453 return 0;
456 static void asp_resmsg(int argc, char **argv)
458 char *p;
460 if ((p = js_string(webcgi_safeget("resmsg", (argc > 0) ? argv[0] : ""))) == NULL) return;
461 web_printf("\nresmsg='%s';\n", p);
462 free(p);
465 // ----------------------------------------------------------------------------
467 // verification... simple sanity checks. UI should verify all fields.
469 // todo: move and re-use for filtering - zzz
471 typedef union {
472 int i;
473 long l;
474 const char *s;
475 } nvset_varg_t;
477 typedef struct {
478 const char *name;
479 enum {
480 VT_NONE, // no checking
481 VT_LENGTH, // check length of string
482 VT_TEXT, // strip \r, check length of string
483 VT_RANGE, // expect an integer, check range
484 VT_IP, // expect an ip address
485 VT_MAC, // expect a mac address
486 #ifdef TCONFIG_IPV6
487 VT_IPV6, // expect an ipv6 address
488 #endif
489 VT_TEMP // no checks, no commit
490 } vtype;
491 nvset_varg_t va;
492 nvset_varg_t vb;
493 } nvset_t;
496 #define V_NONE VT_NONE, { }, { }
497 #define V_01 VT_RANGE, { .l = 0 }, { .l = 1 }
498 #define V_PORT VT_RANGE, { .l = 2 }, { .l = 65535 }
499 #define V_ONOFF VT_LENGTH, { .i = 2 }, { .i = 3 }
500 #define V_WORD VT_LENGTH, { .i = 1 }, { .i = 16 }
501 #define V_LENGTH(min, max) VT_LENGTH, { .i = min }, { .i = max }
502 #define V_TEXT(min, max) VT_TEXT, { .i = min }, { .i = max }
503 #define V_RANGE(min, max) VT_RANGE, { .l = min }, { .l = max }
504 #define V_IP VT_IP, { }, { }
505 #define V_OCTET VT_RANGE, { .l = 0 }, { .l = 255 }
506 #define V_NUM VT_RANGE, { .l = 0 }, { .l = 0x7FFFFFFF }
507 #define V_TEMP VT_TEMP, { }, { }
508 #ifdef TCONFIG_IPV6
509 #define V_IPV6(required) VT_IPV6, { .i = required }, { }
510 #endif
512 static const nvset_t nvset_list[] = {
514 // basic-ident
515 { "router_name", V_LENGTH(0, 32) },
516 { "wan_hostname", V_LENGTH(0, 32) },
517 { "wan_domain", V_LENGTH(0, 32) },
519 // basic-time
520 { "tm_tz", V_LENGTH(1, 64) }, // PST8PDT
521 { "tm_sel", V_LENGTH(1, 64) }, // PST8PDT
522 { "tm_dst", V_01 },
523 { "ntp_updates", V_RANGE(-1, 24) },
524 { "ntp_tdod", V_01 },
525 { "ntp_server", V_LENGTH(1, 150) }, // x y z
526 { "ntp_kiss", V_LENGTH(0, 255) },
527 { "ntpd_enable", V_01 }, //!!Victek. Enable BusyBox NTPD Server.
528 { "ntpd_server", V_LENGTH(0, 128) }, //!!Victek. NTPD Servers.
531 // basic-static
532 { "dhcpd_static", V_LENGTH(0, 108*251) }, // 108 (max chars per entry) x 128 entries
533 { "dhcpd_static_only", V_01 },
534 { "arpbind_static", V_LENGTH(0, 34*128) }, // 34 (max chars per entry) x 128 entries
535 { "arpbind_listed", V_01 }, // AB - Enable static ARP for all devices on list
537 // basic-ddns
538 { "ddnsx0", V_LENGTH(0, 2048) },
539 { "ddnsx1", V_LENGTH(0, 2048) },
540 { "ddnsx0_cache", V_LENGTH(0, 1) }, // only to clear
541 { "ddnsx1_cache", V_LENGTH(0, 1) },
542 { "ddnsx_ip", V_LENGTH(0, 32) },
543 { "ddnsx_save", V_01 },
544 { "ddnsx_refresh", V_RANGE(0, 365) },
546 // basic-network
547 // WAN
548 { "wan_proto", V_LENGTH(1, 16) }, // disabled, dhcp, static, pppoe, pptp, l2tp
549 { "wan_ipaddr", V_IP },
550 { "wan_netmask", V_IP },
551 { "wan_gateway", V_IP },
552 { "hb_server_ip", V_LENGTH(0, 32) },
553 { "l2tp_server_ip", V_LENGTH(0, 128) },
554 { "pptp_server_ip", V_LENGTH(0, 128) },
555 { "pptp_dhcp", V_01 },
556 { "ppp_username", V_LENGTH(0, 60) },
557 { "ppp_passwd", V_LENGTH(0, 60) },
558 { "ppp_service", V_LENGTH(0, 50) },
559 { "ppp_demand", V_01 },
560 { "ppp_custom", V_LENGTH(0, 256) },
561 { "ppp_idletime", V_RANGE(0, 1440) },
562 { "ppp_redialperiod", V_RANGE(1, 86400) },
563 { "ppp_mlppp", V_01 },
564 { "mtu_enable", V_01 },
565 { "wan_mtu", V_RANGE(576, 1500) },
566 { "wan_islan", V_01 },
567 { "modem_ipaddr", V_IP },
568 { "pppoe_lei", V_RANGE(0, 60) },
569 { "pppoe_lef", V_RANGE(0, 10) },
571 #ifdef TCONFIG_DNSCRYPT
572 { "dnscrypt_proxy", V_01 },
573 { "dnscrypt_port", V_PORT },
574 { "dnscrypt_cmd", V_LENGTH(0, 256) },
575 #endif
577 // LAN
578 { "lan_ipaddr", V_IP },
579 { "lan_netmask", V_IP },
580 { "lan_gateway", V_IP },
581 { "wan_dns", V_LENGTH(0, 50) }, // ip ip ip
582 { "lan_proto", V_WORD }, // static, dhcp
583 { "dhcp_start", V_LENGTH(0, 15) }, // remove !
584 { "dhcp_num", V_LENGTH(0, 4) }, // remove !
585 { "dhcpd_startip", V_LENGTH(0, 15) },
586 { "dhcpd_endip", V_LENGTH(0, 15) },
587 { "dhcp_lease", V_LENGTH(0, 5) },
588 { "wan_wins", V_IP },
590 { "lan_state", V_RANGE(0, 7) }, // 0=enable, 1=Descriptor, 2=Invert for Ethernet ports status
592 // 3G MODEM
593 { "modem_pin", V_LENGTH(0,6) },
594 { "modem_dev", V_LENGTH(0,8) },
595 { "modem_init", V_LENGTH(0,25) },
596 { "modem_apn", V_LENGTH(0,25) },
598 #ifdef TCONFIG_VLAN
599 // LAN networks
600 { "lan_ifname", V_LENGTH(0, 5) },
601 { "lan1_ifname", V_LENGTH(0, 5) },
602 { "lan1_ifnames", V_TEXT(0,64) },
603 { "lan1_ipaddr", V_LENGTH(0, 15) },
604 { "lan1_netmask", V_LENGTH(0, 15) },
605 { "lan1_proto", V_LENGTH(0, 6) },
606 { "lan1_stp", V_LENGTH(0, 1) },
607 { "dhcp1_start", V_LENGTH(0, 15) },
608 { "dhcp1_num", V_LENGTH(0, 4) },
609 { "dhcpd1_startip", V_LENGTH(0, 15) },
610 { "dhcpd1_endip", V_LENGTH(0, 15) },
611 { "dhcp1_lease", V_LENGTH(0, 5) },
613 { "lan2_ifname", V_LENGTH(0, 5) },
614 { "lan2_ifnames", V_TEXT(0,64) },
615 { "lan2_ipaddr", V_LENGTH(0, 15) },
616 { "lan2_netmask", V_LENGTH(0, 15) },
617 { "lan2_proto", V_LENGTH(0, 6) },
618 { "lan2_stp", V_LENGTH(0, 1) },
619 { "dhcp2_start", V_LENGTH(0, 15) },
620 { "dhcp2_num", V_LENGTH(0, 4) },
621 { "dhcpd2_startip", V_LENGTH(0, 15) },
622 { "dhcpd2_endip", V_LENGTH(0, 15) },
623 { "dhcp2_lease", V_LENGTH(0, 5) },
625 { "lan3_ifname", V_LENGTH(0, 5) },
626 { "lan3_ifnames", V_TEXT(0,64) },
627 { "lan3_ipaddr", V_LENGTH(0, 15) },
628 { "lan3_netmask", V_LENGTH(0, 15) },
629 { "lan3_proto", V_LENGTH(0, 6) },
630 { "lan3_stp", V_LENGTH(0, 1) },
631 { "dhcp3_start", V_LENGTH(0, 15) },
632 { "dhcp3_num", V_LENGTH(0, 4) },
633 { "dhcpd3_startip", V_LENGTH(0, 15) },
634 { "dhcpd3_endip", V_LENGTH(0, 15) },
635 { "dhcp3_lease", V_LENGTH(0, 5) },
636 #endif
638 // wireless
639 { "wl_radio", V_01 },
640 { "wl_mode", V_LENGTH(2, 3) }, // ap, sta, wet, wds
641 { "wl_net_mode", V_LENGTH(5, 8) }, // disabled, mixed, b-only, g-only, bg-mixed, n-only [speedbooster]
642 { "wl_ssid", V_LENGTH(1, 32) },
643 { "wl_closed", V_01 },
644 { "wl_channel", V_RANGE(0, 216) },
646 #ifdef TCONFIG_VLAN
647 { "wl_vifs", V_LENGTH(0, 64) }, // multiple/virtual BSSIDs
648 #ifndef LINUX26
649 { "nas_alternate", V_01 }, // only meaningful for ND/K24 builds
650 #endif
651 #endif
653 { "wl_security_mode", V_LENGTH(1, 32) }, // disabled, radius, wep, wpa_personal, wpa_enterprise, wpa2_personal, wpa2_enterprise
654 { "wl_radius_ipaddr", V_IP },
655 { "wl_radius_port", V_PORT },
656 { "wl_radius_key", V_LENGTH(1, 64) },
657 { "wl_wep_bit", V_RANGE(64, 128) }, // 64 or 128
658 { "wl_passphrase", V_LENGTH(0, 20) },
659 { "wl_key", V_RANGE(1, 4) },
660 { "wl_key1", V_LENGTH(0, 26) },
661 { "wl_key2", V_LENGTH(0, 26) },
662 { "wl_key3", V_LENGTH(0, 26) },
663 { "wl_key4", V_LENGTH(0, 26) },
664 { "wl_crypto", V_LENGTH(3, 8) }, // tkip, aes, tkip+aes
665 { "wl_wpa_psk", V_LENGTH(8, 64) },
666 { "wl_wpa_gtk_rekey", V_RANGE(60, 7200) },
668 { "wl_lazywds", V_01 },
669 { "wl_wds", V_LENGTH(0, 180) }, // mac mac mac (x 10)
671 { "wl_wds_enable", V_01 },
672 { "wl_gmode", V_RANGE(-1, 6) },
673 { "wl_wep", V_LENGTH(1, 32) }, // off, on, restricted,tkip,aes,tkip+aes
674 { "wl_akm", V_LENGTH(0, 32) }, // wpa, wpa2, psk, psk2, wpa wpa2, psk psk2, ""
675 { "wl_auth_mode", V_LENGTH(4, 6) }, // none, radius
677 { "wl_nmode", V_NONE },
678 { "wl_nband", V_RANGE(0, 2) }, // 2 - 2.4GHz, 1 - 5GHz, 0 - Auto
679 { "wl_nreqd", V_NONE },
680 { "wl_nbw_cap", V_RANGE(0, 2) }, // 0 - 20MHz, 1 - 40MHz, 2 - Auto
681 { "wl_nbw", V_NONE },
682 { "wl_mimo_preamble", V_WORD }, // 802.11n Preamble: mm/gf/auto/gfbcm
683 { "wl_nctrlsb", V_NONE }, // none, lower, upper
685 #ifdef TCONFIG_IPV6
686 // basic-ipv6
687 { "ipv6_service", V_LENGTH(0, 16) }, // '', native, native-pd, 6to4, sit, other
688 { "ipv6_prefix", V_IPV6(0) },
689 { "ipv6_prefix_length", V_RANGE(3, 127) },
690 { "ipv6_rtr_addr", V_IPV6(0) },
691 { "ipv6_radvd", V_01 },
692 { "ipv6_accept_ra", V_NUM },
693 { "ipv6_tun_addr", V_IPV6(1) },
694 { "ipv6_tun_addrlen", V_RANGE(3, 127) },
695 { "ipv6_ifname", V_LENGTH(0, 8) },
696 { "ipv6_tun_v4end", V_IP },
697 { "ipv6_relay", V_RANGE(1, 254) },
698 { "ipv6_tun_mtu", V_NUM }, // Tunnel MTU
699 { "ipv6_tun_ttl", V_NUM }, // Tunnel TTL
700 { "ipv6_dns", V_LENGTH(0, 40*3) }, // ip6 ip6 ip6
701 { "ipv6_6rd_prefix", V_IPV6(0) }, // 6rd prefix
702 { "ipv6_6rd_prefix_length", V_RANGE(3, 127) }, // 6rd prefix length
703 { "ipv6_6rd_borderrelay", V_IP }, // 6rd ipv4 border relay addr
704 { "ipv6_6rd_ipv4masklen", V_RANGE(0, 255) }, // 6rd ipv4 mask
705 #endif
707 // basic-wfilter
708 { "wl_macmode", V_NONE }, // allow, deny, disabled
709 { "wl_maclist", V_LENGTH(0, 18*251) }, // 18 x 250 (11:22:33:44:55:66 ...)
710 { "macnames", V_LENGTH(0, 62*251) }, // 62 (12+1+48+1) x 50 (112233445566<..>) todo: re-use -- zzz
712 // advanced-ctnf
713 { "ct_max", V_NUM },
714 { "ct_tcp_timeout", V_LENGTH(20, 70) },
715 { "ct_udp_timeout", V_LENGTH(5, 15) },
716 { "ct_timeout", V_LENGTH(5, 15) },
717 { "nf_ttl", V_LENGTH(1, 6) },
718 { "nf_l7in", V_01 },
719 #ifdef LINUX26
720 { "nf_sip", V_01 },
721 { "ct_hashsize", V_NUM },
722 #endif
723 { "nf_rtsp", V_01 },
724 { "nf_pptp", V_01 },
725 { "nf_h323", V_01 },
726 { "nf_ftp", V_01 },
728 // advanced-dhcpdns
729 { "dhcpd_slt", V_RANGE(-1, 43200) }, // -1=infinite, 0=follow normal lease time, >=1 custom
730 { "dhcpd_dmdns", V_01 },
731 { "dhcpd_lmax", V_NUM },
732 { "dhcpd_gwmode", V_NUM },
733 { "dns_addget", V_01 },
734 { "dns_intcpt", V_01 },
735 { "dhcpc_minpkt", V_01 },
736 { "dhcpc_custom", V_LENGTH(0, 80) },
737 { "dns_norebind", V_01 },
738 { "dnsmasq_custom", V_TEXT(0, 2048) },
739 { "dnsmasq_q", V_RANGE(0, 7) }, // 0= quiet-dhcp, 1=dhcp6 2=ra
740 { "dhcpd_static_only", V_01 },
742 // advanced-firewall
743 { "block_wan", V_01 },
744 { "block_wan_limit", V_01 },
745 { "block_wan_limit_icmp", V_RANGE(1, 300) },
746 { "block_wan_limit_tr", V_RANGE(1, 300) },
747 { "multicast_pass", V_01 },
748 #ifdef TCONFIG_VLAN
749 { "multicast_lan", V_01 },
750 { "multicast_lan1", V_01 },
751 { "multicast_lan2", V_01 },
752 { "multicast_lan3", V_01 },
753 #endif
754 { "udpxy_enable", V_01 },
755 { "udpxy_stats", V_01 },
756 { "udpxy_clients", V_RANGE(1, 5000) },
757 { "udpxy_port", V_RANGE(0, 65535) },
758 { "block_loopback", V_01 },
759 { "nf_loopback", V_NUM },
760 { "ne_syncookies", V_01 },
761 { "ne_snat", V_01 },
762 { "dhcp_pass", V_01 },
763 #ifdef TCONFIG_EMF
764 { "emf_entry", V_NONE },
765 { "emf_uffp_entry", V_NONE },
766 { "emf_rtport_entry", V_NONE },
767 { "emf_enable", V_01 },
768 #endif
770 // advanced-misc
771 { "wait_time", V_RANGE(3, 20) },
772 { "wan_speed", V_RANGE(0, 4) },
773 { "clkfreq", V_NONE }, // Victek
774 { "jumbo_frame_enable", V_01 }, // Jumbo Frames support (for RT-N16/WNR3500L)
775 { "jumbo_frame_size", V_RANGE(1, 9720) },
776 #ifdef CONFIG_BCMWL5
777 { "ctf_disable", V_01 },
778 #endif
780 #ifdef TCONFIG_VLAN
781 // advanced-vlan
782 { "vlan0ports", V_TEXT(0,16) },
783 { "vlan1ports", V_TEXT(0,16) },
784 { "vlan2ports", V_TEXT(0,16) },
785 { "vlan3ports", V_TEXT(0,16) },
786 { "vlan4ports", V_TEXT(0,16) },
787 { "vlan5ports", V_TEXT(0,16) },
788 { "vlan6ports", V_TEXT(0,16) },
789 { "vlan7ports", V_TEXT(0,16) },
790 { "vlan8ports", V_TEXT(0,16) },
791 { "vlan9ports", V_TEXT(0,16) },
792 { "vlan10ports", V_TEXT(0,16) },
793 { "vlan11ports", V_TEXT(0,16) },
794 { "vlan12ports", V_TEXT(0,16) },
795 { "vlan13ports", V_TEXT(0,16) },
796 { "vlan14ports", V_TEXT(0,16) },
797 { "vlan15ports", V_TEXT(0,16) },
798 { "vlan0hwname", V_TEXT(0,8) },
799 { "vlan1hwname", V_TEXT(0,8) },
800 { "vlan2hwname", V_TEXT(0,8) },
801 { "vlan3hwname", V_TEXT(0,8) },
802 { "vlan4hwname", V_TEXT(0,8) },
803 { "vlan5hwname", V_TEXT(0,8) },
804 { "vlan6hwname", V_TEXT(0,8) },
805 { "vlan7hwname", V_TEXT(0,8) },
806 { "vlan8hwname", V_TEXT(0,8) },
807 { "vlan9hwname", V_TEXT(0,8) },
808 { "vlan10hwname", V_TEXT(0,8) },
809 { "vlan11hwname", V_TEXT(0,8) },
810 { "vlan12hwname", V_TEXT(0,8) },
811 { "vlan13hwname", V_TEXT(0,8) },
812 { "vlan14hwname", V_TEXT(0,8) },
813 { "vlan15hwname", V_TEXT(0,8) },
814 { "wan_ifnameX", V_TEXT(0,8) },
815 { "lan_ifnames", V_TEXT(0,64) },
816 { "manual_boot_nv", V_01 },
817 { "trunk_vlan_so", V_01 },
818 { "vlan0tag", V_TEXT(0,5) },
819 { "vlan0vid", V_TEXT(0,5) },
820 { "vlan1vid", V_TEXT(0,5) },
821 { "vlan2vid", V_TEXT(0,5) },
822 { "vlan3vid", V_TEXT(0,5) },
823 { "vlan4vid", V_TEXT(0,5) },
824 { "vlan5vid", V_TEXT(0,5) },
825 { "vlan6vid", V_TEXT(0,5) },
826 { "vlan7vid", V_TEXT(0,5) },
827 { "vlan8vid", V_TEXT(0,5) },
828 { "vlan9vid", V_TEXT(0,5) },
829 { "vlan10vid", V_TEXT(0,5) },
830 { "vlan11vid", V_TEXT(0,5) },
831 { "vlan12vid", V_TEXT(0,5) },
832 { "vlan13vid", V_TEXT(0,5) },
833 { "vlan14vid", V_TEXT(0,5) },
834 { "vlan15vid", V_TEXT(0,5) },
835 #endif
837 // advanced-mac
838 { "mac_wan", V_LENGTH(0, 17) },
839 { "wl_macaddr", V_LENGTH(0, 17) },
840 { "wl_hwaddr", V_LENGTH(0, 17) },
842 // advanced-routing
843 { "routes_static", V_LENGTH(0, 2048) },
844 { "dhcp_routes", V_01 },
845 { "lan_stp", V_RANGE(0, 1) },
846 { "wk_mode", V_LENGTH(1, 32) }, // gateway, router
847 #ifdef TCONFIG_ZEBRA
848 { "dr_setting", V_RANGE(0, 3) },
849 { "dr_lan_tx", V_LENGTH(0, 32) },
850 { "dr_lan_rx", V_LENGTH(0, 32) },
851 #ifdef TCONFIG_VLAN
852 { "dr_lan1_tx", V_LENGTH(0, 32) },
853 { "dr_lan1_rx", V_LENGTH(0, 32) },
854 { "dr_lan2_tx", V_LENGTH(0, 32) },
855 { "dr_lan2_rx", V_LENGTH(0, 32) },
856 { "dr_lan3_tx", V_LENGTH(0, 32) },
857 { "dr_lan3_rx", V_LENGTH(0, 32) },
858 #endif
859 { "dr_wan_tx", V_LENGTH(0, 32) },
860 { "dr_wan_rx", V_LENGTH(0, 32) },
861 #endif
863 #ifdef TCONFIG_VLAN
864 // advanced-access
865 { "lan_access", V_LENGTH(0, 4096) },
866 #endif
868 // advanced-wireless
869 { "wl_country", V_LENGTH(0, 64) }, // !!TB - Country code
870 { "wl_country_code", V_LENGTH(0, 4) }, // !!TB - Country code
871 { "wl_btc_mode", V_RANGE(0, 2) }, // !!TB - BT Coexistence Mode: 0 (disable), 1 (enable), 2 (preemption)
872 { "wl_afterburner", V_LENGTH(2, 4) }, // off, on, auto
873 { "wl_auth", V_01 },
874 { "wl_rateset", V_LENGTH(2, 7) }, // all, default, 12
875 { "wl_rate", V_RANGE(0, 54 * 1000 * 1000) },
876 { "wl_mrate", V_RANGE(0, 54 * 1000 * 1000) },
877 { "wl_gmode_protection",V_LENGTH(3, 4) }, // off, auto
878 { "wl_frameburst", V_ONOFF }, // off, on
879 { "wl_bcn", V_RANGE(1, 65535) },
880 { "wl_dtim", V_RANGE(1, 255) },
881 { "wl_frag", V_RANGE(256, 2346) },
882 { "wl_rts", V_RANGE(0, 2347) },
883 { "wl_ap_isolate", V_01 },
884 { "wl_plcphdr", V_LENGTH(4, 5) }, // long, short
885 { "wl_antdiv", V_RANGE(0, 3) },
886 { "wl_txant", V_RANGE(0, 3) },
887 { "wl_txpwr", V_RANGE(0, 400) },
888 { "wl_wme", V_WORD }, // auto, off, on
889 { "wl_wme_no_ack", V_ONOFF }, // off, on
890 { "wl_wme_apsd", V_ONOFF }, // off, on
891 { "wl_maxassoc", V_RANGE(0, 255) },
892 { "wl_distance", V_LENGTH(0, 5) }, // "", 1-99999
893 { "wlx_hpamp", V_01 },
894 { "wlx_hperx", V_01 },
895 { "wl_reg_mode", V_LENGTH(1, 3) }, // !!TB - Regulatory: off, h, d
896 { "wl_mitigation", V_RANGE(0, 4) }, // Interference Mitigation Mode (0|1|2|3|4)
897 { "wl_nmode_protection", V_WORD }, // off, auto
898 { "wl_nmcsidx", V_RANGE(-2, 32), }, // -2 - 32
899 { "wl_obss_coex", V_01 },
900 { "wl_wmf_bss_enable", V_01 }, // Toastman
902 // forward-dmz
903 { "dmz_enable", V_01 },
904 { "dmz_ipaddr", V_LENGTH(0, 15) },
905 { "dmz_sip", V_LENGTH(0, 512) },
906 #ifdef TCONFIG_VLAN
907 { "dmz_ifname", V_LENGTH(0, 5) },
908 #endif
909 { "dmz_ra", V_01 },
910 // forward-upnp
911 { "upnp_enable", V_NUM },
912 { "upnp_secure", V_01 },
913 { "upnp_port", V_RANGE(0, 65535) },
914 { "upnp_ssdp_interval", V_RANGE(10, 9999) },
915 { "upnp_mnp", V_01 },
916 { "upnp_clean", V_01 },
917 { "upnp_clean_interval", V_RANGE(60, 65535) },
918 { "upnp_clean_threshold", V_RANGE(0, 9999) },
919 { "upnp_min_port_int", V_PORT },
920 { "upnp_max_port_int", V_PORT },
921 { "upnp_min_port_ext", V_PORT },
922 { "upnp_max_port_ext", V_PORT },
923 #ifdef TCONFIG_VLAN
924 { "upnp_lan", V_01 },
925 { "upnp_lan1", V_01 },
926 { "upnp_lan2", V_01 },
927 { "upnp_lan3", V_01 },
928 #endif
929 { "upnp_custom", V_TEXT(0, 2048) },
931 // forward-basic
932 { "portforward", V_LENGTH(0, 4096) },
934 #ifdef TCONFIG_IPV6
935 // forward-basic-ipv6
936 { "ipv6_portforward", V_LENGTH(0, 4096) },
937 #endif
939 // forward-triggered
940 { "trigforward", V_LENGTH(0, 4096) },
943 // access restriction
944 { "rruleN", V_RANGE(0, 99) },
945 // { "rrule##", V_LENGTH(0, 16384) }, // in save_variables()
947 // admin-access
948 { "http_enable", V_01 },
949 { "https_enable", V_01 },
950 { "https_crt_save", V_01 },
951 { "https_crt_cn", V_LENGTH(0, 64) },
952 { "https_crt_gen", V_TEMP },
953 { "remote_management", V_01 },
954 { "remote_mgt_https", V_01 },
955 { "remote_mgt_nodefault", V_01 },
956 { "http_lanport", V_PORT },
957 { "https_lanport", V_PORT },
958 { "web_wl_filter", V_01 },
959 { "web_css", V_LENGTH(1, 32) },
960 { "web_mx", V_LENGTH(0, 128) },
961 { "http_wanport", V_PORT },
962 { "telnetd_eas", V_01 },
963 { "telnetd_port", V_PORT },
964 { "sshd_eas", V_01 },
965 { "sshd_pass", V_01 },
966 { "sshd_port", V_PORT },
967 { "sshd_remote", V_01 },
968 { "sshd_forwarding", V_01 },
969 { "sshd_rport", V_PORT },
970 { "sshd_authkeys", V_TEXT(0, 4096) },
971 { "rmgt_sip", V_LENGTH(0, 512) },
972 { "ne_shlimit", V_TEXT(1, 50) },
974 // admin-bwm
975 { "rstats_enable", V_01 },
976 { "rstats_path", V_LENGTH(0, 48) },
977 { "rstats_stime", V_RANGE(1, 168) },
978 { "rstats_offset", V_RANGE(1, 31) },
979 { "rstats_exclude", V_LENGTH(0, 64) },
980 { "rstats_sshut", V_01 },
981 { "rstats_bak", V_01 },
983 // admin-ipt
984 { "cstats_enable", V_01 },
985 { "cstats_path", V_LENGTH(0, 48) },
986 { "cstats_stime", V_RANGE(1, 168) },
987 { "cstats_offset", V_RANGE(1, 31) },
988 { "cstats_labels", V_RANGE(0, 2) },
989 { "cstats_exclude", V_LENGTH(0, 512) },
990 { "cstats_include", V_LENGTH(0, 2048) },
991 { "cstats_all", V_01 },
992 { "cstats_sshut", V_01 },
993 { "cstats_bak", V_01 },
995 // admin-buttons
996 { "sesx_led", V_RANGE(0, 255) }, // amber, white, aoss
997 { "sesx_b0", V_RANGE(0, 5) }, // 0-5: toggle wireless, reboot, shutdown, script, usb unmount
998 { "sesx_b1", V_RANGE(0, 5) }, // "
999 { "sesx_b2", V_RANGE(0, 5) }, // "
1000 { "sesx_b3", V_RANGE(0, 5) }, // "
1001 { "sesx_script", V_TEXT(0, 1024) }, //
1002 { "script_brau", V_TEXT(0, 1024) }, //
1004 // admin-debug
1005 { "debug_nocommit", V_01 },
1006 { "debug_cprintf", V_01 },
1007 { "debug_cprintf_file", V_01 },
1008 // { "debug_keepfiles", V_01 },
1009 { "debug_ddns", V_01 },
1010 { "debug_norestart", V_TEXT(0, 128) },
1011 { "console_loglevel", V_RANGE(1, 8) },
1012 { "t_cafree", V_01 },
1013 { "t_hidelr", V_01 },
1015 // admin-sched
1016 { "sch_rboot", V_TEXT(0, 64) },
1017 { "sch_rcon", V_TEXT(0, 64) },
1018 { "sch_c1", V_TEXT(0, 64) },
1019 { "sch_c1_cmd", V_TEXT(0, 2048) },
1020 { "sch_c2", V_TEXT(0, 64) },
1021 { "sch_c2_cmd", V_TEXT(0, 2048) },
1022 { "sch_c3", V_TEXT(0, 64) },
1023 { "sch_c3_cmd", V_TEXT(0, 2048) },
1025 // admin-scripts
1026 { "script_init", V_TEXT(0, 4096) },
1027 { "script_shut", V_TEXT(0, 4096) },
1028 { "script_fire", V_TEXT(0, 8192) },
1029 { "script_wanup", V_TEXT(0, 4096) },
1031 // admin-log
1032 { "log_remote", V_01 },
1033 { "log_remoteip", V_LENGTH(0, 512) },
1034 { "log_remoteport", V_PORT },
1035 { "log_file", V_01 },
1036 { "log_file_custom", V_01 },
1037 { "log_file_path", V_TEXT(0, 4096) },
1038 { "log_file_size", V_RANGE(0, 99999) },
1039 { "log_file_keep", V_RANGE(0, 99) },
1040 { "log_limit", V_RANGE(0, 2400) },
1041 { "log_in", V_RANGE(0, 3) },
1042 { "log_out", V_RANGE(0, 3) },
1043 { "log_mark", V_RANGE(0, 99999) },
1044 { "log_events", V_TEXT(0, 32) }, // "acre,crond,ntp"
1046 // admin-log-webmonitor
1047 { "log_wm", V_01 },
1048 { "log_wmtype", V_RANGE(0, 2) },
1049 { "log_wmip", V_LENGTH(0, 512) },
1050 { "log_wmdmax", V_RANGE(0, 9999) },
1051 { "log_wmsmax", V_RANGE(0, 9999) },
1053 // admin-cifs
1054 { "cifs1", V_LENGTH(1, 1024) },
1055 { "cifs2", V_LENGTH(1, 1024) },
1057 // admin-jffs2
1058 { "jffs2_on", V_01 },
1059 { "jffs2_exec", V_LENGTH(0, 64) },
1060 { "jffs2_format", V_01 },
1062 // nas-usb - !!TB
1063 #ifdef TCONFIG_USB
1064 { "usb_enable", V_01 },
1065 { "usb_uhci", V_RANGE(-1, 1) }, // -1 - disabled, 0 - off, 1 - on
1066 { "usb_ohci", V_RANGE(-1, 1) },
1067 { "usb_usb2", V_RANGE(-1, 1) },
1069 #if defined(LINUX26) && defined(TCONFIG_USB_EXTRAS)
1070 { "usb_mmc", V_RANGE(-1, 1) },
1071 #endif
1072 { "usb_irq_thresh", V_RANGE(0, 6) },
1073 { "usb_storage", V_01 },
1074 { "usb_printer", V_01 },
1075 { "usb_printer_bidirect", V_01 },
1076 { "usb_fs_ext3", V_01 },
1077 { "usb_fs_fat", V_01 },
1078 #ifdef TCONFIG_NTFS
1079 { "usb_fs_ntfs", V_01 },
1080 #endif
1081 { "usb_fs_hfs", V_01 }, //!Victek
1082 { "usb_fs_hfsplus", V_01 }, //!Victek
1083 { "usb_automount", V_01 },
1084 { "script_usbhotplug", V_TEXT(0, 2048) },
1085 { "script_usbmount", V_TEXT(0, 2048) },
1086 { "script_usbumount", V_TEXT(0, 2048) },
1087 { "idle_enable", V_01 },
1088 { "usb_3g", V_01 },
1089 #endif
1091 // nas-ftp - !!TB
1092 #ifdef TCONFIG_FTP
1093 { "ftp_enable", V_RANGE(0, 2) },
1094 { "ftp_super", V_01 },
1095 { "ftp_anonymous", V_RANGE(0, 3) },
1096 { "ftp_dirlist", V_RANGE(0, 2) },
1097 { "ftp_port", V_PORT },
1098 { "ftp_max", V_RANGE(0, 12) },
1099 { "ftp_ipmax", V_RANGE(0, 12) },
1100 { "ftp_staytimeout", V_RANGE(0, 65535) },
1101 { "ftp_rate", V_RANGE(0, 99999) },
1102 { "ftp_anonrate", V_RANGE(0, 99999) },
1103 { "ftp_anonroot", V_LENGTH(0, 256) },
1104 { "ftp_pubroot", V_LENGTH(0, 256) },
1105 { "ftp_pvtroot", V_LENGTH(0, 256) },
1106 { "ftp_users", V_LENGTH(0, 4096) },
1107 { "ftp_custom", V_TEXT(0, 2048) },
1108 { "ftp_sip", V_LENGTH(0, 512) },
1109 { "ftp_limit", V_TEXT(1, 50) },
1110 { "log_ftp", V_01 },
1111 #endif
1113 #ifdef TCONFIG_SNMP
1114 { "snmp_enable", V_RANGE(0, 1) },
1115 { "snmp_port", V_RANGE(1, 65535) },
1116 { "snmp_remote", V_RANGE(0, 1) },
1117 { "snmp_remote_sip", V_LENGTH(0, 512) },
1118 { "snmp_location", V_LENGTH(0, 20) },
1119 { "snmp_contact", V_LENGTH(0, 20) },
1120 { "snmp_ro", V_LENGTH(0, 20) },
1121 #endif
1123 #ifdef TCONFIG_SAMBASRV
1124 // nas-samba - !!TB
1125 { "smbd_enable", V_RANGE(0, 2) },
1126 { "smbd_wgroup", V_LENGTH(0, 20) },
1127 { "smbd_master", V_01 },
1128 { "smbd_wins", V_01 },
1129 { "smbd_cpage", V_LENGTH(0, 4) },
1130 { "smbd_cset", V_LENGTH(0, 20) },
1131 { "smbd_custom", V_TEXT(0, 2048) },
1132 { "smbd_autoshare", V_RANGE(0, 3) },
1133 { "smbd_shares", V_LENGTH(0, 4096) },
1134 { "smbd_user", V_LENGTH(0, 50) },
1135 { "smbd_passwd", V_LENGTH(0, 50) },
1136 #endif
1138 #ifdef TCONFIG_MEDIA_SERVER
1139 // nas-media
1140 { "ms_enable", V_01 },
1141 { "ms_dirs", V_LENGTH(0, 1024) },
1142 { "ms_port", V_RANGE(1, 65535) },
1143 { "ms_dbdir", V_LENGTH(0, 256) },
1144 { "ms_tivo", V_01 },
1145 { "ms_stdlna", V_01 },
1146 { "ms_rescan", V_01 },
1147 { "ms_sas", V_01 },
1148 #endif
1150 // qos
1151 { "qos_enable", V_01 },
1152 { "qos_pfifo", V_01 },
1153 { "qos_ack", V_01 },
1154 { "qos_syn", V_01 },
1155 { "qos_fin", V_01 },
1156 { "qos_rst", V_01 },
1157 { "qos_icmp", V_01 },
1158 { "qos_udp", V_01 },
1159 { "qos_reset", V_01 },
1160 { "qos_pfifo", V_01 }, // !!TB
1161 { "qos_obw", V_RANGE(10, 999999) },
1162 { "qos_ibw", V_RANGE(10, 999999) },
1163 { "qos_orules", V_LENGTH(0, 8192) },
1164 { "qos_default", V_RANGE(0, 9) },
1165 { "qos_irates", V_LENGTH(0, 128) },
1166 { "qos_orates", V_LENGTH(0, 128) },
1167 { "qos_classnames", V_LENGTH(10, 128) }, // !!TOASTMAN
1168 { "atm_overhead", V_RANGE(-127, 128) },
1169 { "ne_vegas", V_01 },
1170 { "ne_valpha", V_NUM },
1171 { "ne_vbeta", V_NUM },
1172 { "ne_vgamma", V_NUM },
1174 // qos-bw-limiter
1175 { "qosl_enable", V_01 },
1176 { "qosl_rules", V_LENGTH(0, 4096) },
1177 /*qosl_ibw unused - qos_ibw shared*/
1178 /*qosl_obw unused - qos_obw shared*/
1180 //NoCatSplash. Victek.
1181 #ifdef TCONFIG_NOCAT
1182 { "NC_enable", V_01 },
1183 { "NC_Verbosity", V_RANGE(0, 10) },
1184 { "NC_GatewayName", V_LENGTH(0, 255) },
1185 { "NC_GatewayPort", V_PORT },
1186 { "NC_ForcedRedirect", V_01 },
1187 { "NC_HomePage", V_LENGTH(0, 255) },
1188 { "NC_DocumentRoot", V_LENGTH(0, 255) },
1189 { "NC_SplashURL", V_LENGTH(0, 255) },
1190 { "NC_LoginTimeout", V_RANGE(0, 86400000) },
1191 { "NC_IdleTimeout", V_RANGE(0, 86400000) },
1192 { "NC_MaxMissedARP", V_RANGE(0, 10) },
1193 { "NC_PeerChecktimeout", V_RANGE(0, 60) },
1194 { "NC_ExcludePorts", V_LENGTH(0, 255) },
1195 { "NC_IncludePorts", V_LENGTH(0, 255) },
1196 { "NC_AllowedWebHosts", V_LENGTH(0, 255) },
1197 { "NC_MACWhiteList", V_LENGTH(0, 255) },
1198 { "NC_SplashFile", V_LENGTH(0, 8192) },
1199 #ifdef TCONFIG_VLAN
1200 { "NC_BridgeLAN", V_LENGTH(0, 50) },
1201 #endif
1202 #endif
1204 // NGinX Roadkill
1205 #ifdef TCONFIG_NGINX
1206 {"nginx_enable", V_01 }, // NGinX enabled
1207 {"nginx_docroot", V_LENGTH(0, 255) }, // root files path
1208 {"nginx_port", V_PORT }, // listening port
1209 {"nginx_fqdn", V_LENGTH(0, 255) }, // server name
1210 {"nginx_priority", V_LENGTH(0, 255) }, // server priority
1211 {"nginx_custom", V_TEXT(0, 4096) }, // user window to add parameters to nginx.conf
1212 #endif
1214 #ifdef TCONFIG_OPENVPN
1215 // vpn
1216 { "vpn_debug", V_01 },
1217 { "vpn_server_eas", V_NONE },
1218 { "vpn_server_dns", V_NONE },
1219 { "vpn_server1_poll", V_RANGE(0, 1440) },
1220 { "vpn_server1_if", V_TEXT(3, 3) }, // tap, tun
1221 { "vpn_server1_proto", V_TEXT(3, 10) }, // udp, tcp-server
1222 { "vpn_server1_port", V_PORT },
1223 { "vpn_server1_firewall", V_TEXT(0, 8) }, // auto, external, custom
1224 { "vpn_server1_crypt", V_TEXT(0, 6) }, // tls, secret, custom
1225 { "vpn_server1_comp", V_TEXT(0, 8) }, // yes, no, adaptive
1226 { "vpn_server1_cipher", V_TEXT(0, 16) },
1227 { "vpn_server1_dhcp", V_01 },
1228 { "vpn_server1_r1", V_IP },
1229 { "vpn_server1_r2", V_IP },
1230 { "vpn_server1_sn", V_IP },
1231 { "vpn_server1_nm", V_IP },
1232 { "vpn_server1_local", V_IP },
1233 { "vpn_server1_remote", V_IP },
1234 { "vpn_server1_reneg", V_RANGE(-1,2147483647)},
1235 { "vpn_server1_hmac", V_RANGE(-1, 2) },
1236 { "vpn_server1_plan", V_01 },
1237 { "vpn_server1_ccd", V_01 },
1238 { "vpn_server1_c2c", V_01 },
1239 { "vpn_server1_ccd_excl", V_01 },
1240 { "vpn_server1_ccd_val", V_NONE },
1241 { "vpn_server1_pdns", V_01 },
1242 { "vpn_server1_rgw", V_01 },
1243 { "vpn_server1_custom", V_NONE },
1244 { "vpn_server1_static", V_NONE },
1245 { "vpn_server1_ca", V_NONE },
1246 { "vpn_server1_crt", V_NONE },
1247 { "vpn_server1_key", V_NONE },
1248 { "vpn_server1_dh", V_NONE },
1249 { "vpn_server2_poll", V_RANGE(0, 1440) },
1250 { "vpn_server2_if", V_TEXT(3, 3) }, // tap, tun
1251 { "vpn_server2_proto", V_TEXT(3, 10) }, // udp, tcp-server
1252 { "vpn_server2_port", V_PORT },
1253 { "vpn_server2_firewall", V_TEXT(0, 8) }, // auto, external, custom
1254 { "vpn_server2_crypt", V_TEXT(0, 6) }, // tls, secret, custom
1255 { "vpn_server2_comp", V_TEXT(0, 8) }, // yes, no, adaptive
1256 { "vpn_server2_cipher", V_TEXT(0, 16) },
1257 { "vpn_server2_dhcp", V_01 },
1258 { "vpn_server2_r1", V_IP },
1259 { "vpn_server2_r2", V_IP },
1260 { "vpn_server2_sn", V_IP },
1261 { "vpn_server2_nm", V_IP },
1262 { "vpn_server2_local", V_IP },
1263 { "vpn_server2_remote", V_IP },
1264 { "vpn_server2_reneg", V_RANGE(-1,2147483647)},
1265 { "vpn_server2_hmac", V_RANGE(-1, 2) },
1266 { "vpn_server2_plan", V_01 },
1267 { "vpn_server2_pdns", V_01 },
1268 { "vpn_server2_rgw", V_01 },
1269 { "vpn_server2_custom", V_NONE },
1270 { "vpn_server2_ccd", V_01 },
1271 { "vpn_server2_c2c", V_01 },
1272 { "vpn_server2_ccd_excl", V_01 },
1273 { "vpn_server2_ccd_val", V_NONE },
1274 { "vpn_server2_static", V_NONE },
1275 { "vpn_server2_ca", V_NONE },
1276 { "vpn_server2_crt", V_NONE },
1277 { "vpn_server2_key", V_NONE },
1278 { "vpn_server2_dh", V_NONE },
1279 { "vpn_client_eas", V_NONE },
1280 { "vpn_client1_poll", V_RANGE(0, 1440) },
1281 { "vpn_client1_if", V_TEXT(3, 3) }, // tap, tun
1282 { "vpn_client1_bridge", V_01 },
1283 { "vpn_client1_nat", V_01 },
1284 { "vpn_client1_proto", V_TEXT(3, 10) }, // udp, tcp-server
1285 { "vpn_client1_addr", V_NONE },
1286 { "vpn_client1_port", V_PORT },
1287 { "vpn_client1_retry", V_RANGE(-1,32767) }, // -1 infinite, 0 disabled, >= 1 custom
1288 { "vpn_client1_firewall", V_TEXT(0, 6) }, // auto, custom
1289 { "vpn_client1_crypt", V_TEXT(0, 6) }, // tls, secret, custom
1290 { "vpn_client1_comp", V_TEXT(0, 8) }, // yes, no, adaptive
1291 { "vpn_client1_cipher", V_TEXT(0, 16) },
1292 { "vpn_client1_local", V_IP },
1293 { "vpn_client1_remote", V_IP },
1294 { "vpn_client1_nm", V_IP },
1295 { "vpn_client1_reneg", V_RANGE(-1,2147483647)},
1296 { "vpn_client1_hmac", V_RANGE(-1, 2) },
1297 { "vpn_client1_adns", V_RANGE(0, 3) },
1298 { "vpn_client1_rgw", V_01 },
1299 { "vpn_client1_gw", V_TEXT(0, 15) },
1300 { "vpn_client1_custom", V_NONE },
1301 { "vpn_client1_static", V_NONE },
1302 { "vpn_client1_ca", V_NONE },
1303 { "vpn_client1_crt", V_NONE },
1304 { "vpn_client1_key", V_NONE },
1305 { "vpn_client1_userauth", V_01 },
1306 { "vpn_client1_username", V_TEXT(0,50) },
1307 { "vpn_client1_password", V_TEXT(0,50) },
1308 { "vpn_client1_useronly", V_01 },
1309 { "vpn_client1_tlsremote",V_01 },
1310 { "vpn_client1_cn", V_NONE },
1311 { "vpn_client2_poll", V_RANGE(0, 1440) },
1312 { "vpn_client2_if", V_TEXT(3, 3) }, // tap, tun
1313 { "vpn_client2_bridge", V_01 },
1314 { "vpn_client2_nat", V_01 },
1315 { "vpn_client2_proto", V_TEXT(3, 10) }, // udp, tcp-server
1316 { "vpn_client2_addr", V_NONE },
1317 { "vpn_client2_port", V_PORT },
1318 { "vpn_client2_retry", V_RANGE(-1,32767) }, // -1 infinite, 0 disabled, >= 1 custom
1319 { "vpn_client2_firewall", V_TEXT(0, 6) }, // auto, custom
1320 { "vpn_client2_crypt", V_TEXT(0, 6) }, // tls, secret, custom
1321 { "vpn_client2_comp", V_TEXT(0, 8) }, // yes, no, adaptive
1322 { "vpn_client2_cipher", V_TEXT(0, 16) },
1323 { "vpn_client2_local", V_IP },
1324 { "vpn_client2_remote", V_IP },
1325 { "vpn_client2_nm", V_IP },
1326 { "vpn_client2_reneg", V_RANGE(-1,2147483647)},
1327 { "vpn_client2_hmac", V_RANGE(-1, 2) },
1328 { "vpn_client2_adns", V_RANGE(0, 3) },
1329 { "vpn_client2_rgw", V_01 },
1330 { "vpn_client2_gw", V_TEXT(0, 15) },
1331 { "vpn_client2_custom", V_NONE },
1332 { "vpn_client2_static", V_NONE },
1333 { "vpn_client2_ca", V_NONE },
1334 { "vpn_client2_crt", V_NONE },
1335 { "vpn_client2_key", V_NONE },
1336 { "vpn_client2_userauth", V_01 },
1337 { "vpn_client2_username", V_TEXT(0,50) },
1338 { "vpn_client2_password", V_TEXT(0,50) },
1339 { "vpn_client2_useronly", V_01 },
1340 { "vpn_client2_tlsremote",V_01 },
1341 { "vpn_client2_cn", V_NONE },
1342 #endif // vpn
1344 // pptp server
1345 { "pptpd_enable", V_01 },
1346 { "pptpd_remoteip", V_TEXT(0,24) },
1347 { "pptpd_forcemppe", V_01 },
1348 { "pptpd_users", V_TEXT(0, 67*16) },
1349 { "pptpd_broadcast", V_TEXT(0,8) },
1350 { "pptpd_dns1", V_TEXT(0, 15) },
1351 { "pptpd_dns2", V_TEXT(0, 15) },
1352 { "pptpd_wins1", V_TEXT(0, 15) },
1353 { "pptpd_wins2", V_TEXT(0, 15) },
1354 { "pptpd_mtu", V_RANGE(576, 1500) },
1355 { "pptpd_mru", V_RANGE(576, 1500) },
1356 { "pptpd_custom", V_TEXT(0, 2048) },
1359 ppp_static 0/1
1360 ppp_static_ip IP
1361 wl_enable 0/1
1362 wl_wds_timeout
1363 wl_maxassoc 1-256
1364 wl_phytype a,b,g
1365 wl_net_reauth
1366 wl_preauth
1367 wl_wme_ap_bk
1368 wl_wme_ap_be
1369 wl_wme_ap_vi
1370 wl_wme_ap_vo
1371 wl_wme_sta_bk
1372 wl_wme_sta_be
1373 wl_wme_sta_vi
1374 wl_wme_sta_vo
1376 port_priority_1 0-2
1377 port_flow_control_1 0,1
1378 port_rate_limit_1 0-8
1379 port_priority_2 0-2
1380 port_flow_control_2 0,1
1381 port_rate_limit_2 0-8
1382 port_priority_3 0-2
1383 port_flow_control_3 0,1
1384 port_rate_limit_3 0-8
1385 port_priority_4 0-2
1386 port_flow_control_4 0,1
1387 port_rate_limit_4 0-8
1388 wl_ap_ip
1389 wl_ap_ssid
1391 #ifdef TCONFIG_USERPPTP
1392 { "pptp_client_enable", V_01 },
1393 { "pptp_client_peerdns", V_RANGE(0,2) },
1394 { "pptp_client_mtuenable",V_01 },
1395 { "pptp_client_mtu", V_RANGE(576, 1500) },
1396 { "pptp_client_mruenable",V_01 },
1397 { "pptp_client_mru", V_RANGE(576, 1500) },
1398 { "pptp_client_nat", V_01 },
1399 { "pptp_client_srvip", V_NONE },
1400 { "pptp_client_srvsub", V_IP },
1401 { "pptp_client_srvsubmsk",V_IP },
1402 { "pptp_client_username", V_TEXT(0,50) },
1403 { "pptp_client_passwd", V_TEXT(0,50) },
1404 { "pptp_client_crypt", V_RANGE(0, 3) },
1405 { "pptp_client_custom", V_NONE },
1406 { "pptp_client_dfltroute",V_01 },
1407 { "pptp_client_stateless",V_01 },
1408 #endif
1409 { NULL }
1413 static int webcgi_nvram_set(const nvset_t *v, const char *name, int write)
1415 char *p, *e;
1416 int n;
1417 long l;
1418 unsigned u[6];
1419 int ok;
1420 int dirty;
1421 #ifdef TCONFIG_IPV6
1422 struct in6_addr addr;
1423 #endif
1425 if ((p = webcgi_get((char*)name)) == NULL) return 0;
1427 _dprintf("[%s] %s=%s\n", v->name, (char*)name, p);
1428 dirty = 0;
1429 ok = 1;
1430 switch (v->vtype) {
1431 case VT_TEXT:
1432 p = unix_string(p); // NOTE: p = malloc'd
1433 // drop
1434 case VT_LENGTH:
1435 n = strlen(p);
1436 if ((n < v->va.i) || (n > v->vb.i)) ok = 0;
1437 break;
1438 case VT_RANGE:
1439 l = strtol(p, &e, 10);
1440 if ((p == e) || (*e) || (l < v->va.l) || (l > v->vb.l)) ok = 0;
1441 break;
1442 case VT_IP:
1443 if ((sscanf(p, "%3u.%3u.%3u.%3u", &u[0], &u[1], &u[2], &u[3]) != 4) ||
1444 (u[0] > 255) || (u[1] > 255) || (u[2] > 255) || (u[3] > 255)) ok = 0;
1445 break;
1446 case VT_MAC:
1447 if ((sscanf(p, "%2x:%2x:%2x:%2x:%2x:%2x", &u[0], &u[1], &u[2], &u[3], &u[4], &u[5]) != 6) ||
1448 (u[0] > 255) || (u[1] > 255) || (u[2] > 255) || (u[3] > 255) || (u[4] > 255) || (u[5] > 255)) ok = 0;
1449 break;
1450 #ifdef TCONFIG_IPV6
1451 case VT_IPV6:
1452 if (strlen(p) > 0 || v->va.i) {
1453 if (inet_pton(AF_INET6, p, &addr) != 1) ok = 0;
1455 break;
1456 #endif
1457 default:
1458 // shutup gcc
1459 break;
1461 if (!ok) {
1462 if (v->vtype == VT_TEXT) free(p);
1463 return -1;
1465 if (write) {
1466 if (!nvram_match((char *)name, p)) {
1467 if (v->vtype != VT_TEMP) dirty = 1;
1468 DEBUG_NVRAMSET(name, p);
1469 nvram_set(name, p);
1472 if (v->vtype == VT_TEXT) free(p);
1474 return dirty;
1477 typedef struct {
1478 const nvset_t *v;
1479 int write;
1480 int dirty;
1481 } nv_list_t;
1483 static int nv_wl_find(int idx, int unit, int subunit, void *param)
1485 nv_list_t *p = param;
1487 int ok = webcgi_nvram_set(p->v, wl_nvname(p->v->name + 3, unit, subunit), p->write);
1488 if (ok < 0)
1489 return 1;
1490 else {
1491 p->dirty |= ok;
1492 return 0;
1496 static int save_variables(int write)
1498 const nvset_t *v;
1499 char *p;
1500 int n;
1501 int ok;
1502 char s[256];
1503 int dirty;
1504 static const char *msgf = "The field \"%s\" is invalid. Please report this problem.";
1505 nv_list_t nv;
1507 dirty = 0;
1508 nv.write = write;
1509 for (v = nvset_list; v->name; ++v) {
1510 ok = webcgi_nvram_set(v, v->name, write);
1512 if ((ok >= 0) && (strncmp(v->name, "wl_", 3) == 0)) {
1513 nv.dirty = dirty;
1514 nv.v = v;
1515 if (foreach_wif(1, &nv, nv_wl_find) == 0)
1516 ok |= nv.dirty;
1517 else
1518 ok = -1;
1521 if (ok < 0) {
1522 sprintf(s, msgf, v->name);
1523 resmsg_set(s);
1524 return 0;
1526 dirty |= ok;
1529 // special cases
1531 char *p1, *p2;
1532 if (((p1 = webcgi_get("set_password_1")) != NULL) && (strcmp(p1, "**********") != 0)) {
1533 if (((p2 = webcgi_get("set_password_2")) != NULL) && (strcmp(p1, p2) == 0)) {
1534 if ((write) && (!nvram_match("http_passwd", p1))) {
1535 dirty = 1;
1536 nvram_set("http_passwd", p1);
1539 else {
1540 sprintf(s, msgf, "password");
1541 resmsg_set(s);
1542 return 0;
1546 for (n = 0; n < 50; ++n) {
1547 sprintf(s, "rrule%d", n);
1548 if ((p = webcgi_get(s)) != NULL) {
1549 if (strlen(p) > 8192) { //Toastman
1550 sprintf(s, msgf, s);
1551 resmsg_set(s);
1552 return 0;
1554 if ((write) && (!nvram_match(s, p))) {
1555 dirty = 1;
1556 DEBUG_NVRAMSET(s, p);
1557 nvram_set(s, p);
1562 return (write) ? dirty : 1;
1565 static void wo_tomato(char *url)
1567 char *v;
1568 int i;
1569 int ajax;
1570 int nvset;
1571 const char *red;
1572 int commit;
1573 int force_commit;
1575 // _dprintf("tomato.cgi\n");
1577 red = webcgi_safeget("_redirect", "");
1578 if (!*red) send_header(200, NULL, mime_html, 0);
1580 commit = atoi(webcgi_safeget("_commit", "1"));
1581 force_commit = atoi(webcgi_safeget("_force_commit", "0"));
1582 ajax = atoi(webcgi_safeget("_ajax", "0"));
1584 nvset = atoi(webcgi_safeget("_nvset", "1"));
1585 if (nvset) {
1586 if (!save_variables(0)) {
1587 if (ajax) {
1588 web_printf("@msg:%s", resmsg_get());
1590 else {
1591 parse_asp("error.asp");
1593 return;
1595 commit = save_variables(1) && commit;
1597 resmsg_set("Settings saved.");
1600 rboot = atoi(webcgi_safeget("_reboot", "0"));
1601 if (rboot) {
1602 parse_asp("reboot.asp");
1604 else {
1605 if (ajax) {
1606 web_printf("@msg:%s", resmsg_get());
1608 else if (atoi(webcgi_safeget("_moveip", "0"))) {
1609 parse_asp("saved-moved.asp");
1611 else if (!*red) {
1612 parse_asp("saved.asp");
1616 if (commit || force_commit) {
1617 _dprintf("commit from tomato.cgi\n");
1618 nvram_commit_x();
1621 if ((v = webcgi_get("_service")) != NULL && *v != 0) {
1622 if (!*red) {
1623 if (ajax) web_printf(" Some services are being restarted...");
1624 web_close();
1626 sleep(1);
1628 if (*v == '*') {
1629 kill(1, SIGHUP);
1631 else {
1632 exec_service(v);
1636 for (i = atoi(webcgi_safeget("_sleep", "0")); i > 0; --i) sleep(1);
1638 if (*red) redirect(red);
1640 if (rboot) {
1641 web_close();
1642 sleep(1);
1643 kill(1, SIGTERM);
1648 // ----------------------------------------------------------------------------
1651 static void wo_update(char *url)
1653 const aspapi_t *api;
1654 const char *name;
1655 int argc;
1656 char *argv[16];
1657 char s[32];
1659 if ((name = webcgi_get("exec")) != NULL) {
1660 for (api = aspapi; api->name; ++api) {
1661 if (strcmp(api->name, name) == 0) {
1662 for (argc = 0; argc < 16; ++argc) {
1663 sprintf(s, "arg%d", argc);
1664 if ((argv[argc] = (char *)webcgi_get(s)) == NULL) break;
1666 api->exec(argc, argv);
1667 break;
1673 static void wo_service(char *url)
1675 int n;
1677 exec_service(webcgi_safeget("_service", ""));
1679 if ((n = atoi(webcgi_safeget("_sleep", "2"))) <= 0) n = 2;
1680 sleep(n);
1682 common_redirect();
1685 static void wo_shutdown(char *url)
1687 parse_asp("shutdown.asp");
1688 web_close();
1689 sleep(1);
1691 kill(1, SIGQUIT);
1694 static void wo_nvcommit(char *url)
1696 parse_asp("saved.asp");
1697 web_close();
1698 nvram_commit();