Tomato 1.28
[tomato.git] / release / src / router / httpd / upnp.c
blob8a8f8fe020a2cf6ec0909daf28f2b3b98c733911
1 /*
3 Tomato Firmware
4 Copyright (C) 2006-2009 Jonathan Zarate
6 */
8 #include "tomato.h"
10 void asp_upnpinfo(int argc, char **argv)
12 #ifdef USE_MINIUPNPD
13 if (nvram_get_int("upnp_enable")) {
14 f_write_string("/etc/upnp/info", "", 0, 0);
15 if (killall("miniupnpd", SIGUSR2) == 0) {
16 f_wait_notexists("/etc/upnp/info", 5);
19 web_puts("\nmupnp_data = '");
20 web_putfile("/etc/upnp/data.info", WOF_JAVASCRIPT);
21 web_puts("';\n");
23 #else
24 unlink("/var/spool/upnp.js");
25 if (nvram_get_int("upnp_enable") == 1) {
26 if (killall("upnp", SIGUSR2) == 0) {
27 f_wait_exists("/var/spool/upnp.js", 5);
31 web_puts("\nupnp_data = [\n");
32 do_file("/var/spool/upnp.js");
33 web_puts("];\n");
34 unlink("/var/spool/upnp.js");
35 #endif
38 void wo_upnp(char *url)
40 #ifdef USE_MINIUPNPD
41 char s[256];
42 const char *proto;
43 const char *eport;
45 if (nvram_get_int("upnp_enable")) {
46 if (((proto = webcgi_get("remove_proto")) != NULL) && (*proto) &&
47 ((eport = webcgi_get("remove_eport")) != NULL) && (*eport)) {
48 sprintf(s, "%3s %6s\n", proto, eport);
49 f_write_string("/etc/upnp/delete", s, 0, 0);
50 if (killall("miniupnpd", SIGUSR2) == 0) {
51 f_wait_notexists("/etc/upnp/delete", 5);
55 common_redirect();
56 #else
57 char s[256];
58 const char *proto;
59 const char *port;
61 if (nvram_get_int("upnp_enable") == 1) {
62 if (((proto = webcgi_get("remove_proto")) != NULL) && (*proto) &&
63 ((port = webcgi_get("remove_ext_port")) != NULL) && (*port)) {
65 sprintf(s, "%s %s\n", proto, port);
66 f_write_string("/var/spool/upnp.delete", s, 0, 0);
67 if (killall("upnp", SIGUSR2) == 0) {
68 f_wait_notexists("/var/spool/upnp.delete", 5);
72 common_redirect();
73 #endif