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 { "logs/view.cgi", NULL
, 0, wi_generic
, wo_viewlog
, 1 },
288 { "logs/*.txt", NULL
, 0, wi_generic
, wo_syslog
, 1 },
289 { "webmon_**", NULL
, 0, wi_generic
, wo_syslog
, 1 },
291 { "logout.asp", NULL
, 0, wi_generic
, wo_asp
, 1 },
292 { "clearcookies.asp", NULL
, 0, wi_generic
, wo_asp
, 1 },
294 // { "spin.gif", NULL, 0, wi_generic_noid, wo_spin, 1 },
296 { "**.asp", NULL
, 0, wi_generic_noid
, wo_asp
, 1 },
297 { "**.css", "text/css", 2, wi_generic_noid
, do_file
, 1 },
298 { "**.htm|**.html", mime_html
, 2, wi_generic_noid
, do_file
, 1 },
299 { "**.gif", "image/gif", 5, wi_generic_noid
, do_file
, 1 },
300 { "**.jpg", "image/jpeg", 5, wi_generic_noid
, do_file
, 1 },
301 { "**.png", "image/png", 5, wi_generic_noid
, do_file
, 1 },
302 { "**.js", mime_javascript
, 2, wi_generic_noid
, do_file
, 1 },
303 { "**.jsx", mime_javascript
, 0, wi_generic
, wo_asp
, 1 },
304 { "**.svg", "image/svg+xml", 2, wi_generic_noid
, do_file
, 1 },
305 { "**.txt", mime_plain
, 2, wi_generic_noid
, do_file
, 1 },
306 { "**.bin", mime_binary
, 0, wi_generic_noid
, do_file
, 1 },
307 { "**.bino", mime_octetstream
, 0, wi_generic_noid
, do_file
, 1 },
308 { "favicon.ico", NULL
, 5, wi_generic_noid
, wo_favicon
, 1 },
309 // !!TB - CGI Support, enable downloading archives
310 { "**/cgi-bin/**|**.sh", NULL
, 0, wi_cgi_bin
, wo_cgi_bin
, 1 },
311 { "**.tar|**.gz", mime_binary
, 0, wi_generic_noid
, do_file
, 1 },
312 { "shell.cgi", mime_javascript
, 0, wi_generic
, wo_shell
, 1 },
313 { "wpad.dat|proxy.pac", "application/x-ns-proxy-autoconfig", 0, wi_generic_noid
, do_file
, 0 },
315 { "webmon.cgi", mime_javascript
, 0, wi_generic
, wo_webmon
, 1 },
316 { "dhcpc.cgi", NULL
, 0, wi_generic
, wo_dhcpc
, 1 },
317 { "dhcpd.cgi", mime_javascript
, 0, wi_generic
, wo_dhcpd
, 1 },
318 { "nvcommit.cgi", NULL
, 0, wi_generic
, wo_nvcommit
, 1 },
319 { "ping.cgi", mime_javascript
, 0, wi_generic
, wo_ping
, 1 },
320 { "trace.cgi", mime_javascript
, 0, wi_generic
, wo_trace
, 1 },
321 { "upgrade.cgi", mime_html
, 0, wi_upgrade
, wo_flash
, 1 },
322 { "upnp.cgi", NULL
, 0, wi_generic
, wo_upnp
, 1 },
323 { "wakeup.cgi", NULL
, 0, wi_generic
, wo_wakeup
, 1 },
324 { "wlmnoise.cgi", mime_html
, 0, wi_generic
, wo_wlmnoise
, 1 },
325 { "wlradio.cgi", NULL
, 0, wi_generic
, wo_wlradio
, 1 },
326 { "resolve.cgi", mime_javascript
, 0, wi_generic
, wo_resolve
, 1 },
327 { "expct.cgi", mime_html
, 0, wi_generic
, wo_expct
, 1 },
328 { "service.cgi", NULL
, 0, wi_generic
, wo_service
, 1 },
329 // { "logout.cgi", NULL, 0, wi_generic, wo_logout, 0 }, // see httpd.c
330 { "shutdown.cgi", mime_html
, 0, wi_generic
, wo_shutdown
, 1 },
331 #ifdef TCONFIG_OPENVPN
332 { "vpnstatus.cgi", mime_javascript
, 0, wi_generic
, wo_vpn_status
, 1 },
335 { "usbcmd.cgi", mime_javascript
, 0, wi_generic
, wo_usbcommand
, 1 }, //!!TB - USB
338 { "blackhole.cgi", NULL
, 0, wi_blackhole
, NULL
, 1 },
340 // { "test", mime_html, 0, wi_generic, wo_test, 1 },
341 { NULL
, NULL
, 0, NULL
, NULL
, 1 }
344 const aspapi_t aspapi
[] = {
345 { "activeroutes", asp_activeroutes
},
346 { "arplist", asp_arplist
},
347 { "bandwidth", asp_bandwidth
},
348 { "build_time", asp_build_time
},
349 { "cgi_get", asp_cgi_get
},
350 { "compmac", asp_compmac
},
351 { "ctcount", asp_ctcount
},
352 { "ctdump", asp_ctdump
},
353 { "ctrate", asp_ctrate
},
354 { "ddnsx", asp_ddnsx
},
355 { "devlist", asp_devlist
},
356 { "webmon", asp_webmon
},
357 { "dhcpc_time", asp_dhcpc_time
},
359 { "ident", asp_ident
},
360 { "lanip", asp_lanip
},
361 { "layer7", asp_layer7
},
362 { "link_uptime", asp_link_uptime
},
363 { "lipp", asp_lipp
},
364 { "netdev", asp_netdev
},
365 { "notice", asp_notice
},
367 { "nvram", asp_nvram
},
368 { "nvramseq", asp_nvramseq
},
369 { "nvstat", asp_nvstat
},
370 { "psup", asp_psup
},
371 { "qrate", asp_qrate
},
372 { "resmsg", asp_resmsg
},
373 { "rrule", asp_rrule
},
374 { "statfs", asp_statfs
},
375 { "sysinfo", asp_sysinfo
},
376 { "time", asp_time
},
377 { "upnpinfo", asp_upnpinfo
},
378 { "version", asp_version
},
379 { "wanstatus", asp_wanstatus
},
380 { "wanup", asp_wanup
},
381 { "wlstats", asp_wlstats
},
382 { "wlclient", asp_wlclient
},
383 { "wlnoise", asp_wlnoise
},
384 { "wlscan", asp_wlscan
},
385 { "wlchannels", asp_wlchannels
}, //!!TB
386 { "wlcountries", asp_wlcountries
},
387 { "wlifaces", asp_wlifaces
},
388 { "wlbands", asp_wlbands
},
390 { "usbdevices", asp_usbdevices
}, //!!TB - USB Support
396 // -----------------------------------------------------------------------------
398 static void asp_css(int argc
, char **argv
)
400 const char *css
= nvram_safe_get("web_css");
402 if (strcmp(css
, "tomato") != 0) {
403 web_printf("<link rel='stylesheet' type='text/css' href='%s.css'>", css
);
407 // -----------------------------------------------------------------------------
409 const char *resmsg_get(void)
411 return webcgi_safeget("resmsg", "");
414 void resmsg_set(const char *msg
)
416 webcgi_set("resmsg", strdup(msg
)); // m ok
419 int resmsg_fread(const char *fname
)
424 f_read_string(fname
, s
, sizeof(s
));
425 if ((p
= strchr(s
, '\n')) != NULL
) *p
= 0;
433 static void asp_resmsg(int argc
, char **argv
)
437 if ((p
= js_string(webcgi_safeget("resmsg", (argc
> 0) ? argv
[0] : ""))) == NULL
) return;
438 web_printf("\nresmsg='%s';\n", p
);
442 // ----------------------------------------------------------------------------
444 // verification... simple sanity checks. UI should verify all fields.
446 // todo: move and re-use for filtering - zzz
457 VT_NONE
, // no checking
458 VT_LENGTH
, // check length of string
459 VT_TEXT
, // strip \r, check length of string
460 VT_RANGE
, // expect an integer, check range
461 VT_IP
, // expect an ip address
462 VT_MAC
, // expect a mac address
464 VT_IPV6
, // expect an ipv6 address
466 VT_TEMP
// no checks, no commit
473 #define V_NONE VT_NONE, { }, { }
474 #define V_01 VT_RANGE, { .l = 0 }, { .l = 1 }
475 #define V_PORT VT_RANGE, { .l = 2 }, { .l = 65535 }
476 #define V_ONOFF VT_LENGTH, { .i = 2 }, { .i = 3 }
477 #define V_WORD VT_LENGTH, { .i = 1 }, { .i = 16 }
478 #define V_LENGTH(min, max) VT_LENGTH, { .i = min }, { .i = max }
479 #define V_TEXT(min, max) VT_TEXT, { .i = min }, { .i = max }
480 #define V_RANGE(min, max) VT_RANGE, { .l = min }, { .l = max }
481 #define V_IP VT_IP, { }, { }
482 #define V_OCTET VT_RANGE, { .l = 0 }, { .l = 255 }
483 #define V_NUM VT_RANGE, { .l = 0 }, { .l = 0x7FFFFFFF }
484 #define V_TEMP VT_TEMP, { }, { }
486 #define V_IPV6(required) VT_IPV6, { .i = required }, { }
489 static const nvset_t nvset_list
[] = {
492 { "router_name", V_LENGTH(0, 32) },
493 { "wan_hostname", V_LENGTH(0, 32) },
494 { "wan_domain", V_LENGTH(0, 32) },
497 { "tm_tz", V_LENGTH(1, 64) }, // PST8PDT
498 { "tm_sel", V_LENGTH(1, 64) }, // PST8PDT
500 { "ntp_updates", V_RANGE(-1, 24) },
501 { "ntp_tdod", V_01
},
502 { "ntp_server", V_LENGTH(1, 150) }, // x y z
503 { "ntp_kiss", V_LENGTH(0, 255) },
506 { "dhcpd_static", V_LENGTH(0, 106*251)}, // 106 (max chars per entry) x 100 entries
509 { "ddnsx0", V_LENGTH(0, 2048) },
510 { "ddnsx1", V_LENGTH(0, 2048) },
511 { "ddnsx0_cache", V_LENGTH(0, 1) }, // only to clear
512 { "ddnsx1_cache", V_LENGTH(0, 1) },
513 { "ddnsx_ip", V_LENGTH(0, 32) },
514 { "ddnsx_save", V_01
},
515 { "ddnsx_refresh", V_RANGE(0, 365) },
519 { "wan_proto", V_LENGTH(1, 16) }, // disabled, dhcp, static, pppoe, pptp, l2tp
520 { "wan_ipaddr", V_IP
},
521 { "wan_netmask", V_IP
},
522 { "wan_gateway", V_IP
},
523 { "hb_server_ip", V_LENGTH(0, 32) },
524 { "l2tp_server_ip", V_LENGTH(0, 128) },
525 { "pptp_server_ip", V_LENGTH(0, 128) },
526 { "pptp_dhcp", V_01
},
527 { "ppp_username", V_LENGTH(0, 60) },
528 { "ppp_passwd", V_LENGTH(0, 60) },
529 { "ppp_service", V_LENGTH(0, 50) },
530 { "ppp_demand", V_01
},
531 { "ppp_custom", V_LENGTH(0, 256) },
532 { "ppp_idletime", V_RANGE(0, 1440) },
533 { "ppp_redialperiod", V_RANGE(1, 86400) },
534 { "mtu_enable", V_01
},
535 { "wan_mtu", V_RANGE(576, 1500) },
536 { "wan_islan", V_01
},
539 { "lan_ipaddr", V_IP
},
540 { "lan_netmask", V_IP
},
541 { "lan_gateway", V_IP
},
542 { "wan_dns", V_LENGTH(0, 50) }, // ip ip ip
543 { "lan_proto", V_WORD
}, // static, dhcp
544 { "dhcp_start", V_RANGE(1, 254) }, // remove !
545 { "dhcp_num", V_RANGE(1, 255) }, // remove !
546 { "dhcpd_startip", V_IP
},
547 { "dhcpd_endip", V_IP
},
548 { "dhcp_lease", V_RANGE(1, 10080) },
549 { "wan_wins", V_IP
},
552 { "wl_radio", V_01
},
553 { "wl_mode", V_LENGTH(2, 3) }, // ap, sta, wet, wds
554 { "wl_net_mode", V_LENGTH(5, 8) }, // disabled, mixed, b-only, g-only, bg-mixed, n-only [speedbooster]
555 { "wl_ssid", V_LENGTH(1, 32) },
556 { "wl_closed", V_01
},
557 { "wl_channel", V_RANGE(0, 216) },
559 { "wl_security_mode", V_LENGTH(1, 32) }, // disabled, radius, wep, wpa_personal, wpa_enterprise, wpa2_personal, wpa2_enterprise
560 { "wl_radius_ipaddr", V_IP
},
561 { "wl_radius_port", V_PORT
},
562 { "wl_radius_key", V_LENGTH(1, 64) },
563 { "wl_wep_bit", V_RANGE(64, 128) }, // 64 or 128
564 { "wl_passphrase", V_LENGTH(0, 20) },
565 { "wl_key", V_RANGE(1, 4) },
566 { "wl_key1", V_LENGTH(0, 26) },
567 { "wl_key2", V_LENGTH(0, 26) },
568 { "wl_key3", V_LENGTH(0, 26) },
569 { "wl_key4", V_LENGTH(0, 26) },
570 { "wl_crypto", V_LENGTH(3, 8) }, // tkip, aes, tkip+aes
571 { "wl_wpa_psk", V_LENGTH(8, 64) },
572 { "wl_wpa_gtk_rekey", V_RANGE(60, 7200) },
574 { "wl_lazywds", V_01
},
575 { "wl_wds", V_LENGTH(0, 180) }, // mac mac mac (x 10)
577 { "wl_wds_enable", V_01
},
578 { "wl_gmode", V_RANGE(-1, 6) },
579 { "wl_wep", V_LENGTH(1, 32) }, // off, on, restricted,tkip,aes,tkip+aes
580 { "wl_akm", V_LENGTH(0, 32) }, // wpa, wpa2, psk, psk2, wpa wpa2, psk psk2, ""
581 { "wl_auth_mode", V_LENGTH(4, 6) }, // none, radius
583 { "wl_nmode", V_NONE
},
584 { "wl_nband", V_RANGE(0, 2) }, // 2 - 2.4GHz, 1 - 5GHz, 0 - Auto
585 { "wl_nreqd", V_NONE
},
586 { "wl_nbw_cap", V_RANGE(0, 2) }, // 0 - 20MHz, 1 - 40MHz, 2 - Auto
587 { "wl_nbw", V_NONE
},
588 { "wl_mimo_preamble", V_WORD
}, // 802.11n Preamble: mm/gf/auto/gfbcm
589 { "wl_nctrlsb", V_NONE
}, // none, lower, upper
593 { "ipv6_service", V_LENGTH(0, 16) }, // '', native, native-pd, 6to4, sit, other
594 { "ipv6_prefix", V_IPV6(0) },
595 { "ipv6_prefix_length", V_RANGE(3, 127) },
596 { "ipv6_rtr_addr", V_IPV6(0) },
597 { "ipv6_radvd", V_01
},
598 { "ipv6_accept_ra", V_NUM
},
599 { "ipv6_tun_addr", V_IPV6(1) },
600 { "ipv6_tun_addrlen", V_RANGE(3, 127) },
601 { "ipv6_ifname", V_LENGTH(0, 8) },
602 { "ipv6_tun_v4end", V_IP
},
603 { "ipv6_relay", V_RANGE(1, 254) },
604 { "ipv6_tun_mtu", V_NUM
}, // Tunnel MTU
605 { "ipv6_tun_ttl", V_NUM
}, // Tunnel TTL
606 { "ipv6_dns", V_LENGTH(0, 40*3) }, // ip6 ip6 ip6
610 { "wl_macmode", V_NONE
}, // allow, deny, disabled
611 { "wl_maclist", V_LENGTH(0, 18*201) }, // 18 x 200 (11:22:33:44:55:66 ...)
612 { "macnames", V_LENGTH(0, 62*201) }, // 62 (12+1+48+1) x 50 (112233445566<..>) todo: re-use -- zzz
616 { "ct_tcp_timeout", V_LENGTH(20, 70) },
617 { "ct_udp_timeout", V_LENGTH(5, 15) },
618 { "ct_timeout", V_LENGTH(5, 15) },
619 { "nf_ttl", V_LENGTH(1, 6) },
623 { "ct_hashsize", V_NUM
},
631 { "dhcpd_slt", V_RANGE(-1, 43200) }, // -1=infinite, 0=follow normal lease time, >=1 custom
632 { "dhcpd_dmdns", V_01
},
633 { "dhcpd_lmax", V_NUM
},
634 { "dhcpd_gwmode", V_NUM
},
635 { "dns_addget", V_01
},
636 { "dns_intcpt", V_01
},
637 { "dhcpc_minpkt", V_01
},
638 { "dhcpc_custom", V_LENGTH(0, 80) },
639 { "dns_norebind", V_01
},
640 { "dnsmasq_custom", V_TEXT(0, 2048) },
641 // { "dnsmasq_norw", V_01 },
644 { "block_wan", V_01
},
645 { "multicast_pass", V_01
},
646 { "block_loopback", V_01
},
647 { "nf_loopback", V_NUM
},
648 { "ne_syncookies", V_01
},
649 { "dhcp_pass", V_01
},
651 { "emf_entry", V_NONE
},
652 { "emf_uffp_entry", V_NONE
},
653 { "emf_rtport_entry", V_NONE
},
654 { "emf_enable", V_01
},
658 { "wait_time", V_RANGE(3, 20) },
659 { "wan_speed", V_RANGE(0, 4) },
660 { "clkfreq", V_RANGE(100, 532) }, // KP
661 { "jumbo_frame_enable", V_01
}, // Jumbo Frames support (for RT-N16/WNR3500L)
662 { "jumbo_frame_size", V_RANGE(1, 9720) },
664 { "ctf_disable", V_01
},
668 { "mac_wan", V_LENGTH(0, 17) },
669 { "wl_macaddr", V_LENGTH(0, 17) },
672 { "routes_static", V_LENGTH(0, 2048) },
673 { "dhcp_routes", V_01
},
674 { "lan_stp", V_RANGE(0, 1) },
675 { "wk_mode", V_LENGTH(1, 32) }, // gateway, router
677 { "dr_setting", V_RANGE(0, 3) },
678 { "dr_lan_tx", V_LENGTH(0, 32) },
679 { "dr_lan_rx", V_LENGTH(0, 32) },
680 { "dr_wan_tx", V_LENGTH(0, 32) },
681 { "dr_wan_rx", V_LENGTH(0, 32) },
685 { "wl_country", V_LENGTH(0, 64) }, // !!TB - Country code
686 { "wl_country_code", V_LENGTH(0, 4) }, // !!TB - Country code
687 { "wl_btc_mode", V_RANGE(0, 2) }, // !!TB - BT Coexistence Mode: 0 (disable), 1 (enable), 2 (preemption)
688 { "wl_afterburner", V_LENGTH(2, 4) }, // off, on, auto
690 { "wl_rateset", V_LENGTH(2, 7) }, // all, default, 12
691 { "wl_rate", V_RANGE(0, 54 * 1000 * 1000) },
692 { "wl_mrate", V_RANGE(0, 54 * 1000 * 1000) },
693 { "wl_gmode_protection",V_LENGTH(3, 4) }, // off, auto
694 { "wl_frameburst", V_ONOFF
}, // off, on
695 { "wl_bcn", V_RANGE(1, 65535) },
696 { "wl_dtim", V_RANGE(1, 255) },
697 { "wl_frag", V_RANGE(256, 2346) },
698 { "wl_rts", V_RANGE(0, 2347) },
699 { "wl_ap_isolate", V_01
},
700 { "wl_plcphdr", V_LENGTH(4, 5) }, // long, short
701 { "wl_antdiv", V_RANGE(0, 3) },
702 { "wl_txant", V_RANGE(0, 3) },
703 { "wl_txpwr", V_RANGE(0, 400) },
704 { "wl_wme", V_WORD
}, // auto, off, on
705 { "wl_wme_no_ack", V_ONOFF
}, // off, on
706 { "wl_wme_apsd", V_ONOFF
}, // off, on
707 { "wl_maxassoc", V_RANGE(0, 255) },
708 { "wl_distance", V_LENGTH(0, 5) }, // "", 1-99999
709 { "wlx_hpamp", V_01
},
710 { "wlx_hperx", V_01
},
711 { "wl_reg_mode", V_LENGTH(1, 3) }, // !!TB - Regulatory: off, h, d
712 { "wl_mitigation", V_RANGE(0, 3) }, // Interference Mitigation Mode (0|1|2|3)
714 { "wl_nmode_protection", V_WORD
, }, // off, auto
715 { "wl_nmcsidx", V_RANGE(-2, 32), }, // -2 - 32
716 { "wl_obss_coex", V_01
},
719 { "dmz_enable", V_01
},
720 { "dmz_ipaddr", V_LENGTH(0, 15) },
721 { "dmz_sip", V_LENGTH(0, 512) },
724 { "upnp_enable", V_NUM
},
725 { "upnp_secure", V_01
},
726 { "upnp_port", V_RANGE(0, 65535) },
727 { "upnp_ssdp_interval", V_RANGE(10, 9999) },
728 { "upnp_mnp", V_01
},
729 { "upnp_clean", V_01
},
730 { "upnp_clean_interval", V_RANGE(60, 65535) },
731 { "upnp_clean_threshold", V_RANGE(0, 9999) },
732 { "upnp_min_port_int", V_PORT
},
733 { "upnp_max_port_int", V_PORT
},
734 { "upnp_min_port_ext", V_PORT
},
735 { "upnp_max_port_ext", V_PORT
},
738 { "portforward", V_LENGTH(0, 4096) },
741 // forward-basic-ipv6
742 { "ipv6_portforward", V_LENGTH(0, 4096) },
746 { "trigforward", V_LENGTH(0, 4096) },
749 // access restriction
750 { "rruleN", V_RANGE(0, 99) },
751 // { "rrule##", V_LENGTH(0, 16384) }, // in save_variables()
754 { "http_enable", V_01
},
755 { "https_enable", V_01
},
756 { "https_crt_save", V_01
},
757 { "https_crt_cn", V_LENGTH(0, 64) },
758 { "https_crt_gen", V_TEMP
},
759 { "remote_management", V_01
},
760 { "remote_mgt_https", V_01
},
761 { "http_lanport", V_PORT
},
762 { "https_lanport", V_PORT
},
763 { "web_wl_filter", V_01
},
764 { "web_css", V_LENGTH(1, 32) },
765 { "web_mx", V_LENGTH(0, 128) },
766 { "http_wanport", V_PORT
},
767 { "telnetd_eas", V_01
},
768 { "telnetd_port", V_PORT
},
769 { "sshd_eas", V_01
},
770 { "sshd_pass", V_01
},
771 { "sshd_port", V_PORT
},
772 { "sshd_remote", V_01
},
773 { "sshd_forwarding", V_01
},
774 { "sshd_rport", V_PORT
},
775 { "sshd_authkeys", V_TEXT(0, 4096) },
776 { "rmgt_sip", V_LENGTH(0, 512) },
777 { "ne_shlimit", V_TEXT(1, 50) },
780 { "rstats_enable", V_01
},
781 { "rstats_path", V_LENGTH(0, 48) },
782 { "rstats_stime", V_RANGE(1, 168) },
783 { "rstats_offset", V_RANGE(1, 31) },
784 { "rstats_exclude", V_LENGTH(0, 64) },
785 { "rstats_sshut", V_01
},
786 { "rstats_bak", V_01
},
789 { "sesx_led", V_RANGE(0, 255) }, // amber, white, aoss
790 { "sesx_b0", V_RANGE(0, 5) }, // 0-5: toggle wireless, reboot, shutdown, script, usb unmount
791 { "sesx_b1", V_RANGE(0, 5) }, // "
792 { "sesx_b2", V_RANGE(0, 5) }, // "
793 { "sesx_b3", V_RANGE(0, 5) }, // "
794 { "sesx_script", V_TEXT(0, 1024) }, //
795 { "script_brau", V_TEXT(0, 1024) }, //
798 { "debug_nocommit", V_01
},
799 { "debug_cprintf", V_01
},
800 { "debug_cprintf_file", V_01
},
801 // { "debug_keepfiles", V_01 },
802 { "debug_ddns", V_01
},
803 { "debug_norestart", V_TEXT(0, 128) },
804 { "console_loglevel", V_RANGE(1, 8) },
805 { "t_cafree", V_01
},
806 { "t_hidelr", V_01
},
809 { "sch_rboot", V_TEXT(0, 64) },
810 { "sch_rcon", V_TEXT(0, 64) },
811 { "sch_c1", V_TEXT(0, 64) },
812 { "sch_c1_cmd", V_TEXT(0, 2048) },
813 { "sch_c2", V_TEXT(0, 64) },
814 { "sch_c2_cmd", V_TEXT(0, 2048) },
815 { "sch_c3", V_TEXT(0, 64) },
816 { "sch_c3_cmd", V_TEXT(0, 2048) },
819 { "script_init", V_TEXT(0, 4096) },
820 { "script_shut", V_TEXT(0, 4096) },
821 { "script_fire", V_TEXT(0, 8192) },
822 { "script_wanup", V_TEXT(0, 4096) },
825 { "log_remote", V_01
},
826 { "log_remoteip", V_LENGTH(0, 512) },
827 { "log_remoteport", V_PORT
},
828 { "log_file", V_01
},
829 { "log_limit", V_RANGE(0, 2400) },
830 { "log_in", V_RANGE(0, 3) },
831 { "log_out", V_RANGE(0, 3) },
832 { "log_mark", V_RANGE(0, 99999) },
833 { "log_events", V_TEXT(0, 32) }, // "acre,crond,ntp"
835 // admin-log-webmonitor
837 { "log_wmtype", V_RANGE(0, 2) },
838 { "log_wmip", V_LENGTH(0, 512) },
839 { "log_wmdmax", V_RANGE(0, 9999) },
840 { "log_wmsmax", V_RANGE(0, 9999) },
843 { "cifs1", V_LENGTH(1, 1024) },
844 { "cifs2", V_LENGTH(1, 1024) },
847 { "jffs2_on", V_01
},
848 { "jffs2_exec", V_LENGTH(0, 64) },
849 { "jffs2_format", V_01
},
853 { "usb_enable", V_01
},
854 { "usb_uhci", V_RANGE(-1, 1) }, // -1 - disabled, 0 - off, 1 - on
855 { "usb_ohci", V_RANGE(-1, 1) },
856 { "usb_usb2", V_RANGE(-1, 1) },
857 { "usb_irq_thresh", V_RANGE(0, 6) },
858 { "usb_storage", V_01
},
859 { "usb_printer", V_01
},
860 { "usb_printer_bidirect", V_01
},
861 { "usb_fs_ext3", V_01
},
862 { "usb_fs_fat", V_01
},
864 { "usb_fs_ntfs", V_01
},
866 { "usb_automount", V_01
},
867 { "script_usbhotplug", V_TEXT(0, 2048) },
868 { "script_usbmount", V_TEXT(0, 2048) },
869 { "script_usbumount", V_TEXT(0, 2048) },
874 { "ftp_enable", V_RANGE(0, 2) },
875 { "ftp_super", V_01
},
876 { "ftp_anonymous", V_RANGE(0, 3) },
877 { "ftp_dirlist", V_RANGE(0, 2) },
878 { "ftp_port", V_PORT
},
879 { "ftp_max", V_RANGE(0, 12) },
880 { "ftp_ipmax", V_RANGE(0, 12) },
881 { "ftp_staytimeout", V_RANGE(0, 65535) },
882 { "ftp_rate", V_RANGE(0, 99999) },
883 { "ftp_anonrate", V_RANGE(0, 99999) },
884 { "ftp_anonroot", V_LENGTH(0, 256) },
885 { "ftp_pubroot", V_LENGTH(0, 256) },
886 { "ftp_pvtroot", V_LENGTH(0, 256) },
887 { "ftp_users", V_LENGTH(0, 4096) },
888 { "ftp_custom", V_TEXT(0, 2048) },
889 { "ftp_sip", V_LENGTH(0, 512) },
890 { "ftp_limit", V_TEXT(1, 50) },
894 #ifdef TCONFIG_SAMBASRV
896 { "smbd_enable", V_RANGE(0, 2) },
897 { "smbd_wgroup", V_LENGTH(0, 20) },
898 { "smbd_master", V_01
},
899 { "smbd_wins", V_01
},
900 { "smbd_cpage", V_LENGTH(0, 4) },
901 { "smbd_cset", V_LENGTH(0, 20) },
902 { "smbd_custom", V_TEXT(0, 2048) },
903 { "smbd_autoshare", V_RANGE(0, 3) },
904 { "smbd_shares", V_LENGTH(0, 4096) },
905 { "smbd_user", V_LENGTH(0, 50) },
906 { "smbd_passwd", V_LENGTH(0, 50) },
909 #ifdef TCONFIG_MEDIA_SERVER
911 { "ms_enable", V_01
},
912 { "ms_dirs", V_LENGTH(0, 1024) },
913 { "ms_port", V_RANGE(0, 65535) },
914 { "ms_dbdir", V_LENGTH(0, 256) },
916 { "ms_stdlna", V_01
},
917 { "ms_rescan", V_01
},
922 { "qos_enable", V_01
},
923 { "qos_pfifo", V_01
},
928 { "qos_icmp", V_01
},
929 { "qos_reset", V_01
},
930 { "qos_pfifo", V_01
}, // !!TB
931 { "qos_obw", V_RANGE(10, 999999) },
932 { "qos_ibw", V_RANGE(10, 999999) },
933 { "qos_orules", V_LENGTH(0, 4096) },
934 { "qos_default", V_RANGE(0, 9) },
935 { "qos_irates", V_LENGTH(0, 128) },
936 { "qos_orates", V_LENGTH(0, 128) },
938 { "ne_vegas", V_01
},
939 { "ne_valpha", V_NUM
},
940 { "ne_vbeta", V_NUM
},
941 { "ne_vgamma", V_NUM
},
944 { "new_qoslimit_enable", V_01
},
947 { "new_qoslimit_rules", V_LENGTH(0, 4096) },
948 { "qosl_enable", V_01
},
949 { "qosl_ulr", V_RANGE(0, 999999) },
950 { "qosl_ulc", V_RANGE(0, 999999) },
951 { "qosl_dlr", V_RANGE(0, 999999) },
952 { "qosl_dlc", V_RANGE(0, 999999) },
953 { "qosl_tcp", V_RANGE(0, 1000) },
954 { "qosl_udp", V_RANGE(0, 100) },
958 { "new_arpbind_enable", V_01
},
959 { "new_arpbind_only", V_01
},
960 { "new_arpbind_list", V_LENGTH(0, 4096) },
962 #ifdef TCONFIG_OPENVPN
964 { "vpn_debug", V_01
},
965 { "vpn_server_eas", V_NONE
},
966 { "vpn_server_dns", V_NONE
},
967 { "vpn_server1_poll", V_RANGE(0, 1440) },
968 { "vpn_server1_if", V_TEXT(3, 3) }, // tap, tun
969 { "vpn_server1_proto", V_TEXT(3, 10) }, // udp, tcp-server
970 { "vpn_server1_port", V_PORT
},
971 { "vpn_server1_firewall", V_TEXT(0, 8) }, // auto, external, custom
972 { "vpn_server1_crypt", V_TEXT(0, 6) }, // tls, secret, custom
973 { "vpn_server1_comp", V_TEXT(0, 8) }, // yes, no, adaptive
974 { "vpn_server1_cipher", V_TEXT(0, 16) },
975 { "vpn_server1_dhcp", V_01
},
976 { "vpn_server1_r1", V_IP
},
977 { "vpn_server1_r2", V_IP
},
978 { "vpn_server1_sn", V_IP
},
979 { "vpn_server1_nm", V_IP
},
980 { "vpn_server1_local", V_IP
},
981 { "vpn_server1_remote", V_IP
},
982 { "vpn_server1_reneg", V_RANGE(-1,2147483647)},
983 { "vpn_server1_hmac", V_RANGE(-1, 2) },
984 { "vpn_server1_plan", V_01
},
985 { "vpn_server1_ccd", V_01
},
986 { "vpn_server1_c2c", V_01
},
987 { "vpn_server1_ccd_excl", V_01
},
988 { "vpn_server1_ccd_val", V_NONE
},
989 { "vpn_server1_pdns", V_01
},
990 { "vpn_server1_rgw", V_01
},
991 { "vpn_server1_custom", V_NONE
},
992 { "vpn_server1_static", V_NONE
},
993 { "vpn_server1_ca", V_NONE
},
994 { "vpn_server1_crt", V_NONE
},
995 { "vpn_server1_key", V_NONE
},
996 { "vpn_server1_dh", V_NONE
},
997 { "vpn_server2_poll", V_RANGE(0, 1440) },
998 { "vpn_server2_if", V_TEXT(3, 3) }, // tap, tun
999 { "vpn_server2_proto", V_TEXT(3, 10) }, // udp, tcp-server
1000 { "vpn_server2_port", V_PORT
},
1001 { "vpn_server2_firewall", V_TEXT(0, 8) }, // auto, external, custom
1002 { "vpn_server2_crypt", V_TEXT(0, 6) }, // tls, secret, custom
1003 { "vpn_server2_comp", V_TEXT(0, 8) }, // yes, no, adaptive
1004 { "vpn_server2_cipher", V_TEXT(0, 16) },
1005 { "vpn_server2_dhcp", V_01
},
1006 { "vpn_server2_r1", V_IP
},
1007 { "vpn_server2_r2", V_IP
},
1008 { "vpn_server2_sn", V_IP
},
1009 { "vpn_server2_nm", V_IP
},
1010 { "vpn_server2_local", V_IP
},
1011 { "vpn_server2_remote", V_IP
},
1012 { "vpn_server2_reneg", V_RANGE(-1,2147483647)},
1013 { "vpn_server2_hmac", V_RANGE(-1, 2) },
1014 { "vpn_server2_plan", V_01
},
1015 { "vpn_server2_pdns", V_01
},
1016 { "vpn_server2_rgw", V_01
},
1017 { "vpn_server2_custom", V_NONE
},
1018 { "vpn_server2_ccd", V_01
},
1019 { "vpn_server2_c2c", V_01
},
1020 { "vpn_server2_ccd_excl", V_01
},
1021 { "vpn_server2_ccd_val", V_NONE
},
1022 { "vpn_server2_static", V_NONE
},
1023 { "vpn_server2_ca", V_NONE
},
1024 { "vpn_server2_crt", V_NONE
},
1025 { "vpn_server2_key", V_NONE
},
1026 { "vpn_server2_dh", V_NONE
},
1027 { "vpn_client_eas", V_NONE
},
1028 { "vpn_client1_poll", V_RANGE(0, 1440) },
1029 { "vpn_client1_if", V_TEXT(3, 3) }, // tap, tun
1030 { "vpn_client1_bridge", V_01
},
1031 { "vpn_client1_nat", V_01
},
1032 { "vpn_client1_proto", V_TEXT(3, 10) }, // udp, tcp-server
1033 { "vpn_client1_addr", V_NONE
},
1034 { "vpn_client1_port", V_PORT
},
1035 { "vpn_client1_retry", V_RANGE(-1,32767) }, // -1 infinite, 0 disabled, >= 1 custom
1036 { "vpn_client1_firewall", V_TEXT(0, 6) }, // auto, custom
1037 { "vpn_client1_crypt", V_TEXT(0, 6) }, // tls, secret, custom
1038 { "vpn_client1_comp", V_TEXT(0, 8) }, // yes, no, adaptive
1039 { "vpn_client1_cipher", V_TEXT(0, 16) },
1040 { "vpn_client1_local", V_IP
},
1041 { "vpn_client1_remote", V_IP
},
1042 { "vpn_client1_nm", V_IP
},
1043 { "vpn_client1_reneg", V_RANGE(-1,2147483647)},
1044 { "vpn_client1_hmac", V_RANGE(-1, 2) },
1045 { "vpn_client1_adns", V_RANGE(0, 3) },
1046 { "vpn_client1_rgw", V_01
},
1047 { "vpn_client1_gw", V_TEXT(0, 15) },
1048 { "vpn_client1_custom", V_NONE
},
1049 { "vpn_client1_static", V_NONE
},
1050 { "vpn_client1_ca", V_NONE
},
1051 { "vpn_client1_crt", V_NONE
},
1052 { "vpn_client1_key", V_NONE
},
1053 { "vpn_client2_poll", V_RANGE(0, 1440) },
1054 { "vpn_client2_if", V_TEXT(3, 3) }, // tap, tun
1055 { "vpn_client2_bridge", V_01
},
1056 { "vpn_client2_nat", V_01
},
1057 { "vpn_client2_proto", V_TEXT(3, 10) }, // udp, tcp-server
1058 { "vpn_client2_addr", V_NONE
},
1059 { "vpn_client2_port", V_PORT
},
1060 { "vpn_client2_retry", V_RANGE(-1,32767) }, // -1 infinite, 0 disabled, >= 1 custom
1061 { "vpn_client2_firewall", V_TEXT(0, 6) }, // auto, custom
1062 { "vpn_client2_crypt", V_TEXT(0, 6) }, // tls, secret, custom
1063 { "vpn_client2_comp", V_TEXT(0, 8) }, // yes, no, adaptive
1064 { "vpn_client2_cipher", V_TEXT(0, 16) },
1065 { "vpn_client2_local", V_IP
},
1066 { "vpn_client2_remote", V_IP
},
1067 { "vpn_client2_nm", V_IP
},
1068 { "vpn_client2_reneg", V_RANGE(-1,2147483647)},
1069 { "vpn_client2_hmac", V_RANGE(-1, 2) },
1070 { "vpn_client2_adns", V_RANGE(0, 3) },
1071 { "vpn_client2_rgw", V_01
},
1072 { "vpn_client2_gw", V_TEXT(0, 15) },
1073 { "vpn_client2_custom", V_NONE
},
1074 { "vpn_client2_static", V_NONE
},
1075 { "vpn_client2_ca", V_NONE
},
1076 { "vpn_client2_crt", V_NONE
},
1077 { "vpn_client2_key", V_NONE
},
1101 port_flow_control_1 0,1
1102 port_rate_limit_1 0-8
1104 port_flow_control_2 0,1
1105 port_rate_limit_2 0-8
1107 port_flow_control_3 0,1
1108 port_rate_limit_3 0-8
1110 port_flow_control_4 0,1
1111 port_rate_limit_4 0-8
1120 static int webcgi_nvram_set(const nvset_t
*v
, const char *name
, int write
)
1129 struct in6_addr addr
;
1132 if ((p
= webcgi_get((char*)name
)) == NULL
) return 0;
1134 _dprintf("[%s] %s=%s\n", v
->name
, (char*)name
, p
);
1139 p
= unix_string(p
); // NOTE: p = malloc'd
1143 if ((n
< v
->va
.i
) || (n
> v
->vb
.i
)) ok
= 0;
1146 l
= strtol(p
, &e
, 10);
1147 if ((p
== e
) || (*e
) || (l
< v
->va
.l
) || (l
> v
->vb
.l
)) ok
= 0;
1150 if ((sscanf(p
, "%3u.%3u.%3u.%3u", &u
[0], &u
[1], &u
[2], &u
[3]) != 4) ||
1151 (u
[0] > 255) || (u
[1] > 255) || (u
[2] > 255) || (u
[3] > 255)) ok
= 0;
1154 if ((sscanf(p
, "%2x:%2x:%2x:%2x:%2x:%2x", &u
[0], &u
[1], &u
[2], &u
[3], &u
[4], &u
[5]) != 6) ||
1155 (u
[0] > 255) || (u
[1] > 255) || (u
[2] > 255) || (u
[3] > 255) || (u
[4] > 255) || (u
[5] > 255)) ok
= 0;
1159 if (strlen(p
) > 0 || v
->va
.i
) {
1160 if (inet_pton(AF_INET6
, p
, &addr
) != 1) ok
= 0;
1169 if (v
->vtype
== VT_TEXT
) free(p
);
1173 if (!nvram_match((char *)name
, p
)) {
1174 if (v
->vtype
!= VT_TEMP
) dirty
= 1;
1175 DEBUG_NVRAMSET(name
, p
);
1179 if (v
->vtype
== VT_TEXT
) free(p
);
1190 static int nv_wl_find(int idx
, int unit
, int subunit
, void *param
)
1192 nv_list_t
*p
= param
;
1194 int ok
= webcgi_nvram_set(p
->v
, wl_nvname(p
->v
->name
+ 3, unit
, subunit
), p
->write
);
1203 static int save_variables(int write
)
1211 static const char *msgf
= "The field \"%s\" is invalid. Please report this problem.";
1216 for (v
= nvset_list
; v
->name
; ++v
) {
1217 ok
= webcgi_nvram_set(v
, v
->name
, write
);
1219 if ((ok
>= 0) && (strncmp(v
->name
, "wl_", 3) == 0)) {
1222 if (foreach_wif(1, &nv
, nv_wl_find
) == 0)
1229 sprintf(s
, msgf
, v
->name
);
1239 if (((p1
= webcgi_get("set_password_1")) != NULL
) && (strcmp(p1
, "**********") != 0)) {
1240 if (((p2
= webcgi_get("set_password_2")) != NULL
) && (strcmp(p1
, p2
) == 0)) {
1241 if ((write
) && (!nvram_match("http_passwd", p1
))) {
1243 nvram_set("http_passwd", p1
);
1247 sprintf(s
, msgf
, "password");
1253 for (n
= 0; n
< 50; ++n
) {
1254 sprintf(s
, "rrule%d", n
);
1255 if ((p
= webcgi_get(s
)) != NULL
) {
1256 if (strlen(p
) > 8192) { //Toastman
1257 sprintf(s
, msgf
, s
);
1261 if ((write
) && (!nvram_match(s
, p
))) {
1263 DEBUG_NVRAMSET(s
, p
);
1269 return (write
) ? dirty
: 1;
1272 static void wo_tomato(char *url
)
1281 // _dprintf("tomato.cgi\n");
1283 red
= webcgi_safeget("_redirect", "");
1284 if (!*red
) send_header(200, NULL
, mime_html
, 0);
1286 commit
= atoi(webcgi_safeget("_commit", "1"));
1287 ajax
= atoi(webcgi_safeget("_ajax", "0"));
1289 nvset
= atoi(webcgi_safeget("_nvset", "1"));
1291 if (!save_variables(0)) {
1293 web_printf("@msg:%s", resmsg_get());
1296 parse_asp("error.asp");
1300 commit
= save_variables(1) && commit
;
1302 resmsg_set("Settings saved.");
1305 rboot
= atoi(webcgi_safeget("_reboot", "0"));
1307 parse_asp("reboot.asp");
1311 web_printf("@msg:%s", resmsg_get());
1313 else if (atoi(webcgi_safeget("_moveip", "0"))) {
1314 parse_asp("saved-moved.asp");
1317 parse_asp("saved.asp");
1322 _dprintf("commit from tomato.cgi\n");
1326 if ((v
= webcgi_get("_service")) != NULL
&& *v
!= 0) {
1328 if (ajax
) web_printf(" Some services are being restarted...");
1341 for (i
= atoi(webcgi_safeget("_sleep", "0")); i
> 0; --i
) sleep(1);
1343 if (*red
) redirect(red
);
1353 // ----------------------------------------------------------------------------
1356 static void wo_update(char *url
)
1358 const aspapi_t
*api
;
1364 if ((name
= webcgi_get("exec")) != NULL
) {
1365 for (api
= aspapi
; api
->name
; ++api
) {
1366 if (strcmp(api
->name
, name
) == 0) {
1367 for (argc
= 0; argc
< 16; ++argc
) {
1368 sprintf(s
, "arg%d", argc
);
1369 if ((argv
[argc
] = (char *)webcgi_get(s
)) == NULL
) break;
1371 api
->exec(argc
, argv
);
1378 static void wo_service(char *url
)
1382 exec_service(webcgi_safeget("_service", ""));
1384 if ((n
= atoi(webcgi_safeget("_sleep", "2"))) <= 0) n
= 2;
1390 static void wo_shutdown(char *url
)
1392 parse_asp("shutdown.asp");
1399 static void wo_nvcommit(char *url
)
1401 parse_asp("saved.asp");